@karmaniverous/get-dotenv 6.0.0-1 → 6.1.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.
Files changed (62) hide show
  1. package/README.md +91 -379
  2. package/dist/cli.d.ts +569 -0
  3. package/dist/cli.mjs +18877 -0
  4. package/dist/cliHost.d.ts +528 -184
  5. package/dist/cliHost.mjs +1977 -1428
  6. package/dist/config.d.ts +191 -14
  7. package/dist/config.mjs +266 -81
  8. package/dist/env-overlay.d.ts +223 -16
  9. package/dist/env-overlay.mjs +185 -4
  10. package/dist/getdotenv.cli.mjs +18025 -3196
  11. package/dist/index.d.ts +623 -256
  12. package/dist/index.mjs +18045 -3206
  13. package/dist/plugins-aws.d.ts +221 -91
  14. package/dist/plugins-aws.mjs +2411 -369
  15. package/dist/plugins-batch.d.ts +300 -103
  16. package/dist/plugins-batch.mjs +2560 -484
  17. package/dist/plugins-cmd.d.ts +229 -106
  18. package/dist/plugins-cmd.mjs +2518 -790
  19. package/dist/plugins-init.d.ts +221 -95
  20. package/dist/plugins-init.mjs +2170 -105
  21. package/dist/plugins.d.ts +246 -125
  22. package/dist/plugins.mjs +17941 -1968
  23. package/dist/templates/cli/index.ts +25 -0
  24. package/{templates/cli/ts → dist/templates/cli}/plugins/hello.ts +13 -9
  25. package/dist/templates/config/js/getdotenv.config.js +20 -0
  26. package/dist/templates/config/json/local/getdotenv.config.local.json +7 -0
  27. package/dist/templates/config/json/public/getdotenv.config.json +9 -0
  28. package/dist/templates/config/public/getdotenv.config.json +8 -0
  29. package/dist/templates/config/ts/getdotenv.config.ts +28 -0
  30. package/dist/templates/config/yaml/local/getdotenv.config.local.yaml +7 -0
  31. package/dist/templates/config/yaml/public/getdotenv.config.yaml +7 -0
  32. package/dist/templates/getdotenv.config.js +20 -0
  33. package/dist/templates/getdotenv.config.json +9 -0
  34. package/dist/templates/getdotenv.config.local.json +7 -0
  35. package/dist/templates/getdotenv.config.local.yaml +7 -0
  36. package/dist/templates/getdotenv.config.ts +28 -0
  37. package/dist/templates/getdotenv.config.yaml +7 -0
  38. package/dist/templates/hello.ts +42 -0
  39. package/dist/templates/index.ts +25 -0
  40. package/dist/templates/js/getdotenv.config.js +20 -0
  41. package/dist/templates/json/local/getdotenv.config.local.json +7 -0
  42. package/dist/templates/json/public/getdotenv.config.json +9 -0
  43. package/dist/templates/local/getdotenv.config.local.json +7 -0
  44. package/dist/templates/local/getdotenv.config.local.yaml +7 -0
  45. package/dist/templates/plugins/hello.ts +42 -0
  46. package/dist/templates/public/getdotenv.config.json +9 -0
  47. package/dist/templates/public/getdotenv.config.yaml +7 -0
  48. package/dist/templates/ts/getdotenv.config.ts +28 -0
  49. package/dist/templates/yaml/local/getdotenv.config.local.yaml +7 -0
  50. package/dist/templates/yaml/public/getdotenv.config.yaml +7 -0
  51. package/getdotenv.config.json +1 -19
  52. package/package.json +42 -39
  53. package/templates/cli/index.ts +25 -0
  54. package/templates/cli/plugins/hello.ts +42 -0
  55. package/templates/config/js/getdotenv.config.js +8 -3
  56. package/templates/config/json/public/getdotenv.config.json +0 -3
  57. package/templates/config/public/getdotenv.config.json +0 -5
  58. package/templates/config/ts/getdotenv.config.ts +8 -3
  59. package/templates/config/yaml/public/getdotenv.config.yaml +0 -3
  60. package/dist/plugins-demo.d.ts +0 -204
  61. package/dist/plugins-demo.mjs +0 -496
  62. package/templates/cli/ts/index.ts +0 -9
package/dist/cliHost.d.ts CHANGED
@@ -1,56 +1,189 @@
1
- import { Command, Option } from 'commander';
1
+ import { OptionValues, Command, InferCommandArguments, Option, CommandUnknownOpts } from '@commander-js/extra-typings';
2
2
  import { z, ZodObject } from 'zod';
3
3
  export { z } from 'zod';
4
4
 
5
5
  /**
6
6
  * Minimal root options shape shared by CLI and generator layers.
7
7
  * Keep keys optional to respect exactOptionalPropertyTypes semantics.
8
+ *
9
+ * @public
8
10
  */
9
- type RootOptionsShape = {
11
+ interface RootOptionsShape {
12
+ /** Target environment (dotenv-expanded). */
10
13
  env?: string;
14
+ /** Explicit variable overrides (dotenv-expanded). */
11
15
  vars?: string;
16
+ /** Command to execute (dotenv-expanded). */
12
17
  command?: string;
18
+ /** Output path for the consolidated environment file (dotenv-expanded). */
13
19
  outputPath?: string;
20
+ /**
21
+ * Shell execution strategy.
22
+ * - `true`: use default OS shell.
23
+ * - `false`: use plain execution (no shell).
24
+ * - string: use specific shell path.
25
+ */
14
26
  shell?: string | boolean;
27
+ /** Whether to load variables into `process.env`. */
15
28
  loadProcess?: boolean;
29
+ /** Exclude all variables from loading. */
16
30
  excludeAll?: boolean;
31
+ /** Exclude dynamic variables. */
17
32
  excludeDynamic?: boolean;
33
+ /** Exclude environment-specific variables. */
18
34
  excludeEnv?: boolean;
35
+ /** Exclude global variables. */
19
36
  excludeGlobal?: boolean;
37
+ /** Exclude private variables. */
20
38
  excludePrivate?: boolean;
39
+ /** Exclude public variables. */
21
40
  excludePublic?: boolean;
41
+ /** Enable console logging of loaded variables. */
22
42
  log?: boolean;
43
+ /** Enable debug logging to stderr. */
23
44
  debug?: boolean;
45
+ /** Capture child process stdio (useful for tests/CI). */
24
46
  capture?: boolean;
47
+ /** Fail on validation errors (schema/requiredKeys). */
25
48
  strict?: boolean;
49
+ /** Enable presentation-time redaction of secret-like keys. */
26
50
  redact?: boolean;
51
+ /** Enable entropy warnings for high-entropy values. */
27
52
  warnEntropy?: boolean;
53
+ /** Entropy threshold (bits/char) for warnings (default 3.8). */
28
54
  entropyThreshold?: number;
55
+ /** Minimum string length to check for entropy (default 16). */
29
56
  entropyMinLength?: number;
30
- entropyWhitelist?: string[];
57
+ /** Regex patterns for keys to exclude from entropy checks. */
58
+ entropyWhitelist?: ReadonlyArray<string>;
59
+ /** Additional regex patterns for keys to redact. */
31
60
  redactPatterns?: string[];
61
+ /** Default target environment when not specified. */
32
62
  defaultEnv?: string;
63
+ /** Token indicating a dotenv file (default: ".env"). */
33
64
  dotenvToken?: string;
65
+ /** Path to dynamic variables module (default: undefined). */
34
66
  dynamicPath?: string;
67
+ /**
68
+ * Emit diagnostics for child env composition.
69
+ * - `true`: trace all keys.
70
+ * - `string[]`: trace selected keys.
71
+ */
35
72
  trace?: boolean | string[];
73
+ /** Paths to search for dotenv files (space-delimited string or array). */
36
74
  paths?: string;
75
+ /** Delimiter for paths string (default: space). */
37
76
  pathsDelimiter?: string;
77
+ /** Regex pattern for paths delimiter. */
38
78
  pathsDelimiterPattern?: string;
79
+ /** Token indicating private variables (default: "local"). */
39
80
  privateToken?: string;
81
+ /** Delimiter for vars string (default: space). */
40
82
  varsDelimiter?: string;
83
+ /** Regex pattern for vars delimiter. */
41
84
  varsDelimiterPattern?: string;
85
+ /** Assignment operator for vars (default: "="). */
42
86
  varsAssignor?: string;
87
+ /** Regex pattern for vars assignment operator. */
43
88
  varsAssignorPattern?: string;
89
+ /** Table of named scripts for execution. */
44
90
  scripts?: ScriptsTable;
45
- };
91
+ }
46
92
  /**
47
- * Scripts table shape (configurable shell type).
93
+ * Definition for a single script entry.
48
94
  */
