@nocobase/cli 2.1.0-beta.21 → 2.1.0-beta.23
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 +37 -49
- package/README.zh-CN.md +36 -47
- package/dist/commands/app/down.js +260 -0
- package/dist/commands/app/logs.js +98 -0
- package/dist/commands/app/restart.js +75 -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/env/info.js +152 -0
- package/dist/commands/env/list.js +23 -9
- package/dist/commands/env/shared.js +158 -0
- 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 +84 -6
- 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/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/api-client.js +20 -6
- 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/prompt-web-ui.js +13 -6
- package/dist/lib/skills-manager.js +34 -7
- package/package.json +27 -4
- package/dist/commands/ps.js +0 -119
|
@@ -0,0 +1,64 @@
|
|
|
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 { formatMissingManagedAppEnvMessage, resolveManagedAppRuntime, runDockerNocoBaseCommand, runLocalNocoBaseCommand, } from '../../lib/app-runtime.js';
|
|
11
|
+
export default class PluginDisable extends Command {
|
|
12
|
+
static hidden = false;
|
|
13
|
+
static args = {
|
|
14
|
+
packages: Args.string({
|
|
15
|
+
required: true,
|
|
16
|
+
multiple: true,
|
|
17
|
+
description: 'Plugin package name(s) to disable (e.g. `@nocobase/plugin-sample`). Pass one or more names as separate arguments.',
|
|
18
|
+
}),
|
|
19
|
+
};
|
|
20
|
+
static description = 'Disable one or more plugins in the selected env (npm/git runs locally, Docker runs inside the saved app container)';
|
|
21
|
+
static examples = [
|
|
22
|
+
'<%= config.bin %> <%= command.id %> @nocobase/plugin-sample',
|
|
23
|
+
'<%= config.bin %> <%= command.id %> @nocobase/plugin-a @nocobase/plugin-b',
|
|
24
|
+
'<%= config.bin %> <%= command.id %> -e local @nocobase/plugin-sample',
|
|
25
|
+
];
|
|
26
|
+
static flags = {
|
|
27
|
+
env: Flags.string({
|
|
28
|
+
char: 'e',
|
|
29
|
+
description: 'CLI env name (from `nb env` / `nb init`). Defaults to the current env when omitted',
|
|
30
|
+
}),
|
|
31
|
+
};
|
|
32
|
+
async run() {
|
|
33
|
+
const { args, flags } = await this.parse(PluginDisable);
|
|
34
|
+
const packages = args.packages;
|
|
35
|
+
if (!Array.isArray(packages) || packages.length === 0) {
|
|
36
|
+
this.error('Pass at least one plugin package name.');
|
|
37
|
+
}
|
|
38
|
+
const runtime = await resolveManagedAppRuntime(flags.env);
|
|
39
|
+
if (!runtime) {
|
|
40
|
+
this.error(formatMissingManagedAppEnvMessage(flags.env));
|
|
41
|
+
}
|
|
42
|
+
if (runtime.kind === 'local') {
|
|
43
|
+
try {
|
|
44
|
+
await runLocalNocoBaseCommand(runtime, ['pm', 'disable', ...packages]);
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
48
|
+
this.error(message);
|
|
49
|
+
}
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (runtime.kind === 'docker') {
|
|
53
|
+
try {
|
|
54
|
+
await runDockerNocoBaseCommand(runtime.containerName, ['pm', 'disable', ...packages]);
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
58
|
+
this.error(message);
|
|
59
|
+
}
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
await this.config.runCommand('api:pm:disable', ['--await-response', '--filter-by-tk', packages.join(',')]);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
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 { formatMissingManagedAppEnvMessage, resolveManagedAppRuntime, runDockerNocoBaseCommand, runLocalNocoBaseCommand, } from '../../lib/app-runtime.js';
|
|
11
|
+
export default class PluginEnable extends Command {
|
|
12
|
+
static hidden = false;
|
|
13
|
+
static args = {
|
|
14
|
+
packages: Args.string({
|
|
15
|
+
required: true,
|
|
16
|
+
multiple: true,
|
|
17
|
+
description: 'Plugin package name(s) to enable (e.g. `@nocobase/plugin-sample`). Pass one or more names as separate arguments.',
|
|
18
|
+
}),
|
|
19
|
+
};
|
|
20
|
+
static description = 'Enable one or more plugins in the selected env (npm/git runs locally, Docker runs inside the saved app container)';
|
|
21
|
+
static examples = [
|
|
22
|
+
'<%= config.bin %> <%= command.id %> @nocobase/plugin-sample',
|
|
23
|
+
'<%= config.bin %> <%= command.id %> @nocobase/plugin-a @nocobase/plugin-b',
|
|
24
|
+
'<%= config.bin %> <%= command.id %> -e local @nocobase/plugin-sample',
|
|
25
|
+
];
|
|
26
|
+
static flags = {
|
|
27
|
+
env: Flags.string({
|
|
28
|
+
char: 'e',
|
|
29
|
+
description: 'CLI env name (from `nb env` / `nb init`). Defaults to the current env when omitted',
|
|
30
|
+
}),
|
|
31
|
+
};
|
|
32
|
+
async run() {
|
|
33
|
+
const { args, flags } = await this.parse(PluginEnable);
|
|
34
|
+
const packages = args.packages;
|
|
35
|
+
if (!Array.isArray(packages) || packages.length === 0) {
|
|
36
|
+
this.error('Pass at least one plugin package name.');
|
|
37
|
+
}
|
|
38
|
+
const runtime = await resolveManagedAppRuntime(flags.env);
|
|
39
|
+
if (!runtime) {
|
|
40
|
+
this.error(formatMissingManagedAppEnvMessage(flags.env));
|
|
41
|
+
}
|
|
42
|
+
if (runtime.kind === 'local') {
|
|
43
|
+
try {
|
|
44
|
+
await runLocalNocoBaseCommand(runtime, ['pm', 'enable', ...packages]);
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
48
|
+
this.error(message);
|
|
49
|
+
}
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (runtime.kind === 'docker') {
|
|
53
|
+
try {
|
|
54
|
+
await runDockerNocoBaseCommand(runtime.containerName, ['pm', 'enable', ...packages]);
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
58
|
+
this.error(message);
|
|
59
|
+
}
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
await this.config.runCommand('api:pm:enable', ['--await-response', '--filter-by-tk', packages.join(',')]);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
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, runDockerNocoBaseCommand, runLocalNocoBaseCommand, } from '../../lib/app-runtime.js';
|
|
11
|
+
export default class PluginList extends Command {
|
|
12
|
+
static hidden = false;
|
|
13
|
+
static args = {};
|
|
14
|
+
static summary = 'List plugins for the selected env';
|
|
15
|
+
static description = 'List installed plugins in the selected env (npm/git runs locally, Docker runs inside the saved app container, HTTP envs fall back to the API)';
|
|
16
|
+
static examples = [
|
|
17
|
+
'<%= config.bin %> <%= command.id %>',
|
|
18
|
+
'<%= config.bin %> <%= command.id %> -e local',
|
|
19
|
+
'<%= config.bin %> <%= command.id %> -e local-docker',
|
|
20
|
+
];
|
|
21
|
+
static flags = {
|
|
22
|
+
env: Flags.string({
|
|
23
|
+
char: 'e',
|
|
24
|
+
description: 'CLI env name (from `nb env` / `nb init`). Defaults to the current env when omitted',
|
|
25
|
+
}),
|
|
26
|
+
};
|
|
27
|
+
async run() {
|
|
28
|
+
const { flags } = await this.parse(PluginList);
|
|
29
|
+
const runtime = await resolveManagedAppRuntime(flags.env);
|
|
30
|
+
if (!runtime) {
|
|
31
|
+
this.error(formatMissingManagedAppEnvMessage(flags.env));
|
|
32
|
+
}
|
|
33
|
+
if (runtime.kind === 'local') {
|
|
34
|
+
try {
|
|
35
|
+
await runLocalNocoBaseCommand(runtime, ['pm', 'list']);
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
39
|
+
this.error(message);
|
|
40
|
+
}
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (runtime.kind === 'docker') {
|
|
44
|
+
try {
|
|
45
|
+
await runDockerNocoBaseCommand(runtime.containerName, ['pm', 'list']);
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
49
|
+
this.error(message);
|
|
50
|
+
}
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (runtime.kind === 'ssh') {
|
|
54
|
+
this.error([
|
|
55
|
+
`Can't list plugins for "${runtime.envName}" yet.`,
|
|
56
|
+
'SSH env support is reserved but not implemented yet.',
|
|
57
|
+
'Use a local, Docker, or HTTP env for plugin inspection right now.',
|
|
58
|
+
].join('\n'));
|
|
59
|
+
}
|
|
60
|
+
await this.config.runCommand('api:pm:list', ['--mode=summary']);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -6,58 +6,7 @@
|
|
|
6
6
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
static args = {
|
|
13
|
-
packages: Args.string({
|
|
14
|
-
required: true,
|
|
15
|
-
multiple: true,
|
|
16
|
-
description: 'Plugin package name(s) to disable (e.g. `@nocobase/plugin-sample`). Pass one or more names as separate arguments.',
|
|
17
|
-
}),
|
|
18
|
-
};
|
|
19
|
-
static description = 'Disable one or more plugins in the selected env (npm/git runs locally, Docker runs inside the saved app container)';
|
|
20
|
-
static examples = [
|
|
21
|
-
'<%= config.bin %> <%= command.id %> @nocobase/plugin-sample',
|
|
22
|
-
'<%= config.bin %> <%= command.id %> @nocobase/plugin-a @nocobase/plugin-b',
|
|
23
|
-
'<%= config.bin %> <%= command.id %> -e local @nocobase/plugin-sample',
|
|
24
|
-
];
|
|
25
|
-
static flags = {
|
|
26
|
-
env: Flags.string({
|
|
27
|
-
char: 'e',
|
|
28
|
-
description: 'CLI env name (from `nb env` / `nb install`). Defaults to the current env when omitted',
|
|
29
|
-
}),
|
|
30
|
-
};
|
|
31
|
-
async run() {
|
|
32
|
-
const { args, flags } = await this.parse(PmDisable);
|
|
33
|
-
const packages = args.packages;
|
|
34
|
-
if (!Array.isArray(packages) || packages.length === 0) {
|
|
35
|
-
this.error('Pass at least one plugin package name.');
|
|
36
|
-
}
|
|
37
|
-
const runtime = await resolveManagedAppRuntime(flags.env);
|
|
38
|
-
if (!runtime) {
|
|
39
|
-
this.error(formatMissingManagedAppEnvMessage(flags.env));
|
|
40
|
-
}
|
|
41
|
-
if (runtime.kind === 'local') {
|
|
42
|
-
try {
|
|
43
|
-
await runLocalNocoBaseCommand(runtime, ['pm', 'disable', ...packages]);
|
|
44
|
-
}
|
|
45
|
-
catch (error) {
|
|
46
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
47
|
-
this.error(message);
|
|
48
|
-
}
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
if (runtime.kind === 'docker') {
|
|
52
|
-
try {
|
|
53
|
-
await runDockerNocoBaseCommand(runtime.containerName, ['pm', 'disable', ...packages]);
|
|
54
|
-
}
|
|
55
|
-
catch (error) {
|
|
56
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
57
|
-
this.error(message);
|
|
58
|
-
}
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
await this.config.runCommand('api:pm:disable', ['--await-response', '--filter-by-tk', packages.join(',')]);
|
|
62
|
-
}
|
|
9
|
+
import PluginDisable from '../plugin/disable.js';
|
|
10
|
+
export default class PmDisable extends PluginDisable {
|
|
11
|
+
static hidden = true;
|
|
63
12
|
}
|
|
@@ -6,58 +6,7 @@
|
|
|
6
6
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
static args = {
|
|
13
|
-
packages: Args.string({
|
|
14
|
-
required: true,
|
|
15
|
-
multiple: true,
|
|
16
|
-
description: 'Plugin package name(s) to enable (e.g. `@nocobase/plugin-sample`). Pass one or more names as separate arguments.',
|
|
17
|
-
}),
|
|
18
|
-
};
|
|
19
|
-
static description = 'Enable one or more plugins in the selected env (npm/git runs locally, Docker runs inside the saved app container)';
|
|
20
|
-
static examples = [
|
|
21
|
-
'<%= config.bin %> <%= command.id %> @nocobase/plugin-sample',
|
|
22
|
-
'<%= config.bin %> <%= command.id %> @nocobase/plugin-a @nocobase/plugin-b',
|
|
23
|
-
'<%= config.bin %> <%= command.id %> -e local @nocobase/plugin-sample',
|
|
24
|
-
];
|
|
25
|
-
static flags = {
|
|
26
|
-
env: Flags.string({
|
|
27
|
-
char: 'e',
|
|
28
|
-
description: 'CLI env name (from `nb env` / `nb install`). Defaults to the current env when omitted',
|
|
29
|
-
}),
|
|
30
|
-
};
|
|
31
|
-
async run() {
|
|
32
|
-
const { args, flags } = await this.parse(PmEnable);
|
|
33
|
-
const packages = args.packages;
|
|
34
|
-
if (!Array.isArray(packages) || packages.length === 0) {
|
|
35
|
-
this.error('Pass at least one plugin package name.');
|
|
36
|
-
}
|
|
37
|
-
const runtime = await resolveManagedAppRuntime(flags.env);
|
|
38
|
-
if (!runtime) {
|
|
39
|
-
this.error(formatMissingManagedAppEnvMessage(flags.env));
|
|
40
|
-
}
|
|
41
|
-
if (runtime.kind === 'local') {
|
|
42
|
-
try {
|
|
43
|
-
await runLocalNocoBaseCommand(runtime, ['pm', 'enable', ...packages]);
|
|
44
|
-
}
|
|
45
|
-
catch (error) {
|
|
46
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
47
|
-
this.error(message);
|
|
48
|
-
}
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
if (runtime.kind === 'docker') {
|
|
52
|
-
try {
|
|
53
|
-
await runDockerNocoBaseCommand(runtime.containerName, ['pm', 'enable', ...packages]);
|
|
54
|
-
}
|
|
55
|
-
catch (error) {
|
|
56
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
57
|
-
this.error(message);
|
|
58
|
-
}
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
await this.config.runCommand('api:pm:enable', ['--await-response', '--filter-by-tk', packages.join(',')]);
|
|
62
|
-
}
|
|
9
|
+
import PluginEnable from '../plugin/enable.js';
|
|
10
|
+
export default class PmEnable extends PluginEnable {
|
|
11
|
+
static hidden = true;
|
|
63
12
|
}
|
package/dist/commands/pm/list.js
CHANGED
|
@@ -6,56 +6,7 @@
|
|
|
6
6
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
static args = {};
|
|
13
|
-
static summary = 'List plugins for the selected env';
|
|
14
|
-
static description = 'List installed plugins in the selected env (npm/git runs locally, Docker runs inside the saved app container, HTTP envs fall back to the API)';
|
|
15
|
-
static examples = [
|
|
16
|
-
'<%= config.bin %> <%= command.id %>',
|
|
17
|
-
'<%= config.bin %> <%= command.id %> -e local',
|
|
18
|
-
'<%= config.bin %> <%= command.id %> -e local-docker',
|
|
19
|
-
];
|
|
20
|
-
static flags = {
|
|
21
|
-
env: Flags.string({
|
|
22
|
-
char: 'e',
|
|
23
|
-
description: 'CLI env name (from `nb env` / `nb install`). Defaults to the current env when omitted',
|
|
24
|
-
}),
|
|
25
|
-
};
|
|
26
|
-
async run() {
|
|
27
|
-
const { flags } = await this.parse(PmList);
|
|
28
|
-
const runtime = await resolveManagedAppRuntime(flags.env);
|
|
29
|
-
if (!runtime) {
|
|
30
|
-
this.error(formatMissingManagedAppEnvMessage(flags.env));
|
|
31
|
-
}
|
|
32
|
-
if (runtime.kind === 'local') {
|
|
33
|
-
try {
|
|
34
|
-
await runLocalNocoBaseCommand(runtime, ['pm', 'list']);
|
|
35
|
-
}
|
|
36
|
-
catch (error) {
|
|
37
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
38
|
-
this.error(message);
|
|
39
|
-
}
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
if (runtime.kind === 'docker') {
|
|
43
|
-
try {
|
|
44
|
-
await runDockerNocoBaseCommand(runtime.containerName, ['pm', 'list']);
|
|
45
|
-
}
|
|
46
|
-
catch (error) {
|
|
47
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
48
|
-
this.error(message);
|
|
49
|
-
}
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
if (runtime.kind === 'ssh') {
|
|
53
|
-
this.error([
|
|
54
|
-
`Can't list plugins for "${runtime.envName}" yet.`,
|
|
55
|
-
'SSH env support is reserved but not implemented yet.',
|
|
56
|
-
'Use a local, Docker, or HTTP env for plugin inspection right now.',
|
|
57
|
-
].join('\n'));
|
|
58
|
-
}
|
|
59
|
-
await this.config.runCommand('api:pm:list', ['--mode=summary']);
|
|
60
|
-
}
|
|
9
|
+
import PluginList from '../plugin/list.js';
|
|
10
|
+
export default class PmList extends PluginList {
|
|
11
|
+
static hidden = true;
|
|
61
12
|
}
|
package/dist/commands/restart.js
CHANGED
|
@@ -6,69 +6,7 @@
|
|
|
6
6
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
function pushFlag(argv, flag, value) {
|
|
14
|
-
if (value !== undefined) {
|
|
15
|
-
argv.push(flag, String(value));
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
export default class Restart extends Command {
|
|
19
|
-
static description = 'Restart NocoBase for the selected env by stopping it first, then starting it again.';
|
|
20
|
-
static examples = [
|
|
21
|
-
'<%= config.bin %> <%= command.id %>',
|
|
22
|
-
'<%= config.bin %> <%= command.id %> --env local',
|
|
23
|
-
'<%= config.bin %> <%= command.id %> --env local --quickstart',
|
|
24
|
-
'<%= config.bin %> <%= command.id %> --env local --port 12000',
|
|
25
|
-
'<%= config.bin %> <%= command.id %> --env local --daemon',
|
|
26
|
-
'<%= config.bin %> <%= command.id %> --env local --no-daemon',
|
|
27
|
-
'<%= config.bin %> <%= command.id %> --env local --instances 2',
|
|
28
|
-
'<%= config.bin %> <%= command.id %> --env local --launch-mode pm2',
|
|
29
|
-
'<%= config.bin %> <%= command.id %> --env local --verbose',
|
|
30
|
-
'<%= config.bin %> <%= command.id %> --env local-docker',
|
|
31
|
-
];
|
|
32
|
-
static flags = {
|
|
33
|
-
env: Flags.string({
|
|
34
|
-
char: 'e',
|
|
35
|
-
description: 'CLI env name to restart. Defaults to the current env when omitted',
|
|
36
|
-
}),
|
|
37
|
-
quickstart: Flags.boolean({ description: 'Quickstart the application after stopping it', required: false }),
|
|
38
|
-
port: Flags.string({ description: 'Port (overrides appPort from env config when set)', char: 'p', required: false }),
|
|
39
|
-
daemon: Flags.boolean({
|
|
40
|
-
description: 'Run the application as a daemon after stopping it (default: true; use --no-daemon to stay in the foreground)',
|
|
41
|
-
char: 'd',
|
|
42
|
-
required: false,
|
|
43
|
-
default: true,
|
|
44
|
-
allowNo: true,
|
|
45
|
-
}),
|
|
46
|
-
instances: Flags.integer({ description: 'Number of instances to run after stopping it', char: 'i', required: false }),
|
|
47
|
-
'launch-mode': Flags.string({ description: 'Launch Mode', required: false, options: ['pm2', 'node'] }),
|
|
48
|
-
verbose: Flags.boolean({
|
|
49
|
-
description: 'Show raw shutdown/startup output from the underlying local or Docker command',
|
|
50
|
-
default: false,
|
|
51
|
-
}),
|
|
52
|
-
};
|
|
53
|
-
async run() {
|
|
54
|
-
const { flags } = await this.parse(Restart);
|
|
55
|
-
const stopArgv = [];
|
|
56
|
-
const daemonFlagWasProvided = argvHasToken(this.argv, ['--daemon', '--no-daemon']);
|
|
57
|
-
pushFlag(stopArgv, '--env', flags.env?.trim() || undefined);
|
|
58
|
-
if (flags.verbose) {
|
|
59
|
-
stopArgv.push('--verbose');
|
|
60
|
-
}
|
|
61
|
-
await this.config.runCommand('stop', stopArgv);
|
|
62
|
-
const startArgv = [...stopArgv];
|
|
63
|
-
if (flags.quickstart) {
|
|
64
|
-
startArgv.push('--quickstart');
|
|
65
|
-
}
|
|
66
|
-
pushFlag(startArgv, '--port', flags.port);
|
|
67
|
-
if (daemonFlagWasProvided) {
|
|
68
|
-
startArgv.push(flags.daemon === false ? '--no-daemon' : '--daemon');
|
|
69
|
-
}
|
|
70
|
-
pushFlag(startArgv, '--instances', flags.instances);
|
|
71
|
-
pushFlag(startArgv, '--launch-mode', flags['launch-mode']);
|
|
72
|
-
await this.config.runCommand('start', startArgv);
|
|
73
|
-
}
|
|
9
|
+
import AppRestart from './app/restart.js';
|
|
10
|
+
export default class Restart extends AppRestart {
|
|
11
|
+
static hidden = true;
|
|
74
12
|
}
|
|
@@ -12,7 +12,7 @@ export default class ScaffoldMigration extends Command {
|
|
|
12
12
|
static args = {
|
|
13
13
|
name: Args.string({ description: 'migration name', required: true }),
|
|
14
14
|
};
|
|
15
|
-
static description = '
|
|
15
|
+
static description = 'Generate a plugin migration file.';
|
|
16
16
|
static examples = [
|
|
17
17
|
'<%= config.bin %> <%= command.id %> migration-name --pkg @nocobase/plugin-acl',
|
|
18
18
|
'<%= config.bin %> <%= command.id %> migration-name --pkg @nocobase/plugin-acl --on afterLoad',
|
|
@@ -12,7 +12,7 @@ export default class ScaffoldPlugin extends Command {
|
|
|
12
12
|
static args = {
|
|
13
13
|
pkg: Args.string({ description: 'plugin package name', required: true }),
|
|
14
14
|
};
|
|
15
|
-
static description = '
|
|
15
|
+
static description = 'Generate a NocoBase plugin scaffold.';
|
|
16
16
|
static examples = [
|
|
17
17
|
'<%= config.bin %> <%= command.id %> @nocobase-example/plugin-hello',
|
|
18
18
|
'<%= config.bin %> <%= command.id %> @nocobase-example/plugin-hello --force-recreate',
|
|
@@ -0,0 +1,71 @@
|
|
|
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 { confirmAction, setVerboseMode } from '../../lib/ui.js';
|
|
11
|
+
import { removeNocoBaseSkills } from '../../lib/skills-manager.js';
|
|
12
|
+
export default class SkillsRemove extends Command {
|
|
13
|
+
static summary = 'Remove the globally installed NocoBase AI coding skills';
|
|
14
|
+
static description = 'Remove the skills installed from nocobase/skills globally. This only removes the skills managed by `nb`.';
|
|
15
|
+
static examples = [
|
|
16
|
+
'<%= config.bin %> <%= command.id %>',
|
|
17
|
+
'<%= config.bin %> <%= command.id %> --yes',
|
|
18
|
+
'<%= config.bin %> <%= command.id %> --json',
|
|
19
|
+
];
|
|
20
|
+
static flags = {
|
|
21
|
+
yes: Flags.boolean({
|
|
22
|
+
char: 'y',
|
|
23
|
+
description: 'Skip the remove confirmation prompt',
|
|
24
|
+
default: false,
|
|
25
|
+
}),
|
|
26
|
+
json: Flags.boolean({
|
|
27
|
+
description: 'Output the result as JSON',
|
|
28
|
+
default: false,
|
|
29
|
+
}),
|
|
30
|
+
verbose: Flags.boolean({
|
|
31
|
+
description: 'Show detailed remove output',
|
|
32
|
+
default: false,
|
|
33
|
+
}),
|
|
34
|
+
};
|
|
35
|
+
async run() {
|
|
36
|
+
const { flags } = await this.parse(SkillsRemove);
|
|
37
|
+
setVerboseMode(flags.verbose);
|
|
38
|
+
if (!flags.yes) {
|
|
39
|
+
const confirmed = await confirmAction('Remove the globally installed NocoBase AI coding skills?', { defaultValue: true });
|
|
40
|
+
if (!confirmed) {
|
|
41
|
+
this.log('Skipped skills removal.');
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const result = await removeNocoBaseSkills({
|
|
46
|
+
verbose: flags.verbose,
|
|
47
|
+
});
|
|
48
|
+
if (flags.json) {
|
|
49
|
+
this.log(JSON.stringify({
|
|
50
|
+
ok: true,
|
|
51
|
+
kind: 'skills',
|
|
52
|
+
action: result.action,
|
|
53
|
+
globalRoot: result.status.globalRoot,
|
|
54
|
+
workspaceRoot: result.status.workspaceRoot,
|
|
55
|
+
installedSkillNames: result.status.installedSkillNames,
|
|
56
|
+
installedVersion: result.status.installedVersion,
|
|
57
|
+
installedRef: result.status.installedRef,
|
|
58
|
+
}, null, 2));
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (result.action === 'noop') {
|
|
62
|
+
this.log(flags.verbose
|
|
63
|
+
? 'NocoBase AI coding skills are not installed globally.'
|
|
64
|
+
: 'NocoBase AI coding skills are not installed.');
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
this.log(flags.verbose
|
|
68
|
+
? 'Removed the global NocoBase AI coding skills.'
|
|
69
|
+
: 'Removed NocoBase AI coding skills globally.');
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -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
|
+
}
|