@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.
Files changed (50) hide show
  1. package/README.md +28 -46
  2. package/README.zh-CN.md +27 -44
  3. package/dist/commands/app/down.js +260 -0
  4. package/dist/commands/app/info.js +140 -0
  5. package/dist/commands/app/logs.js +98 -0
  6. package/dist/commands/app/ps.js +60 -0
  7. package/dist/commands/app/restart.js +75 -0
  8. package/dist/commands/app/shared.js +95 -0
  9. package/dist/commands/app/start.js +252 -0
  10. package/dist/commands/app/stop.js +98 -0
  11. package/dist/commands/app/upgrade.js +595 -0
  12. package/dist/commands/build.js +3 -48
  13. package/dist/commands/dev.js +3 -147
  14. package/dist/commands/down.js +3 -188
  15. package/dist/commands/download.js +4 -856
  16. package/dist/commands/env/add.js +28 -23
  17. package/dist/commands/{prompts-stages.js → examples/prompts-stages.js} +3 -3
  18. package/dist/commands/{prompts-test.js → examples/prompts-test.js} +3 -3
  19. package/dist/commands/init.js +76 -5
  20. package/dist/commands/install.js +288 -61
  21. package/dist/commands/logs.js +3 -88
  22. package/dist/commands/plugin/disable.js +64 -0
  23. package/dist/commands/plugin/enable.js +64 -0
  24. package/dist/commands/plugin/list.js +62 -0
  25. package/dist/commands/pm/disable.js +3 -54
  26. package/dist/commands/pm/enable.js +3 -54
  27. package/dist/commands/pm/list.js +3 -52
  28. package/dist/commands/ps.js +3 -110
  29. package/dist/commands/restart.js +3 -65
  30. package/dist/commands/scaffold/migration.js +1 -1
  31. package/dist/commands/scaffold/plugin.js +1 -1
  32. package/dist/commands/skills/remove.js +71 -0
  33. package/dist/commands/skills/update.js +7 -0
  34. package/dist/commands/source/build.js +58 -0
  35. package/dist/commands/source/dev.js +157 -0
  36. package/dist/commands/source/download.js +866 -0
  37. package/dist/commands/source/test.js +467 -0
  38. package/dist/commands/start.js +3 -209
  39. package/dist/commands/stop.js +3 -88
  40. package/dist/commands/test.js +3 -457
  41. package/dist/commands/upgrade.js +3 -585
  42. package/dist/help/runtime-help.js +3 -0
  43. package/dist/lib/app-health.js +126 -0
  44. package/dist/lib/app-managed-resources.js +264 -0
  45. package/dist/lib/auth-store.js +5 -2
  46. package/dist/lib/cli-home.js +7 -6
  47. package/dist/lib/cli-locale.js +15 -1
  48. package/dist/lib/env-config.js +80 -0
  49. package/dist/lib/skills-manager.js +34 -7
  50. package/package.json +26 -3