49
- type ScriptsTable<TShell extends string | boolean = string | boolean> = Record<string, string | {
95
+ interface ScriptDef<TShell extends string | boolean = string | boolean> {
96
+ /** The command string to execute. */
50
97
  cmd: string;
98
+ /** Shell override for this script. */
51
99
  shell?: TShell | undefined;
52
- }>;
100
+ }
101
+ /**
102
+ * Scripts table shape.
103
+ */
104
+ type ScriptsTable<TShell extends string | boolean = string | boolean> = Record<string, string | ScriptDef<TShell>>;
105
+ /**
106
+ * Identity helper to define a scripts table while preserving a concrete TShell
107
+ * type parameter in downstream inference.
108
+ */
109
+ declare const defineScripts: <TShell extends string | boolean>() => <T extends ScriptsTable<TShell>>(t: T) => T;
110
+ /**
111
+ * Per-invocation context shared with plugins and actions.
112
+ *
113
+ * @public
114
+ */
115
+ interface GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> {
116
+ optionsResolved: TOptions;
117
+ dotenv: ProcessEnv;
118
+ plugins?: Record<string, unknown>;
119
+ pluginConfigs?: Record<string, unknown>;
120
+ }
121
+ /**
122
+ * Options for branding the CLI.
123
+ *
124
+ * @public
125
+ */
126
+ interface BrandOptions {
127
+ /** CLI name. */
128
+ name?: string;
129
+ /** CLI description. */
130
+ description?: string;
131
+ /** CLI version string. */
132
+ version?: string;
133
+ /** Import URL for resolving package version. */
134
+ importMetaUrl?: string;
135
+ /** Custom help header text. */
136
+ helpHeader?: string;
137
+ }
138
+
139
+ /**
140
+ * Resolved CLI options schema.
141
+ * For the current step this mirrors the RAW schema; later stages may further
142
+ * narrow types post-resolution in the host pipeline.
143
+ */
144
+ declare const getDotenvCliOptionsSchemaResolved: z.ZodObject<{
145
+ defaultEnv: z.ZodOptional<z.ZodString>;
146
+ dotenvToken: z.ZodOptional<z.ZodString>;
147
+ dynamicPath: z.ZodOptional<z.ZodString>;
148
+ dynamic: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
149
+ env: z.ZodOptional<z.ZodString>;
150
+ excludeDynamic: z.ZodOptional<z.ZodBoolean>;
151
+ excludeEnv: z.ZodOptional<z.ZodBoolean>;
152
+ excludeGlobal: z.ZodOptional<z.ZodBoolean>;
153
+ excludePrivate: z.ZodOptional<z.ZodBoolean>;
154
+ excludePublic: z.ZodOptional<z.ZodBoolean>;
155
+ loadProcess: z.ZodOptional<z.ZodBoolean>;
156
+ log: z.ZodOptional<z.ZodBoolean>;
157
+ logger: z.ZodDefault<z.ZodUnknown>;
158
+ outputPath: z.ZodOptional<z.ZodString>;
159
+ privateToken: z.ZodOptional<z.ZodString>;
160
+ debug: z.ZodOptional<z.ZodBoolean>;
161
+ strict: z.ZodOptional<z.ZodBoolean>;
162
+ capture: z.ZodOptional<z.ZodBoolean>;
163
+ trace: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodArray<z.ZodString>]>>;
164
+ redact: z.ZodOptional<z.ZodBoolean>;
165
+ warnEntropy: z.ZodOptional<z.ZodBoolean>;
166
+ entropyThreshold: z.ZodOptional<z.ZodNumber>;
167
+ entropyMinLength: z.ZodOptional<z.ZodNumber>;
168
+ entropyWhitelist: z.ZodOptional<z.ZodArray<z.ZodString>>;
169
+ redactPatterns: z.ZodOptional<z.ZodArray<z.ZodString>>;
170
+ paths: z.ZodOptional<z.ZodString>;
171
+ pathsDelimiter: z.ZodOptional<z.ZodString>;
172
+ pathsDelimiterPattern: z.ZodOptional<z.ZodString>;
173
+ scripts: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
174
+ shell: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodString]>>;
175
+ vars: z.ZodOptional<z.ZodString>;
176
+ varsAssignor: z.ZodOptional<z.ZodString>;
177
+ varsAssignorPattern: z.ZodOptional<z.ZodString>;
178
+ varsDelimiter: z.ZodOptional<z.ZodString>;
179
+ varsDelimiterPattern: z.ZodOptional<z.ZodString>;
180
+ }, z.core.$strip>;
53
181
 
