@nocobase/cli 2.1.0-beta.21 → 2.1.0-beta.22
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 +28 -46
- package/README.zh-CN.md +27 -44
- package/dist/commands/app/down.js +260 -0
- package/dist/commands/app/info.js +140 -0
- package/dist/commands/app/logs.js +98 -0
- package/dist/commands/app/ps.js +60 -0
- package/dist/commands/app/restart.js +75 -0
- package/dist/commands/app/shared.js +95 -0
- package/dist/commands/app/start.js +252 -0
- package/dist/commands/app/stop.js +98 -0
- package/dist/commands/app/upgrade.js +595 -0
- package/dist/commands/build.js +3 -48
- package/dist/commands/dev.js +3 -147
- package/dist/commands/down.js +3 -188
- package/dist/commands/download.js +4 -856
- package/dist/commands/env/add.js +28 -23
- package/dist/commands/{prompts-stages.js → examples/prompts-stages.js} +3 -3
- package/dist/commands/{prompts-test.js → examples/prompts-test.js} +3 -3
- package/dist/commands/init.js +76 -5
- package/dist/commands/install.js +288 -61
- package/dist/commands/logs.js +3 -88
- package/dist/commands/plugin/disable.js +64 -0
- package/dist/commands/plugin/enable.js +64 -0
- package/dist/commands/plugin/list.js +62 -0
- package/dist/commands/pm/disable.js +3 -54
- package/dist/commands/pm/enable.js +3 -54
- package/dist/commands/pm/list.js +3 -52
- package/dist/commands/ps.js +3 -110
- package/dist/commands/restart.js +3 -65
- package/dist/commands/scaffold/migration.js +1 -1
- package/dist/commands/scaffold/plugin.js +1 -1
- package/dist/commands/skills/remove.js +71 -0
- package/dist/commands/skills/update.js +7 -0
- package/dist/commands/source/build.js +58 -0
- package/dist/commands/source/dev.js +157 -0
- package/dist/commands/source/download.js +866 -0
- package/dist/commands/source/test.js +467 -0
- package/dist/commands/start.js +3 -209
- package/dist/commands/stop.js +3 -88
- package/dist/commands/test.js +3 -457
- package/dist/commands/upgrade.js +3 -585
- package/dist/help/runtime-help.js +3 -0
- package/dist/lib/app-health.js +126 -0
- package/dist/lib/app-managed-resources.js +264 -0
- package/dist/lib/auth-store.js +5 -2
- package/dist/lib/cli-home.js +7 -6
- package/dist/lib/cli-locale.js +15 -1
- package/dist/lib/env-config.js +80 -0
- package/dist/lib/skills-manager.js +34 -7
- package/package.json +26 -3
|
@@ -50,6 +50,7 @@ export default class SkillsUpdate extends Command {
|
|
|
50
50
|
ok: true,
|
|
51
51
|
kind: 'skills',
|
|
52
52
|
action: result.action,
|
|
53
|
+
reason: result.action === 'noop' ? result.reason : undefined,
|
|
53
54
|
globalRoot: result.status.globalRoot,
|
|
54
55
|
workspaceRoot: result.status.workspaceRoot,
|
|
55
56
|
installedSkillNames: result.status.installedSkillNames,
|
|
@@ -59,6 +60,12 @@ export default class SkillsUpdate extends Command {
|
|
|
59
60
|
return;
|
|
60
61
|
}
|
|
61
62
|
if (result.action === 'noop') {
|
|
63
|
+
if (result.reason === 'not-installed') {
|
|
64
|
+
this.log(flags.verbose
|
|
65
|
+
? 'NocoBase AI coding skills are not installed globally. Run `nb skills install` first.'
|
|
66
|
+
: 'Skipped skills update because NocoBase AI coding skills are not installed.');
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
62
69
|
this.log(flags.verbose
|
|
63
70
|
? 'NocoBase AI coding skills are already up to date globally.'
|
|
64
71
|
: 'NocoBase AI coding skills are up to date.');
|
|
@@ -0,0 +1,58 @@
|
|
|
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 { Args, Command, Flags } from '@oclif/core';
|
|
10
|
+
import { runNocoBaseCommand } from "../../lib/run-npm.js";
|
|
11
|
+
import { setVerboseMode } from '../../lib/ui.js';
|
|
12
|
+
export default class SourceBuild extends Command {
|
|
13
|
+
static hidden = false;
|
|
14
|
+
static args = {
|
|
15
|
+
/** Matches `nb source build @nocobase/acl @nocobase/actions` — zero or more package names. */
|
|
16
|
+
packages: Args.string({
|
|
17
|
+
description: 'package names to build',
|
|
18
|
+
multiple: true,
|
|
19
|
+
required: false,
|
|
20
|
+
}),
|
|
21
|
+
};
|
|
22
|
+
static description = 'Run the legacy NocoBase build for the local source project (forwards to `npm run build` in the repo root)';
|
|
23
|
+
static examples = [
|
|
24
|
+
'<%= config.bin %> <%= command.id %>',
|
|
25
|
+
'<%= config.bin %> <%= command.id %> --no-dts',
|
|
26
|
+
'<%= config.bin %> <%= command.id %> --sourcemap',
|
|
27
|
+
'<%= config.bin %> <%= command.id %> @nocobase/acl',
|
|
28
|
+
'<%= config.bin %> <%= command.id %> @nocobase/acl @nocobase/actions',
|
|
29
|
+
];
|
|
30
|
+
static flags = {
|
|
31
|
+
'cwd': Flags.string({ description: 'Current working directory', char: 'c', required: false }),
|
|
32
|
+
'no-dts': Flags.boolean({ description: 'not generate dts' }),
|
|
33
|
+
sourcemap: Flags.boolean({ description: 'generate sourcemap' }),
|
|
34
|
+
verbose: Flags.boolean({ description: 'Show detailed command output', default: false }),
|
|
35
|
+
};
|
|
36
|
+
async run() {
|
|
37
|
+
const { args, flags } = await this.parse(SourceBuild);
|
|
38
|
+
setVerboseMode(flags.verbose);
|
|
39
|
+
const packages = args.packages ?? [];
|
|
40
|
+
const npmArgs = ['build', ...packages];
|
|
41
|
+
if (flags['no-dts']) {
|
|
42
|
+
npmArgs.push('--no-dts');
|
|
43
|
+
}
|
|
44
|
+
if (flags.sourcemap) {
|
|
45
|
+
npmArgs.push('--sourcemap');
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
await runNocoBaseCommand(npmArgs, {
|
|
49
|
+
cwd: flags['cwd'],
|
|
50
|
+
stdio: flags.verbose ? 'inherit' : 'ignore',
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
55
|
+
this.error(message);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
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, Flags } from '@oclif/core';
|
|
10
|
+
import { formatMissingManagedAppEnvMessage, resolveManagedAppRuntime, runLocalNocoBaseCommand, } from '../../lib/app-runtime.js';
|
|
11
|
+
import { printInfo } from '../../lib/ui.js';
|
|
12
|
+
function formatUnsupportedRuntimeMessage(kind, envName) {
|
|
13
|
+
if (kind === 'docker') {
|
|
14
|
+
return [
|
|
15
|
+
`Can't run dev mode for "${envName}".`,
|
|
16
|
+
'This env is managed by Docker, but `nb source dev` requires a local npm or Git source directory.',
|
|
17
|
+
`Use \`nb app logs --env ${envName}\` to inspect the Docker app, or create a source-based env with \`nb init --env ${envName} --source git\`.`,
|
|
18
|
+
].join('\n');
|
|
19
|
+
}
|
|
20
|
+
if (kind === 'ssh') {
|
|
21
|
+
return [
|
|
22
|
+
`Can't run dev mode for "${envName}" yet.`,
|
|
23
|
+
'SSH env support is reserved but not implemented yet.',
|
|
24
|
+
`Create a source-based env with \`nb init --env ${envName} --source git\` if you want local development mode right now.`,
|
|
25
|
+
].join('\n');
|
|
26
|
+
}
|
|
27
|
+
return [
|
|
28
|
+
`Can't run dev mode for "${envName}".`,
|
|
29
|
+
'This env only has an API connection, but `nb source dev` requires a local npm or Git source directory.',
|
|
30
|
+
`Create a source-based env with \`nb init --env ${envName} --source git\` if you want local development mode.`,
|
|
31
|
+
].join('\n');
|
|
32
|
+
}
|
|
33
|
+
function appUrlForPort(port) {
|
|
34
|
+
const value = String(port ?? '').trim();
|
|
35
|
+
if (!value) {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
return `http://127.0.0.1:${value}`;
|
|
39
|
+
}
|
|
40
|
+
async function isAppAlreadyRunning(appUrl) {
|
|
41
|
+
if (!appUrl) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
const controller = new AbortController();
|
|
45
|
+
const timeout = setTimeout(() => controller.abort(), 1500);
|
|
46
|
+
try {
|
|
47
|
+
const response = await fetch(`${appUrl}/api/__health_check`, {
|
|
48
|
+
signal: controller.signal,
|
|
49
|
+
});
|
|
50
|
+
const text = await response.text();
|
|
51
|
+
return response.ok && text.trim().toLowerCase() === 'ok';
|
|
52
|
+
}
|
|
53
|
+
catch (_error) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
finally {
|
|
57
|
+
clearTimeout(timeout);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
export default class SourceDev extends Command {
|
|
61
|
+
static hidden = false;
|
|
62
|
+
static description = 'Run NocoBase in local development mode for an npm or Git source env.';
|
|
63
|
+
static examples = [
|
|
64
|
+
'<%= config.bin %> <%= command.id %>',
|
|
65
|
+
'<%= config.bin %> <%= command.id %> --env app1',
|
|
66
|
+
'<%= config.bin %> <%= command.id %> --env app1 --db-sync',
|
|
67
|
+
'<%= config.bin %> <%= command.id %> --env app1 --port 12000',
|
|
68
|
+
'<%= config.bin %> <%= command.id %> --env app1 --client',
|
|
69
|
+
'<%= config.bin %> <%= command.id %> --env app1 --server',
|
|
70
|
+
'<%= config.bin %> <%= command.id %> --env app1 --inspect 9229',
|
|
71
|
+
];
|
|
72
|
+
static flags = {
|
|
73
|
+
env: Flags.string({
|
|
74
|
+
char: 'e',
|
|
75
|
+
description: 'CLI env name for dev mode. Defaults to the current env when omitted',
|
|
76
|
+
required: false,
|
|
77
|
+
}),
|
|
78
|
+
'db-sync': Flags.boolean({
|
|
79
|
+
description: 'Synchronize the database before starting dev mode',
|
|
80
|
+
required: false,
|
|
81
|
+
}),
|
|
82
|
+
port: Flags.string({
|
|
83
|
+
description: 'Development server port',
|
|
84
|
+
char: 'p',
|
|
85
|
+
required: false,
|
|
86
|
+
}),
|
|
87
|
+
client: Flags.boolean({
|
|
88
|
+
description: 'Run client dev mode only',
|
|
89
|
+
char: 'c',
|
|
90
|
+
required: false,
|
|
91
|
+
}),
|
|
92
|
+
server: Flags.boolean({
|
|
93
|
+
description: 'Run server dev mode only',
|
|
94
|
+
char: 's',
|
|
95
|
+
required: false,
|
|
96
|
+
}),
|
|
97
|
+
inspect: Flags.string({
|
|
98
|
+
description: 'Node.js inspect port for server debugging',
|
|
99
|
+
char: 'i',
|
|
100
|
+
required: false,
|
|
101
|
+
}),
|
|
102
|
+
};
|
|
103
|
+
async run() {
|
|
104
|
+
const { flags } = await this.parse(SourceDev);
|
|
105
|
+
const requestedEnv = flags.env?.trim() || undefined;
|
|
106
|
+
const runtime = await resolveManagedAppRuntime(requestedEnv);
|
|
107
|
+
if (!runtime) {
|
|
108
|
+
this.error(formatMissingManagedAppEnvMessage(requestedEnv));
|
|
109
|
+
}
|
|
110
|
+
if (runtime.kind === 'docker' || runtime.kind === 'http' || runtime.kind === 'ssh') {
|
|
111
|
+
this.error(formatUnsupportedRuntimeMessage(runtime.kind, runtime.envName));
|
|
112
|
+
}
|
|
113
|
+
const devPort = flags.port
|
|
114
|
+
|| (runtime.env.appPort !== undefined && runtime.env.appPort !== null
|
|
115
|
+
? String(runtime.env.appPort).trim()
|
|
116
|
+
: undefined);
|
|
117
|
+
const appUrl = appUrlForPort(devPort);
|
|
118
|
+
if (await isAppAlreadyRunning(appUrl)) {
|
|
119
|
+
this.error([
|
|
120
|
+
`NocoBase is already running for "${runtime.envName}"${appUrl ? ` at ${appUrl}` : ''}.`,
|
|
121
|
+
flags.port
|
|
122
|
+
? `Choose another dev port with --port, or stop the running app with \`nb app stop --env ${runtime.envName}\` first.`
|
|
123
|
+
: `Run \`nb app stop --env ${runtime.envName}\` before starting dev mode, or choose another dev port with --port.`,
|
|
124
|
+
].join('\n'));
|
|
125
|
+
}
|
|
126
|
+
const npmArgs = ['dev', '--rsbuild'];
|
|
127
|
+
if (flags['db-sync']) {
|
|
128
|
+
npmArgs.push('--db-sync');
|
|
129
|
+
}
|
|
130
|
+
if (devPort) {
|
|
131
|
+
npmArgs.push('--port', devPort);
|
|
132
|
+
}
|
|
133
|
+
if (flags.client) {
|
|
134
|
+
npmArgs.push('--client');
|
|
135
|
+
}
|
|
136
|
+
if (flags.server) {
|
|
137
|
+
npmArgs.push('--server');
|
|
138
|
+
}
|
|
139
|
+
if (flags.inspect) {
|
|
140
|
+
npmArgs.push('--inspect', flags.inspect);
|
|
141
|
+
}
|
|
142
|
+
printInfo(`Starting NocoBase dev mode for "${runtime.envName}" from ${runtime.projectRoot}. Press Ctrl+C to stop.`);
|
|
143
|
+
try {
|
|
144
|
+
await runLocalNocoBaseCommand(runtime, npmArgs, {
|
|
145
|
+
stdio: 'inherit',
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
150
|
+
this.error([
|
|
151
|
+
`Couldn't start dev mode for "${runtime.envName}".`,
|
|
152
|
+
'Check that dependencies are installed and the saved env settings are valid, then try again.',
|
|
153
|
+
`Details: ${message}`,
|
|
154
|
+
].join('\n'));
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|