Skip to content

Commit ad82430

Browse files
committed
chore: change "--offline" option to "--no-tips"
1 parent 0db99f0 commit ad82430

3 files changed

Lines changed: 22 additions & 18 deletions

File tree

packages/cli/src/actions/action-utils.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -222,17 +222,17 @@ export async function getZenStackPackages(
222222
const FETCH_CLI_MAX_TIME = 1000;
223223
const CLI_CONFIG_ENDPOINT = 'https://zenstack.dev/config/cli-v3.json';
224224

225-
const notificationSchema = z.object({
225+
const usageTipsSchema = z.object({
226226
notifications: z.array(z.object({ title: z.string(), url: z.url().optional(), active: z.boolean() })),
227227
});
228228

229229
/**
230-
* Starts the notification fetch in the background. Returns a callback that,
231-
* when invoked check if the fetch is complete. If not complete, it will wait until the max time is reached.
232-
* After that, if fetch is still not complete, just return.
230+
* Starts the usage tips fetch in the background. Returns a callback that, when invoked check if the fetch
231+
* is complete. If not complete, it will wait until the max time is reached. After that, if fetch is still
232+
* not complete, just return.
233233
*/
234-
export function startNotificationFetch() {
235-
let fetchedData: z.infer<typeof notificationSchema> | undefined = undefined;
234+
export function startUsageTipsFetch() {
235+
let fetchedData: z.infer<typeof usageTipsSchema> | undefined = undefined;
236236
let fetchComplete = false;
237237

238238
const start = Date.now();
@@ -245,7 +245,7 @@ export function startNotificationFetch() {
245245
.then(async (res) => {
246246
if (!res.ok) return;
247247
const data = await res.json();
248-
const parseResult = notificationSchema.safeParse(data);
248+
const parseResult = usageTipsSchema.safeParse(data);
249249
if (parseResult.success) {
250250
fetchedData = parseResult.data;
251251
}

packages/cli/src/actions/generate.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
import { invariant, singleDebounce } from '@zenstackhq/common-helpers';
22
import { 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';
44
import { getLiteral, getLiteralArray } from '@zenstackhq/language/utils';
55
import { type CliPlugin } from '@zenstackhq/sdk';
6+
import { watch } from 'chokidar';
67
import colors from 'colors';
78
import { createJiti } from 'jiti';
89
import fs from 'node:fs';
910
import path from 'node:path';
1011
import { pathToFileURL } from 'node:url';
11-
import { watch } from 'chokidar';
1212
import ora, { type Ora } from 'ora';
13+
import semver from 'semver';
1314
import { CliError } from '../cli-error';
1415
import * as corePlugins from '../plugins';
15-
import { getOutputPath, getSchemaFile, getZenStackPackages, loadSchemaDocument } from './action-utils';
16-
import semver from 'semver';
17-
import { startNotificationFetch } from './action-utils';
16+
import {
17+
getOutputPath,
18+
getSchemaFile,
19+
getZenStackPackages,
20+
loadSchemaDocument,
21+
startUsageTipsFetch,
22+
} from './action-utils';
1823

1924
type Options = {
2025
schema?: string;
@@ -25,7 +30,7 @@ type Options = {
2530
liteOnly?: boolean;
2631
generateModels?: boolean;
2732
generateInput?: boolean;
28-
offline?: boolean;
33+
tips?: boolean;
2934
};
3035

3136
/**
@@ -38,12 +43,11 @@ export async function run(options: Options) {
3843
console.warn(colors.yellow(`Failed to check for mismatched ZenStack packages: ${err}`));
3944
}
4045

41-
const maybeShowNotification =
42-
!options.offline && !options.silent && !options.watch ? startNotificationFetch() : undefined;
46+
const maybeShowUsageTips = options.tips && !options.silent && !options.watch ? startUsageTipsFetch() : undefined;
4347

4448
const model = await pureGenerate(options, false);
4549

46-
await maybeShowNotification?.();
50+
await maybeShowUsageTips?.();
4751

4852
if (options.watch) {
4953
const logsEnabled = !options.silent;

packages/cli/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,14 @@ function createProgram() {
7474
);
7575

7676
const noVersionCheckOption = new Option('--no-version-check', 'do not check for new version');
77-
const offlineOption = new Option('--offline', 'run in offline mode');
77+
const noTipsOption = new Option('--no-tips', 'do not show usage tips');
7878

7979
program
8080
.command('generate')
8181
.description('Run code generation plugins')
8282
.addOption(schemaOption)
8383
.addOption(noVersionCheckOption)
84-
.addOption(offlineOption)
84+
.addOption(noTipsOption)
8585
.addOption(new Option('-o, --output <path>', 'default output directory for code generation'))
8686
.addOption(new Option('-w, --watch', 'enable watch mode').default(false))
8787
.addOption(

0 commit comments

Comments
 (0)