182
+ /**
183
+ * Resolved programmatic options schema (post-inheritance).
184
+ * For now, this mirrors the RAW schema; future stages may materialize defaults
185
+ * and narrow shapes as resolution is wired into the host.
186
+ */
54
187
  declare const getDotenvOptionsSchemaResolved: z.ZodObject<{
55
188
  defaultEnv: z.ZodOptional<z.ZodString>;
56
189
  dotenvToken: z.ZodOptional<z.ZodString>;
@@ -64,13 +197,23 @@ declare const getDotenvOptionsSchemaResolved: z.ZodObject<{
64
197
  excludePublic: z.ZodOptional<z.ZodBoolean>;
65
198
  loadProcess: z.ZodOptional<z.ZodBoolean>;
66
199
  log: z.ZodOptional<z.ZodBoolean>;
67
- logger: z.ZodOptional<z.ZodUnknown>;
200
+ logger: z.ZodDefault<z.ZodUnknown>;
68
201
  outputPath: z.ZodOptional<z.ZodString>;
69
202
  paths: z.ZodOptional<z.ZodArray<z.ZodString>>;
70
203
  privateToken: z.ZodOptional<z.ZodString>;
71
204
  vars: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodOptional<z.ZodString>>>;
72
205
  }, z.core.$strip>;
73
206
 
207
+ /**
208
+ * Canonical programmatic options and helpers for get-dotenv.
209
+ *
210
+ * Requirements addressed:
211
+ * - GetDotenvOptions derives from the Zod schema output (single source of truth).
212
+ * - Removed deprecated/compat flags from the public shape (e.g., useConfigLoader).
213
+ * - Provide Vars-aware defineDynamic and a typed config builder defineGetDotenvConfig\<Vars, Env\>().
214
+ * - Preserve existing behavior for defaults resolution and compat converters.
215
+ */
216
+
74
217
  /**
75
218
  * A minimal representation of an environment key/value mapping.
76
219
  * Values may be `undefined` to represent "unset".
@@ -82,7 +225,14 @@ type ProcessEnv = Record<string, string | undefined>;
82
225
  * or `undefined` to unset/skip the variable.
83
226
  */
84
227
  type GetDotenvDynamicFunction = (vars: ProcessEnv, env: string | undefined) => string | undefined;
228
+ /**
229
+ * A map of dynamic variable definitions.
230
+ * Keys are variable names; values are either literal strings or functions.
231
+ */
85
232
  type GetDotenvDynamic = Record<string, GetDotenvDynamicFunction | ReturnType<GetDotenvDynamicFunction>>;
233
+ /**
234
+ * Logger interface compatible with `console` or a subset thereof.
235
+ */
86
236
  type Logger = Record<string, (...args: unknown[]) => void> | typeof console;
87
237
  /**
88
238
  * Canonical programmatic options type (schema-derived).
@@ -92,51 +242,16 @@ type GetDotenvOptions = z.output<typeof getDotenvOptionsSchemaResolved> & {
92
242
  /**
93
243
  * Compile-time overlay: narrowed logger for DX (schema stores unknown).
94
244
  */
95
- logger?: Logger;
245
+ logger: Logger;
96
246
  /**
97
247
  * Compile-time overlay: narrowed dynamic map for DX (schema stores unknown).
98
248
  */
99
249
  dynamic?: GetDotenvDynamic;
100
250
  };
101
251
 
102
- declare const getDotenvCliOptionsSchemaResolved: z.ZodObject<{
103
- defaultEnv: z.ZodOptional<z.ZodString>;
104
- dotenvToken: z.ZodOptional<z.ZodString>;
105
- dynamicPath: z.ZodOptional<z.ZodString>;
106
- dynamic: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
107
- env: z.ZodOptional<z.ZodString>;
108
- excludeDynamic: z.ZodOptional<z.ZodBoolean>;
109
- excludeEnv: z.ZodOptional<z.ZodBoolean>;
110
- excludeGlobal: z.ZodOptional<z.ZodBoolean>;
111
- excludePrivate: z.ZodOptional<z.ZodBoolean>;
112
- excludePublic: z.ZodOptional<z.ZodBoolean>;
113
- loadProcess: z.ZodOptional<z.ZodBoolean>;
114
- log: z.ZodOptional<z.ZodBoolean>;
115
- logger: z.ZodOptional<z.ZodUnknown>;
116
- outputPath: z.ZodOptional<z.ZodString>;
117
- privateToken: z.ZodOptional<z.ZodString>;
118
- debug: z.ZodOptional<z.ZodBoolean>;
119
- strict: z.ZodOptional<z.ZodBoolean>;
120
- capture: z.ZodOptional<z.ZodBoolean>;
121
- trace: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodArray<z.ZodString>]>>;
122
- redact: z.ZodOptional<z.ZodBoolean>;
123
- warnEntropy: z.ZodOptional<z.ZodBoolean>;
124
- entropyThreshold: z.ZodOptional<z.ZodNumber>;
125
- entropyMinLength: z.ZodOptional<z.ZodNumber>;
126
- entropyWhitelist: z.ZodOptional<z.ZodArray<z.ZodString>>;
127
- redactPatterns: z.ZodOptional<z.ZodArray<z.ZodString>>;
128
- paths: z.ZodOptional<z.ZodString>;
129
- pathsDelimiter: z.ZodOptional<z.ZodString>;
130
- pathsDelimiterPattern: z.ZodOptional<z.ZodString>;
131
- scripts: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
132
- shell: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodString]>>;
133
- vars: z.ZodOptional<z.ZodString>;
134
- varsAssignor: z.ZodOptional<z.ZodString>;
135
- varsAssignorPattern: z.ZodOptional<z.ZodString>;
136
- varsDelimiter: z.ZodOptional<z.ZodString>;
137
- varsDelimiterPattern: z.ZodOptional<z.ZodString>;
138
- }, z.core.$strip>;
139
-
252
+ /**
253
+ * Unify Scripts via the generic ScriptsTable<TShell> so shell types propagate.
254
+ */
140
255
  type Scripts = ScriptsTable;
141
256
  /**
142
257
  * Canonical CLI options type derived from the Zod schema output.
@@ -148,23 +263,251 @@ type GetDotenvCliOptions = z.output<typeof getDotenvCliOptionsSchemaResolved> &
148
263
  /**
149
264
  * Compile-only overlay for DX: logger narrowed from unknown.
150
265
  */
151
- logger?: Logger;
266
+ logger: Logger;
152
267
  /**
153
268
  * Compile-only overlay for DX: scripts narrowed from Record\<string, unknown\>.
154
269
  */
155
270
  scripts?: Scripts;
156
271
  };
272
+ /**
273
+ * Base CLI options derived from the shared root option defaults.
274
+ * Used for type-safe initialization of CLI options bags.
275
+ */
276
+ declare const baseGetDotenvCliOptions: Partial<GetDotenvCliOptions>;
157
277
 
278
+ /**
279
+ * Configuration context used for generating dynamic help descriptions.
280
+ * Contains merged CLI options and plugin configuration slices.
281
+ *
282
+ * @public
283
+ */
158
284
  type ResolvedHelpConfig = Partial<GetDotenvCliOptions> & {
285
+ /**
286
+ * Per‑plugin configuration slices keyed by realized mount path
287
+ * (e.g., `"aws"` or `"aws/whoami"`), used for dynamic help text.
288
+ */
159
289
  plugins: Record<string, unknown>;
160
290
  };
