@nocobase/cli 2.1.0-alpha.40 → 2.1.0-alpha.46
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 +20 -8
- package/README.zh-CN.md +20 -8
- package/bin/run.js +9 -37
- package/dist/commands/app/destroy.js +225 -0
- package/dist/commands/app/down.js +24 -254
- package/dist/commands/app/restart.js +12 -5
- package/dist/commands/app/shared.js +122 -0
- package/dist/commands/app/start.js +41 -59
- package/dist/commands/app/stop.js +72 -26
- package/dist/commands/app/upgrade.js +312 -429
- package/dist/commands/config/delete.js +8 -1
- package/dist/commands/config/get.js +5 -0
- package/dist/commands/config/set.js +10 -1
- package/dist/commands/db/ps.js +5 -18
- package/dist/commands/db/start.js +23 -8
- package/dist/commands/env/add.js +66 -6
- package/dist/commands/env/auth.js +86 -27
- package/dist/commands/env/info.js +52 -8
- package/dist/commands/env/list.js +6 -7
- package/dist/commands/env/shared.js +41 -3
- package/dist/commands/env/status.js +10 -7
- package/dist/commands/init.js +214 -136
- package/dist/commands/install.js +364 -294
- package/dist/commands/license/plugins/shared.js +9 -3
- package/dist/commands/license/plugins/sync.js +54 -25
- package/dist/commands/self/update.js +58 -1
- package/dist/commands/source/dev.js +5 -5
- package/dist/commands/source/download.js +29 -25
- package/dist/generated/command-registry.js +3 -2
- package/dist/lib/api-client.js +6 -0
- package/dist/lib/api-command-compat.js +641 -0
- package/dist/lib/app-health.js +31 -18
- package/dist/lib/app-managed-resources.js +1 -1
- package/dist/lib/app-runtime.js +2 -2
- package/dist/lib/auth-store.js +56 -19
- package/dist/lib/backup.js +3 -3
- package/dist/lib/bootstrap.js +14 -8
- package/dist/lib/cli-config.js +137 -4
- package/dist/lib/cli-entry-error.js +44 -0
- package/dist/lib/cli-locale.js +19 -7
- package/dist/lib/db-connection-check.js +61 -0
- package/dist/lib/docker-log-stream.js +45 -0
- package/dist/lib/env-auth.js +98 -11
- package/dist/lib/env-config.js +3 -2
- package/dist/lib/env-guard.js +1 -1
- package/dist/lib/generated-command.js +17 -0
- package/dist/lib/prompt-validators.js +23 -5
- package/dist/lib/prompt-web-ui.js +143 -19
- package/dist/lib/run-npm.js +133 -23
- package/dist/lib/skills-manager.js +80 -4
- package/dist/lib/source-publish.js +4 -1
- package/dist/lib/startup-update.js +74 -50
- package/dist/lib/ui.js +4 -1
- package/dist/locale/en-US.json +92 -5
- package/dist/locale/zh-CN.json +92 -5
- package/package.json +34 -2
|
@@ -7,15 +7,14 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
import { Command } from '@oclif/core';
|
|
10
|
-
import { getCurrentEnvName, listEnvs } from '../../lib/auth-store.js';
|
|
10
|
+
import { getCurrentEnvName, listEnvs, resolveConfiguredAuthType } from '../../lib/auth-store.js';
|
|
11
11
|
import { resolveDefaultConfigScope } from '../../lib/cli-home.js';
|
|
12
|
+
import { translateCli } from '../../lib/cli-locale.js';
|
|
12
13
|
import { renderTable } from '../../lib/ui.js';
|
|
13
14
|
import { resolveApiBaseUrl } from './shared.js';
|
|
14
15
|
export default class EnvList extends Command {
|
|
15
16
|
static summary = 'List configured environments';
|
|
16
|
-
static examples = [
|
|
17
|
-
'<%= config.bin %> <%= command.id %>',
|
|
18
|
-
];
|
|
17
|
+
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
19
18
|
async run() {
|
|
20
19
|
await this.parse(EnvList);
|
|
21
20
|
const scope = resolveDefaultConfigScope();
|
|
@@ -23,8 +22,8 @@ export default class EnvList extends Command {
|
|
|
23
22
|
const currentEnv = await getCurrentEnvName({ scope });
|
|
24
23
|
const names = Object.keys(envs).sort();
|
|
25
24
|
if (!names.length) {
|
|
26
|
-
this.log('
|
|
27
|
-
this.log('
|
|
25
|
+
this.log(translateCli('commands.env.messages.noEnvsConfigured'));
|
|
26
|
+
this.log(translateCli('commands.env.messages.noEnvsConfiguredHelp'));
|
|
28
27
|
return;
|
|
29
28
|
}
|
|
30
29
|
const rows = [];
|
|
@@ -35,7 +34,7 @@ export default class EnvList extends Command {
|
|
|
35
34
|
name,
|
|
36
35
|
env.kind ?? '-',
|
|
37
36
|
resolveApiBaseUrl(env),
|
|
38
|
-
env.auth?.type ?? '',
|
|
37
|
+
resolveConfiguredAuthType(env) ?? env.auth?.type ?? '',
|
|
39
38
|
env.runtime?.version ?? '',
|
|
40
39
|
]);
|
|
41
40
|
}
|
|
@@ -11,13 +11,51 @@ import { executeRawApiRequest } from '../../lib/api-client.js';
|
|
|
11
11
|
export function resolveApiBaseUrl(config) {
|
|
12
12
|
return String(config.apiBaseUrl ?? config.baseUrl ?? config.apibaseUrl ?? '').trim();
|
|
13
13
|
}
|
|
14
|
+
function buildAppPath(publicPath, subapp) {
|
|
15
|
+
const normalizedPublicPath = publicPath.replace(/\/+$/, '');
|
|
16
|
+
if (!subapp) {
|
|
17
|
+
return normalizedPublicPath ? `${normalizedPublicPath}/` : '/';
|
|
18
|
+
}
|
|
19
|
+
const normalizedSubapp = subapp.replace(/^\/+|\/+$/g, '');
|
|
20
|
+
return `${normalizedPublicPath ? normalizedPublicPath : ''}/apps/${normalizedSubapp}/`;
|
|
21
|
+
}
|
|
22
|
+
export function resolveAppUrlFromApiBaseUrl(apiBaseUrl) {
|
|
23
|
+
const value = String(apiBaseUrl ?? '').trim();
|
|
24
|
+
if (!value) {
|
|
25
|
+
return '';
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
const url = new URL(value);
|
|
29
|
+
const subappMatch = url.pathname.match(/^(.*)\/api\/__app\/([^/]+)\/?$/);
|
|
30
|
+
if (subappMatch) {
|
|
31
|
+
url.pathname = buildAppPath(subappMatch[1] ?? '', subappMatch[2]);
|
|
32
|
+
url.search = '';
|
|
33
|
+
url.hash = '';
|
|
34
|
+
return url.toString();
|
|
35
|
+
}
|
|
36
|
+
const appMatch = url.pathname.match(/^(.*)\/api\/?$/);
|
|
37
|
+
if (appMatch) {
|
|
38
|
+
url.pathname = buildAppPath(appMatch[1] ?? '');
|
|
39
|
+
url.search = '';
|
|
40
|
+
url.hash = '';
|
|
41
|
+
return url.toString();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
47
|
+
return value;
|
|
48
|
+
}
|
|
14
49
|
export function appUrl(runtime) {
|
|
50
|
+
const resolvedFromApiBaseUrl = resolveAppUrlFromApiBaseUrl(runtime.env.apiBaseUrl ?? resolveApiBaseUrl(runtime.env.config));
|
|
51
|
+
if (resolvedFromApiBaseUrl) {
|
|
52
|
+
return resolvedFromApiBaseUrl;
|
|
53
|
+
}
|
|
15
54
|
const port = String(runtime.env.config.appPort ?? '').trim();
|
|
16
55
|
if (port) {
|
|
17
|
-
return `http://127.0.0.1:${port}
|
|
56
|
+
return `http://127.0.0.1:${port}/`;
|
|
18
57
|
}
|
|
19
|
-
|
|
20
|
-
return baseUrl.replace(/\/api\/?$/, '');
|
|
58
|
+
return '';
|
|
21
59
|
}
|
|
22
60
|
export function appRootPath(runtime) {
|
|
23
61
|
if (runtime.kind === 'http' || runtime.kind === 'docker') {
|
|
@@ -10,6 +10,7 @@ import { Args, Command, Flags } from '@oclif/core';
|
|
|
10
10
|
import { formatMissingManagedAppEnvMessage, resolveManagedAppRuntime } from '../../lib/app-runtime.js';
|
|
11
11
|
import { getCurrentEnvName, listEnvs } from '../../lib/auth-store.js';
|
|
12
12
|
import { resolveDefaultConfigScope } from '../../lib/cli-home.js';
|
|
13
|
+
import { translateCli } from '../../lib/cli-locale.js';
|
|
13
14
|
import { renderTable } from '../../lib/ui.js';
|
|
14
15
|
import { apiStatus, runtimeStatus } from './shared.js';
|
|
15
16
|
export default class EnvStatus extends Command {
|
|
@@ -46,13 +47,11 @@ export default class EnvStatus extends Command {
|
|
|
46
47
|
const { envs } = await listEnvs({ scope });
|
|
47
48
|
const configuredEnvNames = Object.keys(envs).sort();
|
|
48
49
|
if (!configuredEnvNames.length) {
|
|
49
|
-
this.log('
|
|
50
|
-
this.log('
|
|
50
|
+
this.log(translateCli('commands.env.messages.noEnvsConfigured'));
|
|
51
|
+
this.log(translateCli('commands.env.messages.noEnvsConfiguredHelp'));
|
|
51
52
|
return;
|
|
52
53
|
}
|
|
53
|
-
const envNames = flags.all
|
|
54
|
-
? configuredEnvNames
|
|
55
|
-
: [requestedEnv || (await getCurrentEnvName({ scope }))];
|
|
54
|
+
const envNames = flags.all ? configuredEnvNames : [requestedEnv || (await getCurrentEnvName({ scope }))];
|
|
56
55
|
const rows = [];
|
|
57
56
|
for (const envName of envNames) {
|
|
58
57
|
const runtime = await resolveManagedAppRuntime(envName);
|
|
@@ -76,8 +75,12 @@ export default class EnvStatus extends Command {
|
|
|
76
75
|
rows.push({
|
|
77
76
|
env: runtime.envName,
|
|
78
77
|
status,
|
|
79
|
-
apiBaseUrl: runtime.env.apiBaseUrl
|
|
80
|
-
|
|
78
|
+
apiBaseUrl: runtime.env.apiBaseUrl ||
|
|
79
|
+
String(runtime.env.config.apiBaseUrl ??
|
|
80
|
+
runtime.env.config.baseUrl ??
|
|
81
|
+
envs[envName]?.apiBaseUrl ??
|
|
82
|
+
envs[envName]?.baseUrl ??
|
|
83
|
+
'').trim(),
|
|
81
84
|
});
|
|
82
85
|
}
|
|
83
86
|
if (flags['json-output']) {
|