@karmaniverous/get-dotenv 6.0.0-0 → 6.0.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 (93) hide show
  1. package/README.md +86 -334
  2. package/dist/cli.d.ts +569 -0
  3. package/dist/cli.mjs +18788 -0
  4. package/dist/cliHost.d.ts +548 -253
  5. package/dist/cliHost.mjs +1990 -1458
  6. package/dist/config.d.ts +192 -14
  7. package/dist/config.mjs +256 -81
  8. package/dist/env-overlay.d.ts +226 -18
  9. package/dist/env-overlay.mjs +181 -22
  10. package/dist/getdotenv.cli.mjs +18166 -3437
  11. package/dist/index.d.ts +729 -136
  12. package/dist/index.mjs +18207 -3457
  13. package/dist/plugins-aws.d.ts +289 -104
  14. package/dist/plugins-aws.mjs +2462 -350
  15. package/dist/plugins-batch.d.ts +355 -105
  16. package/dist/plugins-batch.mjs +2595 -420
  17. package/dist/plugins-cmd.d.ts +287 -118
  18. package/dist/plugins-cmd.mjs +2661 -839
  19. package/dist/plugins-init.d.ts +272 -100
  20. package/dist/plugins-init.mjs +2152 -37
  21. package/dist/plugins.d.ts +323 -140
  22. package/dist/plugins.mjs +18006 -2025
  23. package/dist/templates/cli/index.ts +26 -0
  24. package/dist/templates/cli/plugins/hello.ts +43 -0
  25. package/dist/templates/config/js/getdotenv.config.js +20 -0
  26. package/dist/templates/config/json/local/getdotenv.config.local.json +7 -0
  27. package/dist/templates/config/json/public/getdotenv.config.json +9 -0
  28. package/dist/templates/config/public/getdotenv.config.json +8 -0
  29. package/dist/templates/config/ts/getdotenv.config.ts +28 -0
  30. package/dist/templates/config/yaml/local/getdotenv.config.local.yaml +7 -0
  31. package/dist/templates/config/yaml/public/getdotenv.config.yaml +7 -0
  32. package/dist/templates/getdotenv.config.js +20 -0
  33. package/dist/templates/getdotenv.config.json +9 -0
  34. package/dist/templates/getdotenv.config.local.json +7 -0
  35. package/dist/templates/getdotenv.config.local.yaml +7 -0
  36. package/dist/templates/getdotenv.config.ts +28 -0
  37. package/dist/templates/getdotenv.config.yaml +7 -0
  38. package/dist/templates/hello.ts +43 -0
  39. package/dist/templates/index.ts +26 -0
  40. package/dist/templates/js/getdotenv.config.js +20 -0
  41. package/dist/templates/json/local/getdotenv.config.local.json +7 -0
  42. package/dist/templates/json/public/getdotenv.config.json +9 -0
  43. package/dist/templates/local/getdotenv.config.local.json +7 -0
  44. package/dist/templates/local/getdotenv.config.local.yaml +7 -0
  45. package/dist/templates/plugins/hello.ts +43 -0
  46. package/dist/templates/public/getdotenv.config.json +9 -0
  47. package/dist/templates/public/getdotenv.config.yaml +7 -0
  48. package/dist/templates/ts/getdotenv.config.ts +28 -0
  49. package/dist/templates/yaml/local/getdotenv.config.local.yaml +7 -0
  50. package/dist/templates/yaml/public/getdotenv.config.yaml +7 -0
  51. package/getdotenv.config.json +1 -19
  52. package/package.json +52 -89
  53. package/templates/cli/index.ts +26 -0
  54. package/templates/cli/plugins/hello.ts +43 -0
  55. package/templates/config/js/getdotenv.config.js +9 -4
  56. package/templates/config/json/public/getdotenv.config.json +0 -3
  57. package/templates/config/public/getdotenv.config.json +0 -5
  58. package/templates/config/ts/getdotenv.config.ts +17 -5
  59. package/templates/config/yaml/public/getdotenv.config.yaml +0 -3
  60. package/dist/cliHost.cjs +0 -2078
  61. package/dist/cliHost.d.cts +0 -451
  62. package/dist/cliHost.d.mts +0 -451
  63. package/dist/config.cjs +0 -252
  64. package/dist/config.d.cts +0 -55
  65. package/dist/config.d.mts +0 -55
  66. package/dist/env-overlay.cjs +0 -163
  67. package/dist/env-overlay.d.cts +0 -50
  68. package/dist/env-overlay.d.mts +0 -50
  69. package/dist/index.cjs +0 -4077
  70. package/dist/index.d.cts +0 -318
  71. package/dist/index.d.mts +0 -318
  72. package/dist/plugins-aws.cjs +0 -666
  73. package/dist/plugins-aws.d.cts +0 -158
  74. package/dist/plugins-aws.d.mts +0 -158
  75. package/dist/plugins-batch.cjs +0 -658
  76. package/dist/plugins-batch.d.cts +0 -181
  77. package/dist/plugins-batch.d.mts +0 -181
  78. package/dist/plugins-cmd.cjs +0 -1112
  79. package/dist/plugins-cmd.d.cts +0 -178
  80. package/dist/plugins-cmd.d.mts +0 -178
  81. package/dist/plugins-demo.cjs +0 -352
  82. package/dist/plugins-demo.d.cts +0 -158
  83. package/dist/plugins-demo.d.mts +0 -158
  84. package/dist/plugins-demo.d.ts +0 -158
  85. package/dist/plugins-demo.mjs +0 -350
  86. package/dist/plugins-init.cjs +0 -289
  87. package/dist/plugins-init.d.cts +0 -162
  88. package/dist/plugins-init.d.mts +0 -162
  89. package/dist/plugins.cjs +0 -2327
  90. package/dist/plugins.d.cts +0 -211
  91. package/dist/plugins.d.mts +0 -211
  92. package/templates/cli/ts/index.ts +0 -9
  93. package/templates/cli/ts/plugins/hello.ts +0 -17