161
- /** Per-invocation context shared with plugins and actions. */
162
- type GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> = {
163
- optionsResolved: TOptions;
164
- dotenv: ProcessEnv;
165
- plugins?: Record<string, unknown>;
166
- pluginConfigs?: Record<string, unknown>;
291
+ /**
292
+ * Build a help-time configuration bag for dynamic option descriptions.
293
+ * Centralizes construction and reduces inline casts at call sites.
294
+ */
295
+ declare const toHelpConfig: (merged: Partial<GetDotenvCliOptions> | Partial<RootOptionsShape>, plugins: Record<string, unknown> | undefined) => ResolvedHelpConfig;
296
+
297
+ /** src/cliHost/definePlugin/contracts.ts
298
+ * Public contracts for plugin authoring (types only).
299
+ * - No runtime logic or state.
300
+ * - Safe to import broadly without introducing cycles.
301
+ */
302
+
303
+ /**
304
+ * Options for resolving and loading the configuration.
305
+ *
306
+ * @public
307
+ */
308
+ interface ResolveAndLoadOptions {
309
+ /**
310
+ * When false, skips running plugin afterResolve hooks.
311
+ * Useful for top-level help rendering to avoid long-running side-effects
312
+ * while still evaluating dynamic help text.
313
+ *
314
+ * @default true
315
+ */
316
+ runAfterResolve?: boolean;
317
+ }
318
+ /**
319
+ * Structural public interface for the host exposed to plugins.
320
+ * - Extends Commander.Command so plugins can attach options/commands/hooks.
321
+ * - Adds host-specific helpers used by built-in plugins.
322
+ *
323
+ * Purpose: remove nominal class identity (private fields) from the plugin seam
324
+ * to avoid TS2379 under exactOptionalPropertyTypes in downstream consumers.
325
+ */
326
+ interface GetDotenvCliPublic<TOptions extends GetDotenvOptions = GetDotenvOptions, TArgs extends unknown[] = [], TOpts extends OptionValues = {}, TGlobal extends OptionValues = {}> extends Command<TArgs, TOpts, TGlobal> {
327
+ /**
328
+ * Create a namespaced child command with argument inference.
329
+ * Mirrors Commander generics so downstream chaining remains fully typed.
330
+ */
331
+ ns<Usage extends string>(name: Usage): GetDotenvCliPublic<TOptions, [
332
+ ...TArgs,
333
+ ...InferCommandArguments<Usage>
334
+ ], {}, TOpts & TGlobal>;
335
+ /** Return the current context; throws if not yet resolved. */
336
+ getCtx(): GetDotenvCliCtx<TOptions>;
337
+ /** Check whether a context has been resolved (non-throwing). */
338
+ hasCtx(): boolean;
339
+ resolveAndLoad(customOptions?: Partial<TOptions>, opts?: ResolveAndLoadOptions): Promise<GetDotenvCliCtx<TOptions>>;
340
+ setOptionGroup(opt: Option, group: string): void;
341
+ /**
342
+ * Create a dynamic option whose description is computed at help time
343
+ * from the resolved configuration.
344
+ */
345
+ createDynamicOption<Usage extends string>(flags: Usage, desc: (cfg: ResolvedHelpConfig) => string, parser?: (value: string, previous?: unknown) => unknown, defaultValue?: unknown): Option<Usage>;
346
+ createDynamicOption<Usage extends string, TValue = unknown>(flags: Usage, desc: (cfg: ResolvedHelpConfig) => string, parser: (value: string, previous?: TValue) => TValue, defaultValue?: TValue): Option<Usage>;
347
+ }
348
+ /**
349
+ * Optional overrides for plugin composition.
350
+ *
351
+ * @public
352
+ */
353
+ interface PluginNamespaceOverride {
354
+ /**
355
+ * Override the default namespace for this plugin instance.
356
+ */
357
+ ns?: string;
358
+ }
359
+ /**
360
+ * An entry in the plugin children array.
361
+ *
362
+ * @public
363
+ */
364
+ interface PluginChildEntry<TOptions extends GetDotenvOptions = GetDotenvOptions, TArgs extends unknown[] = [], TOpts extends OptionValues = {}, TGlobal extends OptionValues = {}> {
365
+ /** The child plugin instance to mount under this parent. */
366
+ plugin: GetDotenvCliPlugin<TOptions, TArgs, TOpts, TGlobal>;
367
+ /**
368
+ * Optional namespace override for the child when mounted under the parent.
369
+ * When provided, this name is used instead of the child's default `ns`.
370
+ */
371
+ override: PluginNamespaceOverride | undefined;
372
+ }
373
+ /** Public plugin contract used by the GetDotenv CLI host. */
374
+ interface GetDotenvCliPlugin<TOptions extends GetDotenvOptions = GetDotenvOptions, TArgs extends unknown[] = [], TOpts extends OptionValues = {}, TGlobal extends OptionValues = {}> {
375
+ /** Namespace (required): the command name where this plugin is mounted. */
376
+ ns: string;
377
+ /**
378
+ * Setup phase: register commands and wiring on the provided mount.
379
+ * Runs parent → children (pre-order). Return nothing (void).
380
+ */
381
+ setup: (cli: GetDotenvCliPublic<TOptions, TArgs, TOpts, TGlobal>) => void | Promise<void>;
382
+ /**
383
+ * After the dotenv context is resolved, initialize any clients/secrets
384
+ * or attach per-plugin state under ctx.plugins (by convention).
385
+ * Runs parent → children (pre-order).
386
+ */
387
+ afterResolve?: (cli: GetDotenvCliPublic<TOptions, TArgs, TOpts, TGlobal>, ctx: GetDotenvCliCtx<TOptions>) => void | Promise<void>;
388
+ /** Zod schema for this plugin's config slice (from config.plugins[…]). */
389
+ configSchema?: ZodObject;
390
+ /**
391
+ * Compositional children, with optional per-child overrides (e.g., ns).
392
+ * Installed after the parent per pre-order.
393
+ */
394
+ children: Array<PluginChildEntry<TOptions, TArgs, TOpts, TGlobal>>;
395
+ /**
396
+ * Compose a child plugin with optional override (ns). Returns the parent
397
+ * to enable chaining.
398
+ */
399
+ use: (child: GetDotenvCliPlugin<TOptions, TArgs, TOpts, TGlobal>, override?: PluginNamespaceOverride) => GetDotenvCliPlugin<TOptions, TArgs, TOpts, TGlobal>;
400
+ }
401
+ /**
402
+ * Compile-time helper type: the plugin object returned by definePlugin always
403
+ * includes the instance-bound helpers as required members. Keeping the public
404
+ * interface optional preserves compatibility for ad-hoc/test plugins, while
405
+ * return types from definePlugin provide stronger DX for shipped/typed plugins.
406
+ */
407
+ interface PluginWithInstanceHelpers<TOptions extends GetDotenvOptions = GetDotenvOptions, TConfig = unknown, TArgs extends unknown[] = [], TOpts extends OptionValues = {}, TGlobal extends OptionValues = {}> extends GetDotenvCliPlugin<TOptions, TArgs, TOpts, TGlobal> {
408
+ readConfig<TCfg = TConfig>(cli: GetDotenvCliPublic<TOptions, unknown[], OptionValues, OptionValues>): Readonly<TCfg>;
409
+ createPluginDynamicOption<TCfg = TConfig, Usage extends string = string>(cli: GetDotenvCliPublic<TOptions, unknown[], OptionValues, OptionValues>, flags: Usage, desc: (cfg: ResolvedHelpConfig, pluginCfg: Readonly<TCfg>) => string, parser?: (value: string, previous?: unknown) => unknown, defaultValue?: unknown): Option<Usage>;
410
+ }
411
+ /**
412
+ * Public spec type for defining a plugin with compositional helpers.
413
+ */
414
+ type DefineSpec<TOptions extends GetDotenvOptions = GetDotenvOptions, TArgs extends unknown[] = [], TOpts extends OptionValues = {}, TGlobal extends OptionValues = {}> = Omit<GetDotenvCliPlugin<TOptions, TArgs, TOpts, TGlobal>, 'children' | 'use' | 'setup'> & {
415
+ /**
416
+ * Required namespace and setup function. The host creates the mount and
417
+ * passes it into setup; return void | Promise<void>.
418
+ */
419
+ ns: string;
420
+ setup: (cli: GetDotenvCliPublic<TOptions, TArgs, TOpts, TGlobal>) => void | Promise<void>;
167
421
  };
422
+ /**
423
+ * Helper to infer the configuration type from a `PluginWithInstanceHelpers` type.
424
+ */
425
+ type InferPluginConfig<P> = P extends PluginWithInstanceHelpers<GetDotenvOptions, infer C> ? Readonly<C> : never;
426
+
427
+ /**
428
+ * Define a GetDotenv CLI plugin with compositional helpers.
429
+ *
430
+ * @example
431
+ * const p = definePlugin(\{ ns: 'aws', setup(cli) \{ /* wire subcommands *\/ \} \})
432
+ * .use(child, \{ ns: 'whoami' \});
433
+ */
434
+ declare function definePlugin<TOptions extends GetDotenvOptions, Schema extends ZodObject>(spec: Omit<DefineSpec<TOptions>, 'configSchema'> & {
435
+ configSchema: Schema;
436
+ }): PluginWithInstanceHelpers<TOptions, z.output<Schema>>;
437
+ declare function definePlugin<TOptions extends GetDotenvOptions>(spec: DefineSpec<TOptions>): PluginWithInstanceHelpers<TOptions, {}>;
438
+
439
+ /**
440
+ * Helper to decide whether to capture child stdio.
441
+ * Checks GETDOTENV_STDIO env var or the provided bag capture flag.
442
+ */
443
+ declare const shouldCapture: (bagCapture?: boolean) => boolean;
444
+ /**
445
+ * Options for runCommandResult (buffered execution).
446
+ *
447
+ * @public
448
+ */
449
+ interface RunCommandResultOptions {
450
+ /**
451
+ * Working directory for the child process.
452
+ */
453
+ cwd?: string | URL;
454
+ /**
455
+ * Environment variables for the child process. Undefined values are dropped.
456
+ */
457
+ env?: NodeJS.ProcessEnv;
458
+ /**
459
+ * Optional timeout (ms). Kills the child with SIGKILL on expiry.
460
+ */
461
+ timeoutMs?: number;
462
+ }
463
+ /**
464
+ * Options for runCommand (execution with optional inherit/pipe).
465
+ *
466
+ * @public
467
+ */
468
+ interface RunCommandOptions {
469
+ /**
470
+ * Working directory for the child process.
471
+ */
472
+ cwd?: string | URL;
473
+ /**
474
+ * Environment variables for the child process. Undefined values are dropped.
475
+ */
476
+ env?: NodeJS.ProcessEnv;
477
+ /**
478
+ * Stdio strategy for the child process.
479
+ */
480
+ stdio?: 'inherit' | 'pipe';
481
+ }
482
+ /**
483
+ * Execute a command and capture stdout/stderr (buffered).
484
+ * - Preserves plain vs shell behavior and argv/string normalization.
485
+ * - Never re-emits stdout/stderr to parent; returns captured buffers.
486
+ * - Supports optional timeout (ms).
487
+ */
488
+ declare function runCommandResult(command: readonly string[], shell: false, opts?: RunCommandResultOptions): Promise<{
489
+ exitCode: number;
490
+ stdout: string;
491
+ stderr: string;
492
+ }>;
493
+ declare function runCommandResult(command: string | readonly string[], shell: string | boolean | URL, opts?: RunCommandResultOptions): Promise<{
494
+ exitCode: number;
495
+ stdout: string;
496
+ stderr: string;
497
+ }>;
498
+ declare function runCommand(command: readonly string[], shell: false, opts: RunCommandOptions): Promise<number>;
499
+ declare function runCommand(command: string | readonly string[], shell: string | boolean | URL, opts: RunCommandOptions): Promise<number>;
500
+
501
+ /** src/cliHost/GetDotenvCli.ts
502
+ * Plugin-first CLI host for get-dotenv with Commander generics preserved.
503
+ * Public surface implements GetDotenvCliPublic and provides:
504
+ * - attachRootOptions (builder-only; no public override wiring)
505
+ * - resolveAndLoad (strict resolve + context compute)
506
+ * - getCtx/hasCtx accessors
507
+ * - ns() for typed subcommand creation with duplicate-name guard
508
+ * - grouped help rendering with dynamic option descriptions
509
+ */
510
+
168
511
  declare const CTX_SYMBOL: unique symbol;
169
512
  declare const OPTS_SYMBOL: unique symbol;
170
513
  declare const HELP_HEADER_SYMBOL: unique symbol;
@@ -177,11 +520,13 @@ declare const HELP_HEADER_SYMBOL: unique symbol;
177
520
  * - Provide a namespacing helper (ns).
178
521
  * - Support composable plugins with parent → children install and afterResolve.
179
522
  */
180
- declare class GetDotenvCli$1<TOptions extends GetDotenvOptions = GetDotenvOptions> extends Command implements GetDotenvCliPublic<TOptions> {
523
+ declare class GetDotenvCli<TOptions extends GetDotenvOptions = GetDotenvOptions, TArgs extends unknown[] = [], TOpts extends OptionValues = {}, TGlobal extends OptionValues = {}> extends Command<TArgs, TOpts, TGlobal> implements GetDotenvCliPublic<TOptions, TArgs, TOpts, TGlobal> {
181
524
  /** Registered top-level plugins (composition happens via .use()) */
182
525
  private _plugins;
183
526
  /** One-time installation guard */
184
527
  private _installed;
528
+ /** In-flight installation promise to guard against concurrent installs */
529
+ private _installing?;
185
530
  /** Optional header line to prepend in help output */
186
531
  private [HELP_HEADER_SYMBOL];
187
532
  /** Context/options stored under symbols (typed) */
@@ -191,8 +536,13 @@ declare class GetDotenvCli$1<TOptions extends GetDotenvOptions = GetDotenvOption
191
536
  * Create a subcommand using the same subclass, preserving helpers like
192
537
  * dynamicOption on children.
193
538
  */
194
- createCommand(name?: string): Command;
539
+ createCommand(name?: string): GetDotenvCli<TOptions>;
195
540
  constructor(alias?: string);
541
+ /**
542
+ * Attach legacy/base root flags to this CLI instance.
543
+ * Delegates to the pure builder in attachRootOptions.ts.
544
+ */
545
+ attachRootOptions(defaults?: Partial<RootOptionsShape>): this;
196
546
  /**
197
547
  * Resolve options (strict) and compute dotenv context.
198
548
  * Stores the context on the instance under a symbol.
@@ -202,37 +552,30 @@ declare class GetDotenvCli$1<TOptions extends GetDotenvOptions = GetDotenvOption
202
552
  * afterResolve hooks. Useful for top-level help rendering to avoid
203
553
  * long-running side-effects while still evaluating dynamic help text.
204
554
  */
205
- resolveAndLoad(customOptions?: Partial<TOptions>, opts?: {
206
- runAfterResolve?: boolean;
207
- }): Promise<GetDotenvCliCtx<TOptions>>;
555
+ resolveAndLoad(customOptions?: Partial<TOptions>, opts?: ResolveAndLoadOptions): Promise<GetDotenvCliCtx<TOptions>>;
208
556
  /**
209
557
  * Create a Commander Option that computes its description at help time.
210
558
  * The returned Option may be configured (conflicts, default, parser) and
211
559
  * added via addOption().
212
560
  */
213
- createDynamicOption(flags: string, desc: (cfg: ResolvedHelpConfig & {
214
- plugins: Record<string, unknown>;
215
- }) => string, parser?: (value: string, previous?: unknown) => unknown, defaultValue?: unknown): Option;
216
- createDynamicOption<TValue = unknown>(flags: string, desc: (cfg: ResolvedHelpConfig & {
217
- plugins: Record<string, unknown>;
218
- }) => string, parser: (value: string, previous?: TValue) => TValue, defaultValue?: TValue): Option;
219
- /**
220
- * Chainable helper mirroring .option(), but with a dynamic description.
221
- * Equivalent to addOption(createDynamicOption(...)).
222
- */
223
- dynamicOption(flags: string, desc: (cfg: ResolvedHelpConfig & {
224
- plugins: Record<string, unknown>;
225
- }) => string, parser?: (value: string, previous?: unknown) => unknown, defaultValue?: unknown): this;
561
+ createDynamicOption<Usage extends string>(flags: Usage, desc: (cfg: ResolvedHelpConfig) => string, parser?: (value: string, previous?: unknown) => unknown, defaultValue?: unknown): Option<Usage>;
562
+ createDynamicOption<Usage extends string, TValue = unknown>(flags: Usage, desc: (cfg: ResolvedHelpConfig) => string, parser: (value: string, previous?: TValue) => TValue, defaultValue?: TValue): Option<Usage>;
226
563
  /**
227
564
  * Evaluate dynamic descriptions for this command and all descendants using
228
565
  * the provided resolved configuration. Mutates the Option.description in
229
566
  * place so Commander help renders updated text.
230
567
  */
231
568
  evaluateDynamicOptions(resolved: ResolvedHelpConfig): void;
569
+ /** Internal: climb to the true root (host) command. */
570
+ private _root;
232
571
  /**
233
572
  * Retrieve the current invocation context (if any).
234
573
  */
235
- getCtx(): GetDotenvCliCtx<TOptions> | undefined;
574
+ getCtx(): GetDotenvCliCtx<TOptions>;
575
+ /**
576
+ * Check whether a context has been resolved (non-throwing guard).
577
+ */
578
+ hasCtx(): boolean;
236
579
  /**
237
580
  * Retrieve the merged root CLI options bag (if set by passOptions()).
238
581
  * Downstream-safe: no generics required.
@@ -240,25 +583,25 @@ declare class GetDotenvCli$1<TOptions extends GetDotenvOptions = GetDotenvOption
240
583
  getOptions(): GetDotenvCliOptions | undefined;
241
584
  /** Internal: set the merged root options bag for this run. */
242
585
  _setOptionsBag(bag: GetDotenvCliOptions): void;
243
- /** Convenience helper to create a namespaced subcommand. */
244
- ns(name: string): Command;
586
+ /**
587
+ * Convenience helper to create a namespaced subcommand with argument inference.
588
+ * This mirrors Commander generics so downstream chaining stays fully typed.
589
+ */
590
+ ns<Usage extends string>(name: Usage): GetDotenvCliPublic<TOptions, [
591
+ ...TArgs,
592
+ ...InferCommandArguments<Usage>
593
+ ], {}, TOpts & TGlobal>;
245
594
  /**
246
595
  * Tag options added during the provided callback as 'app' for grouped help.
247
596
  * Allows downstream apps to demarcate their root-level options.
248
597
  */
249
- tagAppOptions<T>(fn: (root: Command) => T): T;
598
+ tagAppOptions<T>(fn: (root: CommandUnknownOpts) => T): T;
250
599
  /**
251
600
  * Branding helper: set CLI name/description/version and optional help header.
252
601
  * If version is omitted and importMetaUrl is provided, attempts to read the
253
602
  * nearest package.json version (best-effort; non-fatal on failure).
254
603
  */
255
- brand(args: {
256
- name?: string;
257
- description?: string;
258
- version?: string;
259
- importMetaUrl?: string;
260
- helpHeader?: string;
261
- }): Promise<this>;
604
+ brand(args: BrandOptions): Promise<this>;
262
605
  /**
263
606
  * Insert grouped plugin/app options between "Options" and "Commands" for
264
607
  * hybrid ordering. Applies to root and any parent command.
@@ -272,7 +615,7 @@ declare class GetDotenvCli$1<TOptions extends GetDotenvOptions = GetDotenvOption
272
615
  * Register a plugin for installation (parent level).
273
616
  * Installation occurs on first resolveAndLoad() (or explicit install()).
274
617
  */
275
- use(plugin: GetDotenvCliPlugin<TOptions>): this;
618
+ use(plugin: GetDotenvCliPlugin<TOptions, TArgs, TOpts, TGlobal>, override?: PluginNamespaceOverride): this;
276
619
  /**
277
620
  * Install all registered plugins in parent → children (pre-order).
278
621
  * Runs only once per CLI instance.
@@ -284,132 +627,133 @@ declare class GetDotenvCli$1<TOptions extends GetDotenvOptions = GetDotenvOption
284
627
  private _runAfterResolve;
285
628
  }
286
629
 
287
- /** src/cliHost/definePlugin.ts
288
- * Plugin contracts for the GetDotenv CLI host.
630
+ /** src/cliHost/getRootCommand.ts
631
+ * Typed helper to retrieve the true root command (host) starting from any mount.
632
+ */
633
+
634
+ /**
635
+ * Return the top-level root command for a given mount or action's thisCommand.
289
636
  *
290
- * This module exposes a structural public interface for the host that plugins
291
- * should use (GetDotenvCliPublic). Using a structural type at the seam avoids
292
- * nominal class identity issues (private fields) in downstream consumers.
637
+ * @param cmd - any command (mount or thisCommand inside an action)
638
+ * @returns the root command instance
639
+ */
640
+ declare const getRootCommand: (cmd: CommandUnknownOpts) => CommandUnknownOpts;
641
+
642
+ /** src/cliHost/invoke.ts
643
+ * Shared helpers for composing child env overlays and preserving argv for Node -e.
293
644
  */
294
645
 
295
646
  /**
296
- * Structural public interface for the host exposed to plugins.
297
- * - Extends Commander.Command so plugins can attach options/commands/hooks.
298
- * - Adds host-specific helpers used by built-in plugins.
647
+ * Compose a child-process env overlay from dotenv and the merged CLI options bag.
648
+ * Returns a shallow object including getDotenvCliOptions when serializable.
299
649
  *
300
- * Purpose: remove nominal class identity (private fields) from the plugin seam
301
- * to avoid TS2379 under exactOptionalPropertyTypes in downstream consumers.
650
+ * @param merged - Resolved CLI options bag (or a JSON-serializable subset).
651
+ * @param dotenv - Composed dotenv variables for the current invocation.
652
+ * @returns A string-only env overlay suitable for child process spawning.
302
653
  */
303
- interface GetDotenvCliPublic<TOptions extends GetDotenvOptions = GetDotenvOptions> extends Command {
304
- ns(name: string): Command;
305
- getCtx(): GetDotenvCliCtx<TOptions> | undefined;
306
- resolveAndLoad(customOptions?: Partial<TOptions>, opts?: {
307
- runAfterResolve?: boolean;
308
- }): Promise<GetDotenvCliCtx<TOptions>>;
309
- setOptionGroup(opt: Option, group: string): void;
310
- /**
311
- * Create a dynamic option whose description is computed at help time
312
- * from the resolved configuration.
313
- */
314
- createDynamicOption(flags: string, desc: (cfg: ResolvedHelpConfig & {
315
- plugins: Record<string, unknown>;
316
- }) => string, parser?: (value: string, previous?: unknown) => unknown, defaultValue?: unknown): Option;
317
- createDynamicOption<TValue = unknown>(flags: string, desc: (cfg: ResolvedHelpConfig & {
318
- plugins: Record<string, unknown>;
319
- }) => string, parser: (value: string, previous?: TValue) => TValue, defaultValue?: TValue): Option;
320
- }
321
- /** Public plugin contract used by the GetDotenv CLI host. */
322
- interface GetDotenvCliPlugin<TOptions extends GetDotenvOptions = GetDotenvOptions> {
323
- id?: string;
324
- /**
325
- * Setup phase: register commands and wiring on the provided CLI instance.
326
- * Runs parent → children (pre-order).
327
- */
328
- setup: (cli: GetDotenvCliPublic<TOptions>) => void | Promise<void>;
329
- /**
330
- * After the dotenv context is resolved, initialize any clients/secrets
331
- * or attach per-plugin state under ctx.plugins (by convention).
332
- * Runs parent → children (pre-order).
333
- */
334
- afterResolve?: (cli: GetDotenvCliPublic<TOptions>, ctx: GetDotenvCliCtx<TOptions>) => void | Promise<void>;
335
- /**
336
- * Zod schema for this plugin's config slice (from config.plugins[id]).
337
- * Enforced object-like (ZodObject) to simplify code paths and inference.
338
- */
339
- configSchema?: ZodObject;
340
- /**
341
- * Compositional children. Installed after the parent per pre-order.
342
- */
343
- children: GetDotenvCliPlugin<TOptions>[];
654
+ declare function composeNestedEnv(merged: GetDotenvCliOptions | Record<string, unknown>, dotenv: Record<string, string | undefined>): Record<string, string>;
655
+ /**
656
+ * Strip one layer of symmetric outer quotes (single or double) from a string.
657
+ *
658
+ * @param s - Input string.
659
+ * @returns `s` without one symmetric outer quote pair (when present).
660
+ */
661
+ declare const stripOne: (s: string) => string;
662
+ /**
663
+ * Preserve argv array for Node -e/--eval payloads under shell-off and
664
+ * peel one symmetric outer quote layer from the code argument.
665
+ *
666
+ * @param args - Argument vector intended for direct execution (shell-off).
667
+ * @returns Either the original `args` or a modified copy with a normalized eval payload.
668
+ */
669
+ declare function maybePreserveNodeEvalArgv(args: string[]): string[];
670
+
671
+ /** src/cliHost/paths.ts
672
+ * Helpers for realized mount paths and plugin tree flattening.
673
+ */
674
+
675
+ /**
676
+ * A flattened plugin entry with its realized path.
677
+ *
678
+ * @public
679
+ */
680
+ interface PluginFlattenedEntry<TOptions extends GetDotenvOptions = GetDotenvOptions, TArgs extends unknown[] = [], TOpts extends OptionValues = {}, TGlobal extends OptionValues = {}> {
681
+ /** The plugin instance for this entry in the flattened tree. */
682
+ plugin: GetDotenvCliPlugin<TOptions, TArgs, TOpts, TGlobal>;
344
683
  /**
345
- * Compose a child plugin. Returns the parent to enable chaining.
684
+ * The realized mount path for this plugin (root alias excluded), e.g. "aws/whoami".
346
685
  */
347
- use: (child: GetDotenvCliPlugin<TOptions>) => GetDotenvCliPlugin<TOptions>;
686
+ path: string;
348
687
  }
688
+
349
689
  /**
350
- * Compile-time helper type: the plugin object returned by definePlugin always
351
- * includes the instance-bound helpers as required members. Keeping the public
352
- * interface optional preserves compatibility for ad-hoc/test plugins, while
353
- * return types from definePlugin provide stronger DX for shipped/typed plugins.
690
+ * Retrieve the merged root options bag from the current command context.
691
+ * Climbs to the root `GetDotenvCli` instance to access the persisted options.
692
+ *
693
+ * @param cmd - The current command instance (thisCommand).
694
+ * @throws Error if the root is not a GetDotenvCli or options are missing.
354
695
  */
355
- type PluginWithInstanceHelpers<TOptions extends GetDotenvOptions = GetDotenvOptions, TConfig = unknown> = GetDotenvCliPlugin<TOptions> & {
356
- readConfig<TCfg = TConfig>(cli: GetDotenvCliPublic<TOptions>): Readonly<TCfg>;
357
- createPluginDynamicOption<TCfg = TConfig>(cli: GetDotenvCliPublic<TOptions>, flags: string, desc: (cfg: ResolvedHelpConfig & {
358
- plugins: Record<string, unknown>;
359
- }, pluginCfg: Readonly<TCfg>) => string, parser?: (value: string, previous?: unknown) => unknown, defaultValue?: unknown): Option;
360
- };
696
+ declare const readMergedOptions: (cmd: CommandUnknownOpts) => GetDotenvCliOptions;
697
+
361
698
  /**
362
- * Public spec type for defining a plugin with optional children.
363
- * Exported to ensure TypeDoc links and navigation resolve correctly.
699
+ * Batch services (neutral): resolve command and shell settings.
700
+ * Shared by the generator path and the batch plugin to avoid circular deps.
364
701
  */
365
- type DefineSpec<TOptions extends GetDotenvOptions = GetDotenvOptions> = Omit<GetDotenvCliPlugin<TOptions>, 'children' | 'use'> & {
366
- children?: GetDotenvCliPlugin<TOptions>[];
367
- };
702
+
368
703
  /**
369
- * Define a GetDotenv CLI plugin with compositional helpers.
704
+ * Resolve a command string from the {@link ScriptsTable} table.
705
+ * A script may be expressed as a string or an object with a `cmd` property.
370
706
  *
371
- * @example
372
- * const parent = definePlugin({ id: 'p', setup(cli) { /* omitted *\/ } })
373
- * .use(childA)
374
- * .use(childB);
707
+ * @param scripts - Optional scripts table.
708
+ * @param command - User-provided command name or string.
709
+ * @returns Resolved command string (falls back to the provided command).
375
710
  */
376
- declare function definePlugin<TOptions extends GetDotenvOptions, Schema extends ZodObject>(spec: Omit<DefineSpec<TOptions>, 'configSchema'> & {
377
- configSchema: Schema;
378
- }): PluginWithInstanceHelpers<TOptions, z.output<Schema>>;
379
- declare function definePlugin<TOptions extends GetDotenvOptions>(spec: DefineSpec<TOptions>): PluginWithInstanceHelpers<TOptions, {}>;
380
-
711
+ declare const resolveCommand: (scripts: ScriptsTable | undefined, command: string) => string;
381
712
  /**
382
- * Infer the compile-time plugin config type from a plugin instance created by definePlugin.
383
- * Returns a deeply readonly view to discourage mutation at call sites.
713
+ * Resolve the shell setting for a given command:
714
+ * - If the script entry is an object, prefer its `shell` override.
715
+ * - Otherwise use the provided `shell` (string | boolean).
716
+ *
717
+ * @param scripts - Optional scripts table.
718
+ * @param command - User-provided command name or string.
719
+ * @param shell - Global shell preference (string | boolean).
384
720
  */
385
- type InferPluginConfig<P> = P extends PluginWithInstanceHelpers<GetDotenvOptions, infer C> ? Readonly<C> : never;
721
+ declare const resolveShell: <TShell extends string | boolean>(scripts: ScriptsTable<TShell> | undefined, command: string, shell: TShell | undefined) => TShell | false;
386
722
 
387
723
  /**
388
- * GetDotenvCli with root helpers as real class methods.
389
- * - attachRootOptions: installs legacy/base root flags on the command.
390
- * - passOptions: merges flags (parent \< current), computes dotenv context once,
391
- * runs validation, and persists merged options for nested flows.
724
+ * Result of CLI option resolution.
392
725
  */
393
- declare class GetDotenvCli extends GetDotenvCli$1 {
726
+ interface ResolveCliOptionsResult<T> {
394
727
  /**
395
- * Attach legacy root flags to this CLI instance. Defaults come from
396
- * baseRootOptionDefaults when none are provided.
728
+ * The merged options object after applying defaults, inherited parent
729
+ * values, and the current CLI flags. This bag is used as the effective
730
+ * root options for the current invocation.
397
731
  */
398
- attachRootOptions(defaults?: Partial<RootOptionsShape>): this;
732
+ merged: T;
399
733
  /**
400
- * Install preSubcommand/preAction hooks that:
401
- * - Merge options (parent round-trip + current invocation) using resolveCliOptions.
402
- * - Persist the merged bag on the current command and on the host (for ergonomics).
403
- * - Compute the dotenv context once via resolveAndLoad(serviceOptions).
404
- * - Validate the composed env against discovered config (warn or --strict fail).
734
+ * Positional command (string) resolved for invokers that accept a command
735
+ * payload (e.g., batch parent or cmd alias). When absent, no command is set.
405
736
  */
406
- passOptions(defaults?: Partial<RootOptionsShape>): this;
737
+ command?: string;
407
738
  }
408
739
  /**
409
- * Helper to retrieve the merged root options bag from any action handler
410
- * that only has access to thisCommand. Avoids structural casts.
740
+ * Merge and normalize raw Commander options (current + parent + defaults)
741
+ * into a GetDotenvCliOptions-like object. Types are intentionally wide to
742
+ * avoid cross-layer coupling; callers may cast as needed.
743
+ */
744
+ declare const resolveCliOptions: <T extends Partial<RootOptionsShape> & {
745
+ scripts?: ScriptsTable;
746
+ }>(rawCliOptions: unknown, defaults: Partial<T>, parentJson?: string) => ResolveCliOptionsResult<T>;
747
+
748
+ /**
749
+ * Build a sanitized environment object for spawning child processes.
750
+ * Merges `base` and `overlay`, drops undefined values, and handles platform-specific
751
+ * normalization (e.g. case-insensitivity on Windows).
752
+ *
753
+ * @param base - Base environment (usually `process.env`).
754
+ * @param overlay - Environment variables to overlay.
411
755
  */
412
- declare const readMergedOptions: (cmd: Command) => GetDotenvCliOptions | undefined;
756
+ declare const buildSpawnEnv: (base?: NodeJS.ProcessEnv, overlay?: Record<string, string | undefined>) => NodeJS.ProcessEnv;
413
757
 
414
- export { GetDotenvCli, definePlugin, readMergedOptions };
415
- export type { DefineSpec, GetDotenvCliCtx, GetDotenvCliOptions, GetDotenvCliPlugin, GetDotenvCliPublic, InferPluginConfig, PluginWithInstanceHelpers, ScriptsTable };
758
+ export { GetDotenvCli, baseGetDotenvCliOptions, buildSpawnEnv, composeNestedEnv, definePlugin, defineScripts, getRootCommand, maybePreserveNodeEvalArgv, readMergedOptions, resolveCliOptions, resolveCommand, resolveShell, runCommand, runCommandResult, shouldCapture, stripOne, toHelpConfig };
759
+ export type { BrandOptions, DefineSpec, GetDotenvCliCtx, GetDotenvCliOptions, GetDotenvCliPlugin, GetDotenvCliPublic, InferPluginConfig, PluginChildEntry, PluginFlattenedEntry, PluginNamespaceOverride, PluginWithInstanceHelpers, ResolveAndLoadOptions, ResolveCliOptionsResult, ResolvedHelpConfig, RootOptionsShape, RunCommandOptions, RunCommandResultOptions, ScriptDef, Scripts, ScriptsTable };