@base44-preview/cli 0.1.5-pr.576.d292892 → 0.1.5-pr.578.bad1ac7

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
- }
@@ -9,7 +9,8 @@
9
9
  "preview": "vite preview"
10
10
  },
11
11
  "dependencies": {
12
- "@base44/sdk": "^0.8.3",
12
+ "@base44/sdk": "^0.8.40",
13
+ "@base44/vite-plugin": "^1.0.30",
13
14
  "lucide-react": "^0.475.0",
14
15
  "react": "^18.2.0",
15
16
  "react-dom": "^18.2.0"
@@ -0,0 +1,14 @@
1
+ import { createClient } from '@base44/sdk';
2
+ import { appParams } from '@/lib/app-params';
3
+
4
+ const { appId, token, functionsVersion, appBaseUrl } = appParams;
5
+
6
+ //Create a client with authentication required
7
+ export const base44 = createClient({
8
+ appId,
9
+ token,
10
+ functionsVersion,
11
+ serverUrl: '',
12
+ requiresAuth: false,
13
+ appBaseUrl
14
+ });
@@ -0,0 +1,54 @@
1
+ const isNode = typeof window === 'undefined';
2
+ const windowObj = isNode ? { localStorage: new Map() } : window;
3
+ const storage = windowObj.localStorage;
4
+
5
+ const toSnakeCase = (str) => {
6
+ return str.replace(/([A-Z])/g, '_$1').toLowerCase();
7
+ }
8
+
9
+ const getAppParamValue = (paramName, { defaultValue = undefined, removeFromUrl = false } = {}) => {
10
+ if (isNode) {
11
+ return defaultValue;
12
+ }
13
+ const storageKey = `base44_${toSnakeCase(paramName)}`;
14
+ const urlParams = new URLSearchParams(window.location.search);
15
+ const searchParam = urlParams.get(paramName);
16
+ if (removeFromUrl) {
17
+ urlParams.delete(paramName);
18
+ const newUrl = `${window.location.pathname}${urlParams.toString() ? `?${urlParams.toString()}` : ""
19
+ }${window.location.hash}`;
20
+ window.history.replaceState({}, document.title, newUrl);
21
+ }
22
+ if (searchParam) {
23
+ storage.setItem(storageKey, searchParam);
24
+ return searchParam;
25
+ }
26
+ if (defaultValue) {
27
+ storage.setItem(storageKey, defaultValue);
28
+ return defaultValue;
29
+ }
30
+ const storedValue = storage.getItem(storageKey);
31
+ if (storedValue) {
32
+ return storedValue;
33
+ }
34
+ return null;
35
+ }
36
+
37
+ const getAppParams = () => {
38
+ if (getAppParamValue("clear_access_token") === 'true') {
39
+ storage.removeItem('base44_access_token');
40
+ storage.removeItem('token');
41
+ }
42
+ return {
43
+ appId: getAppParamValue("app_id", { defaultValue: import.meta.env.VITE_BASE44_APP_ID }),
44
+ token: getAppParamValue("access_token", { removeFromUrl: true }),
45
+ fromUrl: getAppParamValue("from_url", { defaultValue: window.location.href }),
46
+ functionsVersion: getAppParamValue("functions_version", { defaultValue: import.meta.env.VITE_BASE44_FUNCTIONS_VERSION }),
47
+ appBaseUrl: getAppParamValue("app_base_url", { defaultValue: import.meta.env.VITE_BASE44_APP_BASE_URL }),
48
+ }
49
+ }
50
+
51
+
52
+ export const appParams = {
53
+ ...getAppParams()
54
+ }
@@ -1,12 +1,7 @@
1
- import { defineConfig } from 'vite';
1
+ import base44 from '@base44/vite-plugin';
2
2
  import react from '@vitejs/plugin-react';
3
- import path from 'path';
3
+ import { defineConfig } from 'vite';
4
4
 
5
5
  export default defineConfig({
6
- plugins: [react()],
7
- resolve: {
8
- alias: {
9
- '@': path.resolve(__dirname, './src'),
10
- },
11
- },
6
+ plugins: [base44(), react()],
12
7
  });
package/dist/cli/index.js CHANGED
@@ -214616,7 +214616,7 @@ var require_buffer_list = __commonJS((exports, module) => {
214616
214616
  }
214617
214617
  }, {
214618
214618
  key: "join",
214619
- value: function join26(s5) {
214619
+ value: function join25(s5) {
214620
214620
  if (this.length === 0)
214621
214621
  return "";
214622
214622
  var p4 = this.head;
@@ -234033,7 +234033,7 @@ function normalizeBase44Env() {
234033
234033
  loadProjectEnvFiles();
234034
234034
 
234035
234035
  // src/cli/index.ts
234036
- import { dirname as dirname24, join as join29 } 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 dirname22, join as join28 } 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,7 +255119,6 @@ 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 dirname19, join as join25 } from "node:path";
255127
255122
  import { pathToFileURL } from "node:url";
255128
255123
  var READY_TIMEOUT = 30000;
255129
255124
 
@@ -255207,8 +255202,7 @@ class FunctionManager {
255207
255202
  }
255208
255203
  spawnFunction(func, port) {
255209
255204
  this.logger.log(`Spawning function "${func.name}" on port ${port}`);
255210
- const importMapPath = join25(dirname19(this.wrapperPath), "import-map.json");
255211
- const process21 = spawn2("deno", ["run", "--allow-all", "--import-map", importMapPath, this.wrapperPath], {
255205
+ const process21 = spawn2("deno", ["run", "--allow-all", this.wrapperPath], {
255212
255206
  env: {
255213
255207
  ...globalThis.process.env,
255214
255208
  FUNCTION_PATH: pathToFileURL(func.entryPath).href,
@@ -257311,9 +257305,9 @@ class NodeFsHandler {
257311
257305
  if (this.fsw.closed) {
257312
257306
  return;
257313
257307
  }
257314
- const dirname21 = sp2.dirname(file2);
257308
+ const dirname20 = sp2.dirname(file2);
257315
257309
  const basename7 = sp2.basename(file2);
257316
- const parent = this.fsw._getWatchedDir(dirname21);
257310
+ const parent = this.fsw._getWatchedDir(dirname20);
257317
257311
  let prevStats = stats;
257318
257312
  if (parent.has(basename7))
257319
257313
  return;
@@ -257340,7 +257334,7 @@ class NodeFsHandler {
257340
257334
  prevStats = newStats2;
257341
257335
  }
257342
257336
  } catch (error48) {
257343
- this.fsw._remove(dirname21, basename7);
257337
+ this.fsw._remove(dirname20, basename7);
257344
257338
  }
257345
257339
  } else if (parent.has(basename7)) {
257346
257340
  const at13 = newStats.atimeMs;
@@ -258373,8 +258367,8 @@ async function createDevServer(options8) {
258373
258367
  broadcastEntityEvent(io6, appId, entityName, event);
258374
258368
  };
258375
258369
  const base44ConfigWatcher = new WatchBase44({
258376
- functions: join28(dirname22(project2.configPath), project2.functionsDir),
258377
- entities: join28(dirname22(project2.configPath), project2.entitiesDir)
258370
+ functions: join27(dirname21(project2.configPath), project2.functionsDir),
258371
+ entities: join27(dirname21(project2.configPath), project2.entitiesDir)
258378
258372
  }, devLogger);
258379
258373
  base44ConfigWatcher.on("change", async (name2) => {
258380
258374
  try {
@@ -258769,7 +258763,7 @@ var import_detect_agent = __toESM(require_dist5(), 1);
258769
258763
  import { release, type } from "node:os";
258770
258764
 
258771
258765
  // ../../node_modules/posthog-node/dist/extensions/error-tracking/modifiers/module.node.mjs
258772
- import { dirname as dirname23, posix, sep } from "path";
258766
+ import { dirname as dirname22, posix, sep } from "path";
258773
258767
  function createModulerModifier() {
258774
258768
  const getModuleFromFileName = createGetModuleFromFilename();
258775
258769
  return async (frames) => {
@@ -258778,7 +258772,7 @@ function createModulerModifier() {
258778
258772
  return frames;
258779
258773
  };
258780
258774
  }
258781
- function createGetModuleFromFilename(basePath = process.argv[1] ? dirname23(process.argv[1]) : process.cwd(), isWindows5 = sep === "\\") {
258775
+ function createGetModuleFromFilename(basePath = process.argv[1] ? dirname22(process.argv[1]) : process.cwd(), isWindows5 = sep === "\\") {
258782
258776
  const normalizedBase = isWindows5 ? normalizeWindowsPath2(basePath) : basePath;
258783
258777
  return (filename) => {
258784
258778
  if (!filename)
@@ -262967,9 +262961,9 @@ function addCommandInfoToErrorReporter(program2, errorReporter) {
262967
262961
  });
262968
262962
  }
262969
262963
  // src/cli/index.ts
262970
- var __dirname4 = dirname24(fileURLToPath6(import.meta.url));
262964
+ var __dirname4 = dirname23(fileURLToPath6(import.meta.url));
262971
262965
  async function runCLI(options8) {
262972
- ensureNpmAssets(join29(__dirname4, "../assets"));
262966
+ ensureNpmAssets(join28(__dirname4, "../assets"));
262973
262967
  const errorReporter = new ErrorReporter;
262974
262968
  errorReporter.registerProcessErrorHandlers();
262975
262969
  const jsonMode = process.argv.includes("--json");
@@ -263008,4 +263002,4 @@ export {
263008
263002
  CLIExitError
263009
263003
  };
263010
263004
 
263011
- //# debugId=95C06FCD441C783464756E2164756E21
263005
+ //# debugId=E927ADA2FAB329A664756E2164756E21