@nocobase/cli 2.1.4-test.4 → 2.1.4-test.5
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.
|
@@ -109,8 +109,8 @@ export default class PromptsStages extends Command {
|
|
|
109
109
|
values: presetValues,
|
|
110
110
|
pageTitle: 'nb prompts-stages — Web UI',
|
|
111
111
|
documentHeading: 'nb prompts-stages — `stages` demo',
|
|
112
|
-
onServerStart: ({
|
|
113
|
-
this.log(`Local Web UI (multi-stage) ready — ${url} (listening on ${
|
|
112
|
+
onServerStart: ({ listenHost, port, url }) => {
|
|
113
|
+
this.log(`Local Web UI (multi-stage) ready — ${url} (listening on ${listenHost}:${port}). Submit the form in the browser to continue.`);
|
|
114
114
|
},
|
|
115
115
|
onOpenBrowserError: (url, err) => {
|
|
116
116
|
this.log(`Open this URL in a browser: ${url} (${err instanceof Error ? err.message : String(err)})`);
|
|
@@ -139,8 +139,8 @@ export default class PromptsTest extends Command {
|
|
|
139
139
|
values: presetValues,
|
|
140
140
|
pageTitle: 'nb prompts-test — UI',
|
|
141
141
|
documentHeading: 'nb prompts-test',
|
|
142
|
-
onServerStart: ({
|
|
143
|
-
this.log(`Local Web UI ready — ${url} (listening on ${
|
|
142
|
+
onServerStart: ({ listenHost, port, url }) => {
|
|
143
|
+
this.log(`Local Web UI ready — ${url} (listening on ${listenHost}:${port}). Submit the form in the browser to continue.`);
|
|
144
144
|
},
|
|
145
145
|
onOpenBrowserError: (url, err) => {
|
|
146
146
|
this.log(`Open this URL in a browser: ${url} (${err instanceof Error ? err.message : String(err)})`);
|
package/dist/commands/init.js
CHANGED
|
@@ -471,7 +471,7 @@ Prompt modes:
|
|
|
471
471
|
default: false,
|
|
472
472
|
}),
|
|
473
473
|
'ui-host': Flags.string({
|
|
474
|
-
description: '
|
|
474
|
+
description: 'Browser-accessible host for the --ui setup page URL (default: 127.0.0.1)',
|
|
475
475
|
}),
|
|
476
476
|
'ui-port': Flags.integer({
|
|
477
477
|
description: 'Port for the local --ui setup server; 0 lets the OS choose an available port',
|
|
@@ -19,7 +19,8 @@ export const PWC_FORM_META_STEP = '_pwcStep';
|
|
|
19
19
|
/** Form POST JSON meta field: current field key when validating a single field. */
|
|
20
20
|
export const PWC_FORM_META_FIELD = '_pwcField';
|
|
21
21
|
const DEFAULT_TIMEOUT_MS = 30 * 60 * 1000;
|
|
22
|
-
const
|
|
22
|
+
const DEFAULT_PUBLIC_HOST = '127.0.0.1';
|
|
23
|
+
const LISTEN_HOST = '0.0.0.0';
|
|
23
24
|
function resolveUiText(text, locale, fallback = '') {
|
|
24
25
|
return resolveLocalizedText(text, { locale, fallback });
|
|
25
26
|
}
|
|
@@ -705,7 +706,7 @@ function runPromptCatalogWebUIImpl(options) {
|
|
|
705
706
|
const initialShow = reflowWebFormState(merged, Object.fromEntries(Object.entries(formDefaults).map(([k, v]) => [k, v])), userSeed).show;
|
|
706
707
|
const submitPath = options.submitPath ?? DEFAULT_SUBMIT;
|
|
707
708
|
const reflowPath = options.reflowPath ?? DEFAULT_REFLOW;
|
|
708
|
-
const
|
|
709
|
+
const publicHost = options.host ?? DEFAULT_PUBLIC_HOST;
|
|
709
710
|
const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
710
711
|
const pageTitle = resolveUiText(options.pageTitle, locale, t('promptCatalog.web.pageTitle'));
|
|
711
712
|
const h1 = resolveUiText(options.documentHeading, locale, t('promptCatalog.web.documentHeading'));
|
|
@@ -753,7 +754,7 @@ function runPromptCatalogWebUIImpl(options) {
|
|
|
753
754
|
}
|
|
754
755
|
};
|
|
755
756
|
const servePage = (port) => {
|
|
756
|
-
const base = `http://${
|
|
757
|
+
const base = `http://${publicHost}:${port}`;
|
|
757
758
|
const formInner = buildPwcFormHtml(catalog, formDefaults, initialShow, pwcStepDefs, 0, pwcNSteps, locale, uiText);
|
|
758
759
|
const wizardClientJson = JSON.stringify({ n: pwcNSteps, stepDefs: pwcStepDefs });
|
|
759
760
|
const pwcValStepUrl = pwcNSteps > 1 ? JSON.stringify(base + resolveValidateStepPath) : 'null';
|
|
@@ -2207,15 +2208,15 @@ function runPromptCatalogWebUIImpl(options) {
|
|
|
2207
2208
|
}
|
|
2208
2209
|
res.writeHead(404).end();
|
|
2209
2210
|
});
|
|
2210
|
-
server.listen(options.port ?? 0,
|
|
2211
|
+
server.listen(options.port ?? 0, LISTEN_HOST, () => {
|
|
2211
2212
|
const addr = server?.address();
|
|
2212
2213
|
if (typeof addr !== 'object' || !addr) {
|
|
2213
2214
|
rejectAndClose(new Error('Failed to bind HTTP server'));
|
|
2214
2215
|
return;
|
|
2215
2216
|
}
|
|
2216
2217
|
const port = addr.port;
|
|
2217
|
-
const startUrl = `http://${
|
|
2218
|
-
options.onServerStart?.({ host, port, url: startUrl });
|
|
2218
|
+
const startUrl = `http://${publicHost}:${port}/`;
|
|
2219
|
+
options.onServerStart?.({ host: publicHost, listenHost: LISTEN_HOST, port, url: startUrl });
|
|
2219
2220
|
const onOpenBrowserError = options.onOpenBrowserError ?? ((u, err) => console.warn(String(err), u));
|
|
2220
2221
|
try {
|
|
2221
2222
|
openUrlInDefaultBrowser(startUrl, onOpenBrowserError);
|