zenstack 0.3.12 → 0.3.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/post-install.js +20 -0
- package/bundle/cli/index.js +80 -79
- package/package.json +4 -3
- package/src/cli/cli-util.ts +10 -3
- package/src/cli/index.ts +7 -13
- package/src/utils/pkg-utils.ts +2 -2
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publisher": "zenstack",
|
|
4
4
|
"displayName": "ZenStack Language Tools",
|
|
5
5
|
"description": "A toolkit for modeling data and access policies in full-stack development with Next.js and Typescript",
|
|
6
|
-
"version": "0.3.
|
|
6
|
+
"version": "0.3.13",
|
|
7
7
|
"author": {
|
|
8
8
|
"name": "ZenStack Team"
|
|
9
9
|
},
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
},
|
|
66
66
|
"main": "./bundle/extension.js",
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@zenstackhq/runtime": "0.3.
|
|
68
|
+
"@zenstackhq/runtime": "0.3.13",
|
|
69
69
|
"async-exit-hook": "^2.0.1",
|
|
70
70
|
"change-case": "^4.1.2",
|
|
71
71
|
"chevrotain": "^9.1.0",
|
|
@@ -127,6 +127,7 @@
|
|
|
127
127
|
"langium:generate": "langium generate",
|
|
128
128
|
"langium:watch": "langium generate --watch",
|
|
129
129
|
"watch": "concurrently --kill-others \"npm:langium:watch\" \"npm:bundle-watch\"",
|
|
130
|
-
"test": "jest"
|
|
130
|
+
"test": "jest",
|
|
131
|
+
"postinstall": "bin/post-install.js"
|
|
131
132
|
}
|
|
132
133
|
}
|
package/src/cli/cli-util.ts
CHANGED
|
@@ -20,6 +20,11 @@ export async function initProject(
|
|
|
20
20
|
projectPath: string,
|
|
21
21
|
packageManager: PackageManagers | undefined
|
|
22
22
|
) {
|
|
23
|
+
if (!fs.existsSync(projectPath)) {
|
|
24
|
+
console.error(`Path does not exist: ${projectPath}`);
|
|
25
|
+
throw new CliError('project path does not exist');
|
|
26
|
+
}
|
|
27
|
+
|
|
23
28
|
const schema = path.join(projectPath, 'zenstack', 'schema.zmodel');
|
|
24
29
|
let schemaGenerated = false;
|
|
25
30
|
|
|
@@ -103,12 +108,14 @@ model Post {
|
|
|
103
108
|
installPackage('@zenstackhq/runtime', false, packageManager, projectPath);
|
|
104
109
|
|
|
105
110
|
if (schemaGenerated) {
|
|
106
|
-
console.log(`Sample model generated at: ${colors.
|
|
111
|
+
console.log(`Sample model generated at: ${colors.blue(schema)}
|
|
107
112
|
|
|
108
113
|
Please check the following guide on how to model your app:
|
|
109
114
|
https://zenstack.dev/#/modeling-your-app.
|
|
110
|
-
|
|
115
|
+
`);
|
|
111
116
|
}
|
|
117
|
+
|
|
118
|
+
console.log(colors.green('\nProject initialized successfully!'));
|
|
112
119
|
}
|
|
113
120
|
|
|
114
121
|
/**
|
|
@@ -176,7 +183,7 @@ export async function loadDocument(
|
|
|
176
183
|
}
|
|
177
184
|
|
|
178
185
|
export async function runGenerator(
|
|
179
|
-
options: { schema: string; packageManager:
|
|
186
|
+
options: { schema: string; packageManager: PackageManagers | undefined },
|
|
180
187
|
includedGenerators?: string[],
|
|
181
188
|
clearOutput = true
|
|
182
189
|
) {
|
package/src/cli/index.ts
CHANGED
|
@@ -13,7 +13,7 @@ import { initProject, runGenerator } from './cli-util';
|
|
|
13
13
|
export const initAction = async (
|
|
14
14
|
projectPath: string,
|
|
15
15
|
options: {
|
|
16
|
-
packageManager: PackageManagers |
|
|
16
|
+
packageManager: PackageManagers | undefined;
|
|
17
17
|
}
|
|
18
18
|
): Promise<void> => {
|
|
19
19
|
await telemetry.trackSpan(
|
|
@@ -21,19 +21,13 @@ export const initAction = async (
|
|
|
21
21
|
'cli:command:complete',
|
|
22
22
|
'cli:command:error',
|
|
23
23
|
{ command: 'init' },
|
|
24
|
-
() =>
|
|
25
|
-
initProject(
|
|
26
|
-
projectPath ?? '.',
|
|
27
|
-
options.packageManager === 'auto detect'
|
|
28
|
-
? undefined
|
|
29
|
-
: options.packageManager
|
|
30
|
-
)
|
|
24
|
+
() => initProject(projectPath, options.packageManager)
|
|
31
25
|
);
|
|
32
26
|
};
|
|
33
27
|
|
|
34
28
|
export const generateAction = async (options: {
|
|
35
29
|
schema: string;
|
|
36
|
-
packageManager:
|
|
30
|
+
packageManager: PackageManagers | undefined;
|
|
37
31
|
}): Promise<void> => {
|
|
38
32
|
await telemetry.trackSpan(
|
|
39
33
|
'cli:command:start',
|
|
@@ -130,9 +124,9 @@ export default async function (): Promise<void> {
|
|
|
130
124
|
).default('./zenstack/schema.zmodel');
|
|
131
125
|
|
|
132
126
|
const pmOption = new Option(
|
|
133
|
-
'--package-manager
|
|
134
|
-
'package manager to use
|
|
135
|
-
).
|
|
127
|
+
'-p, --package-manager <pm>',
|
|
128
|
+
'package manager to use'
|
|
129
|
+
).choices(['npm', 'yarn', 'pnpm']);
|
|
136
130
|
|
|
137
131
|
//#region wraps Prisma commands
|
|
138
132
|
|
|
@@ -140,7 +134,7 @@ export default async function (): Promise<void> {
|
|
|
140
134
|
.command('init')
|
|
141
135
|
.description('Set up a new ZenStack project.')
|
|
142
136
|
.addOption(pmOption)
|
|
143
|
-
.argument('[path]', 'project path')
|
|
137
|
+
.argument('[path]', 'project path', '.')
|
|
144
138
|
.action(initAction);
|
|
145
139
|
|
|
146
140
|
program
|
package/src/utils/pkg-utils.ts
CHANGED
|
@@ -21,12 +21,12 @@ export function installPackage(
|
|
|
21
21
|
projectPath = '.'
|
|
22
22
|
) {
|
|
23
23
|
const manager = pkgManager ?? getPackageManager(projectPath);
|
|
24
|
-
console.log(`Installing package "${pkg}
|
|
24
|
+
console.log(`Installing package "${pkg}" with ${manager}`);
|
|
25
25
|
switch (manager) {
|
|
26
26
|
case 'yarn':
|
|
27
27
|
execSync(
|
|
28
28
|
`yarn --cwd "${projectPath}" add ${pkg} ${
|
|
29
|
-
dev ? ' --
|
|
29
|
+
dev ? ' --dev' : ''
|
|
30
30
|
} --ignore-engines`
|
|
31
31
|
);
|
|
32
32
|
break;
|