@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
package/dist/config.d.ts CHANGED
@@ -1,8 +1,13 @@
1
- type Scripts = Record<string, string | {
1
+ /**
2
+ * Scripts table shape (configurable shell type).
3
+ */
4
+ type ScriptsTable<TShell extends string | boolean = string | boolean> = Record<string, string | {
2
5
  cmd: string;
3
- shell?: string | boolean;
6
+ shell?: TShell | undefined;
4
7
  }>;
5
8
 
9
+ type Scripts = ScriptsTable;
10
+
6
11
  type GetDotenvConfigResolved = {
7
12
  dotenvToken?: string;
8
13
  privateToken?: string;
@@ -1,12 +1,19 @@
1
1
  /**
2
- * A minimal representation of an environment key/value mapping.
3
- * Values may be `undefined` to represent "unset". */ type ProcessEnv = Record<string, string | undefined>;
4
-
5
- type Scripts = Record<string, string | {
2
+ * Scripts table shape (configurable shell type).
3
+ */
4
+ type ScriptsTable<TShell extends string | boolean = string | boolean> = Record<string, string | {
6
5
  cmd: string;
7
- shell?: string | boolean;
6
+ shell?: TShell | undefined;
8
7
  }>;
9
8
 
9
+ type Scripts = ScriptsTable;
10
+
11
+ /**
12
+ * A minimal representation of an environment key/value mapping.
13
+ * Values may be `undefined` to represent "unset".
14
+ */
15
+ type ProcessEnv = Record<string, string | undefined>;
16
+
10
17
  type GetDotenvConfigResolved = {
11
18
  dotenvToken?: string;
12
19
  privateToken?: string;
@@ -39,12 +46,17 @@ type OverlayConfigSources = {
39
46
  * Programmatic explicit vars (if provided) override all config slices.
40
47
  * Progressive expansion is applied within each slice.
41
48
  */
42
- declare const overlayEnv: ({ base, env, configs, programmaticVars, }: {
43
- base: ProcessEnv;
49
+ declare function overlayEnv<B extends ProcessEnv | Readonly<Record<string, string | undefined>>>(args: {
50
+ base: B;
51
+ env: string | undefined;
52
+ configs: OverlayConfigSources;
53
+ }): B;
54
+ declare function overlayEnv<B extends ProcessEnv | Readonly<Record<string, string | undefined>>, P extends ProcessEnv | Readonly<Record<string, string | undefined>>>(args: {
55
+ base: B;
44
56
  env: string | undefined;
45
57
  configs: OverlayConfigSources;
46
- programmaticVars?: ProcessEnv;
47
- }) => ProcessEnv;
58
+ programmaticVars: P;
59
+ }): B & P;
48
60
 
49
61
  export { overlayEnv };
50
62
  export type { OverlayConfigSources };
@@ -109,14 +109,18 @@ const dotenvExpand = (value, ref = process.env) => {
109
109
  * When `progressive` is true, each expanded key becomes available for
110
110
  * subsequent expansions in the same object (left-to-right by object key order).
111
111
  */
112
- const dotenvExpandAll = (values = {}, options = {}) => Object.keys(values).reduce((acc, key) => {
113
- const { ref = process.env, progressive = false } = options;
114
- acc[key] = dotenvExpand(values[key], {
115
- ...ref,
116
- ...(progressive ? acc : {}),
117
- });
118
- return acc;
119
- }, {});
112
+ function dotenvExpandAll(values, options = {}) {
113
+ const { ref = process.env, progressive = false, } = options;
114
+ const out = Object.keys(values).reduce((acc, key) => {
115
+ acc[key] = dotenvExpand(values[key], {
116
+ ...ref,
117
+ ...(progressive ? acc : {}),
118
+ });
119
+ return acc;
120
+ }, {});
121
+ // Key-preserving return with a permissive index signature to allow later additions.
122
+ return out;
123
+ }
120
124
 
121
125
  const applyKv = (current, kv) => {
122
126
  if (!kv || Object.keys(kv).length === 0)
@@ -132,16 +136,7 @@ const applyConfigSlice = (current, cfg, env) => {
132
136
  const envKv = env && cfg.envVars ? cfg.envVars[env] : undefined;
133
137
  return applyKv(afterGlobal, envKv);
134
138
  };
135
- /**
136
- * Overlay config-provided values onto a base ProcessEnv using precedence axes:
137
- * - kind: env \> global
138
- * - privacy: local \> public
139
- * - source: project \> packaged \> base
140
- *
141
- * Programmatic explicit vars (if provided) override all config slices.
142
- * Progressive expansion is applied within each slice.
143
- */
144
- const overlayEnv = ({ base, env, configs, programmaticVars, }) => {
139
+ function overlayEnv({ base, env, configs, programmaticVars, }) {
145
140
  let current = { ...base };
146
141
  // Source: packaged (public -> local)
147
142
  current = applyConfigSlice(current, configs.packaged, env);
@@ -156,6 +151,6 @@ const overlayEnv = ({ base, env, configs, programmaticVars, }) => {
156
151
  current = applyKv(current, toApply);
157
152
  }
158
153
  return current;
159
- };
154
+ }
160
155
 
161
156
  export { overlayEnv };