@karmaniverous/get-dotenv 5.2.5 → 5.2.6

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.
@@ -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,72 @@ 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
+
255
300
  /** * Per-invocation context shared with plugins and actions. */
256
301
  type GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> = {
257
302
  optionsResolved: TOptions;
@@ -271,7 +316,7 @@ declare const HELP_HEADER_SYMBOL: unique symbol;
271
316
  *
272
317
  * NOTE: This host is additive and does not alter the legacy CLI.
273
318
  */
274
- declare class GetDotenvCli<TOptions extends GetDotenvOptions = GetDotenvOptions> extends Command {
319
+ declare class GetDotenvCli$1<TOptions extends GetDotenvOptions = GetDotenvOptions> extends Command {
275
320
  #private;
276
321
  /** Registered top-level plugins (composition happens via .use()) */
277
322
  private _plugins;
@@ -331,72 +376,29 @@ declare class GetDotenvCli<TOptions extends GetDotenvOptions = GetDotenvOptions>
331
376
  private _runAfterResolve;
332
377
  }
333
378
 
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
379
  /**
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.
380
+ * GetDotenvCli with root helpers as real class methods.
381
+ * - attachRootOptions: installs legacy/base root flags on the command.
382
+ * - passOptions: merges flags (parent \< current), computes dotenv context once,
383
+ * runs validation, and persists merged options for nested flows.
349
384
  */
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>;
385
+ declare class GetDotenvCli extends GetDotenvCli$1 {
363
386
  /**
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>;
369
- /**
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.
387
+ * Attach legacy root flags to this CLI instance. Defaults come from
388
+ * baseRootOptionDefaults when none are provided.
372
389
  */
373
- configSchema?: ZodType;
374
- /**
375
- * Compositional children. Installed after the parent per pre-order.
376
- */
377
- children: GetDotenvCliPlugin[];
390
+ attachRootOptions(defaults?: Partial<RootOptionsShape>, opts?: {
391
+ includeCommandOption?: boolean;
392
+ }): this;
378
393
  /**
379
- * Compose a child plugin. Returns the parent to enable chaining.
394
+ * Install preSubcommand/preAction hooks that:
395
+ * - Merge options (parent round-trip + current invocation) using resolveCliOptions.
396
+ * - Persist the merged bag on the current command and on the host (for ergonomics).
397
+ * - Compute the dotenv context once via resolveAndLoad(serviceOptions).
398
+ * - Validate the composed env against discovered config (warn or --strict fail).
380
399
  */
381
- use: (child: GetDotenvCliPlugin) => GetDotenvCliPlugin;
400
+ passOptions(defaults?: Partial<RootOptionsShape>): this;
382
401
  }
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
402
  /**
401
403
  * Helper to retrieve the merged root options bag from any action handler
402
404
  * that only has access to thisCommand. Avoids structural casts.
@@ -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,72 @@ 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
+
255
300
  /** * Per-invocation context shared with plugins and actions. */
256
301
  type GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> = {
257
302
  optionsResolved: TOptions;
@@ -271,7 +316,7 @@ declare const HELP_HEADER_SYMBOL: unique symbol;
271
316
  *
272
317
  * NOTE: This host is additive and does not alter the legacy CLI.
273
318
  */
274
- declare class GetDotenvCli<TOptions extends GetDotenvOptions = GetDotenvOptions> extends Command {
319
+ declare class GetDotenvCli$1<TOptions extends GetDotenvOptions = GetDotenvOptions> extends Command {
275
320
  #private;
276
321
  /** Registered top-level plugins (composition happens via .use()) */
277
322
  private _plugins;
@@ -331,72 +376,29 @@ declare class GetDotenvCli<TOptions extends GetDotenvOptions = GetDotenvOptions>
331
376
  private _runAfterResolve;
332
377
  }
333
378
 
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
379
  /**
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.
380
+ * GetDotenvCli with root helpers as real class methods.
381
+ * - attachRootOptions: installs legacy/base root flags on the command.
382
+ * - passOptions: merges flags (parent \< current), computes dotenv context once,
383
+ * runs validation, and persists merged options for nested flows.
349
384
  */
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>;
385
+ declare class GetDotenvCli extends GetDotenvCli$1 {
363
386
  /**
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>;
369
- /**
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.
387
+ * Attach legacy root flags to this CLI instance. Defaults come from
388
+ * baseRootOptionDefaults when none are provided.
372
389
  */
373
- configSchema?: ZodType;
374
- /**
375
- * Compositional children. Installed after the parent per pre-order.
376
- */
377
- children: GetDotenvCliPlugin[];
390
+ attachRootOptions(defaults?: Partial<RootOptionsShape>, opts?: {
391
+ includeCommandOption?: boolean;
392
+ }): this;
378
393
  /**
379
- * Compose a child plugin. Returns the parent to enable chaining.
394
+ * Install preSubcommand/preAction hooks that:
395
+ * - Merge options (parent round-trip + current invocation) using resolveCliOptions.
396
+ * - Persist the merged bag on the current command and on the host (for ergonomics).
397
+ * - Compute the dotenv context once via resolveAndLoad(serviceOptions).
398
+ * - Validate the composed env against discovered config (warn or --strict fail).
380
399
  */
381
- use: (child: GetDotenvCliPlugin) => GetDotenvCliPlugin;
400
+ passOptions(defaults?: Partial<RootOptionsShape>): this;
382
401
  }
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
402
  /**
401
403
  * Helper to retrieve the merged root options bag from any action handler
402
404
  * that only has access to thisCommand. Avoids structural casts.
package/dist/cliHost.d.ts CHANGED
@@ -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,72 @@ 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
+
255
300
  /** * Per-invocation context shared with plugins and actions. */
256
301
  type GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> = {
257
302
  optionsResolved: TOptions;
@@ -271,7 +316,7 @@ declare const HELP_HEADER_SYMBOL: unique symbol;
271
316
  *
272
317
  * NOTE: This host is additive and does not alter the legacy CLI.
273
318
  */
274
- declare class GetDotenvCli<TOptions extends GetDotenvOptions = GetDotenvOptions> extends Command {
319
+ declare class GetDotenvCli$1<TOptions extends GetDotenvOptions = GetDotenvOptions> extends Command {
275
320
  #private;
276
321
  /** Registered top-level plugins (composition happens via .use()) */
277
322
  private _plugins;
@@ -331,72 +376,29 @@ declare class GetDotenvCli<TOptions extends GetDotenvOptions = GetDotenvOptions>
331
376
  private _runAfterResolve;
332
377
  }
333
378
 
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
379
  /**
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.
380
+ * GetDotenvCli with root helpers as real class methods.
381
+ * - attachRootOptions: installs legacy/base root flags on the command.
382
+ * - passOptions: merges flags (parent \< current), computes dotenv context once,
383
+ * runs validation, and persists merged options for nested flows.
349
384
  */
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>;
385
+ declare class GetDotenvCli extends GetDotenvCli$1 {
363
386
  /**
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>;
369
- /**
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.
387
+ * Attach legacy root flags to this CLI instance. Defaults come from
388
+ * baseRootOptionDefaults when none are provided.
372
389
  */
373
- configSchema?: ZodType;
374
- /**
375
- * Compositional children. Installed after the parent per pre-order.
376
- */
377
- children: GetDotenvCliPlugin[];
390
+ attachRootOptions(defaults?: Partial<RootOptionsShape>, opts?: {
391
+ includeCommandOption?: boolean;
392
+ }): this;
378
393
  /**
379
- * Compose a child plugin. Returns the parent to enable chaining.
394
+ * Install preSubcommand/preAction hooks that:
395
+ * - Merge options (parent round-trip + current invocation) using resolveCliOptions.
396
+ * - Persist the merged bag on the current command and on the host (for ergonomics).
397
+ * - Compute the dotenv context once via resolveAndLoad(serviceOptions).
398
+ * - Validate the composed env against discovered config (warn or --strict fail).
380
399
  */
381
- use: (child: GetDotenvCliPlugin) => GetDotenvCliPlugin;
400
+ passOptions(defaults?: Partial<RootOptionsShape>): this;
382
401
  }
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
402
  /**
401
403
  * Helper to retrieve the merged root options bag from any action handler
402
404
  * that only has access to thisCommand. Avoids structural casts.