@base44-preview/cli 0.1.3-pr.568.68320bd → 0.1.3-pr.568.e436c11
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 +80 -145
- package/dist/cli/index.js.map +13 -12
- 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
|
|
|
@@ -251335,6 +251335,11 @@ class Base44Command extends Command {
|
|
|
251335
251335
|
});
|
|
251336
251336
|
}
|
|
251337
251337
|
}
|
|
251338
|
+
// src/cli/utils/json.ts
|
|
251339
|
+
function toJsonStdout(result) {
|
|
251340
|
+
return `${JSON.stringify(result, null, 2)}
|
|
251341
|
+
`;
|
|
251342
|
+
}
|
|
251338
251343
|
// src/cli/errors.ts
|
|
251339
251344
|
class CLIExitError extends Error {
|
|
251340
251345
|
code;
|
|
@@ -251544,10 +251549,6 @@ var MoveAppResponseSchema = exports_external.looseObject({
|
|
|
251544
251549
|
appId: data.app_id,
|
|
251545
251550
|
newWorkspaceId: data.new_workspace_id
|
|
251546
251551
|
}));
|
|
251547
|
-
var APP_EDITOR_ROLES = ["owner", "admin", "editor"];
|
|
251548
|
-
function canCreateAppsInWorkspace(role) {
|
|
251549
|
-
return role !== undefined && APP_EDITOR_ROLES.includes(role.toLowerCase());
|
|
251550
|
-
}
|
|
251551
251552
|
|
|
251552
251553
|
// src/core/workspace/api.ts
|
|
251553
251554
|
async function listWorkspaces() {
|
|
@@ -253455,62 +253456,13 @@ function fetchWorkspaces(ctx) {
|
|
|
253455
253456
|
errorMessage: "Failed to fetch workspaces"
|
|
253456
253457
|
});
|
|
253457
253458
|
}
|
|
253458
|
-
function workspaceHints(workspaces) {
|
|
253459
|
-
return [
|
|
253460
|
-
{ message: "Run 'base44 workspace list' to see available workspaces" },
|
|
253461
|
-
...workspaces.filter((w) => canCreateAppsInWorkspace(w.userRole)).map((w) => ({ message: `${w.name} — ${w.id}` }))
|
|
253462
|
-
];
|
|
253463
|
-
}
|
|
253464
253459
|
function workspaceLabel(workspace2) {
|
|
253465
253460
|
const suffix = workspace2.isPersonal ? "personal" : workspace2.userRole ?? "member";
|
|
253466
253461
|
return `${workspace2.name} (${suffix})`;
|
|
253467
253462
|
}
|
|
253468
|
-
async function resolveWorkspaceId(ctx, flagWorkspaceId, isInteractive) {
|
|
253463
|
+
async function resolveWorkspaceId(ctx, flagWorkspaceId, isInteractive, options = {}) {
|
|
253469
253464
|
if (flagWorkspaceId) {
|
|
253470
|
-
|
|
253471
|
-
const match = workspaces2.find((w) => w.id === flagWorkspaceId);
|
|
253472
|
-
if (!match) {
|
|
253473
|
-
throw new InvalidInputError(`Workspace "${flagWorkspaceId}" not found, or you are not a member of it.`, { hints: workspaceHints(workspaces2) });
|
|
253474
|
-
}
|
|
253475
|
-
if (!canCreateAppsInWorkspace(match.userRole)) {
|
|
253476
|
-
throw new InvalidInputError(`You don't have permission to create apps in workspace "${match.name}" (your role: ${match.userRole ?? "unknown"}).`);
|
|
253477
|
-
}
|
|
253478
|
-
return match.id;
|
|
253479
|
-
}
|
|
253480
|
-
if (!isInteractive) {
|
|
253481
|
-
return;
|
|
253482
|
-
}
|
|
253483
|
-
const workspaces = await fetchWorkspaces(ctx);
|
|
253484
|
-
const eligible = workspaces.filter((w) => canCreateAppsInWorkspace(w.userRole));
|
|
253485
|
-
if (eligible.length <= 1) {
|
|
253486
|
-
return;
|
|
253487
|
-
}
|
|
253488
|
-
const options = eligible.map((w) => ({
|
|
253489
|
-
value: w.id,
|
|
253490
|
-
label: workspaceLabel(w)
|
|
253491
|
-
}));
|
|
253492
|
-
const selected = await Je({
|
|
253493
|
-
message: "Which workspace should this app belong to?",
|
|
253494
|
-
options,
|
|
253495
|
-
initialValue: eligible[0].id
|
|
253496
|
-
});
|
|
253497
|
-
if (Ct(selected)) {
|
|
253498
|
-
onPromptCancel();
|
|
253499
|
-
}
|
|
253500
|
-
return selected;
|
|
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;
|
|
253465
|
+
return flagWorkspaceId;
|
|
253514
253466
|
}
|
|
253515
253467
|
if (!isInteractive) {
|
|
253516
253468
|
return;
|
|
@@ -253519,13 +253471,13 @@ async function resolveListingWorkspaceId(ctx, flagWorkspaceId, isInteractive) {
|
|
|
253519
253471
|
if (workspaces.length <= 1) {
|
|
253520
253472
|
return;
|
|
253521
253473
|
}
|
|
253522
|
-
const
|
|
253474
|
+
const promptOptions = workspaces.map((w) => ({
|
|
253523
253475
|
value: w.id,
|
|
253524
253476
|
label: workspaceLabel(w)
|
|
253525
253477
|
}));
|
|
253526
253478
|
const selected = await Je({
|
|
253527
|
-
message: "Which workspace
|
|
253528
|
-
options,
|
|
253479
|
+
message: options.promptMessage ?? "Which workspace should this app belong to?",
|
|
253480
|
+
options: promptOptions,
|
|
253529
253481
|
initialValue: workspaces[0].id
|
|
253530
253482
|
});
|
|
253531
253483
|
if (Ct(selected)) {
|
|
@@ -253880,7 +253832,7 @@ async function resolveExplicitAppId(ctx, appId) {
|
|
|
253880
253832
|
return appId;
|
|
253881
253833
|
}
|
|
253882
253834
|
async function chooseProjectInteractively(ctx, options) {
|
|
253883
|
-
const workspaceId = await
|
|
253835
|
+
const workspaceId = await resolveWorkspaceId(ctx, options.workspace ?? options.org, !ctx.isNonInteractive, { promptMessage: "Which workspace is the app in?" });
|
|
253884
253836
|
const projects = await ctx.runTask("Fetching projects...", () => listProjects({ workspaceId }), {
|
|
253885
253837
|
successMessage: "Projects fetched",
|
|
253886
253838
|
errorMessage: "Failed to fetch projects"
|
|
@@ -254375,10 +254327,6 @@ async function resolveFlagOrStdin(flagValue, flagName) {
|
|
|
254375
254327
|
}
|
|
254376
254328
|
return readStdin(flagName, { trim: false });
|
|
254377
254329
|
}
|
|
254378
|
-
function toJsonStdout(result) {
|
|
254379
|
-
return `${JSON.stringify(result, null, 2)}
|
|
254380
|
-
`;
|
|
254381
|
-
}
|
|
254382
254330
|
function parsePositiveInt(value, flagName) {
|
|
254383
254331
|
if (value === undefined) {
|
|
254384
254332
|
return;
|
|
@@ -254816,10 +254764,6 @@ function getTypesCommand() {
|
|
|
254816
254764
|
}
|
|
254817
254765
|
|
|
254818
254766
|
// src/cli/commands/workspace/shared.ts
|
|
254819
|
-
function toJsonStdout2(result) {
|
|
254820
|
-
return `${JSON.stringify(result, null, 2)}
|
|
254821
|
-
`;
|
|
254822
|
-
}
|
|
254823
254767
|
function workspaceTag(workspace2) {
|
|
254824
254768
|
const role = workspace2.userRole ?? "member";
|
|
254825
254769
|
return workspace2.isPersonal ? `personal, ${role}` : role;
|
|
@@ -254838,7 +254782,7 @@ async function getWorkspaceAction({ runTask: runTask2, log, jsonMode }, workspac
|
|
|
254838
254782
|
if (jsonMode) {
|
|
254839
254783
|
return {
|
|
254840
254784
|
outroMessage: workspace2.name,
|
|
254841
|
-
stdout:
|
|
254785
|
+
stdout: toJsonStdout(workspace2)
|
|
254842
254786
|
};
|
|
254843
254787
|
}
|
|
254844
254788
|
log.message(` ${theme.styles.bold(workspace2.name)} ${theme.styles.dim(`[${workspaceTag(workspace2)}]`)}
|
|
@@ -254851,71 +254795,40 @@ function getWorkspaceGetCommand() {
|
|
|
254851
254795
|
}
|
|
254852
254796
|
|
|
254853
254797
|
// src/cli/commands/workspace/list.ts
|
|
254854
|
-
function pluralize2(n5) {
|
|
254855
|
-
return `${n5} workspace${n5 !== 1 ? "s" : ""}`;
|
|
254856
|
-
}
|
|
254857
254798
|
async function listWorkspacesAction({ log, runTask: runTask2, jsonMode }, options8) {
|
|
254858
254799
|
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
254800
|
if (options8.role) {
|
|
254863
254801
|
const role = options8.role.toLowerCase();
|
|
254864
254802
|
workspaces = workspaces.filter((w8) => w8.userRole?.toLowerCase() === role);
|
|
254865
254803
|
}
|
|
254804
|
+
const summary = `${workspaces.length} workspace${workspaces.length !== 1 ? "s" : ""}`;
|
|
254866
254805
|
if (jsonMode) {
|
|
254867
|
-
return {
|
|
254868
|
-
outroMessage: pluralize2(workspaces.length),
|
|
254869
|
-
stdout: toJsonStdout2(workspaces)
|
|
254870
|
-
};
|
|
254806
|
+
return { outroMessage: summary, stdout: toJsonStdout(workspaces) };
|
|
254871
254807
|
}
|
|
254872
254808
|
for (const workspace2 of workspaces) {
|
|
254873
254809
|
log.message(` ${theme.styles.bold(workspace2.name)} ${theme.styles.dim(`[${workspaceTag(workspace2)}]`)}
|
|
254874
254810
|
${theme.styles.dim(workspace2.id)}`);
|
|
254875
254811
|
}
|
|
254876
|
-
return { outroMessage:
|
|
254812
|
+
return { outroMessage: summary };
|
|
254877
254813
|
}
|
|
254878
254814
|
function getWorkspaceListCommand() {
|
|
254879
|
-
return new Base44Command("list", { requireAppContext: false }).description("List the workspaces you belong to").option("--
|
|
254815
|
+
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);
|
|
254880
254816
|
}
|
|
254881
254817
|
|
|
254882
254818
|
// src/cli/commands/workspace/move.ts
|
|
254883
|
-
function
|
|
254884
|
-
|
|
254885
|
-
|
|
254886
|
-
|
|
254887
|
-
|
|
254888
|
-
|
|
254889
|
-
|
|
254890
|
-
|
|
254891
|
-
|
|
254892
|
-
|
|
254893
|
-
throw new InvalidInputError(`Workspace "${target}" not found, or you are not a member of it.`, {
|
|
254894
|
-
hints: [
|
|
254895
|
-
{ message: "Run 'base44 workspace list' to see your workspaces" }
|
|
254896
|
-
]
|
|
254897
|
-
});
|
|
254898
|
-
}
|
|
254899
|
-
if (target === currentWorkspaceId) {
|
|
254900
|
-
throw new InvalidInputError("The app is already in that workspace.");
|
|
254901
|
-
}
|
|
254902
|
-
if (!canCreateAppsInWorkspace(match.userRole)) {
|
|
254903
|
-
throw new InvalidInputError(`You don't have permission to move apps into workspace "${match.name}" (your role: ${match.userRole ?? "unknown"}).`);
|
|
254904
|
-
}
|
|
254905
|
-
return match.id;
|
|
254906
|
-
}
|
|
254907
|
-
if (!isInteractive) {
|
|
254908
|
-
throw new InvalidInputError("A target workspace ID is required in non-interactive mode.", {
|
|
254909
|
-
hints: [
|
|
254910
|
-
{ message: "Usage: base44 workspace move <workspace-id>" },
|
|
254911
|
-
{ message: "Run 'base44 workspace list' to see your workspaces" }
|
|
254912
|
-
]
|
|
254913
|
-
});
|
|
254914
|
-
}
|
|
254915
|
-
if (eligible.length === 0) {
|
|
254819
|
+
async function promptForTargetWorkspace(ctx, appId) {
|
|
254820
|
+
const { workspaces, currentWorkspaceId } = await ctx.runTask("Fetching workspaces...", async () => {
|
|
254821
|
+
const [workspaces2, app] = await Promise.all([
|
|
254822
|
+
listWorkspaces(),
|
|
254823
|
+
getApp(appId)
|
|
254824
|
+
]);
|
|
254825
|
+
return { workspaces: workspaces2, currentWorkspaceId: app.organizationId };
|
|
254826
|
+
}, { errorMessage: "Failed to fetch workspaces" });
|
|
254827
|
+
const destinations = workspaces.filter((w8) => w8.id !== currentWorkspaceId);
|
|
254828
|
+
if (destinations.length === 0) {
|
|
254916
254829
|
throw new InvalidInputError("No other workspaces available to move this app into.");
|
|
254917
254830
|
}
|
|
254918
|
-
const options8 =
|
|
254831
|
+
const options8 = destinations.map((w8) => ({
|
|
254919
254832
|
value: w8.id,
|
|
254920
254833
|
label: `${w8.name} (${w8.userRole ?? "member"})`
|
|
254921
254834
|
}));
|
|
@@ -254926,42 +254839,64 @@ async function resolveTargetWorkspace(target, workspaces, currentWorkspaceId, is
|
|
|
254926
254839
|
if (Ct(selected)) {
|
|
254927
254840
|
onPromptCancel();
|
|
254928
254841
|
}
|
|
254929
|
-
|
|
254842
|
+
const targetWorkspaceId = selected;
|
|
254843
|
+
const nameOf = (id2) => workspaces.find((w8) => w8.id === id2)?.name ?? id2 ?? "unknown workspace";
|
|
254844
|
+
return {
|
|
254845
|
+
targetWorkspaceId,
|
|
254846
|
+
fromName: nameOf(currentWorkspaceId),
|
|
254847
|
+
toName: nameOf(targetWorkspaceId)
|
|
254848
|
+
};
|
|
254930
254849
|
}
|
|
254931
254850
|
async function moveAction(ctx, target, options8) {
|
|
254932
254851
|
const { runTask: runTask2, isNonInteractive, jsonMode } = ctx;
|
|
254933
254852
|
const isInteractive = !isNonInteractive && !jsonMode;
|
|
254934
254853
|
const { id: appId } = getAppContext();
|
|
254935
|
-
|
|
254936
|
-
|
|
254937
|
-
|
|
254938
|
-
|
|
254939
|
-
|
|
254940
|
-
|
|
254941
|
-
|
|
254942
|
-
|
|
254943
|
-
|
|
254944
|
-
|
|
254945
|
-
|
|
254946
|
-
|
|
254947
|
-
|
|
254948
|
-
|
|
254854
|
+
let targetWorkspaceId;
|
|
254855
|
+
let toLabel;
|
|
254856
|
+
if (target) {
|
|
254857
|
+
targetWorkspaceId = target;
|
|
254858
|
+
toLabel = target;
|
|
254859
|
+
if (isInteractive && !options8.yes) {
|
|
254860
|
+
const proceed = await Re({
|
|
254861
|
+
message: `Move this app to workspace ${theme.styles.bold(target)}?`
|
|
254862
|
+
});
|
|
254863
|
+
if (Ct(proceed)) {
|
|
254864
|
+
onPromptCancel();
|
|
254865
|
+
}
|
|
254866
|
+
if (!proceed) {
|
|
254867
|
+
return { outroMessage: "Move cancelled" };
|
|
254868
|
+
}
|
|
254949
254869
|
}
|
|
254950
|
-
|
|
254951
|
-
|
|
254870
|
+
} else if (isInteractive) {
|
|
254871
|
+
const picked = await promptForTargetWorkspace(ctx, appId);
|
|
254872
|
+
targetWorkspaceId = picked.targetWorkspaceId;
|
|
254873
|
+
toLabel = picked.toName;
|
|
254874
|
+
if (!options8.yes) {
|
|
254875
|
+
const proceed = await Re({
|
|
254876
|
+
message: `Move this app from ${theme.styles.bold(picked.fromName)} to ${theme.styles.bold(picked.toName)}?`
|
|
254877
|
+
});
|
|
254878
|
+
if (Ct(proceed)) {
|
|
254879
|
+
onPromptCancel();
|
|
254880
|
+
}
|
|
254881
|
+
if (!proceed) {
|
|
254882
|
+
return { outroMessage: "Move cancelled" };
|
|
254883
|
+
}
|
|
254952
254884
|
}
|
|
254885
|
+
} else {
|
|
254886
|
+
throw new InvalidInputError("A target workspace ID is required in non-interactive mode.", {
|
|
254887
|
+
hints: [
|
|
254888
|
+
{ message: "Usage: base44 workspace move <workspace-id>" },
|
|
254889
|
+
{ message: "Run 'base44 workspace list' to see your workspaces" }
|
|
254890
|
+
]
|
|
254891
|
+
});
|
|
254953
254892
|
}
|
|
254954
254893
|
const result = await runTask2("Moving app to workspace...", () => moveAppToWorkspace(appId, targetWorkspaceId, {
|
|
254955
254894
|
disconnectIntegrations: options8.disconnectIntegrations
|
|
254956
254895
|
}), { errorMessage: "Failed to move app" });
|
|
254957
|
-
const targetName = workspaceName(workspaces, targetWorkspaceId);
|
|
254958
254896
|
if (jsonMode) {
|
|
254959
|
-
return {
|
|
254960
|
-
outroMessage: `App moved to ${targetName}`,
|
|
254961
|
-
stdout: toJsonStdout2(result)
|
|
254962
|
-
};
|
|
254897
|
+
return { outroMessage: "App moved", stdout: toJsonStdout(result) };
|
|
254963
254898
|
}
|
|
254964
|
-
return { outroMessage: `App moved to ${theme.styles.bold(
|
|
254899
|
+
return { outroMessage: `App moved to ${theme.styles.bold(toLabel)}` };
|
|
254965
254900
|
}
|
|
254966
254901
|
function getWorkspaceMoveCommand() {
|
|
254967
254902
|
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", `
|
|
@@ -263005,4 +262940,4 @@ export {
|
|
|
263005
262940
|
CLIExitError
|
|
263006
262941
|
};
|
|
263007
262942
|
|
|
263008
|
-
//# debugId=
|
|
262943
|
+
//# debugId=C39B52458812629964756E2164756E21
|