@base44-preview/cli 0.1.16-pr.635.6b1b04b → 0.1.16-pr.635.9acfc73

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
@@ -230705,11 +230705,11 @@ var TemplatesConfigSchema = object({
230705
230705
  templates: array(TemplateSchema)
230706
230706
  });
230707
230707
  var SiteConfigSchema = object({
230708
- buildCommand: string2().optional().default("npm run build"),
230708
+ buildCommand: string2().default("npm run build"),
230709
230709
  serveCommand: string2().optional(),
230710
- outputDirectory: string2().optional().default("./dist"),
230711
- installCommand: string2().optional().default("npm install"),
230712
- devHostFlag: string2().optional().default("--host")
230710
+ outputDirectory: string2().optional(),
230711
+ installCommand: string2().default("npm install"),
230712
+ devHostFlag: string2().optional()
230713
230713
  });
230714
230714
  var PluginMetadataSchema = object({
230715
230715
  namespace: string2().min(1, "Plugin namespace cannot be empty").regex(/^[a-zA-Z0-9_-]+$/, "Plugin namespace can only contain letters, numbers, underscores, and dashes")
@@ -246682,19 +246682,39 @@ async function gitHead(projectRoot) {
246682
246682
  }
246683
246683
  // src/core/site/serve-command.ts
246684
246684
  var DEFAULT_SERVE_COMMAND = "npm run dev";
246685
- var NPM_RUN_COMMAND = /^npm(\s+--prefix\s+\S+)?\s+run\s+\S+$/;
246685
+ var DEFAULT_HOST_FLAG = "--host";
246686
+ var SCRIPT = "[A-Za-z0-9:_.-]+";
246687
+ var PREFIX2 = "[A-Za-z0-9._/-]+";
246688
+ var SCRIPT_RUNNERS = [
246689
+ {
246690
+ pattern: new RegExp(String.raw`^npm(\s+--prefix\s+${PREFIX2})?\s+run\s+${SCRIPT}$`),
246691
+ separator: " -- "
246692
+ },
246693
+ {
246694
+ pattern: new RegExp(String.raw`^(?:pnpm|yarn|bun)(\s+run)?\s+${SCRIPT}$`),
246695
+ separator: " "
246696
+ }
246697
+ ];
246698
+ function runnerFor(serveCommand) {
246699
+ return SCRIPT_RUNNERS.find((runner) => runner.pattern.test(serveCommand));
246700
+ }
246686
246701
  function withServeAddress(serveCommand, { host, port, hostFlag }) {
246702
+ const command = serveCommand.trim();
246687
246703
  const args = [
246688
- ...host ? [hostFlag, host] : [],
246704
+ ...host ? [hostFlag ?? DEFAULT_HOST_FLAG, host] : [],
246689
246705
  ...port === undefined ? [] : ["--port", String(port)]
246690
246706
  ];
246691
- if (args.length === 0 || !NPM_RUN_COMMAND.test(serveCommand.trim())) {
246692
- return serveCommand;
246707
+ if (args.length === 0) {
246708
+ return { command, droppedAddress: false };
246693
246709
  }
246694
- return `${serveCommand} -- ${args.join(" ")}`;
246695
- }
246696
- function forwardsServeAddress(serveCommand) {
246697
- return NPM_RUN_COMMAND.test(serveCommand.trim());
246710
+ const runner = runnerFor(command);
246711
+ if (!runner) {
246712
+ return { command, droppedAddress: true };
246713
+ }
246714
+ return {
246715
+ command: `${command}${runner.separator}${args.join(" ")}`,
246716
+ droppedAddress: false
246717
+ };
246698
246718
  }
246699
246719
  // src/core/project/deploy.ts
246700
246720
  function hasResourcesToDeploy(projectData) {
@@ -246708,7 +246728,7 @@ function hasResourcesToDeploy(projectData) {
246708
246728
  connectors,
246709
246729
  authConfig
246710
246730
  } = projectData;
246711
- const hasSite = project.site !== undefined;
246731
+ const hasSite = Boolean(project.site?.outputDirectory);
246712
246732
  const hasEntities = entities.length > 0;
246713
246733
  const hasFunctions = functions.length > 0;
246714
246734
  const hasActors = actors.length > 0;
@@ -251067,7 +251087,7 @@ async function deployTarball({ runTask }, project) {
251067
251087
  throw new ConfigNotFoundError("No site configuration found.", {
251068
251088
  hints: [
251069
251089
  {
251070
- message: `Add a 'site' block to your config.jsonc (e.g., "site": { "outputDirectory": "dist" }). Inside one, outputDirectory defaults to "./dist".`
251090
+ message: `Add 'site.outputDirectory' to your config.jsonc (e.g., "site": { "outputDirectory": "dist" })`
251071
251091
  }
251072
251092
  ]
251073
251093
  });
@@ -251256,7 +251276,7 @@ function createServeCommandRunner({
251256
251276
  cwd: projectRoot,
251257
251277
  env: {
251258
251278
  VITE_BASE44_APP_ID: appId,
251259
- VITE_BASE44_APP_BASE_URL: appBaseUrl
251279
+ ...appBaseUrl ? { VITE_BASE44_APP_BASE_URL: appBaseUrl } : {}
251260
251280
  },
251261
251281
  logger: createDevLogger("frontend", theme.colors.base44Orange)
251262
251282
  });
@@ -251271,28 +251291,34 @@ function stopRunnerOnProcessSignals(runner) {
251271
251291
  }
251272
251292
 
251273
251293
  // src/cli/commands/site/dev.ts
251274
- async function siteDevAction(ctx, options) {
251275
- const { app, log } = ctx;
251276
- if (!app) {
251277
- throw new InvalidInputError("No app id resolved for this project.");
251294
+ function parsePort(value) {
251295
+ if (!/^\d+$/.test(value)) {
251296
+ throw new InvalidArgumentError2("must be a whole number");
251278
251297
  }
251279
- const port = options.port === undefined ? undefined : Number(options.port);
251280
- if (port !== undefined && !Number.isInteger(port)) {
251281
- throw new InvalidInputError(`--port must be a whole number: ${options.port}`);
251298
+ const port = Number(value);
251299
+ if (port < 1 || port > 65535) {
251300
+ throw new InvalidArgumentError2("must be between 1 and 65535");
251301
+ }
251302
+ return port;
251303
+ }
251304
+ async function siteDevAction(ctx, options) {
251305
+ const { app } = ctx;
251306
+ if (!app?.projectRoot) {
251307
+ throw new ConfigInvalidError("base44 site dev requires a linked local project. Run it from a project with base44/.app.jsonc.");
251282
251308
  }
251283
251309
  const { project } = await readProjectConfig(app.projectRoot);
251284
251310
  const site = project.site;
251285
251311
  if (!site) {
251286
- throw new InvalidInputError(`This project has no 'site' block in base44/config.jsonc, so there is no frontend to serve. Add one; inside it serveCommand defaults to "npm run dev".`);
251312
+ throw new InvalidInputError(`This project has no 'site' block in base44/config.jsonc, so there is no frontend to serve. Add one naming its serveCommand; site dev falls back to "npm run dev".`);
251287
251313
  }
251288
251314
  const serveCommand = site.serveCommand ?? DEFAULT_SERVE_COMMAND;
251289
- const command = withServeAddress(serveCommand, {
251315
+ const { command, droppedAddress } = withServeAddress(serveCommand, {
251290
251316
  host: options.host,
251291
- port,
251317
+ port: options.port,
251292
251318
  hostFlag: site.devHostFlag
251293
251319
  });
251294
- if ((options.host || port !== undefined) && !forwardsServeAddress(serveCommand)) {
251295
- log.warn(`serveCommand '${serveCommand}' is not an 'npm run' invocation, so --host/--port were not passed to it. Put the address in serveCommand itself.`);
251320
+ if (droppedAddress) {
251321
+ throw new InvalidInputError(`serveCommand '${serveCommand}' takes no forwarded arguments, so --host/--port cannot be passed to it. Put the address in serveCommand itself, or use an 'npm run', 'pnpm', 'yarn' or 'bun run' script.`);
251296
251322
  }
251297
251323
  const runner = createServeCommandRunner({
251298
251324
  serveCommand: command,
@@ -251304,11 +251330,11 @@ async function siteDevAction(ctx, options) {
251304
251330
  runner.onExit((code) => process.exit(code ?? 1));
251305
251331
  runner.start();
251306
251332
  return {
251307
- outroMessage: `Frontend dev server running '${command}' against ${theme.styles.bold(options.backendUrl)}`
251333
+ outroMessage: options.backendUrl ? `Frontend dev server running '${command}' against ${theme.styles.bold(options.backendUrl)}` : `Frontend dev server running '${command}'`
251308
251334
  };
251309
251335
  }
251310
251336
  function getSiteDevCommand() {
251311
- return new Base44Command("dev", { requireAuth: false }).description("Run the site's dev server against a given backend (no local backend)").requiredOption("--backend-url <url>", "Backend the frontend should call, injected as VITE_BASE44_APP_BASE_URL").option("--host <address>", "Address to bind, e.g. 0.0.0.0").option("--port <number>", "Port to bind").action(siteDevAction);
251337
+ return new Base44Command("dev", { requireAuth: false }).description("Run the site's dev server against a given backend (no local backend)").option("--backend-url <url>", "Backend the frontend should call, injected as VITE_BASE44_APP_BASE_URL. Omit for a frontend that reaches its backend same-origin.").option("--host <address>", "Address to bind, e.g. 0.0.0.0").option("--port <number>", "Port to bind", parsePort).action(siteDevAction);
251312
251338
  }
251313
251339
 
251314
251340
  // src/cli/commands/site/open.ts
@@ -255754,7 +255780,7 @@ function readStdin2() {
255754
255780
  process.stdin.on("error", reject);
255755
255781
  });
255756
255782
  }
255757
- function parsePort(value) {
255783
+ function parsePort2(value) {
255758
255784
  const port = Number(value);
255759
255785
  if (!Number.isInteger(port) || port <= 0 || port > 65535) {
255760
255786
  throw new InvalidInputError(`Invalid --port value: "${value}".`, {
@@ -255791,7 +255817,7 @@ async function execAction({ app, isNonInteractive }, options) {
255791
255817
  if (!code.trim()) {
255792
255818
  throw noInputError;
255793
255819
  }
255794
- const local = options.local ? await resolveLocalTarget(options.port !== undefined ? parsePort(options.port) : DEFAULT_DEV_SERVER_PORT) : undefined;
255820
+ const local = options.local ? await resolveLocalTarget(options.port !== undefined ? parsePort2(options.port) : DEFAULT_DEV_SERVER_PORT) : undefined;
255795
255821
  const { exitCode } = await runScript({
255796
255822
  appId: app.id,
255797
255823
  code,
@@ -255903,17 +255929,22 @@ async function eject(ctx, options, command) {
255903
255929
  errorMessage: "Failed to pull project"
255904
255930
  });
255905
255931
  const { project } = await readProjectConfig(resolvedPath);
255906
- const installCommand = project.site?.installCommand;
255907
- const buildCommand = project.site?.buildCommand;
255908
- if (installCommand && buildCommand) {
255932
+ const site = project.site;
255933
+ if (site) {
255909
255934
  const shouldDeploy = options.yes ? true : await Re({
255910
255935
  message: "Would you like to deploy your project now?"
255911
255936
  });
255912
255937
  if (!Ct(shouldDeploy) && shouldDeploy) {
255913
255938
  await runTask("Installing dependencies...", async (updateMessage) => {
255914
- await execa({ cwd: resolvedPath, shell: true })`${installCommand}`;
255939
+ await execa({
255940
+ cwd: resolvedPath,
255941
+ shell: true
255942
+ })`${site.installCommand}`;
255915
255943
  updateMessage("Building project...");
255916
- await execa({ cwd: resolvedPath, shell: true })`${buildCommand}`;
255944
+ await execa({
255945
+ cwd: resolvedPath,
255946
+ shell: true
255947
+ })`${site.buildCommand}`;
255917
255948
  }, {
255918
255949
  successMessage: theme.colors.base44Orange("Project built successfully"),
255919
255950
  errorMessage: "Failed to build project"
@@ -260021,4 +260052,4 @@ export {
260021
260052
  runCLI
260022
260053
  };
260023
260054
 
260024
- //# debugId=03FA5EAAD08DEC4B64756E2164756E21
260055
+ //# debugId=4E22A7FA1E6E28E764756E2164756E21