@base44-preview/cli 0.0.32-pr.265.44aca22 → 0.0.32-pr.266.84fc9f3
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 +51 -128
- package/dist/cli/index.js.map +6 -8
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -18485,7 +18485,7 @@ var require_lodash2 = __commonJS((exports, module) => {
|
|
|
18485
18485
|
result2[value] = [key];
|
|
18486
18486
|
}
|
|
18487
18487
|
}, getIteratee);
|
|
18488
|
-
var
|
|
18488
|
+
var invoke = baseRest(baseInvoke);
|
|
18489
18489
|
function keys(object2) {
|
|
18490
18490
|
return isArrayLike(object2) ? arrayLikeKeys(object2) : baseKeys(object2);
|
|
18491
18491
|
}
|
|
@@ -19340,7 +19340,7 @@ __p += '`;
|
|
|
19340
19340
|
lodash.includes = includes;
|
|
19341
19341
|
lodash.indexOf = indexOf;
|
|
19342
19342
|
lodash.inRange = inRange;
|
|
19343
|
-
lodash.invoke =
|
|
19343
|
+
lodash.invoke = invoke;
|
|
19344
19344
|
lodash.isArguments = isArguments;
|
|
19345
19345
|
lodash.isArray = isArray;
|
|
19346
19346
|
lodash.isArrayBuffer = isArrayBuffer2;
|
|
@@ -186073,81 +186073,6 @@ async function pushFunctions(functions) {
|
|
|
186073
186073
|
const functionsWithCode = await Promise.all(functions.map(loadFunctionCode));
|
|
186074
186074
|
return deployFunctions(functionsWithCode);
|
|
186075
186075
|
}
|
|
186076
|
-
// src/core/site/schema.ts
|
|
186077
|
-
var DeployResponseSchema = exports_external.object({
|
|
186078
|
-
app_url: exports_external.url()
|
|
186079
|
-
}).transform((data) => ({
|
|
186080
|
-
appUrl: data.app_url
|
|
186081
|
-
}));
|
|
186082
|
-
var PublishedUrlResponseSchema = exports_external.object({
|
|
186083
|
-
url: exports_external.string()
|
|
186084
|
-
});
|
|
186085
|
-
|
|
186086
|
-
// src/core/site/api.ts
|
|
186087
|
-
async function uploadSite(archivePath) {
|
|
186088
|
-
const archiveBuffer = await readFile(archivePath);
|
|
186089
|
-
const blob = new Blob([archiveBuffer], { type: "application/gzip" });
|
|
186090
|
-
const formData = new FormData;
|
|
186091
|
-
formData.append("file", blob, "dist.tar.gz");
|
|
186092
|
-
const appClient = getAppClient();
|
|
186093
|
-
let response;
|
|
186094
|
-
try {
|
|
186095
|
-
response = await appClient.post("deploy-dist", {
|
|
186096
|
-
body: formData,
|
|
186097
|
-
timeout: 180000
|
|
186098
|
-
});
|
|
186099
|
-
} catch (error48) {
|
|
186100
|
-
throw await ApiError.fromHttpError(error48, "deploying site");
|
|
186101
|
-
}
|
|
186102
|
-
const result = DeployResponseSchema.safeParse(await response.json());
|
|
186103
|
-
if (!result.success) {
|
|
186104
|
-
throw new SchemaValidationError("There was an issue deploying your site", result.error);
|
|
186105
|
-
}
|
|
186106
|
-
return result.data;
|
|
186107
|
-
}
|
|
186108
|
-
async function getSiteUrl(projectId) {
|
|
186109
|
-
const id = projectId ?? getAppConfig().id;
|
|
186110
|
-
let response;
|
|
186111
|
-
try {
|
|
186112
|
-
response = await base44Client.get(`api/apps/platform/${id}/published-url`);
|
|
186113
|
-
} catch (error48) {
|
|
186114
|
-
throw await ApiError.fromHttpError(error48, "fetching site URL");
|
|
186115
|
-
}
|
|
186116
|
-
const result = PublishedUrlResponseSchema.safeParse(await response.json());
|
|
186117
|
-
if (!result.success) {
|
|
186118
|
-
throw new SchemaValidationError("Invalid response from server", result.error);
|
|
186119
|
-
}
|
|
186120
|
-
return result.data.url;
|
|
186121
|
-
}
|
|
186122
|
-
|
|
186123
|
-
// src/core/resources/function/invoke.ts
|
|
186124
|
-
var METHODS_WITH_BODY = new Set(["POST", "PUT", "PATCH"]);
|
|
186125
|
-
async function invokeFunction(functionName, data, options) {
|
|
186126
|
-
const { id } = getAppConfig();
|
|
186127
|
-
const method = options?.method?.toUpperCase() ?? "POST";
|
|
186128
|
-
const siteUrl = await getSiteUrl();
|
|
186129
|
-
const url2 = `${siteUrl.replace(/\/+$/, "")}/api/functions/${functionName}`;
|
|
186130
|
-
const auth = await readAuth();
|
|
186131
|
-
let token = auth.accessToken;
|
|
186132
|
-
if (isTokenExpired(auth)) {
|
|
186133
|
-
const refreshed = await refreshAndSaveTokens();
|
|
186134
|
-
if (refreshed) {
|
|
186135
|
-
token = refreshed;
|
|
186136
|
-
}
|
|
186137
|
-
}
|
|
186138
|
-
const response = await distribution_default(url2, {
|
|
186139
|
-
method,
|
|
186140
|
-
...METHODS_WITH_BODY.has(method) ? { json: data } : {},
|
|
186141
|
-
headers: {
|
|
186142
|
-
Authorization: `Bearer ${token}`,
|
|
186143
|
-
"X-App-Id": id,
|
|
186144
|
-
"User-Agent": "Base44 CLI",
|
|
186145
|
-
...options?.headers
|
|
186146
|
-
},
|
|
186147
|
-
timeout: options?.timeout ?? 300000
|
|
186148
|
-
});
|
|
186149
|
-
return response.json();
|
|
186150
|
-
}
|
|
186151
186076
|
// src/core/resources/function/resource.ts
|
|
186152
186077
|
var functionResource = {
|
|
186153
186078
|
readAll: readAllFunctions,
|
|
@@ -186363,6 +186288,53 @@ async function createProjectFilesForExistingProject(options) {
|
|
|
186363
186288
|
}
|
|
186364
186289
|
// src/core/project/deploy.ts
|
|
186365
186290
|
import { resolve } from "node:path";
|
|
186291
|
+
|
|
186292
|
+
// src/core/site/schema.ts
|
|
186293
|
+
var DeployResponseSchema = exports_external.object({
|
|
186294
|
+
app_url: exports_external.url()
|
|
186295
|
+
}).transform((data) => ({
|
|
186296
|
+
appUrl: data.app_url
|
|
186297
|
+
}));
|
|
186298
|
+
var PublishedUrlResponseSchema = exports_external.object({
|
|
186299
|
+
url: exports_external.string()
|
|
186300
|
+
});
|
|
186301
|
+
|
|
186302
|
+
// src/core/site/api.ts
|
|
186303
|
+
async function uploadSite(archivePath) {
|
|
186304
|
+
const archiveBuffer = await readFile(archivePath);
|
|
186305
|
+
const blob = new Blob([archiveBuffer], { type: "application/gzip" });
|
|
186306
|
+
const formData = new FormData;
|
|
186307
|
+
formData.append("file", blob, "dist.tar.gz");
|
|
186308
|
+
const appClient = getAppClient();
|
|
186309
|
+
let response;
|
|
186310
|
+
try {
|
|
186311
|
+
response = await appClient.post("deploy-dist", {
|
|
186312
|
+
body: formData,
|
|
186313
|
+
timeout: 180000
|
|
186314
|
+
});
|
|
186315
|
+
} catch (error48) {
|
|
186316
|
+
throw await ApiError.fromHttpError(error48, "deploying site");
|
|
186317
|
+
}
|
|
186318
|
+
const result = DeployResponseSchema.safeParse(await response.json());
|
|
186319
|
+
if (!result.success) {
|
|
186320
|
+
throw new SchemaValidationError("There was an issue deploying your site", result.error);
|
|
186321
|
+
}
|
|
186322
|
+
return result.data;
|
|
186323
|
+
}
|
|
186324
|
+
async function getSiteUrl(projectId) {
|
|
186325
|
+
const id = projectId ?? getAppConfig().id;
|
|
186326
|
+
let response;
|
|
186327
|
+
try {
|
|
186328
|
+
response = await base44Client.get(`api/apps/platform/${id}/published-url`);
|
|
186329
|
+
} catch (error48) {
|
|
186330
|
+
throw await ApiError.fromHttpError(error48, "fetching site URL");
|
|
186331
|
+
}
|
|
186332
|
+
const result = PublishedUrlResponseSchema.safeParse(await response.json());
|
|
186333
|
+
if (!result.success) {
|
|
186334
|
+
throw new SchemaValidationError("Invalid response from server", result.error);
|
|
186335
|
+
}
|
|
186336
|
+
return result.data.url;
|
|
186337
|
+
}
|
|
186366
186338
|
// src/core/site/config.ts
|
|
186367
186339
|
async function getSiteFilePaths(outputDir) {
|
|
186368
186340
|
return await globby("**/*", {
|
|
@@ -195015,55 +194987,6 @@ function getEntitiesPushCommand(context) {
|
|
|
195015
194987
|
}));
|
|
195016
194988
|
}
|
|
195017
194989
|
|
|
195018
|
-
// src/cli/commands/functions/invoke.ts
|
|
195019
|
-
function collectHeader(value, previous) {
|
|
195020
|
-
const idx = value.indexOf(":");
|
|
195021
|
-
if (idx === -1) {
|
|
195022
|
-
throw new Error(`Invalid header (expected "Name: Value"): ${value}`);
|
|
195023
|
-
}
|
|
195024
|
-
const name2 = value.slice(0, idx).trim();
|
|
195025
|
-
const headerValue = value.slice(idx + 1).trim();
|
|
195026
|
-
return { ...previous, [name2]: headerValue };
|
|
195027
|
-
}
|
|
195028
|
-
function parseJsonArg(value) {
|
|
195029
|
-
try {
|
|
195030
|
-
const parsed = JSON.parse(value);
|
|
195031
|
-
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
195032
|
-
throw new Error("Data must be a JSON object");
|
|
195033
|
-
}
|
|
195034
|
-
return parsed;
|
|
195035
|
-
} catch (e2) {
|
|
195036
|
-
throw new Error(`Invalid JSON data: ${e2 instanceof Error ? e2.message : String(e2)}`);
|
|
195037
|
-
}
|
|
195038
|
-
}
|
|
195039
|
-
async function invokeFunctionAction(functionName, options) {
|
|
195040
|
-
const data = options.data ? parseJsonArg(options.data) : {};
|
|
195041
|
-
const method = options.method?.toUpperCase() ?? "POST";
|
|
195042
|
-
const timeout2 = options.timeout ? parseInt(options.timeout, 10) * 1000 : undefined;
|
|
195043
|
-
R2.info(`Invoking function ${theme.styles.bold(functionName)} (${method})`);
|
|
195044
|
-
const result = await runTask("Running function", async () => {
|
|
195045
|
-
return await invokeFunction(functionName, data, {
|
|
195046
|
-
timeout: timeout2,
|
|
195047
|
-
method,
|
|
195048
|
-
headers: options.header
|
|
195049
|
-
});
|
|
195050
|
-
}, {
|
|
195051
|
-
successMessage: "Function executed successfully",
|
|
195052
|
-
errorMessage: "Function execution failed"
|
|
195053
|
-
});
|
|
195054
|
-
const output = typeof result === "string" ? result : JSON.stringify(result, null, 2);
|
|
195055
|
-
R2.info(`Response:
|
|
195056
|
-
${output}`);
|
|
195057
|
-
return {
|
|
195058
|
-
outroMessage: `Function ${theme.styles.bold(functionName)} completed`
|
|
195059
|
-
};
|
|
195060
|
-
}
|
|
195061
|
-
function getFunctionsInvokeCommand(context) {
|
|
195062
|
-
return new Command("invoke").description("Invoke a deployed backend function").argument("<function-name>", "Name of the function to invoke").option("-X, --method <verb>", "HTTP method (default: POST)").option("-H, --header <header>", "Custom header (Name: Value), repeatable", collectHeader, {}).option("-d, --data <json>", "JSON data to send to the function").option("-t, --timeout <seconds>", "Timeout in seconds (default: 300)").action(async (functionName, options) => {
|
|
195063
|
-
await runCommand(() => invokeFunctionAction(functionName, options), { requireAuth: true }, context);
|
|
195064
|
-
});
|
|
195065
|
-
}
|
|
195066
|
-
|
|
195067
194990
|
// src/cli/commands/functions/deploy.ts
|
|
195068
194991
|
async function deployFunctionsAction() {
|
|
195069
194992
|
const { functions } = await readProjectConfig();
|
|
@@ -195101,7 +195024,7 @@ ${errorMessages}`, {
|
|
|
195101
195024
|
function getFunctionsDeployCommand(context) {
|
|
195102
195025
|
return new Command("functions").description("Manage project functions").addCommand(new Command("deploy").description("Deploy local functions to Base44").action(async () => {
|
|
195103
195026
|
await runCommand(deployFunctionsAction, { requireAuth: true }, context);
|
|
195104
|
-
}))
|
|
195027
|
+
}));
|
|
195105
195028
|
}
|
|
195106
195029
|
|
|
195107
195030
|
// src/cli/commands/project/create.ts
|
|
@@ -200240,4 +200163,4 @@ export {
|
|
|
200240
200163
|
CLIExitError
|
|
200241
200164
|
};
|
|
200242
200165
|
|
|
200243
|
-
//# debugId=
|
|
200166
|
+
//# debugId=8FF06F66318A4ACC64756E2164756E21
|