@base44-preview/cli 0.0.55-pr.545.81d207d → 0.0.55-pr.545.9513e13

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/cli/index.js CHANGED
@@ -255490,6 +255490,7 @@ class ServeRunner {
255490
255490
  logger;
255491
255491
  child;
255492
255492
  stopping = false;
255493
+ stopPromise;
255493
255494
  exitListeners = [];
255494
255495
  constructor(options8) {
255495
255496
  this.command = options8.command;
@@ -255501,12 +255502,14 @@ class ServeRunner {
255501
255502
  if (this.child) {
255502
255503
  return;
255503
255504
  }
255505
+ const stdin2 = process21.platform === "win32" ? "ignore" : "inherit";
255504
255506
  const child = spawn3(this.command, {
255505
255507
  cwd: this.cwd,
255506
255508
  shell: true,
255507
- detached: process21.platform !== "win32",
255509
+ detached: true,
255508
255510
  env: { ...process21.env, ...this.env },
255509
- stdio: ["inherit", "pipe", "pipe"]
255511
+ stdio: [stdin2, "pipe", "pipe"],
255512
+ windowsHide: true
255510
255513
  });
255511
255514
  this.child = child;
255512
255515
  this.setupHandlers(child);
@@ -255515,6 +255518,13 @@ class ServeRunner {
255515
255518
  this.exitListeners.push(listener);
255516
255519
  }
255517
255520
  async stop() {
255521
+ if (this.stopPromise) {
255522
+ return this.stopPromise;
255523
+ }
255524
+ this.stopPromise = this.stopChild();
255525
+ return this.stopPromise;
255526
+ }
255527
+ async stopChild() {
255518
255528
  const child = this.child;
255519
255529
  if (!child || child.exitCode !== null) {
255520
255530
  return;
@@ -255522,7 +255532,14 @@ class ServeRunner {
255522
255532
  this.stopping = true;
255523
255533
  const exited = new Promise((resolve10) => child.once("exit", () => resolve10()));
255524
255534
  if (process21.platform === "win32" && child.pid) {
255525
- spawn3("taskkill", ["/pid", String(child.pid), "/T", "/F"]);
255535
+ const taskkill = spawn3("taskkill", ["/pid", String(child.pid), "/T", "/F"], {
255536
+ stdio: "ignore",
255537
+ windowsHide: true
255538
+ });
255539
+ await new Promise((resolve10) => {
255540
+ taskkill.once("exit", () => resolve10());
255541
+ taskkill.once("error", () => resolve10());
255542
+ });
255526
255543
  } else if (child.pid) {
255527
255544
  try {
255528
255545
  process21.kill(-child.pid, "SIGTERM");
@@ -257270,7 +257287,7 @@ async function createDevServer(options8) {
257270
257287
  port: process.env.IS_TEST === "true" ? undefined : DEFAULT_PORT
257271
257288
  });
257272
257289
  const baseUrl = `http://localhost:${port}`;
257273
- const { functions, entities, project: project2 } = await options8.loadResources();
257290
+ const { functions, entities, project: project2, siteUrl } = await options8.loadResources();
257274
257291
  const app = import_express6.default();
257275
257292
  const remoteProxy = import_http_proxy_middleware2.createProxyMiddleware({
257276
257293
  target: BASE44_APP_URL,
@@ -257330,6 +257347,12 @@ async function createDevServer(options8) {
257330
257347
  const customIntegrationRoutes = createCustomIntegrationRoutes(remoteProxy, devLogger);
257331
257348
  app.use("/api/apps/:appId/integrations/custom", customIntegrationRoutes);
257332
257349
  app.use((req, res, next) => {
257350
+ if (siteUrl && (req.path === "/login" || req.path.startsWith("/login/"))) {
257351
+ const targetUrl = new URL(req.originalUrl, siteUrl);
257352
+ devLogger.warn(`"${req.originalUrl}" requires hosted login, redirecting to ${targetUrl.toString()}`);
257353
+ res.redirect(targetUrl.toString());
257354
+ return;
257355
+ }
257333
257356
  if (!req.originalUrl.endsWith("analytics/track/batch")) {
257334
257357
  devLogger.warn(`"${req.originalUrl}" is not supported in local development, passing call to production`);
257335
257358
  }
@@ -257399,12 +257422,27 @@ async function createDevServer(options8) {
257399
257422
  logger: createDevLogger("frontend", theme.colors.base44Orange)
257400
257423
  });
257401
257424
  }
257425
+ let shutdownPromise;
257402
257426
  const shutdown = async () => {
257403
- base44ConfigWatcher.close();
257404
- io6.close();
257405
- await functionManager.stopAll();
257406
- await serveRunner?.stop();
257407
- server.close();
257427
+ shutdownPromise ??= (async () => {
257428
+ base44ConfigWatcher.close();
257429
+ io6.close();
257430
+ await functionManager.stopAll();
257431
+ await serveRunner?.stop();
257432
+ await new Promise((resolve12, reject) => {
257433
+ server.close((error48) => {
257434
+ if (error48) {
257435
+ reject(error48);
257436
+ return;
257437
+ }
257438
+ resolve12();
257439
+ });
257440
+ });
257441
+ })().catch((error48) => {
257442
+ const errorMessage = error48 instanceof Error ? error48.message : String(error48);
257443
+ devLogger.error(`Failed to shut down dev server: ${errorMessage}`);
257444
+ });
257445
+ return shutdownPromise;
257408
257446
  };
257409
257447
  process.on("SIGINT", shutdown);
257410
257448
  process.on("SIGTERM", shutdown);
@@ -257435,6 +257473,9 @@ async function devAction(ctx, options8) {
257435
257473
  }
257436
257474
  const port = options8.port ? Number(options8.port) : undefined;
257437
257475
  const appId = app.id;
257476
+ const siteUrlPromise = getSiteUrl().catch(() => {
257477
+ return;
257478
+ });
257438
257479
  const { port: resolvedPort, isServingFrontend } = await createDevServer({
257439
257480
  log,
257440
257481
  port,
@@ -257442,7 +257483,8 @@ async function devAction(ctx, options8) {
257442
257483
  denoWrapperPath: getDenoWrapperPath(),
257443
257484
  loadResources: async () => {
257444
257485
  const { functions, entities, project: project2 } = await readProjectConfig();
257445
- return { functions, entities, project: project2 };
257486
+ const siteUrl = await siteUrlPromise;
257487
+ return { functions, entities, project: project2, siteUrl };
257446
257488
  }
257447
257489
  });
257448
257490
  const outroMessage = isServingFrontend ? "Open your app using the frontend dev server URL" : `Dev server is available at ${theme.colors.links(localServerUrl(resolvedPort))}`;
@@ -261928,4 +261970,4 @@ export {
261928
261970
  CLIExitError
261929
261971
  };
261930
261972
 
261931
- //# debugId=6B1ECA05EAAE1CF664756E2164756E21
261973
+ //# debugId=F0F854B64EB6D34464756E2164756E21