@base44-preview/cli 0.0.45-pr.420.aabc644 → 0.0.45-pr.420.b567bca

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.
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Deno Function Wrapper
3
+ *
4
+ * This script is executed by Deno to run user functions.
5
+ * It patches Deno.serve to inject a dynamic port before importing the user's function.
6
+ *
7
+ * Environment variables:
8
+ * - FUNCTION_PATH: Absolute path to the user's function entry file
9
+ * - FUNCTION_PORT: Port number for the function to listen on
10
+ * - FUNCTION_NAME: Name of the function (for logging)
11
+ */
12
+
13
+ // Make this file a module for top-level await support
14
+ export {};
15
+
16
+ const functionPath = Deno.env.get("FUNCTION_PATH");
17
+ const port = parseInt(Deno.env.get("FUNCTION_PORT") || "8000", 10);
18
+ const functionName = Deno.env.get("FUNCTION_NAME") || "unknown";
19
+
20
+ if (!functionPath) {
21
+ console.error("[wrapper] FUNCTION_PATH environment variable is required");
22
+ Deno.exit(1);
23
+ }
24
+
25
+ // Store the original Deno.serve
26
+ const originalServe = Deno.serve.bind(Deno);
27
+
28
+ // Patch Deno.serve to inject our port and add onListen callback
29
+ // @ts-expect-error - We're intentionally overriding Deno.serve
30
+ Deno.serve = (
31
+ optionsOrHandler:
32
+ | Deno.ServeOptions
33
+ | Deno.ServeHandler
34
+ | (Deno.ServeOptions & { handler: Deno.ServeHandler }),
35
+ maybeHandler?: Deno.ServeHandler,
36
+ ): Deno.HttpServer<Deno.NetAddr> => {
37
+ const onListen = () => {
38
+ // This message is used by FunctionManager to detect when the function is ready
39
+ console.log(`[${functionName}] Listening on http://localhost:${port}`);
40
+ };
41
+
42
+ // Handle the different Deno.serve signatures:
43
+ // 1. Deno.serve(handler)
44
+ // 2. Deno.serve(options, handler)
45
+ // 3. Deno.serve({ ...options, handler })
46
+ if (typeof optionsOrHandler === "function") {
47
+ // Signature: Deno.serve(handler)
48
+ return originalServe({ port, onListen }, optionsOrHandler);
49
+ }
50
+
51
+ if (maybeHandler) {
52
+ // Signature: Deno.serve(options, handler)
53
+ return originalServe({ ...optionsOrHandler, port, onListen }, maybeHandler);
54
+ }
55
+
56
+ // Signature: Deno.serve({ ...options, handler })
57
+ const options = optionsOrHandler as Deno.ServeOptions & {
58
+ handler: Deno.ServeHandler;
59
+ };
60
+ return originalServe({ ...options, port, onListen });
61
+ };
62
+
63
+ console.log(`[${functionName}] Starting function from ${functionPath}`);
64
+
65
+ // Dynamically import the user's function
66
+ // The function will call Deno.serve which is now patched to use our port
67
+ try {
68
+ await import(functionPath);
69
+ } catch (error) {
70
+ console.error(`[${functionName}] Failed to load function:`, error);
71
+ Deno.exit(1);
72
+ }
package/dist/cli/index.js CHANGED
@@ -167116,8 +167116,8 @@ var require_factory = __commonJS((exports) => {
167116
167116
  exports.createProxyMiddleware = createProxyMiddleware;
167117
167117
  var http_proxy_middleware_1 = require_http_proxy_middleware();
167118
167118
  function createProxyMiddleware(options8) {
167119
- const { middleware: middleware2 } = new http_proxy_middleware_1.HttpProxyMiddleware(options8);
167120
- return middleware2;
167119
+ const { middleware } = new http_proxy_middleware_1.HttpProxyMiddleware(options8);
167120
+ return middleware;
167121
167121
  }
167122
167122
  });
167123
167123
 
@@ -246140,7 +246140,7 @@ function getTemplatesIndexPath() {
246140
246140
  return join8(ASSETS_DIR, "templates", "templates.json");
246141
246141
  }
246142
246142
  function getDenoWrapperPath() {
246143
- return join8(ASSETS_DIR, "deno-runtime", "main.js");
246143
+ return join8(ASSETS_DIR, "deno-runtime", "main.ts");
246144
246144
  }
