@base44-preview/cli 0.0.37-pr.357.cd3f097 → 0.0.37-pr.357.f1ef2fd

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
@@ -244359,14 +244359,14 @@ import { tmpdir as tmpdir2 } from "node:os";
244359
244359
  import { dirname as dirname12, join as join16, resolve as resolve6 } from "node:path";
244360
244360
  import { fileURLToPath as fileURLToPath8 } from "node:url";
244361
244361
  var __dirname6 = dirname12(fileURLToPath8(import.meta.url));
244362
- var EXEC_WRAPPER_PATH = join16(__dirname6, "../deno-runtime/exec.js");
244362
+ var EXEC_WRAPPER_PATH = join16(__dirname6, "../deno-runtime/exec.ts");
244363
244363
  function verifyDenoIsInstalled() {
244364
244364
  const result = spawnSync3("deno", ["--version"]);
244365
244365
  if (result.error) {
244366
244366
  throw new DependencyNotFoundError("Deno is required to run scripts with exec", {
244367
244367
  hints: [
244368
244368
  {
244369
- message: "Install Deno: https://docs.deno.com/runtime/getting-started/installation/"
244369
+ message: "Install Deno: https://docs.deno.com/runtime/getting_started/installation/"
244370
244370
  }
244371
244371
  ]
244372
244372
  });
@@ -244384,24 +244384,25 @@ function readStdin() {
244384
244384
  });
244385
244385
  }
244386
244386
  async function execAction(scriptArg, options8, extraArgs) {
244387
- verifyDenoIsInstalled();
244388
244387
  let scriptPath;
244389
244388
  let tempFile = null;
244390
244389
  const hasFile = scriptArg !== undefined;
244391
244390
  const hasEval = options8.eval !== undefined;
244392
- const isStdinPipe = !hasFile && !hasEval && !process.stdin.isTTY;
244393
- if (hasFile && hasEval) {
244394
- throw new InvalidInputError("Cannot use both a file path and -e flag. Provide only one input mode.");
244391
+ const hasStdin = options8.stdin === true;
244392
+ const inputCount = [hasFile, hasEval, hasStdin].filter(Boolean).length;
244393
+ if (inputCount > 1) {
244394
+ throw new InvalidInputError("Cannot use more than one input mode. Provide only one of: file path, -e, or --stdin.");
244395
244395
  }
244396
- if (!hasFile && !hasEval && !isStdinPipe) {
244397
- throw new InvalidInputError("No script provided. Pass a file path, use -e for inline code, or pipe from stdin.", {
244396
+ if (inputCount === 0) {
244397
+ throw new InvalidInputError("No script provided. Pass a file path, use -e for inline code, or use --stdin.", {
244398
244398
  hints: [
244399
244399
  { message: "File: base44 exec ./script.ts" },
244400
244400
  { message: 'Eval: base44 exec -e "console.log(1)"' },
244401
- { message: "Stdin: echo 'code' | base44 exec" }
244401
+ { message: "Stdin: echo 'code' | base44 exec --stdin" }
244402
244402
  ]
244403
244403
  });
244404
244404
  }
244405
+ verifyDenoIsInstalled();
244405
244406
  if (hasFile) {
244406
244407
  scriptPath = `file://${resolve6(scriptArg)}`;
244407
244408
  } else {
@@ -244411,24 +244412,34 @@ async function execAction(scriptArg, options8, extraArgs) {
244411
244412
  scriptPath = `file://${tempFile}`;
244412
244413
  }
244413
244414
  const appConfig = getAppConfig();
244414
- let appUserToken;
244415
- try {
244416
- const response = await getAppClient().get("auth/token").json();
244417
- appUserToken = response.token;
244418
- } catch (error48) {
244419
- throw await ApiError.fromHttpError(error48, "exchanging platform token for app user token");
244420
- }
244421
- const tempWrapper = join16(tmpdir2(), `base44-exec-wrapper-${Date.now()}.js`);
244415
+ const [appUserToken, appBaseUrl] = await Promise.all([
244416
+ (async () => {
244417
+ try {
244418
+ const response = await getAppClient().get("auth/token").json();
244419
+ return response.token;
244420
+ } catch (error48) {
244421
+ throw await ApiError.fromHttpError(error48, "exchanging platform token for app user token");
244422
+ }
244423
+ })(),
244424
+ getSiteUrl()
244425
+ ]);
244426
+ const tempWrapper = join16(tmpdir2(), `base44-exec-wrapper-${Date.now()}.ts`);
244422
244427
  copyFileSync(EXEC_WRAPPER_PATH, tempWrapper);
244423
244428
  try {
244424
244429
  const exitCode = await new Promise((resolvePromise) => {
244425
- const child = spawn3("deno", ["run", "--allow-all", "--node-modules-dir=auto", tempWrapper, ...extraArgs], {
244430
+ const child = spawn3("deno", [
244431
+ "run",
244432
+ "--allow-all",
244433
+ "--node-modules-dir=auto",
244434
+ tempWrapper,
244435
+ ...extraArgs
244436
+ ], {
244426
244437
  env: {
244427
244438
  ...process.env,
244428
244439
  SCRIPT_PATH: scriptPath,
244429
244440
  BASE44_APP_ID: appConfig.id,
244430
244441
  BASE44_ACCESS_TOKEN: appUserToken,
244431
- BASE44_API_URL: getBase44ApiUrl()
244442
+ BASE44_APP_BASE_URL: appBaseUrl
244432
244443
  },
244433
244444
  stdio: "inherit"
244434
244445
  });
@@ -244451,7 +244462,7 @@ async function execAction(scriptArg, options8, extraArgs) {
244451
244462
  return {};
244452
244463
  }
244453
244464
  function getExecCommand(context) {
244454
- const cmd = new Command("exec").description("Run a script with the Base44 SDK pre-authenticated as the current user").argument("[script]", "Path to a .ts or .js script file").option("-e, --eval <code>", "Evaluate inline code").allowUnknownOption(true).action(async (script, options8) => {
244465
+ const cmd = new Command("exec").description("Run a script with the Base44 SDK pre-authenticated as the current user").argument("[script]", "Path to a .ts or .js script file").option("-e, --eval <code>", "Evaluate inline code").option("--stdin", "Read script from stdin").allowUnknownOption(true).action(async (script, options8) => {
244455
244466
  const dashIndex = process.argv.indexOf("--");
244456
244467
  const extraArgs = dashIndex !== -1 ? process.argv.slice(dashIndex + 1) : [];
244457
244468
  await runCommand(() => execAction(script, options8, extraArgs), { requireAuth: true }, context);
@@ -248813,4 +248824,4 @@ export {
248813
248824
  CLIExitError
248814
248825
  };
248815
248826
 
248816
- //# debugId=D8A2BAE36472B6C264756E2164756E21
248827
+ //# debugId=B38C305D7E2A64DC64756E2164756E21