@nocobase/cli 2.1.0-alpha.3 → 2.1.0-alpha.30
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/LICENSE.txt +107 -0
- package/README.md +379 -19
- package/README.zh-CN.md +329 -0
- package/bin/run.cmd +3 -0
- package/bin/run.js +131 -0
- package/dist/commands/api/resource/create.js +15 -0
- package/dist/commands/api/resource/destroy.js +15 -0
- package/dist/commands/api/resource/get.js +15 -0
- package/dist/commands/api/resource/index.js +20 -0
- package/dist/commands/api/resource/list.js +16 -0
- package/dist/commands/api/resource/query.js +15 -0
- package/dist/commands/api/resource/update.js +15 -0
- package/dist/commands/app/down.js +266 -0
- package/dist/commands/app/logs.js +98 -0
- package/dist/commands/app/restart.js +75 -0
- package/dist/commands/app/start.js +253 -0
- package/dist/commands/app/stop.js +99 -0
- package/dist/commands/app/upgrade.js +582 -0
- package/{src/cli.js → dist/commands/build.js} +4 -11
- package/dist/commands/config/delete.js +30 -0
- package/dist/commands/config/get.js +29 -0
- package/dist/commands/config/index.js +20 -0
- package/dist/commands/config/list.js +29 -0
- package/dist/commands/config/set.js +35 -0
- package/dist/commands/db/check.js +238 -0
- package/dist/commands/db/logs.js +85 -0
- package/dist/commands/db/ps.js +60 -0
- package/dist/commands/db/shared.js +96 -0
- package/dist/commands/db/start.js +71 -0
- package/dist/commands/db/stop.js +71 -0
- package/{templates/plugin/src/client/models/index.ts → dist/commands/dev.js} +4 -4
- package/{src/index.js → dist/commands/down.js} +4 -6
- package/{src/commands/locale/react-js-cron/index.js → dist/commands/download.js} +4 -8
- package/dist/commands/env/add.js +312 -0
- package/dist/commands/env/auth.js +55 -0
- package/dist/commands/env/info.js +156 -0
- package/dist/commands/env/list.js +50 -0
- package/dist/commands/env/remove.js +59 -0
- package/dist/commands/env/shared.js +158 -0
- package/dist/commands/env/update.js +67 -0
- package/dist/commands/env/use.js +28 -0
- package/dist/commands/examples/prompts-stages.js +150 -0
- package/dist/commands/examples/prompts-test.js +181 -0
- package/dist/commands/init.js +1027 -0
- package/dist/commands/install.js +2206 -0
- package/dist/commands/license/activate.js +360 -0
- package/dist/commands/license/env.js +94 -0
- package/dist/commands/license/generate-id.js +108 -0
- package/dist/commands/license/id.js +56 -0
- package/dist/commands/license/index.js +20 -0
- package/dist/commands/license/plugins/clean.js +101 -0
- package/dist/commands/license/plugins/index.js +20 -0
- package/dist/commands/license/plugins/list.js +50 -0
- package/dist/commands/license/plugins/shared.js +325 -0
- package/dist/commands/license/plugins/sync.js +269 -0
- package/dist/commands/license/shared.js +414 -0
- package/dist/commands/license/status.js +50 -0
- package/dist/commands/logs.js +12 -0
- package/dist/commands/plugin/disable.js +66 -0
- package/dist/commands/plugin/enable.js +66 -0
- package/dist/commands/plugin/list.js +62 -0
- package/dist/commands/pm/disable.js +12 -0
- package/dist/commands/pm/enable.js +12 -0
- package/dist/commands/pm/list.js +12 -0
- package/dist/commands/restart.js +12 -0
- package/dist/commands/scaffold/migration.js +38 -0
- package/dist/commands/scaffold/plugin.js +37 -0
- package/dist/commands/self/check.js +71 -0
- package/dist/commands/self/index.js +20 -0
- package/dist/commands/self/update.js +86 -0
- package/dist/commands/skills/check.js +69 -0
- package/dist/commands/skills/index.js +20 -0
- package/dist/commands/skills/install.js +71 -0
- package/dist/commands/skills/remove.js +71 -0
- package/dist/commands/skills/update.js +78 -0
- package/dist/commands/source/build.js +58 -0
- package/dist/commands/source/dev.js +158 -0
- package/dist/commands/source/download.js +866 -0
- package/dist/commands/source/test.js +467 -0
- package/dist/commands/start.js +12 -0
- package/dist/commands/stop.js +12 -0
- package/dist/commands/test.js +12 -0
- package/dist/commands/upgrade.js +12 -0
- package/dist/generated/command-registry.js +133 -0
- package/dist/help/runtime-help.js +23 -0
- package/dist/lib/api-client.js +329 -0
- package/dist/lib/app-health.js +126 -0
- package/dist/lib/app-managed-resources.js +268 -0
- package/dist/lib/app-runtime.js +171 -0
- package/dist/lib/auth-store.js +328 -0
- package/dist/lib/bootstrap.js +384 -0
- package/dist/lib/build-config.js +18 -0
- package/dist/lib/builtin-db.js +86 -0
- package/dist/lib/cli-config.js +176 -0
- package/dist/lib/cli-home.js +47 -0
- package/dist/lib/cli-locale.js +129 -0
- package/dist/lib/command-discovery.js +39 -0
- package/dist/lib/db-connection-check.js +178 -0
- package/dist/lib/env-auth.js +872 -0
- package/dist/lib/env-config.js +87 -0
- package/dist/lib/generated-command.js +171 -0
- package/dist/lib/http-request.js +49 -0
- package/dist/lib/naming.js +70 -0
- package/dist/lib/openapi.js +62 -0
- package/dist/lib/plugin-storage.js +127 -0
- package/dist/lib/post-processors.js +23 -0
- package/dist/lib/prompt-catalog.js +581 -0
- package/dist/lib/prompt-validators.js +185 -0
- package/dist/lib/prompt-web-ui.js +2103 -0
- package/dist/lib/resource-command.js +343 -0
- package/dist/lib/resource-request.js +104 -0
- package/dist/lib/run-npm.js +250 -0
- package/dist/lib/runtime-env-vars.js +32 -0
- package/dist/lib/runtime-generator.js +498 -0
- package/dist/lib/runtime-store.js +56 -0
- package/dist/lib/self-manager.js +301 -0
- package/dist/lib/skills-manager.js +296 -0
- package/dist/lib/startup-update.js +281 -0
- package/dist/lib/ui.js +178 -0
- package/dist/locale/en-US.json +339 -0
- package/dist/locale/zh-CN.json +339 -0
- package/dist/post-processors/data-modeling.js +66 -0
- package/dist/post-processors/data-source-manager.js +114 -0
- package/dist/post-processors/index.js +19 -0
- package/nocobase-ctl.config.json +369 -0
- package/package.json +95 -26
- package/LICENSE +0 -661
- package/bin/index.js +0 -39
- package/nocobase.conf.tpl +0 -95
- package/src/commands/benchmark.js +0 -73
- package/src/commands/build.js +0 -49
- package/src/commands/clean.js +0 -30
- package/src/commands/client.js +0 -166
- package/src/commands/create-nginx-conf.js +0 -37
- package/src/commands/create-plugin.js +0 -33
- package/src/commands/dev.js +0 -200
- package/src/commands/doc.js +0 -76
- package/src/commands/e2e.js +0 -265
- package/src/commands/global.js +0 -43
- package/src/commands/index.js +0 -45
- package/src/commands/instance-id.js +0 -47
- package/src/commands/locale/cronstrue.js +0 -122
- package/src/commands/locale/react-js-cron/en-US.json +0 -75
- package/src/commands/locale/react-js-cron/zh-CN.json +0 -33
- package/src/commands/locale/react-js-cron/zh-TW.json +0 -33
- package/src/commands/locale.js +0 -81
- package/src/commands/p-test.js +0 -88
- package/src/commands/perf.js +0 -63
- package/src/commands/pkg.js +0 -321
- package/src/commands/pm2.js +0 -37
- package/src/commands/postinstall.js +0 -88
- package/src/commands/start.js +0 -148
- package/src/commands/tar.js +0 -36
- package/src/commands/test-coverage.js +0 -55
- package/src/commands/test.js +0 -107
- package/src/commands/umi.js +0 -33
- package/src/commands/update-deps.js +0 -72
- package/src/commands/upgrade.js +0 -47
- package/src/commands/view-license-key.js +0 -44
- package/src/license.js +0 -76
- package/src/logger.js +0 -75
- package/src/plugin-generator.js +0 -80
- package/src/util.js +0 -517
- package/templates/bundle-status.html +0 -338
- package/templates/create-app-package.json +0 -39
- package/templates/plugin/.npmignore.tpl +0 -2
- package/templates/plugin/README.md.tpl +0 -1
- package/templates/plugin/client.d.ts +0 -2
- package/templates/plugin/client.js +0 -1
- package/templates/plugin/package.json.tpl +0 -11
- package/templates/plugin/server.d.ts +0 -2
- package/templates/plugin/server.js +0 -1
- package/templates/plugin/src/client/client.d.ts +0 -249
- package/templates/plugin/src/client/index.tsx.tpl +0 -1
- package/templates/plugin/src/client/locale.ts +0 -21
- package/templates/plugin/src/client/plugin.tsx.tpl +0 -10
- package/templates/plugin/src/index.ts +0 -2
- package/templates/plugin/src/locale/en-US.json +0 -1
- package/templates/plugin/src/locale/zh-CN.json +0 -1
- package/templates/plugin/src/server/collections/.gitkeep +0 -0
- package/templates/plugin/src/server/index.ts.tpl +0 -1
- package/templates/plugin/src/server/plugin.ts.tpl +0 -19
|
@@ -0,0 +1,50 @@
|
|
|
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 { ensureInstanceId, licenseEnvFlag, licenseJsonFlag, requireLicenseRuntime } from './shared.js';
|
|
11
|
+
export default class LicenseStatus extends Command {
|
|
12
|
+
static summary = 'Show commercial license status for the selected env';
|
|
13
|
+
static description = 'Inspect the selected env and show the current commercial licensing status. Use `--doctor` for extra diagnostic checks once the license backend wiring is implemented.';
|
|
14
|
+
static examples = [
|
|
15
|
+
'<%= config.bin %> <%= command.id %>',
|
|
16
|
+
'<%= config.bin %> <%= command.id %> --env app1',
|
|
17
|
+
'<%= config.bin %> <%= command.id %> --env app1 --doctor',
|
|
18
|
+
'<%= config.bin %> <%= command.id %> --env app1 --json',
|
|
19
|
+
];
|
|
20
|
+
static flags = {
|
|
21
|
+
env: licenseEnvFlag,
|
|
22
|
+
json: licenseJsonFlag,
|
|
23
|
+
doctor: Flags.boolean({
|
|
24
|
+
description: 'Run extra diagnostic checks and suggestions',
|
|
25
|
+
default: false,
|
|
26
|
+
}),
|
|
27
|
+
};
|
|
28
|
+
async run() {
|
|
29
|
+
const { flags } = await this.parse(LicenseStatus);
|
|
30
|
+
const runtime = await requireLicenseRuntime(flags.env);
|
|
31
|
+
const payload = {
|
|
32
|
+
ok: true,
|
|
33
|
+
env: runtime.envName,
|
|
34
|
+
kind: runtime.kind,
|
|
35
|
+
instanceId: await ensureInstanceId(runtime),
|
|
36
|
+
licensed: false,
|
|
37
|
+
doctor: Boolean(flags.doctor),
|
|
38
|
+
implemented: false,
|
|
39
|
+
message: 'Commercial license status is not implemented yet in the new CLI.',
|
|
40
|
+
};
|
|
41
|
+
if (flags.json) {
|
|
42
|
+
this.log(JSON.stringify(payload, null, 2));
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
this.log(`License status for env "${runtime.envName}": not implemented yet`);
|
|
46
|
+
if (flags.doctor) {
|
|
47
|
+
this.log('Diagnostic checks for commercial licensing are not implemented yet in the new CLI.');
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
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 AppLogs from './app/logs.js';
|
|
10
|
+
export default class Logs extends AppLogs {
|
|
11
|
+
static hidden = true;
|
|
12
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
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
|
+
import { announceTargetEnv } from '../../lib/ui.js';
|
|
12
|
+
export default class PluginDisable extends Command {
|
|
13
|
+
static hidden = false;
|
|
14
|
+
static args = {
|
|
15
|
+
packages: Args.string({
|
|
16
|
+
required: true,
|
|
17
|
+
multiple: true,
|
|
18
|
+
description: 'Plugin package name(s) to disable (e.g. `@nocobase/plugin-sample`). Pass one or more names as separate arguments.',
|
|
19
|
+
}),
|
|
20
|
+
};
|
|
21
|
+
static description = 'Disable one or more plugins in the selected env (npm/git runs locally, Docker runs inside the saved app container)';
|
|
22
|
+
static examples = [
|
|
23
|
+
'<%= config.bin %> <%= command.id %> @nocobase/plugin-sample',
|
|
24
|
+
'<%= config.bin %> <%= command.id %> @nocobase/plugin-a @nocobase/plugin-b',
|
|
25
|
+
'<%= config.bin %> <%= command.id %> -e local @nocobase/plugin-sample',
|
|
26
|
+
];
|
|
27
|
+
static flags = {
|
|
28
|
+
env: Flags.string({
|
|
29
|
+
char: 'e',
|
|
30
|
+
description: 'CLI env name (from `nb env` / `nb init`). Defaults to the current env when omitted',
|
|
31
|
+
}),
|
|
32
|
+
};
|
|
33
|
+
async run() {
|
|
34
|
+
const { args, flags } = await this.parse(PluginDisable);
|
|
35
|
+
const packages = args.packages;
|
|
36
|
+
if (!Array.isArray(packages) || packages.length === 0) {
|
|
37
|
+
this.error('Pass at least one plugin package name.');
|
|
38
|
+
}
|
|
39
|
+
const runtime = await resolveManagedAppRuntime(flags.env);
|
|
40
|
+
if (!runtime) {
|
|
41
|
+
this.error(formatMissingManagedAppEnvMessage(flags.env));
|
|
42
|
+
}
|
|
43
|
+
announceTargetEnv(runtime.envName);
|
|
44
|
+
if (runtime.kind === 'local') {
|
|
45
|
+
try {
|
|
46
|
+
await runLocalNocoBaseCommand(runtime, ['pm', 'disable', ...packages]);
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
50
|
+
this.error(message);
|
|
51
|
+
}
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (runtime.kind === 'docker') {
|
|
55
|
+
try {
|
|
56
|
+
await runDockerNocoBaseCommand(runtime.containerName, ['pm', 'disable', ...packages]);
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
60
|
+
this.error(message);
|
|
61
|
+
}
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
await this.config.runCommand('api:pm:disable', ['--await-response', '--filter-by-tk', packages.join(',')]);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
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
|
+
import { announceTargetEnv } from '../../lib/ui.js';
|
|
12
|
+
export default class PluginEnable extends Command {
|
|
13
|
+
static hidden = false;
|
|
14
|
+
static args = {
|
|
15
|
+
packages: Args.string({
|
|
16
|
+
required: true,
|
|
17
|
+
multiple: true,
|
|
18
|
+
description: 'Plugin package name(s) to enable (e.g. `@nocobase/plugin-sample`). Pass one or more names as separate arguments.',
|
|
19
|
+
}),
|
|
20
|
+
};
|
|
21
|
+
static description = 'Enable one or more plugins in the selected env (npm/git runs locally, Docker runs inside the saved app container)';
|
|
22
|
+
static examples = [
|
|
23
|
+
'<%= config.bin %> <%= command.id %> @nocobase/plugin-sample',
|
|
24
|
+
'<%= config.bin %> <%= command.id %> @nocobase/plugin-a @nocobase/plugin-b',
|
|
25
|
+
'<%= config.bin %> <%= command.id %> -e local @nocobase/plugin-sample',
|
|
26
|
+
];
|
|
27
|
+
static flags = {
|
|
28
|
+
env: Flags.string({
|
|
29
|
+
char: 'e',
|
|
30
|
+
description: 'CLI env name (from `nb env` / `nb init`). Defaults to the current env when omitted',
|
|
31
|
+
}),
|
|
32
|
+
};
|
|
33
|
+
async run() {
|
|
34
|
+
const { args, flags } = await this.parse(PluginEnable);
|
|
35
|
+
const packages = args.packages;
|
|
36
|
+
if (!Array.isArray(packages) || packages.length === 0) {
|
|
37
|
+
this.error('Pass at least one plugin package name.');
|
|
38
|
+
}
|
|
39
|
+
const runtime = await resolveManagedAppRuntime(flags.env);
|
|
40
|
+
if (!runtime) {
|
|
41
|
+
this.error(formatMissingManagedAppEnvMessage(flags.env));
|
|
42
|
+
}
|
|
43
|
+
announceTargetEnv(runtime.envName);
|
|
44
|
+
if (runtime.kind === 'local') {
|
|
45
|
+
try {
|
|
46
|
+
await runLocalNocoBaseCommand(runtime, ['pm', 'enable', ...packages]);
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
50
|
+
this.error(message);
|
|
51
|
+
}
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (runtime.kind === 'docker') {
|
|
55
|
+
try {
|
|
56
|
+
await runDockerNocoBaseCommand(runtime.containerName, ['pm', 'enable', ...packages]);
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
60
|
+
this.error(message);
|
|
61
|
+
}
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
await this.config.runCommand('api:pm:enable', ['--await-response', '--filter-by-tk', packages.join(',')]);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
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 PluginDisable from '../plugin/disable.js';
|
|
10
|
+
export default class PmDisable extends PluginDisable {
|
|
11
|
+
static hidden = true;
|
|
12
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
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 PluginEnable from '../plugin/enable.js';
|
|
10
|
+
export default class PmEnable extends PluginEnable {
|
|
11
|
+
static hidden = true;
|
|
12
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
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 PluginList from '../plugin/list.js';
|
|
10
|
+
export default class PmList extends PluginList {
|
|
11
|
+
static hidden = true;
|
|
12
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
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 AppRestart from './app/restart.js';
|
|
10
|
+
export default class Restart extends AppRestart {
|
|
11
|
+
static hidden = true;
|
|
12
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
export default class ScaffoldMigration extends Command {
|
|
12
|
+
static args = {
|
|
13
|
+
name: Args.string({ description: 'migration name', required: true }),
|
|
14
|
+
};
|
|
15
|
+
static description = 'Generate a plugin migration file.';
|
|
16
|
+
static examples = [
|
|
17
|
+
'<%= config.bin %> <%= command.id %> migration-name --pkg @nocobase/plugin-acl',
|
|
18
|
+
'<%= config.bin %> <%= command.id %> migration-name --pkg @nocobase/plugin-acl --on afterLoad',
|
|
19
|
+
];
|
|
20
|
+
static flags = {
|
|
21
|
+
pkg: Flags.string({ description: 'plugin package name', required: true }),
|
|
22
|
+
on: Flags.string({ description: 'on', required: false, options: ['beforeLoad', 'afterSync', 'afterLoad'] }),
|
|
23
|
+
};
|
|
24
|
+
async run() {
|
|
25
|
+
const { args, flags } = await this.parse(ScaffoldMigration);
|
|
26
|
+
const npmArgs = ['create-migration', args.name, '--pkg', flags.pkg];
|
|
27
|
+
if (flags.on) {
|
|
28
|
+
npmArgs.push('--on', flags.on);
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
await runNocoBaseCommand(npmArgs, { env: { LOGGER_SILENT: 'true' } });
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
35
|
+
this.error(message);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
export default class ScaffoldPlugin extends Command {
|
|
12
|
+
static args = {
|
|
13
|
+
pkg: Args.string({ description: 'plugin package name', required: true }),
|
|
14
|
+
};
|
|
15
|
+
static description = 'Generate a NocoBase plugin scaffold.';
|
|
16
|
+
static examples = [
|
|
17
|
+
'<%= config.bin %> <%= command.id %> @nocobase-example/plugin-hello',
|
|
18
|
+
'<%= config.bin %> <%= command.id %> @nocobase-example/plugin-hello --force-recreate',
|
|
19
|
+
];
|
|
20
|
+
static flags = {
|
|
21
|
+
'force-recreate': Flags.boolean({ description: 'Force recreate the plugin', char: 'f', required: false }),
|
|
22
|
+
};
|
|
23
|
+
async run() {
|
|
24
|
+
const { args, flags } = await this.parse(ScaffoldPlugin);
|
|
25
|
+
const npmArgs = ['pm', 'create', args.pkg];
|
|
26
|
+
if (flags['force-recreate']) {
|
|
27
|
+
npmArgs.push('--force-recreate');
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
await runNocoBaseCommand(npmArgs, { env: { LOGGER_SILENT: 'true' } });
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
34
|
+
this.error(message);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -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 { getRecommendedSelfUpdateCommand, inspectSelfStatus, } from '../../lib/self-manager.js';
|
|
11
|
+
import { printInfo, renderTable } from '../../lib/ui.js';
|
|
12
|
+
export default class SelfCheck extends Command {
|
|
13
|
+
static summary = 'Check the installed NocoBase CLI version and self-update support';
|
|
14
|
+
static description = 'Inspect the current NocoBase CLI install, resolve the latest version for the selected channel, and report whether automatic self-update is supported.';
|
|
15
|
+
static examples = [
|
|
16
|
+
'<%= config.bin %> <%= command.id %>',
|
|
17
|
+
'<%= config.bin %> <%= command.id %> --channel beta',
|
|
18
|
+
'<%= config.bin %> <%= command.id %> --json',
|
|
19
|
+
];
|
|
20
|
+
static flags = {
|
|
21
|
+
channel: Flags.string({
|
|
22
|
+
description: 'Release channel to compare against. Defaults to the current CLI channel.',
|
|
23
|
+
options: ['auto', 'latest', 'beta', 'alpha'],
|
|
24
|
+
default: 'auto',
|
|
25
|
+
}),
|
|
26
|
+
json: Flags.boolean({
|
|
27
|
+
description: 'Output the result as JSON',
|
|
28
|
+
default: false,
|
|
29
|
+
}),
|
|
30
|
+
};
|
|
31
|
+
async run() {
|
|
32
|
+
const { flags } = await this.parse(SelfCheck);
|
|
33
|
+
const status = await inspectSelfStatus({
|
|
34
|
+
channel: flags.channel,
|
|
35
|
+
});
|
|
36
|
+
if (flags.json) {
|
|
37
|
+
this.log(JSON.stringify({
|
|
38
|
+
ok: true,
|
|
39
|
+
kind: 'self',
|
|
40
|
+
packageName: status.packageName,
|
|
41
|
+
currentVersion: status.currentVersion,
|
|
42
|
+
latestVersion: status.latestVersion,
|
|
43
|
+
channel: status.channel,
|
|
44
|
+
updateAvailable: status.updateAvailable,
|
|
45
|
+
installMethod: status.installMethod,
|
|
46
|
+
updatable: status.updatable,
|
|
47
|
+
updateBlockedReason: status.updateBlockedReason,
|
|
48
|
+
recommendedCommand: getRecommendedSelfUpdateCommand(status),
|
|
49
|
+
registryError: status.registryError,
|
|
50
|
+
}, null, 2));
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
this.log(renderTable(['Field', 'Value'], [
|
|
54
|
+
['Current version', status.currentVersion || 'unknown'],
|
|
55
|
+
['Latest version', status.latestVersion || 'unknown'],
|
|
56
|
+
['Channel', status.channel],
|
|
57
|
+
['Install method', status.installMethod],
|
|
58
|
+
['Auto-update', status.updatable ? 'supported' : 'not supported'],
|
|
59
|
+
['Update available', status.updateAvailable ? 'yes' : 'no'],
|
|
60
|
+
]));
|
|
61
|
+
if (status.updateAvailable && status.updatable) {
|
|
62
|
+
printInfo('Run `nb self update`.');
|
|
63
|
+
}
|
|
64
|
+
else if (status.updateAvailable && status.updateBlockedReason) {
|
|
65
|
+
printInfo(status.updateBlockedReason);
|
|
66
|
+
}
|
|
67
|
+
if (status.registryError) {
|
|
68
|
+
printInfo(`Version check warning: ${status.registryError}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
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, loadHelpClass } from '@oclif/core';
|
|
10
|
+
export default class Self extends Command {
|
|
11
|
+
static summary = 'Inspect or update the NocoBase CLI itself';
|
|
12
|
+
async run() {
|
|
13
|
+
await this.parse(Self);
|
|
14
|
+
const Help = await loadHelpClass(this.config);
|
|
15
|
+
await new Help(this.config, this.config.pjson.oclif.helpOptions ?? this.config.pjson.helpOptions).showHelp([
|
|
16
|
+
this.id ?? 'self',
|
|
17
|
+
...this.argv,
|
|
18
|
+
]);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
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 { formatSelfUpdateUnavailableMessage, formatUnsupportedSelfUpdateMessage, inspectSelfStatus, updateSelf, } from '../../lib/self-manager.js';
|
|
12
|
+
export default class SelfUpdate extends Command {
|
|
13
|
+
static summary = 'Update the globally installed NocoBase CLI';
|
|
14
|
+
static description = 'Update the current NocoBase CLI install when it is managed by a standard global npm install.';
|
|
15
|
+
static examples = [
|
|
16
|
+
'<%= config.bin %> <%= command.id %>',
|
|
17
|
+
'<%= config.bin %> <%= command.id %> --yes',
|
|
18
|
+
'<%= config.bin %> <%= command.id %> --channel alpha --json',
|
|
19
|
+
];
|
|
20
|
+
static flags = {
|
|
21
|
+
channel: Flags.string({
|
|
22
|
+
description: 'Release channel to update to. Defaults to the current CLI channel.',
|
|
23
|
+
options: ['auto', 'latest', 'beta', 'alpha'],
|
|
24
|
+
default: 'auto',
|
|
25
|
+
}),
|
|
26
|
+
yes: Flags.boolean({
|
|
27
|
+
char: 'y',
|
|
28
|
+
description: 'Skip the update confirmation prompt',
|
|
29
|
+
default: false,
|
|
30
|
+
}),
|
|
31
|
+
json: Flags.boolean({
|
|
32
|
+
description: 'Output the result as JSON',
|
|
33
|
+
default: false,
|
|
34
|
+
}),
|
|
35
|
+
verbose: Flags.boolean({
|
|
36
|
+
description: 'Show detailed update output',
|
|
37
|
+
default: false,
|
|
38
|
+
}),
|
|
39
|
+
};
|
|
40
|
+
async run() {
|
|
41
|
+
const { flags } = await this.parse(SelfUpdate);
|
|
42
|
+
setVerboseMode(flags.verbose);
|
|
43
|
+
const status = await inspectSelfStatus({
|
|
44
|
+
channel: flags.channel,
|
|
45
|
+
});
|
|
46
|
+
if (!status.updatable) {
|
|
47
|
+
this.error(formatUnsupportedSelfUpdateMessage(status));
|
|
48
|
+
}
|
|
49
|
+
if (!status.latestVersion && status.registryError) {
|
|
50
|
+
this.error(formatSelfUpdateUnavailableMessage(status));
|
|
51
|
+
}
|
|
52
|
+
if (!flags.yes && status.updateAvailable) {
|
|
53
|
+
const confirmed = await confirmAction(`Update ${status.packageName} from ${status.currentVersion} to ${status.latestVersion}?`, { defaultValue: false });
|
|
54
|
+
if (!confirmed) {
|
|
55
|
+
this.log('Skipped CLI update.');
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const result = await updateSelf({
|
|
60
|
+
channel: flags.channel,
|
|
61
|
+
verbose: flags.verbose,
|
|
62
|
+
});
|
|
63
|
+
if (flags.json) {
|
|
64
|
+
this.log(JSON.stringify({
|
|
65
|
+
ok: true,
|
|
66
|
+
kind: 'self',
|
|
67
|
+
action: result.action,
|
|
68
|
+
packageName: result.status.packageName,
|
|
69
|
+
packageSpec: result.packageSpec,
|
|
70
|
+
channel: result.status.channel,
|
|
71
|
+
fromVersion: result.status.currentVersion,
|
|
72
|
+
toVersion: result.targetVersion,
|
|
73
|
+
}, null, 2));
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (result.action === 'noop') {
|
|
77
|
+
this.log(flags.verbose
|
|
78
|
+
? `NocoBase CLI is already up to date at ${result.status.currentVersion}.`
|
|
79
|
+
: `NocoBase CLI is up to date: ${result.status.currentVersion}.`);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
this.log(flags.verbose
|
|
83
|
+
? `Updated NocoBase CLI from ${result.status.currentVersion} using ${result.packageSpec}${result.targetVersion ? ` (latest ${result.status.channel} resolves to ${result.targetVersion})` : ''}.`
|
|
84
|
+
: `Updated NocoBase CLI: ${result.status.currentVersion} -> ${result.targetVersion}.`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
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 { inspectSkillsStatus } from '../../lib/skills-manager.js';
|
|
11
|
+
import { printInfo, renderTable } from '../../lib/ui.js';
|
|
12
|
+
export default class SkillsCheck extends Command {
|
|
13
|
+
static summary = 'Check the globally installed NocoBase AI coding skills';
|
|
14
|
+
static description = 'Inspect the global NocoBase AI coding skills and report whether they are managed by the CLI and whether an update is available.';
|
|
15
|
+
static examples = [
|
|
16
|
+
'<%= config.bin %> <%= command.id %>',
|
|
17
|
+
'<%= config.bin %> <%= command.id %> --json',
|
|
18
|
+
];
|
|
19
|
+
static flags = {
|
|
20
|
+
json: Flags.boolean({
|
|
21
|
+
description: 'Output the result as JSON',
|
|
22
|
+
default: false,
|
|
23
|
+
}),
|
|
24
|
+
};
|
|
25
|
+
async run() {
|
|
26
|
+
const { flags } = await this.parse(SkillsCheck);
|
|
27
|
+
const status = await inspectSkillsStatus();
|
|
28
|
+
if (flags.json) {
|
|
29
|
+
this.log(JSON.stringify({
|
|
30
|
+
ok: true,
|
|
31
|
+
kind: 'skills',
|
|
32
|
+
globalRoot: status.globalRoot,
|
|
33
|
+
workspaceRoot: status.workspaceRoot,
|
|
34
|
+
installed: status.installed,
|
|
35
|
+
managedByNb: status.managedByNb,
|
|
36
|
+
sourcePackage: status.sourcePackage,
|
|
37
|
+
npmPackageName: status.npmPackageName,
|
|
38
|
+
installedSkillNames: status.installedSkillNames,
|
|
39
|
+
installedVersion: status.installedVersion,
|
|
40
|
+
latestVersion: status.latestVersion,
|
|
41
|
+
installedRef: status.installedRef,
|
|
42
|
+
latestRef: status.latestRef,
|
|
43
|
+
updateAvailable: status.updateAvailable,
|
|
44
|
+
recommendedCommand: status.installed ? 'nb skills update --yes' : 'nb skills install --yes',
|
|
45
|
+
registryError: status.registryError,
|
|
46
|
+
}, null, 2));
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
this.log(renderTable(['Field', 'Value'], [
|
|
50
|
+
['Skills home', status.globalRoot],
|
|
51
|
+
['Installed', status.installed ? 'yes' : 'no'],
|
|
52
|
+
['Managed by nb', status.managedByNb ? 'yes' : 'no'],
|
|
53
|
+
['Installed skills', status.installedSkillNames.length ? status.installedSkillNames.join(', ') : '(none)'],
|
|
54
|
+
['Installed version', status.installedVersion ?? '(unknown)'],
|
|
55
|
+
['Latest version', status.latestVersion ?? '(unknown)'],
|
|
56
|
+
['Update available', status.updateAvailable === null ? 'unknown' : status.updateAvailable ? 'yes' : 'no'],
|
|
57
|
+
]));
|
|
58
|
+
if (!status.installed) {
|
|
59
|
+
printInfo('Run `nb skills install` to install the NocoBase AI coding skills globally.');
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (status.updateAvailable) {
|
|
63
|
+
printInfo('Run `nb skills update` to refresh the global NocoBase AI coding skills.');
|
|
64
|
+
}
|
|
65
|
+
if (status.registryError) {
|
|
66
|
+
printInfo(`Update check warning: ${status.registryError}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
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, loadHelpClass } from '@oclif/core';
|
|
10
|
+
export default class Skills extends Command {
|
|
11
|
+
static summary = 'Inspect or synchronize global NocoBase AI coding skills';
|
|
12
|
+
async run() {
|
|
13
|
+
await this.parse(Skills);
|
|
14
|
+
const Help = await loadHelpClass(this.config);
|
|
15
|
+
await new Help(this.config, this.config.pjson.oclif.helpOptions ?? this.config.pjson.helpOptions).showHelp([
|
|
16
|
+
this.id ?? 'skills',
|
|
17
|
+
...this.argv,
|
|
18
|
+
]);
|
|
19
|
+
}
|
|
20
|
+
}
|