package/package.json CHANGED
@@ -13,58 +13,61 @@
13
13
  "url": "https://github.com/karmaniverous/get-dotenv/issues"
14
14
  },
15
15
  "dependencies": {
16
- "commander": "^14.0.1",
16
+ "@commander-js/extra-typings": "^14.0.0",
17
+ "commander": "^14.0.2",
17
18
  "dotenv": "^17.2.3",
18
- "execa": "^9.6.0",
19
+ "execa": "^9.6.1",
19
20
  "fs-extra": "^11.3.2",
20
- "globby": "^15",
21
+ "globby": "^16",
21
22
  "nanoid": "^5.1.6",
22
23
  "package-directory": "^8.1.0",
23
- "yaml": "^2.8.1",
24
- "zod": "^4.1.12"
24
+ "yaml": "^2.8.2",
25
+ "zod": "^4.1.13"
25
26
  },
26
27
  "description": "Process dotenv files in an arbitrary location & optionally populate environment variables.",
27
28
  "devDependencies": {
28
- "@dotenvx/dotenvx": "^1.51.0",
29
- "@eslint/js": "^9.38.0",
30
- "@rollup/plugin-alias": "^5.1.1",
31
- "@rollup/plugin-commonjs": "^28.0.8",
29
+ "@aws-sdk/client-sts": "^3.948.0",
30
+ "@dotenvx/dotenvx": "^1.51.2",
31
+ "@eslint/js": "^9.39.2",
32
+ "@rollup/plugin-alias": "^6.0.0",
33
+ "@rollup/plugin-commonjs": "^29.0.0",
32
34
  "@rollup/plugin-json": "^6.1.0",
33
35
  "@rollup/plugin-node-resolve": "^16.0.3",
34
- "@rollup/plugin-typescript": "^12.1.4",
36
+ "@rollup/plugin-typescript": "^12.3.0",
35
37
  "@types/fs-extra": "^11.0.4",
36
- "@types/node": "^24",
37
- "@vitest/coverage-v8": "^3.2.4",
38
- "@vitest/eslint-plugin": "^1.3.23",
38
+ "@types/node": "^25",
39
+ "@vitest/coverage-v8": "^4.0.15",
40
+ "@vitest/eslint-plugin": "^1.5.2",
39
41
  "auto-changelog": "^2.5.0",
40
42
  "cross-env": "^10.1.0",
41
- "esbuild": "^0.25.11",
42
- "eslint": "^9.38.0",
43
+ "esbuild": "^0.27.1",
44
+ "eslint": "^9.39.2",
43
45
  "eslint-config-prettier": "^10.1.8",
44
46
  "eslint-plugin-jsonc": "^2.21.0",
45
47
  "eslint-plugin-prettier": "^5.5.4",
46
48
  "eslint-plugin-simple-import-sort": "^12.1.1",
47
- "eslint-plugin-tsdoc": "^0.4.0",
49
+ "eslint-plugin-tsdoc": "^0.5.0",
48
50
  "fs-extra": "^11.3.2",
49
- "globals": "^16.4.0",
50
- "jsonc-eslint-parser": "^2.4.1",
51
- "knip": "^5.66.1",
52
- "lefthook": "^2.0.0",
53
- "npm-packlist": "^10.0.2",
54
- "prettier": "^3.6.2",
55
- "release-it": "^19.0.5",
56
- "rimraf": "^6.0.1",
57
- "rollup": "^4.52.5",
58
- "rollup-plugin-dts": "^6.2.3",
51
+ "globals": "^16.5.0",
52
+ "jsonc-eslint-parser": "^2.4.2",
53
+ "knip": "^5.73.4",
54
+ "lefthook": "^2.0.11",
55
+ "npm-packlist": "^10.0.3",
56
+ "prettier": "^3.7.4",
57
+ "release-it": "^19.1.0",
58
+ "rimraf": "^6.1.2",
59
+ "rollup": "^4.53.3",
60
+ "rollup-plugin-copy": "^3.5.0",
61
+ "rollup-plugin-dts": "^6.3.0",
59
62
  "tslib": "^2.8.1",
60
- "tsx": "^4.20.6",
61
- "typedoc": "^0.28.14",
63
+ "tsx": "^4.21.0",
64
+ "typedoc": "^0.28.15",
62
65
  "typedoc-plugin-mdn-links": "^5.0.10",
63
66
  "typedoc-plugin-replace-text": "^4.2.0",
64
67
  "typescript": "^5.9.3",
65
- "typescript-eslint": "^8.46.1",
68
+ "typescript-eslint": "^8.49.0",
66
69
  "vite-tsconfig-paths": "^5.1.4",
67
- "vitest": "^3.2.4"
70
+ "vitest": "^4.0.15"
68
71
  },
