@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.
- package/README.md +63 -67
- package/dist/cliHost.cjs +765 -549
- package/dist/cliHost.d.cts +128 -84
- package/dist/cliHost.d.mts +128 -84
- package/dist/cliHost.d.ts +128 -84
- package/dist/cliHost.mjs +765 -549
- package/dist/getdotenv.cli.mjs +915 -685
- package/dist/index.cjs +959 -1006
- package/dist/index.d.cts +18 -178
- package/dist/index.d.mts +18 -178
- package/dist/index.d.ts +18 -178
- package/dist/index.mjs +960 -1006
- package/dist/plugins-aws.cjs +0 -1
- package/dist/plugins-aws.d.cts +8 -78
- package/dist/plugins-aws.d.mts +8 -78
- package/dist/plugins-aws.d.ts +8 -78
- package/dist/plugins-aws.mjs +0 -1
- package/dist/plugins-batch.cjs +53 -11
- package/dist/plugins-batch.d.cts +10 -79
- package/dist/plugins-batch.d.mts +10 -79
- package/dist/plugins-batch.d.ts +10 -79
- package/dist/plugins-batch.mjs +53 -11
- package/dist/plugins-cmd.cjs +162 -1555
- package/dist/plugins-cmd.d.cts +8 -78
- package/dist/plugins-cmd.d.mts +8 -78
- package/dist/plugins-cmd.d.ts +8 -78
- package/dist/plugins-cmd.mjs +162 -1554
- package/dist/plugins-demo.cjs +52 -7
- package/dist/plugins-demo.d.cts +8 -78
- package/dist/plugins-demo.d.mts +8 -78
- package/dist/plugins-demo.d.ts +8 -78
- package/dist/plugins-demo.mjs +52 -7
- package/dist/plugins-init.d.cts +8 -78
- package/dist/plugins-init.d.mts +8 -78
- package/dist/plugins-init.d.ts +8 -78
- package/dist/plugins.cjs +283 -1630
- package/dist/plugins.d.cts +10 -79
- package/dist/plugins.d.mts +10 -79
- package/dist/plugins.d.ts +10 -79
- package/dist/plugins.mjs +285 -1631
- package/package.json +4 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
/** src/cliCore/spawnEnv.ts
|
|
2
|
+
* Build a sanitized environment bag for child processes.
|
|
3
|
+
*
|
|
4
|
+
* Requirements addressed:
|
|
5
|
+
* - Provide a single helper (buildSpawnEnv) to normalize/dedupe child env.
|
|
6
|
+
* - Drop undefined values (exactOptional semantics).
|
|
7
|
+
* - On Windows, dedupe keys case-insensitively and prefer the last value,
|
|
8
|
+
* preserving the latest key's casing. Ensure HOME fallback from USERPROFILE.
|
|
9
|
+
* Normalize TMP/TEMP consistency when either is present.
|
|
10
|
+
* - On POSIX, keep keys as-is; when a temp dir key is present (TMPDIR/TMP/TEMP),
|
|
11
|
+
* ensure TMPDIR exists for downstream consumers that expect it.
|
|
12
|
+
*
|
|
13
|
+
* Adapter responsibility: pure mapping; no business logic.
|
|
14
|
+
*/
|
|
15
|
+
type SpawnEnv = Readonly<Partial<Record<string, string>>>;
|
|
16
|
+
/** Build a sanitized env for child processes from base + overlay. */
|
|
17
|
+
declare const buildSpawnEnv: (base?: NodeJS.ProcessEnv, overlay?: Record<string, string | undefined>) => SpawnEnv;
|
|
2
18
|
|
|
3
19
|
/**
|
|
4
20
|
* Minimal root options shape shared by CLI and generator layers.
|
|
@@ -49,45 +65,6 @@ type ScriptsTable<TShell extends string | boolean = string | boolean> = Record<s
|
|
|
49
65
|
shell?: TShell;
|
|
50
66
|
}>;
|
|
51
67
|
|
|
52
|
-
/**
|
|
53
|
-
* Adapter-layer augmentation: add chainable helpers to GetDotenvCli without
|
|
54
|
-
* coupling the core host to cliCore. Importing this module has side effects:
|
|
55
|
-
* it extends the prototype and merges types for consumers.
|
|
56
|
-
*/
|
|
57
|
-
declare module '../cliHost/GetDotenvCli' {
|
|
58
|
-
interface GetDotenvCli {
|
|
59
|
-
/**
|
|
60
|
-
* Attach legacy root flags to this CLI instance. Defaults come from
|
|
61
|
-
* baseRootOptionDefaults when none are provided. */
|
|
62
|
-
attachRootOptions(defaults?: Partial<RootOptionsShape>, opts?: {
|
|
63
|
-
includeCommandOption?: boolean;
|
|
64
|
-
}): this;
|
|
65
|
-
/**
|
|
66
|
-
* Install a preSubcommand hook that merges CLI flags (including parent
|
|
67
|
-
* round-trip) and resolves the dotenv context before executing actions.
|
|
68
|
-
* Defaults come from baseRootOptionDefaults when none are provided.
|
|
69
|
-
*/ passOptions(defaults?: Partial<RootOptionsShape>): this;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/** src/cliCore/spawnEnv.ts
|
|
74
|
-
* Build a sanitized environment bag for child processes.
|
|
75
|
-
*
|
|
76
|
-
* Requirements addressed:
|
|
77
|
-
* - Provide a single helper (buildSpawnEnv) to normalize/dedupe child env.
|
|
78
|
-
* - Drop undefined values (exactOptional semantics).
|
|
79
|
-
* - On Windows, dedupe keys case-insensitively and prefer the last value,
|
|
80
|
-
* preserving the latest key's casing. Ensure HOME fallback from USERPROFILE.
|
|
81
|
-
* Normalize TMP/TEMP consistency when either is present.
|
|
82
|
-
* - On POSIX, keep keys as-is; when a temp dir key is present (TMPDIR/TMP/TEMP),
|
|
83
|
-
* ensure TMPDIR exists for downstream consumers that expect it.
|
|
84
|
-
*
|
|
85
|
-
* Adapter responsibility: pure mapping; no business logic.
|
|
86
|
-
*/
|
|
87
|
-
type SpawnEnv = Readonly<Partial<Record<string, string>>>;
|
|
88
|
-
/** Build a sanitized env for child processes from base + overlay. */
|
|
89
|
-
declare const buildSpawnEnv: (base?: NodeJS.ProcessEnv, overlay?: Record<string, string | undefined>) => SpawnEnv;
|
|
90
|
-
|
|
91
68
|
type RootOptionsShapeCompat = Omit<RootOptionsShape, 'vars' | 'paths'> & {
|
|
92
69
|
vars?: string | Record<string, string | undefined>;
|
|
93
70
|
paths?: string | string[];
|
|
@@ -268,143 +245,6 @@ declare const dotenvExpandAll: (values?: ProcessEnv, options?: {
|
|
|
268
245
|
*/
|
|
269
246
|
declare const dotenvExpandFromProcessEnv: (value: string | undefined) => string | undefined;
|
|
270
247
|
|
|
271
|
-
type Scripts = Record<string, string | {
|
|
272
|
-
cmd: string;
|
|
273
|
-
shell?: string | boolean;
|
|
274
|
-
}>;
|
|
275
|
-
/**
|
|
276
|
-
* Options passed programmatically to `getDotenvCli`.
|
|
277
|
-
*/
|
|
278
|
-
interface GetDotenvCliOptions extends Omit<GetDotenvOptions, 'paths' | 'vars'> {
|
|
279
|
-
/**
|
|
280
|
-
* Logs CLI internals when true.
|
|
281
|
-
*/
|
|
282
|
-
debug?: boolean;
|
|
283
|
-
/**
|
|
284
|
-
* Strict mode: fail the run when env validation issues are detected
|
|
285
|
-
* (schema or requiredKeys). Warns by default when false or unset.
|
|
286
|
-
*/
|
|
287
|
-
strict?: boolean;
|
|
288
|
-
/**
|
|
289
|
-
* Redaction (presentation): mask secret-like values in logs/trace.
|
|
290
|
-
*/
|
|
291
|
-
redact?: boolean;
|
|
292
|
-
/**
|
|
293
|
-
* Entropy warnings (presentation): emit once-per-key warnings for high-entropy values.
|
|
294
|
-
*/
|
|
295
|
-
warnEntropy?: boolean;
|
|
296
|
-
entropyThreshold?: number;
|
|
297
|
-
entropyMinLength?: number;
|
|
298
|
-
entropyWhitelist?: string[];
|
|
299
|
-
redactPatterns?: string[];
|
|
300
|
-
/**
|
|
301
|
-
* When true, capture child stdout/stderr and re-emit after completion.
|
|
302
|
-
* Useful for tests/CI. Default behavior is streaming via stdio: 'inherit'.
|
|
303
|
-
*/
|
|
304
|
-
capture?: boolean;
|
|
305
|
-
/**
|
|
306
|
-
* A delimited string of paths to dotenv files.
|
|
307
|
-
*/
|
|
308
|
-
paths?: string;
|
|
309
|
-
/**
|
|
310
|
-
* A delimiter string with which to split `paths`. Only used if
|
|
311
|
-
* `pathsDelimiterPattern` is not provided.
|
|
312
|
-
*/
|
|
313
|
-
pathsDelimiter?: string;
|
|
314
|
-
/**
|
|
315
|
-
* A regular expression pattern with which to split `paths`. Supersedes
|
|
316
|
-
* `pathsDelimiter`.
|
|
317
|
-
*/
|
|
318
|
-
pathsDelimiterPattern?: string;
|
|
319
|
-
/**
|
|
320
|
-
* Scripts that can be executed from the CLI, either individually or via the batch subcommand.
|
|
321
|
-
*/
|
|
322
|
-
scripts?: Scripts;
|
|
323
|
-
/**
|
|
324
|
-
* Determines how commands and scripts are executed. If `false` or
|
|
325
|
-
* `undefined`, commands are executed as plain Javascript using the default
|
|
326
|
-
* execa parser. If `true`, commands are executed using the default OS shell
|
|
327
|
-
* parser. Otherwise the user may provide a specific shell string (e.g.
|
|
328
|
-
* `/bin/bash`)
|
|
329
|
-
*/
|
|
330
|
-
shell?: string | boolean;
|
|
331
|
-
/**
|
|
332
|
-
* A delimited string of key-value pairs declaratively specifying variables &
|
|
333
|
-
* values to be loaded in addition to any dotenv files.
|
|
334
|
-
*/
|
|
335
|
-
vars?: string;
|
|
336
|
-
/**
|
|
337
|
-
* A string with which to split keys from values in `vars`. Only used if
|
|
338
|
-
* `varsDelimiterPattern` is not provided.
|
|
339
|
-
*/
|
|
340
|
-
varsAssignor?: string;
|
|
341
|
-
/**
|
|
342
|
-
* A regular expression pattern with which to split variable names from values
|
|
343
|
-
* in `vars`. Supersedes `varsAssignor`.
|
|
344
|
-
*/
|
|
345
|
-
varsAssignorPattern?: string;
|
|
346
|
-
/**
|
|
347
|
-
* A string with which to split `vars` into key-value pairs. Only used if
|
|
348
|
-
* `varsDelimiterPattern` is not provided.
|
|
349
|
-
*/
|
|
350
|
-
varsDelimiter?: string;
|
|
351
|
-
/**
|
|
352
|
-
* A regular expression pattern with which to split `vars` into key-value
|
|
353
|
-
* pairs. Supersedes `varsDelimiter`.
|
|
354
|
-
*/
|
|
355
|
-
varsDelimiterPattern?: string;
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
/**
|
|
359
|
-
* GetDotenv CLI Pre-hook Callback function type. Mutates inbound options &
|
|
360
|
-
* executes side effects within the `getDotenv` context.
|
|
361
|
-
*/
|
|
362
|
-
type GetDotenvCliPreHookCallback = (options: GetDotenvCliOptions) => Promise<void>;
|
|
363
|
-
/**
|
|
364
|
-
* GetDotenv CLI Post-hook Callback function type. Executes side effects within
|
|
365
|
-
* the `getDotenv` context.
|
|
366
|
-
*/
|
|
367
|
-
type GetDotenvCliPostHookCallback = (dotenv: ProcessEnv) => Promise<void>;
|
|
368
|
-
/**
|
|
369
|
-
* `generateGetDotenvCli` options. Defines local instance of the GetDotenv CLI and
|
|
370
|
-
* sets defaults that can be overridden by local `getdotenv.config.json` in
|
|
371
|
-
* projects that import the CLI.
|
|
372
|
-
*/
|
|
373
|
-
interface GetDotenvCliGenerateOptions extends GetDotenvCliOptions {
|
|
374
|
-
/**
|
|
375
|
-
* CLI alias. Should align with the `bin` property in `package.json`.
|
|
376
|
-
*/
|
|
377
|
-
alias: string;
|
|
378
|
-
/**
|
|
379
|
-
* Cli description (appears in CLI help).
|
|
380
|
-
*/
|
|
381
|
-
description: string;
|
|
382
|
-
/**
|
|
383
|
-
* The `import.meta.url` of the module generating the CLI.
|
|
384
|
-
*/
|
|
385
|
-
importMetaUrl: string;
|
|
386
|
-
/**
|
|
387
|
-
* Logger object (defaults to console)
|
|
388
|
-
*/
|
|
389
|
-
logger: Logger;
|
|
390
|
-
/**
|
|
391
|
-
* Mutates inbound options & executes side effects within the `getDotenv`
|
|
392
|
-
* context before executing CLI commands.
|
|
393
|
-
*/
|
|
394
|
-
preHook?: GetDotenvCliPreHookCallback;
|
|
395
|
-
/**
|
|
396
|
-
* Executes side effects within the `getDotenv` context after executing CLI
|
|
397
|
-
* commands.
|
|
398
|
-
*/
|
|
399
|
-
postHook?: GetDotenvCliPostHookCallback;
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
/**
|
|
403
|
-
* Generate a Commander CLI Command for get-dotenv.
|
|
404
|
-
* Orchestration only: delegates building and lifecycle hooks.
|
|
405
|
-
*/
|
|
406
|
-
declare const generateGetDotenvCli: (customOptions: Pick<GetDotenvCliGenerateOptions, "importMetaUrl"> & Partial<Omit<GetDotenvCliGenerateOptions, "importMetaUrl">>) => Promise<Command>;
|
|
407
|
-
|
|
408
248
|
/**
|
|
409
249
|
* Asynchronously process dotenv files of the form `.env[.<ENV>][.<PRIVATE_TOKEN>]`
|
|
410
250
|
*
|
|
@@ -474,5 +314,5 @@ declare function createCli(opts?: CreateCliOptions): {
|
|
|
474
314
|
run: (argv: string[]) => Promise<void>;
|
|
475
315
|
};
|
|
476
316
|
|
|
477
|
-
export { buildSpawnEnv, createCli, defineDynamic, dotenvExpand, dotenvExpandAll, dotenvExpandFromProcessEnv,
|
|
317
|
+
export { buildSpawnEnv, createCli, defineDynamic, dotenvExpand, dotenvExpandAll, dotenvExpandFromProcessEnv, getDotenv, getDotenvCliOptions2Options, interpolateDeep };
|
|
478
318
|
export type { CreateCliOptions, GetDotenvDynamic, GetDotenvOptions, ProcessEnv };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
/** src/cliCore/spawnEnv.ts
|
|
2
|
+
* Build a sanitized environment bag for child processes.
|
|
3
|
+
*
|
|
4
|
+
* Requirements addressed:
|
|
5
|
+
* - Provide a single helper (buildSpawnEnv) to normalize/dedupe child env.
|
|
6
|
+
* - Drop undefined values (exactOptional semantics).
|
|
7
|
+
* - On Windows, dedupe keys case-insensitively and prefer the last value,
|
|
8
|
+
* preserving the latest key's casing. Ensure HOME fallback from USERPROFILE.
|
|
9
|
+
* Normalize TMP/TEMP consistency when either is present.
|
|
10
|
+
* - On POSIX, keep keys as-is; when a temp dir key is present (TMPDIR/TMP/TEMP),
|
|
11
|
+
* ensure TMPDIR exists for downstream consumers that expect it.
|
|
12
|
+
*
|
|
13
|
+
* Adapter responsibility: pure mapping; no business logic.
|
|
14
|
+
*/
|
|
15
|
+
type SpawnEnv = Readonly<Partial<Record<string, string>>>;
|
|
16
|
+
/** Build a sanitized env for child processes from base + overlay. */
|
|
17
|
+
declare const buildSpawnEnv: (base?: NodeJS.ProcessEnv, overlay?: Record<string, string | undefined>) => SpawnEnv;
|
|
2
18
|
|
|
3
19
|
/**
|
|
4
20
|
* Minimal root options shape shared by CLI and generator layers.
|
|
@@ -49,45 +65,6 @@ type ScriptsTable<TShell extends string | boolean = string | boolean> = Record<s
|
|
|
49
65
|
shell?: TShell;
|
|
50
66
|
}>;
|
|
51
67
|
|
|
52
|
-
/**
|
|
53
|
-
* Adapter-layer augmentation: add chainable helpers to GetDotenvCli without
|
|
54
|
-
* coupling the core host to cliCore. Importing this module has side effects:
|
|
55
|
-
* it extends the prototype and merges types for consumers.
|
|
56
|
-
*/
|
|
57
|
-
declare module '../cliHost/GetDotenvCli' {
|
|
58
|
-
interface GetDotenvCli {
|
|
59
|
-
/**
|
|
60
|
-
* Attach legacy root flags to this CLI instance. Defaults come from
|
|
61
|
-
* baseRootOptionDefaults when none are provided. */
|
|
62
|
-
attachRootOptions(defaults?: Partial<RootOptionsShape>, opts?: {
|
|
63
|
-
includeCommandOption?: boolean;
|
|
64
|
-
}): this;
|
|
65
|
-
/**
|
|
66
|
-
* Install a preSubcommand hook that merges CLI flags (including parent
|
|
67
|
-
* round-trip) and resolves the dotenv context before executing actions.
|
|
68
|
-
* Defaults come from baseRootOptionDefaults when none are provided.
|
|
69
|
-
*/ passOptions(defaults?: Partial<RootOptionsShape>): this;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/** src/cliCore/spawnEnv.ts
|
|
74
|
-
* Build a sanitized environment bag for child processes.
|
|
75
|
-
*
|
|
76
|
-
* Requirements addressed:
|
|
77
|
-
* - Provide a single helper (buildSpawnEnv) to normalize/dedupe child env.
|
|
78
|
-
* - Drop undefined values (exactOptional semantics).
|
|
79
|
-
* - On Windows, dedupe keys case-insensitively and prefer the last value,
|
|
80
|
-
* preserving the latest key's casing. Ensure HOME fallback from USERPROFILE.
|
|
81
|
-
* Normalize TMP/TEMP consistency when either is present.
|
|
82
|
-
* - On POSIX, keep keys as-is; when a temp dir key is present (TMPDIR/TMP/TEMP),
|
|
83
|
-
* ensure TMPDIR exists for downstream consumers that expect it.
|
|
84
|
-
*
|
|
85
|
-
* Adapter responsibility: pure mapping; no business logic.
|
|
86
|
-
*/
|
|
87
|
-
type SpawnEnv = Readonly<Partial<Record<string, string>>>;
|
|
88
|
-
/** Build a sanitized env for child processes from base + overlay. */
|
|
89
|
-
declare const buildSpawnEnv: (base?: NodeJS.ProcessEnv, overlay?: Record<string, string | undefined>) => SpawnEnv;
|
|
90
|
-
|
|
91
68
|
type RootOptionsShapeCompat = Omit<RootOptionsShape, 'vars' | 'paths'> & {
|
|
92
69
|
vars?: string | Record<string, string | undefined>;
|
|
93
70
|
paths?: string | string[];
|
|
@@ -268,143 +245,6 @@ declare const dotenvExpandAll: (values?: ProcessEnv, options?: {
|
|
|
268
245
|
*/
|
|
269
246
|
declare const dotenvExpandFromProcessEnv: (value: string | undefined) => string | undefined;
|
|
270
247
|
|
|
271
|
-
type Scripts = Record<string, string | {
|
|
272
|
-
cmd: string;
|
|
273
|
-
shell?: string | boolean;
|
|
274
|
-
}>;
|
|
275
|
-
/**
|
|
276
|
-
* Options passed programmatically to `getDotenvCli`.
|
|
277
|
-
*/
|
|
278
|
-
interface GetDotenvCliOptions extends Omit<GetDotenvOptions, 'paths' | 'vars'> {
|
|
279
|
-
/**
|
|
280
|
-
* Logs CLI internals when true.
|
|
281
|
-
*/
|
|
282
|
-
debug?: boolean;
|
|
283
|
-
/**
|
|
284
|
-
* Strict mode: fail the run when env validation issues are detected
|
|
285
|
-
* (schema or requiredKeys). Warns by default when false or unset.
|
|
286
|
-
*/
|
|
287
|
-
strict?: boolean;
|
|
288
|
-
/**
|
|
289
|
-
* Redaction (presentation): mask secret-like values in logs/trace.
|
|
290
|
-
*/
|
|
291
|
-
redact?: boolean;
|
|
292
|
-
/**
|
|
293
|
-
* Entropy warnings (presentation): emit once-per-key warnings for high-entropy values.
|
|
294
|
-
*/
|
|
295
|
-
warnEntropy?: boolean;
|
|
296
|
-
entropyThreshold?: number;
|
|
297
|
-
entropyMinLength?: number;
|
|
298
|
-
entropyWhitelist?: string[];
|
|
299
|
-
redactPatterns?: string[];
|
|
300
|
-
/**
|
|
301
|
-
* When true, capture child stdout/stderr and re-emit after completion.
|
|
302
|
-
* Useful for tests/CI. Default behavior is streaming via stdio: 'inherit'.
|
|
303
|
-
*/
|
|
304
|
-
capture?: boolean;
|
|
305
|
-
/**
|
|
306
|
-
* A delimited string of paths to dotenv files.
|
|
307
|
-
*/
|
|
308
|
-
paths?: string;
|
|
309
|
-
/**
|
|
310
|
-
* A delimiter string with which to split `paths`. Only used if
|
|
311
|
-
* `pathsDelimiterPattern` is not provided.
|
|
312
|
-
*/
|
|
313
|
-
pathsDelimiter?: string;
|
|
314
|
-
/**
|
|
315
|
-
* A regular expression pattern with which to split `paths`. Supersedes
|
|
316
|
-
* `pathsDelimiter`.
|
|
317
|
-
*/
|
|
318
|
-
pathsDelimiterPattern?: string;
|
|
319
|
-
/**
|
|
320
|
-
* Scripts that can be executed from the CLI, either individually or via the batch subcommand.
|
|
321
|
-
*/
|
|
322
|
-
scripts?: Scripts;
|
|
323
|
-
/**
|
|
324
|
-
* Determines how commands and scripts are executed. If `false` or
|
|
325
|
-
* `undefined`, commands are executed as plain Javascript using the default
|
|
326
|
-
* execa parser. If `true`, commands are executed using the default OS shell
|
|
327
|
-
* parser. Otherwise the user may provide a specific shell string (e.g.
|
|
328
|
-
* `/bin/bash`)
|
|
329
|
-
*/
|
|
330
|
-
shell?: string | boolean;
|
|
331
|
-
/**
|
|
332
|
-
* A delimited string of key-value pairs declaratively specifying variables &
|
|
333
|
-
* values to be loaded in addition to any dotenv files.
|
|
334
|
-
*/
|
|
335
|
-
vars?: string;
|
|
336
|
-
/**
|
|
337
|
-
* A string with which to split keys from values in `vars`. Only used if
|
|
338
|
-
* `varsDelimiterPattern` is not provided.
|
|
339
|
-
*/
|
|
340
|
-
varsAssignor?: string;
|
|
341
|
-
/**
|
|
342
|
-
* A regular expression pattern with which to split variable names from values
|
|
343
|
-
* in `vars`. Supersedes `varsAssignor`.
|
|
344
|
-
*/
|
|
345
|
-
varsAssignorPattern?: string;
|
|
346
|
-
/**
|
|
347
|
-
* A string with which to split `vars` into key-value pairs. Only used if
|
|
348
|
-
* `varsDelimiterPattern` is not provided.
|
|
349
|
-
*/
|
|
350
|
-
varsDelimiter?: string;
|
|
351
|
-
/**
|
|
352
|
-
* A regular expression pattern with which to split `vars` into key-value
|
|
353
|
-
* pairs. Supersedes `varsDelimiter`.
|
|
354
|
-
*/
|
|
355
|
-
varsDelimiterPattern?: string;
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
/**
|
|
359
|
-
* GetDotenv CLI Pre-hook Callback function type. Mutates inbound options &
|
|
360
|
-
* executes side effects within the `getDotenv` context.
|
|
361
|
-
*/
|
|
362
|
-
type GetDotenvCliPreHookCallback = (options: GetDotenvCliOptions) => Promise<void>;
|
|
363
|
-
/**
|
|
364
|
-
* GetDotenv CLI Post-hook Callback function type. Executes side effects within
|
|
365
|
-
* the `getDotenv` context.
|
|
366
|
-
*/
|
|
367
|
-
type GetDotenvCliPostHookCallback = (dotenv: ProcessEnv) => Promise<void>;
|
|
368
|
-
/**
|
|
369
|
-
* `generateGetDotenvCli` options. Defines local instance of the GetDotenv CLI and
|
|
370
|
-
* sets defaults that can be overridden by local `getdotenv.config.json` in
|
|
371
|
-
* projects that import the CLI.
|
|
372
|
-
*/
|
|
373
|
-
interface GetDotenvCliGenerateOptions extends GetDotenvCliOptions {
|
|
374
|
-
/**
|
|
375
|
-
* CLI alias. Should align with the `bin` property in `package.json`.
|
|
376
|
-
*/
|
|
377
|
-
alias: string;
|
|
378
|
-
/**
|
|
379
|
-
* Cli description (appears in CLI help).
|
|
380
|
-
*/
|
|
381
|
-
description: string;
|
|
382
|
-
/**
|
|
383
|
-
* The `import.meta.url` of the module generating the CLI.
|
|
384
|
-
*/
|
|
385
|
-
importMetaUrl: string;
|
|
386
|
-
/**
|
|
387
|
-
* Logger object (defaults to console)
|
|
388
|
-
*/
|
|
389
|
-
logger: Logger;
|
|
390
|
-
/**
|
|
391
|
-
* Mutates inbound options & executes side effects within the `getDotenv`
|
|
392
|
-
* context before executing CLI commands.
|
|
393
|
-
*/
|
|
394
|
-
preHook?: GetDotenvCliPreHookCallback;
|
|
395
|
-
/**
|
|
396
|
-
* Executes side effects within the `getDotenv` context after executing CLI
|
|
397
|
-
* commands.
|
|
398
|
-
*/
|
|
399
|
-
postHook?: GetDotenvCliPostHookCallback;
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
/**
|
|
403
|
-
* Generate a Commander CLI Command for get-dotenv.
|
|
404
|
-
* Orchestration only: delegates building and lifecycle hooks.
|
|
405
|
-
*/
|
|
406
|
-
declare const generateGetDotenvCli: (customOptions: Pick<GetDotenvCliGenerateOptions, "importMetaUrl"> & Partial<Omit<GetDotenvCliGenerateOptions, "importMetaUrl">>) => Promise<Command>;
|
|
407
|
-
|
|
408
248
|
/**
|
|
409
249
|
* Asynchronously process dotenv files of the form `.env[.<ENV>][.<PRIVATE_TOKEN>]`
|
|
410
250
|
*
|
|
@@ -474,5 +314,5 @@ declare function createCli(opts?: CreateCliOptions): {
|
|
|
474
314
|
run: (argv: string[]) => Promise<void>;
|
|
475
315
|
};
|
|
476
316
|
|
|
477
|
-
export { buildSpawnEnv, createCli, defineDynamic, dotenvExpand, dotenvExpandAll, dotenvExpandFromProcessEnv,
|
|
317
|
+
export { buildSpawnEnv, createCli, defineDynamic, dotenvExpand, dotenvExpandAll, dotenvExpandFromProcessEnv, getDotenv, getDotenvCliOptions2Options, interpolateDeep };
|
|
478
318
|
export type { CreateCliOptions, GetDotenvDynamic, GetDotenvOptions, ProcessEnv };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
/** src/cliCore/spawnEnv.ts
|
|
2
|
+
* Build a sanitized environment bag for child processes.
|
|
3
|
+
*
|
|
4
|
+
* Requirements addressed:
|
|
5
|
+
* - Provide a single helper (buildSpawnEnv) to normalize/dedupe child env.
|
|
6
|
+
* - Drop undefined values (exactOptional semantics).
|
|
7
|
+
* - On Windows, dedupe keys case-insensitively and prefer the last value,
|
|
8
|
+
* preserving the latest key's casing. Ensure HOME fallback from USERPROFILE.
|
|
9
|
+
* Normalize TMP/TEMP consistency when either is present.
|
|
10
|
+
* - On POSIX, keep keys as-is; when a temp dir key is present (TMPDIR/TMP/TEMP),
|
|
11
|
+
* ensure TMPDIR exists for downstream consumers that expect it.
|
|
12
|
+
*
|
|
13
|
+
* Adapter responsibility: pure mapping; no business logic.
|
|
14
|
+
*/
|
|
15
|
+
type SpawnEnv = Readonly<Partial<Record<string, string>>>;
|
|
16
|
+
/** Build a sanitized env for child processes from base + overlay. */
|
|
17
|
+
declare const buildSpawnEnv: (base?: NodeJS.ProcessEnv, overlay?: Record<string, string | undefined>) => SpawnEnv;
|
|
2
18
|
|
|
3
19
|
/**
|
|
4
20
|
* Minimal root options shape shared by CLI and generator layers.
|
|
@@ -49,45 +65,6 @@ type ScriptsTable<TShell extends string | boolean = string | boolean> = Record<s
|
|
|
49
65
|
shell?: TShell;
|
|
50
66
|
}>;
|
|
51
67
|
|
|
52
|
-
/**
|
|
53
|
-
* Adapter-layer augmentation: add chainable helpers to GetDotenvCli without
|
|
54
|
-
* coupling the core host to cliCore. Importing this module has side effects:
|
|
55
|
-
* it extends the prototype and merges types for consumers.
|
|
56
|
-
*/
|
|
57
|
-
declare module '../cliHost/GetDotenvCli' {
|
|
58
|
-
interface GetDotenvCli {
|
|
59
|
-
/**
|
|
60
|
-
* Attach legacy root flags to this CLI instance. Defaults come from
|
|
61
|
-
* baseRootOptionDefaults when none are provided. */
|
|
62
|
-
attachRootOptions(defaults?: Partial<RootOptionsShape>, opts?: {
|
|
63
|
-
includeCommandOption?: boolean;
|
|
64
|
-
}): this;
|
|
65
|
-
/**
|
|
66
|
-
* Install a preSubcommand hook that merges CLI flags (including parent
|
|
67
|
-
* round-trip) and resolves the dotenv context before executing actions.
|
|
68
|
-
* Defaults come from baseRootOptionDefaults when none are provided.
|
|
69
|
-
*/ passOptions(defaults?: Partial<RootOptionsShape>): this;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/** src/cliCore/spawnEnv.ts
|
|
74
|
-
* Build a sanitized environment bag for child processes.
|
|
75
|
-
*
|
|
76
|
-
* Requirements addressed:
|
|
77
|
-
* - Provide a single helper (buildSpawnEnv) to normalize/dedupe child env.
|
|
78
|
-
* - Drop undefined values (exactOptional semantics).
|
|
79
|
-
* - On Windows, dedupe keys case-insensitively and prefer the last value,
|
|
80
|
-
* preserving the latest key's casing. Ensure HOME fallback from USERPROFILE.
|
|
81
|
-
* Normalize TMP/TEMP consistency when either is present.
|
|
82
|
-
* - On POSIX, keep keys as-is; when a temp dir key is present (TMPDIR/TMP/TEMP),
|
|
83
|
-
* ensure TMPDIR exists for downstream consumers that expect it.
|
|
84
|
-
*
|
|
85
|
-
* Adapter responsibility: pure mapping; no business logic.
|
|
86
|
-
*/
|
|
87
|
-
type SpawnEnv = Readonly<Partial<Record<string, string>>>;
|
|
88
|
-
/** Build a sanitized env for child processes from base + overlay. */
|
|
89
|
-
declare const buildSpawnEnv: (base?: NodeJS.ProcessEnv, overlay?: Record<string, string | undefined>) => SpawnEnv;
|
|
90
|
-
|
|
91
68
|
type RootOptionsShapeCompat = Omit<RootOptionsShape, 'vars' | 'paths'> & {
|
|
92
69
|
vars?: string | Record<string, string | undefined>;
|
|
93
70
|
paths?: string | string[];
|
|
@@ -268,143 +245,6 @@ declare const dotenvExpandAll: (values?: ProcessEnv, options?: {
|
|
|
268
245
|
*/
|
|
269
246
|
declare const dotenvExpandFromProcessEnv: (value: string | undefined) => string | undefined;
|
|
270
247
|
|
|
271
|
-
type Scripts = Record<string, string | {
|
|
272
|
-
cmd: string;
|
|
273
|
-
shell?: string | boolean;
|
|
274
|
-
}>;
|
|
275
|
-
/**
|
|
276
|
-
* Options passed programmatically to `getDotenvCli`.
|
|
277
|
-
*/
|
|
278
|
-
interface GetDotenvCliOptions extends Omit<GetDotenvOptions, 'paths' | 'vars'> {
|
|
279
|
-
/**
|
|
280
|
-
* Logs CLI internals when true.
|
|
281
|
-
*/
|
|
282
|
-
debug?: boolean;
|
|
283
|
-
/**
|
|
284
|
-
* Strict mode: fail the run when env validation issues are detected
|
|
285
|
-
* (schema or requiredKeys). Warns by default when false or unset.
|
|
286
|
-
*/
|
|
287
|
-
strict?: boolean;
|
|
288
|
-
/**
|
|
289
|
-
* Redaction (presentation): mask secret-like values in logs/trace.
|
|
290
|
-
*/
|
|
291
|
-
redact?: boolean;
|
|
292
|
-
/**
|
|
293
|
-
* Entropy warnings (presentation): emit once-per-key warnings for high-entropy values.
|
|
294
|
-
*/
|
|
295
|
-
warnEntropy?: boolean;
|
|
296
|
-
entropyThreshold?: number;
|
|
297
|
-
entropyMinLength?: number;
|
|
298
|
-
entropyWhitelist?: string[];
|
|
299
|
-
redactPatterns?: string[];
|
|
300
|
-
/**
|
|
301
|
-
* When true, capture child stdout/stderr and re-emit after completion.
|
|
302
|
-
* Useful for tests/CI. Default behavior is streaming via stdio: 'inherit'.
|
|
303
|
-
*/
|
|
304
|
-
capture?: boolean;
|
|
305
|
-
/**
|
|
306
|
-
* A delimited string of paths to dotenv files.
|
|
307
|
-
*/
|
|
308
|
-
paths?: string;
|
|
309
|
-
/**
|
|
310
|
-
* A delimiter string with which to split `paths`. Only used if
|
|
311
|
-
* `pathsDelimiterPattern` is not provided.
|
|
312
|
-
*/
|
|
313
|
-
pathsDelimiter?: string;
|
|
314
|
-
/**
|
|
315
|
-
* A regular expression pattern with which to split `paths`. Supersedes
|
|
316
|
-
* `pathsDelimiter`.
|
|
317
|
-
*/
|
|
318
|
-
pathsDelimiterPattern?: string;
|
|
319
|
-
/**
|
|
320
|
-
* Scripts that can be executed from the CLI, either individually or via the batch subcommand.
|
|
321
|
-
*/
|
|
322
|
-
scripts?: Scripts;
|
|
323
|
-
/**
|
|
324
|
-
* Determines how commands and scripts are executed. If `false` or
|
|
325
|
-
* `undefined`, commands are executed as plain Javascript using the default
|
|
326
|
-
* execa parser. If `true`, commands are executed using the default OS shell
|
|
327
|
-
* parser. Otherwise the user may provide a specific shell string (e.g.
|
|
328
|
-
* `/bin/bash`)
|
|
329
|
-
*/
|
|
330
|
-
shell?: string | boolean;
|
|
331
|
-
/**
|
|
332
|
-
* A delimited string of key-value pairs declaratively specifying variables &
|
|
333
|
-
* values to be loaded in addition to any dotenv files.
|
|
334
|
-
*/
|
|
335
|
-
vars?: string;
|
|
336
|
-
/**
|
|
337
|
-
* A string with which to split keys from values in `vars`. Only used if
|
|
338
|
-
* `varsDelimiterPattern` is not provided.
|
|
339
|
-
*/
|
|
340
|
-
varsAssignor?: string;
|
|
341
|
-
/**
|
|
342
|
-
* A regular expression pattern with which to split variable names from values
|
|
343
|
-
* in `vars`. Supersedes `varsAssignor`.
|
|
344
|
-
*/
|
|
345
|
-
varsAssignorPattern?: string;
|
|
346
|
-
/**
|
|
347
|
-
* A string with which to split `vars` into key-value pairs. Only used if
|
|
348
|
-
* `varsDelimiterPattern` is not provided.
|
|
349
|
-
*/
|
|
350
|
-
varsDelimiter?: string;
|
|
351
|
-
/**
|
|
352
|
-
* A regular expression pattern with which to split `vars` into key-value
|
|
353
|
-
* pairs. Supersedes `varsDelimiter`.
|
|
354
|
-
*/
|
|
355
|
-
varsDelimiterPattern?: string;
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
/**
|
|
359
|
-
* GetDotenv CLI Pre-hook Callback function type. Mutates inbound options &
|
|
360
|
-
* executes side effects within the `getDotenv` context.
|
|
361
|
-
*/
|
|
362
|
-
type GetDotenvCliPreHookCallback = (options: GetDotenvCliOptions) => Promise<void>;
|
|
363
|
-
/**
|
|
364
|
-
* GetDotenv CLI Post-hook Callback function type. Executes side effects within
|
|
365
|
-
* the `getDotenv` context.
|
|
366
|
-
*/
|
|
367
|
-
type GetDotenvCliPostHookCallback = (dotenv: ProcessEnv) => Promise<void>;
|
|
368
|
-
/**
|
|
369
|
-
* `generateGetDotenvCli` options. Defines local instance of the GetDotenv CLI and
|
|
370
|
-
* sets defaults that can be overridden by local `getdotenv.config.json` in
|
|
371
|
-
* projects that import the CLI.
|
|
372
|
-
*/
|
|
373
|
-
interface GetDotenvCliGenerateOptions extends GetDotenvCliOptions {
|
|
374
|
-
/**
|
|
375
|
-
* CLI alias. Should align with the `bin` property in `package.json`.
|
|
376
|
-
*/
|
|
377
|
-
alias: string;
|
|
378
|
-
/**
|
|
379
|
-
* Cli description (appears in CLI help).
|
|
380
|
-
*/
|
|
381
|
-
description: string;
|
|
382
|
-
/**
|
|
383
|
-
* The `import.meta.url` of the module generating the CLI.
|
|
384
|
-
*/
|
|
385
|
-
importMetaUrl: string;
|
|
386
|
-
/**
|
|
387
|
-
* Logger object (defaults to console)
|
|
388
|
-
*/
|
|
389
|
-
logger: Logger;
|
|
390
|
-
/**
|
|
391
|
-
* Mutates inbound options & executes side effects within the `getDotenv`
|
|
392
|
-
* context before executing CLI commands.
|
|
393
|
-
*/
|
|
394
|
-
preHook?: GetDotenvCliPreHookCallback;
|
|
395
|
-
/**
|
|
396
|
-
* Executes side effects within the `getDotenv` context after executing CLI
|
|
397
|
-
* commands.
|
|
398
|
-
*/
|
|
399
|
-
postHook?: GetDotenvCliPostHookCallback;
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
/**
|
|
403
|
-
* Generate a Commander CLI Command for get-dotenv.
|
|
404
|
-
* Orchestration only: delegates building and lifecycle hooks.
|
|
405
|
-
*/
|
|
406
|
-
declare const generateGetDotenvCli: (customOptions: Pick<GetDotenvCliGenerateOptions, "importMetaUrl"> & Partial<Omit<GetDotenvCliGenerateOptions, "importMetaUrl">>) => Promise<Command>;
|
|
407
|
-
|
|
408
248
|
/**
|
|
409
249
|
* Asynchronously process dotenv files of the form `.env[.<ENV>][.<PRIVATE_TOKEN>]`
|
|
410
250
|
*
|
|
@@ -474,5 +314,5 @@ declare function createCli(opts?: CreateCliOptions): {
|
|
|
474
314
|
run: (argv: string[]) => Promise<void>;
|
|
475
315
|
};
|
|
476
316
|
|
|
477
|
-
export { buildSpawnEnv, createCli, defineDynamic, dotenvExpand, dotenvExpandAll, dotenvExpandFromProcessEnv,
|
|
317
|
+
export { buildSpawnEnv, createCli, defineDynamic, dotenvExpand, dotenvExpandAll, dotenvExpandFromProcessEnv, getDotenv, getDotenvCliOptions2Options, interpolateDeep };
|
|
478
318
|
export type { CreateCliOptions, GetDotenvDynamic, GetDotenvOptions, ProcessEnv };
|