@karmaniverous/get-dotenv 5.0.0 → 5.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.
@@ -95,6 +95,93 @@ interface GetDotenvOptions {
95
95
  useConfigLoader?: boolean;
96
96
  }
97
97
 
98
+ type Scripts = Record<string, string | {
99
+ cmd: string;
100
+ shell?: string | boolean;
101
+ }>;
102
+ /**
103
+ * Options passed programmatically to `getDotenvCli`.
104
+ */
105
+ interface GetDotenvCliOptions extends Omit<GetDotenvOptions, 'paths' | 'vars'> {
106
+ /**
107
+ * Logs CLI internals when true.
108
+ */
109
+ debug?: boolean;
110
+ /**
111
+ * Strict mode: fail the run when env validation issues are detected
112
+ * (schema or requiredKeys). Warns by default when false or unset.
113
+ */
114
+ strict?: boolean;
115
+ /**
116
+ * Redaction (presentation): mask secret-like values in logs/trace.
117
+ */
118
+ redact?: boolean;
119
+ /**
120
+ * Entropy warnings (presentation): emit once-per-key warnings for high-entropy values.
121
+ */
122
+ warnEntropy?: boolean;
123
+ entropyThreshold?: number;
124
+ entropyMinLength?: number;
125
+ entropyWhitelist?: string[];
126
+ redactPatterns?: string[];
127
+ /**
128
+ * When true, capture child stdout/stderr and re-emit after completion.
129
+ * Useful for tests/CI. Default behavior is streaming via stdio: 'inherit'.
130
+ */
131
+ capture?: boolean;
132
+ /**
133
+ * A delimited string of paths to dotenv files.
134
+ */
135
+ paths?: string;
136
+ /**
137
+ * A delimiter string with which to split `paths`. Only used if
138
+ * `pathsDelimiterPattern` is not provided.
139
+ */
140
+ pathsDelimiter?: string;
141
+ /**
142
+ * A regular expression pattern with which to split `paths`. Supersedes
143
+ * `pathsDelimiter`.
144
+ */
145
+ pathsDelimiterPattern?: string;
146
+ /**
147
+ * Scripts that can be executed from the CLI, either individually or via the batch subcommand.
148
+ */
149
+ scripts?: Scripts;
150
+ /**
151
+ * Determines how commands and scripts are executed. If `false` or
152
+ * `undefined`, commands are executed as plain Javascript using the default
153
+ * execa parser. If `true`, commands are executed using the default OS shell
154
+ * parser. Otherwise the user may provide a specific shell string (e.g.
155
+ * `/bin/bash`)
156
+ */
157
+ shell?: string | boolean;
158
+ /**
159
+ * A delimited string of key-value pairs declaratively specifying variables &
160
+ * values to be loaded in addition to any dotenv files.
161
+ */
162
+ vars?: string;
163
+ /**
164
+ * A string with which to split keys from values in `vars`. Only used if
165
+ * `varsDelimiterPattern` is not provided.
166
+ */
167
+ varsAssignor?: string;
168
+ /**
169
+ * A regular expression pattern with which to split variable names from values
170
+ * in `vars`. Supersedes `varsAssignor`.
171
+ */
172
+ varsAssignorPattern?: string;
173
+ /**
174
+ * A string with which to split `vars` into key-value pairs. Only used if
175
+ * `varsDelimiterPattern` is not provided.
176
+ */
177
+ varsDelimiter?: string;
178
+ /**
179
+ * A regular expression pattern with which to split `vars` into key-value
180
+ * pairs. Supersedes `varsDelimiter`.
181
+ */
182
+ varsDelimiterPattern?: string;
183
+ }
184
+
98
185
  /** * Per-invocation context shared with plugins and actions. */
