@karmaniverous/get-dotenv 6.0.0-0 → 6.0.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 (93) hide show
  1. package/README.md +86 -334
  2. package/dist/cli.d.ts +569 -0
  3. package/dist/cli.mjs +18788 -0
  4. package/dist/cliHost.d.ts +548 -253
  5. package/dist/cliHost.mjs +1990 -1458
  6. package/dist/config.d.ts +192 -14
  7. package/dist/config.mjs +256 -81
  8. package/dist/env-overlay.d.ts +226 -18
  9. package/dist/env-overlay.mjs +181 -22
  10. package/dist/getdotenv.cli.mjs +18166 -3437
  11. package/dist/index.d.ts +729 -136
  12. package/dist/index.mjs +18207 -3457
  13. package/dist/plugins-aws.d.ts +289 -104
  14. package/dist/plugins-aws.mjs +2462 -350
  15. package/dist/plugins-batch.d.ts +355 -105
  16. package/dist/plugins-batch.mjs +2595 -420
  17. package/dist/plugins-cmd.d.ts +287 -118
  18. package/dist/plugins-cmd.mjs +2661 -839
  19. package/dist/plugins-init.d.ts +272 -100
  20. package/dist/plugins-init.mjs +2152 -37
  21. package/dist/plugins.d.ts +323 -140
  22. package/dist/plugins.mjs +18006 -2025
  23. package/dist/templates/cli/index.ts +26 -0
  24. package/dist/templates/cli/plugins/hello.ts +43 -0
  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 +43 -0
  39. package/dist/templates/index.ts +26 -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 +43 -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 +52 -89
  53. package/templates/cli/index.ts +26 -0
  54. package/templates/cli/plugins/hello.ts +43 -0
  55. package/templates/config/js/getdotenv.config.js +9 -4
  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 +17 -5
  59. package/templates/config/yaml/public/getdotenv.config.yaml +0 -3
  60. package/dist/cliHost.cjs +0 -2078
  61. package/dist/cliHost.d.cts +0 -451
  62. package/dist/cliHost.d.mts +0 -451
  63. package/dist/config.cjs +0 -252
  64. package/dist/config.d.cts +0 -55
  65. package/dist/config.d.mts +0 -55
  66. package/dist/env-overlay.cjs +0 -163
  67. package/dist/env-overlay.d.cts +0 -50
  68. package/dist/env-overlay.d.mts +0 -50
  69. package/dist/index.cjs +0 -4077
  70. package/dist/index.d.cts +0 -318
  71. package/dist/index.d.mts +0 -318
  72. package/dist/plugins-aws.cjs +0 -666
  73. package/dist/plugins-aws.d.cts +0 -158
  74. package/dist/plugins-aws.d.mts +0 -158
  75. package/dist/plugins-batch.cjs +0 -658
  76. package/dist/plugins-batch.d.cts +0 -181
  77. package/dist/plugins-batch.d.mts +0 -181
  78. package/dist/plugins-cmd.cjs +0 -1112
  79. package/dist/plugins-cmd.d.cts +0 -178
  80. package/dist/plugins-cmd.d.mts +0 -178
  81. package/dist/plugins-demo.cjs +0 -352
  82. package/dist/plugins-demo.d.cts +0 -158
  83. package/dist/plugins-demo.d.mts +0 -158
  84. package/dist/plugins-demo.d.ts +0 -158
  85. package/dist/plugins-demo.mjs +0 -350
  86. package/dist/plugins-init.cjs +0 -289
  87. package/dist/plugins-init.d.cts +0 -162
  88. package/dist/plugins-init.d.mts +0 -162
  89. package/dist/plugins.cjs +0 -2327
  90. package/dist/plugins.d.cts +0 -211
  91. package/dist/plugins.d.mts +0 -211
  92. package/templates/cli/ts/index.ts +0 -9
  93. package/templates/cli/ts/plugins/hello.ts +0 -17
