@karmaniverous/get-dotenv 5.2.4 → 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.
- package/README.md +5 -5
- package/dist/cliHost.cjs +678 -271
- package/dist/cliHost.d.cts +124 -60
- package/dist/cliHost.d.mts +124 -60
- package/dist/cliHost.d.ts +124 -60
- package/dist/cliHost.mjs +679 -272
- package/dist/getdotenv.cli.mjs +647 -631
- package/dist/index.cjs +694 -678
- package/dist/index.d.cts +18 -39
- package/dist/index.d.mts +18 -39
- package/dist/index.d.ts +18 -39
- package/dist/index.mjs +695 -679
- package/dist/plugins-aws.d.cts +8 -8
- package/dist/plugins-aws.d.mts +8 -8
- package/dist/plugins-aws.d.ts +8 -8
- package/dist/plugins-batch.d.cts +8 -8
- package/dist/plugins-batch.d.mts +8 -8
- package/dist/plugins-batch.d.ts +8 -8
- package/dist/plugins-cmd.cjs +159 -1551
- package/dist/plugins-cmd.d.cts +8 -8
- package/dist/plugins-cmd.d.mts +8 -8
- package/dist/plugins-cmd.d.ts +8 -8
- package/dist/plugins-cmd.mjs +160 -1551
- package/dist/plugins-demo.d.cts +8 -8
- package/dist/plugins-demo.d.mts +8 -8
- package/dist/plugins-demo.d.ts +8 -8
- package/dist/plugins-init.d.cts +8 -8
- package/dist/plugins-init.d.mts +8 -8
- package/dist/plugins-init.d.ts +8 -8
- package/dist/plugins.cjs +156 -1547
- package/dist/plugins.d.cts +8 -8
- package/dist/plugins.d.mts +8 -8
- package/dist/plugins.d.ts +8 -8
- package/dist/plugins.mjs +158 -1548
- package/package.json +1 -1
package/dist/cliHost.d.cts
CHANGED
|
@@ -1,6 +1,47 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { ZodType } from 'zod';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Minimal root options shape shared by CLI and generator layers.
|
|
6
|
+
* Keep keys optional to respect exactOptionalPropertyTypes semantics.
|
|
7
|
+
*/
|
|
8
|
+
type RootOptionsShape = {
|
|
9
|
+
env?: string;
|
|
10
|
+
vars?: string;
|
|
11
|
+
command?: string;
|
|
12
|
+
outputPath?: string;
|
|
13
|
+
shell?: string | boolean;
|
|
14
|
+
loadProcess?: boolean;
|
|
15
|
+
excludeAll?: boolean;
|
|
16
|
+
excludeDynamic?: boolean;
|
|
17
|
+
excludeEnv?: boolean;
|
|
18
|
+
excludeGlobal?: boolean;
|
|
19
|
+
excludePrivate?: boolean;
|
|
20
|
+
excludePublic?: boolean;
|
|
21
|
+
log?: boolean;
|
|
22
|
+
debug?: boolean;
|
|
23
|
+
capture?: boolean;
|
|
24
|
+
strict?: boolean;
|
|
25
|
+
redact?: boolean;
|
|
26
|
+
warnEntropy?: boolean;
|
|
27
|
+
entropyThreshold?: number;
|
|
28
|
+
entropyMinLength?: number;
|
|
29
|
+
entropyWhitelist?: string[];
|
|
30
|
+
redactPatterns?: string[];
|
|
31
|
+
defaultEnv?: string;
|
|
32
|
+
dotenvToken?: string;
|
|
33
|
+
dynamicPath?: string;
|
|
34
|
+
trace?: boolean | string[];
|
|
35
|
+
paths?: string;
|
|
36
|
+
pathsDelimiter?: string;
|
|
37
|
+
pathsDelimiterPattern?: string;
|
|
38
|
+
privateToken?: string;
|
|
39
|
+
varsDelimiter?: string;
|
|
40
|
+
varsDelimiterPattern?: string;
|
|
41
|
+
varsAssignor?: string;
|
|
42
|
+
varsAssignorPattern?: string;
|
|
43
|
+
scripts?: ScriptsTable;
|
|
44
|
+
};
|
|
4
45
|
/**
|
|
5
46
|
* Scripts table shape (configurable shell type).
|
|
6
47
|
*/
|
|
@@ -190,6 +231,72 @@ interface GetDotenvCliOptions extends Omit<GetDotenvOptions, 'paths' | 'vars'> {
|
|
|
190
231
|
varsDelimiterPattern?: string;
|
|
191
232
|
}
|
|
192
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
|
+
|
|
193
300
|
/** * Per-invocation context shared with plugins and actions. */
|
|
194
301
|
type GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> = {
|
|
195
302
|
optionsResolved: TOptions;
|
|
@@ -209,7 +316,7 @@ declare const HELP_HEADER_SYMBOL: unique symbol;
|
|
|
209
316
|
*
|
|
210
317
|
* NOTE: This host is additive and does not alter the legacy CLI.
|
|
211
318
|
*/
|
|
212
|
-
declare class GetDotenvCli<TOptions extends GetDotenvOptions = GetDotenvOptions> extends Command {
|
|
319
|
+
declare class GetDotenvCli$1<TOptions extends GetDotenvOptions = GetDotenvOptions> extends Command {
|
|
213
320
|
#private;
|
|
214
321
|
/** Registered top-level plugins (composition happens via .use()) */
|
|
215
322
|
private _plugins;
|
|
@@ -269,72 +376,29 @@ declare class GetDotenvCli<TOptions extends GetDotenvOptions = GetDotenvOptions>
|
|
|
269
376
|
private _runAfterResolve;
|
|
270
377
|
}
|
|
271
378
|
|
|
272
|
-
/** src/cliHost/definePlugin.ts
|
|
273
|
-
* Plugin contracts for the GetDotenv CLI host.
|
|
274
|
-
*
|
|
275
|
-
* This module exposes a structural public interface for the host that plugins
|
|
276
|
-
* should use (GetDotenvCliPublic). Using a structural type at the seam avoids
|
|
277
|
-
* nominal class identity issues (private fields) in downstream consumers.
|
|
278
|
-
*/
|
|
279
|
-
|
|
280
379
|
/**
|
|
281
|
-
*
|
|
282
|
-
* -
|
|
283
|
-
* -
|
|
284
|
-
*
|
|
285
|
-
* Purpose: remove nominal class identity (private fields) from the plugin seam
|
|
286
|
-
* 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.
|
|
287
384
|
*/
|
|
288
|
-
|
|
289
|
-
ns: (name: string) => Command;
|
|
290
|
-
getCtx: () => GetDotenvCliCtx<TOptions> | undefined;
|
|
291
|
-
resolveAndLoad: (customOptions?: Partial<TOptions>) => Promise<GetDotenvCliCtx<TOptions>>;
|
|
292
|
-
};
|
|
293
|
-
/** Public plugin contract used by the GetDotenv CLI host. */
|
|
294
|
-
interface GetDotenvCliPlugin {
|
|
295
|
-
id?: string;
|
|
296
|
-
/**
|
|
297
|
-
* Setup phase: register commands and wiring on the provided CLI instance.
|
|
298
|
-
* Runs parent → children (pre-order).
|
|
299
|
-
*/
|
|
300
|
-
setup: (cli: GetDotenvCliPublic) => void | Promise<void>;
|
|
301
|
-
/**
|
|
302
|
-
* After the dotenv context is resolved, initialize any clients/secrets
|
|
303
|
-
* or attach per-plugin state under ctx.plugins (by convention).
|
|
304
|
-
* Runs parent → children (pre-order).
|
|
305
|
-
*/
|
|
306
|
-
afterResolve?: (cli: GetDotenvCliPublic, ctx: GetDotenvCliCtx) => void | Promise<void>;
|
|
385
|
+
declare class GetDotenvCli extends GetDotenvCli$1 {
|
|
307
386
|
/**
|
|
308
|
-
*
|
|
309
|
-
*
|
|
387
|
+
* Attach legacy root flags to this CLI instance. Defaults come from
|
|
388
|
+
* baseRootOptionDefaults when none are provided.
|
|
310
389
|
*/
|
|
311
|
-
|
|
390
|
+
attachRootOptions(defaults?: Partial<RootOptionsShape>, opts?: {
|
|
391
|
+
includeCommandOption?: boolean;
|
|
392
|
+
}): this;
|
|
312
393
|
/**
|
|
313
|
-
*
|
|
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).
|
|
314
399
|
*/
|
|
315
|
-
|
|
316
|
-
/**
|
|
317
|
-
* Compose a child plugin. Returns the parent to enable chaining.
|
|
318
|
-
*/
|
|
319
|
-
use: (child: GetDotenvCliPlugin) => GetDotenvCliPlugin;
|
|
400
|
+
passOptions(defaults?: Partial<RootOptionsShape>): this;
|
|
320
401
|
}
|
|
321
|
-
/**
|
|
322
|
-
* Public spec type for defining a plugin with optional children.
|
|
323
|
-
* Exported to ensure TypeDoc links and navigation resolve correctly.
|
|
324
|
-
*/
|
|
325
|
-
type DefineSpec = Omit<GetDotenvCliPlugin, 'children' | 'use'> & {
|
|
326
|
-
children?: GetDotenvCliPlugin[];
|
|
327
|
-
};
|
|
328
|
-
/**
|
|
329
|
-
* Define a GetDotenv CLI plugin with compositional helpers.
|
|
330
|
-
*
|
|
331
|
-
* @example
|
|
332
|
-
* const parent = definePlugin(\{ id: 'p', setup(cli) \{ /* ... *\/ \} \})
|
|
333
|
-
* .use(childA)
|
|
334
|
-
* .use(childB);
|
|
335
|
-
*/
|
|
336
|
-
declare const definePlugin: (spec: DefineSpec) => GetDotenvCliPlugin;
|
|
337
|
-
|
|
338
402
|
/**
|
|
339
403
|
* Helper to retrieve the merged root options bag from any action handler
|
|
340
404
|
* that only has access to thisCommand. Avoids structural casts.
|
package/dist/cliHost.d.mts
CHANGED
|
@@ -1,6 +1,47 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { ZodType } from 'zod';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Minimal root options shape shared by CLI and generator layers.
|
|
6
|
+
* Keep keys optional to respect exactOptionalPropertyTypes semantics.
|
|
7
|
+
*/
|
|
8
|
+
type RootOptionsShape = {
|
|
9
|
+
env?: string;
|
|
10
|
+
vars?: string;
|
|
11
|
+
command?: string;
|
|
12
|
+
outputPath?: string;
|
|
13
|
+
shell?: string | boolean;
|
|
14
|
+
loadProcess?: boolean;
|
|
15
|
+
excludeAll?: boolean;
|
|
16
|
+
excludeDynamic?: boolean;
|
|
17
|
+
excludeEnv?: boolean;
|
|
18
|
+
excludeGlobal?: boolean;
|
|
19
|
+
excludePrivate?: boolean;
|
|
20
|
+
excludePublic?: boolean;
|
|
21
|
+
log?: boolean;
|
|
22
|
+
debug?: boolean;
|
|
23
|
+
capture?: boolean;
|
|
24
|
+
strict?: boolean;
|
|
25
|
+
redact?: boolean;
|
|
26
|
+
warnEntropy?: boolean;
|
|
27
|
+
entropyThreshold?: number;
|
|
28
|
+
entropyMinLength?: number;
|
|
29
|
+
entropyWhitelist?: string[];
|
|
30
|
+
redactPatterns?: string[];
|
|
31
|
+
defaultEnv?: string;
|
|
32
|
+
dotenvToken?: string;
|
|
33
|
+
dynamicPath?: string;
|
|
34
|
+
trace?: boolean | string[];
|
|
35
|
+
paths?: string;
|
|
36
|
+
pathsDelimiter?: string;
|
|
37
|
+
pathsDelimiterPattern?: string;
|
|
38
|
+
privateToken?: string;
|
|
39
|
+
varsDelimiter?: string;
|
|
40
|
+
varsDelimiterPattern?: string;
|
|
41
|
+
varsAssignor?: string;
|
|
42
|
+
varsAssignorPattern?: string;
|
|
43
|
+
scripts?: ScriptsTable;
|
|
44
|
+
};
|
|
4
45
|
/**
|
|
5
46
|
* Scripts table shape (configurable shell type).
|
|
6
47
|
*/
|
|
@@ -190,6 +231,72 @@ interface GetDotenvCliOptions extends Omit<GetDotenvOptions, 'paths' | 'vars'> {
|
|
|
190
231
|
varsDelimiterPattern?: string;
|
|
191
232
|
}
|
|
192
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
|
+
|
|
193
300
|
/** * Per-invocation context shared with plugins and actions. */
|
|
194
301
|
type GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> = {
|
|
195
302
|
optionsResolved: TOptions;
|
|
@@ -209,7 +316,7 @@ declare const HELP_HEADER_SYMBOL: unique symbol;
|
|
|
209
316
|
*
|
|
210
317
|
* NOTE: This host is additive and does not alter the legacy CLI.
|
|
211
318
|
*/
|
|
212
|
-
declare class GetDotenvCli<TOptions extends GetDotenvOptions = GetDotenvOptions> extends Command {
|
|
319
|
+
declare class GetDotenvCli$1<TOptions extends GetDotenvOptions = GetDotenvOptions> extends Command {
|
|
213
320
|
#private;
|
|
214
321
|
/** Registered top-level plugins (composition happens via .use()) */
|
|
215
322
|
private _plugins;
|
|
@@ -269,72 +376,29 @@ declare class GetDotenvCli<TOptions extends GetDotenvOptions = GetDotenvOptions>
|
|
|
269
376
|
private _runAfterResolve;
|
|
270
377
|
}
|
|
271
378
|
|
|
272
|
-
/** src/cliHost/definePlugin.ts
|
|
273
|
-
* Plugin contracts for the GetDotenv CLI host.
|
|
274
|
-
*
|
|
275
|
-
* This module exposes a structural public interface for the host that plugins
|
|
276
|
-
* should use (GetDotenvCliPublic). Using a structural type at the seam avoids
|
|
277
|
-
* nominal class identity issues (private fields) in downstream consumers.
|
|
278
|
-
*/
|
|
279
|
-
|
|
280
379
|
/**
|
|
281
|
-
*
|
|
282
|
-
* -
|
|
283
|
-
* -
|
|
284
|
-
*
|
|
285
|
-
* Purpose: remove nominal class identity (private fields) from the plugin seam
|
|
286
|
-
* 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.
|
|
287
384
|
*/
|
|
288
|
-
|
|
289
|
-
ns: (name: string) => Command;
|
|
290
|
-
getCtx: () => GetDotenvCliCtx<TOptions> | undefined;
|
|
291
|
-
resolveAndLoad: (customOptions?: Partial<TOptions>) => Promise<GetDotenvCliCtx<TOptions>>;
|
|
292
|
-
};
|
|
293
|
-
/** Public plugin contract used by the GetDotenv CLI host. */
|
|
294
|
-
interface GetDotenvCliPlugin {
|
|
295
|
-
id?: string;
|
|
296
|
-
/**
|
|
297
|
-
* Setup phase: register commands and wiring on the provided CLI instance.
|
|
298
|
-
* Runs parent → children (pre-order).
|
|
299
|
-
*/
|
|
300
|
-
setup: (cli: GetDotenvCliPublic) => void | Promise<void>;
|
|
301
|
-
/**
|
|
302
|
-
* After the dotenv context is resolved, initialize any clients/secrets
|
|
303
|
-
* or attach per-plugin state under ctx.plugins (by convention).
|
|
304
|
-
* Runs parent → children (pre-order).
|
|
305
|
-
*/
|
|
306
|
-
afterResolve?: (cli: GetDotenvCliPublic, ctx: GetDotenvCliCtx) => void | Promise<void>;
|
|
385
|
+
declare class GetDotenvCli extends GetDotenvCli$1 {
|
|
307
386
|
/**
|
|
308
|
-
*
|
|
309
|
-
*
|
|
387
|
+
* Attach legacy root flags to this CLI instance. Defaults come from
|
|
388
|
+
* baseRootOptionDefaults when none are provided.
|
|
310
389
|
*/
|
|
311
|
-
|
|
390
|
+
attachRootOptions(defaults?: Partial<RootOptionsShape>, opts?: {
|
|
391
|
+
includeCommandOption?: boolean;
|
|
392
|
+
}): this;
|
|
312
393
|
/**
|
|
313
|
-
*
|
|
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).
|
|
314
399
|
*/
|
|
315
|
-
|
|
316
|
-
/**
|
|
317
|
-
* Compose a child plugin. Returns the parent to enable chaining.
|
|
318
|
-
*/
|
|
319
|
-
use: (child: GetDotenvCliPlugin) => GetDotenvCliPlugin;
|
|
400
|
+
passOptions(defaults?: Partial<RootOptionsShape>): this;
|
|
320
401
|
}
|
|
321
|
-
/**
|
|
322
|
-
* Public spec type for defining a plugin with optional children.
|
|
323
|
-
* Exported to ensure TypeDoc links and navigation resolve correctly.
|
|
324
|
-
*/
|
|
325
|
-
type DefineSpec = Omit<GetDotenvCliPlugin, 'children' | 'use'> & {
|
|
326
|
-
children?: GetDotenvCliPlugin[];
|
|
327
|
-
};
|
|
328
|
-
/**
|
|
329
|
-
* Define a GetDotenv CLI plugin with compositional helpers.
|
|
330
|
-
*
|
|
331
|
-
* @example
|
|
332
|
-
* const parent = definePlugin(\{ id: 'p', setup(cli) \{ /* ... *\/ \} \})
|
|
333
|
-
* .use(childA)
|
|
334
|
-
* .use(childB);
|
|
335
|
-
*/
|
|
336
|
-
declare const definePlugin: (spec: DefineSpec) => GetDotenvCliPlugin;
|
|
337
|
-
|
|
338
402
|
/**
|
|
339
403
|
* Helper to retrieve the merged root options bag from any action handler
|
|
340
404
|
* that only has access to thisCommand. Avoids structural casts.
|
package/dist/cliHost.d.ts
CHANGED
|
@@ -1,6 +1,47 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { ZodType } from 'zod';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Minimal root options shape shared by CLI and generator layers.
|
|
6
|
+
* Keep keys optional to respect exactOptionalPropertyTypes semantics.
|
|
7
|
+
*/
|
|
8
|
+
type RootOptionsShape = {
|
|
9
|
+
env?: string;
|
|
10
|
+
vars?: string;
|
|
11
|
+
command?: string;
|
|
12
|
+
outputPath?: string;
|
|
13
|
+
shell?: string | boolean;
|
|
14
|
+
loadProcess?: boolean;
|
|
15
|
+
excludeAll?: boolean;
|
|
16
|
+
excludeDynamic?: boolean;
|
|
17
|
+
excludeEnv?: boolean;
|
|
18
|
+
excludeGlobal?: boolean;
|
|
19
|
+
excludePrivate?: boolean;
|
|
20
|
+
excludePublic?: boolean;
|
|
21
|
+
log?: boolean;
|
|
22
|
+
debug?: boolean;
|
|
23
|
+
capture?: boolean;
|
|
24
|
+
strict?: boolean;
|
|
25
|
+
redact?: boolean;
|
|
26
|
+
warnEntropy?: boolean;
|
|
27
|
+
entropyThreshold?: number;
|
|
28
|
+
entropyMinLength?: number;
|
|
29
|
+
entropyWhitelist?: string[];
|
|
30
|
+
redactPatterns?: string[];
|
|
31
|
+
defaultEnv?: string;
|
|
32
|
+
dotenvToken?: string;
|
|
33
|
+
dynamicPath?: string;
|
|
34
|
+
trace?: boolean | string[];
|
|
35
|
+
paths?: string;
|
|
36
|
+
pathsDelimiter?: string;
|
|
37
|
+
pathsDelimiterPattern?: string;
|
|
38
|
+
privateToken?: string;
|
|
39
|
+
varsDelimiter?: string;
|
|
40
|
+
varsDelimiterPattern?: string;
|
|
41
|
+
varsAssignor?: string;
|
|
42
|
+
varsAssignorPattern?: string;
|
|
43
|
+
scripts?: ScriptsTable;
|
|
44
|
+
};
|
|
4
45
|
/**
|
|
5
46
|
* Scripts table shape (configurable shell type).
|
|
6
47
|
*/
|
|
@@ -190,6 +231,72 @@ interface GetDotenvCliOptions extends Omit<GetDotenvOptions, 'paths' | 'vars'> {
|
|
|
190
231
|
varsDelimiterPattern?: string;
|
|
191
232
|
}
|
|
192
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
|
+
|
|
193
300
|
/** * Per-invocation context shared with plugins and actions. */
|
|
194
301
|
type GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> = {
|
|
195
302
|
optionsResolved: TOptions;
|
|
@@ -209,7 +316,7 @@ declare const HELP_HEADER_SYMBOL: unique symbol;
|
|
|
209
316
|
*
|
|
210
317
|
* NOTE: This host is additive and does not alter the legacy CLI.
|
|
211
318
|
*/
|
|
212
|
-
declare class GetDotenvCli<TOptions extends GetDotenvOptions = GetDotenvOptions> extends Command {
|
|
319
|
+
declare class GetDotenvCli$1<TOptions extends GetDotenvOptions = GetDotenvOptions> extends Command {
|
|
213
320
|
#private;
|
|
214
321
|
/** Registered top-level plugins (composition happens via .use()) */
|
|
215
322
|
private _plugins;
|
|
@@ -269,72 +376,29 @@ declare class GetDotenvCli<TOptions extends GetDotenvOptions = GetDotenvOptions>
|
|
|
269
376
|
private _runAfterResolve;
|
|
270
377
|
}
|
|
271
378
|
|
|
272
|
-
/** src/cliHost/definePlugin.ts
|
|
273
|
-
* Plugin contracts for the GetDotenv CLI host.
|
|
274
|
-
*
|
|
275
|
-
* This module exposes a structural public interface for the host that plugins
|
|
276
|
-
* should use (GetDotenvCliPublic). Using a structural type at the seam avoids
|
|
277
|
-
* nominal class identity issues (private fields) in downstream consumers.
|
|
278
|
-
*/
|
|
279
|
-
|
|
280
379
|
/**
|
|
281
|
-
*
|
|
282
|
-
* -
|
|
283
|
-
* -
|
|
284
|
-
*
|
|
285
|
-
* Purpose: remove nominal class identity (private fields) from the plugin seam
|
|
286
|
-
* 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.
|
|
287
384
|
*/
|
|
288
|
-
|
|
289
|
-
ns: (name: string) => Command;
|
|
290
|
-
getCtx: () => GetDotenvCliCtx<TOptions> | undefined;
|
|
291
|
-
resolveAndLoad: (customOptions?: Partial<TOptions>) => Promise<GetDotenvCliCtx<TOptions>>;
|
|
292
|
-
};
|
|
293
|
-
/** Public plugin contract used by the GetDotenv CLI host. */
|
|
294
|
-
interface GetDotenvCliPlugin {
|
|
295
|
-
id?: string;
|
|
296
|
-
/**
|
|
297
|
-
* Setup phase: register commands and wiring on the provided CLI instance.
|
|
298
|
-
* Runs parent → children (pre-order).
|
|
299
|
-
*/
|
|
300
|
-
setup: (cli: GetDotenvCliPublic) => void | Promise<void>;
|
|
301
|
-
/**
|
|
302
|
-
* After the dotenv context is resolved, initialize any clients/secrets
|
|
303
|
-
* or attach per-plugin state under ctx.plugins (by convention).
|
|
304
|
-
* Runs parent → children (pre-order).
|
|
305
|
-
*/
|
|
306
|
-
afterResolve?: (cli: GetDotenvCliPublic, ctx: GetDotenvCliCtx) => void | Promise<void>;
|
|
385
|
+
declare class GetDotenvCli extends GetDotenvCli$1 {
|
|
307
386
|
/**
|
|
308
|
-
*
|
|
309
|
-
*
|
|
387
|
+
* Attach legacy root flags to this CLI instance. Defaults come from
|
|
388
|
+
* baseRootOptionDefaults when none are provided.
|
|
310
389
|
*/
|
|
311
|
-
|
|
390
|
+
attachRootOptions(defaults?: Partial<RootOptionsShape>, opts?: {
|
|
391
|
+
includeCommandOption?: boolean;
|
|
392
|
+
}): this;
|
|
312
393
|
/**
|
|
313
|
-
*
|
|
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).
|
|
314
399
|
*/
|
|
315
|
-
|
|
316
|
-
/**
|
|
317
|
-
* Compose a child plugin. Returns the parent to enable chaining.
|
|
318
|
-
*/
|
|
319
|
-
use: (child: GetDotenvCliPlugin) => GetDotenvCliPlugin;
|
|
400
|
+
passOptions(defaults?: Partial<RootOptionsShape>): this;
|
|
320
401
|
}
|
|
321
|
-
/**
|
|
322
|
-
* Public spec type for defining a plugin with optional children.
|
|
323
|
-
* Exported to ensure TypeDoc links and navigation resolve correctly.
|
|
324
|
-
*/
|
|
325
|
-
type DefineSpec = Omit<GetDotenvCliPlugin, 'children' | 'use'> & {
|
|
326
|
-
children?: GetDotenvCliPlugin[];
|
|
327
|
-
};
|
|
328
|
-
/**
|
|
329
|
-
* Define a GetDotenv CLI plugin with compositional helpers.
|
|
330
|
-
*
|
|
331
|
-
* @example
|
|
332
|
-
* const parent = definePlugin(\{ id: 'p', setup(cli) \{ /* ... *\/ \} \})
|
|
333
|
-
* .use(childA)
|
|
334
|
-
* .use(childB);
|
|
335
|
-
*/
|
|
336
|
-
declare const definePlugin: (spec: DefineSpec) => GetDotenvCliPlugin;
|
|
337
|
-
|
|
338
402
|
/**
|
|
339
403
|
* Helper to retrieve the merged root options bag from any action handler
|
|
340
404
|
* that only has access to thisCommand. Avoids structural casts.
|