@base44-preview/cli 0.1.4-pr.567.1086443 → 0.1.4-pr.567.2681dfe
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 +76 -102
- package/dist/cli/index.js.map +12 -11
- package/package.json +1 -1
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 =
|
|
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
|
|
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
|
|
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
|
|
168660
|
-
if (escape3 && typeof
|
|
168661
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
253491
|
-
if (eligible.length <= 1) {
|
|
253477
|
+
if (workspaces.length <= 1) {
|
|
253492
253478
|
return;
|
|
253493
253479
|
}
|
|
253494
|
-
const options =
|
|
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:
|
|
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:
|
|
254779
|
+
stdout: toJsonStdout(workspace2)
|
|
254802
254780
|
};
|
|
254803
254781
|
}
|
|
254804
254782
|
log.message(` ${theme.styles.bold(workspace2.name)} ${theme.styles.dim(`[${workspaceTag(workspace2)}]`)}
|
|
@@ -254816,9 +254794,6 @@ function pluralize2(n5) {
|
|
|
254816
254794
|
}
|
|
254817
254795
|
async function listWorkspacesAction({ log, runTask: runTask2, jsonMode }, options8) {
|
|
254818
254796
|
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
254797
|
if (options8.role) {
|
|
254823
254798
|
const role = options8.role.toLowerCase();
|
|
254824
254799
|
workspaces = workspaces.filter((w8) => w8.userRole?.toLowerCase() === role);
|
|
@@ -254826,7 +254801,7 @@ async function listWorkspacesAction({ log, runTask: runTask2, jsonMode }, option
|
|
|
254826
254801
|
if (jsonMode) {
|
|
254827
254802
|
return {
|
|
254828
254803
|
outroMessage: pluralize2(workspaces.length),
|
|
254829
|
-
stdout:
|
|
254804
|
+
stdout: toJsonStdout(workspaces)
|
|
254830
254805
|
};
|
|
254831
254806
|
}
|
|
254832
254807
|
for (const workspace2 of workspaces) {
|
|
@@ -254836,46 +254811,23 @@ async function listWorkspacesAction({ log, runTask: runTask2, jsonMode }, option
|
|
|
254836
254811
|
return { outroMessage: pluralize2(workspaces.length) };
|
|
254837
254812
|
}
|
|
254838
254813
|
function getWorkspaceListCommand() {
|
|
254839
|
-
return new Base44Command("list", { requireAppContext: false }).description("List the workspaces you belong to").option("--
|
|
254814
|
+
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
254815
|
}
|
|
254841
254816
|
|
|
254842
254817
|
// src/cli/commands/workspace/move.ts
|
|
254843
|
-
function
|
|
254844
|
-
|
|
254845
|
-
|
|
254846
|
-
|
|
254847
|
-
|
|
254848
|
-
|
|
254849
|
-
|
|
254850
|
-
|
|
254851
|
-
|
|
254852
|
-
|
|
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) {
|
|
254818
|
+
async function promptForTargetWorkspace(ctx, appId) {
|
|
254819
|
+
const { workspaces, currentWorkspaceId } = await ctx.runTask("Fetching workspaces...", async () => {
|
|
254820
|
+
const [workspaces2, app] = await Promise.all([
|
|
254821
|
+
listWorkspaces(),
|
|
254822
|
+
getApp(appId)
|
|
254823
|
+
]);
|
|
254824
|
+
return { workspaces: workspaces2, currentWorkspaceId: app.organizationId };
|
|
254825
|
+
}, { errorMessage: "Failed to fetch workspaces" });
|
|
254826
|
+
const destinations = workspaces.filter((w8) => w8.id !== currentWorkspaceId);
|
|
254827
|
+
if (destinations.length === 0) {
|
|
254876
254828
|
throw new InvalidInputError("No other workspaces available to move this app into.");
|
|
254877
254829
|
}
|
|
254878
|
-
const options8 =
|
|
254830
|
+
const options8 = destinations.map((w8) => ({
|
|
254879
254831
|
value: w8.id,
|
|
254880
254832
|
label: `${w8.name} (${w8.userRole ?? "member"})`
|
|
254881
254833
|
}));
|
|
@@ -254886,42 +254838,64 @@ async function resolveTargetWorkspace(target, workspaces, currentWorkspaceId, is
|
|
|
254886
254838
|
if (Ct(selected)) {
|
|
254887
254839
|
onPromptCancel();
|
|
254888
254840
|
}
|
|
254889
|
-
|
|
254841
|
+
const targetWorkspaceId = selected;
|
|
254842
|
+
const nameOf = (id2) => workspaces.find((w8) => w8.id === id2)?.name ?? id2 ?? "unknown workspace";
|
|
254843
|
+
return {
|
|
254844
|
+
targetWorkspaceId,
|
|
254845
|
+
fromName: nameOf(currentWorkspaceId),
|
|
254846
|
+
toName: nameOf(targetWorkspaceId)
|
|
254847
|
+
};
|
|
254890
254848
|
}
|
|
254891
254849
|
async function moveAction(ctx, target, options8) {
|
|
254892
254850
|
const { runTask: runTask2, isNonInteractive, jsonMode } = ctx;
|
|
254893
254851
|
const isInteractive = !isNonInteractive && !jsonMode;
|
|
254894
254852
|
const { id: appId } = getAppContext();
|
|
254895
|
-
|
|
254896
|
-
|
|
254897
|
-
|
|
254898
|
-
|
|
254899
|
-
|
|
254900
|
-
|
|
254901
|
-
|
|
254902
|
-
|
|
254903
|
-
|
|
254904
|
-
|
|
254905
|
-
|
|
254906
|
-
|
|
254907
|
-
|
|
254908
|
-
|
|
254853
|
+
let targetWorkspaceId;
|
|
254854
|
+
let toLabel;
|
|
254855
|
+
if (target) {
|
|
254856
|
+
targetWorkspaceId = target;
|
|
254857
|
+
toLabel = target;
|
|
254858
|
+
if (isInteractive && !options8.yes) {
|
|
254859
|
+
const proceed = await Re({
|
|
254860
|
+
message: `Move this app to workspace ${theme.styles.bold(target)}?`
|
|
254861
|
+
});
|
|
254862
|
+
if (Ct(proceed)) {
|
|
254863
|
+
onPromptCancel();
|
|
254864
|
+
}
|
|
254865
|
+
if (!proceed) {
|
|
254866
|
+
return { outroMessage: "Move cancelled" };
|
|
254867
|
+
}
|
|
254909
254868
|
}
|
|
254910
|
-
|
|
254911
|
-
|
|
254869
|
+
} else if (isInteractive) {
|
|
254870
|
+
const picked = await promptForTargetWorkspace(ctx, appId);
|
|
254871
|
+
targetWorkspaceId = picked.targetWorkspaceId;
|
|
254872
|
+
toLabel = picked.toName;
|
|
254873
|
+
if (!options8.yes) {
|
|
254874
|
+
const proceed = await Re({
|
|
254875
|
+
message: `Move this app from ${theme.styles.bold(picked.fromName)} to ${theme.styles.bold(picked.toName)}?`
|
|
254876
|
+
});
|
|
254877
|
+
if (Ct(proceed)) {
|
|
254878
|
+
onPromptCancel();
|
|
254879
|
+
}
|
|
254880
|
+
if (!proceed) {
|
|
254881
|
+
return { outroMessage: "Move cancelled" };
|
|
254882
|
+
}
|
|
254912
254883
|
}
|
|
254884
|
+
} else {
|
|
254885
|
+
throw new InvalidInputError("A target workspace ID is required in non-interactive mode.", {
|
|
254886
|
+
hints: [
|
|
254887
|
+
{ message: "Usage: base44 workspace move <workspace-id>" },
|
|
254888
|
+
{ message: "Run 'base44 workspace list' to see your workspaces" }
|
|
254889
|
+
]
|
|
254890
|
+
});
|
|
254913
254891
|
}
|
|
254914
254892
|
const result = await runTask2("Moving app to workspace...", () => moveAppToWorkspace(appId, targetWorkspaceId, {
|
|
254915
254893
|
disconnectIntegrations: options8.disconnectIntegrations
|
|
254916
254894
|
}), { errorMessage: "Failed to move app" });
|
|
254917
|
-
const targetName = workspaceName(workspaces, targetWorkspaceId);
|
|
254918
254895
|
if (jsonMode) {
|
|
254919
|
-
return {
|
|
254920
|
-
outroMessage: `App moved to ${targetName}`,
|
|
254921
|
-
stdout: toJsonStdout2(result)
|
|
254922
|
-
};
|
|
254896
|
+
return { outroMessage: "App moved", stdout: toJsonStdout(result) };
|
|
254923
254897
|
}
|
|
254924
|
-
return { outroMessage: `App moved to ${theme.styles.bold(
|
|
254898
|
+
return { outroMessage: `App moved to ${theme.styles.bold(toLabel)}` };
|
|
254925
254899
|
}
|
|
254926
254900
|
function getWorkspaceMoveCommand() {
|
|
254927
254901
|
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 +262939,4 @@ export {
|
|
|
262965
262939
|
CLIExitError
|
|
262966
262940
|
};
|
|
262967
262941
|
|
|
262968
|
-
//# debugId=
|
|
262942
|
+
//# debugId=286FD2180C08CE2564756E2164756E21
|