Skip to content

Commit 32691ce

Browse files
authored
Merge pull request #188 from zenstackhq/dev
merge dev to main
2 parents c5660c5 + bca8ee8 commit 32691ce

File tree

29 files changed

+55
-138
lines changed

29 files changed

+55
-138
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "zenstack-v3",
3-
"version": "3.0.0-alpha.27",
3+
"version": "3.0.0-alpha.28",
44
"description": "ZenStack",
55
"packageManager": "[email protected]",
66
"scripts": {

packages/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"publisher": "zenstack",
44
"displayName": "ZenStack CLI",
55
"description": "FullStack database toolkit with built-in access control and automatic API generation.",
6-
"version": "3.0.0-alpha.27",
6+
"version": "3.0.0-alpha.28",
77
"type": "module",
88
"author": {
99
"name": "ZenStack Team"

packages/cli/src/actions/validate.ts renamed to packages/cli/src/actions/check.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ type Options = {
66
};
77

88
/**
9-
* CLI action for validating schema without generation
9+
* CLI action for checking a schema's validity.
1010
*/
1111
export async function run(options: Options) {
1212
const schemaFile = getSchemaFile(options.schema);

packages/cli/src/actions/generate.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { getPkgJsonConfig, getSchemaFile, loadSchemaDocument } from './action-ut
1212
type Options = {
1313
schema?: string;
1414
output?: string;
15-
silent?: boolean;
1615
};
1716

1817
/**
@@ -28,9 +27,8 @@ export async function run(options: Options) {
2827

2928
await runPlugins(schemaFile, model, outputPath);
3029

31-
if (!options.silent) {
32-
console.log(colors.green(`Generation completed successfully in ${Date.now() - start}ms.\n`));
33-
console.log(`You can now create a ZenStack client with it.
30+
console.log(colors.green(`Generation completed successfully in ${Date.now() - start}ms.\n`));
31+
console.log(`You can now create a ZenStack client with it.
3432
3533
\`\`\`ts
3634
import { ZenStackClient } from '@zenstackhq/runtime';
@@ -40,7 +38,6 @@ const client = new ZenStackClient(schema, {
4038
dialect: { ... }
4139
});
4240
\`\`\``);
43-
}
4441
}
4542

4643
function getOutputPath(options: Options, schemaFile: string) {

packages/cli/src/actions/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ import { run as generate } from './generate';
33
import { run as info } from './info';
44
import { run as init } from './init';
55
import { run as migrate } from './migrate';
6-
import { run as validate } from './validate';
6+
import { run as check } from './check';
77

8-
export { db, generate, info, init, migrate, validate };
8+
export { db, generate, info, init, migrate, check };

packages/cli/src/index.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ const initAction = async (projectPath: string): Promise<void> => {
2525
await actions.init(projectPath);
2626
};
2727

28-
const validateAction = async (options: Parameters<typeof actions.validate>[0]): Promise<void> => {
29-
await actions.validate(options);
28+
const checkAction = async (options: Parameters<typeof actions.check>[0]): Promise<void> => {
29+
await actions.check(options);
3030
};
3131

3232
export function createProgram() {
@@ -40,26 +40,25 @@ export function createProgram() {
4040
.description(
4141
`${colors.bold.blue(
4242
'ζ',
43-
)} ZenStack is a database access toolkit for TypeScript apps.\n\nDocumentation: https://zenstack.dev.`,
43+
)} ZenStack is the data layer for modern TypeScript apps.\n\nDocumentation: https://zenstack.dev.`,
4444
)
4545
.showHelpAfterError()
4646
.showSuggestionAfterError();
4747

4848
const schemaOption = new Option(
4949
'--schema <file>',
50-
`schema file (with extension ${schemaExtensions}). Defaults to "schema.zmodel" unless specified in package.json.`,
50+
`schema file (with extension ${schemaExtensions}). Defaults to "zenstack/schema.zmodel" unless specified in package.json.`,
5151
);
5252

5353
program
5454
.command('generate')
55-
.description('Run code generation.')
55+
.description('Run code generation plugins.')
5656
.addOption(schemaOption)
57-
.addOption(new Option('--silent', 'do not print any output'))
58-
.addOption(new Option('-o, --output <path>', 'default output directory for core plugins'))
57+
.addOption(new Option('-o, --output <path>', 'default output directory for code generation'))
5958
.action(generateAction);
6059

61-
const migrateCommand = program.command('migrate').description('Update the database schema with migrations.');
62-
const migrationsOption = new Option('--migrations <path>', 'path for migrations');
60+
const migrateCommand = program.command('migrate').description('Run database schema migration related tasks.');
61+
const migrationsOption = new Option('--migrations <path>', 'path that contains the "migrations" directory');
6362

6463
migrateCommand
6564
.command('dev')
@@ -98,22 +97,22 @@ export function createProgram() {
9897
.addOption(migrationsOption)
9998
.addOption(new Option('--applied <migration>', 'record a specific migration as applied'))
10099
.addOption(new Option('--rolled-back <migration>', 'record a specific migration as rolled back'))
101-
.description('Resolve issues with database migrations in deployment databases')
100+
.description('Resolve issues with database migrations in deployment databases.')
102101
.action((options) => migrateAction('resolve', options));
103102

104103
const dbCommand = program.command('db').description('Manage your database schema during development.');
105104

106105
dbCommand
107106
.command('push')
108-
.description('Push the state from your schema to your database')
107+
.description('Push the state from your schema to your database.')
109108
.addOption(schemaOption)
110109
.addOption(new Option('--accept-data-loss', 'ignore data loss warnings'))
111110
.addOption(new Option('--force-reset', 'force a reset of the database before push'))
112111
.action((options) => dbAction('push', options));
113112

114113
program
115114
.command('info')
116-
.description('Get information of installed ZenStack and related packages.')
115+
.description('Get information of installed ZenStack packages.')
117116
.argument('[path]', 'project path', '.')
118117
.action(infoAction);
119118

@@ -123,7 +122,11 @@ export function createProgram() {
123122
.argument('[path]', 'project path', '.')
124123
.action(initAction);
125124

126-
program.command('validate').description('Validate a ZModel schema.').addOption(schemaOption).action(validateAction);
125+
program
126+
.command('check')
127+
.description('Check a ZModel schema for syntax or semantic errors.')
128+
.addOption(schemaOption)
129+
.action(checkAction);
127130

128131
return program;
129132
}

packages/cli/test/validate.test.ts renamed to packages/cli/test/check.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,29 +40,29 @@ describe('CLI validate command test', () => {
4040
const workDir = createProject(validModel);
4141

4242
// Should not throw an error
43-
expect(() => runCli('validate', workDir)).not.toThrow();
43+
expect(() => runCli('check', workDir)).not.toThrow();
4444
});
4545

4646
it('should fail validation for invalid schema', () => {
4747
const workDir = createProject(invalidModel);
4848

4949
// Should throw an error due to validation failure
50-
expect(() => runCli('validate', workDir)).toThrow();
50+
expect(() => runCli('check', workDir)).toThrow();
5151
});
5252

5353
it('should respect custom schema location', () => {
5454
const workDir = createProject(validModel);
5555
fs.renameSync(path.join(workDir, 'zenstack/schema.zmodel'), path.join(workDir, 'zenstack/custom.zmodel'));
5656

5757
// Should not throw an error when using custom schema path
58-
expect(() => runCli('validate --schema ./zenstack/custom.zmodel', workDir)).not.toThrow();
58+
expect(() => runCli('check --schema ./zenstack/custom.zmodel', workDir)).not.toThrow();
5959
});
6060

6161
it('should fail when schema file does not exist', () => {
6262
const workDir = createProject(validModel);
6363

6464
// Should throw an error when schema file doesn't exist
65-
expect(() => runCli('validate --schema ./nonexistent.zmodel', workDir)).toThrow();
65+
expect(() => runCli('check --schema ./nonexistent.zmodel', workDir)).toThrow();
6666
});
6767

6868
it('should respect package.json config', () => {
@@ -78,7 +78,7 @@ describe('CLI validate command test', () => {
7878
fs.writeFileSync(path.join(workDir, 'package.json'), JSON.stringify(pkgJson, null, 2));
7979

8080
// Should not throw an error when using package.json config
81-
expect(() => runCli('validate', workDir)).not.toThrow();
81+
expect(() => runCli('check', workDir)).not.toThrow();
8282
});
8383

8484
it('should validate schema with syntax errors', () => {
@@ -96,6 +96,6 @@ model User {
9696
const workDir = createProject(modelWithSyntaxError, false);
9797

9898
// Should throw an error due to syntax error
99-
expect(() => runCli('validate', workDir)).toThrow();
99+
expect(() => runCli('check', workDir)).toThrow();
100100
});
101101
});

packages/common-helpers/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@zenstackhq/common-helpers",
3-
"version": "3.0.0-alpha.27",
3+
"version": "3.0.0-alpha.28",
44
"description": "ZenStack Common Helpers",
55
"type": "module",
66
"scripts": {

packages/create-zenstack/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "create-zenstack",
3-
"version": "3.0.0-alpha.27",
3+
"version": "3.0.0-alpha.28",
44
"description": "Create a new ZenStack project",
55
"type": "module",
66
"scripts": {

packages/dialects/sql.js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@zenstackhq/kysely-sql-js",
3-
"version": "3.0.0-alpha.27",
3+
"version": "3.0.0-alpha.28",
44
"description": "Kysely dialect for sql.js",
55
"type": "module",
66
"scripts": {

0 commit comments

Comments
 (0)