@base44-preview/cli 0.0.41-pr.381.83d161e → 0.0.41-pr.386.60085e2
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.
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deno Function Wrapper
|
|
3
|
+
*
|
|
4
|
+
* This script is executed by Deno to run user functions.
|
|
5
|
+
* It patches Deno.serve to inject a dynamic port before importing the user's function.
|
|
6
|
+
*
|
|
7
|
+
* Environment variables:
|
|
8
|
+
* - FUNCTION_PATH: Absolute path to the user's function entry file
|
|
9
|
+
* - FUNCTION_PORT: Port number for the function to listen on
|
|
10
|
+
* - FUNCTION_NAME: Name of the function (for logging)
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
// Make this file a module for top-level await support
|
|
14
|
+
export {};
|
|
15
|
+
|
|
16
|
+
const functionPath = Deno.env.get("FUNCTION_PATH");
|
|
17
|
+
const port = parseInt(Deno.env.get("FUNCTION_PORT") || "8000", 10);
|
|
18
|
+
const functionName = Deno.env.get("FUNCTION_NAME") || "unknown";
|
|
19
|
+
|
|
20
|
+
if (!functionPath) {
|
|
21
|
+
console.error("[wrapper] FUNCTION_PATH environment variable is required");
|
|
22
|
+
Deno.exit(1);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Store the original Deno.serve
|
|
26
|
+
const originalServe = Deno.serve.bind(Deno);
|
|
27
|
+
|
|
28
|
+
// Patch Deno.serve to inject our port and add onListen callback
|
|
29
|
+
// @ts-expect-error - We're intentionally overriding Deno.serve
|
|
30
|
+
Deno.serve = (
|
|
31
|
+
optionsOrHandler:
|
|
32
|
+
| Deno.ServeOptions
|
|
33
|
+
| Deno.ServeHandler
|
|
34
|
+
| (Deno.ServeOptions & { handler: Deno.ServeHandler }),
|
|
35
|
+
maybeHandler?: Deno.ServeHandler,
|
|
36
|
+
): Deno.HttpServer<Deno.NetAddr> => {
|
|
37
|
+
const onListen = () => {
|
|
38
|
+
// This message is used by FunctionManager to detect when the function is ready
|
|
39
|
+
console.log(`[${functionName}] Listening on http://localhost:${port}`);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// Handle the different Deno.serve signatures:
|
|
43
|
+
// 1. Deno.serve(handler)
|
|
44
|
+
// 2. Deno.serve(options, handler)
|
|
45
|
+
// 3. Deno.serve({ ...options, handler })
|
|
46
|
+
if (typeof optionsOrHandler === "function") {
|
|
47
|
+
// Signature: Deno.serve(handler)
|
|
48
|
+
return originalServe({ port, onListen }, optionsOrHandler);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (maybeHandler) {
|
|
52
|
+
// Signature: Deno.serve(options, handler)
|
|
53
|
+
return originalServe({ ...optionsOrHandler, port, onListen }, maybeHandler);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Signature: Deno.serve({ ...options, handler })
|
|
57
|
+
const options = optionsOrHandler as Deno.ServeOptions & {
|
|
58
|
+
handler: Deno.ServeHandler;
|
|
59
|
+
};
|
|
60
|
+
return originalServe({ ...options, port, onListen });
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
console.log(`[${functionName}] Starting function from ${functionPath}`);
|
|
64
|
+
|
|
65
|
+
// Dynamically import the user's function
|
|
66
|
+
// The function will call Deno.serve which is now patched to use our port
|
|
67
|
+
try {
|
|
68
|
+
await import(functionPath);
|
|
69
|
+
} catch (error) {
|
|
70
|
+
console.error(`[${functionName}] Failed to load function:`, error);
|
|
71
|
+
Deno.exit(1);
|
|
72
|
+
}
|
package/dist/cli/index.js
CHANGED
|
@@ -231169,16 +231169,6 @@ async function deployFunctions(functions) {
|
|
|
231169
231169
|
}
|
|
231170
231170
|
return result.data;
|
|
231171
231171
|
}
|
|
231172
|
-
async function deleteSingleFunction(name2) {
|
|
231173
|
-
const appClient = getAppClient();
|
|
231174
|
-
try {
|
|
231175
|
-
await appClient.delete(`backend-functions/${encodeURIComponent(name2)}`, {
|
|
231176
|
-
timeout: 60000
|
|
231177
|
-
});
|
|
231178
|
-
} catch (error48) {
|
|
231179
|
-
throw await ApiError.fromHttpError(error48, `deleting function "${name2}"`);
|
|
231180
|
-
}
|
|
231181
|
-
}
|
|
231182
231172
|
function buildLogsQueryString(filters) {
|
|
231183
231173
|
const params = new URLSearchParams;
|
|
231184
231174
|
if (filters.since) {
|
|
@@ -231559,7 +231549,7 @@ function getTemplatesIndexPath() {
|
|
|
231559
231549
|
return join7(ASSETS_DIR, "templates", "templates.json");
|
|
231560
231550
|
}
|
|
231561
231551
|
function getDenoWrapperPath() {
|
|
231562
|
-
return join7(ASSETS_DIR, "deno-runtime", "main.
|
|
231552
|
+
return join7(ASSETS_DIR, "deno-runtime", "main.ts");
|
|
231563
231553
|
}
|
|
231564
231554
|
function ensureNpmAssets(sourceDir) {
|
|
231565
231555
|
if (existsSync(ASSETS_DIR))
|
|
@@ -240347,63 +240337,6 @@ function getEntitiesPushCommand(context) {
|
|
|
240347
240337
|
}));
|
|
240348
240338
|
}
|
|
240349
240339
|
|
|
240350
|
-
// src/cli/utils/parseNames.ts
|
|
240351
|
-
function parseNames(args) {
|
|
240352
|
-
return args.flatMap((arg) => arg.split(",")).map((n2) => n2.trim()).filter(Boolean);
|
|
240353
|
-
}
|
|
240354
|
-
|
|
240355
|
-
// src/cli/commands/functions/delete.ts
|
|
240356
|
-
async function deleteFunctionsAction(names) {
|
|
240357
|
-
let deleted = 0;
|
|
240358
|
-
let notFound = 0;
|
|
240359
|
-
let errors4 = 0;
|
|
240360
|
-
let completed = 0;
|
|
240361
|
-
const total = names.length;
|
|
240362
|
-
for (const name2 of names) {
|
|
240363
|
-
R2.step(theme.styles.dim(`[${completed + 1}/${total}] Deleting ${name2}...`));
|
|
240364
|
-
try {
|
|
240365
|
-
await deleteSingleFunction(name2);
|
|
240366
|
-
R2.success(`${name2.padEnd(25)} deleted`);
|
|
240367
|
-
deleted++;
|
|
240368
|
-
} catch (error48) {
|
|
240369
|
-
if (error48 instanceof ApiError && error48.statusCode === 404) {
|
|
240370
|
-
R2.warn(`${name2.padEnd(25)} not found`);
|
|
240371
|
-
notFound++;
|
|
240372
|
-
} else {
|
|
240373
|
-
R2.error(`${name2.padEnd(25)} error: ${error48 instanceof Error ? error48.message : String(error48)}`);
|
|
240374
|
-
errors4++;
|
|
240375
|
-
}
|
|
240376
|
-
}
|
|
240377
|
-
completed++;
|
|
240378
|
-
}
|
|
240379
|
-
if (names.length === 1) {
|
|
240380
|
-
if (deleted)
|
|
240381
|
-
return { outroMessage: `Function "${names[0]}" deleted` };
|
|
240382
|
-
if (notFound)
|
|
240383
|
-
return { outroMessage: `Function "${names[0]}" not found` };
|
|
240384
|
-
return { outroMessage: `Failed to delete "${names[0]}"` };
|
|
240385
|
-
}
|
|
240386
|
-
const parts = [];
|
|
240387
|
-
if (deleted > 0)
|
|
240388
|
-
parts.push(`${deleted}/${total} deleted`);
|
|
240389
|
-
if (notFound > 0)
|
|
240390
|
-
parts.push(`${notFound} not found`);
|
|
240391
|
-
if (errors4 > 0)
|
|
240392
|
-
parts.push(`${errors4} error${errors4 !== 1 ? "s" : ""}`);
|
|
240393
|
-
return { outroMessage: parts.join(", ") };
|
|
240394
|
-
}
|
|
240395
|
-
function getDeleteCommand(context) {
|
|
240396
|
-
return new Command("delete").description("Delete deployed functions").argument("<names...>", "Function names to delete").action(async (rawNames) => {
|
|
240397
|
-
await runCommand(() => {
|
|
240398
|
-
const names = parseNames(rawNames);
|
|
240399
|
-
if (names.length === 0) {
|
|
240400
|
-
throw new InvalidInputError("At least one function name is required");
|
|
240401
|
-
}
|
|
240402
|
-
return deleteFunctionsAction(names);
|
|
240403
|
-
}, { requireAuth: true }, context);
|
|
240404
|
-
});
|
|
240405
|
-
}
|
|
240406
|
-
|
|
240407
240340
|
// src/cli/commands/functions/deploy.ts
|
|
240408
240341
|
async function deployFunctionsAction() {
|
|
240409
240342
|
const { functions } = await readProjectConfig();
|
|
@@ -240436,15 +240369,10 @@ async function deployFunctionsAction() {
|
|
|
240436
240369
|
}
|
|
240437
240370
|
return { outroMessage: "Functions deployed to Base44" };
|
|
240438
240371
|
}
|
|
240439
|
-
function
|
|
240440
|
-
return new Command("deploy").description("Deploy local functions to Base44").action(async () => {
|
|
240372
|
+
function getFunctionsDeployCommand(context) {
|
|
240373
|
+
return new Command("functions").description("Manage project functions").addCommand(new Command("deploy").description("Deploy local functions to Base44").action(async () => {
|
|
240441
240374
|
await runCommand(deployFunctionsAction, { requireAuth: true }, context);
|
|
240442
|
-
});
|
|
240443
|
-
}
|
|
240444
|
-
|
|
240445
|
-
// src/cli/commands/functions/index.ts
|
|
240446
|
-
function getFunctionsCommand(context) {
|
|
240447
|
-
return new Command("functions").description("Manage backend functions").addCommand(getDeployCommand(context)).addCommand(getDeleteCommand(context));
|
|
240375
|
+
}));
|
|
240448
240376
|
}
|
|
240449
240377
|
|
|
240450
240378
|
// src/cli/commands/project/create.ts
|
|
@@ -240686,7 +240614,7 @@ ${summaryLines.join(`
|
|
|
240686
240614
|
}
|
|
240687
240615
|
return { outroMessage: "App deployed successfully" };
|
|
240688
240616
|
}
|
|
240689
|
-
function
|
|
240617
|
+
function getDeployCommand(context) {
|
|
240690
240618
|
return new Command("deploy").description("Deploy all project resources (entities, functions, agents, connectors, and site)").option("-y, --yes", "Skip confirmation prompt").action(async (options) => {
|
|
240691
240619
|
await runCommand(() => deployAction({
|
|
240692
240620
|
...options,
|
|
@@ -243923,13 +243851,13 @@ function createProgram(context) {
|
|
|
243923
243851
|
program2.addCommand(getLogoutCommand(context));
|
|
243924
243852
|
program2.addCommand(getCreateCommand(context));
|
|
243925
243853
|
program2.addCommand(getDashboardCommand(context));
|
|
243926
|
-
program2.addCommand(
|
|
243854
|
+
program2.addCommand(getDeployCommand(context));
|
|
243927
243855
|
program2.addCommand(getLinkCommand(context));
|
|
243928
243856
|
program2.addCommand(getEjectCommand(context));
|
|
243929
243857
|
program2.addCommand(getEntitiesPushCommand(context));
|
|
243930
243858
|
program2.addCommand(getAgentsCommand(context));
|
|
243931
243859
|
program2.addCommand(getConnectorsCommand(context));
|
|
243932
|
-
program2.addCommand(
|
|
243860
|
+
program2.addCommand(getFunctionsDeployCommand(context));
|
|
243933
243861
|
program2.addCommand(getSecretsCommand(context));
|
|
243934
243862
|
program2.addCommand(getSiteCommand(context));
|
|
243935
243863
|
program2.addCommand(getTypesCommand(context));
|
|
@@ -248175,4 +248103,4 @@ export {
|
|
|
248175
248103
|
CLIExitError
|
|
248176
248104
|
};
|
|
248177
248105
|
|
|
248178
|
-
//# debugId=
|
|
248106
|
+
//# debugId=56DB991BD2BD39CD64756E2164756E21
|