@nocobase/cli 2.1.0-alpha.45 → 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 -32
- 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 +92 -20
- package/dist/commands/app/shared.js +3 -2
- package/dist/commands/app/start.js +143 -38
- package/dist/commands/app/stop.js +31 -2
- package/dist/commands/app/upgrade.js +11 -7
- package/dist/commands/config/delete.js +10 -2
- package/dist/commands/config/get.js +7 -1
- package/dist/commands/config/set.js +12 -2
- package/dist/commands/db/ps.js +5 -18
- package/dist/commands/env/add.js +24 -44
- package/dist/commands/env/auth.js +1 -1
- package/dist/commands/env/info.js +3 -2
- package/dist/commands/env/list.js +4 -5
- 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/status.js +10 -7
- package/dist/commands/env/update.js +385 -21
- package/dist/commands/init.js +368 -98
- package/dist/commands/install.js +271 -104
- 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/self/update.js +58 -1
- package/dist/commands/source/dev.js +5 -5
- package/dist/commands/source/test.js +13 -14
- package/dist/lib/app-health.js +39 -32
- package/dist/lib/app-managed-resources.js +25 -9
- package/dist/lib/app-public-path.js +80 -0
- package/dist/lib/app-runtime.js +12 -3
- package/dist/lib/auth-store.js +128 -4
- package/dist/lib/backup.js +3 -3
- package/dist/lib/bootstrap.js +14 -8
- package/dist/lib/cli-config.js +229 -3
- package/dist/lib/cli-entry-error.js +52 -0
- package/dist/lib/command-log.js +284 -0
- package/dist/lib/docker-env-file.js +10 -2
- package/dist/lib/docker-log-stream.js +45 -0
- package/dist/lib/env-auth.js +25 -14
- 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 +22 -2
- package/dist/lib/startup-update.js +74 -50
- package/dist/lib/ui.js +2 -1
- package/dist/locale/en-US.json +122 -22
- package/dist/locale/zh-CN.json +119 -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
|
@@ -6,10 +6,12 @@
|
|
|
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 { fileURLToPath } from 'node:url';
|
|
9
10
|
import { Command, Flags } from '@oclif/core';
|
|
10
11
|
import { getCurrentEnvName } from '../../lib/auth-store.js';
|
|
11
12
|
import { ensureCrossEnvConfirmed, hasExplicitEnvSelection } from '../../lib/env-guard.js';
|
|
12
|
-
import { formatMissingManagedAppEnvMessage, resolveManagedAppRuntime, runLocalNocoBaseCommand, } from '../../lib/app-runtime.js';
|
|
13
|
+
import { formatMissingManagedAppEnvMessage, managedAppLifecycleEnvVars, resolveManagedAppRuntime, runLocalNocoBaseCommand, } from '../../lib/app-runtime.js';
|
|
14
|
+
import { resolveProjectCwd, runNocoBaseCommand } from '../../lib/run-npm.js';
|
|
13
15
|
import { announceTargetEnv, failTask, isInteractiveTerminal, printInfo, startTask, succeedTask } from '../../lib/ui.js';
|
|
14
16
|
import { builtinDbContainerName, removeDockerContainerIfExists } from './shared.js';
|
|
15
17
|
function formatStopFailure(envName, message) {
|
|
@@ -26,6 +28,33 @@ function formatStopCrossEnvConfirmationRequiredMessage(currentEnv, requestedEnv)
|
|
|
26
28
|
'Re-run the command with `--yes` to confirm this one-off cross-env stop, or switch the current env first.',
|
|
27
29
|
].join('\n');
|
|
28
30
|
}
|
|
31
|
+
function isMissingManagedLocalProjectError(message) {
|
|
32
|
+
return (message.includes('The specified --cwd does not exist:') ||
|
|
33
|
+
message.includes('The specified --cwd is not a directory:') ||
|
|
34
|
+
message.includes("Couldn't find a NocoBase source project from --cwd:"));
|
|
35
|
+
}
|
|
36
|
+
async function stopLocalRuntimeWithFallback(runtime, options) {
|
|
37
|
+
const env = managedAppLifecycleEnvVars();
|
|
38
|
+
try {
|
|
39
|
+
await runLocalNocoBaseCommand(runtime, ['pm2', 'kill'], {
|
|
40
|
+
env,
|
|
41
|
+
stdio: options.stdio,
|
|
42
|
+
});
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
47
|
+
if (!isMissingManagedLocalProjectError(message)) {
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const cliProjectCwd = resolveProjectCwd(fileURLToPath(new URL('.', import.meta.url)));
|
|
52
|
+
await runNocoBaseCommand(['pm2', 'kill'], {
|
|
53
|
+
cwd: cliProjectCwd,
|
|
54
|
+
env,
|
|
55
|
+
stdio: options.stdio,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
29
58
|
export default class AppStop extends Command {
|
|
30
59
|
static hidden = false;
|
|
31
60
|
static description = 'Stop NocoBase for the selected env. Local npm/git installs stop the app process, and Docker installs remove the saved app container.';
|
|
@@ -121,7 +150,7 @@ export default class AppStop extends Command {
|
|
|
121
150
|
else {
|
|
122
151
|
startTask(`Stopping NocoBase for "${runtime.envName}"...`);
|
|
123
152
|
try {
|
|
124
|
-
await
|
|
153
|
+
await stopLocalRuntimeWithFallback(runtime, {
|
|
125
154
|
stdio: commandStdio,
|
|
126
155
|
});
|
|
127
156
|
succeedTask(`NocoBase has stopped for "${runtime.envName}".`);
|
|
@@ -13,6 +13,7 @@ import { ensureCrossEnvConfirmed, hasExplicitEnvSelection } from '../../lib/env-
|
|
|
13
13
|
import { DEFAULT_DOCKER_REGISTRY } from "../../lib/docker-image.js";
|
|
14
14
|
import { confirm } from "../../lib/inquirer.js";
|
|
15
15
|
import { announceTargetEnv, isInteractiveTerminal, printInfo, printWarning, succeedTask } from '../../lib/ui.js';
|
|
16
|
+
import { resolveAppUrlFromApiBaseUrl } from '../env/shared.js';
|
|
16
17
|
function trimValue(value) {
|
|
17
18
|
return String(value ?? '').trim();
|
|
18
19
|
}
|
|
@@ -25,15 +26,16 @@ function formatAppUrl(port) {
|
|
|
25
26
|
return value ? `http://127.0.0.1:${value}` : undefined;
|
|
26
27
|
}
|
|
27
28
|
function formatDisplayUrl(apiBaseUrl, appPort) {
|
|
29
|
+
const resolvedFromApiBaseUrl = resolveAppUrlFromApiBaseUrl(apiBaseUrl);
|
|
30
|
+
if (resolvedFromApiBaseUrl) {
|
|
31
|
+
return resolvedFromApiBaseUrl;
|
|
32
|
+
}
|
|
28
33
|
const appUrl = formatAppUrl(appPort);
|
|
29
34
|
if (appUrl) {
|
|
30
35
|
return appUrl;
|
|
31
36
|
}
|
|
32
37
|
const value = trimValue(apiBaseUrl);
|
|
33
|
-
|
|
34
|
-
return undefined;
|
|
35
|
-
}
|
|
36
|
-
return value.replace(/\/api\/?$/, '');
|
|
38
|
+
return value ? value.replace(/\/api\/?$/, '') : undefined;
|
|
37
39
|
}
|
|
38
40
|
function readEnvValue(env, key) {
|
|
39
41
|
return trimValue(env.config[key]);
|
|
@@ -312,7 +314,7 @@ export default class AppUpgrade extends Command {
|
|
|
312
314
|
throw new Error([
|
|
313
315
|
`Env "${runtime.envName}" does not have a saved \`downloadVersion\`.`,
|
|
314
316
|
'This env cannot be upgraded until a source version is explicit.',
|
|
315
|
-
|
|
317
|
+
`Re-run \`nb init --ui --env ${runtime.envName}\` for this env, or pass \`--version\` to \`nb app upgrade\`.`,
|
|
316
318
|
].join('\n'));
|
|
317
319
|
}
|
|
318
320
|
return {
|
|
@@ -383,7 +385,7 @@ export default class AppUpgrade extends Command {
|
|
|
383
385
|
this.error([
|
|
384
386
|
`Can't upgrade "${runtime.envName}" from this machine.`,
|
|
385
387
|
'This env only has an API connection, so there is no saved local app or Docker runtime to upgrade here.',
|
|
386
|
-
'If you want a local NocoBase AI environment that the CLI can upgrade, run `nb init` first.',
|
|
388
|
+
'If you want a local NocoBase AI environment that the CLI can upgrade, run `nb init --ui` first.',
|
|
387
389
|
].join('\n'));
|
|
388
390
|
}
|
|
389
391
|
if (runtime.kind === 'ssh') {
|
|
@@ -493,8 +495,10 @@ export default class AppUpgrade extends Command {
|
|
|
493
495
|
});
|
|
494
496
|
}
|
|
495
497
|
await runWithSuppressedTargetEnvLog(async () => {
|
|
498
|
+
const startArgv = buildManagedActionArgv(runtime.envName, parsed, { quickstart: true });
|
|
499
|
+
startArgv.push('--no-sync-licensed-plugins');
|
|
496
500
|
await runWithSuppressedStartSuccessLog(async () => {
|
|
497
|
-
await runCommand('app:start',
|
|
501
|
+
await runCommand('app:start', startArgv);
|
|
498
502
|
});
|
|
499
503
|
});
|
|
500
504
|
if (resolvedVersion.persistDownloadVersion) {
|
|
@@ -8,16 +8,23 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { Args, Command } from '@oclif/core';
|
|
10
10
|
import { assertSupportedCliConfigKey, deleteCliConfigValue } from '../../lib/cli-config.js';
|
|
11
|
+
import { clearLegacyStartupUpdatePolicyForCurrentInstall } from '../../lib/startup-update.js';
|
|
11
12
|
export default class ConfigDelete extends Command {
|
|
12
13
|
static summary = 'Delete an explicitly configured CLI setting';
|
|
13
14
|
static examples = [
|
|
14
15
|
'<%= config.bin %> <%= command.id %> locale',
|
|
15
|
-
'<%= config.bin %> <%= command.id %>
|
|
16
|
+
'<%= config.bin %> <%= command.id %> update.policy',
|
|
16
17
|
'<%= config.bin %> <%= command.id %> docker.network',
|
|
17
18
|
'<%= config.bin %> <%= command.id %> docker.container-prefix',
|
|
18
19
|
'<%= config.bin %> <%= command.id %> bin.docker',
|
|
20
|
+
'<%= config.bin %> <%= command.id %> bin.caddy',
|
|
19
21
|
'<%= config.bin %> <%= command.id %> bin.git',
|
|
22
|
+
'<%= config.bin %> <%= command.id %> bin.nginx',
|
|
23
|
+
'<%= config.bin %> <%= command.id %> proxy.nb-cli-root',
|
|
24
|
+
'<%= config.bin %> <%= command.id %> proxy.upstream-host',
|
|
20
25
|
'<%= config.bin %> <%= command.id %> bin.yarn',
|
|
26
|
+
'<%= config.bin %> <%= command.id %> log.enabled',
|
|
27
|
+
'<%= config.bin %> <%= command.id %> log.retention-days',
|
|
21
28
|
];
|
|
22
29
|
static args = {
|
|
23
30
|
key: Args.string({
|
|
@@ -29,6 +36,7 @@ export default class ConfigDelete extends Command {
|
|
|
29
36
|
const { args } = await this.parse(ConfigDelete);
|
|
30
37
|
const key = assertSupportedCliConfigKey(args.key);
|
|
31
38
|
const removed = await deleteCliConfigValue(key);
|
|
32
|
-
|
|
39
|
+
const clearedLegacy = key === 'update.policy' ? await clearLegacyStartupUpdatePolicyForCurrentInstall() : false;
|
|
40
|
+
this.log(removed || clearedLegacy ? `Deleted ${key}` : `${key} was not set`);
|
|
33
41
|
}
|
|
34
42
|
}
|
|
@@ -12,12 +12,18 @@ export default class ConfigGet extends Command {
|
|
|
12
12
|
static summary = 'Get the effective CLI configuration value for a key';
|
|
13
13
|
static examples = [
|
|
14
14
|
'<%= config.bin %> <%= command.id %> locale',
|
|
15
|
-
'<%= config.bin %> <%= command.id %>
|
|
15
|
+
'<%= config.bin %> <%= command.id %> update.policy',
|
|
16
16
|
'<%= config.bin %> <%= command.id %> docker.network',
|
|
17
17
|
'<%= config.bin %> <%= command.id %> docker.container-prefix',
|
|
18
18
|
'<%= config.bin %> <%= command.id %> bin.docker',
|
|
19
|
+
'<%= config.bin %> <%= command.id %> bin.caddy',
|
|
19
20
|
'<%= config.bin %> <%= command.id %> bin.git',
|
|
21
|
+
'<%= config.bin %> <%= command.id %> bin.nginx',
|
|
22
|
+
'<%= config.bin %> <%= command.id %> proxy.nb-cli-root',
|
|
23
|
+
'<%= config.bin %> <%= command.id %> proxy.upstream-host',
|
|
20
24
|
'<%= config.bin %> <%= command.id %> bin.yarn',
|
|
25
|
+
'<%= config.bin %> <%= command.id %> log.enabled',
|
|
26
|
+
'<%= config.bin %> <%= command.id %> log.retention-days',
|
|
21
27
|
];
|
|
22
28
|
static args = {
|
|
23
29
|
key: Args.string({
|
|
@@ -8,17 +8,24 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { Args, Command } from '@oclif/core';
|
|
10
10
|
import { assertSupportedCliConfigKey, setCliConfigValue } from '../../lib/cli-config.js';
|
|
11
|
+
import { clearLegacyStartupUpdatePolicyForCurrentInstall } from '../../lib/startup-update.js';
|
|
11
12
|
export default class ConfigSet extends Command {
|
|
12
13
|
static summary = 'Set a CLI configuration value';
|
|
13
|
-
static description = 'Set a
|
|
14
|
+
static description = 'Set a CLI configuration value for a supported configuration key.';
|
|
14
15
|
static examples = [
|
|
15
16
|
'<%= config.bin %> <%= command.id %> locale zh-CN',
|
|
16
|
-
'<%= config.bin %> <%= command.id %>
|
|
17
|
+
'<%= config.bin %> <%= command.id %> update.policy prompt',
|
|
17
18
|
'<%= config.bin %> <%= command.id %> docker.network nocobase',
|
|
18
19
|
'<%= config.bin %> <%= command.id %> docker.container-prefix nb',
|
|
19
20
|
'<%= config.bin %> <%= command.id %> bin.docker /usr/local/bin/docker',
|
|
21
|
+
'<%= config.bin %> <%= command.id %> bin.caddy /usr/bin/caddy',
|
|
20
22
|
'<%= config.bin %> <%= command.id %> bin.git /usr/bin/git',
|
|
23
|
+
'<%= config.bin %> <%= command.id %> bin.nginx /usr/sbin/nginx',
|
|
24
|
+
'<%= config.bin %> <%= command.id %> proxy.nb-cli-root /workspace',
|
|
25
|
+
'<%= config.bin %> <%= command.id %> proxy.upstream-host host.docker.internal',
|
|
21
26
|
'<%= config.bin %> <%= command.id %> bin.yarn yarn',
|
|
27
|
+
'<%= config.bin %> <%= command.id %> log.enabled false',
|
|
28
|
+
'<%= config.bin %> <%= command.id %> log.retention-days 14',
|
|
22
29
|
];
|
|
23
30
|
static args = {
|
|
24
31
|
key: Args.string({
|
|
@@ -34,6 +41,9 @@ export default class ConfigSet extends Command {
|
|
|
34
41
|
const { args } = await this.parse(ConfigSet);
|
|
35
42
|
const key = assertSupportedCliConfigKey(args.key);
|
|
36
43
|
const value = await setCliConfigValue(key, args.value);
|
|
44
|
+
if (key === 'update.policy') {
|
|
45
|
+
await clearLegacyStartupUpdatePolicyForCurrentInstall();
|
|
46
|
+
}
|
|
37
47
|
this.log(`${key}=${value}`);
|
|
38
48
|
}
|
|
39
49
|
}
|
package/dist/commands/db/ps.js
CHANGED
|
@@ -13,10 +13,7 @@ import { renderTable } from '../../lib/ui.js';
|
|
|
13
13
|
import { builtinDbStatus, resolveDbRuntime } from './shared.js';
|
|
14
14
|
export default class DbPs extends Command {
|
|
15
15
|
static description = 'Show built-in database runtime status for configured envs without starting or stopping anything.';
|
|
16
|
-
static examples = [
|
|
17
|
-
'<%= config.bin %> <%= command.id %>',
|
|
18
|
-
'<%= config.bin %> <%= command.id %> --env app1',
|
|
19
|
-
];
|
|
16
|
+
static examples = ['<%= config.bin %> <%= command.id %>', '<%= config.bin %> <%= command.id %> --env app1'];
|
|
20
17
|
static flags = {
|
|
21
18
|
env: Flags.string({
|
|
22
19
|
char: 'e',
|
|
@@ -26,11 +23,9 @@ export default class DbPs extends Command {
|
|
|
26
23
|
async run() {
|
|
27
24
|
const { flags } = await this.parse(DbPs);
|
|
28
25
|
const requestedEnv = flags.env?.trim() || undefined;
|
|
29
|
-
const envNames = requestedEnv
|
|
30
|
-
? [requestedEnv]
|
|
31
|
-
: Object.keys((await listEnvs()).envs).sort();
|
|
26
|
+
const envNames = requestedEnv ? [requestedEnv] : Object.keys((await listEnvs()).envs).sort();
|
|
32
27
|
if (!envNames.length) {
|
|
33
|
-
this.log('No NocoBase env is configured yet. Run `nb init` to create one first.');
|
|
28
|
+
this.log('No NocoBase env is configured yet. Run `nb init --ui` to create one first.');
|
|
34
29
|
return;
|
|
35
30
|
}
|
|
36
31
|
const rows = [];
|
|
@@ -44,16 +39,8 @@ export default class DbPs extends Command {
|
|
|
44
39
|
continue;
|
|
45
40
|
}
|
|
46
41
|
const type = runtime.kind === 'builtin' ? 'builtin' : runtime.status;
|
|
47
|
-
const status = runtime.kind === 'builtin'
|
|
48
|
-
|
|
49
|
-
: runtime.status;
|
|
50
|
-
rows.push([
|
|
51
|
-
runtime.envName,
|
|
52
|
-
type,
|
|
53
|
-
runtime.dbDialect,
|
|
54
|
-
status,
|
|
55
|
-
runtime.address,
|
|
56
|
-
]);
|
|
42
|
+
const status = runtime.kind === 'builtin' ? await builtinDbStatus(runtime.containerName) : runtime.status;
|
|
43
|
+
rows.push([runtime.envName, type, runtime.dbDialect, status, runtime.address]);
|
|
57
44
|
}
|
|
58
45
|
this.log(renderTable(['Env', 'Type', 'Dialect', 'Status', 'Address'], rows));
|
|
59
46
|
}
|
package/dist/commands/env/add.js
CHANGED
|
@@ -9,44 +9,12 @@
|
|
|
9
9
|
import { Args, Command, Flags } from '@oclif/core';
|
|
10
10
|
import { setCurrentEnv, upsertEnv } from '../../lib/auth-store.js';
|
|
11
11
|
import { resolveDefaultConfigScope } from '../../lib/cli-home.js';
|
|
12
|
-
import {
|
|
12
|
+
import { ENV_BOOLEAN_CONFIG_FLAG_MAP, ENV_STRING_CONFIG_FLAG_MAP } from '../../lib/env-command-config.js';
|
|
13
|
+
import { buildStoredEnvConfig } from '../../lib/env-config.js';
|
|
13
14
|
import { runPromptCatalog, } from '../../lib/prompt-catalog.js';
|
|
14
15
|
import { applyCliLocale, CLI_LOCALE_FLAG_DESCRIPTION, CLI_LOCALE_FLAG_OPTIONS, localeText, } from '../../lib/cli-locale.js';
|
|
15
16
|
import { validateApiBaseUrl } from '../../lib/prompt-validators.js';
|
|
16
17
|
import { printInfo, printStage, printSuccess, printVerbose, setVerboseMode } from '../../lib/ui.js';
|
|
17
|
-
const ENV_RUNTIME_FLAG_MAP = {
|
|
18
|
-
source: 'source',
|
|
19
|
-
'download-version': 'downloadVersion',
|
|
20
|
-
'docker-registry': 'dockerRegistry',
|
|
21
|
-
'docker-platform': 'dockerPlatform',
|
|
22
|
-
'git-url': 'gitUrl',
|
|
23
|
-
'npm-registry': 'npmRegistry',
|
|
24
|
-
'app-root-path': 'appRootPath',
|
|
25
|
-
'storage-path': 'storagePath',
|
|
26
|
-
'app-port': 'appPort',
|
|
27
|
-
'app-key': 'appKey',
|
|
28
|
-
timezone: 'timezone',
|
|
29
|
-
'db-dialect': 'dbDialect',
|
|
30
|
-
'builtin-db-image': 'builtinDbImage',
|
|
31
|
-
'db-host': 'dbHost',
|
|
32
|
-
'db-port': 'dbPort',
|
|
33
|
-
'db-database': 'dbDatabase',
|
|
34
|
-
'db-user': 'dbUser',
|
|
35
|
-
'db-password': 'dbPassword',
|
|
36
|
-
'db-schema': 'dbSchema',
|
|
37
|
-
'db-table-prefix': 'dbTablePrefix',
|
|
38
|
-
'root-username': 'rootUsername',
|
|
39
|
-
'root-email': 'rootEmail',
|
|
40
|
-
'root-password': 'rootPassword',
|
|
41
|
-
'root-nickname': 'rootNickname',
|
|
42
|
-
};
|
|
43
|
-
const ENV_BOOLEAN_RUNTIME_FLAG_MAP = {
|
|
44
|
-
'builtin-db': 'builtinDb',
|
|
45
|
-
'dev-dependencies': 'devDependencies',
|
|
46
|
-
build: 'build',
|
|
47
|
-
'build-dts': 'buildDts',
|
|
48
|
-
'db-underscored': 'dbUnderscored',
|
|
49
|
-
};
|
|
50
18
|
const envAddText = (key, values) => localeText(`commands.envAdd.${key}`, values);
|
|
51
19
|
const envAddAccessTokenPrompt = {
|
|
52
20
|
type: 'text',
|
|
@@ -182,14 +150,28 @@ export default class EnvAdd extends Command {
|
|
|
182
150
|
hidden: true,
|
|
183
151
|
description: 'Whether declaration files were emitted during build for this env',
|
|
184
152
|
}),
|
|
153
|
+
'app-path': Flags.string({
|
|
154
|
+
hidden: true,
|
|
155
|
+
description: 'App path saved with this env',
|
|
156
|
+
}),
|
|
185
157
|
'app-root-path': Flags.string({
|
|
186
158
|
hidden: true,
|
|
159
|
+
deprecated: true,
|
|
187
160
|
description: 'Application root path saved with this env',
|
|
188
161
|
}),
|
|
189
162
|
'storage-path': Flags.string({
|
|
190
163
|
hidden: true,
|
|
164
|
+
deprecated: true,
|
|
191
165
|
description: 'Storage path saved with this env',
|
|
192
166
|
}),
|
|
167
|
+
'app-public-path': Flags.string({
|
|
168
|
+
hidden: true,
|
|
169
|
+
description: 'Application public path saved with this env',
|
|
170
|
+
}),
|
|
171
|
+
'env-file': Flags.string({
|
|
172
|
+
hidden: true,
|
|
173
|
+
description: 'Docker env file saved with this env',
|
|
174
|
+
}),
|
|
193
175
|
'app-port': Flags.string({
|
|
194
176
|
hidden: true,
|
|
195
177
|
description: 'Application HTTP port saved with this env',
|
|
@@ -283,17 +265,17 @@ export default class EnvAdd extends Command {
|
|
|
283
265
|
type: 'select',
|
|
284
266
|
message: envAddText('prompts.authType.message'),
|
|
285
267
|
options: [
|
|
286
|
-
{
|
|
287
|
-
value: 'basic',
|
|
288
|
-
label: envAddText('prompts.authType.basicLabel'),
|
|
289
|
-
hint: envAddText('prompts.authType.basicHint'),
|
|
290
|
-
},
|
|
291
268
|
{
|
|
292
269
|
value: 'oauth',
|
|
293
270
|
label: envAddText('prompts.authType.oauthLabel'),
|
|
294
271
|
hint: envAddText('prompts.authType.oauthHint'),
|
|
295
272
|
},
|
|
296
273
|
{ value: 'token', label: envAddText('prompts.authType.tokenLabel') },
|
|
274
|
+
{
|
|
275
|
+
value: 'basic',
|
|
276
|
+
label: envAddText('prompts.authType.basicLabel'),
|
|
277
|
+
hint: envAddText('prompts.authType.basicHint'),
|
|
278
|
+
},
|
|
297
279
|
],
|
|
298
280
|
initialValue: 'oauth',
|
|
299
281
|
required: true,
|
|
@@ -360,20 +342,18 @@ export default class EnvAdd extends Command {
|
|
|
360
342
|
}
|
|
361
343
|
buildEnvConfig(results, flags) {
|
|
362
344
|
const authType = String(results.authType ?? '').trim();
|
|
363
|
-
const authUsername = authType === 'basic'
|
|
364
|
-
? String(results.username ?? flags.username ?? '').trim()
|
|
365
|
-
: '';
|
|
345
|
+
const authUsername = authType === 'basic' ? String(results.username ?? flags.username ?? '').trim() : '';
|
|
366
346
|
const envConfigInput = {
|
|
367
347
|
apiBaseUrl: results.apiBaseUrl,
|
|
368
348
|
authType,
|
|
369
349
|
authUsername: authUsername || undefined,
|
|
370
350
|
accessToken: results.accessToken,
|
|
371
351
|
};
|
|
372
|
-
for (const [flagName, configKey] of Object.entries(
|
|
352
|
+
for (const [flagName, configKey] of Object.entries(ENV_STRING_CONFIG_FLAG_MAP)) {
|
|
373
353
|
const value = flags[flagName];
|
|
374
354
|
envConfigInput[configKey] = value;
|
|
375
355
|
}
|
|
376
|
-
for (const [flagName, configKey] of Object.entries(
|
|
356
|
+
for (const [flagName, configKey] of Object.entries(ENV_BOOLEAN_CONFIG_FLAG_MAP)) {
|
|
377
357
|
const value = flags[flagName];
|
|
378
358
|
envConfigInput[configKey] = value;
|
|
379
359
|
}
|
|
@@ -23,7 +23,7 @@ function resolveExplicitAuthType(value) {
|
|
|
23
23
|
return value === 'basic' || value === 'token' || value === 'oauth' ? value : undefined;
|
|
24
24
|
}
|
|
25
25
|
function formatMissingEnvMessage(envName) {
|
|
26
|
-
return [`Env "${envName}" is not configured.`, `Run \`nb env
|
|
26
|
+
return [`Env "${envName}" is not configured.`, `Run \`nb init --ui --env ${envName}\` first.`].join('\n');
|
|
27
27
|
}
|
|
28
28
|
export default class EnvAuth extends Command {
|
|
29
29
|
static summary = 'Authenticate a saved NocoBase environment with basic login, a token, or OAuth';
|
|
@@ -10,7 +10,7 @@ import { Args, Command, Flags } from '@oclif/core';
|
|
|
10
10
|
import { formatMissingManagedAppEnvMessage, resolveManagedAppRuntime } from '../../lib/app-runtime.js';
|
|
11
11
|
import { resolveBuiltinDbConnection } from '../../lib/builtin-db.js';
|
|
12
12
|
import { renderTable } from '../../lib/ui.js';
|
|
13
|
-
import {
|
|
13
|
+
import { appPath, appUrl, dbStatus, runtimeStatus, sourcePath, storagePath } from './shared.js';
|
|
14
14
|
const MISSING_FIELD = Symbol('missingField');
|
|
15
15
|
const FORBIDDEN_FIELD_PATH_SEGMENTS = new Set(['__proto__', 'constructor', 'prototype']);
|
|
16
16
|
function normalizeJsonValue(value) {
|
|
@@ -120,7 +120,8 @@ export default class EnvInfo extends Command {
|
|
|
120
120
|
const dbDialect = builtinDbConnection?.dbDialect ?? runtime.env.config.dbDialect;
|
|
121
121
|
const appGroup = {
|
|
122
122
|
url: appUrl(runtime),
|
|
123
|
-
|
|
123
|
+
appPath: appPath(runtime),
|
|
124
|
+
sourcePath: sourcePath(runtime),
|
|
124
125
|
storagePath: storagePath(runtime),
|
|
125
126
|
appPort: runtime.env.config.appPort,
|
|
126
127
|
appStatus: await runtimeStatus(runtime),
|
|
@@ -9,13 +9,12 @@
|
|
|
9
9
|
import { Command } from '@oclif/core';
|
|
10
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 = [];
|
|
@@ -0,0 +1,28 @@
|
|
|
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 } from '@oclif/core';
|
|
10
|
+
import { createEnvProxyCaddyFlags, ENV_PROXY_NAME_ARG, runEnvProxyCommand } from './index.js';
|
|
11
|
+
export default class EnvProxyCaddy extends Command {
|
|
12
|
+
static summary = 'Generate Caddy proxy files for one managed env';
|
|
13
|
+
static examples = [
|
|
14
|
+
'<%= config.bin %> <%= command.id %>',
|
|
15
|
+
'<%= config.bin %> <%= command.id %> --env app1',
|
|
16
|
+
'<%= config.bin %> <%= command.id %> --env app1 --host a.local.nocobase.com --port 8080',
|
|
17
|
+
'<%= config.bin %> <%= command.id %> --env app1 --install --reload',
|
|
18
|
+
'<%= config.bin %> <%= command.id %> --env app1 --print',
|
|
19
|
+
];
|
|
20
|
+
static args = {
|
|
21
|
+
name: ENV_PROXY_NAME_ARG,
|
|
22
|
+
};
|
|
23
|
+
static flags = createEnvProxyCaddyFlags();
|
|
24
|
+
async run() {
|
|
25
|
+
const { args, flags } = await this.parse(EnvProxyCaddy);
|
|
26
|
+
await runEnvProxyCommand(this, args, flags, 'caddy');
|
|
27
|
+
}
|
|
28
|
+
}
|