@karmaniverous/get-dotenv 5.2.5 → 6.0.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 (41) hide show
  1. package/README.md +63 -67
  2. package/dist/cliHost.cjs +765 -549
  3. package/dist/cliHost.d.cts +128 -84
  4. package/dist/cliHost.d.mts +128 -84
  5. package/dist/cliHost.d.ts +128 -84
  6. package/dist/cliHost.mjs +765 -549
  7. package/dist/getdotenv.cli.mjs +915 -685
  8. package/dist/index.cjs +959 -1006
  9. package/dist/index.d.cts +18 -178
  10. package/dist/index.d.mts +18 -178
  11. package/dist/index.d.ts +18 -178
  12. package/dist/index.mjs +960 -1006
  13. package/dist/plugins-aws.cjs +0 -1
  14. package/dist/plugins-aws.d.cts +8 -78
  15. package/dist/plugins-aws.d.mts +8 -78
  16. package/dist/plugins-aws.d.ts +8 -78
  17. package/dist/plugins-aws.mjs +0 -1
  18. package/dist/plugins-batch.cjs +53 -11
  19. package/dist/plugins-batch.d.cts +10 -79
  20. package/dist/plugins-batch.d.mts +10 -79
  21. package/dist/plugins-batch.d.ts +10 -79
  22. package/dist/plugins-batch.mjs +53 -11
  23. package/dist/plugins-cmd.cjs +162 -1555
  24. package/dist/plugins-cmd.d.cts +8 -78
  25. package/dist/plugins-cmd.d.mts +8 -78
  26. package/dist/plugins-cmd.d.ts +8 -78
  27. package/dist/plugins-cmd.mjs +162 -1554
  28. package/dist/plugins-demo.cjs +52 -7
  29. package/dist/plugins-demo.d.cts +8 -78
  30. package/dist/plugins-demo.d.mts +8 -78
  31. package/dist/plugins-demo.d.ts +8 -78
  32. package/dist/plugins-demo.mjs +52 -7
  33. package/dist/plugins-init.d.cts +8 -78
  34. package/dist/plugins-init.d.mts +8 -78
  35. package/dist/plugins-init.d.ts +8 -78
  36. package/dist/plugins.cjs +283 -1630
  37. package/dist/plugins.d.cts +10 -79
  38. package/dist/plugins.d.mts +10 -79
  39. package/dist/plugins.d.ts +10 -79
  40. package/dist/plugins.mjs +285 -1631
  41. package/package.json +4 -2
package/dist/cliHost.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Command } from 'commander';
1
+ import { Command, Option } from 'commander';
2
2
  import { ZodType } from 'zod';
3
3
 
4
4
  /**
@@ -50,27 +50,6 @@ type ScriptsTable<TShell extends string | boolean = string | boolean> = Record<s
50
50
  shell?: TShell;
51
51
  }>;
52
52
 
53
- /**
54
- * Adapter-layer augmentation: add chainable helpers to GetDotenvCli without
55
- * coupling the core host to cliCore. Importing this module has side effects:
56
- * it extends the prototype and merges types for consumers.
57
- */
58
- declare module '../cliHost/GetDotenvCli' {
59
- interface GetDotenvCli {
60
- /**
61
- * Attach legacy root flags to this CLI instance. Defaults come from
62
- * baseRootOptionDefaults when none are provided. */
63
- attachRootOptions(defaults?: Partial<RootOptionsShape>, opts?: {
64
- includeCommandOption?: boolean;
65
- }): this;
66
- /**
67
- * Install a preSubcommand hook that merges CLI flags (including parent
68
- * round-trip) and resolves the dotenv context before executing actions.
69
- * Defaults come from baseRootOptionDefaults when none are provided.
70
- */ passOptions(defaults?: Partial<RootOptionsShape>): this;
71
- }
72
- }
73
-
74
53
  /**
75
54
  * A minimal representation of an environment key/value mapping.
76
55
  * Values may be `undefined` to represent "unset". */ type ProcessEnv = Record<string, string | undefined>;
