@base44-preview/cli 0.1.16-pr.635.0ca7e05 → 0.1.16-pr.635.2ec10a1

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().default("npm run build"),
230709
- serveCommand: string2().optional(),
230710
- outputDirectory: string2().optional(),
230711
- installCommand: string2().default("npm install"),
230712
- devHostFlag: string2().optional()
230708
+ buildCommand: string2().optional().default("npm run build"),
230709
+ serveCommand: string2().optional().default("npm run dev"),
230710
+ outputDirectory: string2().optional().default("./dist"),
230711
+ installCommand: string2().optional().default("npm install"),
230712
+ devHostFlag: string2().optional().default("--host")
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")
@@ -246681,40 +246681,19 @@ async function gitHead(projectRoot) {
246681
246681
  }
246682
246682
  }
246683
246683
  // src/core/site/serve-command.ts
246684
- var DEFAULT_SERVE_COMMAND = "npm run dev";
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
- }
246684
+ var NPM_RUN_COMMAND = /^npm(\s+--prefix\s+\S+)?\s+run\s+\S+$/;
246701
246685
  function withServeAddress(serveCommand, { host, port, hostFlag }) {
246702
- const command = serveCommand.trim();
246703
246686
  const args = [
246704
- ...host ? [hostFlag ?? DEFAULT_HOST_FLAG, host] : [],
246687
+ ...host ? [hostFlag, host] : [],
246705
246688
  ...port === undefined ? [] : ["--port", String(port)]
246706
246689
  ];
246707
- if (args.length === 0) {
246708
- return { command, droppedAddress: false };
246690
+ if (args.length === 0 || !NPM_RUN_COMMAND.test(serveCommand.trim())) {
246691
+ return serveCommand;
246709
246692
  }
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
- };
246693
+ return `${serveCommand} -- ${args.join(" ")}`;
246694
+ }
246695
+ function forwardsServeAddress(serveCommand) {
246696
+ return NPM_RUN_COMMAND.test(serveCommand.trim());
246718
246697
  }
246719
246698
  // src/core/project/deploy.ts
246720
246699
  function hasResourcesToDeploy(projectData) {
@@ -246728,7 +246707,7 @@ function hasResourcesToDeploy(projectData) {
246728
246707
  connectors,
246729
246708
  authConfig
246730
246709
  } = projectData;
246731
- const hasSite = Boolean(project.site?.outputDirectory);
246710
+ const hasSite = project.site !== undefined;
246732
246711
  const hasEntities = entities.length > 0;
246733
246712
  const hasFunctions = functions.length > 0;
246734
246713
  const hasActors = actors.length > 0;
@@ -249618,7 +249597,7 @@ async function buildAction(ctx) {
249618
249597
  };
249619
249598
  }
249620
249599
  function getBuildCommand() {
249621
- return new Base44Command("build", { requireAuth: false }).description("Build the site with the Base44 app id injected").action(buildAction);
249600
+ return new Base44Command("build").description("Build the site with the Base44 app id injected").action(buildAction);
249622
249601
  }
249623
249602
 
249624
249603
  // src/cli/commands/project/create.ts
