Split out @preserves/schema-cli from @preserves/schema

This commit is contained in:
Tony Garnock-Jones 2023-10-19 02:27:01 +02:00
parent 4e471ed896
commit 01d3659216
16 changed files with 89 additions and 29 deletions

View File

@ -0,0 +1,2 @@
dist/
lib/

View File

@ -0,0 +1 @@
version-tag-prefix javascript-@preserves/schema-cli@

View File

@ -0,0 +1 @@
# Preserves Schema for TypeScript/JavaScript: Command-line tools

View File

@ -0,0 +1,39 @@
{
"name": "@preserves/schema-cli",
"version": "0.990.1",
"description": "Command-line tools for Preserves Schema",
"homepage": "https://gitlab.com/preserves/preserves",
"license": "Apache-2.0",
"publishConfig": {
"access": "public"
},
"repository": "gitlab:preserves/preserves",
"author": "Tony Garnock-Jones <tonyg@leastfixedpoint.com>",
"scripts": {
"clean": "rm -rf lib dist",
"prepare": "yarn compile && yarn rollup",
"compile": "tsc",
"compile:watch": "yarn compile -w",
"rollup": "rollup -c",
"rollup:watch": "yarn rollup -w",
"test": "true",
"veryclean": "yarn run clean && rm -rf node_modules"
},
"bin": {
"preserves-schema-ts": "./bin/preserves-schema-ts.js",
"preserves-schemac": "./bin/preserves-schemac.js"
},
"devDependencies": {
"@types/glob": "^7.1",
"@types/minimatch": "^3.0"
},
"dependencies": {
"@preserves/core": "^0.990.0",
"@preserves/schema": "^0.990.1",
"chalk": "^4.1",
"chokidar": "^3.5",
"commander": "^7.2",
"glob": "^7.1",
"minimatch": "^3.0"
}
}

View File

@ -0,0 +1,17 @@
import terser from '@rollup/plugin-terser';
function cli(name) {
return {
input: `lib/bin/${name}.js`,
output: [{file: `dist/bin/${name}.js`, format: 'commonjs'}],
external: [
'@preserves/core',
'@preserves/schema',
],
};
}
export default [
cli('preserves-schema-ts'),
cli('preserves-schemac'),
];

View File

@ -1,10 +1,9 @@
import fs from 'fs';
import path from 'path';
import { glob } from 'glob';
import { IdentitySet, formatPosition, Position } from '@preserves/core';
import { readSchema } from '../reader';
import chalk from 'chalk';
import * as M from '../meta';
import { IdentitySet, formatPosition, Position } from '@preserves/core';
import { readSchema, Meta as M } from '@preserves/schema';
export interface Diagnostic {
type: 'warn' | 'error';

View File

@ -1,9 +1,8 @@
import { compile } from '../index';
import fs from 'fs';
import path from 'path';
import minimatch from 'minimatch';
import { Command } from 'commander';
import * as M from '../meta';
import { compile, Meta as M } from '@preserves/schema';
import chalk from 'chalk';
import { is, Position } from '@preserves/core';
import chokidar from 'chokidar';

View File

@ -2,7 +2,7 @@ import { Command } from 'commander';
import { canonicalEncode, KeyedDictionary, underlying } from '@preserves/core';
import fs from 'fs';
import path from 'path';
import * as M from '../meta';
import { Meta as M } from '@preserves/schema';
import { expandInputGlob, formatFailures } from './cli-utils';
export type CommandLineArguments = {

View File

@ -0,0 +1,16 @@
{
"compilerOptions": {
"target": "ES2017",
"lib": ["es2019", "DOM"],
"declaration": true,
"baseUrl": "./src",
"rootDir": "./src",
"outDir": "./lib",
"declarationDir": "./lib",
"esModuleInterop": true,
"moduleResolution": "node",
"sourceMap": true,
"strict": true
},
"include": ["src/**/*"]
}

View File

@ -2,3 +2,7 @@
This is an implementation of [Preserves Schema](https://preserves.dev/preserves-schema.html)
for TypeScript and JavaScript.
This package implements a Schema runtime and a Schema-to-TypeScript compiler, but offers no
command line interfaces. See `@preserves/schema-cli` for command-line tools for working with
Schema and compiling from Schema to TypeScript.

View File

@ -1,6 +1,6 @@
{
"name": "@preserves/schema",
"version": "0.990.0",
"version": "0.990.1",
"description": "Schema support for Preserves data serialization format",
"homepage": "https://gitlab.com/preserves/preserves",
"license": "Apache-2.0",
@ -13,7 +13,7 @@
"types": "lib/index.d.ts",
"author": "Tony Garnock-Jones <tonyg@leastfixedpoint.com>",
"scripts": {
"regenerate": "rm -rf ./src/gen && yarn copy-schema && ./bin/preserves-schema-ts.js --output ./src/gen ./dist:schema.prs",
"regenerate": "rm -rf ./src/gen && yarn copy-schema && ../schema-cli/bin/preserves-schema-ts.js --output ./src/gen ./dist:schema.prs",
"clean": "rm -rf lib dist",
"prepare": "yarn compile && yarn rollup && yarn copy-schema",
"compile": "tsc",
@ -25,18 +25,7 @@
"test:watch": "jest --watch",
"veryclean": "yarn run clean && rm -rf node_modules"
},
"bin": {
"preserves-schema-ts": "./bin/preserves-schema-ts.js",
"preserves-schemac": "./bin/preserves-schemac.js"
},
"dependencies": {
"@preserves/core": "^0.990.0",
"@types/glob": "^7.1",
"@types/minimatch": "^3.0",
"chalk": "^4.1",
"chokidar": "^3.5",
"commander": "^7.2",
"glob": "^7.1",
"minimatch": "^3.0"
"@preserves/core": "^0.990.0"
}
}

View File

@ -31,13 +31,6 @@ function cli(name) {
output: [{file: `dist/bin/${name}.js`, format: 'commonjs'}],
external: [
'@preserves/core',
'chalk',
'chokidar',
'fs',
'glob',
'minimatch',
'path',
'commander',
],
};
}
@ -53,6 +46,4 @@ export default [
],
external: ['@preserves/core'],
},
cli('preserves-schema-ts'),
cli('preserves-schemac'),
];

View File

@ -20,5 +20,7 @@ open "cd packages/core; yarn run test:watch"
open "cd packages/schema; yarn run compile:watch"
open "cd packages/schema; yarn run rollup:watch"
open "cd packages/schema; yarn run test:watch"
open "cd packages/schema-cli; yarn run compile:watch"
open "cd packages/schema-cli; yarn run rollup:watch"
tmux select-layout even-vertical