Prepare for command-line schem compiler tool
This commit is contained in:
parent
447380218e
commit
8187337187
|
@ -0,0 +1,3 @@
|
|||
#!/usr/bin/env node
|
||||
require('../dist/bin/preserves-schema-ts.js').main(process.argv.slice(2));
|
||||
|
|
@ -30,5 +30,8 @@
|
|||
"veryclean": "npm run clean && rm -rf node_modules",
|
||||
"watch": "npx tsc -w"
|
||||
},
|
||||
"bin": {
|
||||
"preserves-schema-ts": "./bin/preserves-schema-ts.js"
|
||||
},
|
||||
"dependencies": {}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ function es6(insertion, extra) {
|
|||
};
|
||||
}
|
||||
|
||||
export default {
|
||||
export default [{
|
||||
input: 'lib/index.js',
|
||||
output: [
|
||||
umd(''),
|
||||
|
@ -31,4 +31,15 @@ export default {
|
|||
es6(''),
|
||||
es6('.min', { plugins: [terser()] }),
|
||||
],
|
||||
}
|
||||
}, {
|
||||
input: 'lib/bin/preserves-schema-ts.js',
|
||||
output: [{
|
||||
file: 'dist/bin/preserves-schema-ts.js',
|
||||
format: 'umd',
|
||||
name: 'PreservesC_TS',
|
||||
globals: {
|
||||
'fs': 'fs',
|
||||
},
|
||||
}],
|
||||
external: ['fs'],
|
||||
}]
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
import { BASE, compile, readSchema } from '../schema/index';
|
||||
import fs from 'fs';
|
||||
|
||||
export function main(argv: Array<string>) {
|
||||
console.log('// ' + JSON.stringify(argv));
|
||||
const src = fs.readFileSync(__dirname + '/../../../../schema/schema.txt', 'utf-8');
|
||||
const sch = readSchema(src);
|
||||
console.log(compile(
|
||||
[{ moduleName: 'BASE', modulePath: 'BASE', schema: BASE, inline: true }],
|
||||
sch,
|
||||
'..'));
|
||||
}
|
|
@ -1,21 +1,6 @@
|
|||
export * from './annotated';
|
||||
export * from './bytes';
|
||||
export * from './codec';
|
||||
export * from './decoder';
|
||||
export * from './dictionary';
|
||||
export * from './encoder';
|
||||
export * from './flex';
|
||||
export * from './float';
|
||||
export * from './fold';
|
||||
export * from './fromjs';
|
||||
export * from './is';
|
||||
export * from './reader';
|
||||
export * from './record';
|
||||
export * from './strip';
|
||||
export * from './symbols';
|
||||
export * from './text';
|
||||
export * from './values';
|
||||
export * from './runtime';
|
||||
export * as Constants from './constants';
|
||||
export * as Schema from './schema/index';
|
||||
|
||||
const _Array = Array;
|
||||
type _Array<T> = Array<T>;
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
export * from './annotated';
|
||||
export * from './bytes';
|
||||
export * from './codec';
|
||||
export * from './decoder';
|
||||
export * from './dictionary';
|
||||
export * from './encoder';
|
||||
export * from './flex';
|
||||
export * from './float';
|
||||
export * from './fold';
|
||||
export * from './fromjs';
|
||||
export * from './is';
|
||||
export * from './reader';
|
||||
export * from './record';
|
||||
export * from './strip';
|
||||
export * from './symbols';
|
||||
export * from './text';
|
||||
export * from './values';
|
|
@ -1,4 +1,4 @@
|
|||
import { Record, KeyedDictionary } from '..';
|
||||
import { Record, KeyedDictionary } from '../runtime';
|
||||
import { AtomKind, Pattern, Schema } from './meta';
|
||||
import * as M from './meta';
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Pattern, NamedPattern, Schema, Input } from "./meta";
|
||||
import * as M from './meta';
|
||||
import { Annotated, Bytes, Dictionary, Fold, fold, preserves, Record, Tuple, Value } from "..";
|
||||
import { Annotated, Bytes, Dictionary, Fold, fold, preserves, Record, Tuple, Value } from "../runtime";
|
||||
import { Formatter, parens, seq, Item, opseq, block, commas, brackets, anglebrackets, braces } from "./block";
|
||||
|
||||
function fnblock(... items: Item[]): Item {
|
||||
|
@ -302,14 +302,3 @@ export function sourceCodeFor(v: Value<any>): Item {
|
|||
},
|
||||
});
|
||||
}
|
||||
|
||||
import fs from 'fs';
|
||||
import { readSchema } from "./reader";
|
||||
import { BASE } from "./base";
|
||||
function main() {
|
||||
const src = fs.readFileSync(__dirname + '/../../../../schema/schema.txt', 'utf-8');
|
||||
const sch = readSchema(src);
|
||||
console.log(compile([{ moduleName: 'BASE', modulePath: 'BASE', schema: BASE, inline: true }], sch, '..'));
|
||||
}
|
||||
|
||||
main();
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
export * from './reader';
|
||||
export * from './compiler';
|
||||
export * from './base';
|
|
@ -1,6 +1,6 @@
|
|||
import { Environment, Pattern, NamedPattern, lookup } from "./meta";
|
||||
import * as M from './meta';
|
||||
import { Value, Float, Bytes, is, isPointer, Record, Dictionary, Set } from "..";
|
||||
import { Value, Float, Bytes, is, isPointer, Record, Dictionary, Set } from "../runtime";
|
||||
|
||||
export function validator(env: Environment, p: Pattern): (v: Value<any>) => boolean {
|
||||
function walk(p: Pattern, v: Value<any>, recordOkAsTuple = false): boolean {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Dictionary, KeyedDictionary, Record, Value, preserves } from '..';
|
||||
import { Dictionary, KeyedDictionary, Record, Value, preserves } from '../runtime';
|
||||
|
||||
export type Input = Value<never>;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Annotated, Dictionary, is, KeyedDictionary, peel, preserves, Record, strip, Tuple } from '..';
|
||||
import { Annotated, Dictionary, is, KeyedDictionary, peel, preserves, Record, strip, Tuple } from '../runtime';
|
||||
|
||||
import { Input, NamedPattern, Pattern, Schema } from './meta';
|
||||
import * as M from './meta';
|
||||
|
|
Loading…
Reference in New Issue