@@ -251087,7 +251066,7 @@ async function deployTarball({ runTask }, project) {
251087
251066
  throw new ConfigNotFoundError("No site configuration found.", {
251088
251067
  hints: [
251089
251068
  {
251090
- message: `Add 'site.outputDirectory' to your config.jsonc (e.g., "site": { "outputDirectory": "dist" })`
251069
+ message: `Add a 'site' block to your config.jsonc (e.g., "site": { "outputDirectory": "dist" }). Inside one, outputDirectory defaults to "./dist".`
251091
251070
  }
251092
251071
  ]
251093
251072
  });
@@ -251276,7 +251255,7 @@ function createServeCommandRunner({
251276
251255
  cwd: projectRoot,
251277
251256
  env: {
251278
251257
  VITE_BASE44_APP_ID: appId,
251279
- ...appBaseUrl ? { VITE_BASE44_APP_BASE_URL: appBaseUrl } : {}
251258
+ VITE_BASE44_APP_BASE_URL: appBaseUrl
251280
251259
  },
251281
251260
  logger: createDevLogger("frontend", theme.colors.base44Orange)
251282
251261
  });
@@ -251291,34 +251270,27 @@ function stopRunnerOnProcessSignals(runner) {
251291
251270
  }
251292
251271
 
251293
251272
  // src/cli/commands/site/dev.ts
251294
- function parsePort(value) {
251295
- if (!/^\d+$/.test(value)) {
251296
- throw new InvalidArgumentError2("must be a whole number");
251297
- }
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
251273
  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.");
251274
+ const { app, log } = ctx;
251275
+ if (!app) {
251276
+ throw new InvalidInputError("No app id resolved for this project.");
251277
+ }
251278
+ const port = options.port === undefined ? undefined : Number(options.port);
251279
+ if (port !== undefined && !Number.isInteger(port)) {
251280
+ throw new InvalidInputError(`--port must be a whole number: ${options.port}`);
251308
251281
  }
251309
251282
  const { project } = await readProjectConfig(app.projectRoot);
251310
251283
  const site = project.site;
251311
251284
  if (!site) {
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".`);
251285
+ 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".`);
251313
251286
  }
251314
- const serveCommand = site.serveCommand ?? DEFAULT_SERVE_COMMAND;
251315
- const { command, droppedAddress } = withServeAddress(serveCommand, {
251287
+ const command = withServeAddress(site.serveCommand, {
251316
251288
  host: options.host,
251317
- port: options.port,
251289
+ port,
251318
251290
  hostFlag: site.devHostFlag
251319
251291
  });
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.`);
251292
+ if ((options.host || port !== undefined) && !forwardsServeAddress(site.serveCommand)) {
251293
+ log.warn(`serveCommand '${site.serveCommand}' is not an 'npm run' invocation, so --host/--port were not passed to it. Put the address in serveCommand itself.`);
251322
251294
  }
251323
251295
  const runner = createServeCommandRunner({
251324
251296
  serveCommand: command,
@@ -251330,11 +251302,11 @@ async function siteDevAction(ctx, options) {
251330
251302
  runner.onExit((code) => process.exit(code ?? 1));
251331
251303
  runner.start();
251332
251304
  return {
251333
- outroMessage: options.backendUrl ? `Frontend dev server running '${command}' against ${theme.styles.bold(options.backendUrl)}` : `Frontend dev server running '${command}'`
251305
+ outroMessage: `Frontend dev server running '${command}' against ${theme.styles.bold(options.backendUrl)}`
251334
251306
  };
251335
251307
  }
251336
251308
  function getSiteDevCommand() {
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);
251309
+ 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);
251338
251310
  }
251339
251311
 
251340
251312
  // src/cli/commands/site/open.ts
@@ -255678,7 +255650,7 @@ function startServeCommand(runner, backend) {
255678
255650
  async function remoteDevAction(app) {
255679
255651
  const site = await resolveConfiguredSite(app);
255680
255652
  if (!site) {
255681
- throw new ConfigInvalidError("base44 dev --remote serves the frontend against the production backend, but this project has no site.serveCommand in base44/config.jsonc.");
255653
+ throw new ConfigInvalidError(`base44 dev --remote serves the frontend against the production backend, but this project has no 'site' block in base44/config.jsonc. Add one; inside it serveCommand defaults to "npm run dev".`);
255682
255654
  }
255683
255655
  const appBaseUrl = await getSiteUrl();
255684
255656
  const runner = createServeCommandRunner({
@@ -255780,7 +255752,7 @@ function readStdin2() {
255780
255752
  process.stdin.on("error", reject);
255781
255753
  });
255782
255754
  }
255783
- function parsePort2(value) {
255755
+ function parsePort(value) {
255784
255756
  const port = Number(value);
255785
255757
  if (!Number.isInteger(port) || port <= 0 || port > 65535) {
255786
255758
  throw new InvalidInputError(`Invalid --port value: "${value}".`, {
@@ -255817,7 +255789,7 @@ async function execAction({ app, isNonInteractive }, options) {
255817
255789
  if (!code.trim()) {
255818
255790
  throw noInputError;
255819
255791
  }
255820
- const local = options.local ? await resolveLocalTarget(options.port !== undefined ? parsePort2(options.port) : DEFAULT_DEV_SERVER_PORT) : undefined;
255792
+ const local = options.local ? await resolveLocalTarget(options.port !== undefined ? parsePort(options.port) : DEFAULT_DEV_SERVER_PORT) : undefined;
255821
255793
  const { exitCode } = await runScript({
255822
255794
  appId: app.id,
255823
255795
  code,
@@ -255929,22 +255901,17 @@ async function eject(ctx, options, command) {
255929
255901
  errorMessage: "Failed to pull project"
255930
255902
  });
255931
255903
  const { project } = await readProjectConfig(resolvedPath);
255932
- const site = project.site;
255933
- if (site?.outputDirectory) {
255904
+ const installCommand = project.site?.installCommand;
255905
+ const buildCommand = project.site?.buildCommand;
255906
+ if (installCommand && buildCommand) {
255934
255907
  const shouldDeploy = options.yes ? true : await Re({
255935
255908
  message: "Would you like to deploy your project now?"
255936
255909
  });
255937
255910
  if (!Ct(shouldDeploy) && shouldDeploy) {
255938
255911
  await runTask("Installing dependencies...", async (updateMessage) => {
255939
- await execa({
255940
- cwd: resolvedPath,
255941
- shell: true
255942
- })`${site.installCommand}`;
255912
+ await execa({ cwd: resolvedPath, shell: true })`${installCommand}`;
255943
255913
  updateMessage("Building project...");
255944
- await execa({
255945
- cwd: resolvedPath,
255946
- shell: true
255947
- })`${site.buildCommand}`;
255914
+ await execa({ cwd: resolvedPath, shell: true })`${buildCommand}`;
255948
255915
  }, {
255949
255916
  successMessage: theme.colors.base44Orange("Project built successfully"),
255950
255917
  errorMessage: "Failed to build project"
@@ -260052,4 +260019,4 @@ export {
260052
260019
  runCLI
260053
260020
  };
260054
260021
 
260055
- //# debugId=641CFB9F676DAC6564756E2164756E21
260022
+ //# debugId=26F032DEEC9B5A8664756E2164756E21