@nocobase/cli 2.1.0-beta.44.test.3 → 2.1.0-beta.44.test.4

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.
Files changed (77) hide show
  1. package/bin/run.js +40 -3
  2. package/dist/commands/app/destroy.js +13 -6
  3. package/dist/commands/app/restart.js +11 -2
  4. package/dist/commands/app/shared.js +3 -2
  5. package/dist/commands/app/start.js +10 -2
  6. package/dist/commands/app/upgrade.js +6 -4
  7. package/dist/commands/config/delete.js +2 -0
  8. package/dist/commands/config/get.js +2 -0
  9. package/dist/commands/config/set.js +2 -0
  10. package/dist/commands/env/add.js +5 -5
  11. package/dist/commands/init.js +117 -7
  12. package/dist/commands/install.js +50 -13
  13. package/dist/commands/source/download.js +1 -1
  14. package/dist/commands/source/test.js +13 -14
  15. package/dist/locale/en-US.json +13 -5
  16. package/dist/locale/zh-CN.json +13 -5
  17. package/package.json +1 -7
  18. package/scripts/build.mjs +34 -0
  19. package/scripts/clean.mjs +9 -0
  20. package/tsconfig.json +19 -0
  21. package/dist/lib/api-client.js +0 -335
  22. package/dist/lib/api-command-compat.js +0 -641
  23. package/dist/lib/app-health.js +0 -139
  24. package/dist/lib/app-managed-resources.js +0 -321
  25. package/dist/lib/app-public-path.js +0 -80
  26. package/dist/lib/app-runtime.js +0 -189
  27. package/dist/lib/auth-store.js +0 -498
  28. package/dist/lib/backup.js +0 -171
  29. package/dist/lib/bootstrap.js +0 -409
  30. package/dist/lib/build-config.js +0 -18
  31. package/dist/lib/builtin-db.js +0 -86
  32. package/dist/lib/cli-config.js +0 -398
  33. package/dist/lib/cli-entry-error.js +0 -44
  34. package/dist/lib/cli-home.js +0 -47
  35. package/dist/lib/cli-locale.js +0 -141
  36. package/dist/lib/command-discovery.js +0 -39
  37. package/dist/lib/db-connection-check.js +0 -219
  38. package/dist/lib/docker-env-file.js +0 -60
  39. package/dist/lib/docker-image.js +0 -37
  40. package/dist/lib/docker-log-stream.js +0 -45
  41. package/dist/lib/env-auth.js +0 -960
  42. package/dist/lib/env-command-config.js +0 -45
  43. package/dist/lib/env-config.js +0 -100
  44. package/dist/lib/env-guard.js +0 -61
  45. package/dist/lib/env-paths.js +0 -101
  46. package/dist/lib/env-proxy.js +0 -1295
  47. package/dist/lib/generated-command.js +0 -203
  48. package/dist/lib/http-request.js +0 -49
  49. package/dist/lib/inquirer-theme.js +0 -17
  50. package/dist/lib/inquirer.js +0 -243
  51. package/dist/lib/managed-env-file.js +0 -98
  52. package/dist/lib/naming.js +0 -70
  53. package/dist/lib/object-utils.js +0 -76
  54. package/dist/lib/openapi.js +0 -62
  55. package/dist/lib/plugin-import.js +0 -279
  56. package/dist/lib/plugin-storage.js +0 -64
  57. package/dist/lib/post-processors.js +0 -23
  58. package/dist/lib/prompt-catalog-core.js +0 -185
  59. package/dist/lib/prompt-catalog-terminal.js +0 -375
  60. package/dist/lib/prompt-catalog.js +0 -10
  61. package/dist/lib/prompt-validators.js +0 -258
  62. package/dist/lib/prompt-web-ui.js +0 -2227
  63. package/dist/lib/resource-command.js +0 -357
  64. package/dist/lib/resource-request.js +0 -104
  65. package/dist/lib/run-npm.js +0 -393
  66. package/dist/lib/runtime-env-vars.js +0 -32
  67. package/dist/lib/runtime-generator.js +0 -498
  68. package/dist/lib/runtime-store.js +0 -56
  69. package/dist/lib/self-manager.js +0 -301
  70. package/dist/lib/session-id.js +0 -17
  71. package/dist/lib/session-integration.js +0 -703
  72. package/dist/lib/session-store.js +0 -118
  73. package/dist/lib/skills-manager.js +0 -438
  74. package/dist/lib/source-publish.js +0 -326
  75. package/dist/lib/source-registry.js +0 -188
  76. package/dist/lib/startup-update.js +0 -309
  77. package/dist/lib/ui.js +0 -159
