@wolfstar/env-utilities 2.1.0 → 2.2.0

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.
package/README.md CHANGED
@@ -61,6 +61,29 @@ Files on the left have more priority than files on the right:
61
61
 
62
62
  [CRA Reference](https://create-react-app.dev/docs/adding-custom-environment-variables/#what-other-env-files-can-be-used)
63
63
 
64
+ ### Experimental: [varlock](https://varlock.dev) support
65
+
66
+ `@wolfstar/env-utilities` can optionally delegate environment variable resolution to
67
+ [varlock](https://varlock.dev), a schema-based alternative to `dotenv` with built-in validation, type-safety, and
68
+ secret protection. Support for it is **experimental**.
69
+
70
+ To use it, first set up varlock in your project (`npx varlock init`) and install the optional `varlock` package, then
71
+ opt in via the `loader` option or the `DOTENV_LOADER` environment variable:
72
+
73
+ ```typescript
74
+ import { setup } from '@wolfstar/env-utilities';
75
+
76
+ setup({ loader: 'varlock' });
77
+ ```
78
+
79
+ ```
80
+ DOTENV_LOADER=varlock
81
+ ```
82
+
83
+ When `loader: 'varlock'` is set, varlock resolves your checked-in `.env.schema` (with its own `.env*` file discovery
84
+ and validation) and injects the result into `process.env`; the dotenv-specific options above (`encoding`, `path`,
85
+ `env`) are ignored in favour of the schema. `prefix` still applies to the resolved variables.
86
+
64
87
  ### Typing Environment Variables
65
88
 
66
89
  To add new entries, you augment `Env` from `@wolfstar/env-utilities/dist/lib/types` using any of the following types:
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_src = require('./src-B2pnGjJn.cjs');
2
+ const require_src = require('./src-DCzHag6L.cjs');
3
3
 
4
4
  exports.envIsDefined = require_src.envIsDefined;
5
5
  exports.envIsNull = require_src.envIsNull;
@@ -28,6 +28,19 @@ interface EnvLoaderOptions extends Omit<DotenvConfigOptions, 'path'> {
28
28
  * ```
29
29
  */
30
30
  path?: string | URL;
31
+ /**
32
+ * **Experimental.** Selects the loader used to resolve environment variables.
33
+ *
34
+ * - `'dotenv'` (default): loads and merges `.env*` files with `dotenv`/`dotenv-expand`, as documented on the
35
+ * other options.
36
+ * - `'varlock'`: delegates to {@link https://varlock.dev | varlock} instead of `dotenv`. Varlock resolves a
37
+ * checked-in `.env.schema` (with its own `.env*` file discovery and validation) via its CLI and injects the
38
+ * result into `process.env`. When selected, `encoding`, `path`, and `env` are ignored — configure the schema
39
+ * itself instead. Requires the optional `varlock` package to be installed.
40
+ *
41
+ * @default 'dotenv'
42
+ */
43
+ loader?: 'dotenv' | 'varlock';
31
44
  }
32
45
  //#endregion
33
46
  //#region src/lib/setup.d.ts
@@ -60,6 +73,11 @@ export interface Env {
60
73
  DOTENV_ENV?: string;
61
74
  DOTENV_PATH?: string;
62
75
  DOTENV_PREFIX?: string;
76
+ /**
77
+ * **Experimental.** Selects the loader used by `setup()`: `'dotenv'` (default) or `'varlock'` (see
78
+ * {@link https://varlock.dev}).
79
+ */
80
+ DOTENV_LOADER?: 'dotenv' | 'varlock';
63
81
  }
64
82
  //#endregion
65
83
  //#region src/lib/utils.d.ts
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/lib/env-loader.ts","../../src/lib/setup.ts","../../src/lib/types.ts","../../src/lib/utils.ts","../../src/index.ts"],"mappings":";;UAMiB,yBAAyB,KAAK;;;;EAI9C;;;;EAIA;;;;;;;;;;;;;;;;;;;EAmBA,gBAAgB;;;;wBC5BD,MAAM,yBAAyB,MAAM,kBAAkB;iBA8BtD,wBAAwB,KAAK;;;;EAI7C,gBAAgB;;YAGL,iBAAiB;;;YC1CjB;YACA;YACA;YACA;EAAyB;;YAEzB,eAAe;YACf,eAAe,KAAK,SAAS,IAAI,WAAW,gBAAgB,gBAAgB,uBAAuB,KAAI;YACvG,gBAAgB,KAAK,SAAS,IAAI,WAAW,4BAA4B,aAAY;YACrF,gBAAgB,KAAK,SAAS,IAAI,WAAW,4BAA4B,aAAY;YACrF,eAAe,KAAK,SAAS,IAAI,WAAW,2BAA2B,aAAY;YACnF,cAAc,KAAK,SAAS,IAAI,WAAW,0BAA0B,aAAY;iBAE5E;EAChB;EACA,eAAe;EACf;EACA;EACA;EACA;;;;wBChBe,gBAAgB,KAAK,YAAY;wBACjC,gBAAgB,KAAK,YAAY;wBAajC,eAAe,KAAK,WAAW;wBAC/B,eAAe,KAAK,WAAW;wBAa/B,gBAAgB,KAAK,YAAY;wBACjC,gBAAgB,KAAK,YAAY;wBAajC,eAAe,UAAU,WAAW,KAAK,GAAG,eAAe,IAAI,KAAK,YAAY,IAAI;wBACpF,eAAe,UAAU,WAAW,KAAK,GAAG,cAAc,IAAI,YAAY,YAAY,IAAI;wBAW1F,cAAc,KAAK,UAAU;wBAC7B,cAAc,KAAK,UAAU;;;;;;;;wBAkB7B,UAAU,KAAK;;;;;;;;wBAYf,eAAe,KAAK;;;;;;;;;;wBAcpB,aAAa,KAAK;;;;;;wBASlB,gBAAgB,eAAe;;;QCxGvC;YACG;cACC,mBAAmB"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/lib/env-loader.ts","../../src/lib/setup.ts","../../src/lib/types.ts","../../src/lib/utils.ts","../../src/index.ts"],"mappings":";;UAOiB,yBAAyB,KAAK;;;;EAI9C;;;;EAIA;;;;;;;;;;;;;;;;;;;EAmBA,gBAAgB;;;;;;;;;;;;;EAahB;;;;wBC1Ce,MAAM,yBAAyB,MAAM,kBAAkB;iBA+BtD,wBAAwB,KAAK;;;;EAI7C,gBAAgB;;YAGL,iBAAiB;;;YC3CjB;YACA;YACA;YACA;EAAyB;;YAEzB,eAAe;YACf,eAAe,KAAK,SAAS,IAAI,WAAW,gBAAgB,gBAAgB,uBAAuB,KAAI;YACvG,gBAAgB,KAAK,SAAS,IAAI,WAAW,4BAA4B,aAAY;YACrF,gBAAgB,KAAK,SAAS,IAAI,WAAW,4BAA4B,aAAY;YACrF,eAAe,KAAK,SAAS,IAAI,WAAW,2BAA2B,aAAY;YACnF,cAAc,KAAK,SAAS,IAAI,WAAW,0BAA0B,aAAY;iBAE5E;EAChB;EACA,eAAe;EACf;EACA;EACA;EACA;;;;;EAKA;;;;wBCrBe,gBAAgB,KAAK,YAAY;wBACjC,gBAAgB,KAAK,YAAY;wBAajC,eAAe,KAAK,WAAW;wBAC/B,eAAe,KAAK,WAAW;wBAa/B,gBAAgB,KAAK,YAAY;wBACjC,gBAAgB,KAAK,YAAY;wBAajC,eAAe,UAAU,WAAW,KAAK,GAAG,eAAe,IAAI,KAAK,YAAY,IAAI;wBACpF,eAAe,UAAU,WAAW,KAAK,GAAG,cAAc,IAAI,YAAY,YAAY,IAAI;wBAW1F,cAAc,KAAK,UAAU;wBAC7B,cAAc,KAAK,UAAU;;;;;;;;wBAkB7B,UAAU,KAAK;;;;;;;;wBAYf,eAAe,KAAK;;;;;;;;;;wBAcpB,aAAa,KAAK;;;;;;wBASlB,gBAAgB,eAAe;;;QCxGvC;YACG;cACC,mBAAmB"}
@@ -1,4 +1,4 @@
1
- const require_src = require('./src-B2pnGjJn.cjs');
1
+ const require_src = require('./src-DCzHag6L.cjs');
2
2
 
3
3
  //#region src/setup.ts
4
4
  require_src.setup();
@@ -2,15 +2,17 @@ let node_url = require("node:url");
2
2
  let _sapphire_pieces = require("@sapphire/pieces");
3
3
  let dotenv = require("dotenv");
4
4
  let dotenv_expand = require("dotenv-expand");
5
+ let node_module = require("node:module");
5
6
  let node_path = require("node:path");
6
7
 
7
8
  //#region src/lib/env-loader.ts
8
- const packageVersion = "2.1.0";
9
+ const packageVersion = "2.2.0";
9
10
  function resolveDebugLogger() {
10
11
  return _sapphire_pieces.container.logger ?? console;
11
12
  }
12
13
  function loadEnvFiles(options) {
13
14
  const log = options?.debug ? (message) => resolveDebugLogger().debug(`[@wolfstar/env-utilities@${packageVersion}] ${message}`) : () => void 0;
15
+ if (options?.loader === "varlock") return loadWithVarlock(options, log);
14
16
  /**
15
17
  * @see {@linkplain https://github.com/facebook/create-react-app/blob/d960b9e38c062584ff6cfb1a70e1512509a966e7/packages/react-scripts/config/env.js#L18-L23}
16
18
  */
@@ -50,19 +52,48 @@ function loadEnvFiles(options) {
50
52
  /**
51
53
  * @see {@linkplain https://github.com/facebook/create-react-app/blob/d960b9e38c062584ff6cfb1a70e1512509a966e7/packages/react-scripts/config/env.js#L72-L89}
52
54
  */
53
- if (options?.prefix) {
54
- const prefixRegExp = new RegExp(`^${options.prefix}`, "i");
55
- parsed = Object.keys(parsed).filter((key) => {
56
- const match = prefixRegExp.test(key);
57
- log(`Prefix for key \`${key}\` ${match ? "matches" : "does not match"} \`${options.prefix}\``);
58
- return match;
59
- }).reduce((obj, key) => {
60
- obj[key] = parsed[key];
61
- return obj;
62
- }, {});
55
+ if (options?.prefix) parsed = filterByPrefix(parsed, options.prefix, log);
56
+ return { parsed };
57
+ }
58
+ /**
59
+ * **Experimental.** Resolves environment variables via {@link https://varlock.dev | varlock} instead of `dotenv`.
60
+ *
61
+ * Varlock ships no synchronous "parse only" API comparable to `dotenv.config()`; its documented Node.js
62
+ * integration (`varlock/auto-load`) resolves the configured `.env.schema` by shelling out to its CLI and injects
63
+ * the result directly into `process.env`. To still return a `dotenv`-compatible {@link DotenvConfigOutput}, this
64
+ * diffs `process.env` before and after loading and reports the keys varlock added or changed.
65
+ */
66
+ function loadWithVarlock(options, log) {
67
+ log("resolving environment variables via varlock");
68
+ const before = { ...process.env };
69
+ try {
70
+ (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href)("varlock/auto-load");
71
+ } catch (error) {
72
+ if (error.code === "MODULE_NOT_FOUND") throw new Error("The 'varlock' loader was requested, but the optional `varlock` package is not installed. Install it with your package manager (e.g. `pnpm add varlock`) to use it.");
73
+ throw error;
63
74
  }
75
+ let parsed = {};
76
+ for (const [key, value] of Object.entries(process.env)) {
77
+ if (/^_{1,2}VARLOCK_/i.test(key)) continue;
78
+ if (value !== void 0 && before[key] !== value) {
79
+ log(`\`${key}\` resolved via varlock`);
80
+ parsed[key] = value;
81
+ }
82
+ }
83
+ if (options.prefix) parsed = filterByPrefix(parsed, options.prefix, log);
64
84
  return { parsed };
65
85
  }
