@base44-preview/cli 0.0.32-pr.247.7e47d4d → 0.0.32-pr.249.10b4d54

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/README.md CHANGED
@@ -7,7 +7,6 @@ Base44's backend service provides a managed backend for your applications, inclu
7
7
  - **Create projects** from templates.
8
8
  - **Sync** resources defined in local code with your Base44 backend.
9
9
  - **Deploy sites** to Base44's hosting platform.
10
- - **Generate TypeScript types** from your project resources.
11
10
 
12
11
  To get started, see the full list of commands below or check out the [documentation](https://docs.base44.com/developers/references/cli/get-started/overview).
13
12
 
@@ -44,20 +43,19 @@ The CLI will guide you through project setup. For step-by-step tutorials, see th
44
43
 
45
44
  | Command | Description |
46
45
  | ------- | ----------- |
47
- | [`agents pull`](https://docs.base44.com/developers/references/cli/commands/agents-pull) | Pull agents from Base44 to local files |
48
- | [`agents push`](https://docs.base44.com/developers/references/cli/commands/agents-push) | Push local agents to Base44 |
49
46
  | [`create`](https://docs.base44.com/developers/references/cli/commands/create) | Create a new Base44 project from a template |
50
- | [`dashboard open`](https://docs.base44.com/developers/references/cli/commands/dashboard) | Open the app dashboard in your browser |
51
47
  | [`deploy`](https://docs.base44.com/developers/references/cli/commands/deploy) | Deploy resources and site to Base44 |
52
- | [`entities push`](https://docs.base44.com/developers/references/cli/commands/entities-push) | Push local entity schemas to Base44 |
53
- | [`functions deploy`](https://docs.base44.com/developers/references/cli/commands/functions-deploy) | Deploy local functions to Base44 |
54
48
  | [`link`](https://docs.base44.com/developers/references/cli/commands/link) | Link a local project to a project on Base44 |
49
+ | [`dashboard open`](https://docs.base44.com/developers/references/cli/commands/dashboard) | Open the app dashboard in your browser |
55
50
  | [`login`](https://docs.base44.com/developers/references/cli/commands/login) | Authenticate with Base44 |
56
51
  | [`logout`](https://docs.base44.com/developers/references/cli/commands/logout) | Sign out and clear stored credentials |
52
+ | [`whoami`](https://docs.base44.com/developers/references/cli/commands/whoami) | Display the current authenticated user |
53
+ | [`agents pull`](https://docs.base44.com/developers/references/cli/commands/agents-pull) | Pull agents from Base44 to local files |
54
+ | [`agents push`](https://docs.base44.com/developers/references/cli/commands/agents-push) | Push local agents to Base44 |
55
+ | [`entities push`](https://docs.base44.com/developers/references/cli/commands/entities-push) | Push local entity schemas to Base44 |
56
+ | [`functions deploy`](https://docs.base44.com/developers/references/cli/commands/functions-deploy) | Deploy local functions to Base44 |
57
57
  | [`site deploy`](https://docs.base44.com/developers/references/cli/commands/site-deploy) | Deploy built site files to Base44 hosting |
58
58
  | [`site open`](https://docs.base44.com/developers/references/cli/commands/site-open) | Open the published site in your browser |
59
- | [`types generate`](https://docs.base44.com/developers/references/cli/commands/types-generate) | Generate TypeScript types from project resources |
60
- | [`whoami`](https://docs.base44.com/developers/references/cli/commands/whoami) | Display the current authenticated user |
61
59
 
62
60
 
63
61
  <!--| [`eject`](https://docs.base44.com/developers/references/cli/commands/eject) | Create a Base44 backend project from an existing Base44 app | -->
package/dist/cli/index.js CHANGED
@@ -193486,6 +193486,7 @@ 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",
193489
193490
  "@types/ejs": "^3.1.5",
193490
193491
  "@types/express": "^5.0.6",
193491
193492
  "@types/json-schema": "^7.0.15",
@@ -195205,9 +195206,62 @@ function getTypesCommand(context) {
195205
195206
  return new Command("types").description("Manage TypeScript type generation").addCommand(getTypesGenerateCommand(context));
195206
195207
  }
195207
195208
 
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
+
195208
195261
  // src/cli/dev/dev-server/main.ts
195209
195262
  var import_cors = __toESM(require_lib4(), 1);
195210
- var import_express = __toESM(require_express(), 1);
195263
+ var import_express2 = __toESM(require_express(), 1);
195264
+ import { dirname as dirname12, join as join16 } from "node:path";
195211
195265
 
195212
195266
  // node_modules/get-port/index.js
195213
195267
  import net from "node:net";
@@ -195325,11 +195379,220 @@ async function getPorts(options8) {
195325
195379
 
195326
195380
  // src/cli/dev/dev-server/main.ts
195327
195381
  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
195328
195588
  var DEFAULT_PORT = 4400;
195329
195589
  var BASE44_APP_URL = "https://base44.app";
195330
- async function createDevServer(options8 = {}) {
195331
- const port = options8.port ?? await getPorts({ port: DEFAULT_PORT });
195332
- const app = import_express.default();
195590
+ async function createDevServer(options8) {
195591
+ const { logger, port: userPort } = options8;
195592
+ const port = userPort ?? await getPorts({ port: DEFAULT_PORT });
195593
+ const { project: project2 } = await readProjectConfig();
195594
+ const configDir = dirname12(project2.configPath);
195595
+ const app = import_express2.default();
195333
195596
  const remoteProxy = import_http_proxy_middleware.createProxyMiddleware({
195334
195597
  target: BASE44_APP_URL,
195335
195598
  changeOrigin: true
@@ -195346,9 +195609,17 @@ async function createDevServer(options8 = {}) {
195346
195609
  }
195347
195610
  next();
195348
195611
  });
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);
195349
195619
  app.use((req, res, next) => {
195350
195620
  return remoteProxy(req, res, next);
195351
195621
  });
195622
+ app.use(import_express2.default.json());
195352
195623
  return new Promise((resolve5, reject) => {
195353
195624
  const server = app.listen(port, "127.0.0.1", (err) => {
195354
195625
  if (err) {
@@ -195370,7 +195641,10 @@ async function createDevServer(options8 = {}) {
195370
195641
  // src/cli/commands/dev.ts
195371
195642
  async function devAction(options8) {
195372
195643
  const port = options8.port ? Number(options8.port) : undefined;
195373
- const { port: resolvedPort } = await createDevServer({ port });
195644
+ const { port: resolvedPort } = await createDevServer({
195645
+ port,
195646
+ logger: createDevLogger()
195647
+ });
195374
195648
  return {
195375
195649
  outroMessage: `Dev server is available at ${theme.colors.links(`http://localhost:${resolvedPort}`)}`
195376
195650
  };
@@ -195532,7 +195806,7 @@ function nanoid3(size = 21) {
195532
195806
  }
195533
195807
 
195534
195808
  // node_modules/posthog-node/dist/extensions/error-tracking/modifiers/module.node.mjs
195535
- import { dirname as dirname11, posix, sep } from "path";
195809
+ import { dirname as dirname13, posix, sep } from "path";
195536
195810
  function createModulerModifier() {
195537
195811
  const getModuleFromFileName = createGetModuleFromFilename();
195538
195812
  return async (frames) => {
@@ -195541,7 +195815,7 @@ function createModulerModifier() {
195541
195815
  return frames;
195542
195816
  };
195543
195817
  }
195544
- function createGetModuleFromFilename(basePath = process.argv[1] ? dirname11(process.argv[1]) : process.cwd(), isWindows4 = sep === "\\") {
195818
+ function createGetModuleFromFilename(basePath = process.argv[1] ? dirname13(process.argv[1]) : process.cwd(), isWindows4 = sep === "\\") {
195545
195819
  const normalizedBase = isWindows4 ? normalizeWindowsPath2(basePath) : basePath;
195546
195820
  return (filename) => {
195547
195821
  if (!filename)
@@ -199760,4 +200034,4 @@ export {
199760
200034
  CLIExitError
199761
200035
  };
199762
200036
 
199763
- //# debugId=BE87F2C8EFF5B4AD64756E2164756E21
200037
+ //# debugId=8F3746945013573D64756E2164756E21