@nocobase/cli 2.1.20 → 2.1.22
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.
|
@@ -170,8 +170,13 @@ export default class EnvInfo extends Command {
|
|
|
170
170
|
'auth.accessToken': authGroup.accessToken,
|
|
171
171
|
'auth.refreshToken': authGroup.refreshToken,
|
|
172
172
|
};
|
|
173
|
+
const envGroup = {
|
|
174
|
+
name: runtime.envName,
|
|
175
|
+
kind: runtime.kind,
|
|
176
|
+
};
|
|
173
177
|
const output = {
|
|
174
178
|
ok: true,
|
|
179
|
+
name: runtime.envName,
|
|
175
180
|
env: runtime.envName,
|
|
176
181
|
kind: runtime.kind,
|
|
177
182
|
app: serializeGroup(appGroup),
|
|
@@ -197,6 +202,11 @@ export default class EnvInfo extends Command {
|
|
|
197
202
|
this.log(JSON.stringify(output, null, 2));
|
|
198
203
|
return;
|
|
199
204
|
}
|
|
200
|
-
this.log([
|
|
205
|
+
this.log([
|
|
206
|
+
createGroupTable('Env', envGroup),
|
|
207
|
+
createGroupTable('App', appGroup),
|
|
208
|
+
createGroupTable('DB', dbGroup),
|
|
209
|
+
createGroupTable('API', apiGroup),
|
|
210
|
+
].join('\n\n'));
|
|
201
211
|
}
|
|
202
212
|
}
|
package/dist/commands/init.js
CHANGED
|
@@ -16,7 +16,8 @@ import { getEnv, upsertEnv } from "../lib/auth-store.js";
|
|
|
16
16
|
import { runPromptCatalog, } from "../lib/prompt-catalog.js";
|
|
17
17
|
import { applyCliLocale, localeText, translateCli } from "../lib/cli-locale.js";
|
|
18
18
|
import { resolveConfiguredEnvPath, resolveDefaultConfigScope, resolveEnvRelativePath } from '../lib/cli-home.js';
|
|
19
|
-
import { resolveDefaultApiHost, resolveDefaultUiHost } from '../lib/cli-config.js';
|
|
19
|
+
import { getCliConfigValue, resolveDefaultApiHost, resolveDefaultUiHost } from '../lib/cli-config.js';
|
|
20
|
+
import { resolveOfficialDockerRegistry } from '../lib/docker-image.js';
|
|
20
21
|
import { areConfiguredPathsEquivalent, deriveConfiguredSourcePath, deriveConfiguredStoragePath, inferConfiguredAppPathFromLegacyConfig, } from '../lib/env-paths.js';
|
|
21
22
|
import { formatMissingManagedAppEnvMessage } from '../lib/app-runtime.js';
|
|
22
23
|
import { runPromptCatalogWebUI } from "../lib/prompt-web-ui.js";
|
|
@@ -697,6 +698,12 @@ Prompt modes:
|
|
|
697
698
|
if (flags.yes && !Object.prototype.hasOwnProperty.call(downloadSeed, 'source')) {
|
|
698
699
|
downloadSeed.source = 'docker';
|
|
699
700
|
}
|
|
701
|
+
const builtinDbImageRegistry = String(presetValues.dockerRegistry ?? '').trim() ||
|
|
702
|
+
resolveOfficialDockerRegistry(await getCliConfigValue('nb-image-registry'));
|
|
703
|
+
if (!Object.prototype.hasOwnProperty.call(presetValues, 'dockerRegistry')) {
|
|
704
|
+
out.dockerRegistry = builtinDbImageRegistry;
|
|
705
|
+
}
|
|
706
|
+
out.builtinDbImageRegistry = builtinDbImageRegistry;
|
|
700
707
|
const dbInitial = await Install.buildDbPromptInitialValues({
|
|
701
708
|
flags,
|
|
702
709
|
downloadResults: downloadSeed,
|
|
@@ -704,6 +711,9 @@ Prompt modes:
|
|
|
704
711
|
warnOnPortFallback: false,
|
|
705
712
|
});
|
|
706
713
|
for (const [key, value] of Object.entries(dbInitial)) {
|
|
714
|
+
if (key === 'builtinDbImage') {
|
|
715
|
+
continue;
|
|
716
|
+
}
|
|
707
717
|
if (!Object.prototype.hasOwnProperty.call(presetValues, key)) {
|
|
708
718
|
out[key] = value;
|
|
709
719
|
}
|
package/dist/commands/install.js
CHANGED
|
@@ -540,7 +540,9 @@ export default class Install extends Command {
|
|
|
540
540
|
type: 'text',
|
|
541
541
|
message: installText('prompts.builtinDbImage.message'),
|
|
542
542
|
placeholder: installText('prompts.builtinDbImage.placeholder'),
|
|
543
|
-
initialValue: (values) => defaultBuiltinDbImageForDialect(values.dbDialect
|
|
543
|
+
initialValue: (values) => defaultBuiltinDbImageForDialect(values.dbDialect, {
|
|
544
|
+
registry: String(values.builtinDbImageRegistry ?? '').trim() || undefined,
|
|
545
|
+
}),
|
|
544
546
|
hidden: (values) => !values.builtinDb || !supportsBuiltinDbDialect(values.dbDialect),
|
|
545
547
|
required: true,
|
|
546
548
|
},
|
package/dist/lib/cli-config.js
CHANGED
|
@@ -242,7 +242,9 @@ export function getEffectiveCliConfigValue(config, key) {
|
|
|
242
242
|
case 'docker.container-prefix':
|
|
243
243
|
return trimValue(config.name) || DEFAULT_DOCKER_CONTAINER_PREFIX;
|
|
244
244
|
case 'nb-image-registry':
|
|
245
|
-
return explicit ??
|
|
245
|
+
return explicit ?? (resolveCliLocale(undefined, { configuredLocale: trimValue(config.settings?.locale) }) === 'zh-CN'
|
|
246
|
+
? 'aliyun'
|
|
247
|
+
: DEFAULT_NB_IMAGE_REGISTRY);
|
|
246
248
|
case 'nb-image-variant':
|
|
247
249
|
return explicit ?? DEFAULT_NB_IMAGE_VARIANT;
|
|
248
250
|
case 'bin.docker':
|
|
@@ -11,6 +11,17 @@ import { exit, stdin as stdinStream, stdout as stdoutStream } from 'node:process
|
|
|
11
11
|
import { createCliTranslate } from "./cli-locale.js";
|
|
12
12
|
import { confirm, select, input, password } from "./inquirer.js";
|
|
13
13
|
import { createPromptCatalogHooks, hasIvKey, isBlankText, isPromptBlockSkipped, mergedBoolean, mergedInteger, mergedPassword, mergedSelect, mergedText, resolvePromptCatalogLocale, resolvePromptText, runPromptFieldValidate, selectOptionValues, tryApplyPreset, } from "./prompt-catalog-core.js";
|
|
14
|
+
function buildPromptComputationSeed(catalog, initialValues) {
|
|
15
|
+
const catalogKeys = new Set(Object.keys(catalog));
|
|
16
|
+
const seed = {};
|
|
17
|
+
for (const [key, value] of Object.entries(initialValues)) {
|
|
18
|
+
if (catalogKeys.has(key) || value === undefined || value === null) {
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
seed[key] = value;
|
|
22
|
+
}
|
|
23
|
+
return seed;
|
|
24
|
+
}
|
|
14
25
|
function adaptInquirerValidate(validate) {
|
|
15
26
|
if (!validate) {
|
|
16
27
|
return undefined;
|
|
@@ -113,14 +124,16 @@ export async function runPromptCatalog(catalog, options = {}) {
|
|
|
113
124
|
const hooks = createTerminalHooks(locale, options.hooks);
|
|
114
125
|
const interactive = Boolean(stdinStream.isTTY && stdoutStream.isTTY && !options.yes);
|
|
115
126
|
const preset = options.values ?? {};
|
|
127
|
+
const computationSeed = buildPromptComputationSeed(catalog, resolveIv);
|
|
116
128
|
const out = {};
|
|
117
129
|
const renderer = createInquirerRenderer();
|
|
118
130
|
for (const [key, def] of Object.entries(catalog)) {
|
|
119
|
-
|
|
131
|
+
const valuesSoFar = { ...computationSeed, ...out };
|
|
132
|
+
if (isPromptBlockSkipped(def, valuesSoFar)) {
|
|
120
133
|
continue;
|
|
121
134
|
}
|
|
122
135
|
if (tryApplyPreset(key, def, preset, out, hooks, locale)) {
|
|
123
|
-
const errV = await runPromptFieldValidate(def, out[key], out);
|
|
136
|
+
const errV = await runPromptFieldValidate(def, out[key], { ...computationSeed, ...out });
|
|
124
137
|
if (errV) {
|
|
125
138
|
hooks.onMissingNonInteractive(errV);
|
|
126
139
|
}
|
|
@@ -135,7 +148,7 @@ export async function runPromptCatalog(catalog, options = {}) {
|
|
|
135
148
|
continue;
|
|
136
149
|
}
|
|
137
150
|
if (def.type === 'run') {
|
|
138
|
-
await def.run(out, options.command);
|
|
151
|
+
await def.run({ ...computationSeed, ...out }, options.command);
|
|
139
152
|
continue;
|
|
140
153
|
}
|
|
141
154
|
if (def.type === 'text') {
|
|
@@ -144,18 +157,18 @@ export async function runPromptCatalog(catalog, options = {}) {
|
|
|
144
157
|
? resolvePromptText(def.placeholder, locale)
|
|
145
158
|
: undefined;
|
|
146
159
|
if (!interactive) {
|
|
147
|
-
const merged = mergedText(key, def, resolveIv, useYesInitial,
|
|
160
|
+
const merged = mergedText(key, def, resolveIv, useYesInitial, valuesSoFar);
|
|
148
161
|
if (def.required && isBlankText(merged)) {
|
|
149
162
|
hooks.onMissingNonInteractive(t('promptCatalog.nonInteractive.textRequired', { key }));
|
|
150
163
|
}
|
|
151
164
|
out[key] = merged;
|
|
152
|
-
const errT = await runPromptFieldValidate(def, merged, { ...out, [key]: merged });
|
|
165
|
+
const errT = await runPromptFieldValidate(def, merged, { ...computationSeed, ...out, [key]: merged });
|
|
153
166
|
if (errT) {
|
|
154
167
|
hooks.onMissingNonInteractive(errT);
|
|
155
168
|
}
|
|
156
169
|
continue;
|
|
157
170
|
}
|
|
158
|
-
const merged = mergedText(key, def, promptIv, false,
|
|
171
|
+
const merged = mergedText(key, def, promptIv, false, valuesSoFar);
|
|
159
172
|
const raw = await callPrompt(() => renderer.text({
|
|
160
173
|
message,
|
|
161
174
|
initialValue: merged,
|
|
@@ -168,7 +181,7 @@ export async function runPromptCatalog(catalog, options = {}) {
|
|
|
168
181
|
return undefined;
|
|
169
182
|
}
|
|
170
183
|
const currentValue = typeof value === 'string' ? value : String(value ?? '');
|
|
171
|
-
const result = runPromptFieldValidate(def, currentValue, { ...out, [key]: currentValue });
|
|
184
|
+
const result = runPromptFieldValidate(def, currentValue, { ...computationSeed, ...out, [key]: currentValue });
|
|
172
185
|
return result;
|
|
173
186
|
},
|
|
174
187
|
}), renderer, hooks);
|
|
@@ -180,7 +193,7 @@ export async function runPromptCatalog(catalog, options = {}) {
|
|
|
180
193
|
if (!interactive) {
|
|
181
194
|
const b = mergedBoolean(key, def, resolveIv, useYesInitial);
|
|
182
195
|
out[key] = b;
|
|
183
|
-
const errB = await runPromptFieldValidate(def, b, { ...out, [key]: b });
|
|
196
|
+
const errB = await runPromptFieldValidate(def, b, { ...computationSeed, ...out, [key]: b });
|
|
184
197
|
if (errB) {
|
|
185
198
|
hooks.onMissingNonInteractive(errB);
|
|
186
199
|
}
|
|
@@ -191,7 +204,7 @@ export async function runPromptCatalog(catalog, options = {}) {
|
|
|
191
204
|
for (;;) {
|
|
192
205
|
const raw = await callPrompt(() => renderer.confirm({ message, initialValue: merged }), renderer, hooks);
|
|
193
206
|
const b = Boolean(raw);
|
|
194
|
-
const errB = await runPromptFieldValidate(def, b, { ...out, [key]: b });
|
|
207
|
+
const errB = await runPromptFieldValidate(def, b, { ...computationSeed, ...out, [key]: b });
|
|
195
208
|
if (errB) {
|
|
196
209
|
renderer.error(errB);
|
|
197
210
|
continue;
|
|
@@ -224,7 +237,7 @@ export async function runPromptCatalog(catalog, options = {}) {
|
|
|
224
237
|
: t('promptCatalog.nonInteractive.selectMissingDefault', { key }));
|
|
225
238
|
}
|
|
226
239
|
out[key] = merged;
|
|
227
|
-
const errS = await runPromptFieldValidate(def, merged, { ...out, [key]: merged });
|
|
240
|
+
const errS = await runPromptFieldValidate(def, merged, { ...computationSeed, ...out, [key]: merged });
|
|
228
241
|
if (errS) {
|
|
229
242
|
hooks.onMissingNonInteractive(errS);
|
|
230
243
|
}
|
|
@@ -248,7 +261,7 @@ export async function runPromptCatalog(catalog, options = {}) {
|
|
|
248
261
|
initialValue: uiInitial,
|
|
249
262
|
}), renderer, hooks);
|
|
250
263
|
const picked = raw;
|
|
251
|
-
const errS = await runPromptFieldValidate(def, picked, { ...out, [key]: picked });
|
|
264
|
+
const errS = await runPromptFieldValidate(def, picked, { ...computationSeed, ...out, [key]: picked });
|
|
252
265
|
if (errS) {
|
|
253
266
|
renderer.error(errS);
|
|
254
267
|
continue;
|
|
@@ -269,13 +282,13 @@ export async function runPromptCatalog(catalog, options = {}) {
|
|
|
269
282
|
if (def.type === 'password') {
|
|
270
283
|
const message = resolvePromptText(def.message, locale, key);
|
|
271
284
|
if (!interactive) {
|
|
272
|
-
const merged = mergedPassword(key, def, resolveIv, useYesInitial);
|
|
285
|
+
const merged = mergedPassword(key, def, resolveIv, useYesInitial, valuesSoFar);
|
|
273
286
|
if (merged === undefined) {
|
|
274
287
|
if (def.required) {
|
|
275
288
|
hooks.onMissingNonInteractive(t('promptCatalog.nonInteractive.passwordRequired', { key }));
|
|
276
289
|
}
|
|
277
290
|
out[key] = '';
|
|
278
|
-
const errPE = await runPromptFieldValidate(def, '', { ...out, [key]: '' });
|
|
291
|
+
const errPE = await runPromptFieldValidate(def, '', { ...computationSeed, ...out, [key]: '' });
|
|
279
292
|
if (errPE) {
|
|
280
293
|
hooks.onMissingNonInteractive(errPE);
|
|
281
294
|
}
|
|
@@ -285,7 +298,7 @@ export async function runPromptCatalog(catalog, options = {}) {
|
|
|
285
298
|
hooks.onMissingNonInteractive(t('promptCatalog.nonInteractive.passwordRequiredNonEmpty', { key }));
|
|
286
299
|
}
|
|
287
300
|
out[key] = merged;
|
|
288
|
-
const errP = await runPromptFieldValidate(def, merged, { ...out, [key]: merged });
|
|
301
|
+
const errP = await runPromptFieldValidate(def, merged, { ...computationSeed, ...out, [key]: merged });
|
|
289
302
|
if (errP) {
|
|
290
303
|
hooks.onMissingNonInteractive(errP);
|
|
291
304
|
}
|
|
@@ -302,7 +315,7 @@ export async function runPromptCatalog(catalog, options = {}) {
|
|
|
302
315
|
return undefined;
|
|
303
316
|
}
|
|
304
317
|
const currentValue = typeof value === 'string' ? value : String(value ?? '');
|
|
305
|
-
const result = runPromptFieldValidate(def, currentValue, { ...out, [key]: currentValue });
|
|
318
|
+
const result = runPromptFieldValidate(def, currentValue, { ...computationSeed, ...out, [key]: currentValue });
|
|
306
319
|
return result;
|
|
307
320
|
},
|
|
308
321
|
}), renderer, hooks);
|
|
@@ -322,14 +335,14 @@ export async function runPromptCatalog(catalog, options = {}) {
|
|
|
322
335
|
}
|
|
323
336
|
const z = def.initialValue ?? 0;
|
|
324
337
|
out[key] = z;
|
|
325
|
-
const errI = await runPromptFieldValidate(def, z, { ...out, [key]: z });
|
|
338
|
+
const errI = await runPromptFieldValidate(def, z, { ...computationSeed, ...out, [key]: z });
|
|
326
339
|
if (errI) {
|
|
327
340
|
hooks.onMissingNonInteractive(errI);
|
|
328
341
|
}
|
|
329
342
|
continue;
|
|
330
343
|
}
|
|
331
344
|
out[key] = merged;
|
|
332
|
-
const errI2 = await runPromptFieldValidate(def, merged, { ...out, [key]: merged });
|
|
345
|
+
const errI2 = await runPromptFieldValidate(def, merged, { ...computationSeed, ...out, [key]: merged });
|
|
333
346
|
if (errI2) {
|
|
334
347
|
hooks.onMissingNonInteractive(errI2);
|
|
335
348
|
}
|
|
@@ -349,7 +362,7 @@ export async function runPromptCatalog(catalog, options = {}) {
|
|
|
349
362
|
}
|
|
350
363
|
if (def.validate) {
|
|
351
364
|
const z = def.initialValue ?? 0;
|
|
352
|
-
return runPromptFieldValidate(def, z, { ...out, [key]: z });
|
|
365
|
+
return runPromptFieldValidate(def, z, { ...computationSeed, ...out, [key]: z });
|
|
353
366
|
}
|
|
354
367
|
return undefined;
|
|
355
368
|
}
|
|
@@ -360,7 +373,7 @@ export async function runPromptCatalog(catalog, options = {}) {
|
|
|
360
373
|
return undefined;
|
|
361
374
|
}
|
|
362
375
|
const n = Number.parseInt(trimmed, 10);
|
|
363
|
-
return runPromptFieldValidate(def, n, { ...out, [key]: n });
|
|
376
|
+
return runPromptFieldValidate(def, n, { ...computationSeed, ...out, [key]: n });
|
|
364
377
|
},
|
|
365
378
|
}), renderer, hooks);
|
|
366
379
|
if (typeof raw === 'string' && raw.trim() === '' && !def.required) {
|
|
@@ -48,13 +48,24 @@ function isInputBlock(def) {
|
|
|
48
48
|
def.type === 'password' ||
|
|
49
49
|
def.type === 'integer');
|
|
50
50
|
}
|
|
51
|
+
function buildPromptComputationSeed(catalog, userPreset) {
|
|
52
|
+
const catalogKeys = new Set(Object.keys(catalog));
|
|
53
|
+
const seed = {};
|
|
54
|
+
for (const [key, value] of Object.entries(userPreset)) {
|
|
55
|
+
if (catalogKeys.has(key) || value === undefined || value === null) {
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
seed[key] = value;
|
|
59
|
+
}
|
|
60
|
+
return seed;
|
|
61
|
+
}
|
|
51
62
|
/**
|
|
52
63
|
* Merges CLI/env **`userPreset`** with catalog block defaults, in the same key order and with the
|
|
53
64
|
* same `hidden` / `run` semantics as {@link isPromptBlockSkipped}, so the web form can prefill
|
|
54
65
|
* and reflow `hidden` fields (e.g. `integer` when `select` changes).
|
|
55
66
|
*/
|
|
56
67
|
export function buildWebFormValuesFromCatalog(catalog, userPreset = {}) {
|
|
57
|
-
const out =
|
|
68
|
+
const out = buildPromptComputationSeed(catalog, userPreset);
|
|
58
69
|
for (const [key, def] of Object.entries(catalog)) {
|
|
59
70
|
if (def.type === 'intro' || def.type === 'outro') {
|
|
60
71
|
continue;
|
|
@@ -109,7 +120,7 @@ function defaultValueForInput(key, def, out) {
|
|
|
109
120
|
* from current raw form data (e.g. after changing `select`). Matches how {@link isPromptBlockSkipped} uses `out` while iterating the catalog.
|
|
110
121
|
*/
|
|
111
122
|
export function reflowWebFormState(catalog, raw, userSeed = {}) {
|
|
112
|
-
const out =
|
|
123
|
+
const out = buildPromptComputationSeed(catalog, userSeed);
|
|
113
124
|
const show = {};
|
|
114
125
|
for (const [key, def] of Object.entries(catalog)) {
|
|
115
126
|
if (def.type === 'intro' || def.type === 'outro') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/cli",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.22",
|
|
4
4
|
"description": "NocoBase Command Line Tool",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/generated/command-registry.js",
|
|
@@ -144,5 +144,5 @@
|
|
|
144
144
|
"type": "git",
|
|
145
145
|
"url": "git+https://github.com/nocobase/nocobase.git"
|
|
146
146
|
},
|
|
147
|
-
"gitHead": "
|
|
147
|
+
"gitHead": "811fc3d272389739babdfa4338faf843d5bf04ff"
|
|
148
148
|
}
|