@karmaniverous/get-dotenv 5.2.6 → 6.0.0-1
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 +106 -70
- package/dist/cliHost.d.ts +232 -226
- package/dist/cliHost.mjs +777 -545
- package/dist/config.d.ts +7 -2
- package/dist/env-overlay.d.ts +21 -9
- package/dist/env-overlay.mjs +14 -19
- package/dist/getdotenv.cli.mjs +1366 -1163
- package/dist/index.d.ts +415 -242
- package/dist/index.mjs +1364 -1414
- package/dist/plugins-aws.d.ts +149 -94
- package/dist/plugins-aws.mjs +307 -195
- package/dist/plugins-batch.d.ts +153 -99
- package/dist/plugins-batch.mjs +277 -95
- package/dist/plugins-cmd.d.ts +140 -94
- package/dist/plugins-cmd.mjs +636 -502
- package/dist/plugins-demo.d.ts +140 -94
- package/dist/plugins-demo.mjs +237 -46
- package/dist/plugins-init.d.ts +140 -94
- package/dist/plugins-init.mjs +129 -12
- package/dist/plugins.d.ts +166 -103
- package/dist/plugins.mjs +977 -840
- package/package.json +15 -53
- package/templates/cli/ts/plugins/hello.ts +27 -6
- package/templates/config/js/getdotenv.config.js +1 -1
- package/templates/config/ts/getdotenv.config.ts +9 -2
- package/dist/cliHost.cjs +0 -1875
- package/dist/cliHost.d.cts +0 -409
- package/dist/cliHost.d.mts +0 -409
- package/dist/config.cjs +0 -252
- package/dist/config.d.cts +0 -55
- package/dist/config.d.mts +0 -55
- package/dist/env-overlay.cjs +0 -163
- package/dist/env-overlay.d.cts +0 -50
- package/dist/env-overlay.d.mts +0 -50
- package/dist/index.cjs +0 -4140
- package/dist/index.d.cts +0 -457
- package/dist/index.d.mts +0 -457
- package/dist/plugins-aws.cjs +0 -667
- package/dist/plugins-aws.d.cts +0 -158
- package/dist/plugins-aws.d.mts +0 -158
- package/dist/plugins-batch.cjs +0 -616
- package/dist/plugins-batch.d.cts +0 -180
- package/dist/plugins-batch.d.mts +0 -180
- package/dist/plugins-cmd.cjs +0 -1113
- package/dist/plugins-cmd.d.cts +0 -178
- package/dist/plugins-cmd.d.mts +0 -178
- package/dist/plugins-demo.cjs +0 -307
- package/dist/plugins-demo.d.cts +0 -158
- package/dist/plugins-demo.d.mts +0 -158
- package/dist/plugins-init.cjs +0 -289
- package/dist/plugins-init.d.cts +0 -162
- package/dist/plugins-init.d.mts +0 -162
- package/dist/plugins.cjs +0 -2283
- package/dist/plugins.d.cts +0 -210
- package/dist/plugins.d.mts +0 -210
package/dist/index.d.mts
DELETED
|
@@ -1,457 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
|
|
3
|
-
/** src/cliCore/spawnEnv.ts
|
|
4
|
-
* Build a sanitized environment bag for child processes.
|
|
5
|
-
*
|
|
6
|
-
* Requirements addressed:
|
|
7
|
-
* - Provide a single helper (buildSpawnEnv) to normalize/dedupe child env.
|
|
8
|
-
* - Drop undefined values (exactOptional semantics).
|
|
9
|
-
* - On Windows, dedupe keys case-insensitively and prefer the last value,
|
|
10
|
-
* preserving the latest key's casing. Ensure HOME fallback from USERPROFILE.
|
|
11
|
-
* Normalize TMP/TEMP consistency when either is present.
|
|
12
|
-
* - On POSIX, keep keys as-is; when a temp dir key is present (TMPDIR/TMP/TEMP),
|
|
13
|
-
* ensure TMPDIR exists for downstream consumers that expect it.
|
|
14
|
-
*
|
|
15
|
-
* Adapter responsibility: pure mapping; no business logic.
|
|
16
|
-
*/
|
|
17
|
-
type SpawnEnv = Readonly<Partial<Record<string, string>>>;
|
|
18
|
-
/** Build a sanitized env for child processes from base + overlay. */
|
|
19
|
-
declare const buildSpawnEnv: (base?: NodeJS.ProcessEnv, overlay?: Record<string, string | undefined>) => SpawnEnv;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Minimal root options shape shared by CLI and generator layers.
|
|
23
|
-
* Keep keys optional to respect exactOptionalPropertyTypes semantics.
|
|
24
|
-
*/
|
|
25
|
-
type RootOptionsShape = {
|
|
26
|
-
env?: string;
|
|
27
|
-
vars?: string;
|
|
28
|
-
command?: string;
|
|
29
|
-
outputPath?: string;
|
|
30
|
-
shell?: string | boolean;
|
|
31
|
-
loadProcess?: boolean;
|
|
32
|
-
excludeAll?: boolean;
|
|
33
|
-
excludeDynamic?: boolean;
|
|
34
|
-
excludeEnv?: boolean;
|
|
35
|
-
excludeGlobal?: boolean;
|
|
36
|
-
excludePrivate?: boolean;
|
|
37
|
-
excludePublic?: boolean;
|
|
38
|
-
log?: boolean;
|
|
39
|
-
debug?: boolean;
|
|
40
|
-
capture?: boolean;
|
|
41
|
-
strict?: boolean;
|
|
42
|
-
redact?: boolean;
|
|
43
|
-
warnEntropy?: boolean;
|
|
44
|
-
entropyThreshold?: number;
|
|
45
|
-
entropyMinLength?: number;
|
|
46
|
-
entropyWhitelist?: string[];
|
|
47
|
-
redactPatterns?: string[];
|
|
48
|
-
defaultEnv?: string;
|
|
49
|
-
dotenvToken?: string;
|
|
50
|
-
dynamicPath?: string;
|
|
51
|
-
trace?: boolean | string[];
|
|
52
|
-
paths?: string;
|
|
53
|
-
pathsDelimiter?: string;
|
|
54
|
-
pathsDelimiterPattern?: string;
|
|
55
|
-
privateToken?: string;
|
|
56
|
-
varsDelimiter?: string;
|
|
57
|
-
varsDelimiterPattern?: string;
|
|
58
|
-
varsAssignor?: string;
|
|
59
|
-
varsAssignorPattern?: string;
|
|
60
|
-
scripts?: ScriptsTable;
|
|
61
|
-
};
|
|
62
|
-
/**
|
|
63
|
-
* Scripts table shape (configurable shell type).
|
|
64
|
-
*/
|
|
65
|
-
type ScriptsTable<TShell extends string | boolean = string | boolean> = Record<string, string | {
|
|
66
|
-
cmd: string;
|
|
67
|
-
shell?: TShell;
|
|
68
|
-
}>;
|
|
69
|
-
|
|
70
|
-
type RootOptionsShapeCompat = Omit<RootOptionsShape, 'vars' | 'paths'> & {
|
|
71
|
-
vars?: string | Record<string, string | undefined>;
|
|
72
|
-
paths?: string | string[];
|
|
73
|
-
};
|
|
74
|
-
/**
|
|
75
|
-
* A minimal representation of an environment key/value mapping.
|
|
76
|
-
* Values may be `undefined` to represent "unset". */ type ProcessEnv = Record<string, string | undefined>;
|
|
77
|
-
/**
|
|
78
|
-
* Dynamic variable function signature. Receives the current expanded variables
|
|
79
|
-
* and the selected environment (if any), and returns either a string to set
|
|
80
|
-
* or `undefined` to unset/skip the variable.
|
|
81
|
-
*/
|
|
82
|
-
type GetDotenvDynamicFunction = (vars: ProcessEnv, env: string | undefined) => string | undefined;
|
|
83
|
-
type GetDotenvDynamic = Record<string, GetDotenvDynamicFunction | ReturnType<GetDotenvDynamicFunction>>;
|
|
84
|
-
type Logger = Record<string, (...args: unknown[]) => void> | typeof console;
|
|
85
|
-
/**
|
|
86
|
-
* Helper to define a dynamic map with strong inference.
|
|
87
|
-
*
|
|
88
|
-
* @example
|
|
89
|
-
* const dynamic = defineDynamic(\{ KEY: (\{ FOO = '' \}) =\> FOO + '-x' \});
|
|
90
|
-
*/
|
|
91
|
-
declare const defineDynamic: <T extends GetDotenvDynamic>(d: T) => T;
|
|
92
|
-
/**
|
|
93
|
-
* Options passed programmatically to `getDotenv`.
|
|
94
|
-
*/
|
|
95
|
-
interface GetDotenvOptions {
|
|
96
|
-
/**
|
|
97
|
-
* default target environment (used if `env` is not provided)
|
|
98
|
-
*/
|
|
99
|
-
defaultEnv?: string;
|
|
100
|
-
/**
|
|
101
|
-
* token indicating a dotenv file
|
|
102
|
-
*/
|
|
103
|
-
dotenvToken: string;
|
|
104
|
-
/**
|
|
105
|
-
* path to JS/TS module default-exporting an object keyed to dynamic variable functions
|
|
106
|
-
*/
|
|
107
|
-
dynamicPath?: string;
|
|
108
|
-
/**
|
|
109
|
-
* Programmatic dynamic variables map. When provided, this takes precedence
|
|
110
|
-
* over {@link GetDotenvOptions.dynamicPath}.
|
|
111
|
-
*/
|
|
112
|
-
dynamic?: GetDotenvDynamic;
|
|
113
|
-
/**
|
|
114
|
-
* target environment
|
|
115
|
-
*/
|
|
116
|
-
env?: string;
|
|
117
|
-
/**
|
|
118
|
-
* exclude dynamic variables from loading
|
|
119
|
-
*/
|
|
120
|
-
excludeDynamic?: boolean;
|
|
121
|
-
/**
|
|
122
|
-
* exclude environment-specific variables from loading
|
|
123
|
-
*/
|
|
124
|
-
excludeEnv?: boolean;
|
|
125
|
-
/**
|
|
126
|
-
* exclude global variables from loading
|
|
127
|
-
*/
|
|
128
|
-
excludeGlobal?: boolean;
|
|
129
|
-
/**
|
|
130
|
-
* exclude private variables from loading
|
|
131
|
-
*/
|
|
132
|
-
excludePrivate?: boolean;
|
|
133
|
-
/**
|
|
134
|
-
* exclude public variables from loading
|
|
135
|
-
*/
|
|
136
|
-
excludePublic?: boolean;
|
|
137
|
-
/**
|
|
138
|
-
* load dotenv variables to `process.env`
|
|
139
|
-
*/
|
|
140
|
-
loadProcess?: boolean;
|
|
141
|
-
/**
|
|
142
|
-
* log loaded dotenv variables to `logger`
|
|
143
|
-
*/
|
|
144
|
-
log?: boolean;
|
|
145
|
-
/**
|
|
146
|
-
* logger object (defaults to console)
|
|
147
|
-
*/
|
|
148
|
-
logger?: Logger;
|
|
149
|
-
/**
|
|
150
|
-
* if populated, writes consolidated dotenv file to this path (follows dotenvExpand rules)
|
|
151
|
-
*/
|
|
152
|
-
outputPath?: string;
|
|
153
|
-
/**
|
|
154
|
-
* array of input directory paths
|
|
155
|
-
*/
|
|
156
|
-
paths?: string[];
|
|
157
|
-
/**
|
|
158
|
-
* filename token indicating private variables
|
|
159
|
-
*/
|
|
160
|
-
privateToken?: string;
|
|
161
|
-
/**
|
|
162
|
-
* explicit variables to include
|
|
163
|
-
*/
|
|
164
|
-
vars?: ProcessEnv;
|
|
165
|
-
/**
|
|
166
|
-
* Reserved: config loader flag (no-op).
|
|
167
|
-
* The plugin-first host and generator paths already use the config
|
|
168
|
-
* loader/overlay pipeline unconditionally (no-op when no config files
|
|
169
|
-
* are present). This flag is accepted for forward compatibility but
|
|
170
|
-
* currently has no effect.
|
|
171
|
-
*/
|
|
172
|
-
useConfigLoader?: boolean;
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Converts programmatic CLI options to `getDotenv` options. *
|
|
176
|
-
* @param cliOptions - CLI options. Defaults to `{}`.
|
|
177
|
-
*
|
|
178
|
-
* @returns `getDotenv` options.
|
|
179
|
-
*/
|
|
180
|
-
declare const getDotenvCliOptions2Options: ({ paths, pathsDelimiter, pathsDelimiterPattern, vars, varsAssignor, varsAssignorPattern, varsDelimiter, varsDelimiterPattern, ...rest }: RootOptionsShapeCompat) => GetDotenvOptions;
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* Recursively expands environment variables in a string. Variables may be
|
|
184
|
-
* presented with optional default as `$VAR[:default]` or `${VAR[:default]}`.
|
|
185
|
-
* Unknown variables will expand to an empty string.
|
|
186
|
-
*
|
|
187
|
-
* @param value - The string to expand.
|
|
188
|
-
* @param ref - The reference object to use for variable expansion.
|
|
189
|
-
* @returns The expanded string.
|
|
190
|
-
*
|
|
191
|
-
* @example
|
|
192
|
-
* ```ts
|
|
193
|
-
* process.env.FOO = 'bar';
|
|
194
|
-
* dotenvExpand('Hello $FOO'); // "Hello bar"
|
|
195
|
-
* dotenvExpand('Hello $BAZ:world'); // "Hello world"
|
|
196
|
-
* ```
|
|
197
|
-
*
|
|
198
|
-
* @remarks
|
|
199
|
-
* The expansion is recursive. If a referenced variable itself contains
|
|
200
|
-
* references, those will also be expanded until a stable value is reached.
|
|
201
|
-
* Escaped references (e.g. `\$FOO`) are preserved as literals.
|
|
202
|
-
*/
|
|
203
|
-
declare const dotenvExpand: (value: string | undefined, ref?: ProcessEnv) => string | undefined;
|
|
204
|
-
/**
|
|
205
|
-
* Recursively expands environment variables in the values of a JSON object.
|
|
206
|
-
* Variables may be presented with optional default as `$VAR[:default]` or
|
|
207
|
-
* `${VAR[:default]}`. Unknown variables will expand to an empty string.
|
|
208
|
-
*
|
|
209
|
-
* @param values - The values object to expand.
|
|
210
|
-
* @param options - Expansion options.
|
|
211
|
-
* @returns The value object with expanded string values.
|
|
212
|
-
*
|
|
213
|
-
* @example
|
|
214
|
-
* ```ts
|
|
215
|
-
* process.env.FOO = 'bar';
|
|
216
|
-
* dotenvExpandAll({ A: '$FOO', B: 'x${FOO}y' });
|
|
217
|
-
* // => { A: "bar", B: "xbary" }
|
|
218
|
-
* ```
|
|
219
|
-
*
|
|
220
|
-
* @remarks
|
|
221
|
-
* Options:
|
|
222
|
-
* - ref: The reference object to use for expansion (defaults to process.env).
|
|
223
|
-
* - progressive: Whether to progressively add expanded values to the set of
|
|
224
|
-
* reference keys.
|
|
225
|
-
*
|
|
226
|
-
* When `progressive` is true, each expanded key becomes available for
|
|
227
|
-
* subsequent expansions in the same object (left-to-right by object key order).
|
|
228
|
-
*/
|
|
229
|
-
declare const dotenvExpandAll: (values?: ProcessEnv, options?: {
|
|
230
|
-
ref?: ProcessEnv;
|
|
231
|
-
progressive?: boolean;
|
|
232
|
-
}) => Record<string, string | undefined>;
|
|
233
|
-
/**
|
|
234
|
-
* Recursively expands environment variables in a string using `process.env` as
|
|
235
|
-
* the expansion reference. Variables may be presented with optional default as
|
|
236
|
-
* `$VAR[:default]` or `${VAR[:default]}`. Unknown variables will expand to an
|
|
237
|
-
* empty string.
|
|
238
|
-
*
|
|
239
|
-
* @param value - The string to expand.
|
|
240
|
-
* @returns The expanded string.
|
|
241
|
-
*
|
|
242
|
-
* @example
|
|
243
|
-
* ```ts
|
|
244
|
-
* process.env.FOO = 'bar';
|
|
245
|
-
* dotenvExpandFromProcessEnv('Hello $FOO'); // "Hello bar"
|
|
246
|
-
* ```
|
|
247
|
-
*/
|
|
248
|
-
declare const dotenvExpandFromProcessEnv: (value: string | undefined) => string | undefined;
|
|
249
|
-
|
|
250
|
-
type Scripts = Record<string, string | {
|
|
251
|
-
cmd: string;
|
|
252
|
-
shell?: string | boolean;
|
|
253
|
-
}>;
|
|
254
|
-
/**
|
|
255
|
-
* Options passed programmatically to `getDotenvCli`.
|
|
256
|
-
*/
|
|
257
|
-
interface GetDotenvCliOptions extends Omit<GetDotenvOptions, 'paths' | 'vars'> {
|
|
258
|
-
/**
|
|
259
|
-
* Logs CLI internals when true.
|
|
260
|
-
*/
|
|
261
|
-
debug?: boolean;
|
|
262
|
-
/**
|
|
263
|
-
* Strict mode: fail the run when env validation issues are detected
|
|
264
|
-
* (schema or requiredKeys). Warns by default when false or unset.
|
|
265
|
-
*/
|
|
266
|
-
strict?: boolean;
|
|
267
|
-
/**
|
|
268
|
-
* Redaction (presentation): mask secret-like values in logs/trace.
|
|
269
|
-
*/
|
|
270
|
-
redact?: boolean;
|
|
271
|
-
/**
|
|
272
|
-
* Entropy warnings (presentation): emit once-per-key warnings for high-entropy values.
|
|
273
|
-
*/
|
|
274
|
-
warnEntropy?: boolean;
|
|
275
|
-
entropyThreshold?: number;
|
|
276
|
-
entropyMinLength?: number;
|
|
277
|
-
entropyWhitelist?: string[];
|
|
278
|
-
redactPatterns?: string[];
|
|
279
|
-
/**
|
|
280
|
-
* When true, capture child stdout/stderr and re-emit after completion.
|
|
281
|
-
* Useful for tests/CI. Default behavior is streaming via stdio: 'inherit'.
|
|
282
|
-
*/
|
|
283
|
-
capture?: boolean;
|
|
284
|
-
/**
|
|
285
|
-
* A delimited string of paths to dotenv files.
|
|
286
|
-
*/
|
|
287
|
-
paths?: string;
|
|
288
|
-
/**
|
|
289
|
-
* A delimiter string with which to split `paths`. Only used if
|
|
290
|
-
* `pathsDelimiterPattern` is not provided.
|
|
291
|
-
*/
|
|
292
|
-
pathsDelimiter?: string;
|
|
293
|
-
/**
|
|
294
|
-
* A regular expression pattern with which to split `paths`. Supersedes
|
|
295
|
-
* `pathsDelimiter`.
|
|
296
|
-
*/
|
|
297
|
-
pathsDelimiterPattern?: string;
|
|
298
|
-
/**
|
|
299
|
-
* Scripts that can be executed from the CLI, either individually or via the batch subcommand.
|
|
300
|
-
*/
|
|
301
|
-
scripts?: Scripts;
|
|
302
|
-
/**
|
|
303
|
-
* Determines how commands and scripts are executed. If `false` or
|
|
304
|
-
* `undefined`, commands are executed as plain Javascript using the default
|
|
305
|
-
* execa parser. If `true`, commands are executed using the default OS shell
|
|
306
|
-
* parser. Otherwise the user may provide a specific shell string (e.g.
|
|
307
|
-
* `/bin/bash`)
|
|
308
|
-
*/
|
|
309
|
-
shell?: string | boolean;
|
|
310
|
-
/**
|
|
311
|
-
* A delimited string of key-value pairs declaratively specifying variables &
|
|
312
|
-
* values to be loaded in addition to any dotenv files.
|
|
313
|
-
*/
|
|
314
|
-
vars?: string;
|
|
315
|
-
/**
|
|
316
|
-
* A string with which to split keys from values in `vars`. Only used if
|
|
317
|
-
* `varsDelimiterPattern` is not provided.
|
|
318
|
-
*/
|
|
319
|
-
varsAssignor?: string;
|
|
320
|
-
/**
|
|
321
|
-
* A regular expression pattern with which to split variable names from values
|
|
322
|
-
* in `vars`. Supersedes `varsAssignor`.
|
|
323
|
-
*/
|
|
324
|
-
varsAssignorPattern?: string;
|
|
325
|
-
/**
|
|
326
|
-
* A string with which to split `vars` into key-value pairs. Only used if
|
|
327
|
-
* `varsDelimiterPattern` is not provided.
|
|
328
|
-
*/
|
|
329
|
-
varsDelimiter?: string;
|
|
330
|
-
/**
|
|
331
|
-
* A regular expression pattern with which to split `vars` into key-value
|
|
332
|
-
* pairs. Supersedes `varsDelimiter`.
|
|
333
|
-
*/
|
|
334
|
-
varsDelimiterPattern?: string;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
/**
|
|
338
|
-
* GetDotenv CLI Pre-hook Callback function type. Mutates inbound options &
|
|
339
|
-
* executes side effects within the `getDotenv` context.
|
|
340
|
-
*/
|
|
341
|
-
type GetDotenvCliPreHookCallback = (options: GetDotenvCliOptions) => Promise<void>;
|
|
342
|
-
/**
|
|
343
|
-
* GetDotenv CLI Post-hook Callback function type. Executes side effects within
|
|
344
|
-
* the `getDotenv` context.
|
|
345
|
-
*/
|
|
346
|
-
type GetDotenvCliPostHookCallback = (dotenv: ProcessEnv) => Promise<void>;
|
|
347
|
-
/**
|
|
348
|
-
* `generateGetDotenvCli` options. Defines local instance of the GetDotenv CLI and
|
|
349
|
-
* sets defaults that can be overridden by local `getdotenv.config.json` in
|
|
350
|
-
* projects that import the CLI.
|
|
351
|
-
*/
|
|
352
|
-
interface GetDotenvCliGenerateOptions extends GetDotenvCliOptions {
|
|
353
|
-
/**
|
|
354
|
-
* CLI alias. Should align with the `bin` property in `package.json`.
|
|
355
|
-
*/
|
|
356
|
-
alias: string;
|
|
357
|
-
/**
|
|
358
|
-
* Cli description (appears in CLI help).
|
|
359
|
-
*/
|
|
360
|
-
description: string;
|
|
361
|
-
/**
|
|
362
|
-
* The `import.meta.url` of the module generating the CLI.
|
|
363
|
-
*/
|
|
364
|
-
importMetaUrl: string;
|
|
365
|
-
/**
|
|
366
|
-
* Logger object (defaults to console)
|
|
367
|
-
*/
|
|
368
|
-
logger: Logger;
|
|
369
|
-
/**
|
|
370
|
-
* Mutates inbound options & executes side effects within the `getDotenv`
|
|
371
|
-
* context before executing CLI commands.
|
|
372
|
-
*/
|
|
373
|
-
preHook?: GetDotenvCliPreHookCallback;
|
|
374
|
-
/**
|
|
375
|
-
* Executes side effects within the `getDotenv` context after executing CLI
|
|
376
|
-
* commands.
|
|
377
|
-
*/
|
|
378
|
-
postHook?: GetDotenvCliPostHookCallback;
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
/**
|
|
382
|
-
* Generate a Commander CLI Command for get-dotenv.
|
|
383
|
-
* Orchestration only: delegates building and lifecycle hooks.
|
|
384
|
-
*/
|
|
385
|
-
declare const generateGetDotenvCli: (customOptions: Pick<GetDotenvCliGenerateOptions, "importMetaUrl"> & Partial<Omit<GetDotenvCliGenerateOptions, "importMetaUrl">>) => Promise<Command>;
|
|
386
|
-
|
|
387
|
-
/**
|
|
388
|
-
* Asynchronously process dotenv files of the form `.env[.<ENV>][.<PRIVATE_TOKEN>]`
|
|
389
|
-
*
|
|
390
|
-
* @param options - `GetDotenvOptions` object
|
|
391
|
-
* @returns The combined parsed dotenv object.
|
|
392
|
-
* * @example Load from the project root with default tokens
|
|
393
|
-
* ```ts
|
|
394
|
-
* const vars = await getDotenv();
|
|
395
|
-
* console.log(vars.MY_SETTING);
|
|
396
|
-
* ```
|
|
397
|
-
*
|
|
398
|
-
* @example Load from multiple paths and a specific environment
|
|
399
|
-
* ```ts
|
|
400
|
-
* const vars = await getDotenv({
|
|
401
|
-
* env: 'dev',
|
|
402
|
-
* dotenvToken: '.testenv',
|
|
403
|
-
* privateToken: 'secret',
|
|
404
|
-
* paths: ['./', './packages/app'],
|
|
405
|
-
* });
|
|
406
|
-
* ```
|
|
407
|
-
*
|
|
408
|
-
* @example Use dynamic variables
|
|
409
|
-
* ```ts
|
|
410
|
-
* // .env.js default-exports: { DYNAMIC: ({ PREV }) => `${PREV}-suffix` }
|
|
411
|
-
* const vars = await getDotenv({ dynamicPath: '.env.js' });
|
|
412
|
-
* ```
|
|
413
|
-
*
|
|
414
|
-
* @remarks
|
|
415
|
-
* - When {@link GetDotenvOptions.loadProcess} is true, the resulting variables are merged
|
|
416
|
-
* into `process.env` as a side effect.
|
|
417
|
-
* - When {@link GetDotenvOptions.outputPath} is provided, a consolidated dotenv file is written.
|
|
418
|
-
* The path is resolved after expansion, so it may reference previously loaded vars.
|
|
419
|
-
*
|
|
420
|
-
* @throws Error when a dynamic module is present but cannot be imported.
|
|
421
|
-
* @throws Error when an output path was requested but could not be resolved.
|
|
422
|
-
*/
|
|
423
|
-
declare const getDotenv: (options?: Partial<GetDotenvOptions>) => Promise<ProcessEnv>;
|
|
424
|
-
|
|
425
|
-
/**
|
|
426
|
-
* Deeply interpolate string leaves against envRef.
|
|
427
|
-
* Arrays are not recursed into; they are returned unchanged.
|
|
428
|
-
*
|
|
429
|
-
* @typeParam T - Shape of the input value.
|
|
430
|
-
* @param value - Input value (object/array/primitive).
|
|
431
|
-
* @param envRef - Reference environment for interpolation.
|
|
432
|
-
* @returns A new value with string leaves interpolated.
|
|
433
|
-
*/
|
|
434
|
-
declare const interpolateDeep: <T>(value: T, envRef: ProcessEnv) => T;
|
|
435
|
-
|
|
436
|
-
/**
|
|
437
|
-
* Create a get-dotenv CLI host with included plugins.
|
|
438
|
-
*
|
|
439
|
-
* Options:
|
|
440
|
-
* - alias: command name used for help/argv scaffolding (default: "getdotenv")
|
|
441
|
-
* - branding: optional help header; when omitted, brand() uses "<alias> v<version>"
|
|
442
|
-
*
|
|
443
|
-
* Usage:
|
|
444
|
-
* import \{ createCli \} from '\@karmaniverous/get-dotenv';
|
|
445
|
-
* await createCli(\{ alias: 'getdotenv', branding: 'getdotenv vX.Y.Z' \})
|
|
446
|
-
* .run(process.argv.slice(2));
|
|
447
|
-
*/
|
|
448
|
-
type CreateCliOptions = {
|
|
449
|
-
alias?: string;
|
|
450
|
-
branding?: string;
|
|
451
|
-
};
|
|
452
|
-
declare function createCli(opts?: CreateCliOptions): {
|
|
453
|
-
run: (argv: string[]) => Promise<void>;
|
|
454
|
-
};
|
|
455
|
-
|
|
456
|
-
export { buildSpawnEnv, createCli, defineDynamic, dotenvExpand, dotenvExpandAll, dotenvExpandFromProcessEnv, generateGetDotenvCli, getDotenv, getDotenvCliOptions2Options, interpolateDeep };
|
|
457
|
-
export type { CreateCliOptions, GetDotenvDynamic, GetDotenvOptions, ProcessEnv };
|