86
+ function filterByPrefix(parsed, prefix, log) {
87
+ const prefixRegExp = new RegExp(`^${prefix}`, "i");
88
+ return Object.keys(parsed).filter((key) => {
89
+ const match = prefixRegExp.test(key);
90
+ log(`Prefix for key \`${key}\` ${match ? "matches" : "does not match"} \`${prefix}\``);
91
+ return match;
92
+ }).reduce((obj, key) => {
93
+ obj[key] = parsed[key];
94
+ return obj;
95
+ }, {});
96
+ }
66
97
  function appendSuffix(path, suffix) {
67
98
  if (typeof path === "string") return `${path}${suffix}`;
68
99
  const file = (0, node_url.fileURLToPath)(path);
@@ -183,6 +214,7 @@ function setup(pathOrOptions) {
183
214
  env: process.env.DOTENV_ENV,
184
215
  path: process.env.DOTENV_PATH,
185
216
  prefix: process.env.DOTENV_PREFIX,
217
+ loader: process.env.DOTENV_LOADER,
186
218
  ...options
187
219
  });
188
220
  }
@@ -248,4 +280,4 @@ Object.defineProperty(exports, 'setup', {
248
280
  return setup;
249
281
  }
250
282
  });
251
- //# sourceMappingURL=src-B2pnGjJn.cjs.map
283
+ //# sourceMappingURL=src-DCzHag6L.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"src-B2pnGjJn.cjs","names":["fileURLToPath"],"sources":["../../src/lib/utils.ts","../../src/lib/setup.ts"],"sourcesContent":["import type { Env, EnvAny, EnvArray, EnvBoolean, EnvInteger, EnvNumber, EnvString } from './types';\n\nexport function envParseInteger(key: EnvInteger, defaultValue?: number): number;\nexport function envParseInteger(key: EnvInteger, defaultValue: number | null): number | null;\nexport function envParseInteger(key: EnvInteger, defaultValue?: number | null): number | null {\n\tconst value = process.env[key];\n\tif (!value) {\n\t\tif (defaultValue === undefined) throw new ReferenceError(`[ENV] ${key} - The key must be an integer, but is empty or undefined.`);\n\t\treturn defaultValue;\n\t}\n\n\tconst integer = Number(value);\n\tif (Number.isInteger(integer)) return integer;\n\tthrow new TypeError(`[ENV] ${key} - The key must be an integer, but received '${value}'.`);\n}\n\nexport function envParseNumber(key: EnvNumber, defaultValue?: number): number;\nexport function envParseNumber(key: EnvNumber, defaultValue: number | null): number | null;\nexport function envParseNumber(key: EnvNumber, defaultValue?: number | null): number | null {\n\tconst value = process.env[key];\n\tif (!value) {\n\t\tif (defaultValue === undefined) throw new ReferenceError(`[ENV] ${key} - The key must be a number, but is empty or undefined.`);\n\t\treturn defaultValue;\n\t}\n\n\tconst integer = Number(value);\n\tif (!Number.isNaN(integer)) return integer;\n\tthrow new TypeError(`[ENV] ${key} - The key must be a number, but received '${value}'.`);\n}\n\nexport function envParseBoolean(key: EnvBoolean, defaultValue?: boolean): boolean;\nexport function envParseBoolean(key: EnvBoolean, defaultValue: boolean | null): boolean | null;\nexport function envParseBoolean(key: EnvBoolean, defaultValue?: boolean | null): boolean | null {\n\tconst value = process.env[key];\n\tif (!value) {\n\t\tif (defaultValue === undefined) throw new ReferenceError(`[ENV] ${key} - The key must be a boolean, but is empty or undefined.`);\n\t\treturn defaultValue;\n\t}\n\n\tif (value.length === 4 && value.toLowerCase() === 'true') return true;\n\tif (value.length === 5 && value.toLowerCase() === 'false') return false;\n\tthrow new TypeError(`[ENV] ${key} - The key must be a boolean, but received '${value}'.`);\n}\n\nexport function envParseString<K extends EnvString>(key: K, defaultValue?: Env[K]): NonNullable<Env[K]>;\nexport function envParseString<K extends EnvString>(key: K, defaultValue: Env[K] | null): NonNullable<Env[K]> | null;\nexport function envParseString<K extends EnvString>(key: K, defaultValue?: Env[K] | null): NonNullable<Env[K]> | null {\n\tconst value = process.env[key];\n\tif (!value) {\n\t\tif (defaultValue === undefined) throw new ReferenceError(`[ENV] ${key} - The key must be a string, but is empty or undefined.`);\n\t\treturn defaultValue!;\n\t}\n\n\treturn value!;\n}\n\nexport function envParseArray(key: EnvArray, defaultValue?: string[]): string[];\nexport function envParseArray(key: EnvArray, defaultValue: string[] | null): string[] | null;\nexport function envParseArray(key: EnvArray, defaultValue?: string[] | null): string[] | null {\n\tconst value = process.env[key];\n\tif (!value) {\n\t\tif (defaultValue === undefined) throw new ReferenceError(`[ENV] ${key} - The key must be an array, but is empty or undefined.`);\n\t\treturn defaultValue;\n\t}\n\n\treturn value.split(' ');\n}\n\n/**\n * Checks if the value of the specified environment variable is null.\n * @param key - The name of the environment variable.\n * @returns Whether the value of the specified environment variable is:\n * - The string `\"0\"`\n * - The string `\"null\"`, case insensitive\n */\nexport function envIsNull(key: EnvAny): boolean {\n\tconst value = process.env[key];\n\treturn typeof value === 'string' && (value === '0' || (value.length === 4 && value.toLowerCase() === 'null'));\n}\n\n/**\n * Checks if the value of the specified environment variable is undefined.\n * @param key - The name of the environment variable.\n * @returns Whether the value of the specified environment variable is:\n * - `undefined`\n * - An empty string (`\"\"`)\n */\nexport function envIsUndefined(key: EnvAny): boolean {\n\tconst value = process.env[key];\n\treturn value === undefined || value.length === 0;\n}\n\n/**\n * Checks if the value of the specified environment variable is nullish.\n * @param key - The name of the environment variable.\n * @returns Whether the value of the specified environment variable is:\n * - `undefined`\n * - An empty string (`\"\"`)\n * - The string `\"0\"`\n * - The string `\"null\"`, case insensitive\n */\nexport function envIsNullish(key: EnvAny): boolean {\n\treturn envIsUndefined(key) || envIsNull(key);\n}\n\n/**\n * Checks if any of the specified environment variables is defined.\n * @param key - The name of the environment variable.\n * @returns Whether the value of any of the specified environment variables is a non-empty string\n */\nexport function envIsDefined(...keys: readonly EnvAny[]): boolean {\n\treturn keys.every((key) => !envIsUndefined(key));\n}\n","import type { DotenvConfigOutput } from 'dotenv';\nimport { fileURLToPath } from 'node:url';\nimport { loadEnvFiles, type EnvLoaderOptions } from './env-loader';\nimport { envIsDefined, envParseBoolean } from './utils';\n\nexport function setup(pathOrOptions?: string | URL | EnvSetupOptions): DotenvConfigOutput {\n\t// Unless explicitly defined, set NODE_ENV as development:\n\tprocess.env.NODE_ENV ??= 'development';\n\n\tlet options: EnvLoaderOptions;\n\tif (typeof pathOrOptions === 'undefined') {\n\t\toptions = {};\n\t} else if (typeof pathOrOptions === 'string') {\n\t\toptions = { path: pathOrOptions };\n\t} else if (typeof pathOrOptions === 'object') {\n\t\tif (pathOrOptions instanceof URL) {\n\t\t\toptions = { path: fileURLToPath(pathOrOptions) };\n\t\t} else {\n\t\t\tconst { path, ...rest } = pathOrOptions;\n\t\t\toptions = { path: typeof path === 'undefined' ? path : typeof path === 'string' ? path : fileURLToPath(path), ...rest };\n\t\t}\n\t} else {\n\t\tthrow new TypeError('Expected undefined, string, URL, or EnvSetupOptions');\n\t}\n\n\treturn loadEnvFiles({\n\t\tdebug: envIsDefined('DOTENV_DEBUG') ? envParseBoolean('DOTENV_DEBUG') : undefined,\n\t\tencoding: process.env.DOTENV_ENCODING,\n\t\tenv: process.env.DOTENV_ENV,\n\t\tpath: process.env.DOTENV_PATH,\n\t\tprefix: process.env.DOTENV_PREFIX,\n\t\t...options\n\t});\n}\n\nexport interface EnvSetupOptions extends Omit<EnvLoaderOptions, 'path'> {\n\t/**\n\t * You may specify a custom path if your file containing environment variables is located elsewhere.\n\t */\n\tpath?: string | URL;\n}\n\nexport type EnvSetupResult = DotenvConfigOutput;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,SAAgB,gBAAgB,KAAiB,cAA6C;CAC7F,MAAM,QAAQ,QAAQ,IAAI;CAC1B,IAAI,CAAC,OAAO;EACX,IAAI,iBAAiB,QAAW,MAAM,IAAI,eAAe,SAAS,IAAI,0DAA0D;EAChI,OAAO;CACR;CAEA,MAAM,UAAU,OAAO,KAAK;CAC5B,IAAI,OAAO,UAAU,OAAO,GAAG,OAAO;CACtC,MAAM,IAAI,UAAU,SAAS,IAAI,+CAA+C,MAAM,GAAG;AAC1F;AAIA,SAAgB,eAAe,KAAgB,cAA6C;CAC3F,MAAM,QAAQ,QAAQ,IAAI;CAC1B,IAAI,CAAC,OAAO;EACX,IAAI,iBAAiB,QAAW,MAAM,IAAI,eAAe,SAAS,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AsB;CAClD,OAAO,eAAe,GAAG,KAAK,UAAU,GAAG;AAC5C;;;;;;AAOA,SAAgB,aAAa,GAAG,MAAkC;CACjE,OAAO,KAAK,OAAO,QAAQ,CAAC,eAAe,GAAG,CAAC;AAChD;;;;AC3GA,SAAgB,MAAM,eAAoE;CAEzF,QAAQ,IAAI,aAAa;CAEzB,IAAI;CACJ,IAAI,OAAO,kBAAkB,aAC5B,UAAU,CAAC;MACL,IAAI,OAAO,kBAAkB,UACnC,UAAU,EAAE,MAAM,cAAc;MAC1B,IAAI,OAAO,kBAAkB,UAAU;EAC7C,IAAI,yBAAyB,KAC5B,UAAU,EAAE,UAAMA,wBAAc,aAAa,EAAE;OACzC;GACN,MAAM,EAAE,MAAM,GAAG,SAAS;GAC1B,UAAU;IAAE,MAAM,OAAO,SAAS,cAAc,OAAO,OAAO,SAAS,WAAW,WAAOA,wBAAc,IAAI;IAAG,GAAG;GAAK;EACvH;CACD,OACC,MAAM,IAAI,UAAU,qDAAqD;CAG1E,OAAO,aAAa;EACnB,OAAO,aAAa,cAAc,IAAI,gBAAgB,cAAc,IAAI;EACxE,UAAU,QAAQ,IAAI;EACtB,KAAK,QAAQ,IAAI;EACjB,MAAM,QAAQ,IAAI;EAClB,QAAQ,QAAQ,IAAI;EACpB,GAAG;CACJ,CAAC;AACF"}
1
+ {"version":3,"file":"src-DCzHag6L.cjs","names":["fileURLToPath"],"sources":["../../src/lib/utils.ts","../../src/lib/setup.ts"],"sourcesContent":["import type { Env, EnvAny, EnvArray, EnvBoolean, EnvInteger, EnvNumber, EnvString } from './types';\n\nexport function envParseInteger(key: EnvInteger, defaultValue?: number): number;\nexport function envParseInteger(key: EnvInteger, defaultValue: number | null): number | null;\nexport function envParseInteger(key: EnvInteger, defaultValue?: number | null): number | null {\n\tconst value = process.env[key];\n\tif (!value) {\n\t\tif (defaultValue === undefined) throw new ReferenceError(`[ENV] ${key} - The key must be an integer, but is empty or undefined.`);\n\t\treturn defaultValue;\n\t}\n\n\tconst integer = Number(value);\n\tif (Number.isInteger(integer)) return integer;\n\tthrow new TypeError(`[ENV] ${key} - The key must be an integer, but received '${value}'.`);\n}\n\nexport function envParseNumber(key: EnvNumber, defaultValue?: number): number;\nexport function envParseNumber(key: EnvNumber, defaultValue: number | null): number | null;\nexport function envParseNumber(key: EnvNumber, defaultValue?: number | null): number | null {\n\tconst value = process.env[key];\n\tif (!value) {\n\t\tif (defaultValue === undefined) throw new ReferenceError(`[ENV] ${key} - The key must be a number, but is empty or undefined.`);\n\t\treturn defaultValue;\n\t}\n\n\tconst integer = Number(value);\n\tif (!Number.isNaN(integer)) return integer;\n\tthrow new TypeError(`[ENV] ${key} - The key must be a number, but received '${value}'.`);\n}\n\nexport function envParseBoolean(key: EnvBoolean, defaultValue?: boolean): boolean;\nexport function envParseBoolean(key: EnvBoolean, defaultValue: boolean | null): boolean | null;\nexport function envParseBoolean(key: EnvBoolean, defaultValue?: boolean | null): boolean | null {\n\tconst value = process.env[key];\n\tif (!value) {\n\t\tif (defaultValue === undefined) throw new ReferenceError(`[ENV] ${key} - The key must be a boolean, but is empty or undefined.`);\n\t\treturn defaultValue;\n\t}\n\n\tif (value.length === 4 && value.toLowerCase() === 'true') return true;\n\tif (value.length === 5 && value.toLowerCase() === 'false') return false;\n\tthrow new TypeError(`[ENV] ${key} - The key must be a boolean, but received '${value}'.`);\n}\n\nexport function envParseString<K extends EnvString>(key: K, defaultValue?: Env[K]): NonNullable<Env[K]>;\nexport function envParseString<K extends EnvString>(key: K, defaultValue: Env[K] | null): NonNullable<Env[K]> | null;\nexport function envParseString<K extends EnvString>(key: K, defaultValue?: Env[K] | null): NonNullable<Env[K]> | null {\n\tconst value = process.env[key];\n\tif (!value) {\n\t\tif (defaultValue === undefined) throw new ReferenceError(`[ENV] ${key} - The key must be a string, but is empty or undefined.`);\n\t\treturn defaultValue!;\n\t}\n\n\treturn value!;\n}\n\nexport function envParseArray(key: EnvArray, defaultValue?: string[]): string[];\nexport function envParseArray(key: EnvArray, defaultValue: string[] | null): string[] | null;\nexport function envParseArray(key: EnvArray, defaultValue?: string[] | null): string[] | null {\n\tconst value = process.env[key];\n\tif (!value) {\n\t\tif (defaultValue === undefined) throw new ReferenceError(`[ENV] ${key} - The key must be an array, but is empty or undefined.`);\n\t\treturn defaultValue;\n\t}\n\n\treturn value.split(' ');\n}\n\n/**\n * Checks if the value of the specified environment variable is null.\n * @param key - The name of the environment variable.\n * @returns Whether the value of the specified environment variable is:\n * - The string `\"0\"`\n * - The string `\"null\"`, case insensitive\n */\nexport function envIsNull(key: EnvAny): boolean {\n\tconst value = process.env[key];\n\treturn typeof value === 'string' && (value === '0' || (value.length === 4 && value.toLowerCase() === 'null'));\n}\n\n/**\n * Checks if the value of the specified environment variable is undefined.\n * @param key - The name of the environment variable.\n * @returns Whether the value of the specified environment variable is:\n * - `undefined`\n * - An empty string (`\"\"`)\n */\nexport function envIsUndefined(key: EnvAny): boolean {\n\tconst value = process.env[key];\n\treturn value === undefined || value.length === 0;\n}\n\n/**\n * Checks if the value of the specified environment variable is nullish.\n * @param key - The name of the environment variable.\n * @returns Whether the value of the specified environment variable is:\n * - `undefined`\n * - An empty string (`\"\"`)\n * - The string `\"0\"`\n * - The string `\"null\"`, case insensitive\n */\nexport function envIsNullish(key: EnvAny): boolean {\n\treturn envIsUndefined(key) || envIsNull(key);\n}\n\n/**\n * Checks if any of the specified environment variables is defined.\n * @param key - The name of the environment variable.\n * @returns Whether the value of any of the specified environment variables is a non-empty string\n */\nexport function envIsDefined(...keys: readonly EnvAny[]): boolean {\n\treturn keys.every((key) => !envIsUndefined(key));\n}\n","import type { DotenvConfigOutput } from 'dotenv';\nimport { fileURLToPath } from 'node:url';\nimport { loadEnvFiles, type EnvLoaderOptions } from './env-loader';\nimport { envIsDefined, envParseBoolean } from './utils';\n\nexport function setup(pathOrOptions?: string | URL | EnvSetupOptions): DotenvConfigOutput {\n\t// Unless explicitly defined, set NODE_ENV as development:\n\tprocess.env.NODE_ENV ??= 'development';\n\n\tlet options: EnvLoaderOptions;\n\tif (typeof pathOrOptions === 'undefined') {\n\t\toptions = {};\n\t} else if (typeof pathOrOptions === 'string') {\n\t\toptions = { path: pathOrOptions };\n\t} else if (typeof pathOrOptions === 'object') {\n\t\tif (pathOrOptions instanceof URL) {\n\t\t\toptions = { path: fileURLToPath(pathOrOptions) };\n\t\t} else {\n\t\t\tconst { path, ...rest } = pathOrOptions;\n\t\t\toptions = { path: typeof path === 'undefined' ? path : typeof path === 'string' ? path : fileURLToPath(path), ...rest };\n\t\t}\n\t} else {\n\t\tthrow new TypeError('Expected undefined, string, URL, or EnvSetupOptions');\n\t}\n\n\treturn loadEnvFiles({\n\t\tdebug: envIsDefined('DOTENV_DEBUG') ? envParseBoolean('DOTENV_DEBUG') : undefined,\n\t\tencoding: process.env.DOTENV_ENCODING,\n\t\tenv: process.env.DOTENV_ENV,\n\t\tpath: process.env.DOTENV_PATH,\n\t\tprefix: process.env.DOTENV_PREFIX,\n\t\tloader: process.env.DOTENV_LOADER,\n\t\t...options\n\t});\n}\n\nexport interface EnvSetupOptions extends Omit<EnvLoaderOptions, 'path'> {\n\t/**\n\t * You may specify a custom path if your file containing environment variables is located elsewhere.\n\t */\n\tpath?: string | URL;\n}\n\nexport type EnvSetupResult = DotenvConfigOutput;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,SAAgB,gBAAgB,KAAiB,cAA6C;CAC7F,MAAM,QAAQ,QAAQ,IAAI;CAC1B,IAAI,CAAC,OAAO;EACX,IAAI,iBAAiB,QAAW,MAAM,IAAI,eAAe,SAAS,IAAI,0DAA0D;EAChI,OAAO;CACR;CAEA,MAAM,UAAU,OAAO,KAAK;CAC5B,IAAI,OAAO,UAAU,OAAO,GAAG,OAAO;CACtC,MAAM,IAAI,UAAU,SAAS,IAAI,+CAA+C,MAAM,GAA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AM;AACtG;;;;;;;;AASA,SAAgB,eAAe,KAAsB;CACpD,MAAM,QAAQ,QAAQ,IAAI;CAC1B,OAAO,UAAU,UAAa,MAAM,WAAW;AAChD;;;;;;;;;;AAWA,SAAgB,aAAa,KAAsB;CAClD,OAAO,eAAe,GAAG,KAAK,UAAU,GAAG;AAC5C;;;;;;AAOA,SAAgB,aAAa,GAAG,MAAkC;CACjE,OAAO,KAAK,OAAO,QAAQ,CAAC,eAAe,GAAG,CAAC;AAChD;;;;AC3GA,SAAgB,MAAM,eAAoE;CAEzF,QAAQ,IAAI,aAAa;CAEzB,IAAI;CACJ,IAAI,OAAO,kBAAkB,aAC5B,UAAU,CAAC;MACL,IAAI,OAAO,kBAAkB,UACnC,UAAU,EAAE,MAAM,cAAc;MAC1B,IAAI,OAAO,kBAAkB,UAAU;EAC7C,IAAI,yBAAyB,KAC5B,UAAU,EAAE,UAAMA,wBAAc,aAAa,EAAE;OACzC;GACN,MAAM,EAAE,MAAM,GAAG,SAAS;GAC1B,UAAU;IAAE,MAAM,OAAO,SAAS,cAAc,OAAO,OAAO,SAAS,WAAW,WAAOA,wBAAc,IAAI;IAAG,GAAG;GAAK;EACvH;CACD,OACC,MAAM,IAAI,UAAU,qDAAqD;CAG1E,OAAO,aAAa;EACnB,OAAO,aAAa,cAAc,IAAI,gBAAgB,cAAc,IAAI;EACxE,UAAU,QAAQ,IAAI;EACtB,KAAK,QAAQ,IAAI;EACjB,MAAM,QAAQ,IAAI;EAClB,QAAQ,QAAQ,IAAI;EACpB,QAAQ,QAAQ,IAAI;EACpB,GAAG;CACJ,CAAC;AACF"}
@@ -28,6 +28,19 @@ interface EnvLoaderOptions extends Omit<DotenvConfigOptions, 'path'> {
28
28
  * ```
29
29
  */
30
30
  path?: string | URL;
31
+ /**
32
+ * **Experimental.** Selects the loader used to resolve environment variables.
33
+ *
34
+ * - `'dotenv'` (default): loads and merges `.env*` files with `dotenv`/`dotenv-expand`, as documented on the
35
+ * other options.
36
+ * - `'varlock'`: delegates to {@link https://varlock.dev | varlock} instead of `dotenv`. Varlock resolves a
37
+ * checked-in `.env.schema` (with its own `.env*` file discovery and validation) via its CLI and injects the
38
+ * result into `process.env`. When selected, `encoding`, `path`, and `env` are ignored — configure the schema
39
+ * itself instead. Requires the optional `varlock` package to be installed.
40
+ *
41
+ * @default 'dotenv'
42
+ */
43
+ loader?: 'dotenv' | 'varlock';
31
44
  }
32
45
  //#endregion
33
46
  //#region src/lib/setup.d.ts
@@ -60,6 +73,11 @@ export interface Env {
60
73
  DOTENV_ENV?: string;
61
74
  DOTENV_PATH?: string;
62
75
  DOTENV_PREFIX?: string;
76
+ /**
77
+ * **Experimental.** Selects the loader used by `setup()`: `'dotenv'` (default) or `'varlock'` (see
78
+ * {@link https://varlock.dev}).
79
+ */
80
+ DOTENV_LOADER?: 'dotenv' | 'varlock';
63
81
  }
64
82
  //#endregion
65
83
  //#region src/lib/utils.d.ts
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/lib/env-loader.ts","../../src/lib/setup.ts","../../src/lib/types.ts","../../src/lib/utils.ts","../../src/index.ts"],"mappings":";;UAMiB,yBAAyB,KAAK;;;;EAI9C;;;;EAIA;;;;;;;;;;;;;;;;;;;EAmBA,gBAAgB;;;;wBC5BD,MAAM,yBAAyB,MAAM,kBAAkB;iBA8BtD,wBAAwB,KAAK;;;;EAI7C,gBAAgB;;YAGL,iBAAiB;;;YC1CjB;YACA;YACA;YACA;EAAyB;;YAEzB,eAAe;YACf,eAAe,KAAK,SAAS,IAAI,WAAW,gBAAgB,gBAAgB,uBAAuB,KAAI;YACvG,gBAAgB,KAAK,SAAS,IAAI,WAAW,4BAA4B,aAAY;YACrF,gBAAgB,KAAK,SAAS,IAAI,WAAW,4BAA4B,aAAY;YACrF,eAAe,KAAK,SAAS,IAAI,WAAW,2BAA2B,aAAY;YACnF,cAAc,KAAK,SAAS,IAAI,WAAW,0BAA0B,aAAY;iBAE5E;EAChB;EACA,eAAe;EACf;EACA;EACA;EACA;;;;wBChBe,gBAAgB,KAAK,YAAY;wBACjC,gBAAgB,KAAK,YAAY;wBAajC,eAAe,KAAK,WAAW;wBAC/B,eAAe,KAAK,WAAW;wBAa/B,gBAAgB,KAAK,YAAY;wBACjC,gBAAgB,KAAK,YAAY;wBAajC,eAAe,UAAU,WAAW,KAAK,GAAG,eAAe,IAAI,KAAK,YAAY,IAAI;wBACpF,eAAe,UAAU,WAAW,KAAK,GAAG,cAAc,IAAI,YAAY,YAAY,IAAI;wBAW1F,cAAc,KAAK,UAAU;wBAC7B,cAAc,KAAK,UAAU;;;;;;;;wBAkB7B,UAAU,KAAK;;;;;;;;wBAYf,eAAe,KAAK;;;;;;;;;;wBAcpB,aAAa,KAAK;;;;;;wBASlB,gBAAgB,eAAe;;;QCxGvC;YACG;cACC,mBAAmB"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/lib/env-loader.ts","../../src/lib/setup.ts","../../src/lib/types.ts","../../src/lib/utils.ts","../../src/index.ts"],"mappings":";;UAOiB,yBAAyB,KAAK;;;;EAI9C;;;;EAIA;;;;;;;;;;;;;;;;;;;EAmBA,gBAAgB;;;;;;;;;;;;;EAahB;;;;wBC1Ce,MAAM,yBAAyB,MAAM,kBAAkB;iBA+BtD,wBAAwB,KAAK;;;;EAI7C,gBAAgB;;YAGL,iBAAiB;;;YC3CjB;YACA;YACA;YACA;EAAyB;;YAEzB,eAAe;YACf,eAAe,KAAK,SAAS,IAAI,WAAW,gBAAgB,gBAAgB,uBAAuB,KAAI;YACvG,gBAAgB,KAAK,SAAS,IAAI,WAAW,4BAA4B,aAAY;YACrF,gBAAgB,KAAK,SAAS,IAAI,WAAW,4BAA4B,aAAY;YACrF,eAAe,KAAK,SAAS,IAAI,WAAW,2BAA2B,aAAY;YACnF,cAAc,KAAK,SAAS,IAAI,WAAW,0BAA0B,aAAY;iBAE5E;EAChB;EACA,eAAe;EACf;EACA;EACA;EACA;;;;;EAKA;;;;wBCrBe,gBAAgB,KAAK,YAAY;wBACjC,gBAAgB,KAAK,YAAY;wBAajC,eAAe,KAAK,WAAW;wBAC/B,eAAe,KAAK,WAAW;wBAa/B,gBAAgB,KAAK,YAAY;wBACjC,gBAAgB,KAAK,YAAY;wBAajC,eAAe,UAAU,WAAW,KAAK,GAAG,eAAe,IAAI,KAAK,YAAY,IAAI;wBACpF,eAAe,UAAU,WAAW,KAAK,GAAG,cAAc,IAAI,YAAY,YAAY,IAAI;wBAW1F,cAAc,KAAK,UAAU;wBAC7B,cAAc,KAAK,UAAU;;;;;;;;wBAkB7B,UAAU,KAAK;;;;;;;;wBAYf,eAAe,KAAK;;;;;;;;;;wBAcpB,aAAa,KAAK;;;;;;wBASlB,gBAAgB,eAAe;;;QCxGvC;YACG;cACC,mBAAmB"}
package/dist/esm/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import { a as envIsUndefined, c as envParseInteger, i as envIsNullish, l as envParseNumber, n as envIsDefined, o as envParseArray, r as envIsNull, s as envParseBoolean, t as setup, u as envParseString } from "./src-CZP5csNb.js";
1
+ import { a as envIsUndefined, c as envParseInteger, i as envIsNullish, l as envParseNumber, n as envIsDefined, o as envParseArray, r as envIsNull, s as envParseBoolean, t as setup, u as envParseString } from "./src-BHEW4qZd.js";
2
2
 
3
3
  export { envIsDefined, envIsNull, envIsNullish, envIsUndefined, envParseArray, envParseBoolean, envParseInteger, envParseNumber, envParseString, setup };
package/dist/esm/setup.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as setup } from "./src-CZP5csNb.js";
1
+ import { t as setup } from "./src-BHEW4qZd.js";
2
2
 
3
3
  //#region src/setup.ts
4
4
  setup();
@@ -1,3 +1,4 @@
1
+ import { createRequire } from "node:module";
1
2
  import { fileURLToPath } from "node:url";
2
3
  import { container } from "@sapphire/pieces";
3
4
  import { config } from "dotenv";
@@ -5,12 +6,13 @@ import { expand } from "dotenv-expand";
5
6
  import { basename, dirname, join, resolve } from "node:path";
6
7
 
7
8
  //#region src/lib/env-loader.ts
8
- const packageVersion = "2.1.0";
9
+ const packageVersion = "2.2.0";
9
10
  function resolveDebugLogger() {
10
11
  return container.logger ?? console;
11
12
  }
12
13
  function loadEnvFiles(options) {
13
14
  const log = options?.debug ? (message) => resolveDebugLogger().debug(`[@wolfstar/env-utilities@${packageVersion}] ${message}`) : () => void 0;
15
+ if (options?.loader === "varlock") return loadWithVarlock(options, log);
14
16
  /**
15
17
  * @see {@linkplain https://github.com/facebook/create-react-app/blob/d960b9e38c062584ff6cfb1a70e1512509a966e7/packages/react-scripts/config/env.js#L18-L23}
16
18
  */
@@ -50,19 +52,48 @@ function loadEnvFiles(options) {
50
52
  /**
51
53
  * @see {@linkplain https://github.com/facebook/create-react-app/blob/d960b9e38c062584ff6cfb1a70e1512509a966e7/packages/react-scripts/config/env.js#L72-L89}
52
54
  */
53
- if (options?.prefix) {
54
- const prefixRegExp = new RegExp(`^${options.prefix}`, "i");
55
- parsed = Object.keys(parsed).filter((key) => {
56
- const match = prefixRegExp.test(key);
57
- log(`Prefix for key \`${key}\` ${match ? "matches" : "does not match"} \`${options.prefix}\``);
58
- return match;
59
- }).reduce((obj, key) => {
60
- obj[key] = parsed[key];
61
- return obj;
62
- }, {});
55
+ if (options?.prefix) parsed = filterByPrefix(parsed, options.prefix, log);
56
+ return { parsed };
57
+ }
58
+ /**
59
+ * **Experimental.** Resolves environment variables via {@link https://varlock.dev | varlock} instead of `dotenv`.
60
+ *
61
+ * Varlock ships no synchronous "parse only" API comparable to `dotenv.config()`; its documented Node.js
62
+ * integration (`varlock/auto-load`) resolves the configured `.env.schema` by shelling out to its CLI and injects
63
+ * the result directly into `process.env`. To still return a `dotenv`-compatible {@link DotenvConfigOutput}, this
64
+ * diffs `process.env` before and after loading and reports the keys varlock added or changed.
65
+ */
66
+ function loadWithVarlock(options, log) {
67
+ log("resolving environment variables via varlock");
68
+ const before = { ...process.env };
69
+ try {
70
+ createRequire(import.meta.url)("varlock/auto-load");
71
+ } catch (error) {
72
+ if (error.code === "MODULE_NOT_FOUND") throw new Error("The 'varlock' loader was requested, but the optional `varlock` package is not installed. Install it with your package manager (e.g. `pnpm add varlock`) to use it.");
73
+ throw error;
63
74
  }
75
+ let parsed = {};
76
+ for (const [key, value] of Object.entries(process.env)) {
77
+ if (/^_{1,2}VARLOCK_/i.test(key)) continue;
78
+ if (value !== void 0 && before[key] !== value) {
79
+ log(`\`${key}\` resolved via varlock`);
80
+ parsed[key] = value;
81
+ }
82
+ }
83
+ if (options.prefix) parsed = filterByPrefix(parsed, options.prefix, log);
64
84
  return { parsed };
65
85
  }
