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