@@ -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 { Args, Command, Flags } from '@oclif/core';
10
- import { formatMissingManagedAppEnvMessage, resolveManagedAppRuntime, runDockerNocoBaseCommand, runLocalNocoBaseCommand, } from '../../lib/app-runtime.js';
11
- export default class PmDisable extends Command {
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 { Args, Command, Flags } from '@oclif/core';
10
- import { formatMissingManagedAppEnvMessage, resolveManagedAppRuntime, runDockerNocoBaseCommand, runLocalNocoBaseCommand, } from '../../lib/app-runtime.js';
11
- export default class PmEnable extends Command {
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
  }
@@ -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 { Command, Flags } from '@oclif/core';
10
- import { formatMissingManagedAppEnvMessage, resolveManagedAppRuntime, runDockerNocoBaseCommand, runLocalNocoBaseCommand, } from '../../lib/app-runtime.js';
11
- export default class PmList extends Command {
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
  }
@@ -6,114 +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 { Command, Flags } from '@oclif/core';
10
- import { buildDockerDbContainerName, dockerContainerExists, dockerContainerIsRunning, formatMissingManagedAppEnvMessage, resolveManagedAppRuntime, } from '../lib/app-runtime.js';
11
- import { listEnvs } from '../lib/auth-store.js';
12
- import { renderTable } from '../lib/ui.js';
13
- function resolveApiBaseUrl(config) {
14
- return String(config.apiBaseUrl ?? config.baseUrl ?? config.apibaseUrl ?? '').trim();
15
- }
16
- function appUrl(runtime) {
17
- const port = String(runtime.env.config.appPort ?? '').trim();
18
- if (port) {
19
- return `http://127.0.0.1:${port}`;
20
- }
21
- const baseUrl = resolveApiBaseUrl(runtime.env.config);
22
- return baseUrl.replace(/\/api\/?$/, '');
23
- }
24
- async function isLocalAppHealthy(runtime) {
25
- const port = String(runtime.env.config.appPort ?? '').trim();
26
- if (!port) {
27
- return false;
28
- }
29
- const controller = new AbortController();
30
- const timeout = setTimeout(() => controller.abort(), 1500);
31
- try {
32
- const response = await fetch(`http://127.0.0.1:${port}/api/__health_check`, {
33
- signal: controller.signal,
34
- });
35
- const text = await response.text();
36
- return response.ok && text.trim().toLowerCase() === 'ok';
37
- }
38
- catch (_error) {
39
- return false;
40
- }
41
- finally {
42
- clearTimeout(timeout);
43
- }
44
- }
45
- async function dockerStatus(containerName) {
46
- if (!(await dockerContainerExists(containerName))) {
47
- return 'missing';
48
- }
49
- return await dockerContainerIsRunning(containerName) ? 'running' : 'stopped';
50
- }
51
- async function dbStatus(runtime) {
52
- if (!runtime.env.config.builtinDb) {
53
- return runtime.kind === 'http' ? 'external' : '-';
54
- }
55
- if (runtime.kind === 'http') {
56
- return 'external';
57
- }
58
- if (runtime.kind === 'ssh') {
59
- return '-';
60
- }
61
- const dbDialect = String(runtime.env.config.dbDialect ?? 'postgres').trim() || 'postgres';
62
- const containerName = buildDockerDbContainerName(runtime.envName, dbDialect, runtime.workspaceName);
63
- return await dockerStatus(containerName);
64
- }
65
- async function runtimeStatus(runtime) {
66
- if (runtime.kind === 'http') {
67
- return 'http';
68
- }
69
- if (runtime.kind === 'ssh') {
70
- return 'ssh';
71
- }
72
- if (runtime.kind === 'docker') {
73
- return await dockerStatus(runtime.containerName);
74
- }
75
- return await isLocalAppHealthy(runtime) ? 'running' : 'stopped';
76
- }
77
- export default class Ps extends Command {
78
- static description = 'Show NocoBase runtime status for configured envs without starting or stopping anything.';
79
- static examples = [
80
- '<%= config.bin %> <%= command.id %>',
81
- '<%= config.bin %> <%= command.id %> --env app1',
82
- ];
83
- static flags = {
84
- env: Flags.string({
85
- char: 'e',
86
- description: 'CLI env name to inspect. Omit to show all configured envs',
87
- }),
88
- };
89
- async run() {
90
- const { flags } = await this.parse(Ps);
91
- const requestedEnv = flags.env?.trim() || undefined;
92
- const envNames = requestedEnv
93
- ? [requestedEnv]
94
- : Object.keys((await listEnvs()).envs).sort();
95
- if (!envNames.length) {
96
- this.log('No NocoBase env is configured yet. Run `nb init` to create one first.');
97
- return;
98
- }
99
- const rows = [];
100
- for (const envName of envNames) {
101
- const runtime = await resolveManagedAppRuntime(envName);
102
- if (!runtime) {
103
- if (requestedEnv) {
104
- this.error(formatMissingManagedAppEnvMessage(envName));
105
- }
106
- rows.push([envName, '-', 'missing', '-', '']);
107
- continue;
108
- }
109
- rows.push([
110
- runtime.envName,
111
- runtime.kind,
112
- await runtimeStatus(runtime),
113
- await dbStatus(runtime),
114
- appUrl(runtime),
115
- ]);
116
- }
117
- this.log(renderTable(['Env', 'Kind', 'Status', 'Database', 'URL'], rows));
118
- }
9
+ import AppPs from './app/ps.js';
10
+ export default class Ps extends AppPs {
11
+ static hidden = true;
119
12
  }
@@ -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 { Command, Flags } from '@oclif/core';
10
- function argvHasToken(argv, tokens) {
11
- return tokens.some((token) => argv.includes(token));
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 = 'Run the legacy NocoBase scaffold migration (forwards to `npm run scaffold:migration` in the repo root)';
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 = 'Run the legacy NocoBase scaffold plugin (forwards to `npm run scaffold:plugin` in the repo root)';
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
+ }