@karmaniverous/get-dotenv 5.2.6 → 6.0.0-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.
Files changed (55) hide show
  1. package/README.md +106 -70
  2. package/dist/cliHost.d.ts +232 -226
  3. package/dist/cliHost.mjs +777 -545
  4. package/dist/config.d.ts +7 -2
  5. package/dist/env-overlay.d.ts +21 -9
  6. package/dist/env-overlay.mjs +14 -19
  7. package/dist/getdotenv.cli.mjs +1366 -1163
  8. package/dist/index.d.ts +415 -242
  9. package/dist/index.mjs +1364 -1414
  10. package/dist/plugins-aws.d.ts +149 -94
  11. package/dist/plugins-aws.mjs +307 -195
  12. package/dist/plugins-batch.d.ts +153 -99
  13. package/dist/plugins-batch.mjs +277 -95
  14. package/dist/plugins-cmd.d.ts +140 -94
  15. package/dist/plugins-cmd.mjs +636 -502
  16. package/dist/plugins-demo.d.ts +140 -94
  17. package/dist/plugins-demo.mjs +237 -46
  18. package/dist/plugins-init.d.ts +140 -94
  19. package/dist/plugins-init.mjs +129 -12
  20. package/dist/plugins.d.ts +166 -103
  21. package/dist/plugins.mjs +977 -840
  22. package/package.json +15 -53
  23. package/templates/cli/ts/plugins/hello.ts +27 -6
  24. package/templates/config/js/getdotenv.config.js +1 -1
  25. package/templates/config/ts/getdotenv.config.ts +9 -2
  26. package/dist/cliHost.cjs +0 -1875
  27. package/dist/cliHost.d.cts +0 -409
  28. package/dist/cliHost.d.mts +0 -409
  29. package/dist/config.cjs +0 -252
  30. package/dist/config.d.cts +0 -55
  31. package/dist/config.d.mts +0 -55
  32. package/dist/env-overlay.cjs +0 -163
  33. package/dist/env-overlay.d.cts +0 -50
  34. package/dist/env-overlay.d.mts +0 -50
  35. package/dist/index.cjs +0 -4140
  36. package/dist/index.d.cts +0 -457
  37. package/dist/index.d.mts +0 -457
  38. package/dist/plugins-aws.cjs +0 -667
  39. package/dist/plugins-aws.d.cts +0 -158
  40. package/dist/plugins-aws.d.mts +0 -158
  41. package/dist/plugins-batch.cjs +0 -616
  42. package/dist/plugins-batch.d.cts +0 -180
  43. package/dist/plugins-batch.d.mts +0 -180
  44. package/dist/plugins-cmd.cjs +0 -1113
  45. package/dist/plugins-cmd.d.cts +0 -178
  46. package/dist/plugins-cmd.d.mts +0 -178
  47. package/dist/plugins-demo.cjs +0 -307
  48. package/dist/plugins-demo.d.cts +0 -158
  49. package/dist/plugins-demo.d.mts +0 -158
  50. package/dist/plugins-init.cjs +0 -289
  51. package/dist/plugins-init.d.cts +0 -162
  52. package/dist/plugins-init.d.mts +0 -162
  53. package/dist/plugins.cjs +0 -2283
  54. package/dist/plugins.d.cts +0 -210
  55. package/dist/plugins.d.mts +0 -210
