MCPcopy Create free account
hub / github.com/zenstackhq/zenstack / pureGenerate

Function pureGenerate

packages/cli/src/actions/generate.ts:143–173  ·  view source on GitHub ↗
(options: Options, fromWatch: boolean)

Source from the content-addressed store, hash-verified

141}
142
143async function pureGenerate(options: Options, fromWatch: boolean) {
144 const start = Date.now();
145
146 const schemaFile = getSchemaFile(options.schema);
147
148 const model = await loadSchemaDocument(schemaFile);
149 const outputPath = getOutputPath(options, schemaFile);
150
151 await runPlugins(schemaFile, model, outputPath, options);
152
153 if (!options.silent) {
154 console.log(colors.green(`Generation completed successfully in ${Date.now() - start}ms.\n`));
155
156 if (!fromWatch) {
157 console.log(`You can now create a ZenStack client with it.
158
159\`\`\`ts
160import { ZenStackClient } from '@zenstackhq/orm';
161import { schema } from '${path.relative('.', outputPath)}/schema';
162
163const client = new ZenStackClient(schema, {
164 dialect: { ... }
165});
166\`\`\`
167
168Check documentation: https://zenstack.dev/docs/`);
169 }
170 }
171
172 return model;
173}
174
175async function runPlugins(schemaFile: string, model: Model, outputPath: string, options: Options) {
176 const plugins = model.declarations.filter(isPlugin);

Callers 1

runFunction · 0.85

Calls 5

getSchemaFileFunction · 0.90
loadSchemaDocumentFunction · 0.90
getOutputPathFunction · 0.90
runPluginsFunction · 0.85
logMethod · 0.65

Tested by

no test coverage detected