@karmaniverous/get-dotenv 6.1.0 → 6.2.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 (51) hide show
  1. package/README.md +20 -14
  2. package/dist/cli.d.ts +58 -2
  3. package/dist/cli.mjs +800 -364
  4. package/dist/cliHost.d.ts +216 -17
  5. package/dist/cliHost.mjs +178 -14
  6. package/dist/config.d.ts +12 -0
  7. package/dist/config.mjs +79 -2
  8. package/dist/env-overlay.d.ts +8 -0
  9. package/dist/getdotenv.cli.mjs +800 -364
  10. package/dist/index.d.ts +220 -35
  11. package/dist/index.mjs +851 -365
  12. package/dist/plugins-aws.d.ts +94 -6
  13. package/dist/plugins-aws.mjs +462 -184
  14. package/dist/plugins-batch.d.ts +85 -3
  15. package/dist/plugins-batch.mjs +203 -54
  16. package/dist/plugins-cmd.d.ts +85 -3
  17. package/dist/plugins-cmd.mjs +150 -28
  18. package/dist/plugins-init.d.ts +85 -3
  19. package/dist/plugins-init.mjs +270 -131
  20. package/dist/plugins.d.ts +85 -4
  21. package/dist/plugins.mjs +800 -364
  22. package/dist/templates/cli/plugins/hello/defaultAction.ts +27 -0
  23. package/dist/templates/cli/plugins/hello/index.ts +26 -0
  24. package/dist/templates/cli/plugins/hello/options.ts +31 -0
  25. package/dist/templates/cli/plugins/hello/strangerAction.ts +20 -0
  26. package/dist/templates/cli/plugins/hello/types.ts +13 -0
  27. package/dist/templates/defaultAction.ts +27 -0
  28. package/dist/templates/hello/defaultAction.ts +27 -0
  29. package/dist/templates/hello/index.ts +26 -0
  30. package/dist/templates/hello/options.ts +31 -0
  31. package/dist/templates/hello/strangerAction.ts +20 -0
  32. package/dist/templates/hello/types.ts +13 -0
  33. package/dist/templates/index.ts +23 -22
  34. package/dist/templates/options.ts +31 -0
  35. package/dist/templates/plugins/hello/defaultAction.ts +27 -0
  36. package/dist/templates/plugins/hello/index.ts +26 -0
  37. package/dist/templates/plugins/hello/options.ts +31 -0
  38. package/dist/templates/plugins/hello/strangerAction.ts +20 -0
  39. package/dist/templates/plugins/hello/types.ts +13 -0
  40. package/dist/templates/strangerAction.ts +20 -0
  41. package/dist/templates/types.ts +13 -0
  42. package/package.json +3 -4
  43. package/templates/cli/plugins/hello/defaultAction.ts +27 -0
  44. package/templates/cli/plugins/hello/index.ts +26 -0
  45. package/templates/cli/plugins/hello/options.ts +31 -0
  46. package/templates/cli/plugins/hello/strangerAction.ts +20 -0
  47. package/templates/cli/plugins/hello/types.ts +13 -0
  48. package/dist/templates/cli/plugins/hello.ts +0 -42
  49. package/dist/templates/hello.ts +0 -42
  50. package/dist/templates/plugins/hello.ts +0 -42
  51. package/templates/cli/plugins/hello.ts +0 -42
package/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ ![This is how.](./assets/contributions.png)
2
+
1
3
  > Load, expand, and compose environment variables from a deterministic dotenv cascade, then execute commands under that context. Use get‑dotenv as a library, a CLI, or a plugin‑first host to build dotenv‑aware tooling with cross‑platform shell control, CI‑friendly capture, and clear diagnostics.
2
4
 
3
5
  # get-dotenv
@@ -24,19 +26,19 @@ See full guides:
24
26
  - [Shipped plugins](./guides/shipped/index.md)
25
27
  - [Authoring plugins](./guides/authoring/index.md) (host, lifecycle, exec, diagnostics)
26
28
 
