@dotenvage/node 0.3.1 → 0.3.2

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.
Binary file
Binary file
Binary file
Binary file
Binary file
package/nextjs/config.mjs CHANGED
@@ -1,59 +1,41 @@
1
1
  /**
2
2
  * Next.js configuration wrapper for dotenvage integration.
3
3
  *
4
- * This wrapper can be used in two ways:
5
- *
6
- * 1. **With wrapper script (recommended for Edge Runtime):**
7
- * Use `dotenvage-next` bin script to start Next.js:
8
- * "dev": "dotenvage-next dev"
9
- * "build": "dotenvage-next build"
10
- * The wrapper script loads env vars BEFORE Next.js starts, ensuring
11
- * they're available everywhere including Edge Runtime.
12
- *
13
- * 2. **Without wrapper script (server-side only, no Edge Runtime):**
14
- * Use `loadEnv()` from `@dotenvage/node/nextjs` in your config file:
15
- * import { loadEnv } from '@dotenvage/node/nextjs'
16
- * loadEnv()
17
- * Note: This only works for server-side code, not Edge Runtime/middleware.
4
+ * Wrapping your Next.js config with `withDotenvage()` ensures that
5
+ * encrypted .env files are decrypted and loaded into `process.env`
6
+ * when `next.config.mjs` is evaluated (at build time and dev startup).
18
7
  *
19
8
  * Usage in next.config.mjs:
20
9
  * import { withDotenvage } from '@dotenvage/node/nextjs/config'
21
- * import nextMDX from '@next/mdx'
22
- *
23
- * const nextConfig = {
24
- * // your config
25
- * }
26
10
  *
11
+ * const nextConfig = { ... }
27
12
  * export default withDotenvage(nextConfig)
28
13
  *
29
- * IMPORTANT: When using `dotenvage-next` wrapper script, env vars are
30
- * already loaded, so this wrapper is just a pass-through for consistency.
31
- * When NOT using the wrapper script, use `loadEnv()` directly in your config.
14
+ * If the `dotenvage-next` wrapper script already loaded env vars,
15
+ * `loadEnv()` is a no-op (idempotent).
32
16
  */
17
+ import { loadEnv } from "./loader.mjs";
33
18
 
34
19
  /**
35
20
  * Wraps a Next.js configuration object.
36
- * This is mainly for convenience and API consistency.
37
- * When using `dotenvage-next` wrapper script, env vars are already loaded.
21
+ * Loads encrypted .env files via dotenvage before returning the config.
38
22
  *
39
23
  * @param {import('next').NextConfig | ((phase: string) => import('next').NextConfig)} config - Next.js config object or function
40
- * @returns {import('next').NextConfig | ((phase: string) => import('next').NextConfig)} The same config (pass-through)
24
+ * @returns {import('next').NextConfig | ((phase: string) => import('next').NextConfig)} The same config, after loading env vars
41
25
  */
42
26
  export function withDotenvage(config) {
43
- // Pass-through wrapper for API consistency
44
- // When using `dotenvage-next` wrapper script, env vars are already loaded
27
+ loadEnv();
45
28
  return config;
46
29
  }
47
30
 
48
31
  /**
49
- * Wraps a Next.js configuration function to ensure dotenvage is loaded.
50
- * Useful when you need to access the build phase.
32
+ * Wraps a Next.js configuration function.
33
+ * Loads encrypted .env files via dotenvage before returning the function.
51
34
  *
52
35
  * @param {(phase: string, defaultConfig: import('next').NextConfig) => import('next').NextConfig} configFn - Next.js config function
53
- * @returns {(phase: string, defaultConfig: import('next').NextConfig) => import('next').NextConfig} The same function (pass-through)
36
+ * @returns {(phase: string, defaultConfig: import('next').NextConfig) => import('next').NextConfig} The same function, after loading env vars
54
37
  */
55
38
  export function withDotenvageConfig(configFn) {
56
- // Pass-through wrapper for API consistency
57
- // When using `dotenvage-next` wrapper script, env vars are already loaded
39
+ loadEnv();
58
40
  return configFn;
59
41
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotenvage/node",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "Node.js bindings for dotenvage - Dotenv with age encryption",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",