@nocobase/cli 2.1.0-alpha.4 → 2.1.0-alpha.40
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 +393 -19
- package/README.zh-CN.md +343 -0
- package/bin/run.cmd +3 -0
- package/bin/run.js +135 -0
- package/bin/session-env.js +39 -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 +301 -0
- package/dist/commands/app/logs.js +114 -0
- package/dist/commands/app/restart.js +158 -0
- package/dist/commands/app/start.js +305 -0
- package/dist/commands/app/stop.js +115 -0
- package/dist/commands/app/upgrade.js +636 -0
- package/dist/commands/backup/create.js +147 -0
- package/dist/commands/backup/index.js +20 -0
- package/dist/commands/backup/restore.js +105 -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 +240 -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/commands/locale/react-js-cron/index.js → dist/commands/down.js} +3 -8
- package/dist/commands/download.js +13 -0
- package/dist/commands/env/add.js +366 -0
- package/dist/commands/env/auth.js +130 -0
- package/dist/commands/env/current.js +21 -0
- package/dist/commands/env/info.js +157 -0
- package/dist/commands/env/list.js +44 -0
- package/dist/commands/env/remove.js +84 -0
- package/dist/commands/env/shared.js +158 -0
- package/dist/commands/env/status.js +90 -0
- package/dist/commands/env/update.js +74 -0
- package/dist/commands/env/use.js +38 -0
- package/dist/commands/examples/prompts-stages.js +150 -0
- package/dist/commands/examples/prompts-test.js +181 -0
- package/dist/commands/init.js +1092 -0
- package/dist/commands/install.js +2378 -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 +70 -0
- package/dist/commands/license/index.js +20 -0
- package/dist/commands/license/plugins/clean.js +115 -0
- package/dist/commands/license/plugins/index.js +20 -0
- package/dist/commands/license/plugins/list.js +64 -0
- package/dist/commands/license/plugins/shared.js +325 -0
- package/dist/commands/license/plugins/sync.js +285 -0
- package/dist/commands/license/shared.js +423 -0
- package/dist/commands/license/status.js +64 -0
- package/dist/commands/logs.js +12 -0
- package/dist/commands/plugin/disable.js +86 -0
- package/dist/commands/plugin/enable.js +86 -0
- package/dist/commands/plugin/list.js +82 -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 +95 -0
- package/dist/commands/session/id.js +24 -0
- package/dist/commands/session/remove.js +57 -0
- package/dist/commands/session/setup.js +62 -0
- package/dist/commands/skills/check.js +69 -0
- package/dist/commands/skills/index.js +20 -0
- package/dist/commands/skills/install.js +80 -0
- package/dist/commands/skills/remove.js +80 -0
- package/dist/commands/skills/update.js +87 -0
- package/dist/commands/source/build.js +58 -0
- package/dist/commands/source/dev.js +182 -0
- package/dist/commands/source/download.js +880 -0
- package/dist/commands/source/publish.js +109 -0
- package/dist/commands/source/registry/logs.js +70 -0
- package/dist/commands/source/registry/start.js +57 -0
- package/dist/commands/source/registry/status.js +33 -0
- package/dist/commands/source/registry/stop.js +48 -0
- package/dist/commands/source/test.js +477 -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/commands/v1.js +210 -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 +316 -0
- package/dist/lib/app-runtime.js +180 -0
- package/dist/lib/auth-store.js +368 -0
- package/dist/lib/backup.js +171 -0
- package/dist/lib/bootstrap.js +403 -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 +158 -0
- package/dist/lib/docker-env-file.js +52 -0
- package/dist/lib/docker-image.js +37 -0
- package/dist/lib/env-auth.js +873 -0
- package/dist/lib/env-config.js +94 -0
- package/dist/lib/env-guard.js +62 -0
- package/dist/lib/generated-command.js +186 -0
- package/dist/lib/http-request.js +49 -0
- package/dist/lib/inquirer-theme.js +17 -0
- package/dist/lib/inquirer.js +244 -0
- package/dist/lib/naming.js +70 -0
- package/dist/lib/object-utils.js +76 -0
- package/dist/lib/openapi.js +62 -0
- package/dist/lib/plugin-storage.js +64 -0
- package/dist/lib/post-processors.js +23 -0
- package/dist/lib/prompt-catalog-core.js +185 -0
- package/dist/lib/prompt-catalog-terminal.js +375 -0
- package/{src/index.js → dist/lib/prompt-catalog.js} +2 -6
- package/dist/lib/prompt-validators.js +240 -0
- package/dist/lib/prompt-web-ui.js +2103 -0
- package/dist/lib/resource-command.js +357 -0
- package/dist/lib/resource-request.js +104 -0
- package/dist/lib/run-npm.js +275 -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/session-id.js +17 -0
- package/dist/lib/session-integration.js +703 -0
- package/dist/lib/session-store.js +118 -0
- package/dist/lib/skills-manager.js +360 -0
- package/dist/lib/source-publish.js +306 -0
- package/dist/lib/source-registry.js +188 -0
- package/dist/lib/startup-update.js +285 -0
- package/dist/lib/ui.js +155 -0
- package/dist/locale/en-US.json +344 -0
- package/dist/locale/zh-CN.json +344 -0
- package/dist/post-processors/data-modeling.js +84 -0
- package/dist/post-processors/data-source-manager.js +138 -0
- package/dist/post-processors/index.js +19 -0
- package/nocobase-ctl.config.json +388 -0
- package/package.json +100 -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,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import { Command } from '@oclif/core';
|
|
10
|
+
import { resolveSessionIdentity } from '../../lib/session-id.js';
|
|
11
|
+
export default class SessionId extends Command {
|
|
12
|
+
static summary = 'Show the current effective session id';
|
|
13
|
+
static examples = [
|
|
14
|
+
'<%= config.bin %> <%= command.id %>',
|
|
15
|
+
];
|
|
16
|
+
async run() {
|
|
17
|
+
await this.parse(SessionId);
|
|
18
|
+
const identity = resolveSessionIdentity();
|
|
19
|
+
if (!identity) {
|
|
20
|
+
this.error('No effective session id is available. Run `nb session setup`, then open a new shell session or runtime.');
|
|
21
|
+
}
|
|
22
|
+
this.log(identity.id);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
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
|
+
/**
|
|
10
|
+
* This file is part of the NocoBase (R) project.
|
|
11
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
12
|
+
* Authors: NocoBase Team.
|
|
13
|
+
*
|
|
14
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
15
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
16
|
+
*/
|
|
17
|
+
import { Command, Flags } from '@oclif/core';
|
|
18
|
+
import { detectSessionShell, removeSessionIntegration } from '../../lib/session-integration.js';
|
|
19
|
+
export default class SessionRemove extends Command {
|
|
20
|
+
static summary = 'Remove shell session integration for NB_SESSION_ID';
|
|
21
|
+
static examples = [
|
|
22
|
+
'<%= config.bin %> <%= command.id %>',
|
|
23
|
+
'<%= config.bin %> <%= command.id %> --shell zsh',
|
|
24
|
+
];
|
|
25
|
+
static flags = {
|
|
26
|
+
shell: Flags.string({
|
|
27
|
+
description: 'Target shell to remove configuration from',
|
|
28
|
+
options: ['bash', 'zsh', 'fish', 'powershell', 'cmd'],
|
|
29
|
+
}),
|
|
30
|
+
};
|
|
31
|
+
async run() {
|
|
32
|
+
const { flags } = await this.parse(SessionRemove);
|
|
33
|
+
const shell = flags.shell ?? detectSessionShell();
|
|
34
|
+
if (!shell) {
|
|
35
|
+
this.error('Could not detect the current shell. Re-run with `--shell bash|zsh|fish|powershell|cmd`.');
|
|
36
|
+
}
|
|
37
|
+
const result = await removeSessionIntegration(shell);
|
|
38
|
+
this.log(`Session integration removed for ${result.shell}.`);
|
|
39
|
+
if (result.profileUpdated) {
|
|
40
|
+
for (const profileFile of result.profileFiles) {
|
|
41
|
+
this.log(`Profile updated: ${profileFile}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (result.managedFileRemoved) {
|
|
45
|
+
this.log(`Managed file removed: ${result.managedFile}`);
|
|
46
|
+
}
|
|
47
|
+
if (result.cmdAutoRunRemoved) {
|
|
48
|
+
this.log(`cmd AutoRun updated: ${result.cmdAutoRunLocation}`);
|
|
49
|
+
}
|
|
50
|
+
if (result.agentConfigUpdated) {
|
|
51
|
+
this.log(`Opencode config updated: ${result.agentConfigFile}`);
|
|
52
|
+
}
|
|
53
|
+
if (result.agentPluginRemoved) {
|
|
54
|
+
this.log(`Opencode agent plugin removed: ${result.agentPluginFile}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -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
|
+
/**
|
|
10
|
+
* This file is part of the NocoBase (R) project.
|
|
11
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
12
|
+
* Authors: NocoBase Team.
|
|
13
|
+
*
|
|
14
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
15
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
16
|
+
*/
|
|
17
|
+
import { Command, Flags } from '@oclif/core';
|
|
18
|
+
import { detectSessionShell, setupSessionIntegration } from '../../lib/session-integration.js';
|
|
19
|
+
export default class SessionSetup extends Command {
|
|
20
|
+
static summary = 'Set up shell session integration for NB_SESSION_ID';
|
|
21
|
+
static examples = [
|
|
22
|
+
'<%= config.bin %> <%= command.id %>',
|
|
23
|
+
'<%= config.bin %> <%= command.id %> --shell zsh',
|
|
24
|
+
'<%= config.bin %> <%= command.id %> --shell powershell',
|
|
25
|
+
];
|
|
26
|
+
static flags = {
|
|
27
|
+
shell: Flags.string({
|
|
28
|
+
description: 'Target shell to configure',
|
|
29
|
+
options: ['bash', 'zsh', 'fish', 'powershell', 'cmd'],
|
|
30
|
+
}),
|
|
31
|
+
};
|
|
32
|
+
async run() {
|
|
33
|
+
const { flags } = await this.parse(SessionSetup);
|
|
34
|
+
const shell = flags.shell ?? detectSessionShell();
|
|
35
|
+
if (!shell) {
|
|
36
|
+
this.error('Could not detect the current shell. Re-run with `--shell bash|zsh|fish|powershell|cmd`.');
|
|
37
|
+
}
|
|
38
|
+
const result = await setupSessionIntegration(shell);
|
|
39
|
+
this.log(`Session integration configured for ${result.shell}.`);
|
|
40
|
+
this.log(`Managed file: ${result.managedFile}`);
|
|
41
|
+
if (result.cmdAutoRunConfigured) {
|
|
42
|
+
this.log(`cmd AutoRun updated: ${result.cmdAutoRunLocation}`);
|
|
43
|
+
this.log('Open a new cmd session to initialize NB_SESSION_ID automatically.');
|
|
44
|
+
}
|
|
45
|
+
if (result.agentConfigured) {
|
|
46
|
+
this.log(`Opencode agent plugin installed: ${result.agentPluginFile}`);
|
|
47
|
+
this.log(`Opencode config updated: ${result.agentConfigFile}`);
|
|
48
|
+
}
|
|
49
|
+
else if (result.agentSkippedReason === 'opencode_dir_not_found') {
|
|
50
|
+
this.log('Opencode config directory not found. Skipped agent session integration.');
|
|
51
|
+
}
|
|
52
|
+
if (result.profileFiles.length > 0) {
|
|
53
|
+
for (const profileFile of result.profileFiles) {
|
|
54
|
+
this.log(`Profile updated: ${profileFile}`);
|
|
55
|
+
}
|
|
56
|
+
this.log('Open a new shell session or reload your profile to initialize NB_SESSION_ID automatically.');
|
|
57
|
+
}
|
|
58
|
+
if (result.manualStep) {
|
|
59
|
+
this.log(result.manualStep);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
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 { confirm } from "../../lib/inquirer.js";
|
|
11
|
+
import { setVerboseMode } from '../../lib/ui.js';
|
|
12
|
+
import { installNocoBaseSkills } from '../../lib/skills-manager.js';
|
|
13
|
+
export default class SkillsInstall extends Command {
|
|
14
|
+
static summary = 'Install the NocoBase AI coding skills globally';
|
|
15
|
+
static description = 'Install the NocoBase AI coding skills globally. If they are already installed, this command does not update them.';
|
|
16
|
+
static examples = [
|
|
17
|
+
'<%= config.bin %> <%= command.id %>',
|
|
18
|
+
'<%= config.bin %> <%= command.id %> --yes',
|
|
19
|
+
'<%= config.bin %> <%= command.id %> --json',
|
|
20
|
+
];
|
|
21
|
+
static flags = {
|
|
22
|
+
yes: Flags.boolean({
|
|
23
|
+
char: 'y',
|
|
24
|
+
description: 'Skip the install confirmation prompt',
|
|
25
|
+
default: false,
|
|
26
|
+
}),
|
|
27
|
+
json: Flags.boolean({
|
|
28
|
+
description: 'Output the result as JSON',
|
|
29
|
+
default: false,
|
|
30
|
+
}),
|
|
31
|
+
verbose: Flags.boolean({
|
|
32
|
+
description: 'Show detailed install output',
|
|
33
|
+
default: false,
|
|
34
|
+
}),
|
|
35
|
+
};
|
|
36
|
+
async run() {
|
|
37
|
+
const { flags } = await this.parse(SkillsInstall);
|
|
38
|
+
setVerboseMode(flags.verbose);
|
|
39
|
+
if (!flags.yes) {
|
|
40
|
+
let confirmed = false;
|
|
41
|
+
try {
|
|
42
|
+
confirmed = await confirm({
|
|
43
|
+
message: 'Install the NocoBase AI coding skills globally?',
|
|
44
|
+
default: true,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (!confirmed) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const result = await installNocoBaseSkills({
|
|
55
|
+
verbose: flags.verbose,
|
|
56
|
+
});
|
|
57
|
+
if (flags.json) {
|
|
58
|
+
this.log(JSON.stringify({
|
|
59
|
+
ok: true,
|
|
60
|
+
kind: 'skills',
|
|
61
|
+
action: result.action,
|
|
62
|
+
globalRoot: result.status.globalRoot,
|
|
63
|
+
workspaceRoot: result.status.workspaceRoot,
|
|
64
|
+
installedSkillNames: result.status.installedSkillNames,
|
|
65
|
+
installedVersion: result.status.installedVersion,
|
|
66
|
+
installedRef: result.status.installedRef,
|
|
67
|
+
}, null, 2));
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (result.action === 'noop') {
|
|
71
|
+
this.log(flags.verbose
|
|
72
|
+
? 'NocoBase AI coding skills are already installed globally. Run `nb skills update` to refresh them.'
|
|
73
|
+
: 'NocoBase AI coding skills are already installed globally.');
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
this.log(flags.verbose
|
|
77
|
+
? 'Installed the NocoBase AI coding skills globally.'
|
|
78
|
+
: 'Installed NocoBase AI coding skills globally.');
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
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 { confirm } from "../../lib/inquirer.js";
|
|
11
|
+
import { setVerboseMode } from '../../lib/ui.js';
|
|
12
|
+
import { removeNocoBaseSkills } from '../../lib/skills-manager.js';
|
|
13
|
+
export default class SkillsRemove extends Command {
|
|
14
|
+
static summary = 'Remove the globally installed NocoBase AI coding skills';
|
|
15
|
+
static description = 'Remove the skills installed from nocobase/skills globally. This only removes the skills managed by `nb`.';
|
|
16
|
+
static examples = [
|
|
17
|
+
'<%= config.bin %> <%= command.id %>',
|
|
18
|
+
'<%= config.bin %> <%= command.id %> --yes',
|
|
19
|
+
'<%= config.bin %> <%= command.id %> --json',
|
|
20
|
+
];
|
|
21
|
+
static flags = {
|
|
22
|
+
yes: Flags.boolean({
|
|
23
|
+
char: 'y',
|
|
24
|
+
description: 'Skip the remove confirmation prompt',
|
|
25
|
+
default: false,
|
|
26
|
+
}),
|
|
27
|
+
json: Flags.boolean({
|
|
28
|
+
description: 'Output the result as JSON',
|
|
29
|
+
default: false,
|
|
30
|
+
}),
|
|
31
|
+
verbose: Flags.boolean({
|
|
32
|
+
description: 'Show detailed remove output',
|
|
33
|
+
default: false,
|
|
34
|
+
}),
|
|
35
|
+
};
|
|
36
|
+
async run() {
|
|
37
|
+
const { flags } = await this.parse(SkillsRemove);
|
|
38
|
+
setVerboseMode(flags.verbose);
|
|
39
|
+
if (!flags.yes) {
|
|
40
|
+
let confirmed = false;
|
|
41
|
+
try {
|
|
42
|
+
confirmed = await confirm({
|
|
43
|
+
message: 'Remove the globally installed NocoBase AI coding skills?',
|
|
44
|
+
default: true,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (!confirmed) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const result = await removeNocoBaseSkills({
|
|
55
|
+
verbose: flags.verbose,
|
|
56
|
+
});
|
|
57
|
+
if (flags.json) {
|
|
58
|
+
this.log(JSON.stringify({
|
|
59
|
+
ok: true,
|
|
60
|
+
kind: 'skills',
|
|
61
|
+
action: result.action,
|
|
62
|
+
globalRoot: result.status.globalRoot,
|
|
63
|
+
workspaceRoot: result.status.workspaceRoot,
|
|
64
|
+
installedSkillNames: result.status.installedSkillNames,
|
|
65
|
+
installedVersion: result.status.installedVersion,
|
|
66
|
+
installedRef: result.status.installedRef,
|
|
67
|
+
}, null, 2));
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (result.action === 'noop') {
|
|
71
|
+
this.log(flags.verbose
|
|
72
|
+
? 'NocoBase AI coding skills are not installed globally.'
|
|
73
|
+
: 'NocoBase AI coding skills are not installed.');
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
this.log(flags.verbose
|
|
77
|
+
? 'Removed the global NocoBase AI coding skills.'
|
|
78
|
+
: 'Removed NocoBase AI coding skills globally.');
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
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 { confirm } from "../../lib/inquirer.js";
|
|
11
|
+
import { setVerboseMode } from '../../lib/ui.js';
|
|
12
|
+
import { updateNocoBaseSkills } from '../../lib/skills-manager.js';
|
|
13
|
+
export default class SkillsUpdate extends Command {
|
|
14
|
+
static summary = 'Update the globally installed NocoBase AI coding skills';
|
|
15
|
+
static description = 'Refresh the globally installed NocoBase AI coding skills. This command only updates an existing @nocobase/skills install.';
|
|
16
|
+
static examples = [
|
|
17
|
+
'<%= config.bin %> <%= command.id %>',
|
|
18
|
+
'<%= config.bin %> <%= command.id %> --yes',
|
|
19
|
+
'<%= config.bin %> <%= command.id %> --json',
|
|
20
|
+
];
|
|
21
|
+
static flags = {
|
|
22
|
+
yes: Flags.boolean({
|
|
23
|
+
char: 'y',
|
|
24
|
+
description: 'Skip the update confirmation prompt',
|
|
25
|
+
default: false,
|
|
26
|
+
}),
|
|
27
|
+
json: Flags.boolean({
|
|
28
|
+
description: 'Output the result as JSON',
|
|
29
|
+
default: false,
|
|
30
|
+
}),
|
|
31
|
+
verbose: Flags.boolean({
|
|
32
|
+
description: 'Show detailed update output',
|
|
33
|
+
default: false,
|
|
34
|
+
}),
|
|
35
|
+
};
|
|
36
|
+
async run() {
|
|
37
|
+
const { flags } = await this.parse(SkillsUpdate);
|
|
38
|
+
setVerboseMode(flags.verbose);
|
|
39
|
+
if (!flags.yes) {
|
|
40
|
+
let confirmed = false;
|
|
41
|
+
try {
|
|
42
|
+
confirmed = await confirm({
|
|
43
|
+
message: 'Update the globally installed NocoBase AI coding skills?',
|
|
44
|
+
default: true,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (!confirmed) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const result = await updateNocoBaseSkills({
|
|
55
|
+
verbose: flags.verbose,
|
|
56
|
+
});
|
|
57
|
+
if (flags.json) {
|
|
58
|
+
this.log(JSON.stringify({
|
|
59
|
+
ok: true,
|
|
60
|
+
kind: 'skills',
|
|
61
|
+
action: result.action,
|
|
62
|
+
reason: result.action === 'noop' ? result.reason : undefined,
|
|
63
|
+
globalRoot: result.status.globalRoot,
|
|
64
|
+
workspaceRoot: result.status.workspaceRoot,
|
|
65
|
+
installedSkillNames: result.status.installedSkillNames,
|
|
66
|
+
installedVersion: result.status.installedVersion,
|
|
67
|
+
installedRef: result.status.installedRef,
|
|
68
|
+
}, null, 2));
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (result.action === 'noop') {
|
|
72
|
+
if (result.reason === 'not-installed') {
|
|
73
|
+
this.log(flags.verbose
|
|
74
|
+
? 'NocoBase AI coding skills are not installed globally. Run `nb skills install` first.'
|
|
75
|
+
: 'Skipped skills update because NocoBase AI coding skills are not installed.');
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
this.log(flags.verbose
|
|
79
|
+
? 'NocoBase AI coding skills are already up to date globally.'
|
|
80
|
+
: 'NocoBase AI coding skills are up to date.');
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
this.log(flags.verbose
|
|
84
|
+
? 'Updated the global NocoBase AI coding skills.'
|
|
85
|
+
: 'Updated NocoBase AI coding skills globally.');
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -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
|
+
}
|