99
186
  type GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> = {
100
187
  optionsResolved: TOptions;
@@ -102,6 +189,7 @@ type GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> = {
102
189
  plugins?: Record<string, unknown>;
103
190
  pluginConfigs?: Record<string, unknown>;
104
191
  };
192
+ declare const HELP_HEADER_SYMBOL: unique symbol;
105
193
  /**
106
194
  * Plugin-first CLI host for get-dotenv. Extends Commander.Command.
107
195
  *
@@ -114,10 +202,13 @@ type GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> = {
114
202
  * NOTE: This host is additive and does not alter the legacy CLI.
115
203
  */
116
204
  declare class GetDotenvCli<TOptions extends GetDotenvOptions = GetDotenvOptions> extends Command {
205
+ #private;
117
206
  /** Registered top-level plugins (composition happens via .use()) */
118
207
  private _plugins;
119
208
  /** One-time installation guard */
120
209
  private _installed;
210
+ /** Optional header line to prepend in help output */
211
+ private [HELP_HEADER_SYMBOL];
121
212
  constructor(alias?: string);
122
213
  /**
123
214
  * Resolve options (strict) and compute dotenv context. * Stores the context on the instance under a symbol.
@@ -127,9 +218,33 @@ declare class GetDotenvCli<TOptions extends GetDotenvOptions = GetDotenvOptions>
127
218
  * Retrieve the current invocation context (if any).
128
219
  */
129
220
  getCtx(): GetDotenvCliCtx<TOptions> | undefined;
221
+ /**
222
+ * Retrieve the merged root CLI options bag (if set by passOptions()).
223
+ * Downstream-safe: no generics required.
224
+ */
225
+ getOptions(): GetDotenvCliOptions | undefined;
226
+ /** Internal: set the merged root options bag for this run. */
227
+ _setOptionsBag(bag: GetDotenvCliOptions): void;
130
228
  /** * Convenience helper to create a namespaced subcommand.
131
229
  */
132
230
  ns(name: string): Command;
231
+ /**
232
+ * Tag options added during the provided callback as 'app' for grouped help.
233
+ * Allows downstream apps to demarcate their root-level options.
234
+ */
235
+ tagAppOptions<T>(fn: (root: Command) => T): T;
236
+ /**
237
+ * Branding helper: set CLI name/description/version and optional help header.
238
+ * If version is omitted and importMetaUrl is provided, attempts to read the
239
+ * nearest package.json version (best-effort; non-fatal on failure).
240
+ */
241
+ brand(args: {
242
+ name?: string;
243
+ description?: string;
244
+ version?: string;
245
+ importMetaUrl?: string;
246
+ helpHeader?: string;
247
+ }): Promise<this>;
133
248
  /**
134
249
  * Register a plugin for installation (parent level).
135
250
  * Installation occurs on first resolveAndLoad() (or explicit install()).
@@ -95,6 +95,93 @@ interface GetDotenvOptions {
95
95
  useConfigLoader?: boolean;
96
96
  }
97
97
 
98
+ type Scripts = Record<string, string | {
99
+ cmd: string;
100
+ shell?: string | boolean;
101
+ }>;
102
+ /**
103
+ * Options passed programmatically to `getDotenvCli`.
104
+ */
105
+ interface GetDotenvCliOptions extends Omit<GetDotenvOptions, 'paths' | 'vars'> {
106
+ /**
107
+ * Logs CLI internals when true.
108
+ */
109
+ debug?: boolean;
110
+ /**
111
+ * Strict mode: fail the run when env validation issues are detected
112
+ * (schema or requiredKeys). Warns by default when false or unset.
113
+ */
114
+ strict?: boolean;
115
+ /**
116
+ * Redaction (presentation): mask secret-like values in logs/trace.
117
+ */
118
+ redact?: boolean;
119
+ /**
120
+ * Entropy warnings (presentation): emit once-per-key warnings for high-entropy values.
121
+ */
122
+ warnEntropy?: boolean;
123
+ entropyThreshold?: number;
124
+ entropyMinLength?: number;
125
+ entropyWhitelist?: string[];
126
+ redactPatterns?: string[];
127
+ /**
128
+ * When true, capture child stdout/stderr and re-emit after completion.
129
+ * Useful for tests/CI. Default behavior is streaming via stdio: 'inherit'.
130
+ */
131
+ capture?: boolean;
132
+ /**
133
+ * A delimited string of paths to dotenv files.
134
+ */
135
+ paths?: string;
136
+ /**
137
+ * A delimiter string with which to split `paths`. Only used if
138
+ * `pathsDelimiterPattern` is not provided.
139
+ */
140
+ pathsDelimiter?: string;
141
+ /**
142
+ * A regular expression pattern with which to split `paths`. Supersedes
143
+ * `pathsDelimiter`.
144
+ */
145
+ pathsDelimiterPattern?: string;
146
+ /**
147
+ * Scripts that can be executed from the CLI, either individually or via the batch subcommand.
148
+ */
149
+ scripts?: Scripts;
150
+ /**
151
+ * Determines how commands and scripts are executed. If `false` or
152
+ * `undefined`, commands are executed as plain Javascript using the default
153
+ * execa parser. If `true`, commands are executed using the default OS shell
154
+ * parser. Otherwise the user may provide a specific shell string (e.g.
155
+ * `/bin/bash`)
156
+ */
157
+ shell?: string | boolean;
158
+ /**
159
+ * A delimited string of key-value pairs declaratively specifying variables &
160
+ * values to be loaded in addition to any dotenv files.
161
+ */
162
+ vars?: string;
163
+ /**
164
+ * A string with which to split keys from values in `vars`. Only used if
165
+ * `varsDelimiterPattern` is not provided.
166
+ */
167
+ varsAssignor?: string;
168
+ /**
169
+ * A regular expression pattern with which to split variable names from values
170
+ * in `vars`. Supersedes `varsAssignor`.
171
+ */
172
+ varsAssignorPattern?: string;
173
+ /**
174
+ * A string with which to split `vars` into key-value pairs. Only used if
175
+ * `varsDelimiterPattern` is not provided.
176
+ */
177
+ varsDelimiter?: string;
178
+ /**
179
+ * A regular expression pattern with which to split `vars` into key-value
180
+ * pairs. Supersedes `varsDelimiter`.
181
+ */
182
+ varsDelimiterPattern?: string;
183
+ }
184
+
98
185
  /** * Per-invocation context shared with plugins and actions. */
99
186
  type GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> = {
100
187
  optionsResolved: TOptions;
@@ -102,6 +189,7 @@ type GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> = {
102
189
  plugins?: Record<string, unknown>;
103
190
  pluginConfigs?: Record<string, unknown>;
104
191
  };
192
+ declare const HELP_HEADER_SYMBOL: unique symbol;
105
193
  /**
106
194
  * Plugin-first CLI host for get-dotenv. Extends Commander.Command.
107
195
  *
@@ -114,10 +202,13 @@ type GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> = {
114
202
  * NOTE: This host is additive and does not alter the legacy CLI.
115
203
  */
116
204
  declare class GetDotenvCli<TOptions extends GetDotenvOptions = GetDotenvOptions> extends Command {
205
+ #private;
117
206
  /** Registered top-level plugins (composition happens via .use()) */
118
207
  private _plugins;
119
208
  /** One-time installation guard */
120
209
  private _installed;
210
+ /** Optional header line to prepend in help output */
211
+ private [HELP_HEADER_SYMBOL];
121
212
  constructor(alias?: string);
122
213
  /**
123
214
  * Resolve options (strict) and compute dotenv context. * Stores the context on the instance under a symbol.
@@ -127,9 +218,33 @@ declare class GetDotenvCli<TOptions extends GetDotenvOptions = GetDotenvOptions>
127
218
  * Retrieve the current invocation context (if any).
128
219
  */
129
220
  getCtx(): GetDotenvCliCtx<TOptions> | undefined;
221
+ /**
222
+ * Retrieve the merged root CLI options bag (if set by passOptions()).
223
+ * Downstream-safe: no generics required.
224
+ */
225
+ getOptions(): GetDotenvCliOptions | undefined;
226
+ /** Internal: set the merged root options bag for this run. */
227
+ _setOptionsBag(bag: GetDotenvCliOptions): void;
130
228
  /** * Convenience helper to create a namespaced subcommand.
131
229
  */
132
230
  ns(name: string): Command;
231
+ /**
232
+ * Tag options added during the provided callback as 'app' for grouped help.
233
+ * Allows downstream apps to demarcate their root-level options.
234
+ */
235
+ tagAppOptions<T>(fn: (root: Command) => T): T;
236
+ /**
237
+ * Branding helper: set CLI name/description/version and optional help header.
238
+ * If version is omitted and importMetaUrl is provided, attempts to read the
239
+ * nearest package.json version (best-effort; non-fatal on failure).
240
+ */
241
+ brand(args: {
242
+ name?: string;
243
+ description?: string;
244
+ version?: string;
245
+ importMetaUrl?: string;
246
+ helpHeader?: string;
247
+ }): Promise<this>;
133
248
  /**
134
249
  * Register a plugin for installation (parent level).
135
250
  * Installation occurs on first resolveAndLoad() (or explicit install()).
package/package.json CHANGED
@@ -14,54 +14,55 @@
14
14
  },
15
15
  "dependencies": {
16
16
  "commander": "^14.0.1",
17
- "dotenv": "^17.2.2",
17
+ "dotenv": "^17.2.3",
18
18
  "execa": "^9.6.0",
19
19
  "fs-extra": "^11.3.2",
20
- "globby": "^14",
21
- "nanoid": "^5.1.5",
20
+ "globby": "^15",
21
+ "nanoid": "^5.1.6",
22
22
  "package-directory": "^8.1.0",
23
23
  "yaml": "^2.8.1",
24
- "zod": "^4.1.9"
24
+ "zod": "^4.1.12"
25
25
  },
26
26
  "description": "Process dotenv files in an arbitrary location & optionally populate environment variables.",
27
27
  "devDependencies": {
28
- "@dotenvx/dotenvx": "^1.50.1",
29
- "@eslint/js": "^9.36.0",
28
+ "@dotenvx/dotenvx": "^1.51.0",
29
+ "@eslint/js": "^9.38.0",
30
30
  "@rollup/plugin-alias": "^5.1.1",
31
- "@rollup/plugin-commonjs": "^28.0.6",
31
+ "@rollup/plugin-commonjs": "^28.0.8",
32
32
  "@rollup/plugin-json": "^6.1.0",
33
- "@rollup/plugin-node-resolve": "^16.0.1",
33
+ "@rollup/plugin-node-resolve": "^16.0.3",
34
34
  "@rollup/plugin-typescript": "^12.1.4",
35
35
  "@types/fs-extra": "^11.0.4",
36
- "@types/node": "^22",
37
- "@vitest/eslint-plugin": "^1.3.6",
36
+ "@types/node": "^24",
38
37
  "@vitest/coverage-v8": "^3.2.4",
38
+ "@vitest/eslint-plugin": "^1.3.23",
39
39
  "auto-changelog": "^2.5.0",
40
- "esbuild": "^0.25.10",
41
- "eslint": "^9.36.0",
40
+ "cross-env": "^10.1.0",
41
+ "esbuild": "^0.25.11",
42
+ "eslint": "^9.38.0",
42
43
  "eslint-config-prettier": "^10.1.8",
43
- "eslint-plugin-jsonc": "^2.20.1",
44
+ "eslint-plugin-jsonc": "^2.21.0",
44
45
  "eslint-plugin-prettier": "^5.5.4",
45
46
  "eslint-plugin-simple-import-sort": "^12.1.1",
46
47
  "eslint-plugin-tsdoc": "^0.4.0",
47
48
  "fs-extra": "^11.3.2",
48
49
  "globals": "^16.4.0",
49
- "jsonc-eslint-parser": "^2.4.0",
50
- "knip": "^5.63.1",
51
- "npm-packlist": "^10.0.1",
52
- "lefthook": "^1.13.1",
50
+ "jsonc-eslint-parser": "^2.4.1",
51
+ "knip": "^5.66.0",
52
+ "lefthook": "^1.13.6",
53
+ "npm-packlist": "^10.0.2",
53
54
  "prettier": "^3.6.2",
54
55
  "release-it": "^19.0.5",
55
56
  "rimraf": "^6.0.1",
56
- "rollup": "^4.52.0",
57
+ "rollup": "^4.52.5",
57
58
  "rollup-plugin-dts": "^6.2.3",
58
59
  "tslib": "^2.8.1",
59
- "tsx": "^4.20.5",
60
- "typedoc": "^0.28.13",
61
- "typedoc-plugin-mdn-links": "^5.0.9",
60
+ "tsx": "^4.20.6",
61
+ "typedoc": "^0.28.14",
62
+ "typedoc-plugin-mdn-links": "^5.0.10",
62
63
  "typedoc-plugin-replace-text": "^4.2.0",
63
- "typescript": "^5.9.2",
64
- "typescript-eslint": "^8.44.0",
64
+ "typescript": "^5.9.3",
65
+ "typescript-eslint": "^8.46.1",
65
66
  "vite-tsconfig-paths": "^5.1.4",
66
67
  "vitest": "^3.2.4"
67
68
  },
@@ -224,5 +225,5 @@
224
225
  },
225
226
  "type": "module",
226
227
  "types": "dist/index.d.ts",
227
- "version": "5.0.0"
228
+ "version": "5.2.0"
228
229
  }