MCPcopy Index your code
hub / github.com/zenstackhq/zenstack / createProgram

Function createProgram

packages/cli/src/index.ts:54–298  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

52}
53
54function createProgram() {
55 const program = new Command('zen')
56 .alias('zenstack')
57 .helpOption('-h, --help', 'Show this help message')
58 .version(getVersion()!, '-v --version', 'Show CLI version');
59
60 const schemaExtensions = ZModelLanguageMetaData.fileExtensions.join(', ');
61
62 program
63 .description(
64 `${colors.bold.blue(
65 'ζ',
66 )} ZenStack is the modern data layer for TypeScript apps.\n\nDocumentation: https://zenstack.dev/docs`,
67 )
68 .showHelpAfterError()
69 .showSuggestionAfterError();
70
71 const schemaOption = new Option(
72 '--schema <file>',
73 `schema file (with extension ${schemaExtensions}). Defaults to "zenstack/schema.zmodel" unless specified in package.json.`,
74 );
75
76 const noVersionCheckOption = new Option('--no-version-check', 'do not check for new version');
77 const noTipsOption = new Option('--no-tips', 'do not show usage tips');
78
79 const randomPrismaSchemaNameOption = new Option(
80 '--random-prisma-schema-name',
81 'append a random UUID to the temporary Prisma schema filename (e.g., ~schema.<uuid>.prisma) to avoid collisions between concurrent runs sharing a working directory',
82 ).default(false);
83
84 program
85 .command('generate')
86 .description('Run code generation plugins')
87 .addOption(schemaOption)
88 .addOption(noVersionCheckOption)
89 .addOption(noTipsOption)
90 .addOption(new Option('-o, --output <path>', 'default output directory for code generation'))
91 .addOption(new Option('-w, --watch', 'enable watch mode').default(false))
92 .addOption(
93 triStateBooleanOption(
94 '--lite [boolean]',
95 'also generate a lite version of schema without attributes, defaults to false',
96 ),
97 )
98 .addOption(
99 triStateBooleanOption(
100 '--lite-only [boolean]',
101 'only generate lite version of schema without attributes, defaults to false',
102 ),
103 )
104 .addOption(triStateBooleanOption('--generate-models [boolean]', 'generate models.ts file, defaults to true'))
105 .addOption(triStateBooleanOption('--generate-input [boolean]', 'generate input.ts file, defaults to true'))
106 .addOption(new Option('--silent', 'suppress all output except errors').default(false))
107 .action(generateAction);
108
109 const migrateCommand = program.command('migrate').description('Run database schema migration related tasks.');
110 const migrationsOption = new Option('--migrations <path>', 'path that contains the "migrations" directory');
111

Callers 1

mainFunction · 0.85

Calls 8

getVersionFunction · 0.90
checkNewVersionFunction · 0.90
triStateBooleanOptionFunction · 0.85
migrateActionFunction · 0.85
dbActionFunction · 0.85
seedActionFunction · 0.85
argumentMethod · 0.80
descriptionMethod · 0.45

Tested by

no test coverage detected