@base44-preview/cli 0.0.32-pr.249.063e424 → 0.0.32-pr.249.0888dcb
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/LICENSE +21 -0
- package/dist/cli/index.js +58 -122
- package/dist/cli/index.js.map +6 -6
- package/package.json +2 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 base44
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/cli/index.js
CHANGED
|
@@ -193495,7 +193495,7 @@ var package_default = {
|
|
|
193495
193495
|
"command-line"
|
|
193496
193496
|
],
|
|
193497
193497
|
author: "",
|
|
193498
|
-
license: "
|
|
193498
|
+
license: "MIT",
|
|
193499
193499
|
repository: {
|
|
193500
193500
|
type: "git",
|
|
193501
193501
|
url: "https://github.com/base44/cli"
|
|
@@ -195352,49 +195352,20 @@ async function getPorts(options8) {
|
|
|
195352
195352
|
}
|
|
195353
195353
|
|
|
195354
195354
|
// src/cli/dev/dev-server/main.ts
|
|
195355
|
-
var
|
|
195355
|
+
var import_http_proxy_middleware2 = __toESM(require_dist2(), 1);
|
|
195356
195356
|
|
|
195357
195357
|
// src/cli/dev/createDevLogger.ts
|
|
195358
|
-
var dateTimeFormat = new Intl.DateTimeFormat([], {
|
|
195359
|
-
hour: "2-digit",
|
|
195360
|
-
minute: "2-digit",
|
|
195361
|
-
second: "2-digit",
|
|
195362
|
-
hour12: false
|
|
195363
|
-
});
|
|
195364
195358
|
var colorByType = {
|
|
195365
195359
|
error: theme.styles.error,
|
|
195366
195360
|
warn: theme.styles.warn,
|
|
195367
195361
|
log: (text) => text
|
|
195368
195362
|
};
|
|
195369
|
-
function createDevLogger(
|
|
195363
|
+
function createDevLogger() {
|
|
195370
195364
|
const print = (type, msg) => {
|
|
195371
195365
|
const colorize = colorByType[type];
|
|
195372
|
-
|
|
195373
|
-
case "error":
|
|
195374
|
-
console.error(colorize(msg));
|
|
195375
|
-
break;
|
|
195376
|
-
case "warn":
|
|
195377
|
-
console.warn(colorize(msg));
|
|
195378
|
-
break;
|
|
195379
|
-
default:
|
|
195380
|
-
console.log(msg);
|
|
195381
|
-
}
|
|
195382
|
-
};
|
|
195383
|
-
const prefixedLog = (type, msg) => {
|
|
195384
|
-
const timestamp = dateTimeFormat.format(new Date);
|
|
195385
|
-
const colorize = colorByType[type];
|
|
195386
|
-
console.log(`${theme.styles.dim(timestamp)} ${colorize(msg)}`);
|
|
195366
|
+
console[type](colorize(msg));
|
|
195387
195367
|
};
|
|
195388
|
-
return
|
|
195389
|
-
log: (msg) => prefixedLog("log", msg),
|
|
195390
|
-
error: (msg, err) => {
|
|
195391
|
-
prefixedLog("error", msg);
|
|
195392
|
-
if (err) {
|
|
195393
|
-
prefixedLog("error", String(err));
|
|
195394
|
-
}
|
|
195395
|
-
},
|
|
195396
|
-
warn: (msg) => prefixedLog("warn", msg)
|
|
195397
|
-
} : {
|
|
195368
|
+
return {
|
|
195398
195369
|
log: (msg) => print("log", msg),
|
|
195399
195370
|
error: (msg, err) => {
|
|
195400
195371
|
print("error", msg);
|
|
@@ -195423,12 +195394,9 @@ class FunctionManager {
|
|
|
195423
195394
|
this.functions = new Map(functions.map((f7) => [f7.name, f7]));
|
|
195424
195395
|
this.logger = logger;
|
|
195425
195396
|
}
|
|
195426
|
-
|
|
195397
|
+
getFunctionNames() {
|
|
195427
195398
|
return Array.from(this.functions.keys());
|
|
195428
195399
|
}
|
|
195429
|
-
getFunction(name2) {
|
|
195430
|
-
return this.functions.get(name2);
|
|
195431
|
-
}
|
|
195432
195400
|
verifyDenoIsInstalled() {
|
|
195433
195401
|
if (this.functions.size > 0) {
|
|
195434
195402
|
const result = spawnSync2("deno", ["--version"]);
|
|
@@ -195440,6 +195408,12 @@ class FunctionManager {
|
|
|
195440
195408
|
}
|
|
195441
195409
|
}
|
|
195442
195410
|
async ensureRunning(name2) {
|
|
195411
|
+
const backendFunction = this.functions.get(name2);
|
|
195412
|
+
if (!backendFunction) {
|
|
195413
|
+
throw new InvalidInputError(`Function "${name2}" not found`, {
|
|
195414
|
+
hints: [{ message: "Check available functions in your project" }]
|
|
195415
|
+
});
|
|
195416
|
+
}
|
|
195443
195417
|
const existing = this.running.get(name2);
|
|
195444
195418
|
if (existing?.ready) {
|
|
195445
195419
|
return existing.port;
|
|
@@ -195448,12 +195422,6 @@ class FunctionManager {
|
|
|
195448
195422
|
if (pending) {
|
|
195449
195423
|
return pending;
|
|
195450
195424
|
}
|
|
195451
|
-
const backendFunction = this.functions.get(name2);
|
|
195452
|
-
if (!backendFunction) {
|
|
195453
|
-
throw new InvalidInputError(`Function "${name2}" not found`, {
|
|
195454
|
-
hints: [{ message: "Check available functions in your project" }]
|
|
195455
|
-
});
|
|
195456
|
-
}
|
|
195457
195425
|
const promise2 = this.startFunction(name2, backendFunction);
|
|
195458
195426
|
this.starting.set(name2, promise2);
|
|
195459
195427
|
try {
|
|
@@ -195474,10 +195442,6 @@ class FunctionManager {
|
|
|
195474
195442
|
this.setupProcessHandlers(name2, process21);
|
|
195475
195443
|
return this.waitForReady(name2, runningFunc);
|
|
195476
195444
|
}
|
|
195477
|
-
getPort(name2) {
|
|
195478
|
-
const running = this.running.get(name2);
|
|
195479
|
-
return running?.ready ? running.port : undefined;
|
|
195480
|
-
}
|
|
195481
195445
|
stopAll() {
|
|
195482
195446
|
for (const [name2, { process: process21 }] of this.running) {
|
|
195483
195447
|
this.logger.log(`[dev-server] Stopping function: ${name2}`);
|
|
@@ -195537,6 +195501,14 @@ class FunctionManager {
|
|
|
195537
195501
|
}
|
|
195538
195502
|
waitForReady(name2, runningFunc) {
|
|
195539
195503
|
return new Promise((resolve5, reject) => {
|
|
195504
|
+
runningFunc.process.on("exit", (code2) => {
|
|
195505
|
+
if (!runningFunc.ready) {
|
|
195506
|
+
clearTimeout(timeout3);
|
|
195507
|
+
reject(new InternalError(`Function "${name2}" exited with code ${code2}`, {
|
|
195508
|
+
hints: [{ message: "Check the function code for errors" }]
|
|
195509
|
+
}));
|
|
195510
|
+
}
|
|
195511
|
+
});
|
|
195540
195512
|
const timeout3 = setTimeout(() => {
|
|
195541
195513
|
runningFunc.process.kill();
|
|
195542
195514
|
reject(new InternalError(`Function "${name2}" failed to start within ${READY_TIMEOUT / 1000}s timeout`, {
|
|
@@ -195555,90 +195527,54 @@ class FunctionManager {
|
|
|
195555
195527
|
}
|
|
195556
195528
|
};
|
|
195557
195529
|
runningFunc.process.stdout?.on("data", onData);
|
|
195558
|
-
runningFunc.process.on("exit", (code2) => {
|
|
195559
|
-
if (!runningFunc.ready) {
|
|
195560
|
-
clearTimeout(timeout3);
|
|
195561
|
-
reject(new InternalError(`Function "${name2}" exited with code ${code2}`, {
|
|
195562
|
-
hints: [{ message: "Check the function code for errors" }]
|
|
195563
|
-
}));
|
|
195564
|
-
}
|
|
195565
|
-
});
|
|
195566
195530
|
});
|
|
195567
195531
|
}
|
|
195568
195532
|
}
|
|
195569
195533
|
|
|
195570
195534
|
// src/cli/dev/dev-server/routes/functions.ts
|
|
195571
195535
|
var import_express = __toESM(require_express(), 1);
|
|
195572
|
-
|
|
195573
|
-
|
|
195536
|
+
var import_http_proxy_middleware = __toESM(require_dist2(), 1);
|
|
195537
|
+
import { ServerResponse } from "node:http";
|
|
195538
|
+
function createFunctionRouter(manager, logger) {
|
|
195574
195539
|
const router = import_express.Router({ mergeParams: true });
|
|
195575
|
-
|
|
195540
|
+
const portsByRequest = new WeakMap;
|
|
195541
|
+
const proxy = import_http_proxy_middleware.createProxyMiddleware({
|
|
195542
|
+
router: (req) => `http://localhost:${portsByRequest.get(req)}`,
|
|
195543
|
+
changeOrigin: true,
|
|
195544
|
+
on: {
|
|
195545
|
+
proxyReq: (proxyReq, req) => {
|
|
195546
|
+
const xAppId = req.headers["x-app-id"];
|
|
195547
|
+
if (xAppId) {
|
|
195548
|
+
proxyReq.setHeader("Base44-App-Id", xAppId);
|
|
195549
|
+
}
|
|
195550
|
+
proxyReq.setHeader("Base44-Api-Url", `${req.protocol}://${req.headers.host}`);
|
|
195551
|
+
},
|
|
195552
|
+
error: (err, _req, res) => {
|
|
195553
|
+
logger.error("Function proxy error:", err);
|
|
195554
|
+
if (res instanceof ServerResponse && !res.headersSent) {
|
|
195555
|
+
res.writeHead(502, { "Content-Type": "application/json" });
|
|
195556
|
+
res.end(JSON.stringify({
|
|
195557
|
+
error: "Failed to proxy request to function",
|
|
195558
|
+
details: err.message
|
|
195559
|
+
}));
|
|
195560
|
+
}
|
|
195561
|
+
}
|
|
195562
|
+
}
|
|
195563
|
+
});
|
|
195564
|
+
router.all("/:functionName", async (req, res, next) => {
|
|
195576
195565
|
const { functionName } = req.params;
|
|
195577
195566
|
try {
|
|
195578
|
-
const func = manager.getFunction(functionName);
|
|
195579
|
-
if (!func) {
|
|
195580
|
-
res.status(404).json({
|
|
195581
|
-
error: `Function "${functionName}" not found`
|
|
195582
|
-
});
|
|
195583
|
-
return;
|
|
195584
|
-
}
|
|
195585
195567
|
const port = await manager.ensureRunning(functionName);
|
|
195586
|
-
|
|
195568
|
+
portsByRequest.set(req, port);
|
|
195569
|
+
next();
|
|
195587
195570
|
} catch (error48) {
|
|
195588
|
-
logger.error(
|
|
195571
|
+
logger.error("Function error:", error48);
|
|
195589
195572
|
const message = error48 instanceof Error ? error48.message : String(error48);
|
|
195590
195573
|
res.status(500).json({ error: message });
|
|
195591
195574
|
}
|
|
195592
|
-
});
|
|
195575
|
+
}, proxy);
|
|
195593
195576
|
return router;
|
|
195594
195577
|
}
|
|
195595
|
-
function proxyRequest(req, res, port, logger) {
|
|
195596
|
-
return new Promise((resolve5, reject) => {
|
|
195597
|
-
const headers = {
|
|
195598
|
-
...req.headers
|
|
195599
|
-
};
|
|
195600
|
-
delete headers.host;
|
|
195601
|
-
if (headers["x-app-id"]) {
|
|
195602
|
-
headers["Base44-App-Id"] = headers["x-app-id"];
|
|
195603
|
-
}
|
|
195604
|
-
headers["Base44-Api-Url"] = `${req.protocol}://${req.get("host")}`;
|
|
195605
|
-
const options8 = {
|
|
195606
|
-
hostname: "localhost",
|
|
195607
|
-
port,
|
|
195608
|
-
path: req.url,
|
|
195609
|
-
method: req.method,
|
|
195610
|
-
headers
|
|
195611
|
-
};
|
|
195612
|
-
const proxyReq = httpRequest(options8, (proxyRes) => {
|
|
195613
|
-
res.status(proxyRes.statusCode || 200);
|
|
195614
|
-
for (const [key2, value] of Object.entries(proxyRes.headers)) {
|
|
195615
|
-
if (value !== undefined) {
|
|
195616
|
-
res.setHeader(key2, value);
|
|
195617
|
-
}
|
|
195618
|
-
}
|
|
195619
|
-
proxyRes.pipe(res);
|
|
195620
|
-
proxyRes.on("end", () => {
|
|
195621
|
-
resolve5();
|
|
195622
|
-
});
|
|
195623
|
-
proxyRes.on("error", (error48) => {
|
|
195624
|
-
reject(error48);
|
|
195625
|
-
});
|
|
195626
|
-
});
|
|
195627
|
-
proxyReq.on("error", (error48) => {
|
|
195628
|
-
logger.error(`Function proxy error:`, error48);
|
|
195629
|
-
if (!res.headersSent) {
|
|
195630
|
-
res.status(502).json({
|
|
195631
|
-
error: "Failed to proxy request to function",
|
|
195632
|
-
details: error48.message
|
|
195633
|
-
});
|
|
195634
|
-
res.once("finish", resolve5);
|
|
195635
|
-
} else {
|
|
195636
|
-
resolve5();
|
|
195637
|
-
}
|
|
195638
|
-
});
|
|
195639
|
-
req.pipe(proxyReq);
|
|
195640
|
-
});
|
|
195641
|
-
}
|
|
195642
195578
|
|
|
195643
195579
|
// src/cli/dev/dev-server/main.ts
|
|
195644
195580
|
var DEFAULT_PORT = 4400;
|
|
@@ -195649,7 +195585,7 @@ async function createDevServer(options8) {
|
|
|
195649
195585
|
const { project: project2 } = await readProjectConfig();
|
|
195650
195586
|
const configDir = dirname12(project2.configPath);
|
|
195651
195587
|
const app = import_express2.default();
|
|
195652
|
-
const remoteProxy =
|
|
195588
|
+
const remoteProxy = import_http_proxy_middleware2.createProxyMiddleware({
|
|
195653
195589
|
target: BASE44_APP_URL,
|
|
195654
195590
|
changeOrigin: true
|
|
195655
195591
|
});
|
|
@@ -195666,13 +195602,13 @@ async function createDevServer(options8) {
|
|
|
195666
195602
|
next();
|
|
195667
195603
|
});
|
|
195668
195604
|
const functions = await functionResource.readAll(join16(configDir, project2.functionsDir));
|
|
195669
|
-
const devLogger = createDevLogger(
|
|
195605
|
+
const devLogger = createDevLogger();
|
|
195670
195606
|
const functionManager = new FunctionManager(functions, devLogger);
|
|
195671
195607
|
functionManager.verifyDenoIsInstalled();
|
|
195672
|
-
if (functionManager.
|
|
195673
|
-
M2.info(`Loaded functions: ${functionManager.
|
|
195608
|
+
if (functionManager.getFunctionNames().length > 0) {
|
|
195609
|
+
M2.info(`Loaded functions: ${functionManager.getFunctionNames().join(", ")}`);
|
|
195674
195610
|
}
|
|
195675
|
-
const functionRoutes =
|
|
195611
|
+
const functionRoutes = createFunctionRouter(functionManager, devLogger);
|
|
195676
195612
|
app.use("/api/apps/:appId/functions", functionRoutes);
|
|
195677
195613
|
app.use((req, res, next) => {
|
|
195678
195614
|
return remoteProxy(req, res, next);
|
|
@@ -200097,4 +200033,4 @@ export {
|
|
|
200097
200033
|
CLIExitError
|
|
200098
200034
|
};
|
|
200099
200035
|
|
|
200100
|
-
//# debugId=
|
|
200036
|
+
//# debugId=B4C79353BCDBC07064756E2164756E21
|