(options: Options, fromWatch: boolean)
| 141 | } |
| 142 | |
| 143 | async 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 |
| 160 | import { ZenStackClient } from '@zenstackhq/orm'; |
| 161 | import { schema } from '${path.relative('.', outputPath)}/schema'; |
| 162 | |
| 163 | const client = new ZenStackClient(schema, { |
| 164 | dialect: { ... } |
| 165 | }); |
| 166 | \`\`\` |
| 167 | |
| 168 | Check documentation: https://zenstack.dev/docs/`); |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | return model; |
| 173 | } |
| 174 | |
| 175 | async function runPlugins(schemaFile: string, model: Model, outputPath: string, options: Options) { |
| 176 | const plugins = model.declarations.filter(isPlugin); |
no test coverage detected