@base44-preview/cli 0.1.3-pr.567.b7c491a → 0.1.3-pr.568.68320bd

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");
@@ -251561,6 +251566,10 @@ async function listWorkspaces() {
251561
251566
  isPersonal: index === 0
251562
251567
  }));
251563
251568
  }
251569
+ async function getWorkspace(id) {
251570
+ const workspaces = await listWorkspaces();
251571
+ return workspaces.find((w) => w.id === id);
251572
+ }
251564
251573
  async function moveAppToWorkspace(appId, targetWorkspaceId, options = {}) {
251565
251574
  let response;
251566
251575
  try {
@@ -253490,6 +253499,40 @@ async function resolveWorkspaceId(ctx, flagWorkspaceId, isInteractive) {
253490
253499
  }
253491
253500
  return selected;
253492
253501
  }
253502
+ async function resolveListingWorkspaceId(ctx, flagWorkspaceId, isInteractive) {
253503
+ if (flagWorkspaceId) {
253504
+ const workspaces2 = await fetchWorkspaces(ctx);
253505
+ const match = workspaces2.find((w) => w.id === flagWorkspaceId);
253506
+ if (!match) {
253507
+ throw new InvalidInputError(`Workspace "${flagWorkspaceId}" not found, or you are not a member of it.`, {
253508
+ hints: [
253509
+ { message: "Run 'base44 workspace list' to see your workspaces" }
253510
+ ]
253511
+ });
253512
+ }
253513
+ return match.id;
253514
+ }
253515
+ if (!isInteractive) {
253516
+ return;
253517
+ }
253518
+ const workspaces = await fetchWorkspaces(ctx);
253519
+ if (workspaces.length <= 1) {
253520
+ return;
253521
+ }
253522
+ const options = workspaces.map((w) => ({
253523
+ value: w.id,
253524
+ label: workspaceLabel(w)
253525
+ }));
253526
+ const selected = await Je({
253527
+ message: "Which workspace is the app in?",
253528
+ options,
253529
+ initialValue: workspaces[0].id
253530
+ });
253531
+ if (Ct(selected)) {
253532
+ onPromptCancel();
253533
+ }
253534
+ return selected;
253535
+ }
253493
253536
 
253494
253537
  // src/cli/commands/project/create.ts
253495
253538
  function validateCreateOptions(command2) {
@@ -253815,6 +253858,40 @@ async function promptForExistingProject(linkableProjects) {
253815
253858
  }
253816
253859
  return selectedProject;
253817
253860
  }
253861
+ async function resolveExplicitAppId(ctx, appId) {
253862
+ const app = await ctx.runTask("Validating app...", () => getApp(appId), {
253863
+ errorMessage: "Could not validate app"
253864
+ }).catch((error48) => {
253865
+ if (error48 instanceof ApiError && (error48.statusCode === 404 || error48.statusCode === 403)) {
253866
+ throw new InvalidInputError(`App "${appId}" not found, or you don't have access to it.`, {
253867
+ hints: [
253868
+ { message: "Check the app ID is correct" },
253869
+ {
253870
+ message: "Run 'base44 link' without --app-id to browse apps by workspace"
253871
+ }
253872
+ ]
253873
+ });
253874
+ }
253875
+ throw error48;
253876
+ });
253877
+ if (app.isManagedSourceCode) {
253878
+ throw new InvalidInputError(`App "${appId}" is a managed-source app and can't be linked with the CLI.`);
253879
+ }
253880
+ return appId;
253881
+ }
253882
+ async function chooseProjectInteractively(ctx, options) {
253883
+ const workspaceId = await resolveListingWorkspaceId(ctx, options.workspace ?? options.org, !ctx.isNonInteractive);
253884
+ const projects = await ctx.runTask("Fetching projects...", () => listProjects({ workspaceId }), {
253885
+ successMessage: "Projects fetched",
253886
+ errorMessage: "Failed to fetch projects"
253887
+ });
253888
+ const linkableProjects = projects.filter((p) => p.isManagedSourceCode !== true);
253889
+ if (!linkableProjects.length) {
253890
+ return;
253891
+ }
253892
+ const selectedProject = await promptForExistingProject(linkableProjects);
253893
+ return selectedProject.id;
253894
+ }
253818
253895
  async function link(ctx, options, command2) {
253819
253896
  const { log, runTask: runTask2, isNonInteractive } = ctx;
253820
253897
  const appId = readExplicitAppId(command2).value;
@@ -253838,32 +253915,10 @@ async function link(ctx, options, command2) {
253838
253915
  let finalAppId;
253839
253916
  const action = appId ? "choose" : options.create ? "create" : await promptForLinkAction();
253840
253917
  if (action === "choose") {
253841
- const projects = await runTask2("Fetching projects...", async () => listProjects(), {
253842
- successMessage: "Projects fetched",
253843
- errorMessage: "Failed to fetch projects"
253844
- });
253845
- const linkableProjects = projects.filter((p) => p.isManagedSourceCode !== true);
253846
- if (!linkableProjects.length) {
253918
+ const linkedAppId = appId ? await resolveExplicitAppId(ctx, appId) : await chooseProjectInteractively(ctx, options);
253919
+ if (!linkedAppId) {
253847
253920
  return { outroMessage: "No projects available for linking" };
253848
253921
  }
253849
- let linkedAppId;
253850
- if (appId) {
253851
- const project2 = linkableProjects.find((p) => p.id === appId);
253852
- if (!project2) {
253853
- throw new InvalidInputError(`App with ID "${appId}" not found or not available for linking.`, {
253854
- hints: [
253855
- { message: "Check the app ID is correct" },
253856
- {
253857
- message: "Use 'base44 link' without --app-id to see available projects"
253858
- }
253859
- ]
253860
- });
253861
- }
253862
- linkedAppId = appId;
253863
- } else {
253864
- const selectedProject = await promptForExistingProject(linkableProjects);
253865
- linkedAppId = selectedProject.id;
253866
- }
253867
253922
  await runTask2("Linking project...", async () => {
253868
253923
  await writeAppConfig(projectRoot.root, linkedAppId);
253869
253924
  setAppContext({ id: linkedAppId, projectRoot: projectRoot.root });
@@ -253892,7 +253947,7 @@ async function link(ctx, options, command2) {
253892
253947
  function getLinkCommand() {
253893
253948
  return new Base44Command("link", {
253894
253949
  requireAppContext: false
253895
- }).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);
253950
+ }).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);
253896
253951
  }
253897
253952
 
253898
253953
  // src/cli/commands/project/logs.ts
@@ -254770,16 +254825,47 @@ function workspaceTag(workspace2) {
254770
254825
  return workspace2.isPersonal ? `personal, ${role}` : role;
254771
254826
  }
254772
254827
 
254828
+ // src/cli/commands/workspace/get.ts
254829
+ async function getWorkspaceAction({ runTask: runTask2, log, jsonMode }, workspaceId) {
254830
+ const workspace2 = await runTask2("Fetching workspace...", () => getWorkspace(workspaceId), { errorMessage: "Failed to fetch workspace" });
254831
+ if (!workspace2) {
254832
+ throw new InvalidInputError(`Workspace "${workspaceId}" not found, or you are not a member of it.`, {
254833
+ hints: [
254834
+ { message: "Run 'base44 workspace list' to see your workspaces" }
254835
+ ]
254836
+ });
254837
+ }
254838
+ if (jsonMode) {
254839
+ return {
254840
+ outroMessage: workspace2.name,
254841
+ stdout: toJsonStdout2(workspace2)
254842
+ };
254843
+ }
254844
+ log.message(` ${theme.styles.bold(workspace2.name)} ${theme.styles.dim(`[${workspaceTag(workspace2)}]`)}
254845
+ ${theme.styles.dim(workspace2.id)}${workspace2.subscriptionTier ? theme.styles.dim(`
254846
+ tier: ${workspace2.subscriptionTier}`) : ""}`);
254847
+ return { outroMessage: workspace2.name };
254848
+ }
254849
+ function getWorkspaceGetCommand() {
254850
+ return new Base44Command("get", { requireAppContext: false }).description("Show details for a single workspace by ID").argument("<workspace-id>", "Workspace (organization) ID").action(getWorkspaceAction);
254851
+ }
254852
+
254773
254853
  // src/cli/commands/workspace/list.ts
254774
- async function listWorkspacesAction({
254775
- log,
254776
- runTask: runTask2,
254777
- jsonMode
254778
- }) {
254779
- const workspaces = await runTask2("Fetching workspaces...", () => listWorkspaces(), { errorMessage: "Failed to fetch workspaces" });
254854
+ function pluralize2(n5) {
254855
+ return `${n5} workspace${n5 !== 1 ? "s" : ""}`;
254856
+ }
254857
+ async function listWorkspacesAction({ log, runTask: runTask2, jsonMode }, options8) {
254858
+ let workspaces = await runTask2("Fetching workspaces...", () => listWorkspaces(), { errorMessage: "Failed to fetch workspaces" });
254859
+ if (options8.canCreate) {
254860
+ workspaces = workspaces.filter((w8) => canCreateAppsInWorkspace(w8.userRole));
254861
+ }
254862
+ if (options8.role) {
254863
+ const role = options8.role.toLowerCase();
254864
+ workspaces = workspaces.filter((w8) => w8.userRole?.toLowerCase() === role);
254865
+ }
254780
254866
  if (jsonMode) {
254781
254867
  return {
254782
- outroMessage: `${workspaces.length} workspace${workspaces.length !== 1 ? "s" : ""}`,
254868
+ outroMessage: pluralize2(workspaces.length),
254783
254869
  stdout: toJsonStdout2(workspaces)
254784
254870
  };
254785
254871
  }
@@ -254787,12 +254873,10 @@ async function listWorkspacesAction({
254787
254873
  log.message(` ${theme.styles.bold(workspace2.name)} ${theme.styles.dim(`[${workspaceTag(workspace2)}]`)}
254788
254874
  ${theme.styles.dim(workspace2.id)}`);
254789
254875
  }
254790
- return {
254791
- outroMessage: `${workspaces.length} workspace${workspaces.length !== 1 ? "s" : ""}`
254792
- };
254876
+ return { outroMessage: pluralize2(workspaces.length) };
254793
254877
  }
254794
254878
  function getWorkspaceListCommand() {
254795
- return new Base44Command("list", { requireAppContext: false }).description("List the workspaces you belong to").action(listWorkspacesAction);
254879
+ return new Base44Command("list", { requireAppContext: false }).description("List the workspaces you belong to").option("--can-create", "Only workspaces you can create or move apps into (owner/admin/editor)").option("--role <role>", "Only workspaces where your role matches (owner, admin, editor, viewer)").action(listWorkspacesAction);
254796
254880
  }
254797
254881
 
254798
254882
  // src/cli/commands/workspace/move.ts
@@ -254888,7 +254972,7 @@ Examples:
254888
254972
 
254889
254973
  // src/cli/commands/workspace/index.ts
254890
254974
  function getWorkspaceCommand() {
254891
- return new Command("workspace").description("List workspaces and move apps between them").addCommand(getWorkspaceListCommand()).addCommand(getWorkspaceMoveCommand());
254975
+ return new Command("workspace").description("List workspaces, inspect one, and move apps between them").addCommand(getWorkspaceListCommand()).addCommand(getWorkspaceGetCommand()).addCommand(getWorkspaceMoveCommand());
254892
254976
  }
254893
254977
 
254894
254978
  // src/cli/dev/dev-server/main.ts
@@ -262921,4 +263005,4 @@ export {
262921
263005
  CLIExitError
262922
263006
  };
262923
263007
 
262924
- //# debugId=FBAB9A49478F781B64756E2164756E21
263008
+ //# debugId=F3935F096F24A1DE64756E2164756E21