@karmaniverous/get-dotenv 6.2.2 → 6.2.4
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/dist/chunks/AwsRestJsonProtocol-Bq1HE-Ln.mjs +932 -0
- package/dist/chunks/createCli-BY6_cfZr.mjs +439 -0
- package/dist/chunks/externalDataInterceptor-CbsdEYa-.mjs +19 -0
- package/dist/chunks/getSSOTokenFromFile-hUSpR7Wf.mjs +22 -0
- package/dist/chunks/helpConfig-CGejgwWW.mjs +12 -0
- package/dist/chunks/index-B5JKTBOL.mjs +443 -0
- package/dist/chunks/index-BEJFiHMX.mjs +522 -0
- package/dist/chunks/index-BPYF6K_G.mjs +82 -0
- package/dist/chunks/index-Bc3h0a95.mjs +374 -0
- package/dist/chunks/index-BpCF5UKx.mjs +272 -0
- package/dist/chunks/index-C_wqbTwI.mjs +187 -0
- package/dist/chunks/index-CeCufHlm.mjs +9374 -0
- package/dist/chunks/index-Cu7rdyqN.mjs +102 -0
- package/dist/chunks/index-DWAtHEA-.mjs +379 -0
- package/dist/chunks/index-Dp1Ip6Ra.mjs +354 -0
- package/dist/chunks/index-DyU5pKKi.mjs +24 -0
- package/dist/chunks/index-c7zKtEuy.mjs +578 -0
- package/dist/chunks/index-cIunyiUQ.mjs +702 -0
- package/dist/chunks/invoke-DuRPU1oC.mjs +60 -0
- package/dist/chunks/loadModuleDefault-Dj8B3Stt.mjs +123 -0
- package/dist/chunks/loadSso-w1eTVg0O.mjs +412 -0
- package/dist/chunks/loader-DnhPeGfq.mjs +346 -0
- package/dist/chunks/overlayEnv-Bs2kVayG.mjs +234 -0
- package/dist/chunks/package-boo9EyYs.mjs +5 -0
- package/dist/chunks/parseKnownFiles-B9cDK21V.mjs +23 -0
- package/dist/chunks/readMergedOptions-Nt0TR7dX.mjs +1626 -0
- package/dist/chunks/resolveCliOptions-TFRzhB2c.mjs +138 -0
- package/dist/chunks/sdk-stream-mixin-BZoJ5jy9.mjs +167 -0
- package/dist/chunks/spawnEnv-CN8a7cNR.mjs +306 -0
- package/dist/chunks/types-DJ-BGABd.mjs +59 -0
- package/dist/chunks/validate-CDl0rE6k.mjs +61 -0
- package/dist/cli.mjs +39 -19307
- package/dist/cliHost.mjs +20 -2800
- package/dist/config.mjs +10 -509
- package/dist/env-overlay.mjs +6 -337
- package/dist/getdotenv.cli.mjs +39 -19305
- package/dist/index.mjs +39 -19396
- package/dist/plugins-aws.d.ts +1 -4
- package/dist/plugins-aws.mjs +65 -2568
- package/dist/plugins-batch.mjs +16 -2573
- package/dist/plugins-cmd.mjs +19 -3094
- package/dist/plugins-init.d.ts +8 -0
- package/dist/plugins-init.mjs +85 -2297
- package/dist/plugins.mjs +36 -18817
- package/package.json +1 -2
- package/dist/templates/cli/index.ts +0 -25
- package/dist/templates/cli/plugins/hello/defaultAction.ts +0 -27
- package/dist/templates/cli/plugins/hello/index.ts +0 -26
- package/dist/templates/cli/plugins/hello/options.ts +0 -31
- package/dist/templates/cli/plugins/hello/strangerAction.ts +0 -20
- package/dist/templates/cli/plugins/hello/types.ts +0 -13
- package/dist/templates/config/js/getdotenv.config.js +0 -20
- package/dist/templates/config/json/local/getdotenv.config.local.json +0 -7
- package/dist/templates/config/json/public/getdotenv.config.json +0 -9
- package/dist/templates/config/public/getdotenv.config.json +0 -8
- package/dist/templates/config/ts/getdotenv.config.ts +0 -28
- package/dist/templates/config/yaml/local/getdotenv.config.local.yaml +0 -7
- package/dist/templates/config/yaml/public/getdotenv.config.yaml +0 -7
- package/dist/templates/defaultAction.ts +0 -27
- package/dist/templates/getdotenv.config.js +0 -20
- package/dist/templates/getdotenv.config.json +0 -9
- package/dist/templates/getdotenv.config.local.json +0 -7
- package/dist/templates/getdotenv.config.local.yaml +0 -7
- package/dist/templates/getdotenv.config.ts +0 -28
- package/dist/templates/getdotenv.config.yaml +0 -7
- package/dist/templates/hello/defaultAction.ts +0 -27
- package/dist/templates/hello/index.ts +0 -26
- package/dist/templates/hello/options.ts +0 -31
- package/dist/templates/hello/strangerAction.ts +0 -20
- package/dist/templates/hello/types.ts +0 -13
- package/dist/templates/index.ts +0 -26
- package/dist/templates/js/getdotenv.config.js +0 -20
- package/dist/templates/json/local/getdotenv.config.local.json +0 -7
- package/dist/templates/json/public/getdotenv.config.json +0 -9
- package/dist/templates/local/getdotenv.config.local.json +0 -7
- package/dist/templates/local/getdotenv.config.local.yaml +0 -7
- package/dist/templates/options.ts +0 -31
- package/dist/templates/plugins/hello/defaultAction.ts +0 -27
- package/dist/templates/plugins/hello/index.ts +0 -26
- package/dist/templates/plugins/hello/options.ts +0 -31
- package/dist/templates/plugins/hello/strangerAction.ts +0 -20
- package/dist/templates/plugins/hello/types.ts +0 -13
- package/dist/templates/public/getdotenv.config.json +0 -9
- package/dist/templates/public/getdotenv.config.yaml +0 -7
- package/dist/templates/strangerAction.ts +0 -20
- package/dist/templates/ts/getdotenv.config.ts +0 -28
- package/dist/templates/types.ts +0 -13
- package/dist/templates/yaml/local/getdotenv.config.local.yaml +0 -7
- package/dist/templates/yaml/public/getdotenv.config.yaml +0 -7
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validate a composed env against config-provided validation surfaces.
|
|
3
|
+
* Precedence for validation definitions:
|
|
4
|
+
* project.local -\> project.public -\> packaged
|
|
5
|
+
*
|
|
6
|
+
* Behavior:
|
|
7
|
+
* - If a JS/TS `schema` is present, use schema.safeParse(finalEnv).
|
|
8
|
+
* - Else if `requiredKeys` is present, check presence (value !== undefined).
|
|
9
|
+
* - Returns a flat list of issue strings; caller decides warn vs fail.
|
|
10
|
+
*
|
|
11
|
+
* @param finalEnv - Final composed environment to validate.
|
|
12
|
+
* @param sources - Resolved config sources providing `schema` and/or `requiredKeys`.
|
|
13
|
+
* @returns A list of human-readable issue strings (empty when valid).
|
|
14
|
+
*/
|
|
15
|
+
const validateEnvAgainstSources = (finalEnv, sources) => {
|
|
16
|
+
const pick = (getter) => {
|
|
17
|
+
const pl = sources.project?.local;
|
|
18
|
+
const pp = sources.project?.public;
|
|
19
|
+
const pk = sources.packaged;
|
|
20
|
+
return ((pl && getter(pl)) ||
|
|
21
|
+
(pp && getter(pp)) ||
|
|
22
|
+
(pk && getter(pk)) ||
|
|
23
|
+
undefined);
|
|
24
|
+
};
|
|
25
|
+
const schema = pick((cfg) => cfg['schema']);
|
|
26
|
+
if (schema &&
|
|
27
|
+
typeof schema.safeParse === 'function') {
|
|
28
|
+
try {
|
|
29
|
+
const parsed = schema.safeParse(finalEnv);
|
|
30
|
+
if (!parsed.success) {
|
|
31
|
+
// Try to render zod-style issues when available.
|
|
32
|
+
const err = parsed.error;
|
|
33
|
+
const issues = Array.isArray(err.issues) && err.issues.length > 0
|
|
34
|
+
? err.issues.map((i) => {
|
|
35
|
+
const path = Array.isArray(i.path) ? i.path.join('.') : '';
|
|
36
|
+
const msg = i.message ?? 'Invalid value';
|
|
37
|
+
return path ? `[schema] ${path}: ${msg}` : `[schema] ${msg}`;
|
|
38
|
+
})
|
|
39
|
+
: ['[schema] validation failed'];
|
|
40
|
+
return issues;
|
|
41
|
+
}
|
|
42
|
+
return [];
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
// If schema invocation fails, surface a single diagnostic.
|
|
46
|
+
return [
|
|
47
|
+
'[schema] validation failed (unable to execute schema.safeParse)',
|
|
48
|
+
];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const requiredKeys = pick((cfg) => cfg['requiredKeys']);
|
|
52
|
+
if (Array.isArray(requiredKeys) && requiredKeys.length > 0) {
|
|
53
|
+
const missing = requiredKeys.filter((k) => finalEnv[k] === undefined);
|
|
54
|
+
if (missing.length > 0) {
|
|
55
|
+
return missing.map((k) => `[requiredKeys] missing: ${k}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return [];
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export { validateEnvAgainstSources as v };
|