69
72
  "engines": {
70
73
  "node": ">=20"
@@ -72,102 +75,62 @@
72
75
  "exports": {
73
76
  ".": {
74
77
  "import": {
75
- "types": "./dist/index.d.mts",
78
+ "types": "./dist/index.d.ts",
76
79
  "default": "./dist/index.mjs"
77
- },
78
- "require": {
79
- "types": "./dist/index.d.cts",
80
- "default": "./dist/index.cjs"
80
+ }
81
+ },
82
+ "./cli": {
83
+ "import": {
84
+ "types": "./dist/cli.d.ts",
85
+ "default": "./dist/cli.mjs"
81
86
  }
82
87
  },
83
88
  "./cliHost": {
84
89
  "import": {
85
- "types": "./dist/cliHost.d.mts",
90
+ "types": "./dist/cliHost.d.ts",
86
91
  "default": "./dist/cliHost.mjs"
87
- },
88
- "require": {
89
- "types": "./dist/cliHost.d.cts",
90
- "default": "./dist/cliHost.cjs"
91
92
  }
92
93
  },
93
94
  "./plugins": {
94
95
  "import": {
95
- "types": "./dist/plugins.d.mts",
96
+ "types": "./dist/plugins.d.ts",
96
97
  "default": "./dist/plugins.mjs"
97
- },
98
- "require": {
99
- "types": "./dist/plugins.d.cts",
100
- "default": "./dist/plugins.cjs"
101
98
  }
102
99
  },
103
100
  "./plugins/aws": {
104
101
  "import": {
105
- "types": "./dist/plugins-aws.d.mts",
102
+ "types": "./dist/plugins-aws.d.ts",
106
103
  "default": "./dist/plugins-aws.mjs"
107
- },
108
- "require": {
109
- "types": "./dist/plugins-aws.d.cts",
110
- "default": "./dist/plugins-aws.cjs"
111
104
  }
112
105
  },
113
106
  "./plugins/batch": {
114
107
  "import": {
115
- "types": "./dist/plugins-batch.d.mts",
108
+ "types": "./dist/plugins-batch.d.ts",
116
109
  "default": "./dist/plugins-batch.mjs"
117
- },
118
- "require": {
119
- "types": "./dist/plugins-batch.d.cts",
120
- "default": "./dist/plugins-batch.cjs"
121
110
  }
122
111
  },
123
112
  "./plugins/init": {
124
113
  "import": {
125
- "types": "./dist/plugins-init.d.mts",
114
+ "types": "./dist/plugins-init.d.ts",
126
115
  "default": "./dist/plugins-init.mjs"
127
- },
128
- "require": {
129
- "types": "./dist/plugins-init.d.cts",
130
- "default": "./dist/plugins-init.cjs"
131
116
  }
132
117
  },
133
118
  "./plugins/cmd": {
134
119
  "import": {
135
- "types": "./dist/plugins-cmd.d.mts",
120
+ "types": "./dist/plugins-cmd.d.ts",
136
121
  "default": "./dist/plugins-cmd.mjs"
137
- },
138
- "require": {
139
- "types": "./dist/plugins-cmd.d.cts",
140
- "default": "./dist/plugins-cmd.cjs"
141
- }
142
- },
143
- "./plugins/demo": {
144
- "import": {
145
- "types": "./dist/plugins-demo.d.mts",
146
- "default": "./dist/plugins-demo.mjs"
147
- },
148
- "require": {
149
- "types": "./dist/plugins-demo.d.cts",
150
- "default": "./dist/plugins-demo.cjs"
151
122
  }
152
123
  },
153
124
  "./config": {
154
125
  "import": {
155
- "types": "./dist/config.d.mts",
126
+ "types": "./dist/config.d.ts",
156
127
  "default": "./dist/config.mjs"
157
- },
158
- "require": {
159
- "types": "./dist/config.d.cts",
160
- "default": "./dist/config.cjs"
161
128
  }
162
129
  },
163
130
  "./env/overlay": {
164
131
  "import": {
165
- "types": "./dist/env-overlay.d.mts",
132
+ "types": "./dist/env-overlay.d.ts",
166
133
  "default": "./dist/env-overlay.mjs"
167
- },
168
- "require": {
169
- "types": "./dist/env-overlay.d.cts",
170
- "default": "./dist/env-overlay.cjs"
171
134
  }
172
135
  }
173
136
  },
@@ -190,7 +153,7 @@
190
153
  "typescript"
191
154
  ],
