mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-16 02:24:10 +08:00
This is the same code we used before, but: 1. its in a separate package, 2. it also support new serialization to .d.ts, 3. OneOf is now supported entirely (instead of the previous hack). Also, removed the schema.d.ts file and generate it before building the package. It is not git ignored and changing it will not work (it will be overwritten).
29 lines
780 B
JavaScript
29 lines
780 B
JavaScript
#!/usr/bin/env node
|
|
'use strict';
|
|
|
|
const fs = require('fs');
|
|
const minimist = require('minimist');
|
|
|
|
// Load the bootstrap.
|
|
require('../lib/bootstrap-local');
|
|
const SchemaClassFactory = require('@ngtools/json-schema').SchemaClassFactory;
|
|
|
|
const argv = minimist(process.argv.slice(2));
|
|
const inFile = argv._[0];
|
|
const outFile = argv._[1];
|
|
|
|
if (!inFile) {
|
|
process.stderr.write('Need to pass in an input file.\n');
|
|
process.exit(1);
|
|
}
|
|
const jsonSchema = JSON.parse(fs.readFileSync(inFile, 'utf-8'));
|
|
const SchemaClass = SchemaClassFactory(jsonSchema);
|
|
const schemaInstance = new SchemaClass();
|
|
const serialized = schemaInstance.$$serialize('text/x.dts', 'CliConfig');
|
|
|
|
if (outFile) {
|
|
fs.writeFileSync(outFile, serialized, 'utf-8');
|
|
} else {
|
|
process.stdout.write(serialized);
|
|
}
|