@base44-preview/cli 0.0.55-pr.540.d15d29c → 0.0.55-pr.541.052bfa5

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
@@ -218285,6 +218285,7 @@ var PROJECT_CONFIG_PATTERNS = [
218285
218285
  `${PROJECT_SUBDIR}/config.${CONFIG_FILE_EXTENSION_GLOB}`,
218286
218286
  `config.${CONFIG_FILE_EXTENSION_GLOB}`
218287
218287
  ];
218288
+ var BASE44_APP_ID_ENV_VAR = "BASE44_APP_ID";
218288
218289
  var TYPES_OUTPUT_SUBDIR = ".types";
218289
218290
  var TYPES_FILENAME = "types.d.ts";
218290
218291
  var AUTH_CLIENT_ID = "base44_cli";
@@ -233980,7 +233981,7 @@ async function parseEnvFile(filePath) {
233980
233981
  }
233981
233982
  var STRIPE_ENV_PREFIX = "BASE44_PROJECTS_";
233982
233983
  var BASE44_ENV_KEYS = [
233983
- "BASE44_APP_ID",
233984
+ BASE44_APP_ID_ENV_VAR,
233984
233985
  "BASE44_ACCESS_TOKEN",
233985
233986
  "BASE44_REFRESH_TOKEN",
233986
233987
  "BASE44_API_URL"
@@ -235749,12 +235750,11 @@ var theme = {
235749
235750
  if (hints.length === 0) {
235750
235751
  return null;
235751
235752
  }
235752
- const hintLines = hints.flatMap((hint) => {
235753
- const lines = [` ${hint.message}`];
235753
+ const hintLines = hints.map((hint) => {
235754
235754
  if (hint.command) {
235755
- lines.push(` Run: ${hint.command}`);
235755
+ return ` Run: ${hint.command}`;
235756
235756
  }
235757
- return lines;
235757
+ return ` ${hint.message}`;
235758
235758
  });
235759
235759
  return ["[Agent Hints]", ...hintLines].join(`
235760
235760
  `);
@@ -241695,18 +241695,35 @@ function loadFromTestOverrides() {
241695
241695
  }
241696
241696
  return null;
241697
241697
  }
241698
- async function initAppContext() {
241698
+ async function initAppContext(options = {}) {
241699
241699
  const testConfig = loadFromTestOverrides();
241700
241700
  if (testConfig) {
241701
241701
  cache2 = testConfig;
241702
241702
  return cache2;
241703
241703
  }
241704
+ const projectRoot = findProjectRoot();
241705
+ if (options.appId !== undefined) {
241706
+ const id = options.appId.trim();
241707
+ if (!id) {
241708
+ throw new InvalidInputError("App id cannot be empty.");
241709
+ }
241710
+ cache2 = { id, projectRoot: projectRoot?.root };
241711
+ return cache2;
241712
+ }
241704
241713
  if (cache2) {
241705
241714
  return cache2;
241706
241715
  }
241707
- const projectRoot = findProjectRoot();
241708
241716
  if (!projectRoot) {
241709
- throw new ConfigNotFoundError("No Base44 project found. Run this command from a project directory with a config.jsonc file.");
241717
+ throw new ConfigNotFoundError(`No Base44 app ID found. Pass --app-id, set ${BASE44_APP_ID_ENV_VAR}, or run this command from a linked project with base44/.app.jsonc.`, {
241718
+ hints: [
241719
+ { message: "Pass an app ID explicitly with --app-id <id>" },
241720
+ { message: `Set ${BASE44_APP_ID_ENV_VAR} in your environment` },
241721
+ {
241722
+ message: "Run from a linked Base44 project with base44/.app.jsonc, or run 'base44 link'",
241723
+ command: "base44 link"
241724
+ }
241725
+ ]
241726
+ });
241710
241727
  }
241711
241728
  const config3 = await readAppConfig(projectRoot.root);
241712
241729
  const appConfigPath = await findAppConfigPath(projectRoot.root);
@@ -241844,8 +241861,8 @@ async function getAppUserToken() {
241844
241861
  throw await ApiError.fromHttpError(error48, "exchanging platform token for app user token");
241845
241862
  }
241846
241863
  }
241847
- async function getSiteUrl(projectId) {
241848
- const id = projectId ?? getAppContext().id;
241864
+ async function getSiteUrl() {
241865
+ const id = getAppContext().id;
241849
241866
  let response;
241850
241867
  try {
241851
241868
  response = await base44Client.get(`api/apps/platform/${id}/published-url`);
@@ -244434,8 +244451,8 @@ async function ensureAuth(ctx) {
244434
244451
  });
244435
244452
  } catch {}
244436
244453
  }
244437
- async function ensureAppContext(ctx) {
244438
- const appContext = await initAppContext();
244454
+ async function ensureAppContext(ctx, options = {}) {
244455
+ const appContext = await initAppContext(options);
244439
244456
  ctx.app = appContext;
244440
244457
  ctx.errorReporter.setContext({ appId: appContext.id });
244441
244458
  }
@@ -251101,7 +251118,8 @@ class Base44Command extends Command {
251101
251118
  await ensureAuth(this.context);
251102
251119
  }
251103
251120
  if (this._commandOptions.requireAppContext) {
251104
- await ensureAppContext(this.context);
251121
+ const { appId } = this.optsWithGlobals();
251122
+ await ensureAppContext(this.context, { appId });
251105
251123
  }
251106
251124
  const result = await fn(this.context, ...args) ?? {};
251107
251125
  if (!quiet) {
@@ -253070,7 +253088,11 @@ function printProjectSummary({ name: name2, dashboardUrl, appUrl }, log) {
253070
253088
  }
253071
253089
 
253072
253090
  // src/cli/commands/project/create.ts
253073
- function validateNonInteractiveFlags(command2) {
253091
+ function validateCreateOptions(command2) {
253092
+ const { appId } = command2.optsWithGlobals();
253093
+ if (appId !== undefined) {
253094
+ command2.error(`base44 create cannot be used with --app-id or ${BASE44_APP_ID_ENV_VAR}.`);
253095
+ }
253074
253096
  const { path: path17 } = command2.opts();
253075
253097
  if (path17 && !command2.args.length) {
253076
253098
  command2.error("--path requires a project name argument. Usage: base44 create <name> --path <path>");
@@ -253187,7 +253209,7 @@ function getCreateCommand() {
253187
253209
  Examples:
253188
253210
  $ base44 create my-app Creates a base44 project at ./my-app
253189
253211
  $ base44 create my-todo-app --template backend-and-client Creates a base44 backend-and-client project at ./my-todo-app
253190
- $ base44 create my-app --path ./projects/my-app --deploy Creates a base44 project at ./project/my-app and deploys it`).hook("preAction", validateNonInteractiveFlags).action(createAction);
253212
+ $ base44 create my-app --path ./projects/my-app --deploy Creates a base44 project at ./project/my-app and deploys it`).hook("preAction", validateCreateOptions).action(createAction);
253191
253213
  }
253192
253214
 
253193
253215
  // src/cli/commands/project/deploy.ts
@@ -253283,11 +253305,32 @@ function printStripeResult(r, log) {
253283
253305
  log.info(` Connectors dashboard: ${theme.colors.links(getConnectorsUrl())}`);
253284
253306
  }
253285
253307
 
253308
+ // src/cli/commands/project/app-id-options.ts
253309
+ function readExplicitAppId(command2) {
253310
+ const { appId } = command2.optsWithGlobals();
253311
+ const { projectId } = command2.opts();
253312
+ const explicitAppId = command2.getOptionValueSourceWithGlobals("appId") === "cli" ? appId : undefined;
253313
+ const legacyProjectId = command2.getOptionValueSource("projectId") === "cli" ? projectId : undefined;
253314
+ return {
253315
+ appId: explicitAppId,
253316
+ legacyProjectId,
253317
+ value: explicitAppId ?? legacyProjectId
253318
+ };
253319
+ }
253320
+
253286
253321
  // src/cli/commands/project/link.ts
253287
- function validateNonInteractiveFlags2(command2) {
253288
- const { create: create4, name: name2, projectId } = command2.opts();
253289
- if (create4 && projectId) {
253290
- command2.error("--create and --projectId cannot be used together");
253322
+ function validateNonInteractiveFlags(command2) {
253323
+ const { create: create4, name: name2 } = command2.opts();
253324
+ const {
253325
+ appId,
253326
+ legacyProjectId,
253327
+ value: selectedAppId
253328
+ } = readExplicitAppId(command2);
253329
+ if (appId && legacyProjectId) {
253330
+ command2.error("--app-id and --project-id cannot be used together");
253331
+ }
253332
+ if (create4 && selectedAppId) {
253333
+ command2.error("--create and --app-id cannot be used together");
253291
253334
  }
253292
253335
  if (create4 && !name2) {
253293
253336
  command2.error("--name is required when using --create");
@@ -253356,11 +253399,12 @@ async function promptForExistingProject(linkableProjects) {
253356
253399
  }
253357
253400
  return selectedProject;
253358
253401
  }
253359
- async function link(ctx, options) {
253402
+ async function link(ctx, options, command2) {
253360
253403
  const { log, runTask: runTask2, isNonInteractive } = ctx;
253361
- const skipPrompts = !!options.create || !!options.projectId;
253404
+ const appId = readExplicitAppId(command2).value;
253405
+ const skipPrompts = !!options.create || !!appId;
253362
253406
  if (!skipPrompts && isNonInteractive) {
253363
- throw new InvalidInputError("--create with --name, or --projectId, is required in non-interactive mode");
253407
+ throw new InvalidInputError("--create with --name, or --app-id, is required in non-interactive mode");
253364
253408
  }
253365
253409
  const projectRoot = findProjectRoot();
253366
253410
  if (!projectRoot) {
@@ -253375,8 +253419,8 @@ async function link(ctx, options) {
253375
253419
  ]
253376
253420
  });
253377
253421
  }
253378
- let finalProjectId;
253379
- const action = options.projectId ? "choose" : options.create ? "create" : await promptForLinkAction();
253422
+ let finalAppId;
253423
+ const action = appId ? "choose" : options.create ? "create" : await promptForLinkAction();
253380
253424
  if (action === "choose") {
253381
253425
  const projects = await runTask2("Fetching projects...", async () => listProjects(), {
253382
253426
  successMessage: "Projects fetched",
@@ -253386,32 +253430,32 @@ async function link(ctx, options) {
253386
253430
  if (!linkableProjects.length) {
253387
253431
  return { outroMessage: "No projects available for linking" };
253388
253432
  }
253389
- let projectId;
253390
- if (options.projectId) {
253391
- const project2 = linkableProjects.find((p) => p.id === options.projectId);
253433
+ let linkedAppId;
253434
+ if (appId) {
253435
+ const project2 = linkableProjects.find((p) => p.id === appId);
253392
253436
  if (!project2) {
253393
- throw new InvalidInputError(`Project with ID "${options.projectId}" not found or not available for linking.`, {
253437
+ throw new InvalidInputError(`App with ID "${appId}" not found or not available for linking.`, {
253394
253438
  hints: [
253395
- { message: "Check the project ID is correct" },
253439
+ { message: "Check the app ID is correct" },
253396
253440
  {
253397
- message: "Use 'base44 link' without --projectId to see available projects"
253441
+ message: "Use 'base44 link' without --app-id to see available projects"
253398
253442
  }
253399
253443
  ]
253400
253444
  });
253401
253445
  }
253402
- projectId = options.projectId;
253446
+ linkedAppId = appId;
253403
253447
  } else {
253404
253448
  const selectedProject = await promptForExistingProject(linkableProjects);
253405
- projectId = selectedProject.id;
253449
+ linkedAppId = selectedProject.id;
253406
253450
  }
253407
253451
  await runTask2("Linking project...", async () => {
253408
- await writeAppConfig(projectRoot.root, projectId);
253409
- setAppContext({ id: projectId, projectRoot: projectRoot.root });
253452
+ await writeAppConfig(projectRoot.root, linkedAppId);
253453
+ setAppContext({ id: linkedAppId, projectRoot: projectRoot.root });
253410
253454
  }, {
253411
253455
  successMessage: "Project linked successfully",
253412
253456
  errorMessage: "Failed to link project"
253413
253457
  });
253414
- finalProjectId = projectId;
253458
+ finalAppId = linkedAppId;
253415
253459
  }
253416
253460
  if (action === "create") {
253417
253461
  const { name: name2, description } = options.create ? { name: options.name.trim(), description: options.description?.trim() } : await promptForNewProjectDetails();
@@ -253423,13 +253467,15 @@ async function link(ctx, options) {
253423
253467
  });
253424
253468
  await writeAppConfig(projectRoot.root, projectId);
253425
253469
  setAppContext({ id: projectId, projectRoot: projectRoot.root });
253426
- finalProjectId = projectId;
253470
+ finalAppId = projectId;
253427
253471
  }
253428
- log.message(`${theme.styles.header("Dashboard")}: ${theme.colors.links(getDashboardUrl(finalProjectId))}`);
253472
+ log.message(`${theme.styles.header("Dashboard")}: ${theme.colors.links(getDashboardUrl(finalAppId))}`);
253429
253473
  return { outroMessage: "Project linked" };
253430
253474
  }
253431
253475
  function getLinkCommand() {
253432
- return new Base44Command("link", { requireAppContext: false }).description("Link a local project to a Base44 project (create new or link existing)").option("-c, --create", "Create a new project (skip selection prompt)").option("-n, --name <name>", "Project name (required when --create is used)").option("-d, --description <description>", "Project description").option("-p, --projectId <id>", "Project ID to link to an existing project (skips selection prompt)").hook("preAction", validateNonInteractiveFlags2).action(link);
253476
+ return new Base44Command("link", {
253477
+ requireAppContext: false
253478
+ }).description("Link a local project to a Base44 project (create new or link existing)").configureHelp({ showGlobalOptions: true }).option("-c, --create", "Create a new project (skip selection prompt)").option("-n, --name <name>", "Project name (required when --create is used)").option("-d, --description <description>", "Project description").addOption(new Option("-p, --project-id <id>", "Project ID to link to an existing project").hideHelp()).addOption(new Option("--projectId <id>", "Project ID to link to an existing project").hideHelp()).hook("preAction", validateNonInteractiveFlags).action(link);
253433
253479
  }
253434
253480
 
253435
253481
  // src/cli/commands/project/logs.ts
@@ -253519,8 +253565,12 @@ async function fetchLogsForFunctions(functionNames, options, availableFunctionNa
253519
253565
  }
253520
253566
  return allEntries;
253521
253567
  }
253522
- async function getAllFunctionNames() {
253523
- const { functions } = await readProjectConfig();
253568
+ async function getProjectFunctionNames(projectRoot) {
253569
+ const { functions } = await readProjectConfig(projectRoot);
253570
+ return functions.map((fn) => fn.name);
253571
+ }
253572
+ async function getRemoteFunctionNames() {
253573
+ const { functions } = await listDeployedFunctions();
253524
253574
  return functions.map((fn) => fn.name);
253525
253575
  }
253526
253576
  function validateLimit(limit) {
@@ -253531,15 +253581,18 @@ function validateLimit(limit) {
253531
253581
  throw new InvalidInputError(`Invalid limit: "${limit}". Must be a number between 1 and 1000.`);
253532
253582
  }
253533
253583
  }
253534
- async function logsAction(_ctx, options) {
253584
+ async function logsAction(ctx, options) {
253535
253585
  validateLimit(options.limit);
253536
253586
  const specifiedFunctions = parseFunctionNames(options.function);
253537
- const allProjectFunctions = await getAllFunctionNames();
253538
- const functionNames = specifiedFunctions.length > 0 ? specifiedFunctions : allProjectFunctions;
253587
+ const localProjectRoot = ctx.app?.projectRoot;
253588
+ const availableFunctionNames = localProjectRoot ? await getProjectFunctionNames(localProjectRoot) : await getRemoteFunctionNames();
253589
+ const functionNames = specifiedFunctions.length > 0 ? specifiedFunctions : availableFunctionNames;
253539
253590
  if (functionNames.length === 0) {
253540
- return { outroMessage: "No functions found in this project." };
253591
+ return {
253592
+ outroMessage: localProjectRoot ? "No functions found in this project." : "No functions found in this app."
253593
+ };
253541
253594
  }
253542
- let entries = await fetchLogsForFunctions(functionNames, options, allProjectFunctions);
253595
+ let entries = await fetchLogsForFunctions(functionNames, options, availableFunctionNames);
253543
253596
  const limit = options.limit ? Number.parseInt(options.limit, 10) : undefined;
253544
253597
  if (limit !== undefined && entries.length > limit) {
253545
253598
  entries = entries.slice(0, limit);
@@ -253555,17 +253608,20 @@ function getLogsCommand() {
253555
253608
  // src/cli/commands/project/scaffold.ts
253556
253609
  import { basename as basename5, resolve as resolve6 } from "node:path";
253557
253610
  function resolveAppId(options) {
253558
- const appId = options.appId ?? process.env.BASE44_APP_ID;
253611
+ const appId = options.appId;
253559
253612
  if (!appId) {
253560
253613
  throw new InvalidInputError("No app ID found. `base44 scaffold` sets up a local project for an existing Base44 app.", {
253561
- hints: [{ message: "Pass it explicitly with --app-id <id>" }]
253614
+ hints: [
253615
+ { message: "Pass it explicitly with --app-id <id>" },
253616
+ { message: `Set ${BASE44_APP_ID_ENV_VAR} in your environment` }
253617
+ ]
253562
253618
  });
253563
253619
  }
253564
253620
  return appId;
253565
253621
  }
253566
- async function scaffoldAction(ctx, name2, options) {
253622
+ async function scaffoldAction(ctx, name2, options, command2) {
253567
253623
  const { log, runTask: runTask2 } = ctx;
253568
- const appId = resolveAppId(options);
253624
+ const appId = resolveAppId(command2.optsWithGlobals());
253569
253625
  const resolvedPath = resolve6("./");
253570
253626
  const projectName = (name2 ?? basename5(resolvedPath)).trim();
253571
253627
  const template2 = await getTemplateById("backend-only");
@@ -253597,7 +253653,7 @@ function getScaffoldCommand() {
253597
253653
  return new Base44Command("scaffold", {
253598
253654
  requireAppContext: false,
253599
253655
  fullBanner: true
253600
- }).description("Scaffold a local project for an existing Base44 app").addArgument(new Argument("name", "Project name").argOptional()).option("--app-id <id>", "Existing Base44 app ID").option("--no-skills", "Skip AI agent skills installation").addHelpText("after", `
253656
+ }).description("Scaffold a local project for an existing Base44 app").addArgument(new Argument("name", "Project name").argOptional()).option("--no-skills", "Skip AI agent skills installation").addHelpText("after", `
253601
253657
  Examples:
253602
253658
  $ base44 scaffold --app-id app_123 Scaffolds the current dir for the given app
253603
253659
  $ base44 scaffold my-app --app-id app_123 Scaffolds the current dir, named "my-app"`).action(scaffoldAction);
@@ -257353,7 +257409,10 @@ function readStdin2() {
257353
257409
  process.stdin.on("error", reject);
257354
257410
  });
257355
257411
  }
257356
- async function execAction(isNonInteractive) {
257412
+ async function execAction({
257413
+ app,
257414
+ isNonInteractive
257415
+ }) {
257357
257416
  const noInputError = new InvalidInputError("No input provided. Pipe a script to stdin.", {
257358
257417
  hints: [
257359
257418
  { message: "File: cat ./script.ts | base44 exec" },
@@ -257369,7 +257428,7 @@ async function execAction(isNonInteractive) {
257369
257428
  if (!code2.trim()) {
257370
257429
  throw noInputError;
257371
257430
  }
257372
- const { exitCode } = await runScript({ appId: getAppContext().id, code: code2 });
257431
+ const { exitCode } = await runScript({ appId: app.id, code: code2 });
257373
257432
  if (exitCode !== 0) {
257374
257433
  process.exitCode = exitCode;
257375
257434
  }
@@ -257382,18 +257441,26 @@ Examples:
257382
257441
  $ cat ./script.ts | base44 exec
257383
257442
 
257384
257443
  Inline script:
257385
- $ echo "const users = await base44.entities.User.list()" | base44 exec`).action(async ({ isNonInteractive }) => {
257386
- return await execAction(isNonInteractive);
257444
+ $ echo "const users = await base44.entities.User.list()" | base44 exec`).action(async (ctx) => {
257445
+ return await execAction(ctx);
257387
257446
  });
257388
257447
  }
257389
257448
 
257390
257449
  // src/cli/commands/project/eject.ts
257391
257450
  import { resolve as resolve12 } from "node:path";
257392
257451
  var import_kebabCase2 = __toESM(require_kebabCase(), 1);
257393
- async function eject(ctx, options8) {
257452
+ async function eject(ctx, options8, command2) {
257394
257453
  const { log, runTask: runTask2, isNonInteractive } = ctx;
257395
- if (isNonInteractive && !options8.projectId) {
257396
- throw new InvalidInputError("--project-id is required in non-interactive mode");
257454
+ const {
257455
+ appId,
257456
+ legacyProjectId,
257457
+ value: selectedAppId
257458
+ } = readExplicitAppId(command2);
257459
+ if (appId && legacyProjectId) {
257460
+ throw new InvalidInputError("--app-id and --project-id cannot be used together");
257461
+ }
257462
+ if (isNonInteractive && !selectedAppId) {
257463
+ throw new InvalidInputError("--app-id is required in non-interactive mode");
257397
257464
  }
257398
257465
  if (isNonInteractive && !options8.path) {
257399
257466
  throw new InvalidInputError("--path is required in non-interactive mode");
@@ -257401,13 +257468,13 @@ async function eject(ctx, options8) {
257401
257468
  const projects = await listProjects();
257402
257469
  const ejectableProjects = projects.filter((p4) => p4.isManagedSourceCode !== false);
257403
257470
  let selectedProject;
257404
- if (options8.projectId) {
257405
- const foundProject = ejectableProjects.find((p4) => p4.id === options8.projectId);
257471
+ if (selectedAppId) {
257472
+ const foundProject = ejectableProjects.find((p4) => p4.id === selectedAppId);
257406
257473
  if (!foundProject) {
257407
- throw new InvalidInputError(`Project with ID "${options8.projectId}" not found or not ejectable`, {
257474
+ throw new InvalidInputError(`App with ID "${selectedAppId}" not found or not ejectable`, {
257408
257475
  hints: [
257409
257476
  {
257410
- message: "Run 'base44 eject' without --project-id to see available projects"
257477
+ message: "Run 'base44 eject' without --app-id to see available projects"
257411
257478
  }
257412
257479
  ]
257413
257480
  });
@@ -257483,13 +257550,15 @@ async function eject(ctx, options8) {
257483
257550
  return { outroMessage: "Your new project is set and ready to use" };
257484
257551
  }
257485
257552
  function getEjectCommand() {
257486
- return new Base44Command("eject", { requireAppContext: false }).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(eject);
257553
+ return new Base44Command("eject", {
257554
+ requireAppContext: false
257555
+ }).description("Download the code for an existing Base44 project").configureHelp({ showGlobalOptions: true }).option("-p, --path <path>", "Path where to write the project").option("-y, --yes", "Skip confirmation prompts").addOption(new Option("--project-id <id>", "Project ID to eject (skips interactive selection)").hideHelp()).action(eject);
257487
257556
  }
257488
257557
 
257489
257558
  // src/cli/program.ts
257490
257559
  function createProgram(context) {
257491
257560
  const program2 = new Command;
257492
- program2.name("base44").description("Base44 CLI - Unified interface for managing Base44 applications").version(package_default.version);
257561
+ program2.name("base44").description("Base44 CLI - Unified interface for managing Base44 applications").version(package_default.version).addOption(new Option("--app-id <id>", "Base44 app ID to use").env(BASE44_APP_ID_ENV_VAR));
257493
257562
  program2.configureHelp({
257494
257563
  sortSubcommands: true
257495
257564
  });
@@ -261763,4 +261832,4 @@ export {
261763
261832
  CLIExitError
261764
261833
  };
261765
261834
 
261766
- //# debugId=3970718286C2C0E164756E2164756E21
261835
+ //# debugId=7B666BE0D75AFE4564756E2164756E21