@nocobase/cli 2.1.0-alpha.19 → 2.1.0-alpha.20
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/README.md +15 -9
- package/bin/run.js +9 -3
- package/dist/commands/api/resource/index.js +20 -0
- package/dist/commands/build.js +2 -2
- package/dist/commands/db/start.js +22 -0
- package/dist/commands/dev.js +1 -1
- package/dist/commands/download.js +221 -49
- package/dist/commands/env/add.js +179 -34
- package/dist/commands/env/auth.js +31 -6
- package/dist/commands/env/list.js +12 -2
- package/dist/commands/env/remove.js +12 -1
- package/dist/commands/env/update.js +24 -9
- package/dist/commands/env/use.js +11 -1
- package/dist/commands/init.js +186 -0
- package/dist/commands/install.js +660 -12
- package/dist/commands/pm/disable.js +14 -15
- package/dist/commands/pm/enable.js +14 -15
- package/dist/commands/pm/list.js +5 -16
- package/dist/commands/scaffold/migration.js +1 -1
- package/dist/commands/scaffold/plugin.js +1 -1
- package/dist/commands/start.js +1 -1
- package/dist/commands/upgrade.js +1 -1
- package/dist/generated/command-registry.js +57 -11
- package/dist/help/runtime-help.js +20 -0
- package/dist/lib/auth-store.js +48 -3
- package/dist/lib/bootstrap.js +14 -9
- package/dist/lib/command-discovery.js +4 -4
- package/dist/lib/env-auth.js +95 -15
- package/dist/lib/init-browser-wizard.js +431 -0
- package/dist/lib/openapi.js +8 -200
- package/dist/lib/run-npm.js +27 -42
- package/nocobase-ctl.config.json +28 -68
- package/package.json +7 -6
- package/dist/commands/self-update.js +0 -46
package/dist/lib/run-npm.js
CHANGED
|
@@ -7,68 +7,53 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
import { spawn } from 'node:child_process';
|
|
10
|
-
|
|
10
|
+
import path from 'node:path';
|
|
11
|
+
export function run(name, args, options) {
|
|
12
|
+
let cwd = options?.cwd ?? process.cwd();
|
|
13
|
+
if (!path.isAbsolute(cwd)) {
|
|
14
|
+
cwd = path.resolve(process.cwd(), cwd);
|
|
15
|
+
}
|
|
16
|
+
const label = options?.errorName ?? name;
|
|
11
17
|
return new Promise((resolve, reject) => {
|
|
12
18
|
const child = spawn(name, [...args], {
|
|
13
19
|
stdio: 'inherit',
|
|
14
20
|
shell: true,
|
|
15
21
|
cwd,
|
|
16
22
|
env: {
|
|
17
|
-
...options?.env,
|
|
18
23
|
...process.env,
|
|
24
|
+
...options?.env,
|
|
19
25
|
},
|
|
20
26
|
});
|
|
21
27
|
child.once('error', reject);
|
|
22
|
-
child.once('close', (code) => {
|
|
23
|
-
if (code === 0) {
|
|
24
|
-
resolve();
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
reject(new Error(`${name} exited with code ${code}`));
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
/** Run `npm` with the given argument list in `cwd`, inheriting stdio. */
|
|
32
|
-
export function runNpm(args, cwd) {
|
|
33
|
-
return new Promise((resolve, reject) => {
|
|
34
|
-
const child = spawn('yarn', [...args], {
|
|
35
|
-
stdio: 'inherit',
|
|
36
|
-
shell: true,
|
|
37
|
-
cwd,
|
|
38
|
-
env: process.env,
|
|
39
|
-
});
|
|
40
|
-
child.once('error', reject);
|
|
41
28
|
child.once('close', (code, signal) => {
|
|
42
29
|
if (code === 0) {
|
|
43
30
|
resolve();
|
|
44
31
|
return;
|
|
45
32
|
}
|
|
46
33
|
if (signal) {
|
|
47
|
-
reject(new Error(
|
|
34
|
+
reject(new Error(`${label} exited due to signal ${signal}`));
|
|
48
35
|
return;
|
|
49
36
|
}
|
|
50
|
-
reject(new Error(
|
|
37
|
+
reject(new Error(`${label} exited with code ${code}`));
|
|
51
38
|
});
|
|
52
39
|
});
|
|
53
40
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
reject(new Error(`nocobase command exited with code ${code}`));
|
|
72
|
-
});
|
|
41
|
+
/** Run `yarn` with the given argument list, inheriting stdio (errors label as `npm` for compatibility). */
|
|
42
|
+
export function runNpm(args, options) {
|
|
43
|
+
return run('yarn', [...args], { ...options, errorName: 'npm' });
|
|
44
|
+
}
|
|
45
|
+
export function runNocoBaseCommand(args, options) {
|
|
46
|
+
let cwd = options?.cwd ?? process.cwd();
|
|
47
|
+
if (!path.isAbsolute(cwd)) {
|
|
48
|
+
cwd = path.resolve(process.cwd(), cwd);
|
|
49
|
+
}
|
|
50
|
+
const localBin = path.join(cwd, 'node_modules', '.bin');
|
|
51
|
+
return run('node', ['./node_modules/.bin/nocobase-v1', ...args], {
|
|
52
|
+
...options,
|
|
53
|
+
errorName: 'nocobase command',
|
|
54
|
+
env: {
|
|
55
|
+
PATH: `${localBin}${path.delimiter}${process.env.PATH}`,
|
|
56
|
+
...options?.env,
|
|
57
|
+
},
|
|
73
58
|
});
|
|
74
59
|
}
|
package/nocobase-ctl.config.json
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"moduleGroups": [
|
|
3
3
|
{
|
|
4
|
-
"match": [
|
|
5
|
-
"workflow*",
|
|
6
|
-
"@nocobase/plugin-workflow*"
|
|
7
|
-
],
|
|
4
|
+
"match": ["workflow*", "@nocobase/plugin-workflow*"],
|
|
8
5
|
"module": "workflow"
|
|
9
6
|
},
|
|
10
7
|
{
|
|
11
|
-
"match": [
|
|
12
|
-
"@nocobase/plugin-data-source-main",
|
|
13
|
-
"@nocobase/plugin-data-source-manager"
|
|
14
|
-
],
|
|
8
|
+
"match": ["@nocobase/plugin-data-source-main", "@nocobase/plugin-data-source-manager"],
|
|
15
9
|
"module": "data-modeling"
|
|
16
10
|
}
|
|
17
11
|
],
|
|
@@ -21,10 +15,7 @@
|
|
|
21
15
|
"description": "NocoBase core resource APIs.",
|
|
22
16
|
"include": true,
|
|
23
17
|
"resources": {
|
|
24
|
-
"includes": [
|
|
25
|
-
"app",
|
|
26
|
-
"pm"
|
|
27
|
-
],
|
|
18
|
+
"includes": ["app", "pm"],
|
|
28
19
|
"excludes": [],
|
|
29
20
|
"overrides": {
|
|
30
21
|
"app": {
|
|
@@ -45,12 +36,7 @@
|
|
|
45
36
|
"description": "Based on roles, resources, and actions, access control can precisely manage interface configuration permissions, data operation permissions, menu access permissions, and plugin permissions.",
|
|
46
37
|
"include": true,
|
|
47
38
|
"resources": {
|
|
48
|
-
"includes": [
|
|
49
|
-
"availableActions",
|
|
50
|
-
"dataSources",
|
|
51
|
-
"roles",
|
|
52
|
-
"rolesResourcesScopes"
|
|
53
|
-
],
|
|
39
|
+
"includes": ["availableActions", "dataSources", "roles", "rolesResourcesScopes", "desktopRoutes"],
|
|
54
40
|
"excludes": [],
|
|
55
41
|
"overrides": {
|
|
56
42
|
"availableActions": {
|
|
@@ -72,6 +58,14 @@
|
|
|
72
58
|
"name": "roles-resources-scopes",
|
|
73
59
|
"description": "Manage role resource scopes and permissions.",
|
|
74
60
|
"topLevel": false
|
|
61
|
+
},
|
|
62
|
+
"desktopRoutes": {
|
|
63
|
+
"name": "desktop-routes",
|
|
64
|
+
"description": "Manage desktop route permissions and visibility.",
|
|
65
|
+
"topLevel": false,
|
|
66
|
+
"operations": {
|
|
67
|
+
"includes": ["desktopRoutes:listAccessible"]
|
|
68
|
+
}
|
|
75
69
|
}
|
|
76
70
|
}
|
|
77
71
|
}
|
|
@@ -81,9 +75,7 @@
|
|
|
81
75
|
"description": "Allow users to access the HTTP API with API keys.",
|
|
82
76
|
"include": true,
|
|
83
77
|
"resources": {
|
|
84
|
-
"includes": [
|
|
85
|
-
"apiKeys"
|
|
86
|
-
],
|
|
78
|
+
"includes": ["apiKeys"],
|
|
87
79
|
"excludes": [],
|
|
88
80
|
"overrides": {
|
|
89
81
|
"apiKeys": {
|
|
@@ -99,9 +91,7 @@
|
|
|
99
91
|
"description": "User authentication management, including password auth, SMS auth, SSO protocols, and extensible providers.",
|
|
100
92
|
"include": true,
|
|
101
93
|
"resources": {
|
|
102
|
-
"includes": [
|
|
103
|
-
"authenticators"
|
|
104
|
-
],
|
|
94
|
+
"includes": ["authenticators"],
|
|
105
95
|
"excludes": [],
|
|
106
96
|
"overrides": {
|
|
107
97
|
"auth": {
|
|
@@ -122,21 +112,16 @@
|
|
|
122
112
|
"description": "Provide the web client interface for the NocoBase server.",
|
|
123
113
|
"include": true,
|
|
124
114
|
"resources": {
|
|
125
|
-
"includes": [
|
|
126
|
-
"desktopRoutes",
|
|
127
|
-
"roles"
|
|
128
|
-
],
|
|
115
|
+
"includes": ["desktopRoutes"],
|
|
129
116
|
"excludes": [],
|
|
130
117
|
"overrides": {
|
|
131
118
|
"desktopRoutes": {
|
|
132
119
|
"name": "desktop-routes",
|
|
133
120
|
"description": "Manage desktop route permissions and visibility.",
|
|
134
|
-
"topLevel": true
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
"description": "Manage client permissions scoped by role.",
|
|
139
|
-
"topLevel": false
|
|
121
|
+
"topLevel": true,
|
|
122
|
+
"operations": {
|
|
123
|
+
"excludes": ["desktopRoutes:listAccessible"]
|
|
124
|
+
}
|
|
140
125
|
}
|
|
141
126
|
}
|
|
142
127
|
}
|
|
@@ -146,11 +131,7 @@
|
|
|
146
131
|
"description": "Manage data sources, collections, and database modeling resources.",
|
|
147
132
|
"include": true,
|
|
148
133
|
"resources": {
|
|
149
|
-
"includes": [
|
|
150
|
-
"collections",
|
|
151
|
-
"fields",
|
|
152
|
-
"dbViews"
|
|
153
|
-
],
|
|
134
|
+
"includes": ["collections", "fields", "dbViews"],
|
|
154
135
|
"excludes": [],
|
|
155
136
|
"overrides": {
|
|
156
137
|
"collections": {
|
|
@@ -172,9 +153,7 @@
|
|
|
172
153
|
"description": "Manage fields with the compact high-level modeling interface.",
|
|
173
154
|
"topLevel": false,
|
|
174
155
|
"operations": {
|
|
175
|
-
"includes": [
|
|
176
|
-
"apply"
|
|
177
|
-
]
|
|
156
|
+
"includes": ["apply"]
|
|
178
157
|
}
|
|
179
158
|
},
|
|
180
159
|
"dbViews": {
|
|
@@ -182,10 +161,7 @@
|
|
|
182
161
|
"description": "Inspect and query database views.",
|
|
183
162
|
"topLevel": false,
|
|
184
163
|
"operations": {
|
|
185
|
-
"includes": [
|
|
186
|
-
"dbViews:list",
|
|
187
|
-
"dbViews:get"
|
|
188
|
-
]
|
|
164
|
+
"includes": ["dbViews:list", "dbViews:get"]
|
|
189
165
|
}
|
|
190
166
|
}
|
|
191
167
|
}
|
|
@@ -196,9 +172,7 @@
|
|
|
196
172
|
"description": "Provide file storage services, file collections, and attachment fields.",
|
|
197
173
|
"include": true,
|
|
198
174
|
"resources": {
|
|
199
|
-
"includes": [
|
|
200
|
-
"storages"
|
|
201
|
-
],
|
|
175
|
+
"includes": ["storages"],
|
|
202
176
|
"excludes": [],
|
|
203
177
|
"overrides": {
|
|
204
178
|
"storages": {
|
|
@@ -214,9 +188,7 @@
|
|
|
214
188
|
"description": "Manage flow surface composition, configuration, layout, and mutation APIs.",
|
|
215
189
|
"include": true,
|
|
216
190
|
"resources": {
|
|
217
|
-
"includes": [
|
|
218
|
-
"flowSurfaces"
|
|
219
|
-
],
|
|
191
|
+
"includes": ["flowSurfaces"],
|
|
220
192
|
"excludes": [],
|
|
221
193
|
"overrides": {
|
|
222
194
|
"flowSurfaces": {
|
|
@@ -232,9 +204,7 @@
|
|
|
232
204
|
"description": "Map blocks with support for AMap, Google Maps, and extensible providers.",
|
|
233
205
|
"include": true,
|
|
234
206
|
"resources": {
|
|
235
|
-
"includes": [
|
|
236
|
-
"map-configuration"
|
|
237
|
-
],
|
|
207
|
+
"includes": ["map-configuration"],
|
|
238
208
|
"excludes": [],
|
|
239
209
|
"overrides": {
|
|
240
210
|
"map-configuration": {
|
|
@@ -250,9 +220,7 @@
|
|
|
250
220
|
"description": "Adjust system title, logo, language, and other global settings.",
|
|
251
221
|
"include": true,
|
|
252
222
|
"resources": {
|
|
253
|
-
"includes": [
|
|
254
|
-
"systemSettings"
|
|
255
|
-
],
|
|
223
|
+
"includes": ["systemSettings"],
|
|
256
224
|
"excludes": [],
|
|
257
225
|
"overrides": {
|
|
258
226
|
"systemSettings": {
|
|
@@ -268,9 +236,7 @@
|
|
|
268
236
|
"description": "Customize UI colors and dimensions, save themes, and switch between them.",
|
|
269
237
|
"include": true,
|
|
270
238
|
"resources": {
|
|
271
|
-
"includes": [
|
|
272
|
-
"themeConfig"
|
|
273
|
-
],
|
|
239
|
+
"includes": ["themeConfig"],
|
|
274
240
|
"excludes": [],
|
|
275
241
|
"overrides": {
|
|
276
242
|
"themeConfig": {
|
|
@@ -286,13 +252,7 @@
|
|
|
286
252
|
"description": "A powerful BPM tool that provides the foundation for business automation and extensible triggers and nodes.",
|
|
287
253
|
"include": true,
|
|
288
254
|
"resources": {
|
|
289
|
-
"includes": [
|
|
290
|
-
"executions",
|
|
291
|
-
"flow_nodes",
|
|
292
|
-
"jobs",
|
|
293
|
-
"userWorkflowTasks",
|
|
294
|
-
"workflows"
|
|
295
|
-
],
|
|
255
|
+
"includes": ["executions", "flow_nodes", "jobs", "userWorkflowTasks", "workflows"],
|
|
296
256
|
"excludes": [],
|
|
297
257
|
"overrides": {
|
|
298
258
|
"executions": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/cli",
|
|
3
|
-
"version": "2.1.0-alpha.
|
|
3
|
+
"version": "2.1.0-alpha.20",
|
|
4
4
|
"description": "NocoBase Command Line Tool",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/generated/command-registry.js",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"additionalHelpFlags": [
|
|
29
29
|
"-h"
|
|
30
30
|
],
|
|
31
|
+
"helpClass": "./dist/help/runtime-help.js",
|
|
31
32
|
"commands": {
|
|
32
33
|
"strategy": "explicit",
|
|
33
34
|
"target": "./dist/generated/command-registry.js"
|
|
@@ -44,20 +45,20 @@
|
|
|
44
45
|
}
|
|
45
46
|
},
|
|
46
47
|
"dependencies": {
|
|
47
|
-
"@
|
|
48
|
+
"@clack/prompts": "^0.9.1",
|
|
48
49
|
"@oclif/core": "^4.10.4",
|
|
49
50
|
"openapi-types": "^12.1.3",
|
|
50
51
|
"ora": "^8.2.0",
|
|
51
|
-
"picocolors": "^1.1.1"
|
|
52
|
-
"typescript": "^6.0.2"
|
|
52
|
+
"picocolors": "^1.1.1"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/node": "^18.19.130",
|
|
56
|
-
"tsx": "^4.20.6"
|
|
56
|
+
"tsx": "^4.20.6",
|
|
57
|
+
"typescript": "^6.0.2"
|
|
57
58
|
},
|
|
58
59
|
"repository": {
|
|
59
60
|
"type": "git",
|
|
60
61
|
"url": "git+https://github.com/nocobase/nocobase.git"
|
|
61
62
|
},
|
|
62
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "3d1535db6bf93ca23257faf474afee0d565f54c6"
|
|
63
64
|
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
import { Command } from '@oclif/core';
|
|
10
|
-
import { spawn } from 'node:child_process';
|
|
11
|
-
function runNpmInstallGlobal(args) {
|
|
12
|
-
return new Promise((resolve, reject) => {
|
|
13
|
-
const child = spawn('npm', ['install', '-g', ...args], {
|
|
14
|
-
stdio: 'inherit',
|
|
15
|
-
shell: true,
|
|
16
|
-
env: process.env,
|
|
17
|
-
});
|
|
18
|
-
child.once('error', reject);
|
|
19
|
-
child.once('close', (code) => {
|
|
20
|
-
if (code === 0) {
|
|
21
|
-
resolve();
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
reject(new Error(`npm exited with code ${code}`));
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
export default class SelfUpdate extends Command {
|
|
29
|
-
static description = 'Update the NocoBase CLI to the latest version';
|
|
30
|
-
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
31
|
-
async run() {
|
|
32
|
-
this.log('Updating NocoBase CLI to the latest version...');
|
|
33
|
-
try {
|
|
34
|
-
await runNpmInstallGlobal(['@nocobase/cli']);
|
|
35
|
-
this.log('Update finished.');
|
|
36
|
-
}
|
|
37
|
-
catch (error) {
|
|
38
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
39
|
-
this.error([
|
|
40
|
-
'Failed to update the CLI.',
|
|
41
|
-
'Try running manually: npm install -g @nocobase/cli',
|
|
42
|
-
message,
|
|
43
|
-
].join('\n'), { exit: 1 });
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|