@karmaniverous/get-dotenv 6.2.4 → 6.4.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 +1 -0
- package/dist/chunks/{AwsRestJsonProtocol-Bq1HE-Ln.mjs → AwsRestJsonProtocol-fYZqn-kW.mjs} +2 -2
- package/dist/chunks/{createCli-BY6_cfZr.mjs → createCli-BnRdfRRL.mjs} +7 -6
- package/dist/chunks/{externalDataInterceptor-CbsdEYa-.mjs → externalDataInterceptor-CILOLqbB.mjs} +2 -2
- package/dist/chunks/{getSSOTokenFromFile-hUSpR7Wf.mjs → getSSOTokenFromFile-BwMkZ_yT.mjs} +1 -1
- package/dist/chunks/{index-C_wqbTwI.mjs → index-0-nP97ri.mjs} +7 -6
- package/dist/chunks/{index-CeCufHlm.mjs → index-70Dm0f1N.mjs} +11 -10
- package/dist/chunks/{index-BPYF6K_G.mjs → index-BhVOypA1.mjs} +9 -8
- package/dist/chunks/{index-cIunyiUQ.mjs → index-CcwT4HJK.mjs} +6 -5
- package/dist/chunks/{index-BpCF5UKx.mjs → index-D8UL3w94.mjs} +6 -5
- package/dist/chunks/{index-Cu7rdyqN.mjs → index-DLNhHC15.mjs} +9 -8
- package/dist/chunks/{index-Dp1Ip6Ra.mjs → index-DWqbxY8Y.mjs} +11 -10
- package/dist/chunks/{index-c7zKtEuy.mjs → index-Du51s-Z0.mjs} +8 -7
- package/dist/chunks/{index-B5JKTBOL.mjs → index-DuSz0ul6.mjs} +8 -7
- package/dist/chunks/{index-DWAtHEA-.mjs → index-OeNCYa8T.mjs} +6 -5
- package/dist/chunks/{index-DyU5pKKi.mjs → index-_FP0whjC.mjs} +6 -5
- package/dist/chunks/{index-BEJFiHMX.mjs → index-o5zJ9PWL.mjs} +15 -15
- package/dist/chunks/{index-Bc3h0a95.mjs → index-r0Me7-sT.mjs} +112 -6
- package/dist/chunks/{loadSso-w1eTVg0O.mjs → loadSso-CLR1fKci.mjs} +8 -7
- package/dist/chunks/{loader-DnhPeGfq.mjs → loader-CePOf74i.mjs} +1 -0
- package/dist/chunks/{parseKnownFiles-B9cDK21V.mjs → parseKnownFiles-BQvmJ0HK.mjs} +1 -1
- package/dist/chunks/readDotenvCascade-DfFkWMjs.mjs +546 -0
- package/dist/chunks/{readMergedOptions-Nt0TR7dX.mjs → readMergedOptions-B7VdLROn.mjs} +62 -272
- package/dist/chunks/{resolveCliOptions-TFRzhB2c.mjs → resolveCliOptions-pgUXHJtj.mjs} +2 -1
- package/dist/chunks/{sdk-stream-mixin-BZoJ5jy9.mjs → sdk-stream-mixin-ecbbBR0l.mjs} +1 -1
- package/dist/chunks/{spawnEnv-CN8a7cNR.mjs → spawnEnv-CQwFu7ZJ.mjs} +2 -1
- package/dist/chunks/{types-DJ-BGABd.mjs → types-CVDR-Sjk.mjs} +1 -1
- package/dist/cli.d.ts +218 -84
- package/dist/cli.mjs +10 -10
- package/dist/cliHost.d.ts +218 -84
- package/dist/cliHost.mjs +8 -7
- package/dist/config.mjs +2 -1
- package/dist/env-overlay.d.ts +304 -2
- package/dist/env-overlay.mjs +38 -1
- package/dist/getdotenv.cli.mjs +10 -10
- package/dist/index.d.ts +703 -86
- package/dist/index.mjs +862 -13
- package/dist/plugins-aws.d.ts +153 -19
- package/dist/plugins-aws.mjs +5 -4
- package/dist/plugins-batch.d.ts +153 -19
- package/dist/plugins-batch.mjs +5 -4
- package/dist/plugins-cmd.d.ts +153 -19
- package/dist/plugins-cmd.mjs +7 -6
- package/dist/plugins-init.d.ts +153 -19
- package/dist/plugins-init.mjs +4 -4
- package/dist/plugins.d.ts +153 -19
- package/dist/plugins.mjs +9 -9
- package/package.json +1 -1
- package/dist/chunks/overlayEnv-Bs2kVayG.mjs +0 -234
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { Option, Command } from '@commander-js/extra-typings';
|
|
3
|
-
import {
|
|
4
|
-
import { nanoid } from 'nanoid';
|
|
5
|
-
import path from 'path';
|
|
3
|
+
import { g as dotenvExpand, r as readDotenvCascadeWithProvenance, o as overlayEnvWithProvenance, b as applyDynamicMapWithProvenance, l as loadDynamicModuleDefault, h as dotenvExpandFromProcessEnv } from './readDotenvCascade-DfFkWMjs.mjs';
|
|
6
4
|
import fs from 'fs-extra';
|
|
5
|
+
import 'node:path';
|
|
6
|
+
import 'nanoid';
|
|
7
|
+
import path from 'path';
|
|
7
8
|
import 'crypto';
|
|
8
9
|
import { fileURLToPath } from 'url';
|
|
9
|
-
import
|
|
10
|
-
import { g as getDotenvOptionsSchemaResolved, r as resolveGetDotenvConfigSources } from './loader-
|
|
10
|
+
import 'dotenv';
|
|
11
|
+
import { g as getDotenvOptionsSchemaResolved, r as resolveGetDotenvConfigSources } from './loader-CePOf74i.mjs';
|
|
11
12
|
import { packageDirectory } from 'package-directory';
|
|
12
13
|
|
|
13
14
|
/** @internal */
|
|
@@ -113,14 +114,6 @@ const interpolateDeep = (value, envRef) => {
|
|
|
113
114
|
* @param obj - Object to filter.
|
|
114
115
|
* @returns A shallow copy of `obj` without keys whose value is `undefined`.
|
|
115
116
|
*/
|
|
116
|
-
function omitUndefined(obj) {
|
|
117
|
-
const out = {};
|
|
118
|
-
for (const [k, v] of Object.entries(obj)) {
|
|
119
|
-
if (v !== undefined)
|
|
120
|
-
out[k] = v;
|
|
121
|
-
}
|
|
122
|
-
return out;
|
|
123
|
-
}
|
|
124
117
|
/**
|
|
125
118
|
* Specialized helper for env-like maps: drop undefined and return string-only.
|
|
126
119
|
*
|
|
@@ -137,111 +130,6 @@ function omitUndefinedRecord(obj) {
|
|
|
137
130
|
return out;
|
|
138
131
|
}
|
|
139
132
|
|
|
140
|
-
/** src/diagnostics/entropy.ts
|
|
141
|
-
* Entropy diagnostics (presentation-only).
|
|
142
|
-
* - Gated by min length and printable ASCII.
|
|
143
|
-
* - Warn once per key per run when bits/char \>= threshold.
|
|
144
|
-
* - Supports whitelist patterns to suppress known-noise keys.
|
|
145
|
-
*/
|
|
146
|
-
const warned = new Set();
|
|
147
|
-
const isPrintableAscii = (s) => /^[\x20-\x7E]+$/.test(s);
|
|
148
|
-
const compile$1 = (patterns) => (patterns ?? []).map((p) => (typeof p === 'string' ? new RegExp(p, 'i') : p));
|
|
149
|
-
const whitelisted = (key, regs) => regs.some((re) => re.test(key));
|
|
150
|
-
const shannonBitsPerChar = (s) => {
|
|
151
|
-
const freq = new Map();
|
|
152
|
-
for (const ch of s)
|
|
153
|
-
freq.set(ch, (freq.get(ch) ?? 0) + 1);
|
|
154
|
-
const n = s.length;
|
|
155
|
-
let h = 0;
|
|
156
|
-
for (const c of freq.values()) {
|
|
157
|
-
const p = c / n;
|
|
158
|
-
h -= p * Math.log2(p);
|
|
159
|
-
}
|
|
160
|
-
return h;
|
|
161
|
-
};
|
|
162
|
-
/**
|
|
163
|
-
* Maybe emit a one-line entropy warning for a key.
|
|
164
|
-
* Caller supplies an `emit(line)` function; the helper ensures once-per-key.
|
|
165
|
-
*/
|
|
166
|
-
const maybeWarnEntropy = (key, value, origin, opts, emit) => {
|
|
167
|
-
if (!opts || opts.warnEntropy === false)
|
|
168
|
-
return;
|
|
169
|
-
if (warned.has(key))
|
|
170
|
-
return;
|
|
171
|
-
const v = value ?? '';
|
|
172
|
-
const minLen = Math.max(0, opts.entropyMinLength ?? 16);
|
|
173
|
-
const threshold = opts.entropyThreshold ?? 3.8;
|
|
174
|
-
if (v.length < minLen)
|
|
175
|
-
return;
|
|
176
|
-
if (!isPrintableAscii(v))
|
|
177
|
-
return;
|
|
178
|
-
const wl = compile$1(opts.entropyWhitelist);
|
|
179
|
-
if (whitelisted(key, wl))
|
|
180
|
-
return;
|
|
181
|
-
const bpc = shannonBitsPerChar(v);
|
|
182
|
-
if (bpc >= threshold) {
|
|
183
|
-
warned.add(key);
|
|
184
|
-
emit(`[entropy] key=${key} score=${bpc.toFixed(2)} len=${String(v.length)} origin=${origin}`);
|
|
185
|
-
}
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
const DEFAULT_PATTERNS = [
|
|
189
|
-
'\\bsecret\\b',
|
|
190
|
-
'\\btoken\\b',
|
|
191
|
-
'\\bpass(word)?\\b',
|
|
192
|
-
'\\bapi[_-]?key\\b',
|
|
193
|
-
'\\bkey\\b',
|
|
194
|
-
];
|
|
195
|
-
const compile = (patterns) => (patterns && patterns.length > 0 ? patterns : DEFAULT_PATTERNS).map((p) => typeof p === 'string' ? new RegExp(p, 'i') : p);
|
|
196
|
-
const shouldRedactKey = (key, regs) => regs.some((re) => re.test(key));
|
|
197
|
-
const MASK = '[redacted]';
|
|
198
|
-
/**
|
|
199
|
-
* Redact a single displayed value according to key/patterns.
|
|
200
|
-
* Returns the original value when redaction is disabled or key is not matched.
|
|
201
|
-
*/
|
|
202
|
-
const redactDisplay = (key, value, opts) => {
|
|
203
|
-
if (!value)
|
|
204
|
-
return value;
|
|
205
|
-
if (!opts?.redact)
|
|
206
|
-
return value;
|
|
207
|
-
const regs = compile(opts.redactPatterns);
|
|
208
|
-
return shouldRedactKey(key, regs) ? MASK : value;
|
|
209
|
-
};
|
|
210
|
-
/**
|
|
211
|
-
* Produce a shallow redacted copy of an env-like object for display.
|
|
212
|
-
*/
|
|
213
|
-
const redactObject = (obj, opts) => {
|
|
214
|
-
if (!opts?.redact)
|
|
215
|
-
return { ...obj };
|
|
216
|
-
const regs = compile(opts.redactPatterns);
|
|
217
|
-
const out = {};
|
|
218
|
-
for (const [k, v] of Object.entries(obj)) {
|
|
219
|
-
out[k] = v && shouldRedactKey(k, regs) ? MASK : v;
|
|
220
|
-
}
|
|
221
|
-
return out;
|
|
222
|
-
};
|
|
223
|
-
/**
|
|
224
|
-
* Utility to redact three related displayed values (parent/dotenv/final)
|
|
225
|
-
* consistently for trace lines.
|
|
226
|
-
*/
|
|
227
|
-
const redactTriple = (key, triple, opts) => {
|
|
228
|
-
if (!opts?.redact)
|
|
229
|
-
return triple;
|
|
230
|
-
const regs = compile(opts.redactPatterns);
|
|
231
|
-
const maskIf = (v) => (v && shouldRedactKey(key, regs) ? MASK : v);
|
|
232
|
-
const out = {};
|
|
233
|
-
const p = maskIf(triple.parent);
|
|
234
|
-
const d = maskIf(triple.dotenv);
|
|
235
|
-
const f = maskIf(triple.final);
|
|
236
|
-
if (p !== undefined)
|
|
237
|
-
out.parent = p;
|
|
238
|
-
if (d !== undefined)
|
|
239
|
-
out.dotenv = d;
|
|
240
|
-
if (f !== undefined)
|
|
241
|
-
out.final = f;
|
|
242
|
-
return out;
|
|
243
|
-
};
|
|
244
|
-
|
|
245
133
|
/**
|
|
246
134
|
* Base root CLI defaults (shared; kept untyped here to avoid cross-layer deps).
|
|
247
135
|
* Used as the bottom layer for CLI option resolution.
|
|
@@ -382,131 +270,6 @@ const resolveGetDotenvOptions = (customOptions) => {
|
|
|
382
270
|
});
|
|
383
271
|
};
|
|
384
272
|
|
|
385
|
-
/**
|
|
386
|
-
* Asynchronously read a dotenv file & parse it into an object.
|
|
387
|
-
*
|
|
388
|
-
* @param path - Path to dotenv file.
|
|
389
|
-
* @returns The parsed dotenv object.
|
|
390
|
-
*/
|
|
391
|
-
const readDotenv = async (path) => {
|
|
392
|
-
try {
|
|
393
|
-
return (await fs.exists(path)) ? parse(await fs.readFile(path)) : {};
|
|
394
|
-
}
|
|
395
|
-
catch {
|
|
396
|
-
return {};
|
|
397
|
-
}
|
|
398
|
-
};
|
|
399
|
-
|
|
400
|
-
async function getDotenv(options = {}) {
|
|
401
|
-
// Apply defaults.
|
|
402
|
-
const { defaultEnv, dotenvToken = '.env', dynamicPath, env, excludeDynamic = false, excludeEnv = false, excludeGlobal = false, excludePrivate = false, excludePublic = false, loadProcess = false, log = false, logger = console, outputPath, paths = [], privateToken = 'local', vars = {}, } = await resolveGetDotenvOptions(options);
|
|
403
|
-
// Read .env files.
|
|
404
|
-
const loaded = paths.length
|
|
405
|
-
? await paths.reduce(async (e, p) => {
|
|
406
|
-
const publicGlobal = excludePublic || excludeGlobal
|
|
407
|
-
? Promise.resolve({})
|
|
408
|
-
: readDotenv(path.resolve(p, dotenvToken));
|
|
409
|
-
const publicEnv = excludePublic || excludeEnv || (!env && !defaultEnv)
|
|
410
|
-
? Promise.resolve({})
|
|
411
|
-
: readDotenv(path.resolve(p, `${dotenvToken}.${env ?? defaultEnv ?? ''}`));
|
|
412
|
-
const privateGlobal = excludePrivate || excludeGlobal
|
|
413
|
-
? Promise.resolve({})
|
|
414
|
-
: readDotenv(path.resolve(p, `${dotenvToken}.${privateToken}`));
|
|
415
|
-
const privateEnv = excludePrivate || excludeEnv || (!env && !defaultEnv)
|
|
416
|
-
? Promise.resolve({})
|
|
417
|
-
: readDotenv(path.resolve(p, `${dotenvToken}.${env ?? defaultEnv ?? ''}.${privateToken}`));
|
|
418
|
-
const [eResolved, publicGlobalResolved, publicEnvResolved, privateGlobalResolved, privateEnvResolved,] = await Promise.all([
|
|
419
|
-
e,
|
|
420
|
-
publicGlobal,
|
|
421
|
-
publicEnv,
|
|
422
|
-
privateGlobal,
|
|
423
|
-
privateEnv,
|
|
424
|
-
]);
|
|
425
|
-
return {
|
|
426
|
-
...eResolved,
|
|
427
|
-
...publicGlobalResolved,
|
|
428
|
-
...publicEnvResolved,
|
|
429
|
-
...privateGlobalResolved,
|
|
430
|
-
...privateEnvResolved,
|
|
431
|
-
};
|
|
432
|
-
}, Promise.resolve({}))
|
|
433
|
-
: {};
|
|
434
|
-
const outputKey = nanoid();
|
|
435
|
-
const dotenv = dotenvExpandAll({
|
|
436
|
-
...loaded,
|
|
437
|
-
...vars,
|
|
438
|
-
...(outputPath ? { [outputKey]: outputPath } : {}),
|
|
439
|
-
}, { progressive: true });
|
|
440
|
-
// Process dynamic variables. Programmatic option takes precedence over path.
|
|
441
|
-
if (!excludeDynamic) {
|
|
442
|
-
let dynamic = undefined;
|
|
443
|
-
if (options.dynamic && Object.keys(options.dynamic).length > 0) {
|
|
444
|
-
dynamic = options.dynamic;
|
|
445
|
-
}
|
|
446
|
-
else if (dynamicPath) {
|
|
447
|
-
const absDynamicPath = path.resolve(dynamicPath);
|
|
448
|
-
await loadAndApplyDynamic(dotenv, absDynamicPath, env ?? defaultEnv, 'getdotenv-dynamic');
|
|
449
|
-
}
|
|
450
|
-
if (dynamic) {
|
|
451
|
-
try {
|
|
452
|
-
applyDynamicMap(dotenv, dynamic, env ?? defaultEnv);
|
|
453
|
-
}
|
|
454
|
-
catch {
|
|
455
|
-
throw new Error(`Unable to evaluate dynamic variables.`);
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
// Write output file.
|
|
460
|
-
let resultDotenv = dotenv;
|
|
461
|
-
if (outputPath) {
|
|
462
|
-
const outputPathResolved = dotenv[outputKey];
|
|
463
|
-
if (!outputPathResolved)
|
|
464
|
-
throw new Error('Output path not found.');
|
|
465
|
-
const { [outputKey]: _omitted, ...dotenvForOutput } = dotenv;
|
|
466
|
-
await writeDotenvFile(outputPathResolved, dotenvForOutput);
|
|
467
|
-
resultDotenv = dotenvForOutput;
|
|
468
|
-
}
|
|
469
|
-
// Log result.
|
|
470
|
-
if (log) {
|
|
471
|
-
const redactFlag = options.redact ?? false;
|
|
472
|
-
const redactPatterns = options.redactPatterns ?? undefined;
|
|
473
|
-
const redOpts = {};
|
|
474
|
-
if (redactFlag)
|
|
475
|
-
redOpts.redact = true;
|
|
476
|
-
if (redactFlag && Array.isArray(redactPatterns))
|
|
477
|
-
redOpts.redactPatterns = redactPatterns;
|
|
478
|
-
const bag = redactFlag
|
|
479
|
-
? redactObject(resultDotenv, redOpts)
|
|
480
|
-
: { ...resultDotenv };
|
|
481
|
-
logger.log(bag);
|
|
482
|
-
// Entropy warnings: once-per-key-per-run (presentation only)
|
|
483
|
-
const warnEntropyVal = options.warnEntropy ?? true;
|
|
484
|
-
const entropyThresholdVal = options
|
|
485
|
-
.entropyThreshold;
|
|
486
|
-
const entropyMinLengthVal = options
|
|
487
|
-
.entropyMinLength;
|
|
488
|
-
const entropyWhitelistVal = options.entropyWhitelist;
|
|
489
|
-
const entOpts = {};
|
|
490
|
-
if (typeof warnEntropyVal === 'boolean')
|
|
491
|
-
entOpts.warnEntropy = warnEntropyVal;
|
|
492
|
-
if (typeof entropyThresholdVal === 'number')
|
|
493
|
-
entOpts.entropyThreshold = entropyThresholdVal;
|
|
494
|
-
if (typeof entropyMinLengthVal === 'number')
|
|
495
|
-
entOpts.entropyMinLength = entropyMinLengthVal;
|
|
496
|
-
if (Array.isArray(entropyWhitelistVal))
|
|
497
|
-
entOpts.entropyWhitelist = entropyWhitelistVal;
|
|
498
|
-
for (const [k, v] of Object.entries(resultDotenv)) {
|
|
499
|
-
maybeWarnEntropy(k, v, v !== undefined ? 'dotenv' : 'unset', entOpts, (line) => {
|
|
500
|
-
logger.log(line);
|
|
501
|
-
});
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
// Load process.env.
|
|
505
|
-
if (loadProcess)
|
|
506
|
-
Object.assign(process.env, resultDotenv);
|
|
507
|
-
return resultDotenv;
|
|
508
|
-
}
|
|
509
|
-
|
|
510
273
|
/**
|
|
511
274
|
* Compute the realized path for a command mount (leaf-up to root).
|
|
512
275
|
* Excludes the root application alias.
|
|
@@ -567,37 +330,63 @@ const computeContext = async (customOptions, plugins, hostMetaUrl) => {
|
|
|
567
330
|
// Zod boundary: parse returns the schema-derived shape; we adopt our public
|
|
568
331
|
// GetDotenvOptions overlay (logger/dynamic typing) for internal processing.
|
|
569
332
|
const validated = getDotenvOptionsSchemaResolved.parse(optionsResolved);
|
|
570
|
-
//
|
|
571
|
-
const cleanedValidated = omitUndefined(validated);
|
|
572
|
-
const base = await getDotenv({
|
|
573
|
-
...cleanedValidated,
|
|
574
|
-
excludeDynamic: true,
|
|
575
|
-
vars: {},
|
|
576
|
-
log: false,
|
|
577
|
-
loadProcess: false,
|
|
578
|
-
});
|
|
579
|
-
// Discover config sources and overlay with progressive expansion per slice.
|
|
333
|
+
// Discover config sources.
|
|
580
334
|
const sources = await resolveGetDotenvConfigSources(hostMetaUrl);
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
335
|
+
// Base dotenv from files (with file provenance; no dynamics; no programmatic vars; no side effects).
|
|
336
|
+
const envName = validated.env ?? validated.defaultEnv;
|
|
337
|
+
const fileRes = await readDotenvCascadeWithProvenance({
|
|
338
|
+
paths: Array.isArray(validated.paths) ? validated.paths : [],
|
|
339
|
+
...(typeof validated.dotenvToken === 'string'
|
|
340
|
+
? { dotenvToken: validated.dotenvToken }
|
|
341
|
+
: {}),
|
|
342
|
+
...(typeof validated.privateToken === 'string'
|
|
343
|
+
? { privateToken: validated.privateToken }
|
|
344
|
+
: {}),
|
|
345
|
+
...(typeof validated.env === 'string' ? { env: validated.env } : {}),
|
|
346
|
+
...(typeof validated.defaultEnv === 'string'
|
|
347
|
+
? { defaultEnv: validated.defaultEnv }
|
|
348
|
+
: {}),
|
|
349
|
+
...(validated.excludeEnv === true ? { excludeEnv: true } : {}),
|
|
350
|
+
...(validated.excludeGlobal === true ? { excludeGlobal: true } : {}),
|
|
351
|
+
...(validated.excludePrivate === true ? { excludePrivate: true } : {}),
|
|
352
|
+
...(validated.excludePublic === true ? { excludePublic: true } : {}),
|
|
353
|
+
});
|
|
354
|
+
// Overlay configs + vars with provenance.
|
|
355
|
+
const overlaid = overlayEnvWithProvenance({
|
|
356
|
+
base: fileRes.dotenv,
|
|
357
|
+
env: envName,
|
|
584
358
|
configs: sources,
|
|
585
|
-
|
|
359
|
+
programmaticVars: validated.vars ?? {},
|
|
360
|
+
provenance: fileRes.provenance,
|
|
586
361
|
});
|
|
587
|
-
const dotenv = { ...
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
362
|
+
const dotenv = { ...overlaid.env };
|
|
363
|
+
const dotenvProvenance = overlaid.provenance;
|
|
364
|
+
// Dynamic precedence (A2): config dynamic < programmatic dynamic < dynamicPath
|
|
365
|
+
if (!validated.excludeDynamic) {
|
|
366
|
+
// Config dynamics (JS/TS configs only), ordered by source precedence.
|
|
367
|
+
const packagedDyn = (sources.packaged?.dynamic ?? undefined);
|
|
368
|
+
const publicDyn = (sources.project?.public?.dynamic ?? undefined);
|
|
369
|
+
const localDyn = (sources.project?.local?.dynamic ?? undefined);
|
|
370
|
+
applyDynamicMapWithProvenance(dotenv, packagedDyn, envName, dotenvProvenance, {
|
|
371
|
+
dynamicSource: 'config',
|
|
372
|
+
});
|
|
373
|
+
applyDynamicMapWithProvenance(dotenv, publicDyn, envName, dotenvProvenance, {
|
|
374
|
+
dynamicSource: 'config',
|
|
375
|
+
});
|
|
376
|
+
applyDynamicMapWithProvenance(dotenv, localDyn, envName, dotenvProvenance, {
|
|
377
|
+
dynamicSource: 'config',
|
|
378
|
+
});
|
|
379
|
+
// Programmatic dynamic (overrides config dynamic)
|
|
380
|
+
applyDynamicMapWithProvenance(dotenv, validated.dynamic, envName, dotenvProvenance, { dynamicSource: 'programmatic' });
|
|
381
|
+
// dynamicPath (highest dynamic tier; always evaluated when present)
|
|
382
|
+
if (validated.dynamicPath) {
|
|
383
|
+
const absDynamicPath = path.resolve(validated.dynamicPath);
|
|
384
|
+
const dyn = await loadDynamicModuleDefault(absDynamicPath, 'getdotenv-dynamic-host');
|
|
385
|
+
applyDynamicMapWithProvenance(dotenv, dyn, envName, dotenvProvenance, {
|
|
386
|
+
dynamicSource: 'dynamicPath',
|
|
387
|
+
dynamicPath: validated.dynamicPath,
|
|
388
|
+
});
|
|
389
|
+
}
|
|
601
390
|
}
|
|
602
391
|
// Effects:
|
|
603
392
|
if (validated.outputPath) {
|
|
@@ -657,6 +446,7 @@ const computeContext = async (customOptions, plugins, hostMetaUrl) => {
|
|
|
657
446
|
return {
|
|
658
447
|
optionsResolved: validated,
|
|
659
448
|
dotenv,
|
|
449
|
+
dotenvProvenance,
|
|
660
450
|
plugins: {},
|
|
661
451
|
pluginConfigs: mergedPluginConfigsByPath,
|
|
662
452
|
};
|
|
@@ -1623,4 +1413,4 @@ const readMergedOptions = (cmd) => {
|
|
|
1623
1413
|
return bag;
|
|
1624
1414
|
};
|
|
1625
1415
|
|
|
1626
|
-
export { GetDotenvCli as G,
|
|
1416
|
+
export { GetDotenvCli as G, defaultsDeep as a, baseRootOptionDefaults as b, attachRootOptions as c, definePlugin as d, resolveGetDotenvOptions as e, defineDynamic as f, getDotenvCliOptions2Options as g, defineGetDotenvConfig as h, interpolateDeep as i, readMergedOptions as r, writeDotenvFile as w };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { b as baseRootOptionDefaults, a as defaultsDeep } from './readMergedOptions-B7VdLROn.mjs';
|
|
2
2
|
import 'fs-extra';
|
|
3
|
+
import 'node:path';
|
|
3
4
|
import 'crypto';
|
|
4
5
|
import 'path';
|
|
5
6
|
import 'url';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { m as fromBase64, n as toBase64, o as toHex, t as toUtf8, q as fromArrayBuffer, r as streamCollector$1 } from './index-
|
|
1
|
+
import { m as fromBase64, n as toBase64, o as toHex, t as toUtf8, q as fromArrayBuffer, r as streamCollector$1 } from './index-70Dm0f1N.mjs';
|
|
2
2
|
import { Readable } from 'stream';
|
|
3
3
|
|
|
4
4
|
const isReadableStream = (stream) => typeof ReadableStream === "function" &&
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { execa, execaCommand } from 'execa';
|
|
2
2
|
import 'fs-extra';
|
|
3
|
+
import 'node:path';
|
|
3
4
|
import 'crypto';
|
|
4
5
|
import 'path';
|
|
5
6
|
import 'url';
|
|
@@ -303,4 +304,4 @@ const buildSpawnEnv = (base, overlay) => {
|
|
|
303
304
|
return out;
|
|
304
305
|
};
|
|
305
306
|
|
|
306
|
-
export { runCommandResult as a,
|
|
307
|
+
export { runCommandResult as a, resolveCommand as b, resolveShell as c, buildSpawnEnv as d, runCommand as r, shouldCapture as s, tokenize as t };
|