@nocobase/cli 2.1.0-beta.21 → 2.1.0-beta.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -49
- package/README.zh-CN.md +36 -47
- package/dist/commands/app/down.js +260 -0
- package/dist/commands/app/logs.js +98 -0
- package/dist/commands/app/restart.js +75 -0
- package/dist/commands/app/start.js +252 -0
- package/dist/commands/app/stop.js +98 -0
- package/dist/commands/app/upgrade.js +595 -0
- package/dist/commands/build.js +3 -48
- package/dist/commands/dev.js +3 -147
- package/dist/commands/down.js +3 -188
- package/dist/commands/download.js +4 -856
- package/dist/commands/env/add.js +28 -23
- package/dist/commands/env/info.js +152 -0
- package/dist/commands/env/list.js +23 -9
- package/dist/commands/env/shared.js +158 -0
- package/dist/commands/{prompts-stages.js → examples/prompts-stages.js} +3 -3
- package/dist/commands/{prompts-test.js → examples/prompts-test.js} +3 -3
- package/dist/commands/init.js +84 -6
- package/dist/commands/install.js +288 -61
- package/dist/commands/logs.js +3 -88
- package/dist/commands/plugin/disable.js +64 -0
- package/dist/commands/plugin/enable.js +64 -0
- package/dist/commands/plugin/list.js +62 -0
- package/dist/commands/pm/disable.js +3 -54
- package/dist/commands/pm/enable.js +3 -54
- package/dist/commands/pm/list.js +3 -52
- package/dist/commands/restart.js +3 -65
- package/dist/commands/scaffold/migration.js +1 -1
- package/dist/commands/scaffold/plugin.js +1 -1
- package/dist/commands/skills/remove.js +71 -0
- package/dist/commands/skills/update.js +7 -0
- package/dist/commands/source/build.js +58 -0
- package/dist/commands/source/dev.js +157 -0
- package/dist/commands/source/download.js +866 -0
- package/dist/commands/source/test.js +467 -0
- package/dist/commands/start.js +3 -209
- package/dist/commands/stop.js +3 -88
- package/dist/commands/test.js +3 -457
- package/dist/commands/upgrade.js +3 -585
- package/dist/help/runtime-help.js +3 -0
- package/dist/lib/api-client.js +20 -6
- package/dist/lib/app-health.js +126 -0
- package/dist/lib/app-managed-resources.js +264 -0
- package/dist/lib/auth-store.js +5 -2
- package/dist/lib/cli-home.js +7 -6
- package/dist/lib/cli-locale.js +15 -1
- package/dist/lib/env-config.js +80 -0
- package/dist/lib/prompt-web-ui.js +13 -6
- package/dist/lib/skills-manager.js +34 -7
- package/package.json +27 -4
- package/dist/commands/ps.js +0 -119
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/cli",
|
|
3
|
-
"version": "2.1.0-beta.
|
|
3
|
+
"version": "2.1.0-beta.23",
|
|
4
4
|
"description": "NocoBase Command Line Tool",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/generated/command-registry.js",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"clean": "node ./scripts/clean.mjs",
|
|
9
9
|
"build": "node ./scripts/build.mjs",
|
|
10
|
-
"test": "TEST_ENV=server-side yarn --cwd ../../.. vitest run packages/core/cli"
|
|
10
|
+
"test": "NB_CLI_ROOT=. TEST_ENV=server-side yarn --cwd ../../.. vitest run packages/core/cli"
|
|
11
11
|
},
|
|
12
12
|
"keywords": [],
|
|
13
13
|
"author": "",
|
|
@@ -36,8 +36,27 @@
|
|
|
36
36
|
"dirname": "nb",
|
|
37
37
|
"topicSeparator": " ",
|
|
38
38
|
"topics": {
|
|
39
|
+
"app": {
|
|
40
|
+
"description": "Manage NocoBase app runtimes: start, stop, restart, logs, and upgrades."
|
|
41
|
+
},
|
|
42
|
+
"source": {
|
|
43
|
+
"description": "Work with the local NocoBase source project: download, develop, build, and test."
|
|
44
|
+
},
|
|
45
|
+
"scaffold": {
|
|
46
|
+
"description": "Generate NocoBase plugin development scaffolds."
|
|
47
|
+
},
|
|
48
|
+
"plugin": {
|
|
49
|
+
"description": "Manage plugins in the selected NocoBase env."
|
|
50
|
+
},
|
|
51
|
+
"pm": {
|
|
52
|
+
"description": "Manage plugins in the selected NocoBase env.",
|
|
53
|
+
"hidden": true
|
|
54
|
+
},
|
|
55
|
+
"db": {
|
|
56
|
+
"description": "Manage the built-in database for the selected env."
|
|
57
|
+
},
|
|
39
58
|
"env": {
|
|
40
|
-
"description": "Manage NocoBase project environments and
|
|
59
|
+
"description": "Manage NocoBase project environments, status, details, and command runtimes."
|
|
41
60
|
},
|
|
42
61
|
"self": {
|
|
43
62
|
"description": "Inspect or update the NocoBase CLI itself."
|
|
@@ -45,6 +64,10 @@
|
|
|
45
64
|
"skills": {
|
|
46
65
|
"description": "Inspect or synchronize NocoBase AI coding skills for the current workspace."
|
|
47
66
|
},
|
|
67
|
+
"examples": {
|
|
68
|
+
"description": "Internal example commands for prompt and UI experiments.",
|
|
69
|
+
"hidden": true
|
|
70
|
+
},
|
|
48
71
|
"api": {
|
|
49
72
|
"description": "Work with NocoBase API."
|
|
50
73
|
}
|
|
@@ -68,5 +91,5 @@
|
|
|
68
91
|
"type": "git",
|
|
69
92
|
"url": "git+https://github.com/nocobase/nocobase.git"
|
|
70
93
|
},
|
|
71
|
-
"gitHead": "
|
|
94
|
+
"gitHead": "bb4c0d3551bf9eff505b63756dd24a0813231f16"
|
|
72
95
|
}
|
package/dist/commands/ps.js
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
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 { 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
|
-
}
|
|
119
|
-
}
|