2018-07-08 04:37:28 +03:00
|
|
|
#!/usr/bin/env node
|
|
|
|
const child_process = require('child_process')
|
|
|
|
|
|
|
|
// Convert the file-format-spec.ts file into a json schema file
|
|
|
|
let jsonSchema = child_process.execSync(
|
2020-05-24 02:07:38 +03:00
|
|
|
'node_modules/.bin/typescript-json-schema ./src/lib/file-format-spec.ts --titles --required --topRef "*"',
|
2018-07-08 04:37:28 +03:00
|
|
|
{
|
|
|
|
encoding: 'utf8',
|
|
|
|
},
|
|
|
|
)
|
|
|
|
jsonSchema = JSON.parse(jsonSchema)
|
2018-08-14 19:37:42 +03:00
|
|
|
|
|
|
|
if (!jsonSchema.definitions['FileFormat.File']) {
|
|
|
|
console.error('SCHEMA GENERATION FAILURE: Could not find FileFormat.File in the definitions list')
|
|
|
|
console.error(jsonSchema)
|
|
|
|
process.exit(1)
|
|
|
|
}
|
|
|
|
|
2018-07-08 04:37:28 +03:00
|
|
|
jsonSchema['$ref'] = '#/definitions/FileFormat.File'
|
|
|
|
console.log(JSON.stringify(jsonSchema, null, 4))
|