package/dist/plugins.d.ts CHANGED
@@ -1,174 +1,331 @@
1
- import { Command } from 'commander';
2
- import { ZodType } from 'zod';
1
+ import { OptionValues, Command, InferCommandArguments, Option } from '@commander-js/extra-typings';
2
+ import { z, ZodObject } from 'zod';
3
+
4
+ /**
5
+ * Definition for a single script entry.
6
+ */
7
+ interface ScriptDef<TShell extends string | boolean = string | boolean> {
8
+ /** The command string to execute. */
9
+ cmd: string;
10
+ /** Shell override for this script. */
11
+ shell?: TShell | undefined;
12
+ }
13
+ /**
14
+ * Scripts table shape.
15
+ */
16
+ type ScriptsTable<TShell extends string | boolean = string | boolean> = Record<string, string | ScriptDef<TShell>>;
17
+ /**
18
+ * Per-invocation context shared with plugins and actions.
19
+ *
20
+ * @public
21
+ */
22
+ interface GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> {
23
+ optionsResolved: TOptions;
24
+ dotenv: ProcessEnv;
25
+ plugins?: Record<string, unknown>;
26
+ pluginConfigs?: Record<string, unknown>;
27
+ }
28
+
29
+ /**
30
+ * Resolved CLI options schema.
31
+ * For the current step this mirrors the RAW schema; later stages may further
32
+ * narrow types post-resolution in the host pipeline.
33
+ */
34
+ declare const getDotenvCliOptionsSchemaResolved: z.ZodObject<{
35
+ defaultEnv: z.ZodOptional<z.ZodString>;
36
+ dotenvToken: z.ZodOptional<z.ZodString>;
37
+ dynamicPath: z.ZodOptional<z.ZodString>;
38
+ dynamic: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
39
+ env: z.ZodOptional<z.ZodString>;
40
+ excludeDynamic: z.ZodOptional<z.ZodBoolean>;
41
+ excludeEnv: z.ZodOptional<z.ZodBoolean>;
42
+ excludeGlobal: z.ZodOptional<z.ZodBoolean>;
43
+ excludePrivate: z.ZodOptional<z.ZodBoolean>;
44
+ excludePublic: z.ZodOptional<z.ZodBoolean>;
45
+ loadProcess: z.ZodOptional<z.ZodBoolean>;
46
+ log: z.ZodOptional<z.ZodBoolean>;
47
+ logger: z.ZodDefault<z.ZodUnknown>;
48
+ outputPath: z.ZodOptional<z.ZodString>;
49
+ privateToken: z.ZodOptional<z.ZodString>;
50
+ debug: z.ZodOptional<z.ZodBoolean>;
51
+ strict: z.ZodOptional<z.ZodBoolean>;
52
+ capture: z.ZodOptional<z.ZodBoolean>;
53
+ trace: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodArray<z.ZodString>]>>;
54
+ redact: z.ZodOptional<z.ZodBoolean>;
55
+ warnEntropy: z.ZodOptional<z.ZodBoolean>;
56
+ entropyThreshold: z.ZodOptional<z.ZodNumber>;
57
+ entropyMinLength: z.ZodOptional<z.ZodNumber>;
58
+ entropyWhitelist: z.ZodOptional<z.ZodArray<z.ZodString>>;
59
+ redactPatterns: z.ZodOptional<z.ZodArray<z.ZodString>>;
60
+ paths: z.ZodOptional<z.ZodString>;
61
+ pathsDelimiter: z.ZodOptional<z.ZodString>;
62
+ pathsDelimiterPattern: z.ZodOptional<z.ZodString>;
63
+ scripts: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
64
+ shell: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodString]>>;
65
+ vars: z.ZodOptional<z.ZodString>;
66
+ varsAssignor: z.ZodOptional<z.ZodString>;
67
+ varsAssignorPattern: z.ZodOptional<z.ZodString>;
68
+ varsDelimiter: z.ZodOptional<z.ZodString>;
69
+ varsDelimiterPattern: z.ZodOptional<z.ZodString>;
70
+ }, z.core.$strip>;
71
+
72
+ /**
73
+ * Resolved programmatic options schema (post-inheritance).
74
+ * For now, this mirrors the RAW schema; future stages may materialize defaults
75
+ * and narrow shapes as resolution is wired into the host.
76
+ */
77
+ declare const getDotenvOptionsSchemaResolved: z.ZodObject<{
78
+ defaultEnv: z.ZodOptional<z.ZodString>;
79
+ dotenvToken: z.ZodOptional<z.ZodString>;
80
+ dynamicPath: z.ZodOptional<z.ZodString>;
81
+ dynamic: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
82
+ env: z.ZodOptional<z.ZodString>;
83
+ excludeDynamic: z.ZodOptional<z.ZodBoolean>;
84
+ excludeEnv: z.ZodOptional<z.ZodBoolean>;
85
+ excludeGlobal: z.ZodOptional<z.ZodBoolean>;
86
+ excludePrivate: z.ZodOptional<z.ZodBoolean>;
87
+ excludePublic: z.ZodOptional<z.ZodBoolean>;
88
+ loadProcess: z.ZodOptional<z.ZodBoolean>;
89
+ log: z.ZodOptional<z.ZodBoolean>;
90
+ logger: z.ZodDefault<z.ZodUnknown>;
91
+ outputPath: z.ZodOptional<z.ZodString>;
92
+ paths: z.ZodOptional<z.ZodArray<z.ZodString>>;
93
+ privateToken: z.ZodOptional<z.ZodString>;
94
+ vars: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodOptional<z.ZodString>>>;
95
+ }, z.core.$strip>;
96
+
97
+ /**
98
+ * Canonical programmatic options and helpers for get-dotenv.
99
+ *
100
+ * Requirements addressed:
101
+ * - GetDotenvOptions derives from the Zod schema output (single source of truth).
102
+ * - Removed deprecated/compat flags from the public shape (e.g., useConfigLoader).
103
+ * - Provide Vars-aware defineDynamic and a typed config builder defineGetDotenvConfig\<Vars, Env\>().
104
+ * - Preserve existing behavior for defaults resolution and compat converters.
105
+ */
3
106
 
