@nocobase/cli 2.1.4-test.3 → 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: ({ host, port, url }) => {
113
- this.log(`Local Web UI (multi-stage) ready — ${url} (listening on ${host}:${port}). Submit the form in the browser to continue.`);
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: ({ host, port, url }) => {
143
- this.log(`Local Web UI ready — ${url} (listening on ${host}:${port}). Submit the form in the browser to continue.`);
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)})`);
@@ -471,7 +471,7 @@ Prompt modes:
471
471
  default: false,
472
472
  }),
473
473
  'ui-host': Flags.string({
474
- description: 'Host for the local --ui setup server (default: 127.0.0.1)',
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 DEFAULT_HOST = '127.0.0.1';
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 host = options.host ?? DEFAULT_HOST;
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://${host}:${port}`;
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';
@@ -2071,11 +2072,6 @@ function runPromptCatalogWebUIImpl(options) {
2071
2072
  return page;
2072
2073
  };
2073
2074
  server = createServer((req, res) => {
2074
- if (!req.socket.remoteAddress ||
2075
- !['127.0.0.1', '::1', '::ffff:127.0.0.1'].includes(req.socket.remoteAddress)) {
2076
- res.writeHead(403).end();
2077
- return;
2078
- }
2079
2075
  if (req.method === 'GET' && (req.url === '/' || req.url === '')) {
2080
2076
  const addr = server?.address();
2081
2077
  const port = typeof addr === 'object' && addr ? Number(addr.port) : 0;
@@ -2212,15 +2208,15 @@ function runPromptCatalogWebUIImpl(options) {
2212
2208
  }
2213
2209
  res.writeHead(404).end();
2214
2210
  });
2215
- server.listen(options.port ?? 0, host, () => {
2211
+ server.listen(options.port ?? 0, LISTEN_HOST, () => {
2216
2212
  const addr = server?.address();
2217
2213
  if (typeof addr !== 'object' || !addr) {
2218
2214
  rejectAndClose(new Error('Failed to bind HTTP server'));
2219
2215
  return;
2220
2216
  }
2221
2217
  const port = addr.port;
2222
- const startUrl = `http://${host}:${port}/`;
2223
- options.onServerStart?.({ host, port, url: startUrl });
2218
+ const startUrl = `http://${publicHost}:${port}/`;
2219
+ options.onServerStart?.({ host: publicHost, listenHost: LISTEN_HOST, port, url: startUrl });
2224
2220
  const onOpenBrowserError = options.onOpenBrowserError ?? ((u, err) => console.warn(String(err), u));
2225
2221
  try {
2226
2222
  openUrlInDefaultBrowser(startUrl, onOpenBrowserError);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/cli",
3
- "version": "2.1.4-test.3",
3
+ "version": "2.1.4-test.5",
4
4
  "description": "NocoBase Command Line Tool",
5
5
  "type": "module",
6
6
  "main": "dist/generated/command-registry.js",