@base44-preview/cli 0.0.41-pr.381.83d161e → 0.0.41-pr.386.1c19d2c
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) {
|
|
@@ -231481,10 +231471,10 @@ var package_default = {
|
|
|
231481
231471
|
dev: "./bin/dev.ts",
|
|
231482
231472
|
start: "./bin/run.js",
|
|
231483
231473
|
clean: "rm -rf dist && mkdir -p dist",
|
|
231484
|
-
lint: "biome check src tests",
|
|
231485
|
-
"lint:fix": "biome check --write src tests",
|
|
231486
231474
|
test: "vitest run",
|
|
231487
231475
|
"test:watch": "vitest",
|
|
231476
|
+
lint: "cd ../.. && bun run lint",
|
|
231477
|
+
"lint:fix": "cd ../.. && bun run lint:fix",
|
|
231488
231478
|
"build:binaries": "bun run infra/build-binaries.ts",
|
|
231489
231479
|
"package:binaries": "bun run infra/package-binaries.ts"
|
|
231490
231480
|
},
|
|
@@ -231500,7 +231490,6 @@ var package_default = {
|
|
|
231500
231490
|
url: "https://github.com/base44/cli"
|
|
231501
231491
|
},
|
|
231502
231492
|
devDependencies: {
|
|
231503
|
-
"@biomejs/biome": "^2.0.0",
|
|
231504
231493
|
"@clack/prompts": "^1.0.1",
|
|
231505
231494
|
"@seald-io/nedb": "^4.1.2",
|
|
231506
231495
|
"@types/bun": "^1.2.15",
|
|
@@ -231559,7 +231548,7 @@ function getTemplatesIndexPath() {
|
|
|
231559
231548
|
return join7(ASSETS_DIR, "templates", "templates.json");
|
|
231560
231549
|
}
|
|
231561
231550
|
function getDenoWrapperPath() {
|
|
231562
|
-
return join7(ASSETS_DIR, "deno-runtime", "main.
|
|
231551
|
+
return join7(ASSETS_DIR, "deno-runtime", "main.ts");
|
|
231563
231552
|
}
|
|
231564
231553
|
function ensureNpmAssets(sourceDir) {
|
|
231565
231554
|
if (existsSync(ASSETS_DIR))
|
|
@@ -240347,63 +240336,6 @@ function getEntitiesPushCommand(context) {
|
|
|
240347
240336
|
}));
|
|
240348
240337
|
}
|
|
240349
240338
|
|
|
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
240339
|
// src/cli/commands/functions/deploy.ts
|
|
240408
240340
|
async function deployFunctionsAction() {
|
|
240409
240341
|
const { functions } = await readProjectConfig();
|
|
@@ -240436,15 +240368,10 @@ async function deployFunctionsAction() {
|
|
|
240436
240368
|
}
|
|
240437
240369
|
return { outroMessage: "Functions deployed to Base44" };
|
|
240438
240370
|
}
|
|
240439
|
-
function
|
|
240440
|
-
return new Command("deploy").description("Deploy local functions to Base44").action(async () => {
|
|
240371
|
+
function getFunctionsDeployCommand(context) {
|
|
240372
|
+
return new Command("functions").description("Manage project functions").addCommand(new Command("deploy").description("Deploy local functions to Base44").action(async () => {
|
|
240441
240373
|
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));
|
|
240374
|
+
}));
|
|
240448
240375
|
}
|
|
240449
240376
|
|
|
240450
240377
|
// src/cli/commands/project/create.ts
|
|
@@ -240686,7 +240613,7 @@ ${summaryLines.join(`
|
|
|
240686
240613
|
}
|
|
240687
240614
|
return { outroMessage: "App deployed successfully" };
|
|
240688
240615
|
}
|
|
240689
|
-
function
|
|
240616
|
+
function getDeployCommand(context) {
|
|
240690
240617
|
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
240618
|
await runCommand(() => deployAction({
|
|
240692
240619
|
...options,
|
|
@@ -243923,13 +243850,13 @@ function createProgram(context) {
|
|
|
243923
243850
|
program2.addCommand(getLogoutCommand(context));
|
|
243924
243851
|
program2.addCommand(getCreateCommand(context));
|
|
243925
243852
|
program2.addCommand(getDashboardCommand(context));
|
|
243926
|
-
program2.addCommand(
|
|
243853
|
+
program2.addCommand(getDeployCommand(context));
|
|
243927
243854
|
program2.addCommand(getLinkCommand(context));
|
|
243928
243855
|
program2.addCommand(getEjectCommand(context));
|
|
243929
243856
|
program2.addCommand(getEntitiesPushCommand(context));
|
|
243930
243857
|
program2.addCommand(getAgentsCommand(context));
|
|
243931
243858
|
program2.addCommand(getConnectorsCommand(context));
|
|
243932
|
-
program2.addCommand(
|
|
243859
|
+
program2.addCommand(getFunctionsDeployCommand(context));
|
|
243933
243860
|
program2.addCommand(getSecretsCommand(context));
|
|
243934
243861
|
program2.addCommand(getSiteCommand(context));
|
|
243935
243862
|
program2.addCommand(getTypesCommand(context));
|
|
@@ -248175,4 +248102,4 @@ export {
|
|
|
248175
248102
|
CLIExitError
|
|
248176
248103
|
};
|
|
248177
248104
|
|
|
248178
|
-
//# debugId=
|
|
248105
|
+
//# debugId=C89811ECE434F70F64756E2164756E21
|