@nocobase/cli 2.1.0-alpha.36 → 2.1.0-alpha.38
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/dist/commands/app/restart.js +63 -1
- package/dist/commands/app/start.js +41 -16
- package/dist/commands/app/upgrade.js +9 -3
- package/dist/commands/install.js +11 -2
- package/dist/lib/app-managed-resources.js +8 -2
- package/dist/lib/bootstrap.js +1 -1
- package/dist/lib/docker-env-file.js +52 -0
- package/dist/lib/env-config.js +1 -0
- package/package.json +2 -2
|
@@ -8,6 +8,11 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { Command, Flags } from '@oclif/core';
|
|
10
10
|
import { ensureCrossEnvConfirmed, hasExplicitEnvSelection } from '../../lib/env-guard.js';
|
|
11
|
+
import { formatMissingManagedAppEnvMessage, resolveManagedAppRuntime, stopDockerContainer, } from '../../lib/app-runtime.js';
|
|
12
|
+
import { formatAppUrl, resolveManagedAppApiBaseUrl, waitForAppReady } from '../../lib/app-health.js';
|
|
13
|
+
import { recreateSavedDockerApp } from '../../lib/app-managed-resources.js';
|
|
14
|
+
import { run } from '../../lib/run-npm.js';
|
|
15
|
+
import { announceTargetEnv, failTask, startTask, succeedTask } from '../../lib/ui.js';
|
|
11
16
|
function argvHasToken(argv, tokens) {
|
|
12
17
|
return tokens.some((token) => argv.includes(token));
|
|
13
18
|
}
|
|
@@ -16,9 +21,17 @@ function pushFlag(argv, flag, value) {
|
|
|
16
21
|
argv.push(flag, String(value));
|
|
17
22
|
}
|
|
18
23
|
}
|
|
24
|
+
function formatDockerRestartFailure(envName, message) {
|
|
25
|
+
return [
|
|
26
|
+
`Couldn't restart NocoBase for "${envName}".`,
|
|
27
|
+
'The CLI was not able to recreate the saved Docker app container successfully.',
|
|
28
|
+
'Check the saved Docker image, envFile, container settings, and database connection, then try again.',
|
|
29
|
+
`Details: ${message}`,
|
|
30
|
+
].join('\n');
|
|
31
|
+
}
|
|
19
32
|
export default class AppRestart extends Command {
|
|
20
33
|
static hidden = false;
|
|
21
|
-
static description = 'Restart NocoBase for the selected env
|
|
34
|
+
static description = 'Restart NocoBase for the selected env. Local npm/git installs stop and start the app again, and Docker installs recreate the saved app container so saved env changes can take effect.';
|
|
22
35
|
static examples = [
|
|
23
36
|
'<%= config.bin %> <%= command.id %>',
|
|
24
37
|
'<%= config.bin %> <%= command.id %> --env local',
|
|
@@ -71,6 +84,55 @@ export default class AppRestart extends Command {
|
|
|
71
84
|
return;
|
|
72
85
|
}
|
|
73
86
|
}
|
|
87
|
+
const runtime = await resolveManagedAppRuntime(requestedEnv);
|
|
88
|
+
const commandStdio = flags.verbose ? 'inherit' : 'ignore';
|
|
89
|
+
if (!runtime) {
|
|
90
|
+
this.error(formatMissingManagedAppEnvMessage(requestedEnv));
|
|
91
|
+
}
|
|
92
|
+
if (runtime.kind === 'docker') {
|
|
93
|
+
announceTargetEnv(runtime.envName);
|
|
94
|
+
startTask(`Stopping NocoBase for "${runtime.envName}" before restart...`);
|
|
95
|
+
try {
|
|
96
|
+
const state = await stopDockerContainer(runtime.containerName, {
|
|
97
|
+
stdio: commandStdio,
|
|
98
|
+
});
|
|
99
|
+
succeedTask(state === 'already-stopped'
|
|
100
|
+
? `NocoBase was already stopped for "${runtime.envName}".`
|
|
101
|
+
: `Stopped NocoBase for "${runtime.envName}".`);
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
105
|
+
failTask(`Failed to stop NocoBase for "${runtime.envName}".`);
|
|
106
|
+
this.error(formatDockerRestartFailure(runtime.envName, message));
|
|
107
|
+
}
|
|
108
|
+
startTask(`Recreating the Docker app container for "${runtime.envName}"...`);
|
|
109
|
+
try {
|
|
110
|
+
await run('docker', ['rm', '-f', runtime.containerName], {
|
|
111
|
+
errorName: 'docker rm',
|
|
112
|
+
stdio: commandStdio,
|
|
113
|
+
}).catch(() => undefined);
|
|
114
|
+
await recreateSavedDockerApp(runtime, {
|
|
115
|
+
verbose: flags.verbose,
|
|
116
|
+
});
|
|
117
|
+
succeedTask(`Docker app container is ready for "${runtime.envName}".`);
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
121
|
+
failTask(`Failed to recreate NocoBase for "${runtime.envName}".`);
|
|
122
|
+
this.error(formatDockerRestartFailure(runtime.envName, message));
|
|
123
|
+
}
|
|
124
|
+
const appUrl = formatAppUrl(runtime.env.appPort === undefined || runtime.env.appPort === null
|
|
125
|
+
? undefined
|
|
126
|
+
: String(runtime.env.appPort));
|
|
127
|
+
await waitForAppReady({
|
|
128
|
+
envName: runtime.envName,
|
|
129
|
+
apiBaseUrl: resolveManagedAppApiBaseUrl(runtime),
|
|
130
|
+
containerName: runtime.containerName,
|
|
131
|
+
logHint: `You can inspect startup logs with \`nb app logs --env ${runtime.envName}\`.`,
|
|
132
|
+
});
|
|
133
|
+
succeedTask(`NocoBase is running for "${runtime.envName}"${appUrl ? ` at ${appUrl}` : ''}.`);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
74
136
|
const stopArgv = [];
|
|
75
137
|
const daemonFlagWasProvided = argvHasToken(this.argv, ['--daemon', '--no-daemon']);
|
|
76
138
|
pushFlag(stopArgv, '--env', requestedEnv);
|
|
@@ -11,6 +11,7 @@ import { ensureCrossEnvConfirmed, hasExplicitEnvSelection } from '../../lib/env-
|
|
|
11
11
|
import { formatMissingManagedAppEnvMessage, resolveManagedAppRuntime, runLocalNocoBaseCommand, startDockerContainer, } from '../../lib/app-runtime.js';
|
|
12
12
|
import { AppHealthCheckError, formatAppUrl, isAppReady, resolveManagedAppApiBaseUrl, waitForAppReady, } from '../../lib/app-health.js';
|
|
13
13
|
import { ensureBuiltinDbReady, ensureSavedLocalSource, recreateSavedDockerApp, } from '../../lib/app-managed-resources.js';
|
|
14
|
+
import { run } from '../../lib/run-npm.js';
|
|
14
15
|
import { announceTargetEnv, failTask, printInfo, startTask, succeedTask } from '../../lib/ui.js';
|
|
15
16
|
function argvHasToken(argv, tokens) {
|
|
16
17
|
return tokens.some((token) => argv.includes(token));
|
|
@@ -89,6 +90,10 @@ export default class AppStart extends Command {
|
|
|
89
90
|
description: 'Show raw startup output from the underlying local or Docker command',
|
|
90
91
|
default: false,
|
|
91
92
|
}),
|
|
93
|
+
recreate: Flags.boolean({
|
|
94
|
+
description: 'Recreate the saved Docker app container before starting it',
|
|
95
|
+
default: false,
|
|
96
|
+
}),
|
|
92
97
|
};
|
|
93
98
|
async run() {
|
|
94
99
|
const { flags } = await this.parse(AppStart);
|
|
@@ -149,29 +154,49 @@ export default class AppStart extends Command {
|
|
|
149
154
|
? undefined
|
|
150
155
|
: String(runtime.env.appPort));
|
|
151
156
|
const apiBaseUrl = resolveManagedAppApiBaseUrl(runtime);
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
catch (error) {
|
|
163
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
164
|
-
if (/does not exist/i.test(message)) {
|
|
165
|
-
printInfo(`The saved Docker app container for "${runtime.envName}" is missing. Recreating it from the saved Docker env settings...`);
|
|
157
|
+
if (flags.recreate) {
|
|
158
|
+
startTask(`Recreating the Docker app container for "${runtime.envName}"...`);
|
|
159
|
+
try {
|
|
160
|
+
await run('docker', ['rm', '-f', runtime.containerName], {
|
|
161
|
+
errorName: 'docker rm',
|
|
162
|
+
stdio: commandStdio,
|
|
163
|
+
}).catch(() => undefined);
|
|
166
164
|
await recreateSavedDockerApp(runtime, {
|
|
167
165
|
verbose: flags.verbose,
|
|
168
166
|
});
|
|
167
|
+
succeedTask(`Docker app container is ready for "${runtime.envName}".`);
|
|
169
168
|
}
|
|
170
|
-
|
|
171
|
-
|
|
169
|
+
catch (error) {
|
|
170
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
171
|
+
failTask(`Failed to recreate NocoBase for "${runtime.envName}".`);
|
|
172
172
|
this.error(formatDockerStartFailure(runtime.envName, message));
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
|
+
else {
|
|
176
|
+
startTask(`Starting NocoBase for "${runtime.envName}"...`);
|
|
177
|
+
try {
|
|
178
|
+
const state = await startDockerContainer(runtime.containerName, {
|
|
179
|
+
stdio: commandStdio,
|
|
180
|
+
});
|
|
181
|
+
if (state === 'already-running' && await isAppReady(apiBaseUrl)) {
|
|
182
|
+
succeedTask(`NocoBase is already running for "${runtime.envName}"${appUrl ? ` at ${appUrl}` : ''}.`);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
catch (error) {
|
|
187
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
188
|
+
if (/does not exist/i.test(message)) {
|
|
189
|
+
printInfo(`The saved Docker app container for "${runtime.envName}" is missing. Recreating it from the saved Docker env settings...`);
|
|
190
|
+
await recreateSavedDockerApp(runtime, {
|
|
191
|
+
verbose: flags.verbose,
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
failTask(`Failed to start NocoBase for "${runtime.envName}".`);
|
|
196
|
+
this.error(formatDockerStartFailure(runtime.envName, message));
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
175
200
|
await waitForAppReady({
|
|
176
201
|
envName: runtime.envName,
|
|
177
202
|
apiBaseUrl,
|
|
@@ -11,6 +11,7 @@ import { upsertEnv } from '../../lib/auth-store.js';
|
|
|
11
11
|
import { formatMissingManagedAppEnvMessage, resolveManagedAppRuntime, runLocalNocoBaseCommand, startDockerContainer, stopDockerContainer, } from '../../lib/app-runtime.js';
|
|
12
12
|
import { resolveConfiguredEnvPath } from '../../lib/cli-home.js';
|
|
13
13
|
import { deriveBuiltinDbConnection } from '../../lib/builtin-db.js';
|
|
14
|
+
import { resolveDockerEnvFileArg } from "../../lib/docker-env-file.js";
|
|
14
15
|
import { ensureCrossEnvConfirmed, hasExplicitEnvSelection } from '../../lib/env-guard.js';
|
|
15
16
|
import { DEFAULT_DOCKER_REGISTRY, DEFAULT_DOCKER_VERSION, resolveDockerImageRef, } from "../../lib/docker-image.js";
|
|
16
17
|
import { commandSucceeds, run } from '../../lib/run-npm.js';
|
|
@@ -311,12 +312,13 @@ export default class AppUpgrade extends Command {
|
|
|
311
312
|
argv.push('--daemon');
|
|
312
313
|
return argv;
|
|
313
314
|
}
|
|
314
|
-
static buildDockerUpgradePlan(runtime, downloadVersion) {
|
|
315
|
+
static async buildDockerUpgradePlan(runtime, downloadVersion) {
|
|
315
316
|
const dockerRegistry = readEnvValue(runtime.env, 'dockerRegistry') || DEFAULT_DOCKER_REGISTRY;
|
|
316
317
|
const appPort = runtime.env.appPort === undefined || runtime.env.appPort === null
|
|
317
318
|
? ''
|
|
318
319
|
: trimValue(runtime.env.appPort);
|
|
319
320
|
const storagePath = readEnvValue(runtime.env, 'storagePath');
|
|
321
|
+
const envFile = await resolveDockerEnvFileArg(runtime.envName, runtime.env.config);
|
|
320
322
|
const appKey = readEnvValue(runtime.env, 'appKey');
|
|
321
323
|
const timeZone = readEnvValue(runtime.env, 'timezone');
|
|
322
324
|
const builtinDbConnection = runtime.env.config.builtinDb ? deriveBuiltinDbConnection(runtime) : undefined;
|
|
@@ -378,6 +380,9 @@ export default class AppUpgrade extends Command {
|
|
|
378
380
|
if (appPort) {
|
|
379
381
|
args.push('-p', `${appPort}:80`);
|
|
380
382
|
}
|
|
383
|
+
if (envFile) {
|
|
384
|
+
args.push('--env-file', envFile);
|
|
385
|
+
}
|
|
381
386
|
args.push('-e', `APP_KEY=${appKey}`, '-e', `DB_DIALECT=${dbDialect}`, '-e', `DB_HOST=${dbHost}`, '-e', `DB_PORT=${dbPort}`, '-e', `DB_DATABASE=${dbDatabase}`, '-e', `DB_USER=${dbUser}`, '-e', `DB_PASSWORD=${dbPassword}`, '-e', `TZ=${timeZone}`, '-v', `${storagePath}:${DOCKER_APP_STORAGE_DESTINATION}`, imageRef);
|
|
382
387
|
return {
|
|
383
388
|
containerName: runtime.containerName,
|
|
@@ -387,6 +392,7 @@ export default class AppUpgrade extends Command {
|
|
|
387
392
|
imageRef,
|
|
388
393
|
appPort: appPort || undefined,
|
|
389
394
|
storagePath,
|
|
395
|
+
envFile,
|
|
390
396
|
appKey,
|
|
391
397
|
timeZone,
|
|
392
398
|
dbDialect,
|
|
@@ -452,7 +458,7 @@ export default class AppUpgrade extends Command {
|
|
|
452
458
|
const apiBaseUrl = resolveApiBaseUrl(runtime);
|
|
453
459
|
const containerExists = await dockerContainerExists(runtime.containerName);
|
|
454
460
|
if (!flags['skip-code-update']) {
|
|
455
|
-
const plan = AppUpgrade.buildDockerUpgradePlan(runtime, downloadVersion);
|
|
461
|
+
const plan = await AppUpgrade.buildDockerUpgradePlan(runtime, downloadVersion);
|
|
456
462
|
startTask(`Refreshing the Docker image for "${runtime.envName}"...`);
|
|
457
463
|
try {
|
|
458
464
|
await runCommand('source:download', AppUpgrade.buildDockerDownloadArgv(runtime, plan));
|
|
@@ -500,7 +506,7 @@ export default class AppUpgrade extends Command {
|
|
|
500
506
|
}
|
|
501
507
|
}
|
|
502
508
|
else {
|
|
503
|
-
const plan = AppUpgrade.buildDockerUpgradePlan(runtime, downloadVersion);
|
|
509
|
+
const plan = await AppUpgrade.buildDockerUpgradePlan(runtime, downloadVersion);
|
|
504
510
|
const displayUrl = formatDisplayUrl(apiBaseUrl, plan.appPort);
|
|
505
511
|
startTask(`Recreating the Docker app container for "${runtime.envName}"...`);
|
|
506
512
|
try {
|
package/dist/commands/install.js
CHANGED
|
@@ -26,6 +26,7 @@ import { printInfo, printStage, printVerbose, printWarning, setVerboseMode, } fr
|
|
|
26
26
|
import { omitKeys, upperFirst } from "../lib/object-utils.js";
|
|
27
27
|
import { getEnv, setCurrentEnv, upsertEnv } from '../lib/auth-store.js';
|
|
28
28
|
import { buildStoredEnvConfig } from '../lib/env-config.js';
|
|
29
|
+
import { resolveDockerEnvFileArg, } from "../lib/docker-env-file.js";
|
|
29
30
|
import Download, { defaultDockerRegistryForLang, } from './download.js';
|
|
30
31
|
import EnvAdd from "./env/add.js";
|
|
31
32
|
const DEFAULT_INSTALL_ENV_NAME = 'local';
|
|
@@ -1575,7 +1576,7 @@ export default class Install extends Command {
|
|
|
1575
1576
|
printVerbose(`Built-in ${plan.dbDialect} database ready at ${plan.dbHost}:${plan.dbPort}`);
|
|
1576
1577
|
return plan;
|
|
1577
1578
|
}
|
|
1578
|
-
static buildDockerAppPlan(params) {
|
|
1579
|
+
static async buildDockerAppPlan(params) {
|
|
1579
1580
|
const dockerRegistry = String(downloadResultsValue(params.downloadResults, 'dockerRegistry') ?? '').trim()
|
|
1580
1581
|
|| defaultDockerRegistryForLang(process.env.NB_LOCALE);
|
|
1581
1582
|
const version = String(downloadResultsValue(params.downloadResults, 'version') ?? '').trim() || DEFAULT_DOCKER_VERSION;
|
|
@@ -1598,6 +1599,8 @@ export default class Install extends Command {
|
|
|
1598
1599
|
const appKey = crypto.randomBytes(32).toString('hex');
|
|
1599
1600
|
const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone || 'UTC';
|
|
1600
1601
|
const containerName = Install.buildDockerAppContainerName(params.envName, params.dockerContainerPrefix ?? params.workspaceName);
|
|
1602
|
+
const configuredEnvFile = String(params.appResults.envFile ?? '').trim();
|
|
1603
|
+
const envFile = await resolveDockerEnvFileArg(params.envName, configuredEnvFile ? { envFile: configuredEnvFile } : undefined);
|
|
1601
1604
|
const initEnvVars = Install.buildInitAppEnvVars({
|
|
1602
1605
|
appResults: params.appResults,
|
|
1603
1606
|
rootResults: params.rootResults,
|
|
@@ -1614,6 +1617,9 @@ export default class Install extends Command {
|
|
|
1614
1617
|
'-p',
|
|
1615
1618
|
`${appPort}:80`,
|
|
1616
1619
|
];
|
|
1620
|
+
if (envFile) {
|
|
1621
|
+
args.push('--env-file', envFile);
|
|
1622
|
+
}
|
|
1617
1623
|
for (const [key, value] of Object.entries(initEnvVars)) {
|
|
1618
1624
|
args.push('-e', `${key}=${value}`);
|
|
1619
1625
|
}
|
|
@@ -1625,6 +1631,7 @@ export default class Install extends Command {
|
|
|
1625
1631
|
imageRef,
|
|
1626
1632
|
appPort,
|
|
1627
1633
|
storagePath,
|
|
1634
|
+
envFile,
|
|
1628
1635
|
appKey,
|
|
1629
1636
|
timeZone,
|
|
1630
1637
|
args,
|
|
@@ -1647,7 +1654,7 @@ export default class Install extends Command {
|
|
|
1647
1654
|
const networkName = params.builtinDbPlan?.networkName
|
|
1648
1655
|
?? Install.buildBuiltinDbNetworkName(params.envName, params.dockerNetworkName ?? params.workspaceName);
|
|
1649
1656
|
await this.ensureDockerNetwork(networkName);
|
|
1650
|
-
const plan = Install.buildDockerAppPlan({
|
|
1657
|
+
const plan = await Install.buildDockerAppPlan({
|
|
1651
1658
|
envName: params.envName,
|
|
1652
1659
|
workspaceName: params.workspaceName,
|
|
1653
1660
|
dockerContainerPrefix: params.dockerContainerPrefix,
|
|
@@ -1941,6 +1948,7 @@ export default class Install extends Command {
|
|
|
1941
1948
|
|| DEFAULT_INSTALL_APP_PORT;
|
|
1942
1949
|
const storagePath = String(params.appResults.storagePath ?? '').trim()
|
|
1943
1950
|
|| defaultInstallStoragePath(params.envName);
|
|
1951
|
+
const envFile = String(params.appResults.envFile ?? '').trim() || undefined;
|
|
1944
1952
|
const apiBaseUrl = Install.resolveApiBaseUrl({
|
|
1945
1953
|
appResults: params.appResults,
|
|
1946
1954
|
envAddResults: params.envAddResults,
|
|
@@ -1963,6 +1971,7 @@ export default class Install extends Command {
|
|
|
1963
1971
|
appRootPath: params.appResults.appRootPath,
|
|
1964
1972
|
appPort,
|
|
1965
1973
|
storagePath,
|
|
1974
|
+
...(envFile ? { envFile } : {}),
|
|
1966
1975
|
appKey: params.appResults.appKey,
|
|
1967
1976
|
timezone: params.appResults.timeZone,
|
|
1968
1977
|
builtinDb: params.dbResults.builtinDb,
|
|
@@ -10,6 +10,7 @@ import { mkdir, readdir } from 'node:fs/promises';
|
|
|
10
10
|
import { dockerContainerExists, startDockerContainer } from './app-runtime.js';
|
|
11
11
|
import { deriveBuiltinDbConnection, resolveBuiltinDbConnection } from './builtin-db.js';
|
|
12
12
|
import { resolveConfiguredEnvPath } from './cli-home.js';
|
|
13
|
+
import { resolveDockerEnvFileArg } from "./docker-env-file.js";
|
|
13
14
|
import { DEFAULT_DOCKER_REGISTRY, DEFAULT_DOCKER_VERSION, resolveDockerImageRef, } from "./docker-image.js";
|
|
14
15
|
import { commandSucceeds, run } from './run-npm.js';
|
|
15
16
|
import Install from '../commands/install.js';
|
|
@@ -81,12 +82,13 @@ async function localProjectHasFiles(projectRoot) {
|
|
|
81
82
|
return false;
|
|
82
83
|
}
|
|
83
84
|
}
|
|
84
|
-
export function buildSavedDockerRunArgs(runtime) {
|
|
85
|
+
export async function buildSavedDockerRunArgs(runtime) {
|
|
85
86
|
const config = runtime.env.config ?? {};
|
|
86
87
|
const configuredStoragePath = trimValue(config.storagePath);
|
|
87
88
|
const storagePath = configuredStoragePath
|
|
88
89
|
? trimValue(resolveConfiguredEnvPath(configuredStoragePath))
|
|
89
90
|
: '';
|
|
91
|
+
const envFile = await resolveDockerEnvFileArg(runtime.envName, config);
|
|
90
92
|
const appPort = runtime.env.appPort === undefined || runtime.env.appPort === null
|
|
91
93
|
? ''
|
|
92
94
|
: trimValue(runtime.env.appPort);
|
|
@@ -150,16 +152,20 @@ export function buildSavedDockerRunArgs(runtime) {
|
|
|
150
152
|
if (appPort) {
|
|
151
153
|
args.push('-p', `${appPort}:80`);
|
|
152
154
|
}
|
|
155
|
+
if (envFile) {
|
|
156
|
+
args.push('--env-file', envFile);
|
|
157
|
+
}
|
|
153
158
|
args.push('-e', `APP_KEY=${appKey}`, '-e', `DB_DIALECT=${dbDialect}`, '-e', `DB_HOST=${dbHost}`, '-e', `DB_PORT=${dbPort}`, '-e', `DB_DATABASE=${dbDatabase}`, '-e', `DB_USER=${dbUser}`, '-e', `DB_PASSWORD=${dbPassword}`, '-e', `TZ=${timeZone}`, '-v', `${storagePath}:${DOCKER_APP_STORAGE_DESTINATION}`, imageRef);
|
|
154
159
|
return {
|
|
155
160
|
appPort: appPort || undefined,
|
|
156
161
|
storagePath,
|
|
162
|
+
envFile,
|
|
157
163
|
imageRef,
|
|
158
164
|
args,
|
|
159
165
|
};
|
|
160
166
|
}
|
|
161
167
|
export async function recreateSavedDockerApp(runtime, options) {
|
|
162
|
-
const plan = buildSavedDockerRunArgs(runtime);
|
|
168
|
+
const plan = await buildSavedDockerRunArgs(runtime);
|
|
163
169
|
try {
|
|
164
170
|
await ensureDockerNetwork(runtime.workspaceName);
|
|
165
171
|
await mkdir(plan.storagePath, { recursive: true });
|
package/dist/lib/bootstrap.js
CHANGED
|
@@ -344,7 +344,7 @@ export async function ensureRuntimeFromArgv(argv, options) {
|
|
|
344
344
|
}
|
|
345
345
|
stopTask();
|
|
346
346
|
const message = error instanceof Error ? error.message : String(error);
|
|
347
|
-
printWarningBlock(`Unable to load runtime commands. Showing built-in help instead.\
|
|
347
|
+
printWarningBlock(`Unable to load runtime commands. Showing built-in help instead.\n\n${message}`);
|
|
348
348
|
}
|
|
349
349
|
}
|
|
350
350
|
export async function updateEnvRuntime(options) {
|
|
@@ -0,0 +1,52 @@
|
|
|
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 { access } from 'node:fs/promises';
|
|
10
|
+
import { resolveConfiguredEnvPath } from './cli-home.js';
|
|
11
|
+
function trimValue(value) {
|
|
12
|
+
const text = String(value ?? '').trim();
|
|
13
|
+
return text || undefined;
|
|
14
|
+
}
|
|
15
|
+
export function defaultDockerEnvFilePath(envName) {
|
|
16
|
+
return `${envName}/.env`;
|
|
17
|
+
}
|
|
18
|
+
export function resolveConfiguredDockerEnvFilePath(envName, config) {
|
|
19
|
+
return trimValue(config?.envFile) || defaultDockerEnvFilePath(envName);
|
|
20
|
+
}
|
|
21
|
+
export function hasExplicitDockerEnvFile(config) {
|
|
22
|
+
return Boolean(trimValue(config?.envFile));
|
|
23
|
+
}
|
|
24
|
+
export function resolveDockerEnvFilePath(envName, config) {
|
|
25
|
+
return resolveConfiguredEnvPath(resolveConfiguredDockerEnvFilePath(envName, config));
|
|
26
|
+
}
|
|
27
|
+
export async function dockerEnvFileExists(envName, config) {
|
|
28
|
+
const filePath = resolveDockerEnvFilePath(envName, config);
|
|
29
|
+
if (!filePath) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
await access(filePath);
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
catch (_error) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export async function resolveDockerEnvFileArg(envName, config) {
|
|
41
|
+
const filePath = resolveDockerEnvFilePath(envName, config);
|
|
42
|
+
if (!filePath) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
if (await dockerEnvFileExists(envName, config)) {
|
|
46
|
+
return filePath;
|
|
47
|
+
}
|
|
48
|
+
if (hasExplicitDockerEnvFile(config)) {
|
|
49
|
+
throw new Error(`The configured envFile for "${envName}" does not exist: ${resolveConfiguredDockerEnvFilePath(envName, config)}`);
|
|
50
|
+
}
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
package/dist/lib/env-config.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/cli",
|
|
3
|
-
"version": "2.1.0-alpha.
|
|
3
|
+
"version": "2.1.0-alpha.38",
|
|
4
4
|
"description": "NocoBase Command Line Tool",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/generated/command-registry.js",
|
|
@@ -105,5 +105,5 @@
|
|
|
105
105
|
"type": "git",
|
|
106
106
|
"url": "git+https://github.com/nocobase/nocobase.git"
|
|
107
107
|
},
|
|
108
|
-
"gitHead": "
|
|
108
|
+
"gitHead": "cc99815fc9ae0612d6db0db5ebbc87a774fff8ed"
|
|
109
109
|
}
|