@@ -1,180 +0,0 @@
1
- import { Command } from 'commander';
2
- import { ZodType } from 'zod';
3
-
4
- /**
5
- * A minimal representation of an environment key/value mapping.
6
- * Values may be `undefined` to represent "unset". */ type ProcessEnv = Record<string, string | undefined>;
7
- /**
8
- * Dynamic variable function signature. Receives the current expanded variables
9
- * and the selected environment (if any), and returns either a string to set
10
- * or `undefined` to unset/skip the variable.
11
- */
12
- type GetDotenvDynamicFunction = (vars: ProcessEnv, env: string | undefined) => string | undefined;
13
- type GetDotenvDynamic = Record<string, GetDotenvDynamicFunction | ReturnType<GetDotenvDynamicFunction>>;
14
- type Logger = Record<string, (...args: unknown[]) => void> | typeof console;
15
- /**
16
- * Options passed programmatically to `getDotenv`.
17
- */
18
- interface GetDotenvOptions {
19
- /**
20
- * default target environment (used if `env` is not provided)
21
- */
22
- defaultEnv?: string;
23
- /**
24
- * token indicating a dotenv file
25
- */
26
- dotenvToken: string;
27
- /**
28
- * path to JS/TS module default-exporting an object keyed to dynamic variable functions
29
- */
30
- dynamicPath?: string;
31
- /**
32
- * Programmatic dynamic variables map. When provided, this takes precedence
33
- * over {@link GetDotenvOptions.dynamicPath}.
34
- */
35
- dynamic?: GetDotenvDynamic;
36
- /**
37
- * target environment
38
- */
39
- env?: string;
40
- /**
41
- * exclude dynamic variables from loading
42
- */
43
- excludeDynamic?: boolean;
44
- /**
45
- * exclude environment-specific variables from loading
46
- */
47
- excludeEnv?: boolean;
48
- /**
49
- * exclude global variables from loading
50
- */
51
- excludeGlobal?: boolean;
52
- /**
53
- * exclude private variables from loading
54
- */
55
- excludePrivate?: boolean;
56
- /**
57
- * exclude public variables from loading
58
- */
59
- excludePublic?: boolean;
60
- /**
61
- * load dotenv variables to `process.env`
62
- */
63
- loadProcess?: boolean;
64
- /**
65
- * log loaded dotenv variables to `logger`
66
- */
67
- log?: boolean;
68
- /**
69
- * logger object (defaults to console)
70
- */
71
- logger?: Logger;
72
- /**
73
- * if populated, writes consolidated dotenv file to this path (follows dotenvExpand rules)
74
- */
75
- outputPath?: string;
76
- /**
77
- * array of input directory paths
78
- */
79
- paths?: string[];
80
- /**
81
- * filename token indicating private variables
82
- */
83
- privateToken?: string;
84
- /**
85
- * explicit variables to include
86
- */
87
- vars?: ProcessEnv;
88
- /**
89
- * Reserved: config loader flag (no-op).
90
- * The plugin-first host and generator paths already use the config
91
- * loader/overlay pipeline unconditionally (no-op when no config files
92
- * are present). This flag is accepted for forward compatibility but
93
- * currently has no effect.
94
- */
95
- useConfigLoader?: boolean;
96
- }
97
-
98
- /** src/cliHost/definePlugin.ts
99
- * Plugin contracts for the GetDotenv CLI host.
100
- *
101
- * This module exposes a structural public interface for the host that plugins
102
- * should use (GetDotenvCliPublic). Using a structural type at the seam avoids
103
- * nominal class identity issues (private fields) in downstream consumers.
104
- */
105
-
106
- /**
107
- * Structural public interface for the host exposed to plugins.
108
- * - Extends Commander.Command so plugins can attach options/commands/hooks.
109
- * - Adds host-specific helpers used by built-in plugins.
110
- *
111
- * Purpose: remove nominal class identity (private fields) from the plugin seam
112
- * to avoid TS2379 under exactOptionalPropertyTypes in downstream consumers.
113
- */
114
- type GetDotenvCliPublic<TOptions extends GetDotenvOptions = GetDotenvOptions> = Command & {
115
- ns: (name: string) => Command;
116
- getCtx: () => GetDotenvCliCtx<TOptions> | undefined;
117
- resolveAndLoad: (customOptions?: Partial<TOptions>) => Promise<GetDotenvCliCtx<TOptions>>;
118
- };
119
- /** Public plugin contract used by the GetDotenv CLI host. */
120
- interface GetDotenvCliPlugin {
121
- id?: string;
122
- /**
123
- * Setup phase: register commands and wiring on the provided CLI instance.
124
- * Runs parent → children (pre-order).
125
- */
126
- setup: (cli: GetDotenvCliPublic) => void | Promise<void>;
127
- /**
128
- * After the dotenv context is resolved, initialize any clients/secrets
129
- * or attach per-plugin state under ctx.plugins (by convention).
130
- * Runs parent → children (pre-order).
131
- */
132
- afterResolve?: (cli: GetDotenvCliPublic, ctx: GetDotenvCliCtx) => void | Promise<void>;
133
- /**
134
- * Optional Zod schema for this plugin's config slice (from config.plugins[id]).
135
- * When provided, the host validates the merged config under the guarded loader path.
136
- */
137
- configSchema?: ZodType;
138
- /**
139
- * Compositional children. Installed after the parent per pre-order.
140
- */
141
- children: GetDotenvCliPlugin[];
142
- /**
143
- * Compose a child plugin. Returns the parent to enable chaining.
144
- */
145
- use: (child: GetDotenvCliPlugin) => GetDotenvCliPlugin;
146
- }
147
-
148
- /** * Per-invocation context shared with plugins and actions. */
149
- type GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> = {
150
- optionsResolved: TOptions;
151
- dotenv: ProcessEnv;
152
- plugins?: Record<string, unknown>;
153
- pluginConfigs?: Record<string, unknown>;
154
- };
155
-
156
- /**
157
- * Batch services (neutral): resolve command and shell settings.
158
- * Shared by the generator path and the batch plugin to avoid circular deps.
159
- */
160
- type Scripts = Record<string, string | {
161
- cmd: string;
162
- shell?: string | boolean | undefined;
163
- }>;
164
-
165
- type BatchPluginOptions = {
166
- scripts?: Scripts;
167
- shell?: string | boolean;
168
- logger?: Logger;
169
- };
170
-
171
- /**
172
- * Batch plugin for the GetDotenv CLI host.
173
- *
174
- * Mirrors the legacy batch subcommand behavior without altering the shipped CLI. * Options:
175
- * - scripts/shell: used to resolve command and shell behavior per script or global default.
176
- * - logger: defaults to console.
177
- */
178
- declare const batchPlugin: (opts?: BatchPluginOptions) => GetDotenvCliPlugin;
179
-
180
- export { batchPlugin };
@@ -1,180 +0,0 @@
1
- import { Command } from 'commander';
2
- import { ZodType } from 'zod';
3
-
4
- /**
5
- * A minimal representation of an environment key/value mapping.
6
- * Values may be `undefined` to represent "unset". */ type ProcessEnv = Record<string, string | undefined>;
7
- /**
8
- * Dynamic variable function signature. Receives the current expanded variables
9
- * and the selected environment (if any), and returns either a string to set
10
- * or `undefined` to unset/skip the variable.
11
- */
12
- type GetDotenvDynamicFunction = (vars: ProcessEnv, env: string | undefined) => string | undefined;
13
- type GetDotenvDynamic = Record<string, GetDotenvDynamicFunction | ReturnType<GetDotenvDynamicFunction>>;
14
- type Logger = Record<string, (...args: unknown[]) => void> | typeof console;
15
- /**
16
- * Options passed programmatically to `getDotenv`.
17
- */
18
- interface GetDotenvOptions {
19
- /**
20
- * default target environment (used if `env` is not provided)
21
- */
22
- defaultEnv?: string;
23
- /**
24
- * token indicating a dotenv file
25
- */
26
- dotenvToken: string;
27
- /**
28
- * path to JS/TS module default-exporting an object keyed to dynamic variable functions
29
- */
30
- dynamicPath?: string;
31
- /**
32
- * Programmatic dynamic variables map. When provided, this takes precedence
33
- * over {@link GetDotenvOptions.dynamicPath}.
34
- */
35
- dynamic?: GetDotenvDynamic;
36
- /**
37
- * target environment
38
- */
39
- env?: string;
40
- /**
41
- * exclude dynamic variables from loading
42
- */
43
- excludeDynamic?: boolean;
44
- /**
45
- * exclude environment-specific variables from loading
46
- */
47
- excludeEnv?: boolean;
48
- /**
49
- * exclude global variables from loading
50
- */
51
- excludeGlobal?: boolean;
52
- /**
53
- * exclude private variables from loading
54
- */
55
- excludePrivate?: boolean;
56
- /**
57
- * exclude public variables from loading
58
- */
59
- excludePublic?: boolean;
60
- /**
61
- * load dotenv variables to `process.env`
62
- */
63
- loadProcess?: boolean;
64
- /**
65
- * log loaded dotenv variables to `logger`
66
- */
67
- log?: boolean;
68
- /**
69
- * logger object (defaults to console)
70
- */
71
- logger?: Logger;
72
- /**
73
- * if populated, writes consolidated dotenv file to this path (follows dotenvExpand rules)
74
- */
75
- outputPath?: string;
76
- /**
77
- * array of input directory paths
78
- */
79
- paths?: string[];
80
- /**
81
- * filename token indicating private variables
82
- */
83
- privateToken?: string;
84
- /**
85
- * explicit variables to include
86
- */
87
- vars?: ProcessEnv;
88
- /**
89
- * Reserved: config loader flag (no-op).
90
- * The plugin-first host and generator paths already use the config
91
- * loader/overlay pipeline unconditionally (no-op when no config files
92
- * are present). This flag is accepted for forward compatibility but
93
- * currently has no effect.
94
- */
95
- useConfigLoader?: boolean;
96
- }
97
-
98
- /** src/cliHost/definePlugin.ts
99
- * Plugin contracts for the GetDotenv CLI host.
100
- *
101
- * This module exposes a structural public interface for the host that plugins
102
- * should use (GetDotenvCliPublic). Using a structural type at the seam avoids
103
- * nominal class identity issues (private fields) in downstream consumers.
104
- */
105
-
106
- /**
107
- * Structural public interface for the host exposed to plugins.
108
- * - Extends Commander.Command so plugins can attach options/commands/hooks.
109
- * - Adds host-specific helpers used by built-in plugins.
110
- *
111
- * Purpose: remove nominal class identity (private fields) from the plugin seam
112
- * to avoid TS2379 under exactOptionalPropertyTypes in downstream consumers.
113
- */
114
- type GetDotenvCliPublic<TOptions extends GetDotenvOptions = GetDotenvOptions> = Command & {
115
- ns: (name: string) => Command;
116
- getCtx: () => GetDotenvCliCtx<TOptions> | undefined;
117
- resolveAndLoad: (customOptions?: Partial<TOptions>) => Promise<GetDotenvCliCtx<TOptions>>;
118
- };
119
- /** Public plugin contract used by the GetDotenv CLI host. */
120
- interface GetDotenvCliPlugin {
121
- id?: string;
122
- /**
123
- * Setup phase: register commands and wiring on the provided CLI instance.
124
- * Runs parent → children (pre-order).
125
- */
126
- setup: (cli: GetDotenvCliPublic) => void | Promise<void>;
127
- /**
128
- * After the dotenv context is resolved, initialize any clients/secrets
129
- * or attach per-plugin state under ctx.plugins (by convention).
130
- * Runs parent → children (pre-order).
131
- */
132
- afterResolve?: (cli: GetDotenvCliPublic, ctx: GetDotenvCliCtx) => void | Promise<void>;
133
- /**
134
- * Optional Zod schema for this plugin's config slice (from config.plugins[id]).
135
- * When provided, the host validates the merged config under the guarded loader path.
136
- */
137
- configSchema?: ZodType;
138
- /**
139
- * Compositional children. Installed after the parent per pre-order.
140
- */
141
- children: GetDotenvCliPlugin[];
142
- /**
143
- * Compose a child plugin. Returns the parent to enable chaining.
144
- */
145
- use: (child: GetDotenvCliPlugin) => GetDotenvCliPlugin;
146
- }
147
-
148
- /** * Per-invocation context shared with plugins and actions. */
149
- type GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> = {
150
- optionsResolved: TOptions;
151
- dotenv: ProcessEnv;
152
- plugins?: Record<string, unknown>;
153
- pluginConfigs?: Record<string, unknown>;
154
- };
155
-
156
- /**
157
- * Batch services (neutral): resolve command and shell settings.
158
- * Shared by the generator path and the batch plugin to avoid circular deps.
159
- */
160
- type Scripts = Record<string, string | {
161
- cmd: string;
162
- shell?: string | boolean | undefined;
163
- }>;
164
-
165
- type BatchPluginOptions = {
166
- scripts?: Scripts;
167
- shell?: string | boolean;
168
- logger?: Logger;
169
- };
170
-
171
- /**
172
- * Batch plugin for the GetDotenv CLI host.
173
- *
174
- * Mirrors the legacy batch subcommand behavior without altering the shipped CLI. * Options:
175
- * - scripts/shell: used to resolve command and shell behavior per script or global default.
176
- * - logger: defaults to console.
177
- */
178
- declare const batchPlugin: (opts?: BatchPluginOptions) => GetDotenvCliPlugin;
179
-
180
- export { batchPlugin };