246145
246145
  function ensureNpmAssets(sourceDir) {
246146
246146
  if (existsSync(ASSETS_DIR))
@@ -246901,7 +246901,10 @@ async function logout() {
246901
246901
  return { outroMessage: "Logged out successfully" };
246902
246902
  }
246903
246903
  function getLogoutCommand() {
246904
- return new Base44Command("logout", { requireAppConfig: false }).description("Logout from current device").action(logout);
246904
+ return new Base44Command("logout", {
246905
+ requireAuth: false,
246906
+ requireAppConfig: false
246907
+ }).description("Logout from current device").action(logout);
246905
246908
  }
246906
246909
 
246907
246910
  // src/cli/commands/auth/whoami.ts
@@ -248214,12 +248217,21 @@ function getCreateCommand() {
248214
248217
  Examples:
248215
248218
  $ base44 create my-app Creates a base44 project at ./my-app
248216
248219
  $ base44 create my-todo-app --template backend-and-client Creates a base44 backend-and-client project at ./my-todo-app
248217
- $ base44 create my-app --path ./projects/my-app --deploy Creates a base44 project at ./project/my-app and deploys it`).hook("preAction", validateNonInteractiveFlags).action(async (name2, options) => {
248220
+ $ base44 create my-app --path ./projects/my-app --deploy Creates a base44 project at ./project/my-app and deploys it`).hook("preAction", validateNonInteractiveFlags).action(async (name2, options, command2) => {
248218
248221
  if (name2 && !options.path) {
248219
248222
  options.path = `./${import_kebabCase.default(name2)}`;
248220
248223
  }
248221
- const isNonInteractive = !!(options.name ?? name2) && !!options.path;
248222
- if (isNonInteractive) {
248224
+ const skipPrompts = !!(options.name ?? name2) && !!options.path;
248225
+ if (!skipPrompts && command2.isNonInteractive) {
248226
+ throw new InvalidInputError("Project name and --path are required in non-interactive mode", {
248227
+ hints: [
248228
+ {
248229
+ message: "Usage: base44 create <name> --path <path>"
248230
+ }
248231
+ ]
248232
+ });
248233
+ }
248234
+ if (skipPrompts) {
248223
248235
  return await createNonInteractive({
248224
248236
  name: options.name ?? name2,
248225
248237
  ...options
@@ -248295,6 +248307,9 @@ ${summaryLines.join(`
248295
248307
  }
248296
248308
  function getDeployCommand2() {
248297
248309
  return new Base44Command("deploy").description("Deploy all project resources (entities, functions, agents, connectors, and site)").option("-y, --yes", "Skip confirmation prompt").action(async (options, command2) => {
248310
+ if (command2.isNonInteractive && !options.yes) {
248311
+ throw new InvalidInputError("--yes is required in non-interactive mode");
248312
+ }
248298
248313
  return await deployAction({
248299
248314
  ...options,
248300
248315
  isNonInteractive: command2.isNonInteractive
@@ -248462,7 +248477,11 @@ async function link(options) {
248462
248477
  return { outroMessage: "Project linked" };
248463
248478
  }
248464
248479
  function getLinkCommand() {
248465
- return new Base44Command("link", { requireAppConfig: false }).description("Link a local project to a Base44 project (create new or link existing)").option("-c, --create", "Create a new project (skip selection prompt)").option("-n, --name <name>", "Project name (required when --create is used)").option("-d, --description <description>", "Project description").option("-p, --projectId <id>", "Project ID to link to an existing project (skips selection prompt)").hook("preAction", validateNonInteractiveFlags2).action(async (options) => {
248480
+ return new Base44Command("link", { requireAppConfig: false }).description("Link a local project to a Base44 project (create new or link existing)").option("-c, --create", "Create a new project (skip selection prompt)").option("-n, --name <name>", "Project name (required when --create is used)").option("-d, --description <description>", "Project description").option("-p, --projectId <id>", "Project ID to link to an existing project (skips selection prompt)").hook("preAction", validateNonInteractiveFlags2).action(async (options, command2) => {
248481
+ const skipPrompts = !!options.create || !!options.projectId;
248482
+ if (!skipPrompts && command2.isNonInteractive) {
248483
+ throw new InvalidInputError("Either --create --name <name> or --projectId <id> is required in non-interactive mode");
248484
+ }
248466
248485
  return await link(options);
248467
248486
  });
248468
248487
  }
@@ -248724,6 +248743,9 @@ async function deployAction2(options) {
248724
248743
  }
248725
248744
  function getSiteDeployCommand() {
248726
248745
  return new Base44Command("deploy").description("Deploy built site files to Base44 hosting").option("-y, --yes", "Skip confirmation prompt").action(async (options, command2) => {
248746
+ if (command2.isNonInteractive && !options.yes) {
248747
+ throw new InvalidInputError("--yes is required in non-interactive mode");
248748
+ }
248727
248749
  return await deployAction2({
248728
248750
  ...options,
248729
248751
  isNonInteractive: command2.isNonInteractive
@@ -251754,6 +251776,12 @@ async function eject(options8) {
251754
251776
  }
251755
251777
  function getEjectCommand() {
251756
251778
  return new Base44Command("eject", { requireAppConfig: false }).description("Download the code for an existing Base44 project").option("-p, --path <path>", "Path where to write the project").option("--project-id <id>", "Project ID to eject (skips interactive selection)").option("-y, --yes", "Skip confirmation prompts").action(async (options8, command2) => {
251779
+ if (command2.isNonInteractive && !options8.projectId) {
251780
+ throw new InvalidInputError("--project-id is required in non-interactive mode");
251781
+ }
251782
+ if (command2.isNonInteractive && !options8.path) {
251783
+ throw new InvalidInputError("--path is required in non-interactive mode");
251784
+ }
251757
251785
  return await eject({
251758
251786
  ...options8,
251759
251787
  isNonInteractive: command2.isNonInteractive
@@ -256031,4 +256059,4 @@ export {
256031
256059
  CLIExitError
256032
256060
  };
256033
256061
 
256034
- //# debugId=599E781F6D11AED264756E2164756E21
256062
+ //# debugId=C720DFBF6A5E10BF64756E2164756E21