@base44-preview/cli 0.1.4-pr.567.6b2480e → 0.1.4-pr.567.a56c290

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
@@ -161113,11 +161113,11 @@ var require_json4 = __commonJS((exports, module) => {
161113
161113
  var debug = require_src4()("body-parser:json");
161114
161114
  var read3 = require_read();
161115
161115
  var { normalizeOptions: normalizeOptions5 } = require_utils8();
161116
- module.exports = json2;
161116
+ module.exports = json3;
161117
161117
  var FIRST_CHAR_REGEXP = /^[\x20\x09\x0a\x0d]*([^\x20\x09\x0a\x0d])/;
161118
161118
  var JSON_SYNTAX_CHAR = "#";
161119
161119
  var JSON_SYNTAX_REGEXP = /#+/g;
161120
- function json2(options8) {
161120
+ function json3(options8) {
161121
161121
  const normalizedOptions = normalizeOptions5(options8, "application/json");
161122
161122
  var reviver = options8?.reviver;
161123
161123
  var strict = options8?.strict !== false;
@@ -168320,7 +168320,7 @@ var require_response = __commonJS((exports, module) => {
168320
168320
  }
168321
168321
  return this;
168322
168322
  };
168323
- res.json = function json2(obj) {
168323
+ res.json = function json3(obj) {
168324
168324
  var app = this.app;
168325
168325
  var escape3 = app.get("json escape");
168326
168326
  var replacer = app.get("json replacer");
@@ -168656,9 +168656,9 @@ var require_response = __commonJS((exports, module) => {
168656
168656
  file2.pipe(res2);
168657
168657
  }
168658
168658
  function stringify(value, replacer, spaces, escape3) {
168659
- var json2 = replacer || spaces ? JSON.stringify(value, replacer, spaces) : JSON.stringify(value);
168660
- if (escape3 && typeof json2 === "string") {
168661
- json2 = json2.replace(/[<>&]/g, function(c8) {
168659
+ var json3 = replacer || spaces ? JSON.stringify(value, replacer, spaces) : JSON.stringify(value);
168660
+ if (escape3 && typeof json3 === "string") {
168661
+ json3 = json3.replace(/[<>&]/g, function(c8) {
168662
168662
  switch (c8.charCodeAt(0)) {
168663
168663
  case 60:
168664
168664
  return "\\u003c";
@@ -168671,7 +168671,7 @@ var require_response = __commonJS((exports, module) => {
168671
168671
  }
168672
168672
  });
168673
168673
  }
168674
- return json2;
168674
+ return json3;
168675
168675
  }
168676
168676
  });
168677
168677
 
@@ -251341,6 +251341,11 @@ class Base44Command extends Command {
251341
251341
  });
251342
251342
  }
251343
251343
  }
251344
+ // src/cli/utils/json.ts
251345
+ function toJsonStdout(result) {
251346
+ return `${JSON.stringify(result, null, 2)}
251347
+ `;
251348
+ }
251344
251349
  // src/cli/errors.ts
251345
251350
  class CLIExitError extends Error {
251346
251351
  code;
@@ -251550,10 +251555,6 @@ var MoveAppResponseSchema = exports_external.looseObject({
251550
251555
  appId: data.app_id,
251551
251556
  newWorkspaceId: data.new_workspace_id
251552
251557
  }));
251553
- var APP_EDITOR_ROLES = ["owner", "admin", "editor"];
251554
- function canCreateAppsInWorkspace(role) {
251555
- return role !== undefined && APP_EDITOR_ROLES.includes(role.toLowerCase());
251556
- }
251557
251558
 
251558
251559
  // src/core/workspace/api.ts
251559
251560
  async function listWorkspaces() {
@@ -253461,44 +253462,29 @@ function fetchWorkspaces(ctx) {
253461
253462
  errorMessage: "Failed to fetch workspaces"
253462
253463
  });
253463
253464
  }
253464
- function workspaceHints(workspaces) {
253465
- return [
253466
- { message: "Run 'base44 workspace list' to see available workspaces" },
253467
- ...workspaces.filter((w) => canCreateAppsInWorkspace(w.userRole)).map((w) => ({ message: `${w.name} — ${w.id}` }))
253468
- ];
253469
- }
253470
253465
  function workspaceLabel(workspace2) {
253471
253466
  const suffix = workspace2.isPersonal ? "personal" : workspace2.userRole ?? "member";
253472
253467
  return `${workspace2.name} (${suffix})`;
253473
253468
  }
253474
253469
  async function resolveWorkspaceId(ctx, flagWorkspaceId, isInteractive) {
253475
253470
  if (flagWorkspaceId) {
253476
- const workspaces2 = await fetchWorkspaces(ctx);
253477
- const match = workspaces2.find((w) => w.id === flagWorkspaceId);
253478
- if (!match) {
253479
- throw new InvalidInputError(`Workspace "${flagWorkspaceId}" not found, or you are not a member of it.`, { hints: workspaceHints(workspaces2) });
253480
- }
253481
- if (!canCreateAppsInWorkspace(match.userRole)) {
253482
- throw new InvalidInputError(`You don't have permission to create apps in workspace "${match.name}" (your role: ${match.userRole ?? "unknown"}).`);
253483
- }
253484
- return match.id;
253471
+ return flagWorkspaceId;
253485
253472
  }
253486
253473
  if (!isInteractive) {
253487
253474
  return;
253488
253475
  }
253489
253476
  const workspaces = await fetchWorkspaces(ctx);
253490
- const eligible = workspaces.filter((w) => canCreateAppsInWorkspace(w.userRole));
253491
- if (eligible.length <= 1) {
253477
+ if (workspaces.length <= 1) {
253492
253478
  return;
253493
253479
  }
253494
- const options = eligible.map((w) => ({
253480
+ const options = workspaces.map((w) => ({
253495
253481
  value: w.id,
253496
253482
  label: workspaceLabel(w)
253497
253483
  }));
253498
253484
  const selected = await Je({
253499
253485
  message: "Which workspace should this app belong to?",
253500
253486
  options,
253501
- initialValue: eligible[0].id
253487
+ initialValue: workspaces[0].id
253502
253488
  });
253503
253489
  if (Ct(selected)) {
253504
253490
  onPromptCancel();
@@ -254335,10 +254321,6 @@ async function resolveFlagOrStdin(flagValue, flagName) {
254335
254321
  }
254336
254322
  return readStdin(flagName, { trim: false });
254337
254323
  }
254338
- function toJsonStdout(result) {
254339
- return `${JSON.stringify(result, null, 2)}
254340
- `;
254341
- }
254342
254324
  function parsePositiveInt(value, flagName) {
254343
254325
  if (value === undefined) {
254344
254326
  return;
@@ -254776,10 +254758,6 @@ function getTypesCommand() {
254776
254758
  }
254777
254759
 
254778
254760
  // src/cli/commands/workspace/shared.ts
254779
- function toJsonStdout2(result) {
254780
- return `${JSON.stringify(result, null, 2)}
254781
- `;
254782
- }
254783
254761
  function workspaceTag(workspace2) {
254784
254762
  const role = workspace2.userRole ?? "member";
254785
254763
  return workspace2.isPersonal ? `personal, ${role}` : role;
@@ -254798,7 +254776,7 @@ async function getWorkspaceAction({ runTask: runTask2, log, jsonMode }, workspac
254798
254776
  if (jsonMode) {
254799
254777
  return {
254800
254778
  outroMessage: workspace2.name,
254801
- stdout: toJsonStdout2(workspace2)
254779
+ stdout: toJsonStdout(workspace2)
254802
254780
  };
254803
254781
  }
254804
254782
  log.message(` ${theme.styles.bold(workspace2.name)} ${theme.styles.dim(`[${workspaceTag(workspace2)}]`)}
@@ -254811,71 +254789,40 @@ function getWorkspaceGetCommand() {
254811
254789
  }
254812
254790
 
254813
254791
  // src/cli/commands/workspace/list.ts
254814
- function pluralize2(n5) {
254815
- return `${n5} workspace${n5 !== 1 ? "s" : ""}`;
254816
- }
254817
254792
  async function listWorkspacesAction({ log, runTask: runTask2, jsonMode }, options8) {
254818
254793
  let workspaces = await runTask2("Fetching workspaces...", () => listWorkspaces(), { errorMessage: "Failed to fetch workspaces" });
254819
- if (options8.canCreate) {
254820
- workspaces = workspaces.filter((w8) => canCreateAppsInWorkspace(w8.userRole));
254821
- }
254822
254794
  if (options8.role) {
254823
254795
  const role = options8.role.toLowerCase();
254824
254796
  workspaces = workspaces.filter((w8) => w8.userRole?.toLowerCase() === role);
254825
254797
  }
254798
+ const summary = `${workspaces.length} workspace${workspaces.length !== 1 ? "s" : ""}`;
254826
254799
  if (jsonMode) {
254827
- return {
254828
- outroMessage: pluralize2(workspaces.length),
254829
- stdout: toJsonStdout2(workspaces)
254830
- };
254800
+ return { outroMessage: summary, stdout: toJsonStdout(workspaces) };
254831
254801
  }
254832
254802
  for (const workspace2 of workspaces) {
254833
254803
  log.message(` ${theme.styles.bold(workspace2.name)} ${theme.styles.dim(`[${workspaceTag(workspace2)}]`)}
254834
254804
  ${theme.styles.dim(workspace2.id)}`);
254835
254805
  }
254836
- return { outroMessage: pluralize2(workspaces.length) };
254806
+ return { outroMessage: summary };
254837
254807
  }
254838
254808
  function getWorkspaceListCommand() {
254839
- 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);
254809
+ return new Base44Command("list", { requireAppContext: false }).description("List the workspaces you belong to").option("--role <role>", "Only workspaces where your role matches (owner, admin, editor, viewer)").action(listWorkspacesAction);
254840
254810
  }
254841
254811
 
254842
254812
  // src/cli/commands/workspace/move.ts
254843
- function workspaceName(workspaces, id2) {
254844
- if (!id2)
254845
- return "unknown workspace";
254846
- return workspaces.find((w8) => w8.id === id2)?.name ?? id2;
254847
- }
254848
- async function resolveTargetWorkspace(target, workspaces, currentWorkspaceId, isInteractive) {
254849
- const eligible = workspaces.filter((w8) => canCreateAppsInWorkspace(w8.userRole) && w8.id !== currentWorkspaceId);
254850
- if (target) {
254851
- const match = workspaces.find((w8) => w8.id === target);
254852
- if (!match) {
254853
- throw new InvalidInputError(`Workspace "${target}" not found, or you are not a member of it.`, {
254854
- hints: [
254855
- { message: "Run 'base44 workspace list' to see your workspaces" }
254856
- ]
254857
- });
254858
- }
254859
- if (target === currentWorkspaceId) {
254860
- throw new InvalidInputError("The app is already in that workspace.");
254861
- }
254862
- if (!canCreateAppsInWorkspace(match.userRole)) {
254863
- throw new InvalidInputError(`You don't have permission to move apps into workspace "${match.name}" (your role: ${match.userRole ?? "unknown"}).`);
254864
- }
254865
- return match.id;
254866
- }
254867
- if (!isInteractive) {
254868
- throw new InvalidInputError("A target workspace ID is required in non-interactive mode.", {
254869
- hints: [
254870
- { message: "Usage: base44 workspace move <workspace-id>" },
254871
- { message: "Run 'base44 workspace list' to see your workspaces" }
254872
- ]
254873
- });
254874
- }
254875
- if (eligible.length === 0) {
254813
+ async function promptForTargetWorkspace(ctx, appId) {
254814
+ const { workspaces, currentWorkspaceId } = await ctx.runTask("Fetching workspaces...", async () => {
254815
+ const [workspaces2, app] = await Promise.all([
254816
+ listWorkspaces(),
254817
+ getApp(appId)
254818
+ ]);
254819
+ return { workspaces: workspaces2, currentWorkspaceId: app.organizationId };
254820
+ }, { errorMessage: "Failed to fetch workspaces" });
254821
+ const destinations = workspaces.filter((w8) => w8.id !== currentWorkspaceId);
254822
+ if (destinations.length === 0) {
254876
254823
  throw new InvalidInputError("No other workspaces available to move this app into.");
254877
254824
  }
254878
- const options8 = eligible.map((w8) => ({
254825
+ const options8 = destinations.map((w8) => ({
254879
254826
  value: w8.id,
254880
254827
  label: `${w8.name} (${w8.userRole ?? "member"})`
254881
254828
  }));
@@ -254886,42 +254833,64 @@ async function resolveTargetWorkspace(target, workspaces, currentWorkspaceId, is
254886
254833
  if (Ct(selected)) {
254887
254834
  onPromptCancel();
254888
254835
  }
254889
- return selected;
254836
+ const targetWorkspaceId = selected;
254837
+ const nameOf = (id2) => workspaces.find((w8) => w8.id === id2)?.name ?? id2 ?? "unknown workspace";
254838
+ return {
254839
+ targetWorkspaceId,
254840
+ fromName: nameOf(currentWorkspaceId),
254841
+ toName: nameOf(targetWorkspaceId)
254842
+ };
254890
254843
  }
254891
254844
  async function moveAction(ctx, target, options8) {
254892
254845
  const { runTask: runTask2, isNonInteractive, jsonMode } = ctx;
254893
254846
  const isInteractive = !isNonInteractive && !jsonMode;
254894
254847
  const { id: appId } = getAppContext();
254895
- const { workspaces, currentWorkspaceId } = await runTask2("Fetching workspaces...", async () => {
254896
- const [workspaces2, app] = await Promise.all([
254897
- listWorkspaces(),
254898
- getApp(appId)
254899
- ]);
254900
- return { workspaces: workspaces2, currentWorkspaceId: app.organizationId };
254901
- }, { errorMessage: "Failed to fetch workspaces" });
254902
- const targetWorkspaceId = await resolveTargetWorkspace(target, workspaces, currentWorkspaceId, isInteractive);
254903
- if (isInteractive && !options8.yes) {
254904
- const proceed = await Re({
254905
- message: `Move this app from ${theme.styles.bold(workspaceName(workspaces, currentWorkspaceId))} to ${theme.styles.bold(workspaceName(workspaces, targetWorkspaceId))}?`
254906
- });
254907
- if (Ct(proceed)) {
254908
- onPromptCancel();
254848
+ let targetWorkspaceId;
254849
+ let toLabel;
254850
+ if (target) {
254851
+ targetWorkspaceId = target;
254852
+ toLabel = target;
254853
+ if (isInteractive && !options8.yes) {
254854
+ const proceed = await Re({
254855
+ message: `Move this app to workspace ${theme.styles.bold(target)}?`
254856
+ });
254857
+ if (Ct(proceed)) {
254858
+ onPromptCancel();
254859
+ }
254860
+ if (!proceed) {
254861
+ return { outroMessage: "Move cancelled" };
254862
+ }
254909
254863
  }
254910
- if (!proceed) {
254911
- return { outroMessage: "Move cancelled" };
254864
+ } else if (isInteractive) {
254865
+ const picked = await promptForTargetWorkspace(ctx, appId);
254866
+ targetWorkspaceId = picked.targetWorkspaceId;
254867
+ toLabel = picked.toName;
254868
+ if (!options8.yes) {
254869
+ const proceed = await Re({
254870
+ message: `Move this app from ${theme.styles.bold(picked.fromName)} to ${theme.styles.bold(picked.toName)}?`
254871
+ });
254872
+ if (Ct(proceed)) {
254873
+ onPromptCancel();
254874
+ }
254875
+ if (!proceed) {
254876
+ return { outroMessage: "Move cancelled" };
254877
+ }
254912
254878
  }
254879
+ } else {
254880
+ throw new InvalidInputError("A target workspace ID is required in non-interactive mode.", {
254881
+ hints: [
254882
+ { message: "Usage: base44 workspace move <workspace-id>" },
254883
+ { message: "Run 'base44 workspace list' to see your workspaces" }
254884
+ ]
254885
+ });
254913
254886
  }
254914
254887
  const result = await runTask2("Moving app to workspace...", () => moveAppToWorkspace(appId, targetWorkspaceId, {
254915
254888
  disconnectIntegrations: options8.disconnectIntegrations
254916
254889
  }), { errorMessage: "Failed to move app" });
254917
- const targetName = workspaceName(workspaces, targetWorkspaceId);
254918
254890
  if (jsonMode) {
254919
- return {
254920
- outroMessage: `App moved to ${targetName}`,
254921
- stdout: toJsonStdout2(result)
254922
- };
254891
+ return { outroMessage: "App moved", stdout: toJsonStdout(result) };
254923
254892
  }
254924
- return { outroMessage: `App moved to ${theme.styles.bold(targetName)}` };
254893
+ return { outroMessage: `App moved to ${theme.styles.bold(toLabel)}` };
254925
254894
  }
254926
254895
  function getWorkspaceMoveCommand() {
254927
254896
  return new Base44Command("move").description("Move the current app to another workspace").argument("[workspace-id]", "Target workspace (organization) ID").option("--disconnect-integrations", "Disconnect the app's OAuth integrations as part of the move").option("-y, --yes", "Skip the confirmation prompt").addHelpText("after", `
@@ -262965,4 +262934,4 @@ export {
262965
262934
  CLIExitError
262966
262935
  };
262967
262936
 
262968
- //# debugId=B9D4F09248278B0364756E2164756E21
262937
+ //# debugId=A13BE6B0A6A9F5CD64756E2164756E21