4
107
  /**
5
108
  * A minimal representation of an environment key/value mapping.
6
- * Values may be `undefined` to represent "unset". */ type ProcessEnv = Record<string, string | undefined>;
109
+ * Values may be `undefined` to represent "unset".
110
+ */
111
+ type ProcessEnv = Record<string, string | undefined>;
7
112
  /**
8
113
  * Dynamic variable function signature. Receives the current expanded variables
9
114
  * and the selected environment (if any), and returns either a string to set
10
115
  * or `undefined` to unset/skip the variable.
11
116
  */
12
117
  type GetDotenvDynamicFunction = (vars: ProcessEnv, env: string | undefined) => string | undefined;
118
+ /**
119
+ * A map of dynamic variable definitions.
120
+ * Keys are variable names; values are either literal strings or functions.
121
+ */
13
122
  type GetDotenvDynamic = Record<string, GetDotenvDynamicFunction | ReturnType<GetDotenvDynamicFunction>>;
123
+ /**
124
+ * Logger interface compatible with `console` or a subset thereof.
125
+ */
14
126
  type Logger = Record<string, (...args: unknown[]) => void> | typeof console;
15
127
  /**
16
- * Options passed programmatically to `getDotenv`.
128
+ * Canonical programmatic options type (schema-derived).
129
+ * This type is the single source of truth for programmatic options.
17
130
  */