@@ -252,6 +231,75 @@ interface GetDotenvCliOptions extends Omit<GetDotenvOptions, 'paths' | 'vars'> {
252
231
  varsDelimiterPattern?: string;
253
232
  }
254
233
 
234
+ /** src/cliHost/definePlugin.ts
235
+ * Plugin contracts for the GetDotenv CLI host.
236
+ *
237
+ * This module exposes a structural public interface for the host that plugins
238
+ * should use (GetDotenvCliPublic). Using a structural type at the seam avoids
239
+ * nominal class identity issues (private fields) in downstream consumers.
240
+ */
241
+
242
+ /**
243
+ * Structural public interface for the host exposed to plugins.
244
+ * - Extends Commander.Command so plugins can attach options/commands/hooks.
245
+ * - Adds host-specific helpers used by built-in plugins.
246
+ *
247
+ * Purpose: remove nominal class identity (private fields) from the plugin seam
248
+ * to avoid TS2379 under exactOptionalPropertyTypes in downstream consumers.
249
+ */
250
+ type GetDotenvCliPublic<TOptions extends GetDotenvOptions = GetDotenvOptions> = Command & {
251
+ ns: (name: string) => Command;
252
+ getCtx: () => GetDotenvCliCtx<TOptions> | undefined;
253
+ resolveAndLoad: (customOptions?: Partial<TOptions>) => Promise<GetDotenvCliCtx<TOptions>>;
254
+ };
255
+ /** Public plugin contract used by the GetDotenv CLI host. */
256
+ interface GetDotenvCliPlugin {
257
+ id?: string;
258
+ /**
259
+ * Setup phase: register commands and wiring on the provided CLI instance.
260
+ * Runs parent → children (pre-order).
261
+ */
262
+ setup: (cli: GetDotenvCliPublic) => void | Promise<void>;
263
+ /**
264
+ * After the dotenv context is resolved, initialize any clients/secrets
265
+ * or attach per-plugin state under ctx.plugins (by convention).
266
+ * Runs parent → children (pre-order).
267
+ */
268
+ afterResolve?: (cli: GetDotenvCliPublic, ctx: GetDotenvCliCtx) => void | Promise<void>;
269
+ /**
270
+ * Optional Zod schema for this plugin's config slice (from config.plugins[id]).
271
+ * When provided, the host validates the merged config under the guarded loader path.
272
+ */
273
+ configSchema?: ZodType;
274
+ /**
275
+ * Compositional children. Installed after the parent per pre-order.
276
+ */
277
+ children: GetDotenvCliPlugin[];
278
+ /**
279
+ * Compose a child plugin. Returns the parent to enable chaining.
280
+ */
281
+ use: (child: GetDotenvCliPlugin) => GetDotenvCliPlugin;
282
+ }
283
+ /**
284
+ * Public spec type for defining a plugin with optional children.
285
+ * Exported to ensure TypeDoc links and navigation resolve correctly.
286
+ */
287
+ type DefineSpec = Omit<GetDotenvCliPlugin, 'children' | 'use'> & {
288
+ children?: GetDotenvCliPlugin[];
289
+ };
290
+ /**
291
+ * Define a GetDotenv CLI plugin with compositional helpers.
292
+ *
293
+ * @example
294
+ * const parent = definePlugin(\{ id: 'p', setup(cli) \{ /* ... *\/ \} \})
295
+ * .use(childA)
296
+ * .use(childB);
297
+ */
298
+ declare const definePlugin: (spec: DefineSpec) => GetDotenvCliPlugin;
299
+
300
+ type ResolvedHelpConfig = Partial<GetDotenvOptions> & {
301
+ plugins: Record<string, unknown>;
302
+ };
255
303
  /** * Per-invocation context shared with plugins and actions. */
