@karmaniverous/get-dotenv 6.1.1 → 6.2.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 +2 -0
- package/dist/cli.d.ts +58 -2
- package/dist/cli.mjs +149 -14
- package/dist/cliHost.d.ts +216 -17
- package/dist/cliHost.mjs +178 -14
- package/dist/config.d.ts +12 -0
- package/dist/config.mjs +79 -2
- package/dist/env-overlay.d.ts +8 -0
- package/dist/getdotenv.cli.mjs +149 -14
- package/dist/index.d.ts +220 -35
- package/dist/index.mjs +200 -15
- package/dist/plugins-aws.d.ts +89 -3
- package/dist/plugins-aws.mjs +141 -14
- package/dist/plugins-batch.d.ts +83 -2
- package/dist/plugins-batch.mjs +126 -13
- package/dist/plugins-cmd.d.ts +83 -2
- package/dist/plugins-cmd.mjs +120 -13
- package/dist/plugins-init.d.ts +83 -2
- package/dist/plugins-init.mjs +111 -13
- package/dist/plugins.d.ts +78 -2
- package/dist/plugins.mjs +149 -14
- package/package.json +2 -3
package/dist/plugins.mjs
CHANGED
|
@@ -38,26 +38,58 @@ import { versions, env } from 'process';
|
|
|
38
38
|
* Minimal process env representation used by options and helpers.
|
|
39
39
|
* Values may be `undefined` to indicate "unset".
|
|
40
40
|
*/
|
|
41
|
+
/**
|
|
42
|
+
* Schema for an env-like record.
|
|
43
|
+
*
|
|
44
|
+
* Keys are environment variable names and values are either strings or `undefined`
|
|
45
|
+
* (to represent “unset”).
|
|
46
|
+
*
|
|
47
|
+
* @public
|
|
48
|
+
*/
|
|
41
49
|
const processEnvSchema = z$2.record(z$2.string(), z$2.string().optional());
|
|
42
50
|
// RAW: all fields optional — undefined means "inherit" from lower layers.
|
|
51
|
+
/**
|
|
52
|
+
* Programmatic options schema (raw).
|
|
53
|
+
*
|
|
54
|
+
* This schema is the canonical runtime source of truth for the `getDotenv()` programmatic API.
|
|
55
|
+
* All fields are optional; `undefined` generally means “inherit default/lower layer”.
|
|
56
|
+
*
|
|
57
|
+
* @public
|
|
58
|
+
*/
|
|
43
59
|
const getDotenvOptionsSchemaRaw = z$2.object({
|
|
60
|
+
/** Default environment name when `env` is not provided. */
|
|
44
61
|
defaultEnv: z$2.string().optional(),
|
|
62
|
+
/** Base dotenv filename token (default `.env`). */
|
|
45
63
|
dotenvToken: z$2.string().optional(),
|
|
64
|
+
/** Path to a dynamic variables module (JS/TS) to load and apply. */
|
|
46
65
|
dynamicPath: z$2.string().optional(),
|
|
47
|
-
|
|
66
|
+
/** Dynamic map is intentionally wide for now; refine once sources are normalized. */
|
|
48
67
|
dynamic: z$2.record(z$2.string(), z$2.unknown()).optional(),
|
|
68
|
+
/** Selected environment name for this invocation (for env-scoped files and overlays). */
|
|
49
69
|
env: z$2.string().optional(),
|
|
70
|
+
/** When true, skip applying dynamic variables. */
|
|
50
71
|
excludeDynamic: z$2.boolean().optional(),
|
|
72
|
+
/** When true, skip environment-scoped dotenv files. */
|
|
51
73
|
excludeEnv: z$2.boolean().optional(),
|
|
74
|
+
/** When true, skip global dotenv files. */
|
|
52
75
|
excludeGlobal: z$2.boolean().optional(),
|
|
76
|
+
/** When true, skip private dotenv files. */
|
|
53
77
|
excludePrivate: z$2.boolean().optional(),
|
|
78
|
+
/** When true, skip public dotenv files. */
|
|
54
79
|
excludePublic: z$2.boolean().optional(),
|
|
80
|
+
/** When true, merge the final composed environment into `process.env`. */
|
|
55
81
|
loadProcess: z$2.boolean().optional(),
|
|
82
|
+
/** When true, log the final environment map via `logger`. */
|
|
56
83
|
log: z$2.boolean().optional(),
|
|
84
|
+
/** Logger used when `log` is enabled (console-compatible). */
|
|
57
85
|
logger: z$2.unknown().default(console),
|
|
86
|
+
/** Optional output dotenv file path to write after composition. */
|
|
58
87
|
outputPath: z$2.string().optional(),
|
|
88
|
+
/** Dotenv search paths (ordered). */
|
|
59
89
|
paths: z$2.array(z$2.string()).optional(),
|
|
90
|
+
/** Private token suffix for private dotenv files (default `local`). */
|
|
60
91
|
privateToken: z$2.string().optional(),
|
|
92
|
+
/** Explicit variables to overlay onto the composed dotenv map. */
|
|
61
93
|
vars: processEnvSchema.optional(),
|
|
62
94
|
});
|
|
63
95
|
/**
|
|
@@ -65,6 +97,14 @@ const getDotenvOptionsSchemaRaw = z$2.object({
|
|
|
65
97
|
* For now, this mirrors the RAW schema; future stages may materialize defaults
|
|
66
98
|
* and narrow shapes as resolution is wired into the host.
|
|
67
99
|
*/
|
|
100
|
+
/**
|
|
101
|
+
* Programmatic options schema (resolved).
|
|
102
|
+
*
|
|
103
|
+
* Today this mirrors {@link getDotenvOptionsSchemaRaw}, but is kept as a distinct export
|
|
104
|
+
* so future resolution steps can narrow or materialize defaults without breaking the API.
|
|
105
|
+
*
|
|
106
|
+
* @public
|
|
107
|
+
*/
|
|
68
108
|
const getDotenvOptionsSchemaResolved = getDotenvOptionsSchemaRaw;
|
|
69
109
|
|
|
70
110
|
/**
|
|
@@ -74,27 +114,55 @@ const getDotenvOptionsSchemaResolved = getDotenvOptionsSchemaRaw;
|
|
|
74
114
|
* reflect normalized types (paths: string[], vars: ProcessEnv), applied in the
|
|
75
115
|
* CLI resolution pipeline.
|
|
76
116
|
*/
|
|
117
|
+
/**
|
|
118
|
+
* CLI options schema (raw).
|
|
119
|
+
*
|
|
120
|
+
* Extends the programmatic options schema with CLI-only flags and stringly inputs
|
|
121
|
+
* which are normalized later by the host resolution pipeline.
|
|
122
|
+
*
|
|
123
|
+
* @public
|
|
124
|
+
*/
|
|
77
125
|
const getDotenvCliOptionsSchemaRaw = getDotenvOptionsSchemaRaw.extend({
|
|
78
126
|
// CLI-specific fields (stringly inputs before preprocessing)
|
|
127
|
+
/** Enable verbose debug output (host-specific). */
|
|
79
128
|
debug: z$2.boolean().optional(),
|
|
129
|
+
/** Fail on validation errors (schema/requiredKeys). */
|
|
80
130
|
strict: z$2.boolean().optional(),
|
|
131
|
+
/** Capture child process stdio (useful for CI/tests). */
|
|
81
132
|
capture: z$2.boolean().optional(),
|
|
133
|
+
/** Emit child env diagnostics (boolean or selected keys). */
|
|
82
134
|
trace: z$2.union([z$2.boolean(), z$2.array(z$2.string())]).optional(),
|
|
135
|
+
/** Enable presentation-time redaction in trace/log output. */
|
|
83
136
|
redact: z$2.boolean().optional(),
|
|
137
|
+
/** Enable entropy warnings in trace/log output. */
|
|
84
138
|
warnEntropy: z$2.boolean().optional(),
|
|
139
|
+
/** Entropy threshold (bits/char) for warnings. */
|
|
85
140
|
entropyThreshold: z$2.number().optional(),
|
|
141
|
+
/** Minimum value length to consider for entropy warnings. */
|
|
86
142
|
entropyMinLength: z$2.number().optional(),
|
|
143
|
+
/** Regex patterns (strings) to suppress entropy warnings by key. */
|
|
87
144
|
entropyWhitelist: z$2.array(z$2.string()).optional(),
|
|
145
|
+
/** Additional key-match patterns (strings) for redaction. */
|
|
88
146
|
redactPatterns: z$2.array(z$2.string()).optional(),
|
|
147
|
+
/** Dotenv search paths provided as a single delimited string. */
|
|
89
148
|
paths: z$2.string().optional(),
|
|
149
|
+
/** Delimiter string used to split `paths`. */
|
|
90
150
|
pathsDelimiter: z$2.string().optional(),
|
|
151
|
+
/** Regex pattern used to split `paths` (takes precedence over delimiter). */
|
|
91
152
|
pathsDelimiterPattern: z$2.string().optional(),
|
|
153
|
+
/** Scripts table in a permissive shape at parse time (validated elsewhere). */
|
|
92
154
|
scripts: z$2.record(z$2.string(), z$2.unknown()).optional(),
|
|
155
|
+
/** Shell selection (`false` for shell-off, string for explicit shell). */
|
|
93
156
|
shell: z$2.union([z$2.boolean(), z$2.string()]).optional(),
|
|
157
|
+
/** Extra variables expressed as a single delimited string of assignments. */
|
|
94
158
|
vars: z$2.string().optional(),
|
|
159
|
+
/** Assignment operator used when parsing `vars`. */
|
|
95
160
|
varsAssignor: z$2.string().optional(),
|
|
161
|
+
/** Regex pattern used as the assignment operator for `vars` parsing. */
|
|
96
162
|
varsAssignorPattern: z$2.string().optional(),
|
|
163
|
+
/** Delimiter string used to split `vars`. */
|
|
97
164
|
varsDelimiter: z$2.string().optional(),
|
|
165
|
+
/** Regex pattern used to split `vars` (takes precedence over delimiter). */
|
|
98
166
|
varsDelimiterPattern: z$2.string().optional(),
|
|
99
167
|
});
|
|
100
168
|
|
|
@@ -118,17 +186,34 @@ const envStringMap = z$2.record(z$2.string(), stringMap);
|
|
|
118
186
|
* Raw configuration schema for get‑dotenv config files (JSON/YAML/JS/TS).
|
|
119
187
|
* Validates allowed top‑level keys without performing path normalization.
|
|
120
188
|
*/
|
|
189
|
+
/**
|
|
190
|
+
* Config schema for discovered get-dotenv configuration documents (raw).
|
|
191
|
+
*
|
|
192
|
+
* This schema validates the allowed top-level keys for configuration files.
|
|
193
|
+
* It does not normalize paths or coerce types beyond Zod’s parsing.
|
|
194
|
+
*
|
|
195
|
+
* @public
|
|
196
|
+
*/
|
|
121
197
|
const getDotenvConfigSchemaRaw = z$2.object({
|
|
198
|
+
/** Root option defaults applied by the host (CLI-like, collapsed families). */
|
|
122
199
|
rootOptionDefaults: getDotenvCliOptionsSchemaRaw.optional(),
|
|
200
|
+
/** Help-time visibility map for root flags (false hides). */
|
|
123
201
|
rootOptionVisibility: visibilityMap.optional(),
|
|
124
|
-
|
|
202
|
+
/** Scripts table used by cmd/batch resolution (validation intentionally permissive here). */
|
|
203
|
+
scripts: z$2.record(z$2.string(), z$2.unknown()).optional(),
|
|
204
|
+
/** Keys required to be present in the final composed environment. */
|
|
125
205
|
requiredKeys: z$2.array(z$2.string()).optional(),
|
|
206
|
+
/** Validation schema (JS/TS only; JSON/YAML loader rejects). */
|
|
126
207
|
schema: z$2.unknown().optional(), // JS/TS-only; loader rejects in JSON/YAML
|
|
208
|
+
/** Public global variables (string-only). */
|
|
127
209
|
vars: stringMap.optional(), // public, global
|
|
210
|
+
/** Public per-environment variables (string-only). */
|
|
128
211
|
envVars: envStringMap.optional(), // public, per-env
|
|
129
212
|
// Dynamic in config (JS/TS only). JSON/YAML loader will reject if set.
|
|
213
|
+
/** Dynamic variable definitions (JS/TS only). */
|
|
130
214
|
dynamic: z$2.unknown().optional(),
|
|
131
215
|
// Per-plugin config bag; validated by plugins/host when used.
|
|
216
|
+
/** Per-plugin config slices keyed by realized mount path (for example, `aws/whoami`). */
|
|
132
217
|
plugins: z$2.record(z$2.string(), z$2.unknown()).optional(),
|
|
133
218
|
});
|
|
134
219
|
/**
|
|
@@ -958,13 +1043,21 @@ function traceChildEnv(opts) {
|
|
|
958
1043
|
* Base root CLI defaults (shared; kept untyped here to avoid cross-layer deps).
|
|
959
1044
|
* Used as the bottom layer for CLI option resolution.
|
|
960
1045
|
*/
|
|
1046
|
+
const baseScripts = {
|
|
1047
|
+
'git-status': {
|
|
1048
|
+
cmd: 'git branch --show-current && git status -s -u',
|
|
1049
|
+
shell: true,
|
|
1050
|
+
},
|
|
1051
|
+
};
|
|
961
1052
|
/**
|
|
962
|
-
* Default values for root CLI options used by the host and helpers as the
|
|
963
|
-
* baseline layer during option resolution.
|
|
1053
|
+
* Default values for root CLI options used by the host and helpers as the baseline layer during option resolution.
|
|
964
1054
|
*
|
|
965
|
-
* These defaults correspond to the
|
|
966
|
-
*
|
|
967
|
-
* configuration `rootOptionDefaults`
|
|
1055
|
+
* These defaults correspond to the “stringly” root surface (see `RootOptionsShape`) and are merged by precedence with:
|
|
1056
|
+
* - create-time overrides
|
|
1057
|
+
* - any discovered configuration `rootOptionDefaults`
|
|
1058
|
+
* - and finally CLI flags at runtime
|
|
1059
|
+
*
|
|
1060
|
+
* @public
|
|
968
1061
|
*/
|
|
969
1062
|
const baseRootOptionDefaults = {
|
|
970
1063
|
dotenvToken: '.env',
|
|
@@ -978,12 +1071,7 @@ const baseRootOptionDefaults = {
|
|
|
978
1071
|
paths: './',
|
|
979
1072
|
pathsDelimiter: ' ',
|
|
980
1073
|
privateToken: 'local',
|
|
981
|
-
scripts:
|
|
982
|
-
'git-status': {
|
|
983
|
-
cmd: 'git branch --show-current && git status -s -u',
|
|
984
|
-
shell: true,
|
|
985
|
-
},
|
|
986
|
-
},
|
|
1074
|
+
scripts: baseScripts,
|
|
987
1075
|
shell: true,
|
|
988
1076
|
vars: '',
|
|
989
1077
|
varsAssignor: '=',
|
|
@@ -1530,6 +1618,14 @@ async function _execNormalized(command, shell, opts = {}) {
|
|
|
1530
1618
|
return out;
|
|
1531
1619
|
}
|
|
1532
1620
|
}
|
|
1621
|
+
/**
|
|
1622
|
+
* Execute a command and capture stdout/stderr (buffered).
|
|
1623
|
+
*
|
|
1624
|
+
* @param command - Command string (shell) or argv array (shell-off supported).
|
|
1625
|
+
* @param shell - Shell setting (false for plain execution).
|
|
1626
|
+
* @param opts - Execution options (cwd/env/timeout).
|
|
1627
|
+
* @returns A promise resolving to the captured result.
|
|
1628
|
+
*/
|
|
1533
1629
|
async function runCommandResult(command, shell, opts = {}) {
|
|
1534
1630
|
// Build opts without injecting undefined (exactOptionalPropertyTypes-safe)
|
|
1535
1631
|
const coreOpts = { stdio: 'pipe' };
|
|
@@ -1544,6 +1640,14 @@ async function runCommandResult(command, shell, opts = {}) {
|
|
|
1544
1640
|
}
|
|
1545
1641
|
return _execNormalized(command, shell, coreOpts);
|
|
1546
1642
|
}
|
|
1643
|
+
/**
|
|
1644
|
+
* Execute a command and return its exit code.
|
|
1645
|
+
*
|
|
1646
|
+
* @param command - Command string (shell) or argv array (shell-off supported).
|
|
1647
|
+
* @param shell - Shell setting (false for plain execution).
|
|
1648
|
+
* @param opts - Execution options (cwd/env/stdio).
|
|
1649
|
+
* @returns A promise resolving to the process exit code.
|
|
1650
|
+
*/
|
|
1547
1651
|
async function runCommand(command, shell, opts) {
|
|
1548
1652
|
// Build opts without injecting undefined (exactOptionalPropertyTypes-safe)
|
|
1549
1653
|
const callOpts = {};
|
|
@@ -2003,6 +2107,16 @@ function evaluateDynamicOptions(root, resolved) {
|
|
|
2003
2107
|
visit(root);
|
|
2004
2108
|
}
|
|
2005
2109
|
|
|
2110
|
+
/**
|
|
2111
|
+
* Initialize a {@link GetDotenvCli} instance with help configuration and safe defaults.
|
|
2112
|
+
*
|
|
2113
|
+
* @remarks
|
|
2114
|
+
* This is a low-level initializer used by the host constructor to keep `GetDotenvCli.ts`
|
|
2115
|
+
* small and to centralize help/output behavior.
|
|
2116
|
+
*
|
|
2117
|
+
* @param cli - The CLI instance to initialize.
|
|
2118
|
+
* @param headerGetter - Callback returning an optional help header string.
|
|
2119
|
+
*/
|
|
2006
2120
|
function initializeInstance(cli, headerGetter) {
|
|
2007
2121
|
// Configure grouped help: show only base options in default "Options";
|
|
2008
2122
|
// subcommands show all of their own options.
|
|
@@ -3215,16 +3329,29 @@ function attachAwsPreSubcommandHook(cli, plugin) {
|
|
|
3215
3329
|
}
|
|
3216
3330
|
|
|
3217
3331
|
/**
|
|
3218
|
-
*
|
|
3332
|
+
* AWS plugin configuration schema.
|
|
3333
|
+
*
|
|
3334
|
+
* @remarks
|
|
3335
|
+
* This Zod schema is used by the host to validate the `plugins.aws` config slice.
|
|
3336
|
+
*
|
|
3337
|
+
* @public
|
|
3219
3338
|
*/
|
|
3220
3339
|
const awsPluginConfigSchema = z$2.object({
|
|
3340
|
+
/** Preferred AWS profile name (overrides dotenv-derived profile keys when set). */
|
|
3221
3341
|
profile: z$2.string().optional(),
|
|
3342
|
+
/** Preferred AWS region (overrides dotenv-derived region key when set). */
|
|
3222
3343
|
region: z$2.string().optional(),
|
|
3344
|
+
/** Fallback region when region cannot be resolved from config/dotenv/AWS CLI. */
|
|
3223
3345
|
defaultRegion: z$2.string().optional(),
|
|
3346
|
+
/** Dotenv/config key for local profile lookup (default `AWS_LOCAL_PROFILE`). */
|
|
3224
3347
|
profileKey: z$2.string().default('AWS_LOCAL_PROFILE').optional(),
|
|
3348
|
+
/** Dotenv/config fallback key for profile lookup (default `AWS_PROFILE`). */
|
|
3225
3349
|
profileFallbackKey: z$2.string().default('AWS_PROFILE').optional(),
|
|
3350
|
+
/** Dotenv/config key for region lookup (default `AWS_REGION`). */
|
|
3226
3351
|
regionKey: z$2.string().default('AWS_REGION').optional(),
|
|
3352
|
+
/** Credential acquisition strategy (`cli-export` to resolve via AWS CLI, or `none` to skip). */
|
|
3227
3353
|
strategy: z$2.enum(['cli-export', 'none']).default('cli-export').optional(),
|
|
3354
|
+
/** When true, attempt `aws sso login` on-demand when credential export fails for an SSO profile. */
|
|
3228
3355
|
loginOnDemand: z$2.boolean().default(false).optional(),
|
|
3229
3356
|
});
|
|
3230
3357
|
|
|
@@ -14176,7 +14303,9 @@ function attachBatchOptions(plugin, cli) {
|
|
|
14176
14303
|
const ScriptSchema = z$2.union([
|
|
14177
14304
|
z$2.string(),
|
|
14178
14305
|
z$2.object({
|
|
14306
|
+
/** Command string to execute. */
|
|
14179
14307
|
cmd: z$2.string(),
|
|
14308
|
+
/** Optional shell override for this script entry. */
|
|
14180
14309
|
shell: z$2.union([z$2.string(), z$2.boolean()]).optional(),
|
|
14181
14310
|
}),
|
|
14182
14311
|
]);
|
|
@@ -14184,10 +14313,15 @@ const ScriptSchema = z$2.union([
|
|
|
14184
14313
|
* Zod schema for batch plugin configuration.
|
|
14185
14314
|
*/
|
|
14186
14315
|
const batchPluginConfigSchema = z$2.object({
|
|
14316
|
+
/** Optional scripts table scoped to the batch plugin. */
|
|
14187
14317
|
scripts: z$2.record(z$2.string(), ScriptSchema).optional(),
|
|
14318
|
+
/** Optional default shell for batch execution (overridden by per-script shell when present). */
|
|
14188
14319
|
shell: z$2.union([z$2.string(), z$2.boolean()]).optional(),
|
|
14320
|
+
/** Root path for discovery, relative to CWD (or package root when pkgCwd is true). */
|
|
14189
14321
|
rootPath: z$2.string().optional(),
|
|
14322
|
+
/** Space-delimited glob patterns used to discover directories. */
|
|
14190
14323
|
globs: z$2.string().optional(),
|
|
14324
|
+
/** When true, resolve the batch root from the nearest package directory. */
|
|
14191
14325
|
pkgCwd: z$2.boolean().optional(),
|
|
14192
14326
|
});
|
|
14193
14327
|
|
|
@@ -14483,6 +14617,7 @@ const attachCmdParentInvoker = (cli, options, plugin) => {
|
|
|
14483
14617
|
*/
|
|
14484
14618
|
const cmdPluginConfigSchema = z$2
|
|
14485
14619
|
.object({
|
|
14620
|
+
/** When true, expand the alias value before execution (default behavior when omitted). */
|
|
14486
14621
|
expand: z$2.boolean().optional(),
|
|
14487
14622
|
})
|
|
14488
14623
|
.strict();
|
package/package.json
CHANGED
|
@@ -192,8 +192,7 @@
|
|
|
192
192
|
]
|
|
193
193
|
},
|
|
194
194
|
"npm": {
|
|
195
|
-
"publish": false
|
|
196
|
-
"skipChecks": true
|
|
195
|
+
"publish": false
|
|
197
196
|
}
|
|
198
197
|
},
|
|
199
198
|
"repository": {
|
|
@@ -222,5 +221,5 @@
|
|
|
222
221
|
},
|
|
223
222
|
"type": "module",
|
|
224
223
|
"types": "dist/index.d.ts",
|
|
225
|
-
"version": "6.
|
|
224
|
+
"version": "6.2.1"
|
|
226
225
|
}
|