86
+ function filterByPrefix(parsed, prefix, log) {
87
+ const prefixRegExp = new RegExp(`^${prefix}`, "i");
88
+ return Object.keys(parsed).filter((key) => {
89
+ const match = prefixRegExp.test(key);
90
+ log(`Prefix for key \`${key}\` ${match ? "matches" : "does not match"} \`${prefix}\``);
91
+ return match;
92
+ }).reduce((obj, key) => {
93
+ obj[key] = parsed[key];
94
+ return obj;
95
+ }, {});
96
+ }
66
97
  function appendSuffix(path, suffix) {
67
98
  if (typeof path === "string") return `${path}${suffix}`;
68
99
  const file = fileURLToPath(path);
@@ -183,10 +214,11 @@ function setup(pathOrOptions) {
183
214
  env: process.env.DOTENV_ENV,
184
215
  path: process.env.DOTENV_PATH,
185
216
  prefix: process.env.DOTENV_PREFIX,
217
+ loader: process.env.DOTENV_LOADER,
186
218
  ...options
187
219
  });
188
220
  }
189
221
 
190
222
  //#endregion
191
223
  export { envIsUndefined as a, envParseInteger as c, envIsNullish as i, envParseNumber as l, envIsDefined as n, envParseArray as o, envIsNull as r, envParseBoolean as s, setup as t, envParseString as u };