256
304
  type GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> = {
257
305
  optionsResolved: TOptions;
@@ -271,7 +319,7 @@ declare const HELP_HEADER_SYMBOL: unique symbol;
271
319
  *
272
320
  * NOTE: This host is additive and does not alter the legacy CLI.
273
321
  */
274
- declare class GetDotenvCli<TOptions extends GetDotenvOptions = GetDotenvOptions> extends Command {
322
+ declare class GetDotenvCli$1<TOptions extends GetDotenvOptions = GetDotenvOptions> extends Command {
275
323
  #private;
276
324
  /** Registered top-level plugins (composition happens via .use()) */
277
325
  private _plugins;
@@ -279,11 +327,45 @@ declare class GetDotenvCli<TOptions extends GetDotenvOptions = GetDotenvOptions>
279
327
  private _installed;
280
328
  /** Optional header line to prepend in help output */
281
329
  private [HELP_HEADER_SYMBOL];
330
+ /**
331
+ * Create a subcommand using the same subclass, preserving helpers like
332
+ * dynamicOption on children.
333
+ */
334
+ createCommand(name?: string): Command;
282
335
  constructor(alias?: string);
283
336
  /**
284
- * Resolve options (strict) and compute dotenv context. * Stores the context on the instance under a symbol.
337
+ * Resolve options (strict) and compute dotenv context.
338
+ * Stores the context on the instance under a symbol.
339
+ *
340
+ * Options:
341
+ * - opts.runAfterResolve (default true): when false, skips running plugin
342
+ * afterResolve hooks. Useful for top-level help rendering to avoid
343
+ * long-running side-effects while still evaluating dynamic help text.
344
+ */
345
+ resolveAndLoad(customOptions?: Partial<TOptions>, opts?: {
346
+ runAfterResolve?: boolean;
347
+ }): Promise<GetDotenvCliCtx<TOptions>>;
348
+ /**
349
+ * Create a Commander Option that computes its description at help time.
350
+ * The returned Option may be configured (conflicts, default, parser) and
351
+ * added via addOption().
352
+ */
353
+ createDynamicOption<TPlugins = Record<string, unknown>>(flags: string, desc: (cfg: ResolvedHelpConfig & {
354
+ plugins: TPlugins;
355
+ }) => string, parser?: (value: string, previous?: unknown) => unknown, defaultValue?: unknown): Option;
356
+ /**
357
+ * Chainable helper mirroring .option(), but with a dynamic description.
358
+ * Equivalent to addOption(createDynamicOption(...)).
359
+ */
360
+ dynamicOption<TPlugins = Record<string, unknown>>(flags: string, desc: (cfg: ResolvedHelpConfig & {
361
+ plugins: TPlugins;
362
+ }) => string, parser?: (value: string, previous?: unknown) => unknown, defaultValue?: unknown): this;
363
+ /**
364
+ * Evaluate dynamic descriptions for this command and all descendants using
365
+ * the provided resolved configuration. Mutates the Option.description in
366
+ * place so Commander help renders updated text.
285
367
  */
286
- resolveAndLoad(customOptions?: Partial<TOptions>): Promise<GetDotenvCliCtx<TOptions>>;
368
+ evaluateDynamicOptions(resolved: ResolvedHelpConfig): void;
287
369
  /**
288
370
  * Retrieve the current invocation context (if any).
289
371
  */
@@ -315,6 +397,11 @@ declare class GetDotenvCli<TOptions extends GetDotenvOptions = GetDotenvOptions>
315
397
  importMetaUrl?: string;
316
398
  helpHeader?: string;
317
399
  }): Promise<this>;
400
+ /**
401
+ * Insert grouped plugin/app options between "Options" and "Commands" for
402
+ * hybrid ordering. Applies to root and any parent command.
403
+ */
404
+ helpInformation(): string;
318
405
  /**
319
406
  * Register a plugin for installation (parent level).
320
407
  * Installation occurs on first resolveAndLoad() (or explicit install()).
@@ -331,72 +418,29 @@ declare class GetDotenvCli<TOptions extends GetDotenvOptions = GetDotenvOptions>
331
418
  private _runAfterResolve;
332
419
  }
333
420
 
334
- /** src/cliHost/definePlugin.ts
335
- * Plugin contracts for the GetDotenv CLI host.
336
- *
337
- * This module exposes a structural public interface for the host that plugins
338
- * should use (GetDotenvCliPublic). Using a structural type at the seam avoids
339
- * nominal class identity issues (private fields) in downstream consumers.
340
- */
341
-
342
421
  /**
343
- * Structural public interface for the host exposed to plugins.
344
- * - Extends Commander.Command so plugins can attach options/commands/hooks.
345
- * - Adds host-specific helpers used by built-in plugins.
346
- *
347
- * Purpose: remove nominal class identity (private fields) from the plugin seam
348
- * to avoid TS2379 under exactOptionalPropertyTypes in downstream consumers.
422
+ * GetDotenvCli with root helpers as real class methods.
423
+ * - attachRootOptions: installs legacy/base root flags on the command.
424
+ * - passOptions: merges flags (parent \< current), computes dotenv context once,
425
+ * runs validation, and persists merged options for nested flows.
349
426
  */
350
- type GetDotenvCliPublic<TOptions extends GetDotenvOptions = GetDotenvOptions> = Command & {
351
- ns: (name: string) => Command;
352
- getCtx: () => GetDotenvCliCtx<TOptions> | undefined;
353
- resolveAndLoad: (customOptions?: Partial<TOptions>) => Promise<GetDotenvCliCtx<TOptions>>;
354
- };
355
- /** Public plugin contract used by the GetDotenv CLI host. */
356
- interface GetDotenvCliPlugin {
357
- id?: string;
358
- /**
359
- * Setup phase: register commands and wiring on the provided CLI instance.
360
- * Runs parent → children (pre-order).
361
- */
362
- setup: (cli: GetDotenvCliPublic) => void | Promise<void>;
363
- /**
364
- * After the dotenv context is resolved, initialize any clients/secrets
365
- * or attach per-plugin state under ctx.plugins (by convention).
366
- * Runs parent → children (pre-order).
367
- */
368
- afterResolve?: (cli: GetDotenvCliPublic, ctx: GetDotenvCliCtx) => void | Promise<void>;
427
+ declare class GetDotenvCli extends GetDotenvCli$1 {
369
428
  /**
370
- * Optional Zod schema for this plugin's config slice (from config.plugins[id]).
371
- * When provided, the host validates the merged config under the guarded loader path.
429
+ * Attach legacy root flags to this CLI instance. Defaults come from
430
+ * baseRootOptionDefaults when none are provided.
372
431
  */
373
- configSchema?: ZodType;
432
+ attachRootOptions(defaults?: Partial<RootOptionsShape>, opts?: {
433
+ includeCommandOption?: boolean;
434
+ }): this;
374
435
  /**
375
- * Compositional children. Installed after the parent per pre-order.
436
+ * Install preSubcommand/preAction hooks that:
437
+ * - Merge options (parent round-trip + current invocation) using resolveCliOptions.
438
+ * - Persist the merged bag on the current command and on the host (for ergonomics).
439
+ * - Compute the dotenv context once via resolveAndLoad(serviceOptions).
440
+ * - Validate the composed env against discovered config (warn or --strict fail).
376
441
  */
377
- children: GetDotenvCliPlugin[];
378
- /**
379
- * Compose a child plugin. Returns the parent to enable chaining.
380
- */
381
- use: (child: GetDotenvCliPlugin) => GetDotenvCliPlugin;
442
+ passOptions(defaults?: Partial<RootOptionsShape>): this;
382
443
  }
383
- /**
384
- * Public spec type for defining a plugin with optional children.
385
- * Exported to ensure TypeDoc links and navigation resolve correctly.
386
- */
387
- type DefineSpec = Omit<GetDotenvCliPlugin, 'children' | 'use'> & {
388
- children?: GetDotenvCliPlugin[];
389
- };
390
- /**
391
- * Define a GetDotenv CLI plugin with compositional helpers.
392
- *
393
- * @example
394
- * const parent = definePlugin(\{ id: 'p', setup(cli) \{ /* ... *\/ \} \})
395
- * .use(childA)
396
- * .use(childB);
397
- */
398
- declare const definePlugin: (spec: DefineSpec) => GetDotenvCliPlugin;
399
-
400
444
  /**
401
445
  * Helper to retrieve the merged root options bag from any action handler
402
446
  * that only has access to thisCommand. Avoids structural casts.