@nocobase/cli 2.1.0-alpha.46 → 2.1.0-alpha.47
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 +201 -0
- package/README.md +63 -380
- package/assets/env-proxy/nginx/app.conf.tpl +23 -0
- package/assets/env-proxy/nginx/nocobase.conf.tpl +5 -0
- package/assets/env-proxy/nginx/snippets/dist-location.conf +5 -0
- package/assets/env-proxy/nginx/snippets/gzip.conf +17 -0
- package/assets/env-proxy/nginx/snippets/log-format-http.conf +13 -0
- package/assets/env-proxy/nginx/snippets/maps-http.conf +14 -0
- package/assets/env-proxy/nginx/snippets/mime-types.conf +98 -0
- package/assets/env-proxy/nginx/snippets/proxy-location.conf +17 -0
- package/assets/env-proxy/nginx/snippets/spa-location.conf +6 -0
- package/assets/env-proxy/nginx/snippets/uploads-location.conf +21 -0
- package/bin/run.js +40 -3
- package/dist/commands/app/autostart/disable.js +55 -0
- package/dist/commands/app/autostart/enable.js +55 -0
- package/dist/commands/app/autostart/list.js +37 -0
- package/dist/commands/app/autostart/run.js +84 -0
- package/dist/commands/app/autostart/shared.js +49 -0
- package/dist/commands/app/destroy.js +21 -12
- package/dist/commands/app/down.js +2 -2
- package/dist/commands/app/logs.js +2 -1
- package/dist/commands/app/restart.js +89 -24
- package/dist/commands/app/shared.js +3 -2
- package/dist/commands/app/start.js +142 -38
- package/dist/commands/app/stop.js +31 -2
- package/dist/commands/app/upgrade.js +9 -5
- package/dist/commands/config/delete.js +6 -1
- package/dist/commands/config/get.js +6 -1
- package/dist/commands/config/set.js +7 -2
- package/dist/commands/env/add.js +24 -44
- package/dist/commands/env/info.js +3 -2
- package/dist/commands/env/proxy/caddy.js +28 -0
- package/dist/commands/env/proxy/index.js +353 -0
- package/dist/commands/env/proxy/nginx.js +28 -0
- package/dist/commands/env/remove.js +112 -22
- package/dist/commands/env/shared.js +17 -9
- package/dist/commands/env/update.js +385 -21
- package/dist/commands/init.js +350 -98
- package/dist/commands/install.js +218 -75
- package/dist/commands/license/activate.js +63 -244
- package/dist/commands/license/plugins/shared.js +64 -13
- package/dist/commands/plugin/import.js +108 -0
- package/dist/commands/revision/create.js +89 -0
- package/dist/commands/source/test.js +13 -14
- package/dist/lib/app-health.js +5 -5
- package/dist/lib/app-managed-resources.js +24 -8
- package/dist/lib/app-public-path.js +80 -0
- package/dist/lib/app-runtime.js +10 -1
- package/dist/lib/auth-store.js +119 -4
- package/dist/lib/cli-config.js +191 -3
- package/dist/lib/cli-entry-error.js +8 -0
- package/dist/lib/command-log.js +284 -0
- package/dist/lib/docker-env-file.js +10 -2
- package/dist/lib/env-auth.js +4 -1
- package/dist/lib/env-command-config.js +45 -0
- package/dist/lib/env-config.js +7 -2
- package/dist/lib/env-guard.js +9 -10
- package/dist/lib/env-paths.js +101 -0
- package/dist/lib/env-proxy.js +1295 -0
- package/dist/lib/inquirer.js +4 -5
- package/dist/lib/managed-env-file.js +98 -0
- package/dist/lib/plugin-import.js +279 -0
- package/dist/lib/prompt-catalog-core.js +3 -2
- package/dist/lib/prompt-validators.js +14 -0
- package/dist/lib/prompt-web-ui.js +8 -1
- package/dist/lib/run-npm.js +56 -12
- package/dist/lib/skills-manager.js +3 -1
- package/dist/lib/source-publish.js +18 -1
- package/dist/lib/ui.js +2 -1
- package/dist/locale/en-US.json +116 -22
- package/dist/locale/zh-CN.json +113 -19
- package/package.json +5 -7
- package/scripts/build.mjs +34 -0
- package/scripts/clean.mjs +9 -0
- package/tsconfig.json +19 -0
- package/LICENSE.txt +0 -107
- package/README.zh-CN.md +0 -355
package/dist/lib/env-auth.js
CHANGED
|
@@ -34,6 +34,9 @@ export function getOauthResource(issuerOrBaseUrl) {
|
|
|
34
34
|
export function getDefaultOauthScope() {
|
|
35
35
|
return DEFAULT_OAUTH_SCOPE;
|
|
36
36
|
}
|
|
37
|
+
export function getOauthLoopbackRedirectUri(port) {
|
|
38
|
+
return `http://${LOOPBACK_HOST}:${port}/callback`;
|
|
39
|
+
}
|
|
37
40
|
function formatApiAuthError(prefix, data, fallbackStatus) {
|
|
38
41
|
if (typeof data === 'string' && data.trim()) {
|
|
39
42
|
return `${prefix}: ${data}`;
|
|
@@ -655,7 +658,7 @@ async function createLoopbackServer(state) {
|
|
|
655
658
|
return;
|
|
656
659
|
}
|
|
657
660
|
resolve({
|
|
658
|
-
redirectUri:
|
|
661
|
+
redirectUri: getOauthLoopbackRedirectUri(address.port),
|
|
659
662
|
waitForCode,
|
|
660
663
|
close,
|
|
661
664
|
});
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
export const ENV_STRING_CONFIG_FLAG_MAP = {
|
|
10
|
+
source: 'source',
|
|
11
|
+
'download-version': 'downloadVersion',
|
|
12
|
+
'docker-registry': 'dockerRegistry',
|
|
13
|
+
'docker-platform': 'dockerPlatform',
|
|
14
|
+
'git-url': 'gitUrl',
|
|
15
|
+
'npm-registry': 'npmRegistry',
|
|
16
|
+
'app-path': 'appPath',
|
|
17
|
+
'app-root-path': 'appRootPath',
|
|
18
|
+
'storage-path': 'storagePath',
|
|
19
|
+
'app-public-path': 'appPublicPath',
|
|
20
|
+
'cdn-base-url': 'cdnBaseUrl',
|
|
21
|
+
'env-file': 'envFile',
|
|
22
|
+
'app-port': 'appPort',
|
|
23
|
+
'app-key': 'appKey',
|
|
24
|
+
timezone: 'timezone',
|
|
25
|
+
'db-dialect': 'dbDialect',
|
|
26
|
+
'builtin-db-image': 'builtinDbImage',
|
|
27
|
+
'db-host': 'dbHost',
|
|
28
|
+
'db-port': 'dbPort',
|
|
29
|
+
'db-database': 'dbDatabase',
|
|
30
|
+
'db-user': 'dbUser',
|
|
31
|
+
'db-password': 'dbPassword',
|
|
32
|
+
'db-schema': 'dbSchema',
|
|
33
|
+
'db-table-prefix': 'dbTablePrefix',
|
|
34
|
+
'root-username': 'rootUsername',
|
|
35
|
+
'root-email': 'rootEmail',
|
|
36
|
+
'root-password': 'rootPassword',
|
|
37
|
+
'root-nickname': 'rootNickname',
|
|
38
|
+
};
|
|
39
|
+
export const ENV_BOOLEAN_CONFIG_FLAG_MAP = {
|
|
40
|
+
'builtin-db': 'builtinDb',
|
|
41
|
+
'dev-dependencies': 'devDependencies',
|
|
42
|
+
build: 'build',
|
|
43
|
+
'build-dts': 'buildDts',
|
|
44
|
+
'db-underscored': 'dbUnderscored',
|
|
45
|
+
};
|
package/dist/lib/env-config.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
|
+
import { resolveAppPublicPath } from './app-public-path.js';
|
|
9
10
|
const STRING_ENV_CONFIG_KEYS = [
|
|
10
11
|
'source',
|
|
11
12
|
'downloadVersion',
|
|
@@ -13,8 +14,11 @@ const STRING_ENV_CONFIG_KEYS = [
|
|
|
13
14
|
'dockerPlatform',
|
|
14
15
|
'gitUrl',
|
|
15
16
|
'npmRegistry',
|
|
17
|
+
'appPath',
|
|
16
18
|
'appRootPath',
|
|
17
19
|
'storagePath',
|
|
20
|
+
'appPublicPath',
|
|
21
|
+
'cdnBaseUrl',
|
|
18
22
|
'envFile',
|
|
19
23
|
'appPort',
|
|
20
24
|
'appKey',
|
|
@@ -47,11 +51,12 @@ function trimConfigValue(value) {
|
|
|
47
51
|
}
|
|
48
52
|
function resolveEnvKind(input) {
|
|
49
53
|
const source = trimConfigValue(input.source);
|
|
54
|
+
const appPath = trimConfigValue(input.appPath);
|
|
50
55
|
const appRootPath = trimConfigValue(input.appRootPath);
|
|
51
56
|
if (source === 'docker') {
|
|
52
57
|
return 'docker';
|
|
53
58
|
}
|
|
54
|
-
if (source === 'npm' || source === 'git' || source === 'local' || appRootPath) {
|
|
59
|
+
if (source === 'npm' || source === 'git' || source === 'local' || appPath || appRootPath) {
|
|
55
60
|
return 'local';
|
|
56
61
|
}
|
|
57
62
|
return 'http';
|
|
@@ -64,7 +69,7 @@ export function buildStoredEnvConfig(input) {
|
|
|
64
69
|
for (const key of STRING_ENV_CONFIG_KEYS) {
|
|
65
70
|
const value = trimConfigValue(input[key]);
|
|
66
71
|
if (value) {
|
|
67
|
-
envConfig[key] = value;
|
|
72
|
+
envConfig[key] = key === 'appPublicPath' ? resolveAppPublicPath(value) : value;
|
|
68
73
|
}
|
|
69
74
|
}
|
|
70
75
|
for (const key of BOOLEAN_ENV_CONFIG_KEYS) {
|
package/dist/lib/env-guard.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { stdin as input, stdout as output } from 'node:process';
|
|
10
10
|
import { getCurrentEnvName } from './auth-store.js';
|
|
11
|
+
import { translateCli } from './cli-locale.js';
|
|
11
12
|
import { confirm } from "./inquirer.js";
|
|
12
13
|
function normalizeEnvName(value) {
|
|
13
14
|
const text = String(value ?? '').trim();
|
|
@@ -23,18 +24,16 @@ function isInteractiveTerminal() {
|
|
|
23
24
|
return Boolean(input.isTTY && output.isTTY);
|
|
24
25
|
}
|
|
25
26
|
function formatCrossEnvPromptMessage(currentEnv, requestedEnv) {
|
|
26
|
-
return
|
|
27
|
+
return translateCli('commands.shared.crossEnv.prompt', {
|
|
28
|
+
currentEnv,
|
|
29
|
+
requestedEnv,
|
|
30
|
+
});
|
|
27
31
|
}
|
|
28
32
|
export function formatCrossEnvRefusalMessage(currentEnv, requestedEnv) {
|
|
29
|
-
return
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
'',
|
|
34
|
-
'To continue:',
|
|
35
|
-
`- run \`nb env use ${requestedEnv}\` yourself and then re-run the command, or`,
|
|
36
|
-
`- re-run the same command with \`--env ${requestedEnv} --yes\` to confirm this one-off cross-env operation.`,
|
|
37
|
-
].join('\n');
|
|
33
|
+
return translateCli('commands.shared.crossEnv.refusal', {
|
|
34
|
+
currentEnv,
|
|
35
|
+
requestedEnv,
|
|
36
|
+
});
|
|
38
37
|
}
|
|
39
38
|
export async function ensureCrossEnvConfirmed(options) {
|
|
40
39
|
const requestedEnv = normalizeEnvName(options.requestedEnv);
|
|
@@ -0,0 +1,101 @@
|
|
|
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 path from 'node:path';
|
|
10
|
+
import { resolveConfiguredEnvPath } from './cli-home.js';
|
|
11
|
+
function trimPathValue(value) {
|
|
12
|
+
const text = String(value ?? '').trim();
|
|
13
|
+
return text || undefined;
|
|
14
|
+
}
|
|
15
|
+
function normalizePathForComparison(value) {
|
|
16
|
+
return value.replace(/[\\/]+/g, '/').replace(/\/+$/, '');
|
|
17
|
+
}
|
|
18
|
+
export function areConfiguredPathsEquivalent(left, right) {
|
|
19
|
+
const leftValue = trimPathValue(left);
|
|
20
|
+
const rightValue = trimPathValue(right);
|
|
21
|
+
if (!leftValue || !rightValue) {
|
|
22
|
+
return leftValue === rightValue;
|
|
23
|
+
}
|
|
24
|
+
return normalizePathForComparison(leftValue) === normalizePathForComparison(rightValue);
|
|
25
|
+
}
|
|
26
|
+
function trimTrailingSeparators(value) {
|
|
27
|
+
return value.replace(/[\\/]+$/, '');
|
|
28
|
+
}
|
|
29
|
+
function hasTerminalPathSegment(value, segment) {
|
|
30
|
+
const normalized = normalizePathForComparison(value);
|
|
31
|
+
return normalized.endsWith(`/${segment}`) || normalized === segment;
|
|
32
|
+
}
|
|
33
|
+
function dirnameWithTrailingSeparator(value) {
|
|
34
|
+
const trimmed = trimTrailingSeparators(value);
|
|
35
|
+
if (!trimmed) {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
const separatorIndex = Math.max(trimmed.lastIndexOf('/'), trimmed.lastIndexOf('\\'));
|
|
39
|
+
if (separatorIndex < 0) {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
return trimmed.slice(0, separatorIndex + 1);
|
|
43
|
+
}
|
|
44
|
+
function inferAppPathFromLegacyConfigValue(value, leaf) {
|
|
45
|
+
if (!value || !hasTerminalPathSegment(value, leaf)) {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
return dirnameWithTrailingSeparator(value);
|
|
49
|
+
}
|
|
50
|
+
export function deriveConfiguredSourcePath(appPath) {
|
|
51
|
+
const base = trimPathValue(appPath);
|
|
52
|
+
if (!base) {
|
|
53
|
+
return 'source/';
|
|
54
|
+
}
|
|
55
|
+
return `${base.replace(/[\\/]+$/, '')}/source/`;
|
|
56
|
+
}
|
|
57
|
+
export function deriveConfiguredStoragePath(appPath) {
|
|
58
|
+
const base = trimPathValue(appPath);
|
|
59
|
+
if (!base) {
|
|
60
|
+
return 'storage/';
|
|
61
|
+
}
|
|
62
|
+
return `${base.replace(/[\\/]+$/, '')}/storage/`;
|
|
63
|
+
}
|
|
64
|
+
export function inferConfiguredAppPathFromLegacyConfig(config) {
|
|
65
|
+
const explicitAppPath = trimPathValue(config.appPath);
|
|
66
|
+
if (explicitAppPath) {
|
|
67
|
+
return explicitAppPath;
|
|
68
|
+
}
|
|
69
|
+
const candidates = [
|
|
70
|
+
inferAppPathFromLegacyConfigValue(trimPathValue(config.appRootPath), 'source'),
|
|
71
|
+
inferAppPathFromLegacyConfigValue(trimPathValue(config.storagePath), 'storage'),
|
|
72
|
+
].filter((value) => Boolean(value));
|
|
73
|
+
if (candidates.length === 0) {
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
const [first] = candidates;
|
|
77
|
+
if (!first) {
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
return candidates.every((candidate) => areConfiguredPathsEquivalent(candidate, first)) ? first : undefined;
|
|
81
|
+
}
|
|
82
|
+
export function resolveConfiguredAppPath(config, scope) {
|
|
83
|
+
const configuredAppPath = inferConfiguredAppPathFromLegacyConfig(config);
|
|
84
|
+
return configuredAppPath ? resolveConfiguredEnvPath(configuredAppPath, scope) : undefined;
|
|
85
|
+
}
|
|
86
|
+
export function resolveConfiguredSourcePath(config, scope) {
|
|
87
|
+
const legacySourcePath = trimPathValue(config.appRootPath);
|
|
88
|
+
if (legacySourcePath) {
|
|
89
|
+
return resolveConfiguredEnvPath(legacySourcePath, scope);
|
|
90
|
+
}
|
|
91
|
+
const appPath = resolveConfiguredAppPath(config, scope);
|
|
92
|
+
return appPath ? path.join(appPath, 'source') : undefined;
|
|
93
|
+
}
|
|
94
|
+
export function resolveConfiguredStoragePath(config, scope) {
|
|
95
|
+
const legacyStoragePath = trimPathValue(config.storagePath);
|
|
96
|
+
if (legacyStoragePath) {
|
|
97
|
+
return resolveConfiguredEnvPath(legacyStoragePath, scope);
|
|
98
|
+
}
|
|
99
|
+
const appPath = resolveConfiguredAppPath(config, scope);
|
|
100
|
+
return appPath ? path.join(appPath, 'storage') : undefined;
|
|
101
|
+
}
|