@base44-preview/cli 0.1.3-pr.567.b7c491a → 0.1.3-pr.568.67b756c
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 +166 -142
- package/dist/cli/index.js.map +16 -14
- 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
|
|
|
@@ -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: {
|
|
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");
|
|
@@ -251330,6 +251335,11 @@ class Base44Command extends Command {
|
|
|
251330
251335
|
});
|
|
251331
251336
|
}
|
|
251332
251337
|
}
|
|
251338
|
+
// src/cli/utils/json.ts
|
|
251339
|
+
function toJsonStdout(result) {
|
|
251340
|
+
return `${JSON.stringify(result, null, 2)}
|
|
251341
|
+
`;
|
|
251342
|
+
}
|
|
251333
251343
|
// src/cli/errors.ts
|
|
251334
251344
|
class CLIExitError extends Error {
|
|
251335
251345
|
code;
|
|
@@ -251539,10 +251549,6 @@ var MoveAppResponseSchema = exports_external.looseObject({
|
|
|
251539
251549
|
appId: data.app_id,
|
|
251540
251550
|
newWorkspaceId: data.new_workspace_id
|
|
251541
251551
|
}));
|
|
251542
|
-
var APP_EDITOR_ROLES = ["owner", "admin", "editor"];
|
|
251543
|
-
function canCreateAppsInWorkspace(role) {
|
|
251544
|
-
return role !== undefined && APP_EDITOR_ROLES.includes(role.toLowerCase());
|
|
251545
|
-
}
|
|
251546
251552
|
|
|
251547
251553
|
// src/core/workspace/api.ts
|
|
251548
251554
|
async function listWorkspaces() {
|
|
@@ -251561,6 +251567,10 @@ async function listWorkspaces() {
|
|
|
251561
251567
|
isPersonal: index === 0
|
|
251562
251568
|
}));
|
|
251563
251569
|
}
|
|
251570
|
+
async function getWorkspace(id) {
|
|
251571
|
+
const workspaces = await listWorkspaces();
|
|
251572
|
+
return workspaces.find((w) => w.id === id);
|
|
251573
|
+
}
|
|
251564
251574
|
async function moveAppToWorkspace(appId, targetWorkspaceId, options = {}) {
|
|
251565
251575
|
let response;
|
|
251566
251576
|
try {
|
|
@@ -253446,44 +253456,29 @@ function fetchWorkspaces(ctx) {
|
|
|
253446
253456
|
errorMessage: "Failed to fetch workspaces"
|
|
253447
253457
|
});
|
|
253448
253458
|
}
|
|
253449
|
-
function workspaceHints(workspaces) {
|
|
253450
|
-
return [
|
|
253451
|
-
{ message: "Run 'base44 workspace list' to see available workspaces" },
|
|
253452
|
-
...workspaces.filter((w) => canCreateAppsInWorkspace(w.userRole)).map((w) => ({ message: `${w.name} — ${w.id}` }))
|
|
253453
|
-
];
|
|
253454
|
-
}
|
|
253455
253459
|
function workspaceLabel(workspace2) {
|
|
253456
253460
|
const suffix = workspace2.isPersonal ? "personal" : workspace2.userRole ?? "member";
|
|
253457
253461
|
return `${workspace2.name} (${suffix})`;
|
|
253458
253462
|
}
|
|
253459
|
-
async function resolveWorkspaceId(ctx, flagWorkspaceId, isInteractive) {
|
|
253463
|
+
async function resolveWorkspaceId(ctx, flagWorkspaceId, isInteractive, options = {}) {
|
|
253460
253464
|
if (flagWorkspaceId) {
|
|
253461
|
-
|
|
253462
|
-
const match = workspaces2.find((w) => w.id === flagWorkspaceId);
|
|
253463
|
-
if (!match) {
|
|
253464
|
-
throw new InvalidInputError(`Workspace "${flagWorkspaceId}" not found, or you are not a member of it.`, { hints: workspaceHints(workspaces2) });
|
|
253465
|
-
}
|
|
253466
|
-
if (!canCreateAppsInWorkspace(match.userRole)) {
|
|
253467
|
-
throw new InvalidInputError(`You don't have permission to create apps in workspace "${match.name}" (your role: ${match.userRole ?? "unknown"}).`);
|
|
253468
|
-
}
|
|
253469
|
-
return match.id;
|
|
253465
|
+
return flagWorkspaceId;
|
|
253470
253466
|
}
|
|
253471
253467
|
if (!isInteractive) {
|
|
253472
253468
|
return;
|
|
253473
253469
|
}
|
|
253474
253470
|
const workspaces = await fetchWorkspaces(ctx);
|
|
253475
|
-
|
|
253476
|
-
if (eligible.length <= 1) {
|
|
253471
|
+
if (workspaces.length <= 1) {
|
|
253477
253472
|
return;
|
|
253478
253473
|
}
|
|
253479
|
-
const
|
|
253474
|
+
const promptOptions = workspaces.map((w) => ({
|
|
253480
253475
|
value: w.id,
|
|
253481
253476
|
label: workspaceLabel(w)
|
|
253482
253477
|
}));
|
|
253483
253478
|
const selected = await Je({
|
|
253484
|
-
message: "Which workspace should this app belong to?",
|
|
253485
|
-
options,
|
|
253486
|
-
initialValue:
|
|
253479
|
+
message: options.promptMessage ?? "Which workspace should this app belong to?",
|
|
253480
|
+
options: promptOptions,
|
|
253481
|
+
initialValue: workspaces[0].id
|
|
253487
253482
|
});
|
|
253488
253483
|
if (Ct(selected)) {
|
|
253489
253484
|
onPromptCancel();
|
|
@@ -253815,6 +253810,40 @@ async function promptForExistingProject(linkableProjects) {
|
|
|
253815
253810
|
}
|
|
253816
253811
|
return selectedProject;
|
|
253817
253812
|
}
|
|
253813
|
+
async function resolveExplicitAppId(ctx, appId) {
|
|
253814
|
+
const app = await ctx.runTask("Validating app...", () => getApp(appId), {
|
|
253815
|
+
errorMessage: "Could not validate app"
|
|
253816
|
+
}).catch((error48) => {
|
|
253817
|
+
if (error48 instanceof ApiError && (error48.statusCode === 404 || error48.statusCode === 403)) {
|
|
253818
|
+
throw new InvalidInputError(`App "${appId}" not found, or you don't have access to it.`, {
|
|
253819
|
+
hints: [
|
|
253820
|
+
{ message: "Check the app ID is correct" },
|
|
253821
|
+
{
|
|
253822
|
+
message: "Run 'base44 link' without --app-id to browse apps by workspace"
|
|
253823
|
+
}
|
|
253824
|
+
]
|
|
253825
|
+
});
|
|
253826
|
+
}
|
|
253827
|
+
throw error48;
|
|
253828
|
+
});
|
|
253829
|
+
if (app.isManagedSourceCode) {
|
|
253830
|
+
throw new InvalidInputError(`App "${appId}" is a managed-source app and can't be linked with the CLI.`);
|
|
253831
|
+
}
|
|
253832
|
+
return appId;
|
|
253833
|
+
}
|
|
253834
|
+
async function chooseProjectInteractively(ctx, options) {
|
|
253835
|
+
const workspaceId = await resolveWorkspaceId(ctx, options.workspace ?? options.org, !ctx.isNonInteractive, { promptMessage: "Which workspace is the app in?" });
|
|
253836
|
+
const projects = await ctx.runTask("Fetching projects...", () => listProjects({ workspaceId }), {
|
|
253837
|
+
successMessage: "Projects fetched",
|
|
253838
|
+
errorMessage: "Failed to fetch projects"
|
|
253839
|
+
});
|
|
253840
|
+
const linkableProjects = projects.filter((p) => p.isManagedSourceCode !== true);
|
|
253841
|
+
if (!linkableProjects.length) {
|
|
253842
|
+
return;
|
|
253843
|
+
}
|
|
253844
|
+
const selectedProject = await promptForExistingProject(linkableProjects);
|
|
253845
|
+
return selectedProject.id;
|
|
253846
|
+
}
|
|
253818
253847
|
async function link(ctx, options, command2) {
|
|
253819
253848
|
const { log, runTask: runTask2, isNonInteractive } = ctx;
|
|
253820
253849
|
const appId = readExplicitAppId(command2).value;
|
|
@@ -253838,32 +253867,10 @@ async function link(ctx, options, command2) {
|
|
|
253838
253867
|
let finalAppId;
|
|
253839
253868
|
const action = appId ? "choose" : options.create ? "create" : await promptForLinkAction();
|
|
253840
253869
|
if (action === "choose") {
|
|
253841
|
-
const
|
|
253842
|
-
|
|
253843
|
-
errorMessage: "Failed to fetch projects"
|
|
253844
|
-
});
|
|
253845
|
-
const linkableProjects = projects.filter((p) => p.isManagedSourceCode !== true);
|
|
253846
|
-
if (!linkableProjects.length) {
|
|
253870
|
+
const linkedAppId = appId ? await resolveExplicitAppId(ctx, appId) : await chooseProjectInteractively(ctx, options);
|
|
253871
|
+
if (!linkedAppId) {
|
|
253847
253872
|
return { outroMessage: "No projects available for linking" };
|
|
253848
253873
|
}
|
|
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
253874
|
await runTask2("Linking project...", async () => {
|
|
253868
253875
|
await writeAppConfig(projectRoot.root, linkedAppId);
|
|
253869
253876
|
setAppContext({ id: linkedAppId, projectRoot: projectRoot.root });
|
|
@@ -253892,7 +253899,7 @@ async function link(ctx, options, command2) {
|
|
|
253892
253899
|
function getLinkCommand() {
|
|
253893
253900
|
return new Base44Command("link", {
|
|
253894
253901
|
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
|
|
253902
|
+
}).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
253903
|
}
|
|
253897
253904
|
|
|
253898
253905
|
// src/cli/commands/project/logs.ts
|
|
@@ -254320,10 +254327,6 @@ async function resolveFlagOrStdin(flagValue, flagName) {
|
|
|
254320
254327
|
}
|
|
254321
254328
|
return readStdin(flagName, { trim: false });
|
|
254322
254329
|
}
|
|
254323
|
-
function toJsonStdout(result) {
|
|
254324
|
-
return `${JSON.stringify(result, null, 2)}
|
|
254325
|
-
`;
|
|
254326
|
-
}
|
|
254327
254330
|
function parsePositiveInt(value, flagName) {
|
|
254328
254331
|
if (value === undefined) {
|
|
254329
254332
|
return;
|
|
@@ -254761,77 +254764,76 @@ function getTypesCommand() {
|
|
|
254761
254764
|
}
|
|
254762
254765
|
|
|
254763
254766
|
// src/cli/commands/workspace/shared.ts
|
|
254764
|
-
function toJsonStdout2(result) {
|
|
254765
|
-
return `${JSON.stringify(result, null, 2)}
|
|
254766
|
-
`;
|
|
254767
|
-
}
|
|
254768
254767
|
function workspaceTag(workspace2) {
|
|
254769
254768
|
const role = workspace2.userRole ?? "member";
|
|
254770
254769
|
return workspace2.isPersonal ? `personal, ${role}` : role;
|
|
254771
254770
|
}
|
|
254772
254771
|
|
|
254772
|
+
// src/cli/commands/workspace/get.ts
|
|
254773
|
+
async function getWorkspaceAction({ runTask: runTask2, log, jsonMode }, workspaceId) {
|
|
254774
|
+
const workspace2 = await runTask2("Fetching workspace...", () => getWorkspace(workspaceId), { errorMessage: "Failed to fetch workspace" });
|
|
254775
|
+
if (!workspace2) {
|
|
254776
|
+
throw new InvalidInputError(`Workspace "${workspaceId}" not found, or you are not a member of it.`, {
|
|
254777
|
+
hints: [
|
|
254778
|
+
{ message: "Run 'base44 workspace list' to see your workspaces" }
|
|
254779
|
+
]
|
|
254780
|
+
});
|
|
254781
|
+
}
|
|
254782
|
+
if (jsonMode) {
|
|
254783
|
+
return {
|
|
254784
|
+
outroMessage: workspace2.name,
|
|
254785
|
+
stdout: toJsonStdout(workspace2)
|
|
254786
|
+
};
|
|
254787
|
+
}
|
|
254788
|
+
log.message(` ${theme.styles.bold(workspace2.name)} ${theme.styles.dim(`[${workspaceTag(workspace2)}]`)}
|
|
254789
|
+
${theme.styles.dim(workspace2.id)}${workspace2.subscriptionTier ? theme.styles.dim(`
|
|
254790
|
+
tier: ${workspace2.subscriptionTier}`) : ""}`);
|
|
254791
|
+
return { outroMessage: workspace2.name };
|
|
254792
|
+
}
|
|
254793
|
+
function getWorkspaceGetCommand() {
|
|
254794
|
+
return new Base44Command("get", { requireAppContext: false }).description("Show details for a single workspace by ID").argument("<workspace-id>", "Workspace (organization) ID").action(getWorkspaceAction);
|
|
254795
|
+
}
|
|
254796
|
+
|
|
254773
254797
|
// src/cli/commands/workspace/list.ts
|
|
254774
|
-
|
|
254775
|
-
|
|
254776
|
-
|
|
254777
|
-
|
|
254778
|
-
|
|
254779
|
-
|
|
254798
|
+
function pluralize2(n5) {
|
|
254799
|
+
return `${n5} workspace${n5 !== 1 ? "s" : ""}`;
|
|
254800
|
+
}
|
|
254801
|
+
async function listWorkspacesAction({ log, runTask: runTask2, jsonMode }, options8) {
|
|
254802
|
+
let workspaces = await runTask2("Fetching workspaces...", () => listWorkspaces(), { errorMessage: "Failed to fetch workspaces" });
|
|
254803
|
+
if (options8.role) {
|
|
254804
|
+
const role = options8.role.toLowerCase();
|
|
254805
|
+
workspaces = workspaces.filter((w8) => w8.userRole?.toLowerCase() === role);
|
|
254806
|
+
}
|
|
254780
254807
|
if (jsonMode) {
|
|
254781
254808
|
return {
|
|
254782
|
-
outroMessage:
|
|
254783
|
-
stdout:
|
|
254809
|
+
outroMessage: pluralize2(workspaces.length),
|
|
254810
|
+
stdout: toJsonStdout(workspaces)
|
|
254784
254811
|
};
|
|
254785
254812
|
}
|
|
254786
254813
|
for (const workspace2 of workspaces) {
|
|
254787
254814
|
log.message(` ${theme.styles.bold(workspace2.name)} ${theme.styles.dim(`[${workspaceTag(workspace2)}]`)}
|
|
254788
254815
|
${theme.styles.dim(workspace2.id)}`);
|
|
254789
254816
|
}
|
|
254790
|
-
return {
|
|
254791
|
-
outroMessage: `${workspaces.length} workspace${workspaces.length !== 1 ? "s" : ""}`
|
|
254792
|
-
};
|
|
254817
|
+
return { outroMessage: pluralize2(workspaces.length) };
|
|
254793
254818
|
}
|
|
254794
254819
|
function getWorkspaceListCommand() {
|
|
254795
|
-
return new Base44Command("list", { requireAppContext: false }).description("List the workspaces you belong to").action(listWorkspacesAction);
|
|
254820
|
+
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);
|
|
254796
254821
|
}
|
|
254797
254822
|
|
|
254798
254823
|
// src/cli/commands/workspace/move.ts
|
|
254799
|
-
function
|
|
254800
|
-
|
|
254801
|
-
|
|
254802
|
-
|
|
254803
|
-
|
|
254804
|
-
|
|
254805
|
-
|
|
254806
|
-
|
|
254807
|
-
|
|
254808
|
-
|
|
254809
|
-
throw new InvalidInputError(`Workspace "${target}" not found, or you are not a member of it.`, {
|
|
254810
|
-
hints: [
|
|
254811
|
-
{ message: "Run 'base44 workspace list' to see your workspaces" }
|
|
254812
|
-
]
|
|
254813
|
-
});
|
|
254814
|
-
}
|
|
254815
|
-
if (target === currentWorkspaceId) {
|
|
254816
|
-
throw new InvalidInputError("The app is already in that workspace.");
|
|
254817
|
-
}
|
|
254818
|
-
if (!canCreateAppsInWorkspace(match.userRole)) {
|
|
254819
|
-
throw new InvalidInputError(`You don't have permission to move apps into workspace "${match.name}" (your role: ${match.userRole ?? "unknown"}).`);
|
|
254820
|
-
}
|
|
254821
|
-
return match.id;
|
|
254822
|
-
}
|
|
254823
|
-
if (!isInteractive) {
|
|
254824
|
-
throw new InvalidInputError("A target workspace ID is required in non-interactive mode.", {
|
|
254825
|
-
hints: [
|
|
254826
|
-
{ message: "Usage: base44 workspace move <workspace-id>" },
|
|
254827
|
-
{ message: "Run 'base44 workspace list' to see your workspaces" }
|
|
254828
|
-
]
|
|
254829
|
-
});
|
|
254830
|
-
}
|
|
254831
|
-
if (eligible.length === 0) {
|
|
254824
|
+
async function promptForTargetWorkspace(ctx, appId) {
|
|
254825
|
+
const { workspaces, currentWorkspaceId } = await ctx.runTask("Fetching workspaces...", async () => {
|
|
254826
|
+
const [workspaces2, app] = await Promise.all([
|
|
254827
|
+
listWorkspaces(),
|
|
254828
|
+
getApp(appId)
|
|
254829
|
+
]);
|
|
254830
|
+
return { workspaces: workspaces2, currentWorkspaceId: app.organizationId };
|
|
254831
|
+
}, { errorMessage: "Failed to fetch workspaces" });
|
|
254832
|
+
const destinations = workspaces.filter((w8) => w8.id !== currentWorkspaceId);
|
|
254833
|
+
if (destinations.length === 0) {
|
|
254832
254834
|
throw new InvalidInputError("No other workspaces available to move this app into.");
|
|
254833
254835
|
}
|
|
254834
|
-
const options8 =
|
|
254836
|
+
const options8 = destinations.map((w8) => ({
|
|
254835
254837
|
value: w8.id,
|
|
254836
254838
|
label: `${w8.name} (${w8.userRole ?? "member"})`
|
|
254837
254839
|
}));
|
|
@@ -254842,42 +254844,64 @@ async function resolveTargetWorkspace(target, workspaces, currentWorkspaceId, is
|
|
|
254842
254844
|
if (Ct(selected)) {
|
|
254843
254845
|
onPromptCancel();
|
|
254844
254846
|
}
|
|
254845
|
-
|
|
254847
|
+
const targetWorkspaceId = selected;
|
|
254848
|
+
const nameOf = (id2) => workspaces.find((w8) => w8.id === id2)?.name ?? id2 ?? "unknown workspace";
|
|
254849
|
+
return {
|
|
254850
|
+
targetWorkspaceId,
|
|
254851
|
+
fromName: nameOf(currentWorkspaceId),
|
|
254852
|
+
toName: nameOf(targetWorkspaceId)
|
|
254853
|
+
};
|
|
254846
254854
|
}
|
|
254847
254855
|
async function moveAction(ctx, target, options8) {
|
|
254848
254856
|
const { runTask: runTask2, isNonInteractive, jsonMode } = ctx;
|
|
254849
254857
|
const isInteractive = !isNonInteractive && !jsonMode;
|
|
254850
254858
|
const { id: appId } = getAppContext();
|
|
254851
|
-
|
|
254852
|
-
|
|
254853
|
-
|
|
254854
|
-
|
|
254855
|
-
|
|
254856
|
-
|
|
254857
|
-
|
|
254858
|
-
|
|
254859
|
-
|
|
254860
|
-
|
|
254861
|
-
|
|
254862
|
-
|
|
254863
|
-
|
|
254864
|
-
|
|
254859
|
+
let targetWorkspaceId;
|
|
254860
|
+
let toLabel;
|
|
254861
|
+
if (target) {
|
|
254862
|
+
targetWorkspaceId = target;
|
|
254863
|
+
toLabel = target;
|
|
254864
|
+
if (isInteractive && !options8.yes) {
|
|
254865
|
+
const proceed = await Re({
|
|
254866
|
+
message: `Move this app to workspace ${theme.styles.bold(target)}?`
|
|
254867
|
+
});
|
|
254868
|
+
if (Ct(proceed)) {
|
|
254869
|
+
onPromptCancel();
|
|
254870
|
+
}
|
|
254871
|
+
if (!proceed) {
|
|
254872
|
+
return { outroMessage: "Move cancelled" };
|
|
254873
|
+
}
|
|
254865
254874
|
}
|
|
254866
|
-
|
|
254867
|
-
|
|
254875
|
+
} else if (isInteractive) {
|
|
254876
|
+
const picked = await promptForTargetWorkspace(ctx, appId);
|
|
254877
|
+
targetWorkspaceId = picked.targetWorkspaceId;
|
|
254878
|
+
toLabel = picked.toName;
|
|
254879
|
+
if (!options8.yes) {
|
|
254880
|
+
const proceed = await Re({
|
|
254881
|
+
message: `Move this app from ${theme.styles.bold(picked.fromName)} to ${theme.styles.bold(picked.toName)}?`
|
|
254882
|
+
});
|
|
254883
|
+
if (Ct(proceed)) {
|
|
254884
|
+
onPromptCancel();
|
|
254885
|
+
}
|
|
254886
|
+
if (!proceed) {
|
|
254887
|
+
return { outroMessage: "Move cancelled" };
|
|
254888
|
+
}
|
|
254868
254889
|
}
|
|
254890
|
+
} else {
|
|
254891
|
+
throw new InvalidInputError("A target workspace ID is required in non-interactive mode.", {
|
|
254892
|
+
hints: [
|
|
254893
|
+
{ message: "Usage: base44 workspace move <workspace-id>" },
|
|
254894
|
+
{ message: "Run 'base44 workspace list' to see your workspaces" }
|
|
254895
|
+
]
|
|
254896
|
+
});
|
|
254869
254897
|
}
|
|
254870
254898
|
const result = await runTask2("Moving app to workspace...", () => moveAppToWorkspace(appId, targetWorkspaceId, {
|
|
254871
254899
|
disconnectIntegrations: options8.disconnectIntegrations
|
|
254872
254900
|
}), { errorMessage: "Failed to move app" });
|
|
254873
|
-
const targetName = workspaceName(workspaces, targetWorkspaceId);
|
|
254874
254901
|
if (jsonMode) {
|
|
254875
|
-
return {
|
|
254876
|
-
outroMessage: `App moved to ${targetName}`,
|
|
254877
|
-
stdout: toJsonStdout2(result)
|
|
254878
|
-
};
|
|
254902
|
+
return { outroMessage: "App moved", stdout: toJsonStdout(result) };
|
|
254879
254903
|
}
|
|
254880
|
-
return { outroMessage: `App moved to ${theme.styles.bold(
|
|
254904
|
+
return { outroMessage: `App moved to ${theme.styles.bold(toLabel)}` };
|
|
254881
254905
|
}
|
|
254882
254906
|
function getWorkspaceMoveCommand() {
|
|
254883
254907
|
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", `
|
|
@@ -254888,7 +254912,7 @@ Examples:
|
|
|
254888
254912
|
|
|
254889
254913
|
// src/cli/commands/workspace/index.ts
|
|
254890
254914
|
function getWorkspaceCommand() {
|
|
254891
|
-
return new Command("workspace").description("List workspaces and move apps between them").addCommand(getWorkspaceListCommand()).addCommand(getWorkspaceMoveCommand());
|
|
254915
|
+
return new Command("workspace").description("List workspaces, inspect one, and move apps between them").addCommand(getWorkspaceListCommand()).addCommand(getWorkspaceGetCommand()).addCommand(getWorkspaceMoveCommand());
|
|
254892
254916
|
}
|
|
254893
254917
|
|
|
254894
254918
|
// src/cli/dev/dev-server/main.ts
|
|
@@ -262921,4 +262945,4 @@ export {
|
|
|
262921
262945
|
CLIExitError
|
|
262922
262946
|
};
|
|
262923
262947
|
|
|
262924
|
-
//# debugId=
|
|
262948
|
+
//# debugId=BE50FE58EDC1DC8A64756E2164756E21
|