@base44-preview/cli 0.0.32-pr.249.da1c23d → 0.0.32-pr.250.8053fb1
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 +9 -283
- package/dist/cli/index.js.map +6 -9
- package/package.json +1 -2
- package/dist/deno-runtime/main.js +0 -31
- package/dist/deno-runtime/main.js.map +0 -10
package/dist/cli/index.js
CHANGED
|
@@ -186024,7 +186024,7 @@ async function handleUnauthorized(request, _options, response) {
|
|
|
186024
186024
|
return;
|
|
186025
186025
|
}
|
|
186026
186026
|
retriedRequests.add(request);
|
|
186027
|
-
return distribution_default(request, {
|
|
186027
|
+
return distribution_default(request.clone(), {
|
|
186028
186028
|
headers: { Authorization: `Bearer ${newAccessToken}` }
|
|
186029
186029
|
});
|
|
186030
186030
|
}
|
|
@@ -193486,7 +193486,6 @@ var package_default = {
|
|
|
193486
193486
|
"@types/bun": "^1.2.15",
|
|
193487
193487
|
"@types/common-tags": "^1.8.4",
|
|
193488
193488
|
"@types/cors": "^2.8.19",
|
|
193489
|
-
"@types/deno": "^2.5.0",
|
|
193490
193489
|
"@types/ejs": "^3.1.5",
|
|
193491
193490
|
"@types/express": "^5.0.6",
|
|
193492
193491
|
"@types/json-schema": "^7.0.15",
|
|
@@ -195206,62 +195205,9 @@ function getTypesCommand(context) {
|
|
|
195206
195205
|
return new Command("types").description("Manage TypeScript type generation").addCommand(getTypesGenerateCommand(context));
|
|
195207
195206
|
}
|
|
195208
195207
|
|
|
195209
|
-
// src/cli/dev/createDevLogger.ts
|
|
195210
|
-
var dateTimeFormat = new Intl.DateTimeFormat([], {
|
|
195211
|
-
hour: "2-digit",
|
|
195212
|
-
minute: "2-digit",
|
|
195213
|
-
second: "2-digit",
|
|
195214
|
-
hour12: false
|
|
195215
|
-
});
|
|
195216
|
-
var colorByType = {
|
|
195217
|
-
error: source_default.red,
|
|
195218
|
-
warn: source_default.yellow,
|
|
195219
|
-
log: (text) => text
|
|
195220
|
-
};
|
|
195221
|
-
function createDevLogger(isPrefixed = true) {
|
|
195222
|
-
const print = (type, msg) => {
|
|
195223
|
-
const colorize = colorByType[type];
|
|
195224
|
-
switch (type) {
|
|
195225
|
-
case "error":
|
|
195226
|
-
console.error(colorize(msg));
|
|
195227
|
-
break;
|
|
195228
|
-
case "warn":
|
|
195229
|
-
console.warn(colorize(msg));
|
|
195230
|
-
break;
|
|
195231
|
-
default:
|
|
195232
|
-
console.log(msg);
|
|
195233
|
-
}
|
|
195234
|
-
};
|
|
195235
|
-
const prefixedLog = (type, msg) => {
|
|
195236
|
-
const timestamp = dateTimeFormat.format(new Date);
|
|
195237
|
-
const colorize = colorByType[type];
|
|
195238
|
-
console.log(`${source_default.gray(timestamp)} ${colorize(msg)}`);
|
|
195239
|
-
};
|
|
195240
|
-
return isPrefixed ? {
|
|
195241
|
-
log: (msg) => prefixedLog("log", msg),
|
|
195242
|
-
error: (msg, err) => {
|
|
195243
|
-
prefixedLog("error", msg);
|
|
195244
|
-
if (err) {
|
|
195245
|
-
prefixedLog("error", String(err));
|
|
195246
|
-
}
|
|
195247
|
-
},
|
|
195248
|
-
warn: (msg) => prefixedLog("warn", msg)
|
|
195249
|
-
} : {
|
|
195250
|
-
log: (msg) => print("log", msg),
|
|
195251
|
-
error: (msg, err) => {
|
|
195252
|
-
print("error", msg);
|
|
195253
|
-
if (err) {
|
|
195254
|
-
print("error", String(err));
|
|
195255
|
-
}
|
|
195256
|
-
},
|
|
195257
|
-
warn: (msg) => print("warn", msg)
|
|
195258
|
-
};
|
|
195259
|
-
}
|
|
195260
|
-
|
|
195261
195208
|
// src/cli/dev/dev-server/main.ts
|
|
195262
195209
|
var import_cors = __toESM(require_lib4(), 1);
|
|
195263
|
-
var
|
|
195264
|
-
import { dirname as dirname12, join as join16 } from "node:path";
|
|
195210
|
+
var import_express = __toESM(require_express(), 1);
|
|
195265
195211
|
|
|
195266
195212
|
// node_modules/get-port/index.js
|
|
195267
195213
|
import net from "node:net";
|
|
@@ -195379,220 +195325,11 @@ async function getPorts(options8) {
|
|
|
195379
195325
|
|
|
195380
195326
|
// src/cli/dev/dev-server/main.ts
|
|
195381
195327
|
var import_http_proxy_middleware = __toESM(require_dist2(), 1);
|
|
195382
|
-
|
|
195383
|
-
// src/cli/dev/dev-server/function-manager.ts
|
|
195384
|
-
import { spawn as spawn2 } from "node:child_process";
|
|
195385
|
-
import { dirname as dirname11, join as join15 } from "node:path";
|
|
195386
|
-
import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
195387
|
-
var __dirname5 = dirname11(fileURLToPath7(import.meta.url));
|
|
195388
|
-
var WRAPPER_PATH = join15(__dirname5, "../deno-runtime/main.js");
|
|
195389
|
-
var READY_TIMEOUT = 30000;
|
|
195390
|
-
|
|
195391
|
-
class FunctionManager {
|
|
195392
|
-
functions;
|
|
195393
|
-
running = new Map;
|
|
195394
|
-
logger;
|
|
195395
|
-
constructor(functions, logger) {
|
|
195396
|
-
this.functions = new Map(functions.map((f7) => [f7.name, f7]));
|
|
195397
|
-
this.logger = logger;
|
|
195398
|
-
}
|
|
195399
|
-
getFunction(name2) {
|
|
195400
|
-
return this.functions.get(name2);
|
|
195401
|
-
}
|
|
195402
|
-
async ensureRunning(name2) {
|
|
195403
|
-
const existing = this.running.get(name2);
|
|
195404
|
-
if (existing?.ready) {
|
|
195405
|
-
return existing.port;
|
|
195406
|
-
}
|
|
195407
|
-
const backendFunction = this.functions.get(name2);
|
|
195408
|
-
if (!backendFunction) {
|
|
195409
|
-
throw new Error(`Function "${name2}" not found`);
|
|
195410
|
-
}
|
|
195411
|
-
if (existing && !existing.ready) {
|
|
195412
|
-
return this.waitForReady(name2, existing);
|
|
195413
|
-
}
|
|
195414
|
-
const port = await this.allocatePort();
|
|
195415
|
-
const process21 = this.spawnFunction(backendFunction, port);
|
|
195416
|
-
const runningFunc = {
|
|
195417
|
-
process: process21,
|
|
195418
|
-
port,
|
|
195419
|
-
ready: false
|
|
195420
|
-
};
|
|
195421
|
-
this.running.set(name2, runningFunc);
|
|
195422
|
-
this.setupProcessHandlers(name2, process21);
|
|
195423
|
-
return this.waitForReady(name2, runningFunc);
|
|
195424
|
-
}
|
|
195425
|
-
getPort(name2) {
|
|
195426
|
-
const running = this.running.get(name2);
|
|
195427
|
-
return running?.ready ? running.port : undefined;
|
|
195428
|
-
}
|
|
195429
|
-
stopAll() {
|
|
195430
|
-
for (const [name2, { process: process21 }] of this.running) {
|
|
195431
|
-
this.logger.log(`[dev-server] Stopping function: ${name2}`);
|
|
195432
|
-
process21.kill();
|
|
195433
|
-
}
|
|
195434
|
-
this.running.clear();
|
|
195435
|
-
}
|
|
195436
|
-
stop(name2) {
|
|
195437
|
-
const running = this.running.get(name2);
|
|
195438
|
-
if (running) {
|
|
195439
|
-
this.logger.log(`Stopping function: ${name2}`);
|
|
195440
|
-
running.process.kill();
|
|
195441
|
-
this.running.delete(name2);
|
|
195442
|
-
}
|
|
195443
|
-
}
|
|
195444
|
-
async allocatePort() {
|
|
195445
|
-
const usedPorts = Array.from(this.running.values()).map((r5) => r5.port);
|
|
195446
|
-
return getPorts({ exclude: usedPorts });
|
|
195447
|
-
}
|
|
195448
|
-
spawnFunction(func, port) {
|
|
195449
|
-
this.logger.log(`[dev-server] Spawning function "${func.name}" on port ${port}`);
|
|
195450
|
-
const process21 = spawn2("deno", ["run", "--allow-all", WRAPPER_PATH], {
|
|
195451
|
-
env: {
|
|
195452
|
-
...globalThis.process.env,
|
|
195453
|
-
FUNCTION_PATH: func.entryPath,
|
|
195454
|
-
FUNCTION_PORT: String(port),
|
|
195455
|
-
FUNCTION_NAME: func.name
|
|
195456
|
-
},
|
|
195457
|
-
stdio: ["pipe", "pipe", "pipe"]
|
|
195458
|
-
});
|
|
195459
|
-
return process21;
|
|
195460
|
-
}
|
|
195461
|
-
setupProcessHandlers(name2, process21) {
|
|
195462
|
-
process21.stdout?.on("data", (data) => {
|
|
195463
|
-
const lines = data.toString().trim().split(`
|
|
195464
|
-
`);
|
|
195465
|
-
for (const line3 of lines) {
|
|
195466
|
-
this.logger.log(line3);
|
|
195467
|
-
}
|
|
195468
|
-
});
|
|
195469
|
-
process21.stderr?.on("data", (data) => {
|
|
195470
|
-
const lines = data.toString().trim().split(`
|
|
195471
|
-
`);
|
|
195472
|
-
for (const line3 of lines) {
|
|
195473
|
-
this.logger.error(line3);
|
|
195474
|
-
}
|
|
195475
|
-
});
|
|
195476
|
-
process21.on("exit", (code2) => {
|
|
195477
|
-
this.logger.log(`[dev-server] Function "${name2}" exited with code ${code2}`);
|
|
195478
|
-
this.running.delete(name2);
|
|
195479
|
-
});
|
|
195480
|
-
process21.on("error", (error48) => {
|
|
195481
|
-
this.logger.error(`[dev-server] Function "${name2}" error:`, error48);
|
|
195482
|
-
this.running.delete(name2);
|
|
195483
|
-
});
|
|
195484
|
-
}
|
|
195485
|
-
waitForReady(name2, runningFunc) {
|
|
195486
|
-
return new Promise((resolve5, reject) => {
|
|
195487
|
-
const timeout3 = setTimeout(() => {
|
|
195488
|
-
reject(new Error(`Function "${name2}" failed to start within timeout`));
|
|
195489
|
-
}, READY_TIMEOUT);
|
|
195490
|
-
const onData = (data) => {
|
|
195491
|
-
const output = data.toString();
|
|
195492
|
-
if (output.includes("Listening on")) {
|
|
195493
|
-
runningFunc.ready = true;
|
|
195494
|
-
clearTimeout(timeout3);
|
|
195495
|
-
runningFunc.process.stdout?.off("data", onData);
|
|
195496
|
-
resolve5(runningFunc.port);
|
|
195497
|
-
}
|
|
195498
|
-
};
|
|
195499
|
-
runningFunc.process.stdout?.on("data", onData);
|
|
195500
|
-
runningFunc.process.on("exit", (code2) => {
|
|
195501
|
-
if (!runningFunc.ready) {
|
|
195502
|
-
clearTimeout(timeout3);
|
|
195503
|
-
reject(new Error(`Function "${name2}" exited with code ${code2}`));
|
|
195504
|
-
}
|
|
195505
|
-
});
|
|
195506
|
-
});
|
|
195507
|
-
}
|
|
195508
|
-
}
|
|
195509
|
-
|
|
195510
|
-
// src/cli/dev/dev-server/routes/functions.ts
|
|
195511
|
-
var import_express = __toESM(require_express(), 1);
|
|
195512
|
-
import { request as httpRequest } from "node:http";
|
|
195513
|
-
function createFunctionRoutes(manager, logger) {
|
|
195514
|
-
const router = import_express.Router({ mergeParams: true });
|
|
195515
|
-
router.all("/:functionName", async (req, res) => {
|
|
195516
|
-
const { functionName } = req.params;
|
|
195517
|
-
try {
|
|
195518
|
-
const func = manager.getFunction(functionName);
|
|
195519
|
-
if (!func) {
|
|
195520
|
-
res.status(404).json({
|
|
195521
|
-
error: `Function "${functionName}" not found`
|
|
195522
|
-
});
|
|
195523
|
-
return;
|
|
195524
|
-
}
|
|
195525
|
-
const port = await manager.ensureRunning(functionName);
|
|
195526
|
-
await proxyRequest(req, res, port, logger);
|
|
195527
|
-
} catch (error48) {
|
|
195528
|
-
logger.error(`Function error:`, error48);
|
|
195529
|
-
const message = error48 instanceof Error ? error48.message : String(error48);
|
|
195530
|
-
res.status(500).json({ error: message });
|
|
195531
|
-
}
|
|
195532
|
-
});
|
|
195533
|
-
return router;
|
|
195534
|
-
}
|
|
195535
|
-
function proxyRequest(req, res, port, logger) {
|
|
195536
|
-
return new Promise((resolve5, reject) => {
|
|
195537
|
-
const headers = {
|
|
195538
|
-
...req.headers
|
|
195539
|
-
};
|
|
195540
|
-
delete headers.host;
|
|
195541
|
-
if (headers["x-app-id"]) {
|
|
195542
|
-
headers["Base44-App-Id"] = headers["x-app-id"];
|
|
195543
|
-
}
|
|
195544
|
-
headers["Base44-Api-Url"] = `${req.protocol}://${req.get("host")}`;
|
|
195545
|
-
const options8 = {
|
|
195546
|
-
hostname: "localhost",
|
|
195547
|
-
port,
|
|
195548
|
-
path: req.url,
|
|
195549
|
-
method: req.method,
|
|
195550
|
-
headers
|
|
195551
|
-
};
|
|
195552
|
-
const proxyReq = httpRequest(options8, (proxyRes) => {
|
|
195553
|
-
res.status(proxyRes.statusCode || 200);
|
|
195554
|
-
for (const [key2, value] of Object.entries(proxyRes.headers)) {
|
|
195555
|
-
if (value !== undefined) {
|
|
195556
|
-
res.setHeader(key2, value);
|
|
195557
|
-
}
|
|
195558
|
-
}
|
|
195559
|
-
proxyRes.pipe(res);
|
|
195560
|
-
proxyRes.on("end", () => {
|
|
195561
|
-
resolve5();
|
|
195562
|
-
});
|
|
195563
|
-
proxyRes.on("error", (error48) => {
|
|
195564
|
-
reject(error48);
|
|
195565
|
-
});
|
|
195566
|
-
});
|
|
195567
|
-
proxyReq.on("error", (error48) => {
|
|
195568
|
-
logger.error(`Function proxy error:`, error48);
|
|
195569
|
-
if (!res.headersSent) {
|
|
195570
|
-
res.status(502).json({
|
|
195571
|
-
error: "Failed to proxy request to function",
|
|
195572
|
-
details: error48.message
|
|
195573
|
-
});
|
|
195574
|
-
}
|
|
195575
|
-
resolve5();
|
|
195576
|
-
});
|
|
195577
|
-
if (req.body && Object.keys(req.body).length > 0) {
|
|
195578
|
-
const bodyString = JSON.stringify(req.body);
|
|
195579
|
-
proxyReq.setHeader("Content-Type", "application/json");
|
|
195580
|
-
proxyReq.setHeader("Content-Length", Buffer.byteLength(bodyString));
|
|
195581
|
-
proxyReq.write(bodyString);
|
|
195582
|
-
}
|
|
195583
|
-
proxyReq.end();
|
|
195584
|
-
});
|
|
195585
|
-
}
|
|
195586
|
-
|
|
195587
|
-
// src/cli/dev/dev-server/main.ts
|
|
195588
195328
|
var DEFAULT_PORT = 4400;
|
|
195589
195329
|
var BASE44_APP_URL = "https://base44.app";
|
|
195590
|
-
async function createDevServer(options8) {
|
|
195591
|
-
const
|
|
195592
|
-
const
|
|
195593
|
-
const { project: project2 } = await readProjectConfig();
|
|
195594
|
-
const configDir = dirname12(project2.configPath);
|
|
195595
|
-
const app = import_express2.default();
|
|
195330
|
+
async function createDevServer(options8 = {}) {
|
|
195331
|
+
const port = options8.port ?? await getPorts({ port: DEFAULT_PORT });
|
|
195332
|
+
const app = import_express.default();
|
|
195596
195333
|
const remoteProxy = import_http_proxy_middleware.createProxyMiddleware({
|
|
195597
195334
|
target: BASE44_APP_URL,
|
|
195598
195335
|
changeOrigin: true
|
|
@@ -195609,17 +195346,9 @@ async function createDevServer(options8) {
|
|
|
195609
195346
|
}
|
|
195610
195347
|
next();
|
|
195611
195348
|
});
|
|
195612
|
-
const [functions] = await Promise.all([
|
|
195613
|
-
functionResource.readAll(join16(configDir, project2.functionsDir))
|
|
195614
|
-
]);
|
|
195615
|
-
const functionManager = new FunctionManager(functions, logger);
|
|
195616
|
-
logger.log(`Loaded functions: ${functions.map((f7) => f7.name).join(", ") || "(none)"}`);
|
|
195617
|
-
const functionRoutes = createFunctionRoutes(functionManager, logger);
|
|
195618
|
-
app.use("/api/apps/:appId/functions", functionRoutes);
|
|
195619
195349
|
app.use((req, res, next) => {
|
|
195620
195350
|
return remoteProxy(req, res, next);
|
|
195621
195351
|
});
|
|
195622
|
-
app.use(import_express2.default.json());
|
|
195623
195352
|
return new Promise((resolve5, reject) => {
|
|
195624
195353
|
const server = app.listen(port, "127.0.0.1", (err) => {
|
|
195625
195354
|
if (err) {
|
|
@@ -195641,10 +195370,7 @@ async function createDevServer(options8) {
|
|
|
195641
195370
|
// src/cli/commands/dev.ts
|
|
195642
195371
|
async function devAction(options8) {
|
|
195643
195372
|
const port = options8.port ? Number(options8.port) : undefined;
|
|
195644
|
-
const { port: resolvedPort } = await createDevServer({
|
|
195645
|
-
port,
|
|
195646
|
-
logger: createDevLogger()
|
|
195647
|
-
});
|
|
195373
|
+
const { port: resolvedPort } = await createDevServer({ port });
|
|
195648
195374
|
return {
|
|
195649
195375
|
outroMessage: `Dev server is available at ${theme.colors.links(`http://localhost:${resolvedPort}`)}`
|
|
195650
195376
|
};
|
|
@@ -195806,7 +195532,7 @@ function nanoid3(size = 21) {
|
|
|
195806
195532
|
}
|
|
195807
195533
|
|
|
195808
195534
|
// node_modules/posthog-node/dist/extensions/error-tracking/modifiers/module.node.mjs
|
|
195809
|
-
import { dirname as
|
|
195535
|
+
import { dirname as dirname11, posix, sep } from "path";
|
|
195810
195536
|
function createModulerModifier() {
|
|
195811
195537
|
const getModuleFromFileName = createGetModuleFromFilename();
|
|
195812
195538
|
return async (frames) => {
|
|
@@ -195815,7 +195541,7 @@ function createModulerModifier() {
|
|
|
195815
195541
|
return frames;
|
|
195816
195542
|
};
|
|
195817
195543
|
}
|
|
195818
|
-
function createGetModuleFromFilename(basePath = process.argv[1] ?
|
|
195544
|
+
function createGetModuleFromFilename(basePath = process.argv[1] ? dirname11(process.argv[1]) : process.cwd(), isWindows4 = sep === "\\") {
|
|
195819
195545
|
const normalizedBase = isWindows4 ? normalizeWindowsPath2(basePath) : basePath;
|
|
195820
195546
|
return (filename) => {
|
|
195821
195547
|
if (!filename)
|
|
@@ -200034,4 +199760,4 @@ export {
|
|
|
200034
199760
|
CLIExitError
|
|
200035
199761
|
};
|
|
200036
199762
|
|
|
200037
|
-
//# debugId=
|
|
199763
|
+
//# debugId=06A844C7F693D30164756E2164756E21
|