@base44-preview/cli 0.1.4-pr.567.a56c290 → 0.1.5-pr.569.0f0eefe

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
@@ -218287,6 +218287,7 @@ var PROJECT_CONFIG_PATTERNS = [
218287
218287
  `config.${CONFIG_FILE_EXTENSION_GLOB}`
218288
218288
  ];
218289
218289
  var BASE44_APP_ID_ENV_VAR = "BASE44_APP_ID";
218290
+ var DEFAULT_DEV_SERVER_PORT = 4400;
218290
218291
  var TYPES_OUTPUT_SUBDIR = ".types";
218291
218292
  var TYPES_FILENAME = "types.d.ts";
218292
218293
  var AUTH_CLIENT_ID = "base44_cli";
@@ -244011,7 +244012,7 @@ import { join as join11 } from "node:path";
244011
244012
  // package.json
244012
244013
  var package_default = {
244013
244014
  name: "base44",
244014
- version: "0.1.4",
244015
+ version: "0.1.5",
244015
244016
  description: "Base44 CLI - Unified interface for managing Base44 applications",
244016
244017
  type: "module",
244017
244018
  bin: {
@@ -258457,17 +258458,14 @@ function getDevCommand() {
258457
258458
  import { spawn as spawn4 } from "node:child_process";
258458
258459
  import { copyFileSync, writeFileSync as writeFileSync2 } from "node:fs";
258459
258460
  async function runScript(options8) {
258460
- const { appId, code: code2 } = options8;
258461
+ const { appId, code: code2, local } = options8;
258461
258462
  verifyDenoInstalled("to run scripts with exec");
258462
258463
  const cleanupFns = [];
258463
258464
  const tempScript = await $file({ postfix: ".ts" });
258464
258465
  cleanupFns.push(tempScript.cleanup);
258465
258466
  writeFileSync2(tempScript.path, code2, "utf-8");
258466
258467
  const scriptPath = `file://${tempScript.path}`;
258467
- const [appUserToken, appBaseUrl] = await Promise.all([
258468
- getAppUserToken(),
258469
- getSiteUrl()
258470
- ]);
258468
+ const [appUserToken, appBaseUrl] = local ? [local.token, local.serverUrl] : await Promise.all([getAppUserToken(), getSiteUrl()]);
258471
258469
  const tempWrapper = await $file({ postfix: ".ts" });
258472
258470
  cleanupFns.push(tempWrapper.cleanup);
258473
258471
  copyFileSync(getExecWrapperPath(), tempWrapper.path);
@@ -258506,10 +258504,28 @@ function readStdin2() {
258506
258504
  process.stdin.on("error", reject);
258507
258505
  });
258508
258506
  }
258509
- async function execAction({
258510
- app,
258511
- isNonInteractive
258512
- }) {
258507
+ function parsePort(value) {
258508
+ const port = Number(value);
258509
+ if (!Number.isInteger(port) || port <= 0 || port > 65535) {
258510
+ throw new InvalidInputError(`Invalid --port value: "${value}".`, {
258511
+ hints: [{ message: "Pass a port number, e.g. --port 4400" }]
258512
+ });
258513
+ }
258514
+ return port;
258515
+ }
258516
+ async function resolveLocalTarget(port) {
258517
+ const { email: email3 } = await readAuth();
258518
+ return {
258519
+ serverUrl: `http://localhost:${port}`,
258520
+ token: createJwtToken(email3)
258521
+ };
258522
+ }
258523
+ async function execAction({ app, isNonInteractive }, options8) {
258524
+ if (options8.port !== undefined && !options8.local) {
258525
+ throw new InvalidInputError("--port can only be used with --local.", {
258526
+ hints: [{ message: "Usage: base44 exec --local --port <port>" }]
258527
+ });
258528
+ }
258513
258529
  const noInputError = new InvalidInputError("No input provided. Pipe a script to stdin.", {
258514
258530
  hints: [
258515
258531
  { message: "File: cat ./script.ts | base44 exec" },
@@ -258525,22 +258541,24 @@ async function execAction({
258525
258541
  if (!code2.trim()) {
258526
258542
  throw noInputError;
258527
258543
  }
258528
- const { exitCode } = await runScript({ appId: app.id, code: code2 });
258544
+ const local = options8.local ? await resolveLocalTarget(options8.port !== undefined ? parsePort(options8.port) : DEFAULT_DEV_SERVER_PORT) : undefined;
258545
+ const { exitCode } = await runScript({ appId: app.id, code: code2, local });
258529
258546
  if (exitCode !== 0) {
258530
258547
  process.exitCode = exitCode;
258531
258548
  }
258532
258549
  return {};
258533
258550
  }
258534
258551
  function getExecCommand() {
258535
- return new Base44Command("exec").description("Run a script with the Base44 SDK pre-authenticated as the current user").addHelpText("after", `
258552
+ return new Base44Command("exec").description("Run a script with the Base44 SDK pre-authenticated as the current user").option("--local", "Run against the local `base44 dev` server instead of the deployed app").option("--port <number>", `Port the local dev server is on (with --local; defaults to ${DEFAULT_DEV_SERVER_PORT})`).addHelpText("after", `
258536
258553
  Examples:
258537
258554
  Run a script file:
258538
258555
  $ cat ./script.ts | base44 exec
258539
258556
 
258540
258557
  Inline script:
258541
- $ echo "const users = await base44.entities.User.list()" | base44 exec`).action(async (ctx) => {
258542
- return await execAction(ctx);
258543
- });
258558
+ $ echo "const users = await base44.entities.User.list()" | base44 exec
258559
+
258560
+ Against the local dev server (base44 dev must be running):
258561
+ $ echo "await base44.entities.Task.create({ title: 'seed' })" | base44 exec --local`).action(execAction);
258544
258562
  }
258545
258563
 
258546
258564
  // src/cli/commands/project/eject.ts
@@ -262934,4 +262952,4 @@ export {
262934
262952
  CLIExitError
262935
262953
  };
262936
262954
 
262937
- //# debugId=A13BE6B0A6A9F5CD64756E2164756E21
262955
+ //# debugId=8BDA6B1F446714F764756E2164756E21