@base44-preview/cli 0.0.32-pr.249.69186d6 → 0.0.32-pr.249.89127f3

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
@@ -186681,7 +186681,9 @@ var theme = {
186681
186681
  styles: {
186682
186682
  header: source_default.dim,
186683
186683
  bold: source_default.bold,
186684
- dim: source_default.dim
186684
+ dim: source_default.dim,
186685
+ error: source_default.red,
186686
+ warn: source_default.yellow
186685
186687
  },
186686
186688
  format: {
186687
186689
  errorContext(ctx) {
@@ -186783,12 +186785,12 @@ var BANNER_LINES = [
186783
186785
  "██████╔╝██║ ██║███████║███████╗ ██║ ██║",
186784
186786
  "╚═════╝ ╚═╝ ╚═╝╚══════╝╚══════╝ ╚═╝ ╚═╝"
186785
186787
  ];
186786
- async function printBanner() {
186787
- if (process.stdout.isTTY) {
186788
- await printAnimatedLines(BANNER_LINES);
186789
- } else {
186788
+ async function printBanner(isNonInteractive) {
186789
+ if (isNonInteractive) {
186790
186790
  console.log(theme.colors.base44Orange(BANNER_LINES.join(`
186791
186791
  `)));
186792
+ } else {
186793
+ await printAnimatedLines(BANNER_LINES);
186792
186794
  }
186793
186795
  }
186794
186796
  // src/cli/errors.ts
@@ -193593,7 +193595,7 @@ async function printUpgradeNotificationIfAvailable() {
193593
193595
  async function runCommand(commandFn, options, context) {
193594
193596
  console.log();
193595
193597
  if (options?.fullBanner) {
193596
- await printBanner();
193598
+ await printBanner(context.isNonInteractive);
193597
193599
  Ie("");
193598
193600
  } else {
193599
193601
  Ie(theme.colors.base44OrangeBackground(" Base 44 "));
@@ -194523,7 +194525,7 @@ function printSummary(results, oauthOutcomes) {
194523
194525
  M2.error(`Failed: ${r2.type}${r2.error ? ` - ${r2.error}` : ""}`);
194524
194526
  }
194525
194527
  }
194526
- async function pushConnectorsAction() {
194528
+ async function pushConnectorsAction(isNonInteractive) {
194527
194529
  const { connectors } = await readProjectConfig();
194528
194530
  if (connectors.length === 0) {
194529
194531
  M2.info("No local connectors found - checking for remote connectors to remove");
@@ -194537,18 +194539,18 @@ async function pushConnectorsAction() {
194537
194539
  const needsOAuth = filterPendingOAuth(results);
194538
194540
  let outroMessage = "Connectors pushed to Base44";
194539
194541
  const oauthOutcomes = await promptOAuthFlows(needsOAuth, {
194540
- skipPrompt: !!process.env.CI
194542
+ skipPrompt: isNonInteractive
194541
194543
  });
194542
194544
  const allAuthorized = oauthOutcomes.size > 0 && [...oauthOutcomes.values()].every((s) => s === "ACTIVE");
194543
194545
  if (needsOAuth.length > 0 && !allAuthorized) {
194544
- outroMessage = process.env.CI ? "Skipped OAuth in CI. Run 'base44 connectors push' locally or open the links above to authorize." : "Some connectors still require authorization. Run 'base44 connectors push' or open the links above to authorize.";
194546
+ outroMessage = isNonInteractive ? "Skipped OAuth in non-interactive mode. Run 'base44 connectors push' locally or open the links above to authorize." : "Some connectors still require authorization. Run 'base44 connectors push' or open the links above to authorize.";
194545
194547
  }
194546
194548
  printSummary(results, oauthOutcomes);
194547
194549
  return { outroMessage };
194548
194550
  }
194549
194551
  function getConnectorsPushCommand(context) {
194550
194552
  return new Command("push").description("Push local connectors to Base44 (overwrites connectors on Base44)").action(async () => {
194551
- await runCommand(pushConnectorsAction, { requireAuth: true }, context);
194553
+ await runCommand(() => pushConnectorsAction(context.isNonInteractive), { requireAuth: true }, context);
194552
194554
  });
194553
194555
  }
194554
194556
 
@@ -194558,16 +194560,16 @@ function getConnectorsCommand(context) {
194558
194560
  }
194559
194561
 
194560
194562
  // src/cli/commands/dashboard/open.ts
194561
- async function openDashboard() {
194563
+ async function openDashboard(isNonInteractive) {
194562
194564
  const dashboardUrl = getDashboardUrl();
194563
- if (!process.env.CI) {
194565
+ if (!isNonInteractive) {
194564
194566
  await open_default(dashboardUrl);
194565
194567
  }
194566
194568
  return { outroMessage: `Dashboard opened at ${dashboardUrl}` };
194567
194569
  }
194568
194570
  function getDashboardOpenCommand(context) {
194569
194571
  return new Command("open").description("Open the app dashboard in your browser").action(async () => {
194570
- await runCommand(openDashboard, { requireAuth: true }, context);
194572
+ await runCommand(() => openDashboard(context.isNonInteractive), { requireAuth: true }, context);
194571
194573
  });
194572
194574
  }
194573
194575
 
@@ -194873,7 +194875,7 @@ ${summaryLines.join(`
194873
194875
  const needsOAuth = filterPendingOAuth(result.connectorResults ?? []);
194874
194876
  if (needsOAuth.length > 0) {
194875
194877
  const oauthOutcomes = await promptOAuthFlows(needsOAuth, {
194876
- skipPrompt: options.yes || !!process.env.CI
194878
+ skipPrompt: options.yes || options.isNonInteractive
194877
194879
  });
194878
194880
  const allAuthorized = oauthOutcomes.size > 0 && [...oauthOutcomes.values()].every((s) => s === "ACTIVE");
194879
194881
  if (!allAuthorized) {
@@ -194888,7 +194890,10 @@ ${summaryLines.join(`
194888
194890
  }
194889
194891
  function getDeployCommand(context) {
194890
194892
  return new Command("deploy").description("Deploy all project resources (entities, functions, agents, connectors, and site)").option("-y, --yes", "Skip confirmation prompt").action(async (options) => {
194891
- await runCommand(() => deployAction(options), { requireAuth: true }, context);
194893
+ await runCommand(() => deployAction({
194894
+ ...options,
194895
+ isNonInteractive: context.isNonInteractive
194896
+ }), { requireAuth: true }, context);
194892
194897
  });
194893
194898
  }
194894
194899
 
@@ -195070,21 +195075,24 @@ async function deployAction2(options) {
195070
195075
  }
195071
195076
  function getSiteDeployCommand(context) {
195072
195077
  return new Command("deploy").description("Deploy built site files to Base44 hosting").option("-y, --yes", "Skip confirmation prompt").action(async (options) => {
195073
- await runCommand(() => deployAction2(options), { requireAuth: true }, context);
195078
+ await runCommand(() => deployAction2({
195079
+ ...options,
195080
+ isNonInteractive: context.isNonInteractive
195081
+ }), { requireAuth: true }, context);
195074
195082
  });
195075
195083
  }
195076
195084
 
195077
195085
  // src/cli/commands/site/open.ts
195078
- async function openAction() {
195086
+ async function openAction(isNonInteractive) {
195079
195087
  const siteUrl = await getSiteUrl();
195080
- if (!process.env.CI) {
195088
+ if (!isNonInteractive) {
195081
195089
  await open_default(siteUrl);
195082
195090
  }
195083
195091
  return { outroMessage: `Site opened at ${siteUrl}` };
195084
195092
  }
195085
195093
  function getSiteOpenCommand(context) {
195086
195094
  return new Command("open").description("Open the published site in your browser").action(async () => {
195087
- await runCommand(openAction, { requireAuth: true }, context);
195095
+ await runCommand(() => openAction(context.isNonInteractive), { requireAuth: true }, context);
195088
195096
  });
195089
195097
  }
195090
195098
 
@@ -195354,8 +195362,8 @@ var dateTimeFormat = new Intl.DateTimeFormat([], {
195354
195362
  hour12: false
195355
195363
  });
195356
195364
  var colorByType = {
195357
- error: source_default.red,
195358
- warn: source_default.yellow,
195365
+ error: theme.styles.error,
195366
+ warn: theme.styles.warn,
195359
195367
  log: (text) => text
195360
195368
  };
195361
195369
  function createDevLogger(isPrefixed = true) {
@@ -195375,7 +195383,7 @@ function createDevLogger(isPrefixed = true) {
195375
195383
  const prefixedLog = (type, msg) => {
195376
195384
  const timestamp = dateTimeFormat.format(new Date);
195377
195385
  const colorize = colorByType[type];
195378
- console.log(`${source_default.gray(timestamp)} ${colorize(msg)}`);
195386
+ console.log(`${theme.styles.dim(timestamp)} ${colorize(msg)}`);
195379
195387
  };
195380
195388
  return isPrefixed ? {
195381
195389
  log: (msg) => prefixedLog("log", msg),
@@ -195399,7 +195407,7 @@ function createDevLogger(isPrefixed = true) {
195399
195407
  }
195400
195408
 
195401
195409
  // src/cli/dev/dev-server/function-manager.ts
195402
- import { spawn as spawn2 } from "node:child_process";
195410
+ import { spawn as spawn2, spawnSync as spawnSync2 } from "node:child_process";
195403
195411
  import { dirname as dirname11, join as join15 } from "node:path";
195404
195412
  import { fileURLToPath as fileURLToPath7 } from "node:url";
195405
195413
  var __dirname5 = dirname11(fileURLToPath7(import.meta.url));
@@ -195409,6 +195417,7 @@ var READY_TIMEOUT = 30000;
195409
195417
  class FunctionManager {
195410
195418
  functions;
195411
195419
  running = new Map;
195420
+ starting = new Map;
195412
195421
  logger;
195413
195422
  constructor(functions, logger) {
195414
195423
  this.functions = new Map(functions.map((f7) => [f7.name, f7]));
@@ -195422,13 +195431,10 @@ class FunctionManager {
195422
195431
  }
195423
195432
  verifyDenoIsInstalled() {
195424
195433
  if (this.functions.size > 0) {
195425
- try {
195426
- spawn2("deno", ["--version"]);
195427
- } catch {
195434
+ const result = spawnSync2("deno", ["--version"]);
195435
+ if (result.error) {
195428
195436
  throw new DependencyNotFoundError("Deno is required to run functions", {
195429
- hints: [
195430
- { message: "Install Deno from https://deno.com/download" }
195431
- ]
195437
+ hints: [{ message: "Install Deno from https://deno.com/download" }]
195432
195438
  });
195433
195439
  }
195434
195440
  }
@@ -195438,15 +195444,25 @@ class FunctionManager {
195438
195444
  if (existing?.ready) {
195439
195445
  return existing.port;
195440
195446
  }
195447
+ const pending = this.starting.get(name2);
195448
+ if (pending) {
195449
+ return pending;
195450
+ }
195441
195451
  const backendFunction = this.functions.get(name2);
195442
195452
  if (!backendFunction) {
195443
195453
  throw new InvalidInputError(`Function "${name2}" not found`, {
195444
195454
  hints: [{ message: "Check available functions in your project" }]
195445
195455
  });
195446
195456
  }
195447
- if (existing && !existing.ready) {
195448
- return this.waitForReady(name2, existing);
195457
+ const promise2 = this.startFunction(name2, backendFunction);
195458
+ this.starting.set(name2, promise2);
195459
+ try {
195460
+ return await promise2;
195461
+ } finally {
195462
+ this.starting.delete(name2);
195449
195463
  }
195464
+ }
195465
+ async startFunction(name2, backendFunction) {
195450
195466
  const port = await this.allocatePort();
195451
195467
  const process21 = this.spawnFunction(backendFunction, port);
195452
195468
  const runningFunc = {
@@ -195468,6 +195484,7 @@ class FunctionManager {
195468
195484
  process21.kill();
195469
195485
  }
195470
195486
  this.running.clear();
195487
+ this.starting.clear();
195471
195488
  }
195472
195489
  stop(name2) {
195473
195490
  const running = this.running.get(name2);
@@ -195520,7 +195537,16 @@ class FunctionManager {
195520
195537
  }
195521
195538
  waitForReady(name2, runningFunc) {
195522
195539
  return new Promise((resolve5, reject) => {
195540
+ runningFunc.process.on("exit", (code2) => {
195541
+ if (!runningFunc.ready) {
195542
+ clearTimeout(timeout3);
195543
+ reject(new InternalError(`Function "${name2}" exited with code ${code2}`, {
195544
+ hints: [{ message: "Check the function code for errors" }]
195545
+ }));
195546
+ }
195547
+ });
195523
195548
  const timeout3 = setTimeout(() => {
195549
+ runningFunc.process.kill();
195524
195550
  reject(new InternalError(`Function "${name2}" failed to start within ${READY_TIMEOUT / 1000}s timeout`, {
195525
195551
  hints: [
195526
195552
  { message: "Check the function code for startup errors" }
@@ -195537,14 +195563,6 @@ class FunctionManager {
195537
195563
  }
195538
195564
  };
195539
195565
  runningFunc.process.stdout?.on("data", onData);
195540
- runningFunc.process.on("exit", (code2) => {
195541
- if (!runningFunc.ready) {
195542
- clearTimeout(timeout3);
195543
- reject(new InternalError(`Function "${name2}" exited with code ${code2}`, {
195544
- hints: [{ message: "Check the function code for errors" }]
195545
- }));
195546
- }
195547
- });
195548
195566
  });
195549
195567
  }
195550
195568
  }
@@ -195613,8 +195631,10 @@ function proxyRequest(req, res, port, logger) {
195613
195631
  error: "Failed to proxy request to function",
195614
195632
  details: error48.message
195615
195633
  });
195634
+ res.once("finish", resolve5);
195635
+ } else {
195636
+ resolve5();
195616
195637
  }
195617
- resolve5();
195618
195638
  });
195619
195639
  req.pipe(proxyReq);
195620
195640
  });
@@ -195645,9 +195665,7 @@ async function createDevServer(options8) {
195645
195665
  }
195646
195666
  next();
195647
195667
  });
195648
- const [functions] = await Promise.all([
195649
- functionResource.readAll(join16(configDir, project2.functionsDir))
195650
- ]);
195668
+ const functions = await functionResource.readAll(join16(configDir, project2.functionsDir));
195651
195669
  const devLogger = createDevLogger(false);
195652
195670
  const functionManager = new FunctionManager(functions, devLogger);
195653
195671
  functionManager.verifyDenoIsInstalled();
@@ -195667,12 +195685,13 @@ async function createDevServer(options8) {
195667
195685
  } else {
195668
195686
  reject(err);
195669
195687
  }
195688
+ } else {
195670
195689
  const shutdown = () => {
195671
195690
  functionManager.stopAll();
195691
+ server.close();
195672
195692
  };
195673
195693
  process.on("SIGINT", shutdown);
195674
195694
  process.on("SIGTERM", shutdown);
195675
- } else {
195676
195695
  resolve5({
195677
195696
  port,
195678
195697
  server
@@ -195785,7 +195804,7 @@ async function eject(options8) {
195785
195804
  }
195786
195805
  function getEjectCommand(context) {
195787
195806
  return new Command("eject").description("Download the code for an existing Base44 project").option("-p, --path <path>", "Path where to write the project").option("--project-id <id>", "Project ID to eject (skips interactive selection)").option("-y, --yes", "Skip confirmation prompts").action(async (options8) => {
195788
- await runCommand(() => eject(options8), { requireAuth: true, requireAppConfig: false }, context);
195807
+ await runCommand(() => eject({ ...options8, isNonInteractive: context.isNonInteractive }), { requireAuth: true, requireAppConfig: false }, context);
195789
195808
  });
195790
195809
  }
195791
195810
 
@@ -200052,7 +200071,8 @@ function addCommandInfoToErrorReporter(program2, errorReporter) {
200052
200071
  async function runCLI() {
200053
200072
  const errorReporter = new ErrorReporter;
200054
200073
  errorReporter.registerProcessErrorHandlers();
200055
- const context = { errorReporter };
200074
+ const isNonInteractive = !process.stdin.isTTY || !process.stdout.isTTY;
200075
+ const context = { errorReporter, isNonInteractive };
200056
200076
  const program2 = createProgram(context);
200057
200077
  try {
200058
200078
  const userInfo = await readAuth();
@@ -200077,4 +200097,4 @@ export {
200077
200097
  CLIExitError
200078
200098
  };
200079
200099
 
200080
- //# debugId=B7317FFB63A141D964756E2164756E21
200100
+ //# debugId=E2377672720E70A864756E2164756E21