@base44-preview/cli 0.0.55-pr.540.e661f33 → 0.0.55-pr.541.427af2d

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