@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.
- package/README.md +106 -70
- package/dist/cliHost.d.ts +232 -226
- package/dist/cliHost.mjs +777 -545
- package/dist/config.d.ts +7 -2
- package/dist/env-overlay.d.ts +21 -9
- package/dist/env-overlay.mjs +14 -19
- package/dist/getdotenv.cli.mjs +1366 -1163
- package/dist/index.d.ts +415 -242
- package/dist/index.mjs +1364 -1414
- package/dist/plugins-aws.d.ts +149 -94
- package/dist/plugins-aws.mjs +307 -195
- package/dist/plugins-batch.d.ts +153 -99
- package/dist/plugins-batch.mjs +277 -95
- package/dist/plugins-cmd.d.ts +140 -94
- package/dist/plugins-cmd.mjs +636 -502
- package/dist/plugins-demo.d.ts +140 -94
- package/dist/plugins-demo.mjs +237 -46
- package/dist/plugins-init.d.ts +140 -94
- package/dist/plugins-init.mjs +129 -12
- package/dist/plugins.d.ts +166 -103
- package/dist/plugins.mjs +977 -840
- package/package.json +15 -53
- package/templates/cli/ts/plugins/hello.ts +27 -6
- package/templates/config/js/getdotenv.config.js +1 -1
- package/templates/config/ts/getdotenv.config.ts +9 -2
- package/dist/cliHost.cjs +0 -1875
- package/dist/cliHost.d.cts +0 -409
- package/dist/cliHost.d.mts +0 -409
- package/dist/config.cjs +0 -252
- package/dist/config.d.cts +0 -55
- package/dist/config.d.mts +0 -55
- package/dist/env-overlay.cjs +0 -163
- package/dist/env-overlay.d.cts +0 -50
- package/dist/env-overlay.d.mts +0 -50
- package/dist/index.cjs +0 -4140
- package/dist/index.d.cts +0 -457
- package/dist/index.d.mts +0 -457
- package/dist/plugins-aws.cjs +0 -667
- package/dist/plugins-aws.d.cts +0 -158
- package/dist/plugins-aws.d.mts +0 -158
- package/dist/plugins-batch.cjs +0 -616
- package/dist/plugins-batch.d.cts +0 -180
- package/dist/plugins-batch.d.mts +0 -180
- package/dist/plugins-cmd.cjs +0 -1113
- package/dist/plugins-cmd.d.cts +0 -178
- package/dist/plugins-cmd.d.mts +0 -178
- package/dist/plugins-demo.cjs +0 -307
- package/dist/plugins-demo.d.cts +0 -158
- package/dist/plugins-demo.d.mts +0 -158
- package/dist/plugins-init.cjs +0 -289
- package/dist/plugins-init.d.cts +0 -162
- package/dist/plugins-init.d.mts +0 -162
- package/dist/plugins.cjs +0 -2283
- package/dist/plugins.d.cts +0 -210
- package/dist/plugins.d.mts +0 -210
package/dist/plugins-cmd.d.ts
CHANGED
|
@@ -1,9 +1,39 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { z, ZodObject } from 'zod';
|
|
2
|
+
import { Command, Option } from 'commander';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Scripts table shape (configurable shell type).
|
|
6
|
+
*/
|
|
7
|
+
type ScriptsTable<TShell extends string | boolean = string | boolean> = Record<string, string | {
|
|
8
|
+
cmd: string;
|
|
9
|
+
shell?: TShell | undefined;
|
|
10
|
+
}>;
|
|
11
|
+
|
|
12
|
+
declare const getDotenvOptionsSchemaResolved: z.ZodObject<{
|
|
13
|
+
defaultEnv: z.ZodOptional<z.ZodString>;
|
|
14
|
+
dotenvToken: z.ZodOptional<z.ZodString>;
|
|
15
|
+
dynamicPath: z.ZodOptional<z.ZodString>;
|
|
16
|
+
dynamic: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
17
|
+
env: z.ZodOptional<z.ZodString>;
|
|
18
|
+
excludeDynamic: z.ZodOptional<z.ZodBoolean>;
|
|
19
|
+
excludeEnv: z.ZodOptional<z.ZodBoolean>;
|
|
20
|
+
excludeGlobal: z.ZodOptional<z.ZodBoolean>;
|
|
21
|
+
excludePrivate: z.ZodOptional<z.ZodBoolean>;
|
|
22
|
+
excludePublic: z.ZodOptional<z.ZodBoolean>;
|
|
23
|
+
loadProcess: z.ZodOptional<z.ZodBoolean>;
|
|
24
|
+
log: z.ZodOptional<z.ZodBoolean>;
|
|
25
|
+
logger: z.ZodOptional<z.ZodUnknown>;
|
|
26
|
+
outputPath: z.ZodOptional<z.ZodString>;
|
|
27
|
+
paths: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
28
|
+
privateToken: z.ZodOptional<z.ZodString>;
|
|
29
|
+
vars: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodOptional<z.ZodString>>>;
|
|
30
|
+
}, z.core.$strip>;
|
|
3
31
|
|
|
4
32
|
/**
|
|
5
33
|
* A minimal representation of an environment key/value mapping.
|
|
6
|
-
* Values may be `undefined` to represent "unset".
|
|
34
|
+
* Values may be `undefined` to represent "unset".
|
|
35
|
+
*/
|
|
36
|
+
type ProcessEnv = Record<string, string | undefined>;
|
|
7
37
|
/**
|
|
8
38
|
* Dynamic variable function signature. Receives the current expanded variables
|
|
9
39
|
* and the selected environment (if any), and returns either a string to set
|
|
@@ -13,87 +43,86 @@ type GetDotenvDynamicFunction = (vars: ProcessEnv, env: string | undefined) => s
|
|
|
13
43
|
type GetDotenvDynamic = Record<string, GetDotenvDynamicFunction | ReturnType<GetDotenvDynamicFunction>>;
|
|
14
44
|
type Logger = Record<string, (...args: unknown[]) => void> | typeof console;
|
|
15
45
|
/**
|
|
16
|
-
*
|
|
46
|
+
* Canonical programmatic options type (schema-derived).
|
|
47
|
+
* This type is the single source of truth for programmatic options.
|
|
17
48
|
*/
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* default target environment (used if `env` is not provided)
|
|
21
|
-
*/
|
|
22
|
-
defaultEnv?: string;
|
|
49
|
+
type GetDotenvOptions = z.output<typeof getDotenvOptionsSchemaResolved> & {
|
|
23
50
|
/**
|
|
24
|
-
*
|
|
51
|
+
* Compile-time overlay: narrowed logger for DX (schema stores unknown).
|
|
25
52
|
*/
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* path to JS/TS module default-exporting an object keyed to dynamic variable functions
|
|
29
|
-
*/
|
|
30
|
-
dynamicPath?: string;
|
|
53
|
+
logger?: Logger;
|
|
31
54
|
/**
|
|
32
|
-
*
|
|
33
|
-
* over {@link GetDotenvOptions.dynamicPath}.
|
|
55
|
+
* Compile-time overlay: narrowed dynamic map for DX (schema stores unknown).
|
|
34
56
|
*/
|
|
35
57
|
dynamic?: GetDotenvDynamic;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
declare const getDotenvCliOptionsSchemaResolved: z.ZodObject<{
|
|
61
|
+
defaultEnv: z.ZodOptional<z.ZodString>;
|
|
62
|
+
dotenvToken: z.ZodOptional<z.ZodString>;
|
|
63
|
+
dynamicPath: z.ZodOptional<z.ZodString>;
|
|
64
|
+
dynamic: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
65
|
+
env: z.ZodOptional<z.ZodString>;
|
|
66
|
+
excludeDynamic: z.ZodOptional<z.ZodBoolean>;
|
|
67
|
+
excludeEnv: z.ZodOptional<z.ZodBoolean>;
|
|
68
|
+
excludeGlobal: z.ZodOptional<z.ZodBoolean>;
|
|
69
|
+
excludePrivate: z.ZodOptional<z.ZodBoolean>;
|
|
70
|
+
excludePublic: z.ZodOptional<z.ZodBoolean>;
|
|
71
|
+
loadProcess: z.ZodOptional<z.ZodBoolean>;
|
|
72
|
+
log: z.ZodOptional<z.ZodBoolean>;
|
|
73
|
+
logger: z.ZodOptional<z.ZodUnknown>;
|
|
74
|
+
outputPath: z.ZodOptional<z.ZodString>;
|
|
75
|
+
privateToken: z.ZodOptional<z.ZodString>;
|
|
76
|
+
debug: z.ZodOptional<z.ZodBoolean>;
|
|
77
|
+
strict: z.ZodOptional<z.ZodBoolean>;
|
|
78
|
+
capture: z.ZodOptional<z.ZodBoolean>;
|
|
79
|
+
trace: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodArray<z.ZodString>]>>;
|
|
80
|
+
redact: z.ZodOptional<z.ZodBoolean>;
|
|
81
|
+
warnEntropy: z.ZodOptional<z.ZodBoolean>;
|
|
82
|
+
entropyThreshold: z.ZodOptional<z.ZodNumber>;
|
|
83
|
+
entropyMinLength: z.ZodOptional<z.ZodNumber>;
|
|
84
|
+
entropyWhitelist: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
85
|
+
redactPatterns: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
86
|
+
paths: z.ZodOptional<z.ZodString>;
|
|
87
|
+
pathsDelimiter: z.ZodOptional<z.ZodString>;
|
|
88
|
+
pathsDelimiterPattern: z.ZodOptional<z.ZodString>;
|
|
89
|
+
scripts: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
90
|
+
shell: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodString]>>;
|
|
91
|
+
vars: z.ZodOptional<z.ZodString>;
|
|
92
|
+
varsAssignor: z.ZodOptional<z.ZodString>;
|
|
93
|
+
varsAssignorPattern: z.ZodOptional<z.ZodString>;
|
|
94
|
+
varsDelimiter: z.ZodOptional<z.ZodString>;
|
|
95
|
+
varsDelimiterPattern: z.ZodOptional<z.ZodString>;
|
|
96
|
+
}, z.core.$strip>;
|
|
97
|
+
|
|
98
|
+
type Scripts = ScriptsTable;
|
|
99
|
+
/**
|
|
100
|
+
* Canonical CLI options type derived from the Zod schema output.
|
|
101
|
+
* Includes CLI-only flags (debug/strict/capture/trace/redaction/entropy),
|
|
102
|
+
* stringly paths/vars, and inherited programmatic fields (minus normalized
|
|
103
|
+
* shapes that are handled by resolution).
|
|
104
|
+
*/
|
|
105
|
+
type GetDotenvCliOptions = z.output<typeof getDotenvCliOptionsSchemaResolved> & {
|
|
36
106
|
/**
|
|
37
|
-
*
|
|
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)
|
|
107
|
+
* Compile-only overlay for DX: logger narrowed from unknown.
|
|
70
108
|
*/
|
|
71
109
|
logger?: Logger;
|
|
72
110
|
/**
|
|
73
|
-
*
|
|
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
|
|
111
|
+
* Compile-only overlay for DX: scripts narrowed from Record\<string, unknown\>.
|
|
86
112
|
*/
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
113
|
+
scripts?: Scripts;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
type ResolvedHelpConfig = Partial<GetDotenvCliOptions> & {
|
|
117
|
+
plugins: Record<string, unknown>;
|
|
118
|
+
};
|
|
119
|
+
/** Per-invocation context shared with plugins and actions. */
|
|
120
|
+
type GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> = {
|
|
121
|
+
optionsResolved: TOptions;
|
|
122
|
+
dotenv: ProcessEnv;
|
|
123
|
+
plugins?: Record<string, unknown>;
|
|
124
|
+
pluginConfigs?: Record<string, unknown>;
|
|
125
|
+
};
|
|
97
126
|
|
|
98
127
|
/** src/cliHost/definePlugin.ts
|
|
99
128
|
* Plugin contracts for the GetDotenv CLI host.
|
|
@@ -111,46 +140,63 @@ interface GetDotenvOptions {
|
|
|
111
140
|
* Purpose: remove nominal class identity (private fields) from the plugin seam
|
|
112
141
|
* to avoid TS2379 under exactOptionalPropertyTypes in downstream consumers.
|
|
113
142
|
*/
|
|
114
|
-
|
|
115
|
-
ns
|
|
116
|
-
getCtx
|
|
117
|
-
resolveAndLoad
|
|
118
|
-
|
|
143
|
+
interface GetDotenvCliPublic<TOptions extends GetDotenvOptions = GetDotenvOptions> extends Command {
|
|
144
|
+
ns(name: string): Command;
|
|
145
|
+
getCtx(): GetDotenvCliCtx<TOptions> | undefined;
|
|
146
|
+
resolveAndLoad(customOptions?: Partial<TOptions>, opts?: {
|
|
147
|
+
runAfterResolve?: boolean;
|
|
148
|
+
}): Promise<GetDotenvCliCtx<TOptions>>;
|
|
149
|
+
setOptionGroup(opt: Option, group: string): void;
|
|
150
|
+
/**
|
|
151
|
+
* Create a dynamic option whose description is computed at help time
|
|
152
|
+
* from the resolved configuration.
|
|
153
|
+
*/
|
|
154
|
+
createDynamicOption(flags: string, desc: (cfg: ResolvedHelpConfig & {
|
|
155
|
+
plugins: Record<string, unknown>;
|
|
156
|
+
}) => string, parser?: (value: string, previous?: unknown) => unknown, defaultValue?: unknown): Option;
|
|
157
|
+
createDynamicOption<TValue = unknown>(flags: string, desc: (cfg: ResolvedHelpConfig & {
|
|
158
|
+
plugins: Record<string, unknown>;
|
|
159
|
+
}) => string, parser: (value: string, previous?: TValue) => TValue, defaultValue?: TValue): Option;
|
|
160
|
+
}
|
|
119
161
|
/** Public plugin contract used by the GetDotenv CLI host. */
|
|
120
|
-
interface GetDotenvCliPlugin {
|
|
162
|
+
interface GetDotenvCliPlugin<TOptions extends GetDotenvOptions = GetDotenvOptions> {
|
|
121
163
|
id?: string;
|
|
122
164
|
/**
|
|
123
165
|
* Setup phase: register commands and wiring on the provided CLI instance.
|
|
124
166
|
* Runs parent → children (pre-order).
|
|
125
167
|
*/
|
|
126
|
-
setup: (cli: GetDotenvCliPublic) => void | Promise<void>;
|
|
168
|
+
setup: (cli: GetDotenvCliPublic<TOptions>) => void | Promise<void>;
|
|
127
169
|
/**
|
|
128
170
|
* After the dotenv context is resolved, initialize any clients/secrets
|
|
129
171
|
* or attach per-plugin state under ctx.plugins (by convention).
|
|
130
172
|
* Runs parent → children (pre-order).
|
|
131
173
|
*/
|
|
132
|
-
afterResolve?: (cli: GetDotenvCliPublic
|
|
174
|
+
afterResolve?: (cli: GetDotenvCliPublic<TOptions>, ctx: GetDotenvCliCtx<TOptions>) => void | Promise<void>;
|
|
133
175
|
/**
|
|
134
|
-
*
|
|
135
|
-
*
|
|
176
|
+
* Zod schema for this plugin's config slice (from config.plugins[id]).
|
|
177
|
+
* Enforced object-like (ZodObject) to simplify code paths and inference.
|
|
136
178
|
*/
|
|
137
|
-
configSchema?:
|
|
179
|
+
configSchema?: ZodObject;
|
|
138
180
|
/**
|
|
139
181
|
* Compositional children. Installed after the parent per pre-order.
|
|
140
182
|
*/
|
|
141
|
-
children: GetDotenvCliPlugin[];
|
|
183
|
+
children: GetDotenvCliPlugin<TOptions>[];
|
|
142
184
|
/**
|
|
143
185
|
* Compose a child plugin. Returns the parent to enable chaining.
|
|
144
186
|
*/
|
|
145
|
-
use: (child: GetDotenvCliPlugin) => GetDotenvCliPlugin
|
|
187
|
+
use: (child: GetDotenvCliPlugin<TOptions>) => GetDotenvCliPlugin<TOptions>;
|
|
146
188
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
189
|
+
/**
|
|
190
|
+
* Compile-time helper type: the plugin object returned by definePlugin always
|
|
191
|
+
* includes the instance-bound helpers as required members. Keeping the public
|
|
192
|
+
* interface optional preserves compatibility for ad-hoc/test plugins, while
|
|
193
|
+
* return types from definePlugin provide stronger DX for shipped/typed plugins.
|
|
194
|
+
*/
|
|
195
|
+
type PluginWithInstanceHelpers<TOptions extends GetDotenvOptions = GetDotenvOptions, TConfig = unknown> = GetDotenvCliPlugin<TOptions> & {
|
|
196
|
+
readConfig<TCfg = TConfig>(cli: GetDotenvCliPublic<TOptions>): Readonly<TCfg>;
|
|
197
|
+
createPluginDynamicOption<TCfg = TConfig>(cli: GetDotenvCliPublic<TOptions>, flags: string, desc: (cfg: ResolvedHelpConfig & {
|
|
198
|
+
plugins: Record<string, unknown>;
|
|
199
|
+
}, pluginCfg: Readonly<TCfg>) => string, parser?: (value: string, previous?: unknown) => unknown, defaultValue?: unknown): Option;
|
|
154
200
|
};
|
|
155
201
|
|
|
156
202
|
type CmdPluginOptions = {
|
|
@@ -172,7 +218,7 @@ type CmdPluginOptions = {
|
|
|
172
218
|
* - Resolves scripts and shell settings using shared helpers.
|
|
173
219
|
* - Forwards merged CLI options to subprocesses via
|
|
174
220
|
* process.env.getDotenvCliOptions for nested CLI behavior. */
|
|
175
|
-
declare const cmdPlugin: (options?: CmdPluginOptions) =>
|
|
221
|
+
declare const cmdPlugin: (options?: CmdPluginOptions) => PluginWithInstanceHelpers<GetDotenvOptions, {}>;
|
|
176
222
|
|
|
177
223
|
export { cmdPlugin };
|
|
178
224
|
export type { CmdPluginOptions };
|