192
155
  "license": "BSD-3-Clause",
193
- "main": "dist/index.cjs",
156
+ "main": "dist/index.mjs",
194
157
  "name": "@karmaniverous/get-dotenv",
195
158
  "peerDependencies": {
196
159
  "esbuild": "*"
@@ -229,7 +192,8 @@
229
192
  ]
230
193
  },
231
194
  "npm": {
232
- "publish": true
195
+ "publish": false,
196
+ "skipChecks": true
233
197
  }
234
198
  },
235
199
  "repository": {
@@ -248,7 +212,6 @@
248
212
  "lint:fix": "eslint --fix . eslint.config.ts",
249
213
  "release": "dotenvx run -f .env.local -- release-it",
250
214
  "release:pre": "dotenvx run -f .env.local -- release-it --no-git.requireBranch --github.prerelease --preRelease",
251
- "stan:docs": "typedoc --emit none",
252
215
  "test": "vitest run",
253
216
  "typecheck": "tsc -p tsconfig.json --noEmit",
254
217
  "verify:types": "node tools/verify-types.js",
@@ -259,5 +222,5 @@
259
222
  },
260
223
  "type": "module",
261
224
  "types": "dist/index.d.ts",
262
- "version": "6.0.0-0"
225
+ "version": "6.0.0"
263
226
  }
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { createCli } from '@karmaniverous/get-dotenv/cli';
4
+
5
+ import {
6
+ awsPlugin,
7
+ awsWhoamiPlugin,
8
+ batchPlugin,
9
+ cmdPlugin,
10
+ initPlugin,
11
+ } from '@/src/plugins';
12
+
13
+ import { helloPlugin } from './plugins/hello';
14
+
15
+ await createCli({
16
+ alias: 'mycli',
17
+ compose: (program) =>
18
+ program
19
+ .use(
20
+ cmdPlugin({ asDefault: true, optionAlias: '-c, --cmd <command...>' }),
21
+ )
22
+ .use(batchPlugin())
23
+ .use(awsPlugin().use(awsWhoamiPlugin()))
24
+ .use(initPlugin())
25
+ .use(helloPlugin()),
26
+ })();
@@ -0,0 +1,43 @@
1
+ import {
2
+ definePlugin,
3
+ getRootCommand,
4
+ } from '@karmaniverous/get-dotenv/cliHost';
5
+ import { z } from 'zod';
6
+
7
+ const HelloConfigSchema = z.object({
8
+ loud: z.boolean().optional().default(false),
9
+ color: z.string().optional(),
10
+ });
11
+
12
+ export const helloPlugin = () => {
13
+ const plugin = definePlugin({
14
+ ns: 'hello',
15
+ configSchema: HelloConfigSchema,
16
+ setup(cli) {
17
+ cli
18
+ .ns('hello')
19
+ .description('Say hello with current dotenv context')
20
+ .addOption(
21
+ plugin.createPluginDynamicOption(
22
+ cli,
23
+ '--loud',
24
+ (_bag, cfg) =>
25
+ `print greeting in ALL CAPS${cfg.loud ? ' (default)' : ''}`,
26
+ ),
27
+ )
28
+ .action(() => {
29
+ const ctx = cli.getCtx();
30
+ // Derive CLI name from the true root command using a typed helper.
31
+ const rootName = getRootCommand(cli).name();
32
+
33
+ const cfg = plugin.readConfig(cli);
34
+ const keys = Object.keys(ctx.dotenv);
35
+ const label = cfg.loud
36
+ ? `[${rootName}] DOTENV KEYS (${String(keys.length)}):`
37
+ : `[${rootName}] dotenv keys (${String(keys.length)}):`;
38
+ console.log(label, keys.join(', '));
39
+ });
40
+ },
41
+ });
42
+ return plugin;
43
+ };
@@ -1,7 +1,12 @@
1
1
  export default {
2
- dotenvToken: '.env',
3
- privateToken: 'local',
4
- paths: './',
2
+ // Help-time root defaults (example):
3
+ // rootOptionDefaults: {
4
+ // redact: true,
5
+ // // redactPatterns: ['API_KEY', 'SECRET'],
6
+ // },
7
+ // Help-time visibility (example): hide selected root flags in -h
8
+ // rootOptionVisibility: { capture: false },
9
+
5
10
  vars: { APP_SETTING: 'app_value' },
6
11
  envVars: { dev: { ENV_SETTING: 'dev_value' } },
7
12
  dynamic: {
@@ -12,4 +17,4 @@ export default {
12
17
  // provided, this returns an empty string.
13
18
  ENV_TAG: (_vars, env) => (env ? `for-${env}` : ''),
14
19
  },
15
- };
20
+ };
@@ -1,7 +1,4 @@
1
1
  {
2
- "dotenvToken": ".env",
3
- "privateToken": "local",
4
- "paths": "./",
5
2
  "vars": {
6
3
  "APP_SETTING": "app_value"
7
4
  },
@@ -1,9 +1,4 @@
1
1
  {
2
- "dotenvToken": ".env",
3
- "privateToken": "local",
4
- "paths": "./",
5
- "loadProcess": true,
6
- "log": false,
7
2
  "vars": {
8
3
  "APP_NAME": "my-app"
9
4
  },
@@ -1,7 +1,19 @@
1
- export default {
2
- dotenvToken: '.env',
3
- privateToken: 'local',
4
- paths: './',
1
+ import { defineGetDotenvConfig } from '@karmaniverous/get-dotenv/core';
2
+
3
+ type Vars = {
4
+ APP_SETTING?: string;
5
+ ENV_SETTING?: string;
6
+ };
7
+
8
+ export default defineGetDotenvConfig<Vars>({
9
+ // Help-time root defaults (example):
10
+ // rootOptionDefaults: {
11
+ // redact: true,
12
+ // // redactPatterns: ['API_KEY', 'SECRET'],
13
+ // },
14
+ // Help-time visibility (example): hide selected root flags in -h
15
+ // rootOptionVisibility: { capture: false },
16
+
5
17
  vars: { APP_SETTING: 'app_value' },
6
18
  envVars: { dev: { ENV_SETTING: 'dev_value' } },
7
19
  dynamic: {
@@ -13,4 +25,4 @@ export default {
13
25
  ENV_TAG: (_vars: Record<string, string | undefined>, env?: string) =>
14
26
  env ? `for-${env}` : '',
15
27
  },
16
- };
28
+ });
@@ -1,6 +1,3 @@
1
- dotenvToken: ".env"
2
- privateToken: "local"
3
- paths: "./"
4
1
  vars:
5
2
  APP_SETTING: "app_value"
6
3
  envVars: