@nocobase/cli 2.1.0-beta.17 → 2.1.0-beta.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -0
- package/bin/run.js +13 -11
- package/dist/commands/download.js +106 -20
- package/dist/commands/init.js +16 -7
- package/dist/commands/install.js +56 -18
- package/dist/commands/self/check.js +71 -0
- package/dist/commands/self/index.js +20 -0
- package/dist/commands/self/update.js +76 -0
- package/dist/commands/skills/check.js +63 -0
- package/dist/commands/skills/index.js +20 -0
- package/dist/commands/skills/install.js +58 -0
- package/dist/commands/skills/update.js +58 -0
- package/dist/commands/test.js +466 -0
- package/dist/lib/prompt-catalog.js +11 -4
- package/dist/lib/prompt-web-ui.js +45 -10
- package/dist/lib/run-npm.js +82 -8
- package/dist/lib/self-manager.js +246 -0
- package/dist/lib/skills-manager.js +202 -0
- package/dist/locale/en-US.json +19 -5
- package/dist/locale/zh-CN.json +20 -6
- package/package.json +10 -4
|
@@ -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` to update the CLI.');
|
|
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,76 @@
|
|
|
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 } 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
|
+
};
|
|
36
|
+
async run() {
|
|
37
|
+
const { flags } = await this.parse(SelfUpdate);
|
|
38
|
+
const status = await inspectSelfStatus({
|
|
39
|
+
channel: flags.channel,
|
|
40
|
+
});
|
|
41
|
+
if (!status.updatable) {
|
|
42
|
+
this.error(formatUnsupportedSelfUpdateMessage(status));
|
|
43
|
+
}
|
|
44
|
+
if (!status.latestVersion && status.registryError) {
|
|
45
|
+
this.error(formatSelfUpdateUnavailableMessage(status));
|
|
46
|
+
}
|
|
47
|
+
if (!flags.yes && status.updateAvailable) {
|
|
48
|
+
const confirmed = await confirmAction(`Update ${status.packageName} from ${status.currentVersion} to ${status.latestVersion}?`, { defaultValue: false });
|
|
49
|
+
if (!confirmed) {
|
|
50
|
+
this.log('Skipped CLI update.');
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const result = await updateSelf({
|
|
55
|
+
channel: flags.channel,
|
|
56
|
+
});
|
|
57
|
+
if (flags.json) {
|
|
58
|
+
this.log(JSON.stringify({
|
|
59
|
+
ok: true,
|
|
60
|
+
kind: 'self',
|
|
61
|
+
action: result.action,
|
|
62
|
+
packageName: result.status.packageName,
|
|
63
|
+
packageSpec: result.packageSpec,
|
|
64
|
+
channel: result.status.channel,
|
|
65
|
+
fromVersion: result.status.currentVersion,
|
|
66
|
+
toVersion: result.targetVersion,
|
|
67
|
+
}, null, 2));
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (result.action === 'noop') {
|
|
71
|
+
this.log(`NocoBase CLI is already up to date at ${result.status.currentVersion}.`);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
this.log(`Updated NocoBase CLI from ${result.status.currentVersion} using ${result.packageSpec}${result.targetVersion ? ` (latest ${result.status.channel} resolves to ${result.targetVersion})` : ''}.`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
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 NocoBase AI coding skills installed for this workspace';
|
|
14
|
+
static description = 'Inspect the current workspace for 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
|
+
workspaceRoot: status.workspaceRoot,
|
|
33
|
+
installed: status.installed,
|
|
34
|
+
managedByNb: status.managedByNb,
|
|
35
|
+
sourcePackage: status.sourcePackage,
|
|
36
|
+
installedSkillNames: status.installedSkillNames,
|
|
37
|
+
installedRef: status.installedRef,
|
|
38
|
+
latestRef: status.latestRef,
|
|
39
|
+
updateAvailable: status.updateAvailable,
|
|
40
|
+
recommendedCommand: status.installed ? 'nb skills update --yes' : 'nb skills install --yes',
|
|
41
|
+
registryError: status.registryError,
|
|
42
|
+
}, null, 2));
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
this.log(renderTable(['Field', 'Value'], [
|
|
46
|
+
['Workspace', status.workspaceRoot],
|
|
47
|
+
['Installed', status.installed ? 'yes' : 'no'],
|
|
48
|
+
['Managed by nb', status.managedByNb ? 'yes' : 'no'],
|
|
49
|
+
['Installed skills', status.installedSkillNames.length ? status.installedSkillNames.join(', ') : '(none)'],
|
|
50
|
+
['Update available', status.updateAvailable === null ? 'unknown' : status.updateAvailable ? 'yes' : 'no'],
|
|
51
|
+
]));
|
|
52
|
+
if (!status.installed) {
|
|
53
|
+
printInfo('Run `nb skills install` to install the NocoBase AI coding skills for this workspace.');
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (status.updateAvailable) {
|
|
57
|
+
printInfo('Run `nb skills update` to refresh the NocoBase AI coding skills for this workspace.');
|
|
58
|
+
}
|
|
59
|
+
if (status.registryError) {
|
|
60
|
+
printInfo(`Update check warning: ${status.registryError}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -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 NocoBase AI coding skills for this workspace';
|
|
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,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 { Command, Flags } from '@oclif/core';
|
|
10
|
+
import { confirmAction } from '../../lib/ui.js';
|
|
11
|
+
import { installNocoBaseSkills } from '../../lib/skills-manager.js';
|
|
12
|
+
export default class SkillsInstall extends Command {
|
|
13
|
+
static summary = 'Install the NocoBase AI coding skills for this workspace';
|
|
14
|
+
static description = 'Install the NocoBase AI coding skills for the current workspace. If they are already installed, this command does not update them.';
|
|
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 install confirmation prompt',
|
|
24
|
+
default: false,
|
|
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(SkillsInstall);
|
|
33
|
+
if (!flags.yes) {
|
|
34
|
+
const confirmed = await confirmAction('Install the NocoBase AI coding skills for this workspace?', { defaultValue: true });
|
|
35
|
+
if (!confirmed) {
|
|
36
|
+
this.log('Skipped skills install.');
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const result = await installNocoBaseSkills();
|
|
41
|
+
if (flags.json) {
|
|
42
|
+
this.log(JSON.stringify({
|
|
43
|
+
ok: true,
|
|
44
|
+
kind: 'skills',
|
|
45
|
+
action: result.action,
|
|
46
|
+
workspaceRoot: result.status.workspaceRoot,
|
|
47
|
+
installedSkillNames: result.status.installedSkillNames,
|
|
48
|
+
installedRef: result.status.installedRef,
|
|
49
|
+
}, null, 2));
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (result.action === 'noop') {
|
|
53
|
+
this.log('NocoBase AI coding skills are already installed for this workspace. Run `nb skills update` to refresh them.');
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
this.log('Installed the NocoBase AI coding skills for this workspace.');
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -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 { Command, Flags } from '@oclif/core';
|
|
10
|
+
import { confirmAction } from '../../lib/ui.js';
|
|
11
|
+
import { updateNocoBaseSkills } from '../../lib/skills-manager.js';
|
|
12
|
+
export default class SkillsUpdate extends Command {
|
|
13
|
+
static summary = 'Update the NocoBase AI coding skills for this workspace';
|
|
14
|
+
static description = 'Refresh the NocoBase AI coding skills for the current workspace. This command only updates an existing nocobase/skills install.';
|
|
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 update confirmation prompt',
|
|
24
|
+
default: false,
|
|
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(SkillsUpdate);
|
|
33
|
+
if (!flags.yes) {
|
|
34
|
+
const confirmed = await confirmAction('Update the NocoBase AI coding skills for this workspace?', { defaultValue: true });
|
|
35
|
+
if (!confirmed) {
|
|
36
|
+
this.log('Skipped skills update.');
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const result = await updateNocoBaseSkills();
|
|
41
|
+
if (flags.json) {
|
|
42
|
+
this.log(JSON.stringify({
|
|
43
|
+
ok: true,
|
|
44
|
+
kind: 'skills',
|
|
45
|
+
action: result.action,
|
|
46
|
+
workspaceRoot: result.status.workspaceRoot,
|
|
47
|
+
installedSkillNames: result.status.installedSkillNames,
|
|
48
|
+
installedRef: result.status.installedRef,
|
|
49
|
+
}, null, 2));
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (result.action === 'noop') {
|
|
53
|
+
this.log('NocoBase AI coding skills are already up to date for this workspace.');
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
this.log('Updated the NocoBase AI coding skills for this workspace.');
|
|
57
|
+
}
|
|
58
|
+
}
|