192
- //# sourceMappingURL=src-CZP5csNb.js.map
224
+ //# sourceMappingURL=src-BHEW4qZd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"src-CZP5csNb.js","names":[],"sources":["../../src/lib/utils.ts","../../src/lib/setup.ts"],"sourcesContent":["import type { Env, EnvAny, EnvArray, EnvBoolean, EnvInteger, EnvNumber, EnvString } from './types';\n\nexport function envParseInteger(key: EnvInteger, defaultValue?: number): number;\nexport function envParseInteger(key: EnvInteger, defaultValue: number | null): number | null;\nexport function envParseInteger(key: EnvInteger, defaultValue?: number | null): number | null {\n\tconst value = process.env[key];\n\tif (!value) {\n\t\tif (defaultValue === undefined) throw new ReferenceError(`[ENV] ${key} - The key must be an integer, but is empty or undefined.`);\n\t\treturn defaultValue;\n\t}\n\n\tconst integer = Number(value);\n\tif (Number.isInteger(integer)) return integer;\n\tthrow new TypeError(`[ENV] ${key} - The key must be an integer, but received '${value}'.`);\n}\n\nexport function envParseNumber(key: EnvNumber, defaultValue?: number): number;\nexport function envParseNumber(key: EnvNumber, defaultValue: number | null): number | null;\nexport function envParseNumber(key: EnvNumber, defaultValue?: number | null): number | null {\n\tconst value = process.env[key];\n\tif (!value) {\n\t\tif (defaultValue === undefined) throw new ReferenceError(`[ENV] ${key} - The key must be a number, but is empty or undefined.`);\n\t\treturn defaultValue;\n\t}\n\n\tconst integer = Number(value);\n\tif (!Number.isNaN(integer)) return integer;\n\tthrow new TypeError(`[ENV] ${key} - The key must be a number, but received '${value}'.`);\n}\n\nexport function envParseBoolean(key: EnvBoolean, defaultValue?: boolean): boolean;\nexport function envParseBoolean(key: EnvBoolean, defaultValue: boolean | null): boolean | null;\nexport function envParseBoolean(key: EnvBoolean, defaultValue?: boolean | null): boolean | null {\n\tconst value = process.env[key];\n\tif (!value) {\n\t\tif (defaultValue === undefined) throw new ReferenceError(`[ENV] ${key} - The key must be a boolean, but is empty or undefined.`);\n\t\treturn defaultValue;\n\t}\n\n\tif (value.length === 4 && value.toLowerCase() === 'true') return true;\n\tif (value.length === 5 && value.toLowerCase() === 'false') return false;\n\tthrow new TypeError(`[ENV] ${key} - The key must be a boolean, but received '${value}'.`);\n}\n\nexport function envParseString<K extends EnvString>(key: K, defaultValue?: Env[K]): NonNullable<Env[K]>;\nexport function envParseString<K extends EnvString>(key: K, defaultValue: Env[K] | null): NonNullable<Env[K]> | null;\nexport function envParseString<K extends EnvString>(key: K, defaultValue?: Env[K] | null): NonNullable<Env[K]> | null {\n\tconst value = process.env[key];\n\tif (!value) {\n\t\tif (defaultValue === undefined) throw new ReferenceError(`[ENV] ${key} - The key must be a string, but is empty or undefined.`);\n\t\treturn defaultValue!;\n\t}\n\n\treturn value!;\n}\n\nexport function envParseArray(key: EnvArray, defaultValue?: string[]): string[];\nexport function envParseArray(key: EnvArray, defaultValue: string[] | null): string[] | null;\nexport function envParseArray(key: EnvArray, defaultValue?: string[] | null): string[] | null {\n\tconst value = process.env[key];\n\tif (!value) {\n\t\tif (defaultValue === undefined) throw new ReferenceError(`[ENV] ${key} - The key must be an array, but is empty or undefined.`);\n\t\treturn defaultValue;\n\t}\n\n\treturn value.split(' ');\n}\n\n/**\n * Checks if the value of the specified environment variable is null.\n * @param key - The name of the environment variable.\n * @returns Whether the value of the specified environment variable is:\n * - The string `\"0\"`\n * - The string `\"null\"`, case insensitive\n */\nexport function envIsNull(key: EnvAny): boolean {\n\tconst value = process.env[key];\n\treturn typeof value === 'string' && (value === '0' || (value.length === 4 && value.toLowerCase() === 'null'));\n}\n\n/**\n * Checks if the value of the specified environment variable is undefined.\n * @param key - The name of the environment variable.\n * @returns Whether the value of the specified environment variable is:\n * - `undefined`\n * - An empty string (`\"\"`)\n */\nexport function envIsUndefined(key: EnvAny): boolean {\n\tconst value = process.env[key];\n\treturn value === undefined || value.length === 0;\n}\n\n/**\n * Checks if the value of the specified environment variable is nullish.\n * @param key - The name of the environment variable.\n * @returns Whether the value of the specified environment variable is:\n * - `undefined`\n * - An empty string (`\"\"`)\n * - The string `\"0\"`\n * - The string `\"null\"`, case insensitive\n */\nexport function envIsNullish(key: EnvAny): boolean {\n\treturn envIsUndefined(key) || envIsNull(key);\n}\n\n/**\n * Checks if any of the specified environment variables is defined.\n * @param key - The name of the environment variable.\n * @returns Whether the value of any of the specified environment variables is a non-empty string\n */\nexport function envIsDefined(...keys: readonly EnvAny[]): boolean {\n\treturn keys.every((key) => !envIsUndefined(key));\n}\n","import type { DotenvConfigOutput } from 'dotenv';\nimport { fileURLToPath } from 'node:url';\nimport { loadEnvFiles, type EnvLoaderOptions } from './env-loader';\nimport { envIsDefined, envParseBoolean } from './utils';\n\nexport function setup(pathOrOptions?: string | URL | EnvSetupOptions): DotenvConfigOutput {\n\t// Unless explicitly defined, set NODE_ENV as development:\n\tprocess.env.NODE_ENV ??= 'development';\n\n\tlet options: EnvLoaderOptions;\n\tif (typeof pathOrOptions === 'undefined') {\n\t\toptions = {};\n\t} else if (typeof pathOrOptions === 'string') {\n\t\toptions = { path: pathOrOptions };\n\t} else if (typeof pathOrOptions === 'object') {\n\t\tif (pathOrOptions instanceof URL) {\n\t\t\toptions = { path: fileURLToPath(pathOrOptions) };\n\t\t} else {\n\t\t\tconst { path, ...rest } = pathOrOptions;\n\t\t\toptions = { path: typeof path === 'undefined' ? path : typeof path === 'string' ? path : fileURLToPath(path), ...rest };\n\t\t}\n\t} else {\n\t\tthrow new TypeError('Expected undefined, string, URL, or EnvSetupOptions');\n\t}\n\n\treturn loadEnvFiles({\n\t\tdebug: envIsDefined('DOTENV_DEBUG') ? envParseBoolean('DOTENV_DEBUG') : undefined,\n\t\tencoding: process.env.DOTENV_ENCODING,\n\t\tenv: process.env.DOTENV_ENV,\n\t\tpath: process.env.DOTENV_PATH,\n\t\tprefix: process.env.DOTENV_PREFIX,\n\t\t...options\n\t});\n}\n\nexport interface EnvSetupOptions extends Omit<EnvLoaderOptions, 'path'> {\n\t/**\n\t * You may specify a custom path if your file containing environment variables is located elsewhere.\n\t */\n\tpath?: string | URL;\n}\n\nexport type EnvSetupResult = DotenvConfigOutput;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,SAAgB,gBAAgB,KAAiB,cAA6C;CAC7F,MAAM,QAAQ,QAAQ,IAAI;CAC1B,IAAI,CAAC,OAAO;EACX,IAAI,iBAAiB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"sourcesContent":["import type { Env, EnvAny, EnvArray, EnvBoolean, EnvInteger, EnvNumber, EnvString } from './types';\n\nexport function envParseInteger(key: EnvInteger, defaultValue?: number): number;\nexport function envParseInteger(key: EnvInteger, defaultValue: number | null): number | null;\nexport function envParseInteger(key: EnvInteger, defaultValue?: number | null): number | null {\n\tconst value = process.env[key];\n\tif (!value) {\n\t\tif (defaultValue === undefined) throw new ReferenceError(`[ENV] ${key} - The key must be an integer, but is empty or undefined.`);\n\t\treturn defaultValue;\n\t}\n\n\tconst integer = Number(value);\n\tif (Number.isInteger(integer)) return integer;\n\tthrow new TypeError(`[ENV] ${key} - The key must be an integer, but received '${value}'.`);\n}\n\nexport function envParseNumber(key: EnvNumber, defaultValue?: number): number;\nexport function envParseNumber(key: EnvNumber, defaultValue: number | null): number | null;\nexport function envParseNumber(key: EnvNumber, defaultValue?: number | null): number | null {\n\tconst value = process.env[key];\n\tif (!value) {\n\t\tif (defaultValue === undefined) throw new ReferenceError(`[ENV] ${key} - The key must be a number, but is empty or undefined.`);\n\t\treturn defaultValue;\n\t}\n\n\tconst integer = Number(value);\n\tif (!Number.isNaN(integer)) return integer;\n\tthrow new TypeError(`[ENV] ${key} - The key must be a number, but received '${value}'.`);\n}\n\nexport function envParseBoolean(key: EnvBoolean, defaultValue?: boolean): boolean;\nexport function envParseBoolean(key: EnvBoolean, defaultValue: boolean | null): boolean | null;\nexport function envParseBoolean(key: EnvBoolean, defaultValue?: boolean | null): boolean | null {\n\tconst value = process.env[key];\n\tif (!value) {\n\t\tif (defaultValue === undefined) throw new ReferenceError(`[ENV] ${key} - The key must be a boolean, but is empty or undefined.`);\n\t\treturn defaultValue;\n\t}\n\n\tif (value.length === 4 && value.toLowerCase() === 'true') return true;\n\tif (value.length === 5 && value.toLowerCase() === 'false') return false;\n\tthrow new TypeError(`[ENV] ${key} - The key must be a boolean, but received '${value}'.`);\n}\n\nexport function envParseString<K extends EnvString>(key: K, defaultValue?: Env[K]): NonNullable<Env[K]>;\nexport function envParseString<K extends EnvString>(key: K, defaultValue: Env[K] | null): NonNullable<Env[K]> | null;\nexport function envParseString<K extends EnvString>(key: K, defaultValue?: Env[K] | null): NonNullable<Env[K]> | null {\n\tconst value = process.env[key];\n\tif (!value) {\n\t\tif (defaultValue === undefined) throw new ReferenceError(`[ENV] ${key} - The key must be a string, but is empty or undefined.`);\n\t\treturn defaultValue!;\n\t}\n\n\treturn value!;\n}\n\nexport function envParseArray(key: EnvArray, defaultValue?: string[]): string[];\nexport function envParseArray(key: EnvArray, defaultValue: string[] | null): string[] | null;\nexport function envParseArray(key: EnvArray, defaultValue?: string[] | null): string[] | null {\n\tconst value = process.env[key];\n\tif (!value) {\n\t\tif (defaultValue === undefined) throw new ReferenceError(`[ENV] ${key} - The key must be an array, but is empty or undefined.`);\n\t\treturn defaultValue;\n\t}\n\n\treturn value.split(' ');\n}\n\n/**\n * Checks if the value of the specified environment variable is null.\n * @param key - The name of the environment variable.\n * @returns Whether the value of the specified environment variable is:\n * - The string `\"0\"`\n * - The string `\"null\"`, case insensitive\n */\nexport function envIsNull(key: EnvAny): boolean {\n\tconst value = process.env[key];\n\treturn typeof value === 'string' && (value === '0' || (value.length === 4 && value.toLowerCase() === 'null'));\n}\n\n/**\n * Checks if the value of the specified environment variable is undefined.\n * @param key - The name of the environment variable.\n * @returns Whether the value of the specified environment variable is:\n * - `undefined`\n * - An empty string (`\"\"`)\n */\nexport function envIsUndefined(key: EnvAny): boolean {\n\tconst value = process.env[key];\n\treturn value === undefined || value.length === 0;\n}\n\n/**\n * Checks if the value of the specified environment variable is nullish.\n * @param key - The name of the environment variable.\n * @returns Whether the value of the specified environment variable is:\n * - `undefined`\n * - An empty string (`\"\"`)\n * - The string `\"0\"`\n * - The string `\"null\"`, case insensitive\n */\nexport function envIsNullish(key: EnvAny): boolean {\n\treturn envIsUndefined(key) || envIsNull(key);\n}\n\n/**\n * Checks if any of the specified environment variables is defined.\n * @param key - The name of the environment variable.\n * @returns Whether the value of any of the specified environment variables is a non-empty string\n */\nexport function envIsDefined(...keys: readonly EnvAny[]): boolean {\n\treturn keys.every((key) => !envIsUndefined(key));\n}\n","import type { DotenvConfigOutput } from 'dotenv';\nimport { fileURLToPath } from 'node:url';\nimport { loadEnvFiles, type EnvLoaderOptions } from './env-loader';\nimport { envIsDefined, envParseBoolean } from './utils';\n\nexport function setup(pathOrOptions?: string | URL | EnvSetupOptions): DotenvConfigOutput {\n\t// Unless explicitly defined, set NODE_ENV as development:\n\tprocess.env.NODE_ENV ??= 'development';\n\n\tlet options: EnvLoaderOptions;\n\tif (typeof pathOrOptions === 'undefined') {\n\t\toptions = {};\n\t} else if (typeof pathOrOptions === 'string') {\n\t\toptions = { path: pathOrOptions };\n\t} else if (typeof pathOrOptions === 'object') {\n\t\tif (pathOrOptions instanceof URL) {\n\t\t\toptions = { path: fileURLToPath(pathOrOptions) };\n\t\t} else {\n\t\t\tconst { path, ...rest } = pathOrOptions;\n\t\t\toptions = { path: typeof path === 'undefined' ? path : typeof path === 'string' ? path : fileURLToPath(path), ...rest };\n\t\t}\n\t} else {\n\t\tthrow new TypeError('Expected undefined, string, URL, or EnvSetupOptions');\n\t}\n\n\treturn loadEnvFiles({\n\t\tdebug: envIsDefined('DOTENV_DEBUG') ? envParseBoolean('DOTENV_DEBUG') : undefined,\n\t\tencoding: process.env.DOTENV_ENCODING,\n\t\tenv: process.env.DOTENV_ENV,\n\t\tpath: process.env.DOTENV_PATH,\n\t\tprefix: process.env.DOTENV_PREFIX,\n\t\tloader: process.env.DOTENV_LOADER,\n\t\t...options\n\t});\n}\n\nexport interface EnvSetupOptions extends Omit<EnvLoaderOptions, 'path'> {\n\t/**\n\t * You may specify a custom path if your file containing environment variables is located elsewhere.\n\t */\n\tpath?: string | URL;\n}\n\nexport type EnvSetupResult = DotenvConfigOutput;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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I;EAClB,QAAQ,QAAQ,IAAI;EACpB,QAAQ,QAAQ,IAAI;EACpB,GAAG;CACJ,CAAC;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wolfstar/env-utilities",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "Functional utilities for reading and parsing environmental variables",
5
5
  "keywords": [
6
6
  "api",
@@ -69,8 +69,17 @@
69
69
  "golar": "^0.1.10",
70
70
  "tsdown": "^0.23.0",
71
71
  "typescript": "~7.0.2",
72
+ "varlock": "^1.19.0",
72
73
  "vitest": "^4.1.11"
73
74
  },
75
+ "peerDependencies": {
76
+ "varlock": "^1.19.0"
77
+ },
78
+ "peerDependenciesMeta": {
79
+ "varlock": {
80
+ "optional": true
81
+ }
82
+ },
74
83
  "engines": {
75
84
  "node": ">=20"
76
85
  },