18
- interface GetDotenvOptions {
19
- /**
20
- * default target environment (used if `env` is not provided)
21
- */
22
- defaultEnv?: string;
23
- /**
24
- * token indicating a dotenv file
25
- */
26
- dotenvToken: string;
131
+ type GetDotenvOptions = z.output<typeof getDotenvOptionsSchemaResolved> & {
27
132
  /**
28
- * path to JS/TS module default-exporting an object keyed to dynamic variable functions
133
+ * Compile-time overlay: narrowed logger for DX (schema stores unknown).
29
134
  */
30
- dynamicPath?: string;
135
+ logger: Logger;
31
136
  /**
32
- * Programmatic dynamic variables map. When provided, this takes precedence
33
- * over {@link GetDotenvOptions.dynamicPath}.
137
+ * Compile-time overlay: narrowed dynamic map for DX (schema stores unknown).
34
138
  */
35
139
  dynamic?: GetDotenvDynamic;
140
+ };
141
+
142
+ /**
143
+ * Unify Scripts via the generic ScriptsTable<TShell> so shell types propagate.
144
+ */
145
+ type Scripts = ScriptsTable;
146
+ /**
147
+ * Canonical CLI options type derived from the Zod schema output.
148
+ * Includes CLI-only flags (debug/strict/capture/trace/redaction/entropy),
149
+ * stringly paths/vars, and inherited programmatic fields (minus normalized
150
+ * shapes that are handled by resolution).
151
+ */
152
+ type GetDotenvCliOptions = z.output<typeof getDotenvCliOptionsSchemaResolved> & {
36
153
  /**
37
- * target environment
38
- */
39
- env?: string;
40
- /**
41
- * exclude dynamic variables from loading
42
- */
43
- excludeDynamic?: boolean;
44
- /**
45
- * exclude environment-specific variables from loading
46
- */
47
- excludeEnv?: boolean;
48
- /**
49
- * exclude global variables from loading
50
- */
51
- excludeGlobal?: boolean;
52
- /**
53
- * exclude private variables from loading
54
- */
55
- excludePrivate?: boolean;
56
- /**
57
- * exclude public variables from loading
58
- */
59
- excludePublic?: boolean;
60
- /**
61
- * load dotenv variables to `process.env`
62
- */
63
- loadProcess?: boolean;
64
- /**
65
- * log loaded dotenv variables to `logger`
66
- */
67
- log?: boolean;
68
- /**
69
- * logger object (defaults to console)
154
+ * Compile-only overlay for DX: logger narrowed from unknown.
70
155
  */
71
- logger?: Logger;
156
+ logger: Logger;
72
157
  /**
73
- * if populated, writes consolidated dotenv file to this path (follows dotenvExpand rules)
158
+ * Compile-only overlay for DX: scripts narrowed from Record\<string, unknown\>.
74
159
  */
75
- outputPath?: string;
160
+ scripts?: Scripts;
161
+ };
162
+
163
+ /**
164
+ * Configuration context used for generating dynamic help descriptions.
165
+ * Contains merged CLI options and plugin configuration slices.
166
+ *
167
+ * @public
168
+ */
169
+ type ResolvedHelpConfig = Partial<GetDotenvCliOptions> & {
76
170
  /**
77
- * array of input directory paths
171
+ * Per‑plugin configuration slices keyed by realized mount path
172
+ * (e.g., `"aws"` or `"aws/whoami"`), used for dynamic help text.
78
173
  */
79
- paths?: string[];
174
+ plugins: Record<string, unknown>;
175
+ };
176
+
177
+ /** src/cliHost/definePlugin/contracts.ts
178
+ * Public contracts for plugin authoring (types only).
179
+ * - No runtime logic or state.
180
+ * - Safe to import broadly without introducing cycles.
181
+ */
182
+
183
+ /**
184
+ * Options for resolving and loading the configuration.
185
+ *
186
+ * @public
187
+ */
188
+ interface ResolveAndLoadOptions {
80
189
  /**
81
- * filename token indicating private variables
190
+ * When false, skips running plugin afterResolve hooks.
191
+ * Useful for top-level help rendering to avoid long-running side-effects
192
+ * while still evaluating dynamic help text.
193
+ *
194
+ * @default true
82
195
  */
83
- privateToken?: string;
196
+ runAfterResolve?: boolean;
197
+ }
198
+ /**
199
+ * Structural public interface for the host exposed to plugins.
200
+ * - Extends Commander.Command so plugins can attach options/commands/hooks.
201
+ * - Adds host-specific helpers used by built-in plugins.
202
+ *
203
+ * Purpose: remove nominal class identity (private fields) from the plugin seam
204
+ * to avoid TS2379 under exactOptionalPropertyTypes in downstream consumers.
205
+ */
206
+ interface GetDotenvCliPublic<TOptions extends GetDotenvOptions = GetDotenvOptions, TArgs extends unknown[] = [], TOpts extends OptionValues = {}, TGlobal extends OptionValues = {}> extends Command<TArgs, TOpts, TGlobal> {
84
207
  /**
85
- * explicit variables to include
208
+ * Create a namespaced child command with argument inference.
209
+ * Mirrors Commander generics so downstream chaining remains fully typed.
86
210
  */
87
- vars?: ProcessEnv;
211
+ ns<Usage extends string>(name: Usage): GetDotenvCliPublic<TOptions, [
212
+ ...TArgs,
213
+ ...InferCommandArguments<Usage>
214
+ ], {}, TOpts & TGlobal>;
215
+ /** Return the current context; throws if not yet resolved. */
216
+ getCtx(): GetDotenvCliCtx<TOptions>;
217
+ /** Check whether a context has been resolved (non-throwing). */
218
+ hasCtx(): boolean;
219
+ resolveAndLoad(customOptions?: Partial<TOptions>, opts?: ResolveAndLoadOptions): Promise<GetDotenvCliCtx<TOptions>>;
220
+ setOptionGroup(opt: Option, group: string): void;
88
221
  /**
89
- * Reserved: config loader flag (no-op).
90
- * The plugin-first host and generator paths already use the config
91
- * loader/overlay pipeline unconditionally (no-op when no config files
92
- * are present). This flag is accepted for forward compatibility but
93
- * currently has no effect.
222
+ * Create a dynamic option whose description is computed at help time
223
+ * from the resolved configuration.
94
224
  */
95
- useConfigLoader?: boolean;
225
+ createDynamicOption<Usage extends string>(flags: Usage, desc: (cfg: ResolvedHelpConfig) => string, parser?: (value: string, previous?: unknown) => unknown, defaultValue?: unknown): Option<Usage>;
226
+ createDynamicOption<Usage extends string, TValue = unknown>(flags: Usage, desc: (cfg: ResolvedHelpConfig) => string, parser: (value: string, previous?: TValue) => TValue, defaultValue?: TValue): Option<Usage>;
96
227
  }
97
-
98
- /** src/cliHost/definePlugin.ts
99
- * Plugin contracts for the GetDotenv CLI host.
228
+ /**
229
+ * Optional overrides for plugin composition.
100
230
  *
101
- * This module exposes a structural public interface for the host that plugins
102
- * should use (GetDotenvCliPublic). Using a structural type at the seam avoids
103
- * nominal class identity issues (private fields) in downstream consumers.
231
+ * @public
104
232
  */
105
-
233
+ interface PluginNamespaceOverride {
234
+ /**
235
+ * Override the default namespace for this plugin instance.
236
+ */
237
+ ns?: string;
238
+ }
106
239
  /**
107
- * Structural public interface for the host exposed to plugins.
108
- * - Extends Commander.Command so plugins can attach options/commands/hooks.
109
- * - Adds host-specific helpers used by built-in plugins.
240
+ * An entry in the plugin children array.
110
241
  *
111
- * Purpose: remove nominal class identity (private fields) from the plugin seam
112
- * to avoid TS2379 under exactOptionalPropertyTypes in downstream consumers.
242
+ * @public
113
243
  */
114
- type GetDotenvCliPublic<TOptions extends GetDotenvOptions = GetDotenvOptions> = Command & {
115
- ns: (name: string) => Command;
116
- getCtx: () => GetDotenvCliCtx<TOptions> | undefined;
117
- resolveAndLoad: (customOptions?: Partial<TOptions>) => Promise<GetDotenvCliCtx<TOptions>>;
118
- };
244
+ interface PluginChildEntry<TOptions extends GetDotenvOptions = GetDotenvOptions, TArgs extends unknown[] = [], TOpts extends OptionValues = {}, TGlobal extends OptionValues = {}> {
245
+ /** The child plugin instance to mount under this parent. */
246
+ plugin: GetDotenvCliPlugin<TOptions, TArgs, TOpts, TGlobal>;
247
+ /**
248
+ * Optional namespace override for the child when mounted under the parent.
249
+ * When provided, this name is used instead of the child's default `ns`.
250
+ */
251
+ override: PluginNamespaceOverride | undefined;
252
+ }
119
253
  /** Public plugin contract used by the GetDotenv CLI host. */
120
- interface GetDotenvCliPlugin {
121
- id?: string;
254
+ interface GetDotenvCliPlugin<TOptions extends GetDotenvOptions = GetDotenvOptions, TArgs extends unknown[] = [], TOpts extends OptionValues = {}, TGlobal extends OptionValues = {}> {
255
+ /** Namespace (required): the command name where this plugin is mounted. */
256
+ ns: string;
122
257
  /**
123
- * Setup phase: register commands and wiring on the provided CLI instance.
124
- * Runs parent → children (pre-order).
258
+ * Setup phase: register commands and wiring on the provided mount.
259
+ * Runs parent → children (pre-order). Return nothing (void).
125
260
  */
126
- setup: (cli: GetDotenvCliPublic) => void | Promise<void>;
261
+ setup: (cli: GetDotenvCliPublic<TOptions, TArgs, TOpts, TGlobal>) => void | Promise<void>;
127
262
  /**
128
263
  * After the dotenv context is resolved, initialize any clients/secrets
129
264
  * or attach per-plugin state under ctx.plugins (by convention).
130
265
  * Runs parent → children (pre-order).
131
266
  */
132
- afterResolve?: (cli: GetDotenvCliPublic, ctx: GetDotenvCliCtx) => void | Promise<void>;
267
+ afterResolve?: (cli: GetDotenvCliPublic<TOptions, TArgs, TOpts, TGlobal>, ctx: GetDotenvCliCtx<TOptions>) => void | Promise<void>;
268
+ /** Zod schema for this plugin's config slice (from config.plugins[…]). */
269
+ configSchema?: ZodObject;
133
270
  /**
134
- * Optional Zod schema for this plugin's config slice (from config.plugins[id]).
135
- * When provided, the host validates the merged config under the guarded loader path.
271
+ * Compositional children, with optional per-child overrides (e.g., ns).
272
+ * Installed after the parent per pre-order.
136
273
  */
137
- configSchema?: ZodType;
274
+ children: Array<PluginChildEntry<TOptions, TArgs, TOpts, TGlobal>>;
138
275
  /**
139
- * Compositional children. Installed after the parent per pre-order.
276
+ * Compose a child plugin with optional override (ns). Returns the parent
277
+ * to enable chaining.
140
278
  */
141
- children: GetDotenvCliPlugin[];
142
- /**
143
- * Compose a child plugin. Returns the parent to enable chaining.
144
- */
145
- use: (child: GetDotenvCliPlugin) => GetDotenvCliPlugin;
279
+ use: (child: GetDotenvCliPlugin<TOptions, TArgs, TOpts, TGlobal>, override?: PluginNamespaceOverride) => GetDotenvCliPlugin<TOptions, TArgs, TOpts, TGlobal>;
280
+ }
281
+ /**
282
+ * Compile-time helper type: the plugin object returned by definePlugin always
283
+ * includes the instance-bound helpers as required members. Keeping the public
284
+ * interface optional preserves compatibility for ad-hoc/test plugins, while
285
+ * return types from definePlugin provide stronger DX for shipped/typed plugins.
286
+ */
287
+ interface PluginWithInstanceHelpers<TOptions extends GetDotenvOptions = GetDotenvOptions, TConfig = unknown, TArgs extends unknown[] = [], TOpts extends OptionValues = {}, TGlobal extends OptionValues = {}> extends GetDotenvCliPlugin<TOptions, TArgs, TOpts, TGlobal> {
288
+ readConfig<TCfg = TConfig>(cli: GetDotenvCliPublic<TOptions, unknown[], OptionValues, OptionValues>): Readonly<TCfg>;
289
+ 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>;
146
290
  }
147
291
 
148
- /** * Per-invocation context shared with plugins and actions. */
149
- type GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> = {
150
- optionsResolved: TOptions;
151
- dotenv: ProcessEnv;
152
- plugins?: Record<string, unknown>;
153
- pluginConfigs?: Record<string, unknown>;
154
- };
155
-
156
- declare const awsPlugin: () => GetDotenvCliPlugin;
292
+ /**
293
+ * AWS plugin: establishes an AWS session (credentials/region) based on dotenv configuration.
294
+ * Supports SSO login-on-demand and credential exporting.
295
+ * Can be used as a parent command to wrap `aws` CLI invocations.
296
+ */
297
+ declare const awsPlugin: () => PluginWithInstanceHelpers<GetDotenvOptions, {
298
+ profile?: string | undefined;
299
+ region?: string | undefined;
300
+ defaultRegion?: string | undefined;
301
+ profileKey?: string | undefined;
302
+ profileFallbackKey?: string | undefined;
303
+ regionKey?: string | undefined;
304
+ strategy?: "cli-export" | "none" | undefined;
305
+ loginOnDemand?: boolean | undefined;
306
+ }, [], {}, {}>;
157
307
 
158
308
  /**
159
- * Batch services (neutral): resolve command and shell settings.
160
- * Shared by the generator path and the batch plugin to avoid circular deps.
309
+ * AWS Whoami plugin: prints the current AWS caller identity (account, arn, userid).
310
+ * Intended to be mounted under the `aws` plugin.
161
311
  */
162
- type Scripts = Record<string, string | {
163
- cmd: string;
164
- shell?: string | boolean | undefined;
165
- }>;
312
+ declare const awsWhoamiPlugin: () => PluginWithInstanceHelpers<GetDotenvOptions, {}, [], {}, {}>;
166
313
 
167
- type BatchPluginOptions = {
168
- scripts?: Scripts;
314
+ /**
315
+ * Options provided to the batch plugin factory.
316
+ *
317
+ * @public
318
+ */
319
+ interface BatchPluginOptions {
320
+ /**
321
+ * Scripts table used to resolve command names and optional per-script shell overrides.
322
+ */
323
+ scripts?: ScriptsTable;
324
+ /**
325
+ * Global shell preference for batch execution; overridden by per-script shell when present.
326
+ */
169
327
  shell?: string | boolean;
170
- logger?: Logger;
171
- };
328
+ }
172
329
 
173
330
  /**
174
331
  * Batch plugin for the GetDotenv CLI host.
@@ -176,36 +333,62 @@ type BatchPluginOptions = {
176
333
  * Mirrors the legacy batch subcommand behavior without altering the shipped CLI.
177
334
  * Options:
178
335
  * - scripts/shell: used to resolve command and shell behavior per script or global default.
179
- * - logger: defaults to console.
180
336
  */
181
- declare const batchPlugin: (opts?: BatchPluginOptions) => GetDotenvCliPlugin;
337
+ declare const batchPlugin: (opts?: BatchPluginOptions) => PluginWithInstanceHelpers<GetDotenvOptions, {
338
+ scripts?: Record<string, string | {
339
+ cmd: string;
340
+ shell?: string | boolean | undefined;
341
+ }> | undefined;
342
+ shell?: string | boolean | undefined;
343
+ rootPath?: string | undefined;
344
+ globs?: string | undefined;
345
+ pkgCwd?: boolean | undefined;
346
+ }, [], {}, {}>;
182
347
 
183
- type CmdPluginOptions = {
348
+ /**
349
+ * Configuration for the parent-level command alias.
350
+ *
351
+ * @public
352
+ */
353
+ interface CmdOptionAlias {
354
+ /** Option flags (e.g. "-c, --cmd \<command...\>"). */
355
+ flags: string;
356
+ /** Option description. */
357
+ description?: string;
358
+ /** Whether to expand the alias value before execution. */
359
+ expand?: boolean;
360
+ }
361
+ /**
362
+ * Options provided to the cmd plugin factory.
363
+ *
364
+ * @public
365
+ */
366
+ interface CmdPluginOptions {
184
367
  /**
185
- * When true, register as the default subcommand at the root. */
368
+ * When true, register as the default subcommand at the root.
369
+ */
186
370
  asDefault?: boolean;
187
371
  /**
188
- * Optional alias option attached to the parent command to invoke the cmd * behavior without specifying the subcommand explicitly.
372
+ * Optional alias option attached to the parent command to invoke the cmd
373
+ * behavior without specifying the subcommand explicitly.
189
374
  */
190
- optionAlias?: string | {
191
- flags: string;
192
- description?: string;
193
- expand?: boolean;
194
- };
195
- };
196
- /**+ Cmd plugin: executes a command using the current getdotenv CLI context.
197
- *
198
- * - Joins positional args into a single command string.
199
- * - Resolves scripts and shell settings using shared helpers.
200
- * - Forwards merged CLI options to subprocesses via
201
- * process.env.getDotenvCliOptions for nested CLI behavior. */
202
- declare const cmdPlugin: (options?: CmdPluginOptions) => GetDotenvCliPlugin;
375
+ optionAlias?: string | CmdOptionAlias;
376
+ }
203
377
 
204
- declare const demoPlugin: () => GetDotenvCliPlugin;
378
+ /**
379
+ * Cmd plugin: executes a command using the current getdotenv CLI context.
380
+ * Registers the `cmd` subcommand and optionally attaches a parent-level alias (e.g. `-c`).
381
+ *
382
+ * @param options - Plugin configuration options.
383
+ */
384
+ declare const cmdPlugin: (options?: CmdPluginOptions) => PluginWithInstanceHelpers<GetDotenvOptions, {
385
+ expand?: boolean | undefined;
386
+ }, [], {}, {}>;
205
387
 
206
- type InitPluginOptions = {
207
- logger?: Logger;
208
- };
209
- declare const initPlugin: (opts?: InitPluginOptions) => GetDotenvCliPlugin;
388
+ /**
389
+ * Init plugin: scaffolds configuration files and a CLI skeleton for get-dotenv.
390
+ * Supports collision detection, interactive prompts, and CI bypass.
391
+ */
392
+ declare const initPlugin: () => PluginWithInstanceHelpers<GetDotenvOptions, {}, [], {}, {}>;
210
393
 
211
- export { awsPlugin, batchPlugin, cmdPlugin, demoPlugin, initPlugin };
394
+ export { awsPlugin, awsWhoamiPlugin, batchPlugin, cmdPlugin, initPlugin };