@base44-preview/cli 0.1.6-pr.583.b06bd3d → 0.1.7-pr.568.c08ba20

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
@@ -244912,14 +244912,15 @@ async function setAppVisibility(visibility) {
244912
244912
  throw await ApiError.fromHttpError(error48, "updating app visibility");
244913
244913
  }
244914
244914
  }
244915
- async function listProjects() {
244915
+ async function listProjects(options = {}) {
244916
244916
  let response;
244917
244917
  try {
244918
244918
  response = await base44Client.get("api/apps", {
244919
244919
  searchParams: {
244920
244920
  sort: "-updated_date",
244921
244921
  fields: "id,name,user_description,is_managed_source_code",
244922
- limit: 50
244922
+ limit: 50,
244923
+ ...options.workspaceId ? { workspace_id: options.workspaceId } : {}
244923
244924
  }
244924
244925
  });
244925
244926
  } catch (error48) {
@@ -247215,7 +247216,7 @@ import { join as join12 } from "node:path";
247215
247216
  // package.json
247216
247217
  var package_default = {
247217
247218
  name: "base44",
247218
- version: "0.1.6",
247219
+ version: "0.1.7",
247219
247220
  description: "Base44 CLI - Unified interface for managing Base44 applications",
247220
247221
  type: "module",
247221
247222
  bin: {
@@ -256750,7 +256751,7 @@ function workspaceLabel(workspace2) {
256750
256751
  const suffix = workspace2.isPersonal ? "personal" : workspace2.userRole ?? "member";
256751
256752
  return `${workspace2.name} (${suffix})`;
256752
256753
  }
256753
- async function resolveWorkspaceId(ctx, flagWorkspaceId, isInteractive) {
256754
+ async function resolveWorkspaceId(ctx, flagWorkspaceId, isInteractive, options = {}) {
256754
256755
  if (flagWorkspaceId) {
256755
256756
  return flagWorkspaceId;
256756
256757
  }
@@ -256761,13 +256762,13 @@ async function resolveWorkspaceId(ctx, flagWorkspaceId, isInteractive) {
256761
256762
  if (workspaces.length <= 1) {
256762
256763
  return;
256763
256764
  }
256764
- const options = workspaces.map((w) => ({
256765
+ const promptOptions = workspaces.map((w) => ({
256765
256766
  value: w.id,
256766
256767
  label: workspaceLabel(w)
256767
256768
  }));
256768
256769
  const selected = await Je({
256769
- message: "Which workspace should this app belong to?",
256770
- options,
256770
+ message: options.promptMessage ?? "Which workspace should this app belong to?",
256771
+ options: promptOptions,
256771
256772
  initialValue: workspaces[0].id
256772
256773
  });
256773
256774
  if (Ct(selected)) {
@@ -257100,6 +257101,36 @@ async function promptForExistingProject(projects) {
257100
257101
  }
257101
257102
  return selectedProject;
257102
257103
  }
257104
+ async function resolveExplicitAppId(ctx, appId) {
257105
+ await ctx.runTask("Validating app...", () => getApp(appId), {
257106
+ errorMessage: "Could not validate app"
257107
+ }).catch((error48) => {
257108
+ if (error48 instanceof ApiError && (error48.statusCode === 404 || error48.statusCode === 403)) {
257109
+ throw new InvalidInputError(`App "${appId}" not found, or you don't have access to it.`, {
257110
+ hints: [
257111
+ { message: "Check the app ID is correct" },
257112
+ {
257113
+ message: "Run 'base44 link' without --app-id to browse apps by workspace"
257114
+ }
257115
+ ]
257116
+ });
257117
+ }
257118
+ throw error48;
257119
+ });
257120
+ return appId;
257121
+ }
257122
+ async function chooseProjectInteractively(ctx, options) {
257123
+ const workspaceId = await resolveWorkspaceId(ctx, options.workspace ?? options.org, !ctx.isNonInteractive, { promptMessage: "Which workspace is the app in?" });
257124
+ const projects = await ctx.runTask("Fetching projects...", () => listProjects({ workspaceId }), {
257125
+ successMessage: "Projects fetched",
257126
+ errorMessage: "Failed to fetch projects"
257127
+ });
257128
+ if (!projects.length) {
257129
+ return;
257130
+ }
257131
+ const selectedProject = await promptForExistingProject(projects);
257132
+ return selectedProject.id;
257133
+ }
257103
257134
  async function link(ctx, options, command2) {
257104
257135
  const { log, runTask: runTask2, isNonInteractive } = ctx;
257105
257136
  const appId = readExplicitAppId(command2).value;
@@ -257123,31 +257154,10 @@ async function link(ctx, options, command2) {
257123
257154
  let finalAppId;
257124
257155
  const action = appId ? "choose" : options.create ? "create" : await promptForLinkAction();
257125
257156
  if (action === "choose") {
257126
- const projects = await runTask2("Fetching projects...", async () => listProjects(), {
257127
- successMessage: "Projects fetched",
257128
- errorMessage: "Failed to fetch projects"
257129
- });
257130
- if (!projects.length) {
257157
+ const linkedAppId = appId ? await resolveExplicitAppId(ctx, appId) : await chooseProjectInteractively(ctx, options);
257158
+ if (!linkedAppId) {
257131
257159
  return { outroMessage: "No projects available for linking" };
257132
257160
  }
257133
- let linkedAppId;
257134
- if (appId) {
257135
- const project2 = projects.find((p) => p.id === appId);
257136
- if (!project2) {
257137
- throw new InvalidInputError(`App with ID "${appId}" not found.`, {
257138
- hints: [
257139
- { message: "Check the app ID is correct" },
257140
- {
257141
- message: "Use 'base44 link' without --app-id to see available projects"
257142
- }
257143
- ]
257144
- });
257145
- }
257146
- linkedAppId = appId;
257147
- } else {
257148
- const selectedProject = await promptForExistingProject(projects);
257149
- linkedAppId = selectedProject.id;
257150
- }
257151
257161
  await runTask2("Linking project...", async () => {
257152
257162
  await writeAppConfig(projectRoot.root, linkedAppId);
257153
257163
  setAppContext({ id: linkedAppId, projectRoot: projectRoot.root });
@@ -257176,7 +257186,7 @@ async function link(ctx, options, command2) {
257176
257186
  function getLinkCommand() {
257177
257187
  return new Base44Command("link", {
257178
257188
  requireAppContext: false
257179
- }).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);
257189
+ }).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);
257180
257190
  }
257181
257191
 
257182
257192
  // src/cli/commands/project/logs.ts
@@ -266671,4 +266681,4 @@ export {
266671
266681
  CLIExitError
266672
266682
  };
266673
266683
 
266674
- //# debugId=741C52053719673B64756E2164756E21
266684
+ //# debugId=14B1FDDCC926290964756E2164756E21