11import { invariant , singleDebounce } from '@zenstackhq/common-helpers' ;
22import { ZModelLanguageMetaData } from '@zenstackhq/language' ;
3- import { type AbstractDeclaration , isPlugin , LiteralExpr , Plugin , type Model } from '@zenstackhq/language/ast' ;
3+ import { isPlugin , LiteralExpr , Plugin , type AbstractDeclaration , type Model } from '@zenstackhq/language/ast' ;
44import { getLiteral , getLiteralArray } from '@zenstackhq/language/utils' ;
55import { type CliPlugin } from '@zenstackhq/sdk' ;
6+ import { watch } from 'chokidar' ;
67import colors from 'colors' ;
78import { createJiti } from 'jiti' ;
89import fs from 'node:fs' ;
910import path from 'node:path' ;
1011import { pathToFileURL } from 'node:url' ;
11- import { watch } from 'chokidar' ;
1212import ora , { type Ora } from 'ora' ;
13+ import semver from 'semver' ;
1314import { CliError } from '../cli-error' ;
1415import * as corePlugins from '../plugins' ;
15- import { getOutputPath , getSchemaFile , getZenStackPackages , loadSchemaDocument } from './action-utils' ;
16- import semver from 'semver' ;
16+ import {
17+ getOutputPath ,
18+ getSchemaFile ,
19+ getZenStackPackages ,
20+ loadSchemaDocument ,
21+ startUsageTipsFetch ,
22+ } from './action-utils' ;
1723
1824type Options = {
1925 schema ?: string ;
2026 output ?: string ;
2127 silent : boolean ;
2228 watch : boolean ;
23- lite : boolean ;
24- liteOnly : boolean ;
29+ lite ?: boolean ;
30+ liteOnly ?: boolean ;
31+ generateModels ?: boolean ;
32+ generateInput ?: boolean ;
33+ tips ?: boolean ;
2534} ;
2635
2736/**
@@ -33,8 +42,13 @@ export async function run(options: Options) {
3342 } catch ( err ) {
3443 console . warn ( colors . yellow ( `Failed to check for mismatched ZenStack packages: ${ err } ` ) ) ;
3544 }
45+
46+ const maybeShowUsageTips = options . tips && ! options . silent && ! options . watch ? startUsageTipsFetch ( ) : undefined ;
47+
3648 const model = await pureGenerate ( options , false ) ;
3749
50+ await maybeShowUsageTips ?.( ) ;
51+
3852 if ( options . watch ) {
3953 const logsEnabled = ! options . silent ;
4054
@@ -181,12 +195,18 @@ async function runPlugins(schemaFile: string, model: Model, outputPath: string,
181195
182196 // merge CLI options
183197 if ( provider === '@core/typescript' ) {
184- if ( pluginOptions [ ' lite' ] = == undefined ) {
198+ if ( options . lite ! == undefined ) {
185199 pluginOptions [ 'lite' ] = options . lite ;
186200 }
187- if ( pluginOptions [ ' liteOnly' ] = == undefined ) {
201+ if ( options . liteOnly ! == undefined ) {
188202 pluginOptions [ 'liteOnly' ] = options . liteOnly ;
189203 }
204+ if ( options . generateModels !== undefined ) {
205+ pluginOptions [ 'generateModels' ] = options . generateModels ;
206+ }
207+ if ( options . generateInput !== undefined ) {
208+ pluginOptions [ 'generateInput' ] = options . generateInput ;
209+ }
190210 }
191211
192212 processedPlugins . push ( { cliPlugin, pluginOptions } ) ;
@@ -196,7 +216,12 @@ async function runPlugins(schemaFile: string, model: Model, outputPath: string,
196216 const defaultPlugins = [
197217 {
198218 plugin : corePlugins [ 'typescript' ] ,
199- options : { lite : options . lite , liteOnly : options . liteOnly } ,
219+ options : {
220+ lite : options . lite ,
221+ liteOnly : options . liteOnly ,
222+ generateModels : options . generateModels ,
223+ generateInput : options . generateInput ,
224+ } ,
200225 } ,
201226 ] ;
202227 defaultPlugins . forEach ( ( { plugin, options } ) => {
0 commit comments