@base44-preview/cli 0.1.5-pr.576.5e79c21 → 0.1.5-pr.577.1701370

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.
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Entry point for standalone compiled binaries (built with `bun build --compile`).
3
3
  *
4
- * This file embeds a single assets tarball (templates + backend-runtime) into the
4
+ * This file embeds a single assets tarball (templates + deno-runtime) into the
5
5
  * binary and extracts it to ~/.base44/assets/<version>/ on first run.
6
6
  * The npm distribution uses bin/run.js instead — this file is only used
7
7
  * for the compiled binary path.
@@ -25,11 +25,7 @@ const assetsDir = join(homedir(), ".base44", "assets", VERSION);
25
25
  // Extract assets if this version hasn't been unpacked yet.
26
26
  // Bun.file() reads from the virtual $bunfs, then we write to real disk
27
27
  // so the rest of the CLI can access these files normally.
28
- //
29
- // The directory existing is not proof its contents are current: an install
30
- // that predates a renamed or added asset directory would otherwise keep the
31
- // stale layout forever, so check for an expected directory too.
32
- if (!existsSync(assetsDir) || !existsSync(join(assetsDir, "backend-runtime"))) {
28
+ if (!existsSync(assetsDir)) {
33
29
  mkdirSync(assetsDir, { recursive: true });
34
30
  const bytes = await Bun.file(assetsTarball).bytes();
35
31
  const archive = new Bun.Archive(bytes);
@@ -4,13 +4,6 @@
4
4
  * This script is executed by Deno to run user functions.
5
5
  * It patches Deno.serve to inject a dynamic port before importing the user's function.
6
6
  *
7
- * Two handler shapes are supported:
8
- * - `export default async function (req) { ... }` — the shape the deployed
9
- * runtime expects. The wrapper serves it after importing the module.
10
- * - `Deno.serve(handler)` — the legacy shape. A module that calls Deno.serve
11
- * while being imported serves itself and its default export is ignored,
12
- * mirroring the deployed bundler's precedence.
13
- *
14
7
  * Environment variables:
15
8
  * - FUNCTION_PATH: Absolute path to the user's function entry file
16
9
  * - FUNCTION_PORT: Port number for the function to listen on
@@ -32,10 +25,6 @@ if (!functionPath) {
32
25
  // Store the original Deno.serve
33
26
  const originalServe = Deno.serve.bind(Deno);
34
27
 
35
- // Set when the user's module calls Deno.serve while it is being imported.
36
- // Such a module serves itself, so its default export (if any) is ignored.
37
- let servedDuringImport = false;
38
-
39
28
  // Patch Deno.serve to inject our port and add onListen callback.
40
29
  const patchedServe = (
41
30
  optionsOrHandler:
@@ -44,8 +33,6 @@ const patchedServe = (
44
33
  | (Deno.ServeOptions & { handler: Deno.ServeHandler }),
45
34
  maybeHandler?: Deno.ServeHandler,
46
35
  ): Deno.HttpServer<Deno.NetAddr> => {
47
- servedDuringImport = true;
48
-
49
36
  const onListen = () => {
50
37
  // This message is used by FunctionManager to detect when the function is ready
51
38
  console.log(`[${functionName}] Listening on http://localhost:${port}`);
@@ -81,56 +68,13 @@ Object.defineProperty(Deno, "serve", {
81
68
  configurable: true,
82
69
  });
83
70
 
84
- type FetchHandler = (req: Request) => Response | Promise<Response>;
85
-
86
- /**
87
- * Pull the request handler off the user's module namespace, accepting both
88
- * `export default async function (req)` and the `export default { fetch }`
89
- * object form.
90
- */
91
- const resolveDefaultHandler = (
92
- module: Record<string, unknown>,
93
- ): FetchHandler | null => {
94
- const exported = module.default;
95
-
96
- if (typeof exported === "function") {
97
- return exported as FetchHandler;
98
- }
99
-
100
- if (exported && typeof exported === "object") {
101
- const { fetch } = exported as { fetch?: unknown };
102
- if (typeof fetch === "function") {
103
- return (fetch as FetchHandler).bind(exported);
104
- }
105
- }
106
-
107
- return null;
108
- };
109
-
110
71
  console.log(`[${functionName}] Starting function from ${functionPath}`);
111
72
 
112
- // Dynamically import the user's function. A legacy function calls Deno.serve
113
- // during import, which is now patched to use our port.
114
- let functionModule: Record<string, unknown>;
73
+ // Dynamically import the user's function
74
+ // The function will call Deno.serve which is now patched to use our port
115
75
  try {
116
- functionModule = await import(functionPath);
76
+ await import(functionPath);
117
77
  } catch (error) {
118
78
  console.error(`[${functionName}] Failed to load function:`, error);
119
79
  Deno.exit(1);
120
80
  }
121
-
122
- // Nothing served itself during import, so the module is expected to export a
123
- // handler. Serving it here goes through the same patched Deno.serve, so the
124
- // readiness line still gets printed exactly once.
125
- if (!servedDuringImport) {
126
- const handler = resolveDefaultHandler(functionModule);
127
-
128
- if (!handler) {
129
- console.error(
130
- `[${functionName}] The function must export default a request handler or call Deno.serve()`,
131
- );
132
- Deno.exit(1);
133
- }
134
-
135
- Deno.serve(handler);
136
- }
package/dist/cli/index.js CHANGED
@@ -213884,7 +213884,7 @@ var require_parse_path = __commonJS((exports, module) => {
213884
213884
  var reFirstKey = /^[^\[]*/;
213885
213885
  var reDigitPath = /^\[(\d+)\]/;
213886
213886
  var reNormalPath = /^\[([^\]]+)\]/;
213887
- function parsePath2(key2) {
213887
+ function parsePath(key2) {
213888
213888
  function failure() {
213889
213889
  return [{ type: "object", key: key2, last: true }];
213890
213890
  }
@@ -213925,7 +213925,7 @@ var require_parse_path = __commonJS((exports, module) => {
213925
213925
  tail.last = true;
213926
213926
  return steps;
213927
213927
  }
213928
- module.exports = parsePath2;
213928
+ module.exports = parsePath;
213929
213929
  });
213930
213930
 
213931
213931
  // ../../node_modules/append-field/lib/set-value.js
@@ -213996,10 +213996,10 @@ var require_set_value = __commonJS((exports, module) => {
213996
213996
 
213997
213997
  // ../../node_modules/append-field/index.js
213998
213998
  var require_append_field = __commonJS((exports, module) => {
213999
- var parsePath2 = require_parse_path();
213999
+ var parsePath = require_parse_path();
214000
214000
  var setValue = require_set_value();
214001
214001
  function appendField(store, key2, value) {
214002
- var steps = parsePath2(key2);
214002
+ var steps = parsePath(key2);
214003
214003
  steps.reduce(function(context, step) {
214004
214004
  return setValue(context, step, context[step.key], value);
214005
214005
  }, store);
@@ -214616,7 +214616,7 @@ var require_buffer_list = __commonJS((exports, module) => {
214616
214616
  }
214617
214617
  }, {
214618
214618
  key: "join",
214619
- value: function join27(s5) {
214619
+ value: function join25(s5) {
214620
214620
  if (this.length === 0)
214621
214621
  return "";
214622
214622
  var p4 = this.head;
@@ -218205,7 +218205,7 @@ var require_dist5 = __commonJS((exports, module) => {
218205
218205
  });
218206
218206
  module.exports = __toCommonJS(src_exports);
218207
218207
  var import_promises22 = __require("node:fs/promises");
218208
- var import_node_fs24 = __require("node:fs");
218208
+ var import_node_fs23 = __require("node:fs");
218209
218209
  var DEVIN_LOCAL_PATH = "/opt/.devin";
218210
218210
  var CURSOR2 = "cursor";
218211
218211
  var CURSOR_CLI = "cursor-cli";
@@ -218262,7 +218262,7 @@ var require_dist5 = __commonJS((exports, module) => {
218262
218262
  return { isAgent: true, agent: { name: REPLIT } };
218263
218263
  }
218264
218264
  try {
218265
- await (0, import_promises22.access)(DEVIN_LOCAL_PATH, import_node_fs24.constants.F_OK);
218265
+ await (0, import_promises22.access)(DEVIN_LOCAL_PATH, import_node_fs23.constants.F_OK);
218266
218266
  return { isAgent: true, agent: { name: DEVIN } };
218267
218267
  } catch (error48) {}
218268
218268
  return { isAgent: false, agent: undefined };
@@ -234033,7 +234033,7 @@ function normalizeBase44Env() {
234033
234033
  loadProjectEnvFiles();
234034
234034
 
234035
234035
  // src/cli/index.ts
234036
- import { dirname as dirname25, join as join30 } from "node:path";
234036
+ import { dirname as dirname23, join as join28 } from "node:path";
234037
234037
  import { fileURLToPath as fileURLToPath6 } from "node:url";
234038
234038
 
234039
234039
  // ../../node_modules/@clack/core/dist/index.mjs
@@ -244116,17 +244116,14 @@ function getTemplatesDir() {
244116
244116
  function getTemplatesIndexPath() {
244117
244117
  return join11(ASSETS_DIR, "templates", "templates.json");
244118
244118
  }
244119
- function getBackendRuntimeDir() {
244120
- return join11(ASSETS_DIR, "backend-runtime");
244121
- }
244122
244119
  function getDenoWrapperPath() {
244123
- return join11(getBackendRuntimeDir(), "main.ts");
244120
+ return join11(ASSETS_DIR, "deno-runtime", "main.ts");
244124
244121
  }
244125
244122
  function getExecWrapperPath() {
244126
- return join11(getBackendRuntimeDir(), "exec.ts");
244123
+ return join11(ASSETS_DIR, "deno-runtime", "exec.ts");
244127
244124
  }
244128
244125
  function ensureNpmAssets(sourceDir) {
244129
- if (existsSync(ASSETS_DIR) && existsSync(getBackendRuntimeDir()))
244126
+ if (existsSync(ASSETS_DIR))
244130
244127
  return;
244131
244128
  if (!existsSync(sourceDir))
244132
244129
  return;
@@ -253808,7 +253805,7 @@ async function promptForLinkAction() {
253808
253805
  actionOptions.push({
253809
253806
  value: "choose",
253810
253807
  label: "Link an existing project",
253811
- hint: "Choose from one of your available projects previously created by the Base44 CLI"
253808
+ hint: "Choose from one of your existing Base44 apps"
253812
253809
  });
253813
253810
  const action = await Je({
253814
253811
  message: "How would you like to link this project?",
@@ -253845,8 +253842,8 @@ async function promptForNewProjectDetails() {
253845
253842
  description: result.description ? result.description.trim() : undefined
253846
253843
  };
253847
253844
  }
253848
- async function promptForExistingProject(linkableProjects) {
253849
- const projectOptions = linkableProjects.map((project2) => ({
253845
+ async function promptForExistingProject(projects) {
253846
+ const projectOptions = projects.map((project2) => ({
253850
253847
  value: project2,
253851
253848
  label: project2.name
253852
253849
  }));
@@ -253887,15 +253884,14 @@ async function link(ctx, options, command2) {
253887
253884
  successMessage: "Projects fetched",
253888
253885
  errorMessage: "Failed to fetch projects"
253889
253886
  });
253890
- const linkableProjects = projects.filter((p) => p.isManagedSourceCode !== true);
253891
- if (!linkableProjects.length) {
253887
+ if (!projects.length) {
253892
253888
  return { outroMessage: "No projects available for linking" };
253893
253889
  }
253894
253890
  let linkedAppId;
253895
253891
  if (appId) {
253896
- const project2 = linkableProjects.find((p) => p.id === appId);
253892
+ const project2 = projects.find((p) => p.id === appId);
253897
253893
  if (!project2) {
253898
- throw new InvalidInputError(`App with ID "${appId}" not found or not available for linking.`, {
253894
+ throw new InvalidInputError(`App with ID "${appId}" not found.`, {
253899
253895
  hints: [
253900
253896
  { message: "Check the app ID is correct" },
253901
253897
  {
@@ -253906,7 +253902,7 @@ async function link(ctx, options, command2) {
253906
253902
  }
253907
253903
  linkedAppId = appId;
253908
253904
  } else {
253909
- const selectedProject = await promptForExistingProject(linkableProjects);
253905
+ const selectedProject = await promptForExistingProject(projects);
253910
253906
  linkedAppId = selectedProject.id;
253911
253907
  }
253912
253908
  await runTask2("Linking project...", async () => {
@@ -254951,7 +254947,7 @@ function getWorkspaceCommand() {
254951
254947
  // src/cli/dev/dev-server/main.ts
254952
254948
  var import_cors = __toESM(require_lib4(), 1);
254953
254949
  var import_express6 = __toESM(require_express(), 1);
254954
- import { dirname as dirname23, join as join29 } from "node:path";
254950
+ import { dirname as dirname21, join as join27 } from "node:path";
254955
254951
 
254956
254952
  // ../../node_modules/get-port/index.js
254957
254953
  import net from "node:net";
@@ -255123,79 +255119,7 @@ function createDevLogger(label2, labelColor = theme.styles.dim) {
255123
255119
 
255124
255120
  // src/cli/dev/dev-server/function-manager.ts
255125
255121
  import { spawn as spawn2 } from "node:child_process";
255126
- import { dirname as dirname20, join as join26 } from "node:path";
255127
- import { pathToFileURL as pathToFileURL6 } from "node:url";
255128
-
255129
- // src/cli/dev/dev-server/import-map.ts
255130
- var import_json52 = __toESM(require_lib(), 1);
255131
- import { existsSync as existsSync2, readFileSync as readFileSync3 } from "node:fs";
255132
- import { dirname as dirname19, join as join25, parse as parsePath } from "node:path";
255133
255122
  import { pathToFileURL } from "node:url";
255134
- var DENO_CONFIG_NAMES = ["deno.json", "deno.jsonc"];
255135
- function findDenoConfig(startDir) {
255136
- const { root: root2 } = parsePath(startDir);
255137
- let dir = startDir;
255138
- while (true) {
255139
- for (const name2 of DENO_CONFIG_NAMES) {
255140
- const candidate = join25(dir, name2);
255141
- if (existsSync2(candidate))
255142
- return candidate;
255143
- }
255144
- if (dir === root2)
255145
- return null;
255146
- const parent = dirname19(dir);
255147
- if (parent === dir)
255148
- return null;
255149
- dir = parent;
255150
- }
255151
- }
255152
- function absolutize(value, baseUrl) {
255153
- if (!value.startsWith("./") && !value.startsWith("../"))
255154
- return value;
255155
- return new URL(value, baseUrl).href;
255156
- }
255157
- function absolutizeEntries(entries, baseUrl) {
255158
- return Object.fromEntries(Object.entries(entries).map(([key2, value]) => [
255159
- absolutize(key2, baseUrl),
255160
- absolutize(value, baseUrl)
255161
- ]));
255162
- }
255163
- function readImportMap(filePath) {
255164
- const parsed = import_json52.default.parse(readFileSync3(filePath, "utf-8"));
255165
- if (!parsed || typeof parsed !== "object")
255166
- return {};
255167
- const { imports, scopes } = parsed;
255168
- return { imports, scopes };
255169
- }
255170
- function buildImportMapArg(baseImportMapPath, projectDir) {
255171
- const baseUrl = pathToFileURL(baseImportMapPath).href;
255172
- const base = readImportMap(baseImportMapPath);
255173
- const merged = {
255174
- imports: absolutizeEntries(base.imports ?? {}, baseUrl),
255175
- scopes: {}
255176
- };
255177
- const projectConfigPath = findDenoConfig(projectDir);
255178
- if (projectConfigPath) {
255179
- const projectUrl = pathToFileURL(projectConfigPath).href;
255180
- let project2 = {};
255181
- try {
255182
- project2 = readImportMap(projectConfigPath);
255183
- } catch {
255184
- project2 = {};
255185
- }
255186
- merged.imports = {
255187
- ...absolutizeEntries(project2.imports ?? {}, projectUrl),
255188
- ...merged.imports
255189
- };
255190
- for (const [scope, entries] of Object.entries(project2.scopes ?? {})) {
255191
- merged.scopes[absolutize(scope, projectUrl)] = absolutizeEntries(entries, projectUrl);
255192
- }
255193
- }
255194
- const json3 = JSON.stringify(merged);
255195
- return `data:application/json,${encodeURIComponent(json3)}`;
255196
- }
255197
-
255198
- // src/cli/dev/dev-server/function-manager.ts
255199
255123
  var READY_TIMEOUT = 30000;
255200
255124
 
255201
255125
  class FunctionManager {
@@ -255278,11 +255202,10 @@ class FunctionManager {
255278
255202
  }
255279
255203
  spawnFunction(func, port) {
255280
255204
  this.logger.log(`Spawning function "${func.name}" on port ${port}`);
255281
- const importMapArg = buildImportMapArg(join26(dirname20(this.wrapperPath), "import-map.json"), globalThis.process.cwd());
255282
- const process21 = spawn2("deno", ["run", "--allow-all", "--import-map", importMapArg, this.wrapperPath], {
255205
+ const process21 = spawn2("deno", ["run", "--allow-all", this.wrapperPath], {
255283
255206
  env: {
255284
255207
  ...globalThis.process.env,
255285
- FUNCTION_PATH: pathToFileURL6(func.entryPath).href,
255208
+ FUNCTION_PATH: pathToFileURL(func.entryPath).href,
255286
255209
  FUNCTION_PORT: String(port),
255287
255210
  FUNCTION_NAME: func.name
255288
255211
  },
@@ -257382,9 +257305,9 @@ class NodeFsHandler {
257382
257305
  if (this.fsw.closed) {
257383
257306
  return;
257384
257307
  }
257385
- const dirname22 = sp2.dirname(file2);
257308
+ const dirname20 = sp2.dirname(file2);
257386
257309
  const basename7 = sp2.basename(file2);
257387
- const parent = this.fsw._getWatchedDir(dirname22);
257310
+ const parent = this.fsw._getWatchedDir(dirname20);
257388
257311
  let prevStats = stats;
257389
257312
  if (parent.has(basename7))
257390
257313
  return;
@@ -257411,7 +257334,7 @@ class NodeFsHandler {
257411
257334
  prevStats = newStats2;
257412
257335
  }
257413
257336
  } catch (error48) {
257414
- this.fsw._remove(dirname22, basename7);
257337
+ this.fsw._remove(dirname20, basename7);
257415
257338
  }
257416
257339
  } else if (parent.has(basename7)) {
257417
257340
  const at13 = newStats.atimeMs;
@@ -258444,8 +258367,8 @@ async function createDevServer(options8) {
258444
258367
  broadcastEntityEvent(io6, appId, entityName, event);
258445
258368
  };
258446
258369
  const base44ConfigWatcher = new WatchBase44({
258447
- functions: join29(dirname23(project2.configPath), project2.functionsDir),
258448
- entities: join29(dirname23(project2.configPath), project2.entitiesDir)
258370
+ functions: join27(dirname21(project2.configPath), project2.functionsDir),
258371
+ entities: join27(dirname21(project2.configPath), project2.entitiesDir)
258449
258372
  }, devLogger);
258450
258373
  base44ConfigWatcher.on("change", async (name2) => {
258451
258374
  try {
@@ -258840,7 +258763,7 @@ var import_detect_agent = __toESM(require_dist5(), 1);
258840
258763
  import { release, type } from "node:os";
258841
258764
 
258842
258765
  // ../../node_modules/posthog-node/dist/extensions/error-tracking/modifiers/module.node.mjs
258843
- import { dirname as dirname24, posix, sep } from "path";
258766
+ import { dirname as dirname22, posix, sep } from "path";
258844
258767
  function createModulerModifier() {
258845
258768
  const getModuleFromFileName = createGetModuleFromFilename();
258846
258769
  return async (frames) => {
@@ -258849,7 +258772,7 @@ function createModulerModifier() {
258849
258772
  return frames;
258850
258773
  };
258851
258774
  }
258852
- function createGetModuleFromFilename(basePath = process.argv[1] ? dirname24(process.argv[1]) : process.cwd(), isWindows5 = sep === "\\") {
258775
+ function createGetModuleFromFilename(basePath = process.argv[1] ? dirname22(process.argv[1]) : process.cwd(), isWindows5 = sep === "\\") {
258853
258776
  const normalizedBase = isWindows5 ? normalizeWindowsPath2(basePath) : basePath;
258854
258777
  return (filename) => {
258855
258778
  if (!filename)
@@ -263038,9 +262961,9 @@ function addCommandInfoToErrorReporter(program2, errorReporter) {
263038
262961
  });
263039
262962
  }
263040
262963
  // src/cli/index.ts
263041
- var __dirname4 = dirname25(fileURLToPath6(import.meta.url));
262964
+ var __dirname4 = dirname23(fileURLToPath6(import.meta.url));
263042
262965
  async function runCLI(options8) {
263043
- ensureNpmAssets(join30(__dirname4, "../assets"));
262966
+ ensureNpmAssets(join28(__dirname4, "../assets"));
263044
262967
  const errorReporter = new ErrorReporter;
263045
262968
  errorReporter.registerProcessErrorHandlers();
263046
262969
  const jsonMode = process.argv.includes("--json");
@@ -263079,4 +263002,4 @@ export {
263079
263002
  CLIExitError
263080
263003
  };
263081
263004
 
263082
- //# debugId=81AA053654470EFC64756E2164756E21
263005
+ //# debugId=E927ADA2FAB329A664756E2164756E21