@rline/json
Version:
JSON Schema compiler
45 lines (44 loc) • 1.79 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
const _fs = require("@rline/fs");
const _commander = require("commander");
const _path = require("path");
const _process = require("process");
const _init = require("./init");
const _jsoncompiler = require("./json-compiler");
const _schema = require("./schema");
const _tsc = require("./tsc");
/**
* Safe path
*/ const p = (0, _fs.createPathScope)((0, _process.cwd)());
_commander.program.name('json compiler').description('CLI to compile json schemas into a single schema file and typescript types').version('9.4.1');
_commander.program.command('init').name('init').description('Initialize the schema project').action(async ()=>{
await (0, _init.init)((0, _process.cwd)(), (0, _path.join)(__dirname, '../../assets/schema'));
});
_commander.program.command('schema').name('schema').description('Compile json schemas into a single schema').action(async ()=>{
const { main, output, root } = await (0, _jsoncompiler.schemaConfig)((0, _process.cwd)());
await (0, _schema.schema)({
root: p(root),
main: p(root, main),
output: {
schema: p(root, output.schema),
type: ''
}
});
});
_commander.program.command('tsc').name('tsc').description('Compile json schemas into a typescript type').action(async ()=>{
const safepath = (0, _fs.createPathScope)((0, _process.cwd)());
const { output, root } = await (0, _jsoncompiler.schemaConfig)((0, _process.cwd)());
await (0, _tsc.tsc)({
root: safepath(root),
main: safepath(root, output.schema),
output: {
type: safepath(root, output.type),
schema: ''
}
});
});
_commander.program.parse();
//# sourceMappingURL=program.js.map