27
- ## Use Cases
28
-
29
- - Execute deployment steps across many repositories from one command sequence. See [batch plugin guide](./guides/shipped/batch.md)
30
- - Run config‑driven, environment‑aware operations with simple CLI commands. See [config guide](./guides/config.md)
31
- - Compose a rich CLI from shipped and third‑party plugins and share it across projects. See [shipped plugins overview](./guides/shipped/index.md)
32
- - Drive complex AWS workflows in an authenticated, environment‑aware context. See [aws plugin guide](./guides/shipped/aws.md)
33
- - Scaffold a project config and a host‑based CLI skeleton in seconds. See [init plugin guide](./guides/shipped/init.md)
34
- - Batch lint/build/test across a monorepo with deterministic output. See [batch plugin guide](./guides/shipped/batch.md)
35
- - Run cross‑platform commands in CI with normalized shells and capture. See [shell guide](./guides/shell.md)
36
- - Programmatically compose env and run tools inside Node scripts. See [Getting started](./guides/getting-started.md)
37
- - Add observability without leaking secrets using trace, redaction, and entropy warnings. See [diagnostics guide](./guides/authoring/diagnostics.md)
38
- - Author new plugins with maximum DX and minimal boilerplate. See [authoring plugins guide](./guides/authoring/index.md)
39
-
29
+ ## Use Cases
30
+
31
+ - Execute deployment steps across many repositories from one command sequence. See [batch plugin guide](./guides/shipped/batch.md)
32
+ - Run config‑driven, environment‑aware operations with simple CLI commands. See [config guide](./guides/config.md)
33
+ - Compose a rich CLI from shipped and third‑party plugins and share it across projects. See [shipped plugins overview](./guides/shipped/index.md)
34
+ - Drive complex AWS workflows in an authenticated, environment‑aware context. See [aws plugin guide](./guides/shipped/aws.md)
35
+ - Scaffold a project config and a host‑based CLI skeleton in seconds. See [init plugin guide](./guides/shipped/init.md)
36
+ - Batch lint/build/test across a monorepo with deterministic output. See [batch plugin guide](./guides/shipped/batch.md)
37
+ - Run cross‑platform commands in CI with normalized shells and capture. See [shell guide](./guides/shell.md)
38
+ - Programmatically compose env and run tools inside Node scripts. See [Getting started](./guides/getting-started.md)
39
+ - Add observability without leaking secrets using trace, redaction, and entropy warnings. See [diagnostics guide](./guides/authoring/diagnostics.md)
40
+ - Author new plugins with maximum DX and minimal boilerplate. See [authoring plugins guide](./guides/authoring/index.md)
41
+
40
42
  ## Requirements
41
43
 
42
44
  - Node.js ≥ 20 (this repository pins 22.19.0 for CI/reproducibility)
@@ -70,7 +72,7 @@ Embed a CLI quickly (shipped plugins wired for you):
70
72
  #!/usr/bin/env node
71
73
  import { createCli } from '@karmaniverous/get-dotenv/cli';
72
74
 
