@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
@@ -1,162 +1,334 @@
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;
131
+ type GetDotenvOptions = z.output<typeof getDotenvOptionsSchemaResolved> & {
23
132
  /**
24
- * token indicating a dotenv file
133
+ * Compile-time overlay: narrowed logger for DX (schema stores unknown).
25
134
  */
26
- dotenvToken: string;
135
+ logger: Logger;
27
136
  /**
28
- * path to JS/TS module default-exporting an object keyed to dynamic variable functions
29
- */
30
- dynamicPath?: string;
31
- /**
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
154
+ * Compile-only overlay for DX: logger narrowed from unknown.
46
155
  */
47
- excludeEnv?: boolean;
156
+ logger: Logger;
48
157
  /**
49
- * exclude global variables from loading
158
+ * Compile-only overlay for DX: scripts narrowed from Record\<string, unknown\>.
50
159
  */
51
- excludeGlobal?: boolean;
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> & {
52
170
  /**
53
- * exclude private variables from loading
171
+ * Per‑plugin configuration slices keyed by realized mount path
172
+ * (e.g., `"aws"` or `"aws/whoami"`), used for dynamic help text.
54
173
  */
55
- excludePrivate?: boolean;
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 {
56
189
  /**
57
- * exclude public variables from loading
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
58
195
  */
59
- excludePublic?: boolean;
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> {
60
207
  /**
61
- * load dotenv variables to `process.env`
208
+ * Create a namespaced child command with argument inference.
209
+ * Mirrors Commander generics so downstream chaining remains fully typed.
62
210
  */
63
- loadProcess?: boolean;
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;
64
221
  /**
65
- * log loaded dotenv variables to `logger`
222
+ * Create a dynamic option whose description is computed at help time
223
+ * from the resolved configuration.
66
224
  */
67
- log?: 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>;
227
+ }
228
+ /**
229
+ * Optional overrides for plugin composition.
230
+ *
231
+ * @public
232
+ */
233
+ interface PluginNamespaceOverride {
68
234
  /**
69
- * logger object (defaults to console)
235
+ * Override the default namespace for this plugin instance.
70
236
  */
71
- logger?: Logger;
237
+ ns?: string;
238
+ }
239
+ /**
240
+ * An entry in the plugin children array.
241
+ *
242
+ * @public
243
+ */
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>;
72
247
  /**
73
- * if populated, writes consolidated dotenv file to this path (follows dotenvExpand rules)
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`.
74
250
  */
75
- outputPath?: string;
251
+ override: PluginNamespaceOverride | undefined;
252
+ }
253
+ /** Public plugin contract used by the GetDotenv CLI host. */
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;
76
257
  /**
77
- * array of input directory paths
258
+ * Setup phase: register commands and wiring on the provided mount.
259
+ * Runs parent → children (pre-order). Return nothing (void).
78
260
  */
79
- paths?: string[];
261
+ setup: (cli: GetDotenvCliPublic<TOptions, TArgs, TOpts, TGlobal>) => void | Promise<void>;
80
262
  /**
81
- * filename token indicating private variables
263
+ * After the dotenv context is resolved, initialize any clients/secrets
264
+ * or attach per-plugin state under ctx.plugins (by convention).
265
+ * Runs parent → children (pre-order).
82
266
  */
83
- privateToken?: string;
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;
84
270
  /**
85
- * explicit variables to include
271
+ * Compositional children, with optional per-child overrides (e.g., ns).
272
+ * Installed after the parent per pre-order.
86
273
  */
87
- vars?: ProcessEnv;
274
+ children: Array<PluginChildEntry<TOptions, TArgs, TOpts, TGlobal>>;
88
275
  /**
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.
276
+ * Compose a child plugin with optional override (ns). Returns the parent
277
+ * to enable chaining.
94
278
  */
95
- useConfigLoader?: boolean;
279
+ use: (child: GetDotenvCliPlugin<TOptions, TArgs, TOpts, TGlobal>, override?: PluginNamespaceOverride) => GetDotenvCliPlugin<TOptions, TArgs, TOpts, TGlobal>;
96
280
  }
97
-
98
- /** src/cliHost/definePlugin.ts
99
- * Plugin contracts for the GetDotenv CLI host.
100
- *
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.
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.
104
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>;
290
+ }
105
291
 
106
292
  /**
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.
293
+ * Options for planning config template copies.
110
294
  *
111
- * Purpose: remove nominal class identity (private fields) from the plugin seam
112
- * to avoid TS2379 under exactOptionalPropertyTypes in downstream consumers.
295
+ * @public
113
296
  */
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
- };
119
- /** Public plugin contract used by the GetDotenv CLI host. */
120
- interface GetDotenvCliPlugin {
121
- id?: string;
297
+ interface PlanConfigCopiesOptions {
122
298
  /**
123
- * Setup phase: register commands and wiring on the provided CLI instance.
124
- * Runs parent → children (pre-order).
299
+ * Desired config format to scaffold.
125
300
  */
126
- setup: (cli: GetDotenvCliPublic) => void | Promise<void>;
301
+ format: 'json' | 'yaml' | 'js' | 'ts';
127
302
  /**
128
- * After the dotenv context is resolved, initialize any clients/secrets
129
- * or attach per-plugin state under ctx.plugins (by convention).
130
- * Runs parent → children (pre-order).
303
+ * Whether to include a private .local variant (JSON/YAML only).
131
304
  */
132
- afterResolve?: (cli: GetDotenvCliPublic, ctx: GetDotenvCliCtx) => void | Promise<void>;
305
+ withLocal: boolean;
133
306
  /**
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.
307
+ * Absolute destination project root.
136
308
  */
137
- configSchema?: ZodType;
309
+ destRoot: string;
310
+ }
311
+ /**
312
+ * Options for planning CLI skeleton template copies.
313
+ *
314
+ * @public
315
+ */
316
+ interface PlanCliCopiesOptions {
138
317
  /**
139
- * Compositional children. Installed after the parent per pre-order.
318
+ * CLI command name to substitute into templates.
140
319
  */
141
- children: GetDotenvCliPlugin[];
320
+ cliName: string;
142
321
  /**
143
- * Compose a child plugin. Returns the parent to enable chaining.
322
+ * Absolute destination project root.
144
323
  */
145
- use: (child: GetDotenvCliPlugin) => GetDotenvCliPlugin;
324
+ destRoot: string;
146
325
  }
147
326
 
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
- type InitPluginOptions = {
157
- logger?: Logger;
158
- };
159
- declare const initPlugin: (opts?: InitPluginOptions) => GetDotenvCliPlugin;
327
+ /**
328
+ * Init plugin: scaffolds configuration files and a CLI skeleton for get-dotenv.
329
+ * Supports collision detection, interactive prompts, and CI bypass.
330
+ */
331
+ declare const initPlugin: () => PluginWithInstanceHelpers<GetDotenvOptions, {}, [], {}, {}>;
160
332
 
161
333
  export { initPlugin };
162
- export type { InitPluginOptions };
334
+ export type { PlanCliCopiesOptions, PlanConfigCopiesOptions };