@karmaniverous/get-dotenv 6.2.3 → 6.3.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.
Files changed (91) hide show
  1. package/README.md +1 -0
  2. package/dist/chunks/AwsRestJsonProtocol-Dv5q8CFK.mjs +932 -0
  3. package/dist/chunks/createCli-BSn6Be40.mjs +440 -0
  4. package/dist/chunks/externalDataInterceptor-pqHO-Qmn.mjs +19 -0
  5. package/dist/chunks/getSSOTokenFromFile-otmZHSRV.mjs +22 -0
  6. package/dist/chunks/helpConfig-CGejgwWW.mjs +12 -0
  7. package/dist/chunks/index-B18W-ELX.mjs +273 -0
  8. package/dist/chunks/index-BNcKuiBy.mjs +9375 -0
  9. package/dist/chunks/index-Bi0RIILn.mjs +25 -0
  10. package/dist/chunks/index-BqZ3PB6c.mjs +375 -0
  11. package/dist/chunks/index-C4Ac6feq.mjs +355 -0
  12. package/dist/chunks/index-C6uLiKpC.mjs +703 -0
  13. package/dist/chunks/index-CGg5wWCm.mjs +188 -0
  14. package/dist/chunks/index-CXpZ0pei.mjs +579 -0
  15. package/dist/chunks/index-CYoFYXZv.mjs +103 -0
  16. package/dist/chunks/index-DFNcs3pR.mjs +444 -0
  17. package/dist/chunks/index-DLQEHTw4.mjs +83 -0
  18. package/dist/chunks/index-DtRaL61T.mjs +380 -0
  19. package/dist/chunks/index-eZMlmESW.mjs +522 -0
  20. package/dist/chunks/invoke-DuRPU1oC.mjs +60 -0
  21. package/dist/chunks/loadModuleDefault-Dj8B3Stt.mjs +123 -0
  22. package/dist/chunks/loadSso-CJ_XUhEj.mjs +413 -0
  23. package/dist/chunks/loader-CePOf74i.mjs +347 -0
  24. package/dist/chunks/overlayEnv-Bqh_kPGA.mjs +235 -0
  25. package/dist/chunks/package-boo9EyYs.mjs +5 -0
  26. package/dist/chunks/parseKnownFiles-B6x1cUmR.mjs +23 -0
  27. package/dist/chunks/readMergedOptions-DLBDzpXX.mjs +1627 -0
  28. package/dist/chunks/resolveCliOptions-_qtsVxda.mjs +139 -0
  29. package/dist/chunks/sdk-stream-mixin-DCdC70Up.mjs +167 -0
  30. package/dist/chunks/spawnEnv-CQwFu7ZJ.mjs +307 -0
  31. package/dist/chunks/types-DdqcXCV1.mjs +59 -0
  32. package/dist/chunks/validate-CDl0rE6k.mjs +61 -0
  33. package/dist/cli.mjs +39 -19307
  34. package/dist/cliHost.mjs +21 -2800
  35. package/dist/config.mjs +11 -509
  36. package/dist/env-overlay.mjs +7 -337
  37. package/dist/getdotenv.cli.mjs +39 -19305
  38. package/dist/index.d.ts +485 -2
  39. package/dist/index.mjs +657 -19322
  40. package/dist/plugins-aws.d.ts +1 -4
  41. package/dist/plugins-aws.mjs +66 -2568
  42. package/dist/plugins-batch.mjs +17 -2573
  43. package/dist/plugins-cmd.mjs +20 -3094
  44. package/dist/plugins-init.d.ts +8 -0
  45. package/dist/plugins-init.mjs +85 -2297
  46. package/dist/plugins.mjs +36 -18817
  47. package/package.json +1 -2
  48. package/dist/templates/cli/index.ts +0 -25
  49. package/dist/templates/cli/plugins/hello/defaultAction.ts +0 -27
  50. package/dist/templates/cli/plugins/hello/index.ts +0 -26
  51. package/dist/templates/cli/plugins/hello/options.ts +0 -31
  52. package/dist/templates/cli/plugins/hello/strangerAction.ts +0 -20
  53. package/dist/templates/cli/plugins/hello/types.ts +0 -13
  54. package/dist/templates/config/js/getdotenv.config.js +0 -20
  55. package/dist/templates/config/json/local/getdotenv.config.local.json +0 -7
  56. package/dist/templates/config/json/public/getdotenv.config.json +0 -9
  57. package/dist/templates/config/public/getdotenv.config.json +0 -8
  58. package/dist/templates/config/ts/getdotenv.config.ts +0 -28
  59. package/dist/templates/config/yaml/local/getdotenv.config.local.yaml +0 -7
  60. package/dist/templates/config/yaml/public/getdotenv.config.yaml +0 -7
  61. package/dist/templates/defaultAction.ts +0 -27
  62. package/dist/templates/getdotenv.config.js +0 -20
  63. package/dist/templates/getdotenv.config.json +0 -9
  64. package/dist/templates/getdotenv.config.local.json +0 -7
  65. package/dist/templates/getdotenv.config.local.yaml +0 -7
  66. package/dist/templates/getdotenv.config.ts +0 -28
  67. package/dist/templates/getdotenv.config.yaml +0 -7
  68. package/dist/templates/hello/defaultAction.ts +0 -27
  69. package/dist/templates/hello/index.ts +0 -26
  70. package/dist/templates/hello/options.ts +0 -31
  71. package/dist/templates/hello/strangerAction.ts +0 -20
  72. package/dist/templates/hello/types.ts +0 -13
  73. package/dist/templates/index.ts +0 -26
  74. package/dist/templates/js/getdotenv.config.js +0 -20
  75. package/dist/templates/json/local/getdotenv.config.local.json +0 -7
  76. package/dist/templates/json/public/getdotenv.config.json +0 -9
  77. package/dist/templates/local/getdotenv.config.local.json +0 -7
  78. package/dist/templates/local/getdotenv.config.local.yaml +0 -7
  79. package/dist/templates/options.ts +0 -31
  80. package/dist/templates/plugins/hello/defaultAction.ts +0 -27
  81. package/dist/templates/plugins/hello/index.ts +0 -26
  82. package/dist/templates/plugins/hello/options.ts +0 -31
  83. package/dist/templates/plugins/hello/strangerAction.ts +0 -20
  84. package/dist/templates/plugins/hello/types.ts +0 -13
  85. package/dist/templates/public/getdotenv.config.json +0 -9
  86. package/dist/templates/public/getdotenv.config.yaml +0 -7
  87. package/dist/templates/strangerAction.ts +0 -20
  88. package/dist/templates/ts/getdotenv.config.ts +0 -28
  89. package/dist/templates/types.ts +0 -13
  90. package/dist/templates/yaml/local/getdotenv.config.local.yaml +0 -7
  91. package/dist/templates/yaml/public/getdotenv.config.yaml +0 -7