73
- await createCli({ alias: 'toolbox' })();
75
+ await createCli({ alias: 'toolbox' })();
74
76
  ```
75
77
 
76
78
  More first steps and tips at [Getting Started](./guides/getting-started.md)
@@ -151,3 +153,7 @@ See [CHANGELOG.md](./CHANGELOG.md)
151
153
  ## License
152
154
 
153
155
  BSD‑3‑Clause — see [LICENSE](./LICENSE)
156
+
157
+ ---
158
+
159
+ Built for you with ❤️ on Bali! Find more great tools & templates on [my GitHub Profile](https://github.com/karmaniverous).
package/dist/cli.d.ts CHANGED
@@ -107,9 +107,21 @@ type ScriptsTable<TShell extends string | boolean = string | boolean> = Record<s
107
107
  * @public
108
108
  */
109
109
  interface GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> {
110
+ /**
111
+ * Fully resolved option bag used to compute this context.
112
+ */
110
113
  optionsResolved: TOptions;
114
+ /**
115
+ * Final composed dotenv environment for this invocation.
116
+ */
111
117
  dotenv: ProcessEnv;
118
+ /**
119
+ * Optional runtime plugin state bag. Plugins may publish non-sensitive metadata here.
120
+ */
112
121
  plugins?: Record<string, unknown>;
122
+ /**
123
+ * Per-plugin validated configuration slices keyed by realized mount path.
124
+ */
113
125
  pluginConfigs?: Record<string, unknown>;
114
126
  }
115
127
  /**
@@ -135,6 +147,14 @@ interface BrandOptions {
135
147
  * For the current step this mirrors the RAW schema; later stages may further
136
148
  * narrow types post-resolution in the host pipeline.
137
149
  */
150
+ /**
151
+ * CLI options schema (resolved).
152
+ *
153
+ * Today this mirrors {@link getDotenvCliOptionsSchemaRaw}, but is kept as a distinct export
154
+ * so future resolution steps can narrow or materialize defaults without breaking the API.
155
+ *
156
+ * @public
157
+ */
138
158
  declare const getDotenvCliOptionsSchemaResolved: z.ZodObject<{
139
159
  defaultEnv: z.ZodOptional<z.ZodString>;
140
160
  dotenvToken: z.ZodOptional<z.ZodString>;
@@ -178,6 +198,14 @@ declare const getDotenvCliOptionsSchemaResolved: z.ZodObject<{
178
198
  * For now, this mirrors the RAW schema; future stages may materialize defaults
179
199
  * and narrow shapes as resolution is wired into the host.
180
200
  */
201
+ /**
202
+ * Programmatic options schema (resolved).
203
+ *
204
+ * Today this mirrors {@link getDotenvOptionsSchemaRaw}, but is kept as a distinct export
205
+ * so future resolution steps can narrow or materialize defaults without breaking the API.
206
+ *
207
+ * @public
208
+ */
181
209
  declare const getDotenvOptionsSchemaResolved: z.ZodObject<{
182
210
  defaultEnv: z.ZodOptional<z.ZodString>;
183
211
  dotenvToken: z.ZodOptional<z.ZodString>;
@@ -232,7 +260,7 @@ type Logger = Record<string, (...args: unknown[]) => void> | typeof console;
232
260
  * Canonical programmatic options type (schema-derived).
233
261
  * This type is the single source of truth for programmatic options.
234
262
  */
235
- type GetDotenvOptions = z.output<typeof getDotenvOptionsSchemaResolved> & {
263
+ type GetDotenvOptions = Omit<z.output<typeof getDotenvOptionsSchemaResolved>, 'logger' | 'dynamic'> & {
236
264
  /**
237
265
  * Compile-time overlay: narrowed logger for DX (schema stores unknown).
238
266
  */
@@ -253,11 +281,15 @@ type Scripts = ScriptsTable;
253
281
  * stringly paths/vars, and inherited programmatic fields (minus normalized
254
282
  * shapes that are handled by resolution).
255
283
  */
256
- type GetDotenvCliOptions = z.output<typeof getDotenvCliOptionsSchemaResolved> & {
284
+ type GetDotenvCliOptions = Omit<z.output<typeof getDotenvCliOptionsSchemaResolved>, 'logger' | 'dynamic' | 'scripts'> & {
257
285
  /**
258
286
  * Compile-only overlay for DX: logger narrowed from unknown.
259
287
  */
260
288
  logger: Logger;
289
+ /**
290
+ * Compile-only overlay for DX: dynamic map narrowed from unknown.
291
+ */
292
+ dynamic?: GetDotenvDynamic;
261
293
  /**
262
294
  * Compile-only overlay for DX: scripts narrowed from Record\<string, unknown\>.
263
295
  */
@@ -320,13 +352,37 @@ interface GetDotenvCliPublic<TOptions extends GetDotenvOptions = GetDotenvOption
320
352
  getCtx(): GetDotenvCliCtx<TOptions>;
321
353
  /** Check whether a context has been resolved (non-throwing). */
322
354
  hasCtx(): boolean;
355
+ /**
356
+ * Resolve options and compute the dotenv context for this invocation.
357
+ *
358
+ * @param customOptions - Partial options to overlay for this invocation.
359
+ * @param opts - Optional resolver behavior switches (for example, whether to run `afterResolve`).
360
+ * @returns A promise resolving to the computed invocation context.
361
+ */
323
362
  resolveAndLoad(customOptions?: Partial<TOptions>, opts?: ResolveAndLoadOptions): Promise<GetDotenvCliCtx<TOptions>>;
363
+ /**
364
+ * Tag an option with a help group identifier for grouped root help rendering.
365
+ *
366
+ * @param opt - The Commander option to tag.
367
+ * @param group - Group identifier (for example, `base`, `app`, or `plugin:<name>`).
368
+ * @returns Nothing.
369
+ */
324
370
  setOptionGroup(opt: Option, group: string): void;
325
371
  /**
326
372
  * Create a dynamic option whose description is computed at help time
327
373
  * from the resolved configuration.
328
374
  */
375
+ /**
376
+ * Create a dynamic option whose description is computed at help time from the resolved configuration.
377
+ *
378
+ * @param flags - Commander option flags usage string.
379
+ * @param desc - Description builder called during help rendering with the resolved help config.
380
+ * @param parser - Optional argument parser.
381
+ * @param defaultValue - Optional default value.
382
+ * @returns A Commander `Option` instance with a dynamic description.
383
+ */
329
384
  createDynamicOption<Usage extends string>(flags: Usage, desc: (cfg: ResolvedHelpConfig) => string, parser?: (value: string, previous?: unknown) => unknown, defaultValue?: unknown): Option<Usage>;
385
+ /** {@inheritDoc} */
330
386
  createDynamicOption<Usage extends string, TValue = unknown>(flags: Usage, desc: (cfg: ResolvedHelpConfig) => string, parser: (value: string, previous?: TValue) => TValue, defaultValue?: TValue): Option<Usage>;
331
387
  }
332
388
  /**