@base44-preview/cli 0.0.32-pr.271.5d60e7b → 0.0.33-pr.261.cbb005c

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
@@ -46,19 +46,20 @@ The CLI will guide you through project setup. For step-by-step tutorials, see th
46
46
  | [`create`](https://docs.base44.com/developers/references/cli/commands/create) | Create a new Base44 project from a template |
47
47
  | [`deploy`](https://docs.base44.com/developers/references/cli/commands/deploy) | Deploy resources and site to Base44 |
48
48
  | [`link`](https://docs.base44.com/developers/references/cli/commands/link) | Link a local project to a project on Base44 |
49
+ | [`eject`](https://docs.base44.com/developers/references/cli/commands/eject) | Download the code for an existing Base44 project |
49
50
  | [`dashboard open`](https://docs.base44.com/developers/references/cli/commands/dashboard) | Open the app dashboard in your browser |
50
51
  | [`login`](https://docs.base44.com/developers/references/cli/commands/login) | Authenticate with Base44 |
51
52
  | [`logout`](https://docs.base44.com/developers/references/cli/commands/logout) | Sign out and clear stored credentials |
52
53
  | [`whoami`](https://docs.base44.com/developers/references/cli/commands/whoami) | Display the current authenticated user |
53
54
  | [`agents pull`](https://docs.base44.com/developers/references/cli/commands/agents-pull) | Pull agents from Base44 to local files |
54
55
  | [`agents push`](https://docs.base44.com/developers/references/cli/commands/agents-push) | Push local agents to Base44 |
56
+ | [`connectors pull`](https://docs.base44.com/developers/references/cli/commands/connectors-pull) | Pull connectors from Base44 to local files |
57
+ | [`connectors push`](https://docs.base44.com/developers/references/cli/commands/connectors-push) | Push local connectors to Base44 |
55
58
  | [`entities push`](https://docs.base44.com/developers/references/cli/commands/entities-push) | Push local entity schemas to Base44 |
56
59
  | [`functions deploy`](https://docs.base44.com/developers/references/cli/commands/functions-deploy) | Deploy local functions to Base44 |
57
60
  | [`site deploy`](https://docs.base44.com/developers/references/cli/commands/site-deploy) | Deploy built site files to Base44 hosting |
58
61
  | [`site open`](https://docs.base44.com/developers/references/cli/commands/site-open) | Open the published site in your browser |
59
-
60
-
61
- <!--| [`eject`](https://docs.base44.com/developers/references/cli/commands/eject) | Create a Base44 backend project from an existing Base44 app | -->
62
+ | [`types generate`](https://docs.base44.com/developers/references/cli/commands/types-generate) | Generate TypeScript types from project resources |
62
63
 
63
64
  ## AI agent skills
64
65
 
@@ -92,3 +93,4 @@ Found a bug? [Open an issue](https://github.com/base44/cli/issues).
92
93
  ## License
93
94
 
94
95
  ISC
96
+
package/dist/cli/index.js CHANGED
@@ -178514,6 +178514,18 @@ class InvalidInputError extends UserError {
178514
178514
  code = "INVALID_INPUT";
178515
178515
  }
178516
178516
 
178517
+ class DependencyNotFoundError extends UserError {
178518
+ code = "DEPENDENCY_NOT_FOUND";
178519
+ constructor(message, options) {
178520
+ super(message, {
178521
+ hints: options?.hints ?? [
178522
+ { message: "Install the required dependency and try again" }
178523
+ ],
178524
+ cause: options?.cause
178525
+ });
178526
+ }
178527
+ }
178528
+
178517
178529
  class ApiError extends SystemError {
178518
178530
  code = "API_ERROR";
178519
178531
  statusCode;
@@ -178629,6 +178641,21 @@ class FileReadError extends SystemError {
178629
178641
  });
178630
178642
  }
178631
178643
  }
178644
+
178645
+ class InternalError extends SystemError {
178646
+ code = "INTERNAL_ERROR";
178647
+ constructor(message, options) {
178648
+ super(message, {
178649
+ hints: options?.hints ?? [
178650
+ {
178651
+ message: "This is an unexpected error. Please report it if it persists."
178652
+ }
178653
+ ],
178654
+ cause: options?.cause
178655
+ });
178656
+ }
178657
+ }
178658
+
178632
178659
  class TypeGenerationError extends SystemError {
178633
178660
  code = "TYPE_GENERATION_ERROR";
178634
178661
  constructor(message, entityName, cause) {
@@ -187064,7 +187091,9 @@ var theme = {
187064
187091
  styles: {
187065
187092
  header: source_default.dim,
187066
187093
  bold: source_default.bold,
187067
- dim: source_default.dim
187094
+ dim: source_default.dim,
187095
+ error: source_default.red,
187096
+ warn: source_default.yellow
187068
187097
  },
187069
187098
  format: {
187070
187099
  errorContext(ctx) {
@@ -193846,7 +193875,7 @@ var {
193846
193875
  // package.json
193847
193876
  var package_default = {
193848
193877
  name: "base44",
193849
- version: "0.0.32",
193878
+ version: "0.0.33",
193850
193879
  description: "Base44 CLI - Unified interface for managing Base44 applications",
193851
193880
  type: "module",
193852
193881
  bin: {
@@ -193887,6 +193916,7 @@ var package_default = {
193887
193916
  "@types/bun": "^1.2.15",
193888
193917
  "@types/common-tags": "^1.8.4",
193889
193918
  "@types/cors": "^2.8.19",
193919
+ "@types/deno": "^2.5.0",
193890
193920
  "@types/ejs": "^3.1.5",
193891
193921
  "@types/express": "^5.0.6",
193892
193922
  "@types/json-schema": "^7.0.15",
@@ -195610,9 +195640,12 @@ function getTypesCommand(context) {
195610
195640
  return new Command("types").description("Manage TypeScript type generation").addCommand(getTypesGenerateCommand(context));
195611
195641
  }
195612
195642
 
195643
+ // src/cli/commands/dev.ts
195644
+ import { dirname as dirname12, join as join16 } from "node:path";
195645
+
195613
195646
  // src/cli/dev/dev-server/main.ts
195614
195647
  var import_cors = __toESM(require_lib4(), 1);
195615
- var import_express = __toESM(require_express(), 1);
195648
+ var import_express2 = __toESM(require_express(), 1);
195616
195649
 
195617
195650
  // node_modules/get-port/index.js
195618
195651
  import net from "node:net";
@@ -195729,13 +195762,232 @@ async function getPorts(options8) {
195729
195762
  }
195730
195763
 
195731
195764
  // src/cli/dev/dev-server/main.ts
195765
+ var import_http_proxy_middleware2 = __toESM(require_dist2(), 1);
195766
+
195767
+ // src/cli/dev/createDevLogger.ts
195768
+ var colorByType = {
195769
+ error: theme.styles.error,
195770
+ warn: theme.styles.warn,
195771
+ log: (text) => text
195772
+ };
195773
+ function createDevLogger() {
195774
+ const print = (type, msg) => {
195775
+ const colorize = colorByType[type];
195776
+ console[type](colorize(msg));
195777
+ };
195778
+ return {
195779
+ log: (msg) => print("log", msg),
195780
+ error: (msg, err) => {
195781
+ print("error", msg);
195782
+ if (err) {
195783
+ print("error", String(err));
195784
+ }
195785
+ },
195786
+ warn: (msg) => print("warn", msg)
195787
+ };
195788
+ }
195789
+
195790
+ // src/cli/dev/dev-server/function-manager.ts
195791
+ import { spawn as spawn2, spawnSync as spawnSync2 } from "node:child_process";
195792
+ import { dirname as dirname11, join as join15 } from "node:path";
195793
+ import { fileURLToPath as fileURLToPath7 } from "node:url";
195794
+ var __dirname5 = dirname11(fileURLToPath7(import.meta.url));
195795
+ var WRAPPER_PATH = join15(__dirname5, "../deno-runtime/main.js");
195796
+ var READY_TIMEOUT = 30000;
195797
+
195798
+ class FunctionManager {
195799
+ functions;
195800
+ running = new Map;
195801
+ starting = new Map;
195802
+ logger;
195803
+ constructor(functions, logger) {
195804
+ this.functions = new Map(functions.map((f7) => [f7.name, f7]));
195805
+ this.logger = logger;
195806
+ if (functions.length > 0) {
195807
+ this.verifyDenoIsInstalled();
195808
+ }
195809
+ }
195810
+ verifyDenoIsInstalled() {
195811
+ const result = spawnSync2("deno", ["--version"]);
195812
+ if (result.error) {
195813
+ throw new DependencyNotFoundError("Deno is required to run functions", {
195814
+ hints: [{ message: "Install Deno from https://deno.com/download" }]
195815
+ });
195816
+ }
195817
+ }
195818
+ getFunctionNames() {
195819
+ return Array.from(this.functions.keys());
195820
+ }
195821
+ async ensureRunning(name2) {
195822
+ const backendFunction = this.functions.get(name2);
195823
+ if (!backendFunction) {
195824
+ throw new InvalidInputError(`Function "${name2}" not found`, {
195825
+ hints: [{ message: "Check available functions in your project" }]
195826
+ });
195827
+ }
195828
+ const existing = this.running.get(name2);
195829
+ if (existing?.ready) {
195830
+ return existing.port;
195831
+ }
195832
+ const pending = this.starting.get(name2);
195833
+ if (pending) {
195834
+ return pending;
195835
+ }
195836
+ const promise2 = this.startFunction(name2, backendFunction);
195837
+ this.starting.set(name2, promise2);
195838
+ try {
195839
+ return await promise2;
195840
+ } finally {
195841
+ this.starting.delete(name2);
195842
+ }
195843
+ }
195844
+ async startFunction(name2, backendFunction) {
195845
+ const port = await this.allocatePort();
195846
+ const process21 = this.spawnFunction(backendFunction, port);
195847
+ const runningFunc = {
195848
+ process: process21,
195849
+ port,
195850
+ ready: false
195851
+ };
195852
+ this.running.set(name2, runningFunc);
195853
+ this.setupProcessHandlers(name2, process21);
195854
+ return this.waitForReady(name2, runningFunc);
195855
+ }
195856
+ stopAll() {
195857
+ for (const [name2, { process: process21 }] of this.running) {
195858
+ this.logger.log(`[dev-server] Stopping function: ${name2}`);
195859
+ process21.kill();
195860
+ }
195861
+ this.running.clear();
195862
+ this.starting.clear();
195863
+ }
195864
+ async allocatePort() {
195865
+ const usedPorts = Array.from(this.running.values()).map((r5) => r5.port);
195866
+ return getPorts({ exclude: usedPorts });
195867
+ }
195868
+ spawnFunction(func, port) {
195869
+ this.logger.log(`[dev-server] Spawning function "${func.name}" on port ${port}`);
195870
+ const process21 = spawn2("deno", ["run", "--allow-all", WRAPPER_PATH], {
195871
+ env: {
195872
+ ...globalThis.process.env,
195873
+ FUNCTION_PATH: func.entryPath,
195874
+ FUNCTION_PORT: String(port),
195875
+ FUNCTION_NAME: func.name
195876
+ },
195877
+ stdio: ["pipe", "pipe", "pipe"]
195878
+ });
195879
+ return process21;
195880
+ }
195881
+ setupProcessHandlers(name2, process21) {
195882
+ process21.stdout?.on("data", (data) => {
195883
+ const lines = data.toString().trim().split(`
195884
+ `);
195885
+ for (const line3 of lines) {
195886
+ this.logger.log(line3);
195887
+ }
195888
+ });
195889
+ process21.stderr?.on("data", (data) => {
195890
+ const lines = data.toString().trim().split(`
195891
+ `);
195892
+ for (const line3 of lines) {
195893
+ this.logger.error(line3);
195894
+ }
195895
+ });
195896
+ process21.on("exit", (code2) => {
195897
+ this.logger.log(`[dev-server] Function "${name2}" exited with code ${code2}`);
195898
+ this.running.delete(name2);
195899
+ });
195900
+ process21.on("error", (error48) => {
195901
+ this.logger.error(`[dev-server] Function "${name2}" error:`, error48);
195902
+ this.running.delete(name2);
195903
+ });
195904
+ }
195905
+ waitForReady(name2, runningFunc) {
195906
+ return new Promise((resolve5, reject) => {
195907
+ runningFunc.process.on("exit", (code2) => {
195908
+ if (!runningFunc.ready) {
195909
+ clearTimeout(timeout3);
195910
+ reject(new InternalError(`Function "${name2}" exited with code ${code2}`, {
195911
+ hints: [{ message: "Check the function code for errors" }]
195912
+ }));
195913
+ }
195914
+ });
195915
+ const timeout3 = setTimeout(() => {
195916
+ runningFunc.process.kill();
195917
+ reject(new InternalError(`Function "${name2}" failed to start within ${READY_TIMEOUT / 1000}s timeout`, {
195918
+ hints: [
195919
+ { message: "Check the function code for startup errors" }
195920
+ ]
195921
+ }));
195922
+ }, READY_TIMEOUT);
195923
+ const onData = (data) => {
195924
+ const output = data.toString();
195925
+ if (output.includes("Listening on")) {
195926
+ runningFunc.ready = true;
195927
+ clearTimeout(timeout3);
195928
+ runningFunc.process.stdout?.off("data", onData);
195929
+ resolve5(runningFunc.port);
195930
+ }
195931
+ };
195932
+ runningFunc.process.stdout?.on("data", onData);
195933
+ });
195934
+ }
195935
+ }
195936
+
195937
+ // src/cli/dev/dev-server/routes/functions.ts
195938
+ var import_express = __toESM(require_express(), 1);
195732
195939
  var import_http_proxy_middleware = __toESM(require_dist2(), 1);
195940
+ import { ServerResponse } from "node:http";
195941
+ function createFunctionRouter(manager, logger) {
195942
+ const router = import_express.Router({ mergeParams: true });
195943
+ const portsByRequest = new WeakMap;
195944
+ const proxy = import_http_proxy_middleware.createProxyMiddleware({
195945
+ router: (req) => `http://localhost:${portsByRequest.get(req)}`,
195946
+ changeOrigin: true,
195947
+ on: {
195948
+ proxyReq: (proxyReq, req) => {
195949
+ const xAppId = req.headers["x-app-id"];
195950
+ if (xAppId) {
195951
+ proxyReq.setHeader("Base44-App-Id", xAppId);
195952
+ }
195953
+ proxyReq.setHeader("Base44-Api-Url", `${req.protocol}://${req.headers.host}`);
195954
+ },
195955
+ error: (err, _req, res) => {
195956
+ logger.error("Function proxy error:", err);
195957
+ if (res instanceof ServerResponse && !res.headersSent) {
195958
+ res.writeHead(502, { "Content-Type": "application/json" });
195959
+ res.end(JSON.stringify({
195960
+ error: "Failed to proxy request to function",
195961
+ details: err.message
195962
+ }));
195963
+ }
195964
+ }
195965
+ }
195966
+ });
195967
+ router.all("/:functionName", async (req, res, next) => {
195968
+ const { functionName } = req.params;
195969
+ try {
195970
+ const port = await manager.ensureRunning(functionName);
195971
+ portsByRequest.set(req, port);
195972
+ next();
195973
+ } catch (error48) {
195974
+ logger.error("Function error:", error48);
195975
+ const message = error48 instanceof Error ? error48.message : String(error48);
195976
+ res.status(500).json({ error: message });
195977
+ }
195978
+ }, proxy);
195979
+ return router;
195980
+ }
195981
+
195982
+ // src/cli/dev/dev-server/main.ts
195733
195983
  var DEFAULT_PORT = 4400;
195734
195984
  var BASE44_APP_URL = "https://base44.app";
195735
- async function createDevServer(options8 = {}) {
195736
- const port = options8.port ?? await getPorts({ port: DEFAULT_PORT });
195737
- const app = import_express.default();
195738
- const remoteProxy = import_http_proxy_middleware.createProxyMiddleware({
195985
+ async function createDevServer(options8) {
195986
+ const { port: userPort } = options8;
195987
+ const port = userPort ?? await getPorts({ port: DEFAULT_PORT });
195988
+ const { functions } = await options8.loadResources();
195989
+ const app = import_express2.default();
195990
+ const remoteProxy = import_http_proxy_middleware2.createProxyMiddleware({
195739
195991
  target: BASE44_APP_URL,
195740
195992
  changeOrigin: true
195741
195993
  });
@@ -195751,6 +196003,13 @@ async function createDevServer(options8 = {}) {
195751
196003
  }
195752
196004
  next();
195753
196005
  });
196006
+ const devLogger = createDevLogger();
196007
+ const functionManager = new FunctionManager(functions, devLogger);
196008
+ if (functionManager.getFunctionNames().length > 0) {
196009
+ R2.info(`Loaded functions: ${functionManager.getFunctionNames().join(", ")}`);
196010
+ const functionRoutes = createFunctionRouter(functionManager, devLogger);
196011
+ app.use("/api/apps/:appId/functions", functionRoutes);
196012
+ }
195754
196013
  app.use((req, res, next) => {
195755
196014
  return remoteProxy(req, res, next);
195756
196015
  });
@@ -195763,6 +196022,12 @@ async function createDevServer(options8 = {}) {
195763
196022
  reject(err);
195764
196023
  }
195765
196024
  } else {
196025
+ const shutdown = () => {
196026
+ functionManager.stopAll();
196027
+ server.close();
196028
+ };
196029
+ process.on("SIGINT", shutdown);
196030
+ process.on("SIGTERM", shutdown);
195766
196031
  resolve5({
195767
196032
  port,
195768
196033
  server
@@ -195775,7 +196040,15 @@ async function createDevServer(options8 = {}) {
195775
196040
  // src/cli/commands/dev.ts
195776
196041
  async function devAction(options8) {
195777
196042
  const port = options8.port ? Number(options8.port) : undefined;
195778
- const { port: resolvedPort } = await createDevServer({ port });
196043
+ const { port: resolvedPort } = await createDevServer({
196044
+ port,
196045
+ loadResources: async () => {
196046
+ const { project: project2 } = await readProjectConfig();
196047
+ const configDir = dirname12(project2.configPath);
196048
+ const functions = await functionResource.readAll(join16(configDir, project2.functionsDir));
196049
+ return { functions };
196050
+ }
196051
+ });
195779
196052
  return {
195780
196053
  outroMessage: `Dev server is available at ${theme.colors.links(`http://localhost:${resolvedPort}`)}`
195781
196054
  };
@@ -195937,7 +196210,7 @@ function nanoid3(size = 21) {
195937
196210
  }
195938
196211
 
195939
196212
  // node_modules/posthog-node/dist/extensions/error-tracking/modifiers/module.node.mjs
195940
- import { dirname as dirname11, posix, sep } from "path";
196213
+ import { dirname as dirname13, posix, sep } from "path";
195941
196214
  function createModulerModifier() {
195942
196215
  const getModuleFromFileName = createGetModuleFromFilename();
195943
196216
  return async (frames) => {
@@ -195946,7 +196219,7 @@ function createModulerModifier() {
195946
196219
  return frames;
195947
196220
  };
195948
196221
  }
195949
- function createGetModuleFromFilename(basePath = process.argv[1] ? dirname11(process.argv[1]) : process.cwd(), isWindows4 = sep === "\\") {
196222
+ function createGetModuleFromFilename(basePath = process.argv[1] ? dirname13(process.argv[1]) : process.cwd(), isWindows4 = sep === "\\") {
195950
196223
  const normalizedBase = isWindows4 ? normalizeWindowsPath2(basePath) : basePath;
195951
196224
  return (filename) => {
195952
196225
  if (!filename)
@@ -200163,4 +200436,4 @@ export {
200163
200436
  CLIExitError
200164
200437
  };
200165
200438
 
200166
- //# debugId=8FF06F66318A4ACC64756E2164756E21
200439
+ //# debugId=DF6807EB90E6667564756E2164756E21