import { CommandModule } from 'yargs'; import { generate } from './generate'; import { PublishSchemaToDbOptions } from './publish-schema-to-db-options'; export const publishSchemaToDb: CommandModule< unknown, PublishSchemaToDbOptions > = { command: 'publish-schema-to-db', describe: 'Tool to generate the initial database schema for a catalog-like service from publish format definitions.', builder: (yargs) => yargs .option('inputGlob', { // This should be a positional but making it required does not work. alias: 'i', describe: 'Glob pattern matching the publish format schemas to be used for code generation.', type: 'string', demandOption: true, }) .option('idKey', { alias: 'k', describe: 'Key containing the published ID of a content entity.', type: 'string', default: 'content_id', }) .option('ignoredProperties', { alias: 'n', describe: 'List of schema keys to ignore.', type: 'array', default: ['$schema', 'related_items', 'genres'], }) .option('dbSchema', { alias: 's', describe: 'Name of the DB schema for SQL generation.', type: 'string', default: 'app_public', }) .option('outputRoot', { alias: 'o', describe: 'Path to the catalog service directory.', type: 'string', demandOption: true, }), handler: async (argv) => { await generate(argv); }, };