@@ -0,0 +1,440 @@
1
+ import 'zod';
2
+ import 'path';
3
+ import { r as resolveGetDotenvConfigSources } from './loader-CePOf74i.mjs';
4
+ import 'fs-extra';
5
+ import { a as defaultsDeep, g as getDotenvCliOptions2Options, b as baseRootOptionDefaults, G as GetDotenvCli, c as attachRootOptions } from './readMergedOptions-DLBDzpXX.mjs';
6
+ import 'node:path';
7
+ import 'crypto';
8
+ import 'url';
9
+ import 'nanoid';
10
+ import 'dotenv';
11
+ import 'execa';
12
+ import { t as toHelpConfig } from './helpConfig-CGejgwWW.mjs';
13
+ import { r as resolveCliOptions } from './resolveCliOptions-_qtsVxda.mjs';
14
+ import { v as validateEnvAgainstSources } from './validate-CDl0rE6k.mjs';
15
+ import { awsPlugin } from '../plugins-aws.mjs';
16
+ import { a as awsWhoamiPlugin } from './index-BNcKuiBy.mjs';
17
+ import { batchPlugin } from '../plugins-batch.mjs';
18
+ import { c as cmdPlugin } from './index-BqZ3PB6c.mjs';
19
+ import { initPlugin } from '../plugins-init.mjs';
20
+
21
+ const dbg = (...args) => {
22
+ if (process.env.GETDOTENV_DEBUG) {
23
+ try {
24
+ const line = args
25
+ .map((a) => (typeof a === 'string' ? a : JSON.stringify(a)))
26
+ .join(' ');
27
+ process.stderr.write(`[getdotenv:rootHooks] ${line}\n`);
28
+ }
29
+ catch {
30
+ /* ignore */
31
+ }
32
+ }
33
+ };
34
+ // Typed projection for concise debug logs without unsafe member access.
35
+ const debugView = (o) => ({
36
+ env: o.env,
37
+ shell: o.shell,
38
+ log: o.log,
39
+ capture: o.capture,
40
+ strict: o.strict,
41
+ });
42
+ function computeRootDefaults(defaults, sources) {
43
+ const cfgDefaults = defaultsDeep({}, sources.packaged?.rootOptionDefaults ?? {}, sources.project?.public?.rootOptionDefaults ?? {}, sources.project?.local?.rootOptionDefaults ?? {});
44
+ return defaultsDeep(baseRootOptionDefaults, defaults ?? {}, cfgDefaults);
45
+ }
46
+ /**
47
+ * Install root-level hooks (preSubcommand/preAction) to handle configuration loading,
48
+ * option resolution, and context initialization before actions run.
49
+ *
50
+ * @param program - The CLI host instance.
51
+ * @param defaults - Optional root defaults overlay.
52
+ */
53
+ function installRootHooks(program, defaults) {
54
+ // Hook: preSubcommand — always runs for subcommand flows.
55
+ program.hook('preSubcommand', async (thisCommand) => {
56
+ const sources = await resolveGetDotenvConfigSources(import.meta.url);
57
+ const rawArgs = thisCommand.rawArgs ?? [];
58
+ dbg('preSubcommand:rawArgs', rawArgs);
59
+ const raw = thisCommand.opts?.() ?? {};
60
+ // Build unified defaults stack for this run:
61
+ // baseRootOptionDefaults < createCli root defaults (argument) < config.rootOptionDefaults
62
+ const d = computeRootDefaults(defaults ?? {}, sources);
63
+ const { merged } = resolveCliOptions(raw, d, process.env.getDotenvCliOptions);
64
+ dbg('preSubcommand:merged', debugView(merged));
65
+ // Inject merged scripts from config sources (packaged < project/public < project/local).
66
+ merged.scripts = defaultsDeep({}, merged.scripts ?? {}, sources.packaged?.scripts ?? {}, sources.project?.public?.scripts ?? {}, sources.project?.local?.scripts ?? {});
67
+ // Persist merged bag for nested flows and ergonomic access.
68
+ thisCommand.getDotenvCliOptions = merged;
69
+ program._setOptionsBag(merged);
70
+ // Resolve context for this run via programmatic converter.
71
+ const serviceOptions = getDotenvCliOptions2Options(merged);
72
+ await program.resolveAndLoad(serviceOptions);
73
+ // Refresh dynamic help text using the resolved config slices.
74
+ try {
75
+ const ctx = program.getCtx();
76
+ const helpCfg = toHelpConfig(merged, ctx.pluginConfigs);
77
+ program.evaluateDynamicOptions(helpCfg);
78
+ }
79
+ catch {
80
+ /* best-effort */
81
+ }
82
+ // Global validation (once after overlays). Honor --strict.
83
+ try {
84
+ const ctx = program.getCtx();
85
+ const dotenv = ctx.dotenv;
86
+ const sources2 = await resolveGetDotenvConfigSources(import.meta.url);
87
+ const issues = validateEnvAgainstSources(dotenv, sources2);
88
+ if (Array.isArray(issues) && issues.length > 0) {
89
+ const logger = merged.logger;
90
+ issues.forEach((m) => {
91
+ logger.error(m);
92
+ });
93
+ if (merged.strict)
94
+ process.exit(1);
95
+ }
96
+ }
97
+ catch {
98
+ /* tolerate non-strict flows */
99
+ }
100
+ });
101
+ // Hook: preAction — root-only and parent-alias flows.
102
+ program.hook('preAction', async (thisCommand) => {
103
+ const sources = await resolveGetDotenvConfigSources(import.meta.url);
104
+ const rawArgs = thisCommand.rawArgs ?? [];
105
+ dbg('preAction:rawArgs', rawArgs);
106
+ const raw = thisCommand.opts?.() ?? {};
107
+ // Build unified defaults stack for this run:
108
+ // baseRootOptionDefaults < createCli root defaults (argument) < config.rootOptionDefaults
109
+ const d = computeRootDefaults(defaults ?? {}, sources);
110
+ const { merged } = resolveCliOptions(raw, d, process.env.getDotenvCliOptions);
111
+ dbg('preAction:merged', debugView(merged));
112
+ // Inject merged scripts from config sources (packaged < project/public < project/local).
113
+ merged.scripts = defaultsDeep({}, merged.scripts ?? {}, sources.packaged?.scripts ?? {}, sources.project?.public?.scripts ?? {}, sources.project?.local?.scripts ?? {});
114
+ thisCommand.getDotenvCliOptions = merged;
115
+ program._setOptionsBag(merged);
116
+ if (!program.hasCtx()) {
117
+ const serviceOptions = getDotenvCliOptions2Options(merged);
118
+ await program.resolveAndLoad(serviceOptions);
119
+ try {
120
+ const ctx = program.getCtx();
121
+ const helpCfg = toHelpConfig(merged, ctx.pluginConfigs);
122
+ program.evaluateDynamicOptions(helpCfg);
123
+ }
124
+ catch {
125
+ /* tolerate */
126
+ }
127
+ try {
128
+ const ctx = program.getCtx();
129
+ const dotenv = ctx.dotenv;
130
+ const sources2 = await resolveGetDotenvConfigSources(import.meta.url);
131
+ const issues = validateEnvAgainstSources(dotenv, sources2);
132
+ if (Array.isArray(issues) && issues.length > 0) {
133
+ const logger = merged.logger;
134
+ issues.forEach((m) => {
135
+ logger.error(m);
136
+ });
137
+ if (merged.strict)
138
+ process.exit(1);
139
+ }
140
+ }
141
+ catch {
142
+ /* tolerate non-strict flows */
143
+ }
144
+ }
145
+ });
146
+ return program;
147
+ }
148
+
149
+ /**
150
+ * Merge visibility maps left-to-right; later maps override earlier keys.
151
+ * @param layers - zero or more partial visibility maps (undefined ignored)
152
+ * @returns a new merged visibility map
153
+ */
154
+ function mergeRootVisibility(...layers) {
155
+ const out = {};
156
+ for (const m of layers) {
157
+ if (!m)
158
+ continue;
159
+ for (const [k, v] of Object.entries(m)) {
160
+ out[k] = v;
161
+ }
162
+ }
163
+ return out;
164
+ }
165
+ /**
166
+ * Hide a set of long flags (if present) on the provided root program.
167
+ * @param program - the GetDotenvCli root instance
168
+ * @param names - array of long option names (e.g., "--capture")
169
+ */
170
+ function hideByLong(program, names) {
171
+ for (const opt of program.options) {
172
+ const long = opt.long ?? '';
173
+ if (names.includes(long))
174
+ opt.hideHelp(true);
175
+ }
176
+ }
177
+ /**
178
+ * Apply root option visibility to the provided program instance.
179
+ * Flags set to false in the visibility map are hidden via hideHelp(true).
180
+ *
181
+ * Help-time only:
182
+ * - This affects rendering of top-level help; it does not alter parsing or runtime semantics.
183
+ *
184
+ * Families vs singles:
185
+ * - Families (e.g., "shell") hide both ON and OFF flags.
186
+ * - Singles (e.g., "capture") hide the named long flag only.
187
+ *
188
+ * @param program - the GetDotenvCli root instance
189
+ * @param visibility - effective visibility map (false hides; true/undefined shows)
190
+ */
191
+ function applyRootVisibility(program, visibility) {
192
+ if (!visibility)
193
+ return;
194
+ if (Object.keys(visibility).length === 0)
195
+ return;
196
+ const fam = (key, longs) => {
197
+ if (visibility[key] === false)
198
+ hideByLong(program, longs);
199
+ };
200
+ // Families: hide both members when false
201
+ fam('shell', ['--shell', '--shell-off']);
202
+ fam('loadProcess', ['--load-process', '--load-process-off']);
203
+ fam('log', ['--log', '--log-off']);
204
+ fam('excludeDynamic', ['--exclude-dynamic', '--exclude-dynamic-off']);
205
+ fam('excludeEnv', ['--exclude-env', '--exclude-env-off']);
206
+ fam('excludeGlobal', ['--exclude-global', '--exclude-global-off']);
207
+ fam('excludePrivate', ['--exclude-private', '--exclude-private-off']);
208
+ fam('excludePublic', ['--exclude-public', '--exclude-public-off']);
209
+ fam('warnEntropy', ['--entropy-warn', '--entropy-warn-off']);
210
+ // Redact pair (new)
211
+ fam('redact', ['--redact', '--redact-off']);
212
+ // Singles: hide individual long flags
213
+ const singles = [
214
+ ['capture', '--capture'],
215
+ ['strict', '--strict'],
216
+ ['trace', '--trace'],
217
+ ['defaultEnv', '--default-env'],
218
+ ['dotenvToken', '--dotenv-token'],
219
+ ['privateToken', '--private-token'],
220
+ ['dynamicPath', '--dynamic-path'],
221
+ ['paths', '--paths'],
222
+ ['pathsDelimiter', '--paths-delimiter'],
223
+ ['pathsDelimiterPattern', '--paths-delimiter-pattern'],
224
+ ['vars', '--vars'],
225
+ ['varsDelimiter', '--vars-delimiter'],
226
+ ['varsDelimiterPattern', '--vars-delimiter-pattern'],
227
+ ['varsAssignor', '--vars-assignor'],
228
+ ['varsAssignorPattern', '--vars-assignor-pattern'],
229
+ // diagnostics thresholds and whitelist/patterns
230
+ ['entropyThreshold', '--entropy-threshold'],
231
+ ['entropyMinLength', '--entropy-min-length'],
232
+ ['entropyWhitelist', '--entropy-whitelist'],
233
+ ['redactPatterns', '--redact-pattern'],
234
+ ];
235
+ for (const [key, long] of singles) {
236
+ if (visibility[key] === false)
237
+ hideByLong(program, [long]);
238
+ }
239
+ }
240
+
241
+ /**
242
+ * Create a configured get-dotenv CLI host.
243
+ * Applies defaults, installs root hooks, and composes plugins.
244
+ * Returns a runner function that accepts an argv array.
245
+ */
246
+ function createCli(opts = {}) {
247
+ // Pre-compose aws parent/child to avoid nested call-site typing/lint issues
248
+ const alias = typeof opts.alias === 'string' && opts.alias.length > 0
249
+ ? opts.alias
250
+ : 'getdotenv';
251
+ const program = new GetDotenvCli(alias);
252
+ // Default output: normalize help prints so they always end with a blank line.
253
+ // This keeps E2E assertions (CRLF and >=2 trailing newlines) portable across
254
+ // runtimes and capture modes without altering Commander internals.
255
+ const outputCfg = {
256
+ writeOut(str) {
257
+ const txt = typeof str === 'string' ? str : '';
258
+ const hasTwo = /(?:\r?\n){2,}$/.test(txt);
259
+ const hasOne = /\r?\n$/.test(txt);
260
+ const out = hasTwo ? txt : hasOne ? txt + '\n' : txt + '\n\n';
261
+ try {
262
+ process.stdout.write(out);
263
+ }
264
+ catch {
265
+ /* ignore */
266
+ }
267
+ },
268
+ writeErr(str) {
269
+ process.stderr.write(str);
270
+ },
271
+ };
272
+ // Apply default output on root BEFORE composition so subcommands inherit.
273
+ program.configureOutput(outputCfg);
274
+ // Root defaults/visibility for this host (applied once, pre-compose).
275
+ const rootDefaults = opts.rootOptionDefaults ?? {};
276
+ const visibility = opts.rootOptionVisibility ?? {};
277
+ // Tests-only: avoid process.exit during help/version flows under Vitest.
278
+ const underTests = process.env.GETDOTENV_TEST === '1' ||
279
+ typeof process.env.VITEST_WORKER_ID === 'string';
280
+ const dbg = (...args) => {
281
+ if (process.env.GETDOTENV_DEBUG) {
282
+ try {
283
+ const line = args
284
+ .map((a) => (typeof a === 'string' ? a : JSON.stringify(a)))
285
+ .join(' ');
286
+ process.stderr.write(`[getdotenv:run] ${line}\n`);
287
+ }
288
+ catch {
289
+ /* ignore */
290
+ }
291
+ }
292
+ };
293
+ // Pre-install tests-only exitOverride BEFORE composition so compose may override if desired.
294
+ if (underTests) {
295
+ program.exitOverride((err) => {
296
+ const code = err?.code;
297
+ // Commander printed help already; ensure a trailing blank line for tests/CI capture.
298
+ if (code === 'commander.helpDisplayed') {
299
+ try {
300
+ process.stdout.write('\n');
301
+ }
302
+ catch {
303
+ /* ignore */
304
+ }
305
+ return;
306
+ }
307
+ if (code === 'commander.version') {
308
+ return;
309
+ }
310
+ throw err;
311
+ });
312
+ }
313
+ // Root no-op action BEFORE composition so root-only flows trigger hooks;
314
+ // compose() may replace this with its own action.
315
+ program.action(() => {
316
+ /* no-op */
317
+ });
318
+ // Declare root flags and resolution hooks once, pre-compose.
319
+ // 1) Declare flags using the internal builder (no public helper).
320
+ attachRootOptions(program, rootDefaults);
321
+ // 2) Install resolution hooks (preSubcommand/preAction).
322
+ installRootHooks(program, rootDefaults);
323
+ // Apply visibility (hide selected options) after flags are declared.
324
+ if (Object.keys(visibility).length > 0) {
325
+ applyRootVisibility(program, visibility);
326
+ }
327
+ // Compose wiring: user-provided composer wins; otherwise apply shipped defaults.
328
+ if (typeof opts.compose === 'function') {
329
+ opts.compose(program);
330
+ }
331
+ else {
332
+ program
333
+ .use(cmdPlugin({ optionAlias: '-c, --cmd <command...>' }))
334
+ .use(batchPlugin())
335
+ .use(awsPlugin().use(awsWhoamiPlugin()))
336
+ .use(initPlugin());
337
+ }
338
+ // Runner function: accepts full argv or args-only; defaults to process.argv.
339
+ return async function run(argvInput) {
340
+ const argvAll = Array.isArray(argvInput) ? argvInput : process.argv;
341
+ // Derive args-only from a possible full process argv
342
+ const deriveArgsOnly = (v) => {
343
+ if (v.length >= 2) {
344
+ // Common Node/Electron convention: [node, script, ...args]
345
+ return v.slice(2);
346
+ }
347
+ return v.slice();
348
+ };
349
+ const argv = deriveArgsOnly(argvAll);
350
+ // Ensure plugin commands/options are installed before inspecting argv for
351
+ // help-time routing (subcommand vs root help).
352
+ dbg('argv', argv);
353
+ await program.install();
354
+ // Help handling:
355
+ // - Short-circuit ONLY for true top-level -h/--help (no subcommand before flag).
356
+ // - If a subcommand token appears before -h/--help, defer to Commander
357
+ // to render that subcommand's help.
358
+ const helpIdx = argv.findIndex((a) => a === '-h' || a === '--help');
359
+ if (helpIdx >= 0) {
360
+ // Build a set of known subcommand names/aliases on the root.
361
+ const subs = new Set();
362
+ for (const c of program.commands) {
363
+ subs.add(c.name());
364
+ for (const a of c.aliases())
365
+ subs.add(a);
366
+ }
367
+ dbg('helpIdx', helpIdx, 'knownSubs', Array.from(subs.values()));
368
+ const hasSubBeforeHelp = argv
369
+ .slice(0, helpIdx)
370
+ .some((tok) => subs.has(tok));
371
+ if (!hasSubBeforeHelp) {
372
+ await program.brand({
373
+ name: alias,
374
+ importMetaUrl: import.meta.url,
375
+ description: 'Base CLI.',
376
+ ...(typeof opts.branding === 'string' && opts.branding.length > 0
377
+ ? { helpHeader: opts.branding }
378
+ : {}),
379
+ });
380
+ dbg('top-level -h, render root help');
381
+ // Resolve context once without side effects for help rendering.
382
+ const ctx = await program.resolveAndLoad({
383
+ loadProcess: false,
384
+ log: false,
385
+ }, { runAfterResolve: false });
386
+ // Build a help-time defaults bag using the unified stack:
387
+ // baseRootOptionDefaults < createCli rootOptionDefaults < config.rootOptionDefaults
388
+ let cfgDefaults = {};
389
+ try {
390
+ const sources = await resolveGetDotenvConfigSources(import.meta.url);
391
+ cfgDefaults = defaultsDeep({}, sources.packaged?.rootOptionDefaults ?? {}, sources.project?.public?.rootOptionDefaults ?? {}, sources.project?.local?.rootOptionDefaults ?? {});
392
+ }
393
+ catch {
394
+ /* tolerate missing config */
395
+ }
396
+ const mergedDefaultsForHelp = defaultsDeep(baseRootOptionDefaults, rootDefaults, cfgDefaults);
397
+ const { merged: defaultsMerged } = resolveCliOptions({}, mergedDefaultsForHelp, undefined);
398
+ // Use unified defaults directly for help labels (no ctx overlays).
399
+ const helpMerged = { ...defaultsMerged };
400
+ const helpCfg = toHelpConfig(helpMerged, ctx.pluginConfigs);
401
+ // Evaluate dynamic labels
402
+ program.evaluateDynamicOptions(helpCfg);
403
+ // Suppress output only during unit tests; allow E2E to capture.
404
+ const piping = process.env.GETDOTENV_STDIO === 'pipe' ||
405
+ process.env.GETDOTENV_STDOUT === 'pipe';
406
+ if (!(underTests && !piping)) {
407
+ dbg('outputHelp()');
408
+ // Merge visibility for help-time using precedence:
409
+ // createCli(rootOptionVisibility) < packaged/public < project/public < project/local
410
+ try {
411
+ const sources = await resolveGetDotenvConfigSources(import.meta.url);
412
+ const mergedVis = mergeRootVisibility(visibility, sources.packaged?.rootOptionVisibility ?? undefined, sources.project?.public?.rootOptionVisibility ?? undefined, sources.project?.local?.rootOptionVisibility ?? undefined);
413
+ if (Object.keys(mergedVis).length > 0) {
414
+ applyRootVisibility(program, mergedVis);
415
+ }
416
+ }
417
+ catch {
418
+ // best-effort; do not block help
419
+ }
420
+ program.outputHelp();
421
+ }
422
+ return;
423
+ }
424
+ // Subcommand token exists before -h: fall through to normal parsing,
425
+ // letting Commander print that subcommand's help.
426
+ }
427
+ dbg('parseAsync start');
428
+ await program.brand({
429
+ name: alias,
430
+ importMetaUrl: import.meta.url,
431
+ description: 'Base CLI.',
432
+ ...(typeof opts.branding === 'string' && opts.branding.length > 0
433
+ ? { helpHeader: opts.branding }
434
+ : {}),
435
+ });
436
+ await program.parseAsync(['node', alias, ...argv]);
437
+ };
438
+ }
439
+
440
+ export { createCli as c };
@@ -0,0 +1,19 @@
1
+ import { t as tokenIntercept } from './getSSOTokenFromFile-otmZHSRV.mjs';
2
+ import { h as fileIntercept } from './index-BNcKuiBy.mjs';
3
+
4
+ const externalDataInterceptor = {
5
+ getFileRecord() {
6
+ return fileIntercept;
7
+ },
8
+ interceptFile(path, contents) {
9
+ fileIntercept[path] = Promise.resolve(contents);
10
+ },
11
+ getTokenRecord() {
12
+ return tokenIntercept;
13
+ },
14
+ interceptToken(id, contents) {
15
+ tokenIntercept[id] = contents;
16
+ },
17
+ };
18
+
19
+ export { externalDataInterceptor as e };
@@ -0,0 +1,22 @@
1
+ import { readFile } from 'fs/promises';
2
+ import { createHash } from 'crypto';
3
+ import { join } from 'path';
4
+ import { j as getHomeDir } from './index-BNcKuiBy.mjs';
5
+
6
+ const getSSOTokenFilepath = (id) => {
7
+ const hasher = createHash("sha1");
8
+ const cacheName = hasher.update(id).digest("hex");
9
+ return join(getHomeDir(), ".aws", "sso", "cache", `${cacheName}.json`);
10
+ };
11
+
12
+ const tokenIntercept = {};
13
+ const getSSOTokenFromFile = async (id) => {
14
+ if (tokenIntercept[id]) {
15
+ return tokenIntercept[id];
16
+ }
17
+ const ssoTokenFilepath = getSSOTokenFilepath(id);
18
+ const ssoTokenText = await readFile(ssoTokenFilepath, "utf8");
19
+ return JSON.parse(ssoTokenText);
20
+ };
21
+
22
+ export { getSSOTokenFromFile as a, getSSOTokenFilepath as g, tokenIntercept as t };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Build a help-time configuration bag for dynamic option descriptions.
3
+ * Centralizes construction and reduces inline casts at call sites.
4
+ */
5
+ const toHelpConfig = (merged, plugins) => {
6
+ return {
7
+ ...merged,
8
+ plugins: plugins ?? {},
9
+ };
10
+ };
11
+
12
+ export { toHelpConfig as t };