@base44-preview/cli 0.1.4-pr.567.a56c290 → 0.1.5-pr.568.1f028a6

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
@@ -236069,11 +236069,13 @@ var CreateProjectResponseSchema = exports_external.looseObject({
236069
236069
  var AppDetailSchema = exports_external.looseObject({
236070
236070
  id: exports_external.string(),
236071
236071
  name: exports_external.string().optional(),
236072
- organization_id: exports_external.string().nullish()
236072
+ organization_id: exports_external.string().nullish(),
236073
+ is_managed_source_code: exports_external.boolean().optional()
236073
236074
  }).transform((data) => ({
236074
236075
  id: data.id,
236075
236076
  name: data.name,
236076
- organizationId: data.organization_id ?? undefined
236077
+ organizationId: data.organization_id ?? undefined,
236078
+ isManagedSourceCode: data.is_managed_source_code
236077
236079
  }));
236078
236080
  var ProjectSchema = exports_external.object({
236079
236081
  id: exports_external.string(),
@@ -241894,14 +241896,15 @@ async function setAppVisibility(visibility) {
241894
241896
  throw await ApiError.fromHttpError(error48, "updating app visibility");
241895
241897
  }
241896
241898
  }
241897
- async function listProjects() {
241899
+ async function listProjects(options = {}) {
241898
241900
  let response;
241899
241901
  try {
241900
241902
  response = await base44Client.get("api/apps", {
241901
241903
  searchParams: {
241902
241904
  sort: "-updated_date",
241903
241905
  fields: "id,name,user_description,is_managed_source_code",
241904
- limit: 50
241906
+ limit: 50,
241907
+ ...options.workspaceId ? { workspace_id: options.workspaceId } : {}
241905
241908
  }
241906
241909
  });
241907
241910
  } catch (error48) {
@@ -241917,7 +241920,9 @@ async function getApp(appId) {
241917
241920
  let response;
241918
241921
  try {
241919
241922
  response = await base44Client.get(`api/apps/${appId}`, {
241920
- searchParams: { fields: "id,name,organization_id" }
241923
+ searchParams: {
241924
+ fields: "id,name,organization_id,is_managed_source_code"
241925
+ }
241921
241926
  });
241922
241927
  } catch (error48) {
241923
241928
  throw await ApiError.fromHttpError(error48, "fetching app");
@@ -244011,7 +244016,7 @@ import { join as join11 } from "node:path";
244011
244016
  // package.json
244012
244017
  var package_default = {
244013
244018
  name: "base44",
244014
- version: "0.1.4",
244019
+ version: "0.1.5",
244015
244020
  description: "Base44 CLI - Unified interface for managing Base44 applications",
244016
244021
  type: "module",
244017
244022
  bin: {
@@ -253466,7 +253471,7 @@ function workspaceLabel(workspace2) {
253466
253471
  const suffix = workspace2.isPersonal ? "personal" : workspace2.userRole ?? "member";
253467
253472
  return `${workspace2.name} (${suffix})`;
253468
253473
  }
253469
- async function resolveWorkspaceId(ctx, flagWorkspaceId, isInteractive) {
253474
+ async function resolveWorkspaceId(ctx, flagWorkspaceId, isInteractive, options = {}) {
253470
253475
  if (flagWorkspaceId) {
253471
253476
  return flagWorkspaceId;
253472
253477
  }
@@ -253477,13 +253482,13 @@ async function resolveWorkspaceId(ctx, flagWorkspaceId, isInteractive) {
253477
253482
  if (workspaces.length <= 1) {
253478
253483
  return;
253479
253484
  }
253480
- const options = workspaces.map((w) => ({
253485
+ const promptOptions = workspaces.map((w) => ({
253481
253486
  value: w.id,
253482
253487
  label: workspaceLabel(w)
253483
253488
  }));
253484
253489
  const selected = await Je({
253485
- message: "Which workspace should this app belong to?",
253486
- options,
253490
+ message: options.promptMessage ?? "Which workspace should this app belong to?",
253491
+ options: promptOptions,
253487
253492
  initialValue: workspaces[0].id
253488
253493
  });
253489
253494
  if (Ct(selected)) {
@@ -253816,6 +253821,40 @@ async function promptForExistingProject(linkableProjects) {
253816
253821
  }
253817
253822
  return selectedProject;
253818
253823
  }
253824
+ async function resolveExplicitAppId(ctx, appId) {
253825
+ const app = await ctx.runTask("Validating app...", () => getApp(appId), {
253826
+ errorMessage: "Could not validate app"
253827
+ }).catch((error48) => {
253828
+ if (error48 instanceof ApiError && (error48.statusCode === 404 || error48.statusCode === 403)) {
253829
+ throw new InvalidInputError(`App "${appId}" not found, or you don't have access to it.`, {
253830
+ hints: [
253831
+ { message: "Check the app ID is correct" },
253832
+ {
253833
+ message: "Run 'base44 link' without --app-id to browse apps by workspace"
253834
+ }
253835
+ ]
253836
+ });
253837
+ }
253838
+ throw error48;
253839
+ });
253840
+ if (app.isManagedSourceCode) {
253841
+ throw new InvalidInputError(`App "${appId}" is a managed-source app and can't be linked with the CLI.`);
253842
+ }
253843
+ return appId;
253844
+ }
253845
+ async function chooseProjectInteractively(ctx, options) {
253846
+ const workspaceId = await resolveWorkspaceId(ctx, options.workspace ?? options.org, !ctx.isNonInteractive, { promptMessage: "Which workspace is the app in?" });
253847
+ const projects = await ctx.runTask("Fetching projects...", () => listProjects({ workspaceId }), {
253848
+ successMessage: "Projects fetched",
253849
+ errorMessage: "Failed to fetch projects"
253850
+ });
253851
+ const linkableProjects = projects.filter((p) => p.isManagedSourceCode !== true);
253852
+ if (!linkableProjects.length) {
253853
+ return;
253854
+ }
253855
+ const selectedProject = await promptForExistingProject(linkableProjects);
253856
+ return selectedProject.id;
253857
+ }
253819
253858
  async function link(ctx, options, command2) {
253820
253859
  const { log, runTask: runTask2, isNonInteractive } = ctx;
253821
253860
  const appId = readExplicitAppId(command2).value;
@@ -253839,32 +253878,10 @@ async function link(ctx, options, command2) {
253839
253878
  let finalAppId;
253840
253879
  const action = appId ? "choose" : options.create ? "create" : await promptForLinkAction();
253841
253880
  if (action === "choose") {
253842
- const projects = await runTask2("Fetching projects...", async () => listProjects(), {
253843
- successMessage: "Projects fetched",
253844
- errorMessage: "Failed to fetch projects"
253845
- });
253846
- const linkableProjects = projects.filter((p) => p.isManagedSourceCode !== true);
253847
- if (!linkableProjects.length) {
253881
+ const linkedAppId = appId ? await resolveExplicitAppId(ctx, appId) : await chooseProjectInteractively(ctx, options);
253882
+ if (!linkedAppId) {
253848
253883
  return { outroMessage: "No projects available for linking" };
253849
253884
  }
253850
- let linkedAppId;
253851
- if (appId) {
253852
- const project2 = linkableProjects.find((p) => p.id === appId);
253853
- if (!project2) {
253854
- throw new InvalidInputError(`App with ID "${appId}" not found or not available for linking.`, {
253855
- hints: [
253856
- { message: "Check the app ID is correct" },
253857
- {
253858
- message: "Use 'base44 link' without --app-id to see available projects"
253859
- }
253860
- ]
253861
- });
253862
- }
253863
- linkedAppId = appId;
253864
- } else {
253865
- const selectedProject = await promptForExistingProject(linkableProjects);
253866
- linkedAppId = selectedProject.id;
253867
- }
253868
253885
  await runTask2("Linking project...", async () => {
253869
253886
  await writeAppConfig(projectRoot.root, linkedAppId);
253870
253887
  setAppContext({ id: linkedAppId, projectRoot: projectRoot.root });
@@ -253893,7 +253910,7 @@ async function link(ctx, options, command2) {
253893
253910
  function getLinkCommand() {
253894
253911
  return new Base44Command("link", {
253895
253912
  requireAppContext: false
253896
- }).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").option("-w, --workspace <id>", "Workspace (organization) ID to create the app in when using --create (defaults to your personal workspace)").addOption(new Option("--org <id>", "Alias for --workspace").hideHelp()).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);
253913
+ }).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").option("-w, --workspace <id>", "Workspace (organization) ID to scope the app picker to (or create the app in, with --create). Defaults to your personal workspace").addOption(new Option("--org <id>", "Alias for --workspace").hideHelp()).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);
253897
253914
  }
253898
253915
 
253899
253916
  // src/cli/commands/project/logs.ts
@@ -262934,4 +262951,4 @@ export {
262934
262951
  CLIExitError
262935
262952
  };
262936
262953
 
262937
- //# debugId=A13BE6B0A6A9F5CD64756E2164756E21
262954
+ //# debugId=66DC83EDAF91D49064756E2164756E21