@base44-preview/cli 0.0.45-pr.422.0f6b58f → 0.0.45-pr.422.aeaffc8

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
@@ -141617,12 +141617,12 @@ var require_linker = __commonJS((exports) => {
141617
141617
  var require_optionValidator = __commonJS((exports) => {
141618
141618
  Object.defineProperty(exports, "__esModule", { value: true });
141619
141619
  exports.validateOptions = undefined;
141620
- function validateOptions2({ maxItems }) {
141620
+ function validateOptions3({ maxItems }) {
141621
141621
  if (maxItems !== undefined && maxItems < -1) {
141622
141622
  throw RangeError(`Expected options.maxItems to be >= -1, but was given ${maxItems}.`);
141623
141623
  }
141624
141624
  }
141625
- exports.validateOptions = validateOptions2;
141625
+ exports.validateOptions = validateOptions3;
141626
141626
  });
141627
141627
 
141628
141628
  // ../../node_modules/json-schema-to-typescript/dist/src/index.js
@@ -238807,7 +238807,7 @@ function getTemplatesIndexPath() {
238807
238807
  return join8(ASSETS_DIR, "templates", "templates.json");
238808
238808
  }
238809
238809
  function getDenoWrapperPath() {
238810
- return join8(ASSETS_DIR, "deno-runtime", "main.js");
238810
+ return join8(ASSETS_DIR, "deno-runtime", "main.ts");
238811
238811
  }
238812
238812
  function ensureNpmAssets(sourceDir) {
238813
238813
  if (existsSync(ASSETS_DIR))
@@ -246897,20 +246897,38 @@ async function updatePasswordAuth(enable) {
246897
246897
  return await updateAuthConfig({ enableUsernamePassword: enable });
246898
246898
  }
246899
246899
  // src/cli/commands/auth/password-login.ts
246900
- async function passwordLoginAction() {
246901
- const current = await runTask("Fetching current auth config", async () => await getAuthConfig());
246902
- const currentStatus = current.enableUsernamePassword ? "enabled" : "disabled";
246903
- R2.info(`Username & password authentication is currently ${currentStatus}.`);
246904
- const shouldEnable = await Re({
246905
- message: "Enable username & password authentication?",
246906
- initialValue: current.enableUsernamePassword
246907
- });
246908
- if (Ct(shouldEnable)) {
246909
- throw new CLIExitError(0);
246900
+ function validateOptions2(options) {
246901
+ const errors5 = [];
246902
+ if (!options.enable && !options.disable) {
246903
+ errors5.push("Missing required flag: specify --enable or --disable");
246904
+ }
246905
+ if (options.enable && options.disable) {
246906
+ errors5.push("Conflicting flags: --enable and --disable cannot be used together");
246910
246907
  }
246908
+ if (errors5.length > 0) {
246909
+ throw new InvalidInputError(errors5.join(`
246910
+ `), {
246911
+ hints: [
246912
+ {
246913
+ message: "Enable password auth: base44 auth password-login --enable",
246914
+ command: "base44 auth password-login --enable"
246915
+ },
246916
+ {
246917
+ message: "Disable password auth: base44 auth password-login --disable",
246918
+ command: "base44 auth password-login --disable"
246919
+ }
246920
+ ]
246921
+ });
246922
+ }
246923
+ }
246924
+ async function passwordLoginAction(options) {
246925
+ validateOptions2(options);
246926
+ const shouldEnable = !!options.enable;
246927
+ const current = await runTask("Fetching current auth config", async () => await getAuthConfig());
246911
246928
  if (shouldEnable === current.enableUsernamePassword) {
246929
+ const status = shouldEnable ? "enabled" : "disabled";
246912
246930
  return {
246913
- outroMessage: `Username & password authentication is already ${currentStatus}`
246931
+ outroMessage: `Username & password authentication is already ${status}`
246914
246932
  };
246915
246933
  }
246916
246934
  if (!shouldEnable) {
@@ -246920,13 +246938,6 @@ async function passwordLoginAction() {
246920
246938
  };
246921
246939
  if (!hasAnyLoginMethod(configWithoutPassword)) {
246922
246940
  R2.warn("Disabling password auth will leave no login methods enabled. Users will be locked out.");
246923
- const proceed = await Re({
246924
- message: "Are you sure you want to continue?",
246925
- initialValue: false
246926
- });
246927
- if (Ct(proceed) || !proceed) {
246928
- throw new CLIExitError(0);
246929
- }
246930
246941
  }
246931
246942
  }
246932
246943
  const action = shouldEnable ? "Enabling" : "Disabling";
@@ -246937,8 +246948,8 @@ async function passwordLoginAction() {
246937
246948
  };
246938
246949
  }
246939
246950
  function getPasswordLoginCommand(context) {
246940
- return new Command("password-login").description("Enable or disable username & password authentication").action(async () => {
246941
- await runCommand(passwordLoginAction, { requireAuth: true }, context);
246951
+ return new Command("password-login").description("Enable or disable username & password authentication").option("--enable", "Enable password authentication").option("--disable", "Disable password authentication").action(async (options) => {
246952
+ await runCommand(() => passwordLoginAction(options), { requireAuth: true }, context);
246942
246953
  });
246943
246954
  }
246944
246955
 
@@ -256096,4 +256107,4 @@ export {
256096
256107
  CLIExitError
256097
256108
  };
256098
256109
 
256099
- //# debugId=7653CD16B4DE4AF964756E2164756E21
256110
+ //# debugId=632B525105C21B8164756E2164756E21