@@ -1,45 +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
- 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
- };
@@ -1,100 +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 { resolveAppPublicPath } from './app-public-path.js';
10
- const STRING_ENV_CONFIG_KEYS = [
11
- 'source',
12
- 'downloadVersion',
13
- 'dockerRegistry',
14
- 'dockerPlatform',
15
- 'gitUrl',
16
- 'npmRegistry',
17
- 'appPath',
18
- 'appRootPath',
19
- 'storagePath',
20
- 'appPublicPath',
21
- 'cdnBaseUrl',
22
- 'envFile',
23
- 'appPort',
24
- 'appKey',
25
- 'timezone',
26
- 'authUsername',
27
- 'dbDialect',
28
- 'builtinDbImage',
29
- 'dbHost',
30
- 'dbPort',
31
- 'dbDatabase',
32
- 'dbUser',
33
- 'dbPassword',
34
- 'dbSchema',
35
- 'dbTablePrefix',
36
- 'rootUsername',
37
- 'rootEmail',
38
- 'rootPassword',
39
- 'rootNickname',
40
- ];
41
- const BOOLEAN_ENV_CONFIG_KEYS = [
42
- 'builtinDb',
43
- 'devDependencies',
44
- 'build',
45
- 'buildDts',
46
- 'dbUnderscored',
47
- ];
48
- function trimConfigValue(value) {
49
- const text = String(value ?? '').trim();
50
- return text || undefined;
51
- }
52
- function resolveEnvKind(input) {
53
- const source = trimConfigValue(input.source);
54
- const appPath = trimConfigValue(input.appPath);
55
- const appRootPath = trimConfigValue(input.appRootPath);
56
- if (source === 'docker') {
57
- return 'docker';
58
- }
59
- if (source === 'npm' || source === 'git' || source === 'local' || appPath || appRootPath) {
60
- return 'local';
61
- }
62
- return 'http';
63
- }
64
- export function buildStoredEnvConfig(input) {
65
- const envConfig = {
66
- kind: resolveEnvKind(input),
67
- apiBaseUrl: trimConfigValue(input.apiBaseUrl) ?? '',
68
- };
69
- for (const key of STRING_ENV_CONFIG_KEYS) {
70
- const value = trimConfigValue(input[key]);
71
- if (value) {
72
- envConfig[key] = key === 'appPublicPath' ? resolveAppPublicPath(value) : value;
73
- }
74
- }
75
- for (const key of BOOLEAN_ENV_CONFIG_KEYS) {
76
- const value = input[key];
77
- if (typeof value === 'boolean') {
78
- envConfig[key] = value;
79
- }
80
- }
81
- if (input.builtinDb === false) {
82
- envConfig.builtinDbImage = undefined;
83
- }
84
- if (input.builtinDb === true) {
85
- delete envConfig.dbHost;
86
- const source = trimConfigValue(input.source);
87
- if (source === 'docker') {
88
- delete envConfig.dbPort;
89
- }
90
- }
91
- const authType = trimConfigValue(input.authType);
92
- if (authType === 'basic' || authType === 'token' || authType === 'oauth') {
93
- envConfig.authType = authType;
94
- }
95
- const accessToken = trimConfigValue(input.accessToken);
96
- if ((authType === 'basic' || authType === 'token') && accessToken) {
97
- envConfig.accessToken = accessToken;
98
- }
99
- return envConfig;
100
- }
@@ -1,61 +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 { stdin as input, stdout as output } from 'node:process';
10
- import { getCurrentEnvName } from './auth-store.js';
11
- import { translateCli } from './cli-locale.js';
12
- import { confirm } from "./inquirer.js";
13
- function normalizeEnvName(value) {
14
- const text = String(value ?? '').trim();
15
- return text || undefined;
16
- }
17
- export function hasExplicitEnvSelection(argv) {
18
- return argv.some((token, index) => (token === '--env'
19
- || token === '-e'
20
- || token.startsWith('--env=')
21
- || (token.startsWith('-e') && token.length > 2 && index >= 0)));
22
- }
23
- function isInteractiveTerminal() {
24
- return Boolean(input.isTTY && output.isTTY);
25
- }
26
- function formatCrossEnvPromptMessage(currentEnv, requestedEnv) {
27
- return translateCli('commands.shared.crossEnv.prompt', {
28
- currentEnv,
29
- requestedEnv,
30
- });
31
- }
32
- export function formatCrossEnvRefusalMessage(currentEnv, requestedEnv) {
33
- return translateCli('commands.shared.crossEnv.refusal', {
34
- currentEnv,
35
- requestedEnv,
36
- });
37
- }
38
- export async function ensureCrossEnvConfirmed(options) {
39
- const requestedEnv = normalizeEnvName(options.requestedEnv);
40
- if (!requestedEnv) {
41
- return true;
42
- }
43
- const currentEnv = normalizeEnvName(await getCurrentEnvName());
44
- const interactiveTerminal = isInteractiveTerminal();
45
- const bypassInteractivePrompt = Boolean(options.yes);
46
- if (!currentEnv || currentEnv === requestedEnv || bypassInteractivePrompt) {
47
- return true;
48
- }
49
- if (!interactiveTerminal) {
50
- options.command.error(formatCrossEnvRefusalMessage(currentEnv, requestedEnv));
51
- }
52
- try {
53
- return Boolean(await confirm({
54
- message: formatCrossEnvPromptMessage(currentEnv, requestedEnv),
55
- default: false,
56
- }));
57
- }
58
- catch {
59
- return false;
60
- }
61
- }
@@ -1,101 +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 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
- }