@karmaniverous/get-dotenv 6.0.0-1 → 6.1.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.
- package/README.md +91 -379
- package/dist/cli.d.ts +569 -0
- package/dist/cli.mjs +18877 -0
- package/dist/cliHost.d.ts +528 -184
- package/dist/cliHost.mjs +1977 -1428
- package/dist/config.d.ts +191 -14
- package/dist/config.mjs +266 -81
- package/dist/env-overlay.d.ts +223 -16
- package/dist/env-overlay.mjs +185 -4
- package/dist/getdotenv.cli.mjs +18025 -3196
- package/dist/index.d.ts +623 -256
- package/dist/index.mjs +18045 -3206
- package/dist/plugins-aws.d.ts +221 -91
- package/dist/plugins-aws.mjs +2411 -369
- package/dist/plugins-batch.d.ts +300 -103
- package/dist/plugins-batch.mjs +2560 -484
- package/dist/plugins-cmd.d.ts +229 -106
- package/dist/plugins-cmd.mjs +2518 -790
- package/dist/plugins-init.d.ts +221 -95
- package/dist/plugins-init.mjs +2170 -105
- package/dist/plugins.d.ts +246 -125
- package/dist/plugins.mjs +17941 -1968
- package/dist/templates/cli/index.ts +25 -0
- package/{templates/cli/ts → dist/templates/cli}/plugins/hello.ts +13 -9
- package/dist/templates/config/js/getdotenv.config.js +20 -0
- package/dist/templates/config/json/local/getdotenv.config.local.json +7 -0
- package/dist/templates/config/json/public/getdotenv.config.json +9 -0
- package/dist/templates/config/public/getdotenv.config.json +8 -0
- package/dist/templates/config/ts/getdotenv.config.ts +28 -0
- package/dist/templates/config/yaml/local/getdotenv.config.local.yaml +7 -0
- package/dist/templates/config/yaml/public/getdotenv.config.yaml +7 -0
- package/dist/templates/getdotenv.config.js +20 -0
- package/dist/templates/getdotenv.config.json +9 -0
- package/dist/templates/getdotenv.config.local.json +7 -0
- package/dist/templates/getdotenv.config.local.yaml +7 -0
- package/dist/templates/getdotenv.config.ts +28 -0
- package/dist/templates/getdotenv.config.yaml +7 -0
- package/dist/templates/hello.ts +42 -0
- package/dist/templates/index.ts +25 -0
- package/dist/templates/js/getdotenv.config.js +20 -0
- package/dist/templates/json/local/getdotenv.config.local.json +7 -0
- package/dist/templates/json/public/getdotenv.config.json +9 -0
- package/dist/templates/local/getdotenv.config.local.json +7 -0
- package/dist/templates/local/getdotenv.config.local.yaml +7 -0
- package/dist/templates/plugins/hello.ts +42 -0
- package/dist/templates/public/getdotenv.config.json +9 -0
- package/dist/templates/public/getdotenv.config.yaml +7 -0
- package/dist/templates/ts/getdotenv.config.ts +28 -0
- package/dist/templates/yaml/local/getdotenv.config.local.yaml +7 -0
- package/dist/templates/yaml/public/getdotenv.config.yaml +7 -0
- package/getdotenv.config.json +1 -19
- package/package.json +42 -39
- package/templates/cli/index.ts +25 -0
- package/templates/cli/plugins/hello.ts +42 -0
- package/templates/config/js/getdotenv.config.js +8 -3
- package/templates/config/json/public/getdotenv.config.json +0 -3
- package/templates/config/public/getdotenv.config.json +0 -5
- package/templates/config/ts/getdotenv.config.ts +8 -3
- package/templates/config/yaml/public/getdotenv.config.yaml +0 -3
- package/dist/plugins-demo.d.ts +0 -204
- package/dist/plugins-demo.mjs +0 -496
- package/templates/cli/ts/index.ts +0 -9
package/dist/plugins.d.ts
CHANGED
|
@@ -1,14 +1,79 @@
|
|
|
1
|
+
import { OptionValues, Command, InferCommandArguments, Option } from '@commander-js/extra-typings';
|
|
1
2
|
import { z, ZodObject } from 'zod';
|
|
2
|
-
import { Command, Option } from 'commander';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Definition for a single script entry.
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
interface ScriptDef<TShell extends string | boolean = string | boolean> {
|
|
8
|
+
/** The command string to execute. */
|
|
8
9
|
cmd: string;
|
|
10
|
+
/** Shell override for this script. */
|
|
9
11
|
shell?: TShell | undefined;
|
|
10
|
-
}
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Scripts table shape.
|
|
15
|
+
*/
|
|
16
|
+
type ScriptsTable<TShell extends string | boolean = string | boolean> = Record<string, string | ScriptDef<TShell>>;
|
|
17
|
+
/**
|
|
18
|
+
* Per-invocation context shared with plugins and actions.
|
|
19
|
+
*
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
interface GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> {
|
|
23
|
+
optionsResolved: TOptions;
|
|
24
|
+
dotenv: ProcessEnv;
|
|
25
|
+
plugins?: Record<string, unknown>;
|
|
26
|
+
pluginConfigs?: Record<string, unknown>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Resolved CLI options schema.
|
|
31
|
+
* For the current step this mirrors the RAW schema; later stages may further
|
|
32
|
+
* narrow types post-resolution in the host pipeline.
|
|
33
|
+
*/
|
|
34
|
+
declare const getDotenvCliOptionsSchemaResolved: z.ZodObject<{
|
|
35
|
+
defaultEnv: z.ZodOptional<z.ZodString>;
|
|
36
|
+
dotenvToken: z.ZodOptional<z.ZodString>;
|
|
37
|
+
dynamicPath: z.ZodOptional<z.ZodString>;
|
|
38
|
+
dynamic: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
39
|
+
env: z.ZodOptional<z.ZodString>;
|
|
40
|
+
excludeDynamic: z.ZodOptional<z.ZodBoolean>;
|
|
41
|
+
excludeEnv: z.ZodOptional<z.ZodBoolean>;
|
|
42
|
+
excludeGlobal: z.ZodOptional<z.ZodBoolean>;
|
|
43
|
+
excludePrivate: z.ZodOptional<z.ZodBoolean>;
|
|
44
|
+
excludePublic: z.ZodOptional<z.ZodBoolean>;
|
|
45
|
+
loadProcess: z.ZodOptional<z.ZodBoolean>;
|
|
46
|
+
log: z.ZodOptional<z.ZodBoolean>;
|
|
47
|
+
logger: z.ZodDefault<z.ZodUnknown>;
|
|
48
|
+
outputPath: z.ZodOptional<z.ZodString>;
|
|
49
|
+
privateToken: z.ZodOptional<z.ZodString>;
|
|
50
|
+
debug: z.ZodOptional<z.ZodBoolean>;
|
|
51
|
+
strict: z.ZodOptional<z.ZodBoolean>;
|
|
52
|
+
capture: z.ZodOptional<z.ZodBoolean>;
|
|
53
|
+
trace: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodArray<z.ZodString>]>>;
|
|
54
|
+
redact: z.ZodOptional<z.ZodBoolean>;
|
|
55
|
+
warnEntropy: z.ZodOptional<z.ZodBoolean>;
|
|
56
|
+
entropyThreshold: z.ZodOptional<z.ZodNumber>;
|
|
57
|
+
entropyMinLength: z.ZodOptional<z.ZodNumber>;
|
|
58
|
+
entropyWhitelist: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
59
|
+
redactPatterns: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
60
|
+
paths: z.ZodOptional<z.ZodString>;
|
|
61
|
+
pathsDelimiter: z.ZodOptional<z.ZodString>;
|
|
62
|
+
pathsDelimiterPattern: z.ZodOptional<z.ZodString>;
|
|
63
|
+
scripts: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
64
|
+
shell: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodString]>>;
|
|
65
|
+
vars: z.ZodOptional<z.ZodString>;
|
|
66
|
+
varsAssignor: z.ZodOptional<z.ZodString>;
|
|
67
|
+
varsAssignorPattern: z.ZodOptional<z.ZodString>;
|
|
68
|
+
varsDelimiter: z.ZodOptional<z.ZodString>;
|
|
69
|
+
varsDelimiterPattern: z.ZodOptional<z.ZodString>;
|
|
70
|
+
}, z.core.$strip>;
|
|
11
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Resolved programmatic options schema (post-inheritance).
|
|
74
|
+
* For now, this mirrors the RAW schema; future stages may materialize defaults
|
|
75
|
+
* and narrow shapes as resolution is wired into the host.
|
|
76
|
+
*/
|
|
12
77
|
declare const getDotenvOptionsSchemaResolved: z.ZodObject<{
|
|
13
78
|
defaultEnv: z.ZodOptional<z.ZodString>;
|
|
14
79
|
dotenvToken: z.ZodOptional<z.ZodString>;
|
|
@@ -22,13 +87,23 @@ declare const getDotenvOptionsSchemaResolved: z.ZodObject<{
|
|
|
22
87
|
excludePublic: z.ZodOptional<z.ZodBoolean>;
|
|
23
88
|
loadProcess: z.ZodOptional<z.ZodBoolean>;
|
|
24
89
|
log: z.ZodOptional<z.ZodBoolean>;
|
|
25
|
-
logger: z.
|
|
90
|
+
logger: z.ZodDefault<z.ZodUnknown>;
|
|
26
91
|
outputPath: z.ZodOptional<z.ZodString>;
|
|
27
92
|
paths: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
28
93
|
privateToken: z.ZodOptional<z.ZodString>;
|
|
29
94
|
vars: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodOptional<z.ZodString>>>;
|
|
30
95
|
}, z.core.$strip>;
|
|
31
96
|
|
|
97
|
+
/**
|
|
98
|
+
* Canonical programmatic options and helpers for get-dotenv.
|
|
99
|
+
*
|
|
100
|
+
* Requirements addressed:
|
|
101
|
+
* - GetDotenvOptions derives from the Zod schema output (single source of truth).
|
|
102
|
+
* - Removed deprecated/compat flags from the public shape (e.g., useConfigLoader).
|
|
103
|
+
* - Provide Vars-aware defineDynamic and a typed config builder defineGetDotenvConfig\<Vars, Env\>().
|
|
104
|
+
* - Preserve existing behavior for defaults resolution and compat converters.
|
|
105
|
+
*/
|
|
106
|
+
|
|
32
107
|
/**
|
|
33
108
|
* A minimal representation of an environment key/value mapping.
|
|
34
109
|
* Values may be `undefined` to represent "unset".
|
|
@@ -40,7 +115,14 @@ type ProcessEnv = Record<string, string | undefined>;
|
|
|
40
115
|
* or `undefined` to unset/skip the variable.
|
|
41
116
|
*/
|
|
42
117
|
type GetDotenvDynamicFunction = (vars: ProcessEnv, env: string | undefined) => string | undefined;
|
|
118
|
+
/**
|
|
119
|
+
* A map of dynamic variable definitions.
|
|
120
|
+
* Keys are variable names; values are either literal strings or functions.
|
|
121
|
+
*/
|
|
43
122
|
type GetDotenvDynamic = Record<string, GetDotenvDynamicFunction | ReturnType<GetDotenvDynamicFunction>>;
|
|
123
|
+
/**
|
|
124
|
+
* Logger interface compatible with `console` or a subset thereof.
|
|
125
|
+
*/
|
|
44
126
|
type Logger = Record<string, (...args: unknown[]) => void> | typeof console;
|
|
45
127
|
/**
|
|
46
128
|
* Canonical programmatic options type (schema-derived).
|
|
@@ -50,52 +132,17 @@ type GetDotenvOptions = z.output<typeof getDotenvOptionsSchemaResolved> & {
|
|
|
50
132
|
/**
|
|
51
133
|
* Compile-time overlay: narrowed logger for DX (schema stores unknown).
|
|
52
134
|
*/
|
|
53
|
-
logger
|
|
135
|
+
logger: Logger;
|
|
54
136
|
/**
|
|
55
137
|
* Compile-time overlay: narrowed dynamic map for DX (schema stores unknown).
|
|
56
138
|
*/
|
|
57
139
|
dynamic?: GetDotenvDynamic;
|
|
58
140
|
};
|
|
59
141
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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$1 = ScriptsTable;
|
|
142
|
+
/**
|
|
143
|
+
* Unify Scripts via the generic ScriptsTable<TShell> so shell types propagate.
|
|
144
|
+
*/
|
|
145
|
+
type Scripts = ScriptsTable;
|
|
99
146
|
/**
|
|
100
147
|
* Canonical CLI options type derived from the Zod schema output.
|
|
101
148
|
* Includes CLI-only flags (debug/strict/capture/trace/redaction/entropy),
|
|
@@ -106,32 +153,48 @@ type GetDotenvCliOptions = z.output<typeof getDotenvCliOptionsSchemaResolved> &
|
|
|
106
153
|
/**
|
|
107
154
|
* Compile-only overlay for DX: logger narrowed from unknown.
|
|
108
155
|
*/
|
|
109
|
-
logger
|
|
156
|
+
logger: Logger;
|
|
110
157
|
/**
|
|
111
158
|
* Compile-only overlay for DX: scripts narrowed from Record\<string, unknown\>.
|
|
112
159
|
*/
|
|
113
|
-
scripts?: Scripts
|
|
160
|
+
scripts?: Scripts;
|
|
114
161
|
};
|
|
115
162
|
|
|
163
|
+
/**
|
|
164
|
+
* Configuration context used for generating dynamic help descriptions.
|
|
165
|
+
* Contains merged CLI options and plugin configuration slices.
|
|
166
|
+
*
|
|
167
|
+
* @public
|
|
168
|
+
*/
|
|
116
169
|
type ResolvedHelpConfig = Partial<GetDotenvCliOptions> & {
|
|
170
|
+
/**
|
|
171
|
+
* Per‑plugin configuration slices keyed by realized mount path
|
|
172
|
+
* (e.g., `"aws"` or `"aws/whoami"`), used for dynamic help text.
|
|
173
|
+
*/
|
|
117
174
|
plugins: Record<string, unknown>;
|
|
118
175
|
};
|
|
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
|
-
};
|
|
126
176
|
|
|
127
|
-
/** src/cliHost/definePlugin.ts
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
* should use (GetDotenvCliPublic). Using a structural type at the seam avoids
|
|
132
|
-
* nominal class identity issues (private fields) in downstream consumers.
|
|
177
|
+
/** src/cliHost/definePlugin/contracts.ts
|
|
178
|
+
* Public contracts for plugin authoring (types only).
|
|
179
|
+
* - No runtime logic or state.
|
|
180
|
+
* - Safe to import broadly without introducing cycles.
|
|
133
181
|
*/
|
|
134
182
|
|
|
183
|
+
/**
|
|
184
|
+
* Options for resolving and loading the configuration.
|
|
185
|
+
*
|
|
186
|
+
* @public
|
|
187
|
+
*/
|
|
188
|
+
interface ResolveAndLoadOptions {
|
|
189
|
+
/**
|
|
190
|
+
* When false, skips running plugin afterResolve hooks.
|
|
191
|
+
* Useful for top-level help rendering to avoid long-running side-effects
|
|
192
|
+
* while still evaluating dynamic help text.
|
|
193
|
+
*
|
|
194
|
+
* @default true
|
|
195
|
+
*/
|
|
196
|
+
runAfterResolve?: boolean;
|
|
197
|
+
}
|
|
135
198
|
/**
|
|
136
199
|
* Structural public interface for the host exposed to plugins.
|
|
137
200
|
* - Extends Commander.Command so plugins can attach options/commands/hooks.
|
|
@@ -140,51 +203,80 @@ type GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> = {
|
|
|
140
203
|
* Purpose: remove nominal class identity (private fields) from the plugin seam
|
|
141
204
|
* to avoid TS2379 under exactOptionalPropertyTypes in downstream consumers.
|
|
142
205
|
*/
|
|
143
|
-
interface GetDotenvCliPublic<TOptions extends GetDotenvOptions = GetDotenvOptions> extends Command {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
206
|
+
interface GetDotenvCliPublic<TOptions extends GetDotenvOptions = GetDotenvOptions, TArgs extends unknown[] = [], TOpts extends OptionValues = {}, TGlobal extends OptionValues = {}> extends Command<TArgs, TOpts, TGlobal> {
|
|
207
|
+
/**
|
|
208
|
+
* Create a namespaced child command with argument inference.
|
|
209
|
+
* Mirrors Commander generics so downstream chaining remains fully typed.
|
|
210
|
+
*/
|
|
211
|
+
ns<Usage extends string>(name: Usage): GetDotenvCliPublic<TOptions, [
|
|
212
|
+
...TArgs,
|
|
213
|
+
...InferCommandArguments<Usage>
|
|
214
|
+
], {}, TOpts & TGlobal>;
|
|
215
|
+
/** Return the current context; throws if not yet resolved. */
|
|
216
|
+
getCtx(): GetDotenvCliCtx<TOptions>;
|
|
217
|
+
/** Check whether a context has been resolved (non-throwing). */
|
|
218
|
+
hasCtx(): boolean;
|
|
219
|
+
resolveAndLoad(customOptions?: Partial<TOptions>, opts?: ResolveAndLoadOptions): Promise<GetDotenvCliCtx<TOptions>>;
|
|
149
220
|
setOptionGroup(opt: Option, group: string): void;
|
|
150
221
|
/**
|
|
151
222
|
* Create a dynamic option whose description is computed at help time
|
|
152
223
|
* from the resolved configuration.
|
|
153
224
|
*/
|
|
154
|
-
createDynamicOption(flags:
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
225
|
+
createDynamicOption<Usage extends string>(flags: Usage, desc: (cfg: ResolvedHelpConfig) => string, parser?: (value: string, previous?: unknown) => unknown, defaultValue?: unknown): Option<Usage>;
|
|
226
|
+
createDynamicOption<Usage extends string, TValue = unknown>(flags: Usage, desc: (cfg: ResolvedHelpConfig) => string, parser: (value: string, previous?: TValue) => TValue, defaultValue?: TValue): Option<Usage>;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Optional overrides for plugin composition.
|
|
230
|
+
*
|
|
231
|
+
* @public
|
|
232
|
+
*/
|
|
233
|
+
interface PluginNamespaceOverride {
|
|
234
|
+
/**
|
|
235
|
+
* Override the default namespace for this plugin instance.
|
|
236
|
+
*/
|
|
237
|
+
ns?: string;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* An entry in the plugin children array.
|
|
241
|
+
*
|
|
242
|
+
* @public
|
|
243
|
+
*/
|
|
244
|
+
interface PluginChildEntry<TOptions extends GetDotenvOptions = GetDotenvOptions, TArgs extends unknown[] = [], TOpts extends OptionValues = {}, TGlobal extends OptionValues = {}> {
|
|
245
|
+
/** The child plugin instance to mount under this parent. */
|
|
246
|
+
plugin: GetDotenvCliPlugin<TOptions, TArgs, TOpts, TGlobal>;
|
|
247
|
+
/**
|
|
248
|
+
* Optional namespace override for the child when mounted under the parent.
|
|
249
|
+
* When provided, this name is used instead of the child's default `ns`.
|
|
250
|
+
*/
|
|
251
|
+
override: PluginNamespaceOverride | undefined;
|
|
160
252
|
}
|
|
161
253
|
/** Public plugin contract used by the GetDotenv CLI host. */
|
|
162
|
-
interface GetDotenvCliPlugin<TOptions extends GetDotenvOptions = GetDotenvOptions> {
|
|
163
|
-
|
|
254
|
+
interface GetDotenvCliPlugin<TOptions extends GetDotenvOptions = GetDotenvOptions, TArgs extends unknown[] = [], TOpts extends OptionValues = {}, TGlobal extends OptionValues = {}> {
|
|
255
|
+
/** Namespace (required): the command name where this plugin is mounted. */
|
|
256
|
+
ns: string;
|
|
164
257
|
/**
|
|
165
|
-
* Setup phase: register commands and wiring on the provided
|
|
166
|
-
* Runs parent → children (pre-order).
|
|
258
|
+
* Setup phase: register commands and wiring on the provided mount.
|
|
259
|
+
* Runs parent → children (pre-order). Return nothing (void).
|
|
167
260
|
*/
|
|
168
|
-
setup: (cli: GetDotenvCliPublic<TOptions>) => void | Promise<void>;
|
|
261
|
+
setup: (cli: GetDotenvCliPublic<TOptions, TArgs, TOpts, TGlobal>) => void | Promise<void>;
|
|
169
262
|
/**
|
|
170
263
|
* After the dotenv context is resolved, initialize any clients/secrets
|
|
171
264
|
* or attach per-plugin state under ctx.plugins (by convention).
|
|
172
265
|
* Runs parent → children (pre-order).
|
|
173
266
|
*/
|
|
174
|
-
afterResolve?: (cli: GetDotenvCliPublic<TOptions>, ctx: GetDotenvCliCtx<TOptions>) => void | Promise<void>;
|
|
175
|
-
/**
|
|
176
|
-
* Zod schema for this plugin's config slice (from config.plugins[id]).
|
|
177
|
-
* Enforced object-like (ZodObject) to simplify code paths and inference.
|
|
178
|
-
*/
|
|
267
|
+
afterResolve?: (cli: GetDotenvCliPublic<TOptions, TArgs, TOpts, TGlobal>, ctx: GetDotenvCliCtx<TOptions>) => void | Promise<void>;
|
|
268
|
+
/** Zod schema for this plugin's config slice (from config.plugins[…]). */
|
|
179
269
|
configSchema?: ZodObject;
|
|
180
270
|
/**
|
|
181
|
-
* Compositional children
|
|
271
|
+
* Compositional children, with optional per-child overrides (e.g., ns).
|
|
272
|
+
* Installed after the parent per pre-order.
|
|
182
273
|
*/
|
|
183
|
-
children:
|
|
274
|
+
children: Array<PluginChildEntry<TOptions, TArgs, TOpts, TGlobal>>;
|
|
184
275
|
/**
|
|
185
|
-
* Compose a child plugin. Returns the parent
|
|
276
|
+
* Compose a child plugin with optional override (ns). Returns the parent
|
|
277
|
+
* to enable chaining.
|
|
186
278
|
*/
|
|
187
|
-
use: (child: GetDotenvCliPlugin<TOptions
|
|
279
|
+
use: (child: GetDotenvCliPlugin<TOptions, TArgs, TOpts, TGlobal>, override?: PluginNamespaceOverride) => GetDotenvCliPlugin<TOptions, TArgs, TOpts, TGlobal>;
|
|
188
280
|
}
|
|
189
281
|
/**
|
|
190
282
|
* Compile-time helper type: the plugin object returned by definePlugin always
|
|
@@ -192,13 +284,16 @@ interface GetDotenvCliPlugin<TOptions extends GetDotenvOptions = GetDotenvOption
|
|
|
192
284
|
* interface optional preserves compatibility for ad-hoc/test plugins, while
|
|
193
285
|
* return types from definePlugin provide stronger DX for shipped/typed plugins.
|
|
194
286
|
*/
|
|
195
|
-
|
|
196
|
-
readConfig<TCfg = TConfig>(cli: GetDotenvCliPublic<TOptions>): Readonly<TCfg>;
|
|
197
|
-
createPluginDynamicOption<TCfg = TConfig>(cli: GetDotenvCliPublic<TOptions>, flags:
|
|
198
|
-
|
|
199
|
-
}, pluginCfg: Readonly<TCfg>) => string, parser?: (value: string, previous?: unknown) => unknown, defaultValue?: unknown): Option;
|
|
200
|
-
};
|
|
287
|
+
interface PluginWithInstanceHelpers<TOptions extends GetDotenvOptions = GetDotenvOptions, TConfig = unknown, TArgs extends unknown[] = [], TOpts extends OptionValues = {}, TGlobal extends OptionValues = {}> extends GetDotenvCliPlugin<TOptions, TArgs, TOpts, TGlobal> {
|
|
288
|
+
readConfig<TCfg = TConfig>(cli: GetDotenvCliPublic<TOptions, unknown[], OptionValues, OptionValues>): Readonly<TCfg>;
|
|
289
|
+
createPluginDynamicOption<TCfg = TConfig, Usage extends string = string>(cli: GetDotenvCliPublic<TOptions, unknown[], OptionValues, OptionValues>, flags: Usage, desc: (cfg: ResolvedHelpConfig, pluginCfg: Readonly<TCfg>) => string, parser?: (value: string, previous?: unknown) => unknown, defaultValue?: unknown): Option<Usage>;
|
|
290
|
+
}
|
|
201
291
|
|
|
292
|
+
/**
|
|
293
|
+
* AWS plugin: establishes an AWS session (credentials/region) based on dotenv configuration.
|
|
294
|
+
* Supports SSO login-on-demand and credential exporting.
|
|
295
|
+
* Can be used as a parent command to wrap `aws` CLI invocations.
|
|
296
|
+
*/
|
|
202
297
|
declare const awsPlugin: () => PluginWithInstanceHelpers<GetDotenvOptions, {
|
|
203
298
|
profile?: string | undefined;
|
|
204
299
|
region?: string | undefined;
|
|
@@ -208,20 +303,29 @@ declare const awsPlugin: () => PluginWithInstanceHelpers<GetDotenvOptions, {
|
|
|
208
303
|
regionKey?: string | undefined;
|
|
209
304
|
strategy?: "cli-export" | "none" | undefined;
|
|
210
305
|
loginOnDemand?: boolean | undefined;
|
|
211
|
-
}>;
|
|
306
|
+
}, [], {}, {}>;
|
|
212
307
|
|
|
213
308
|
/**
|
|
214
|
-
*
|
|
215
|
-
*
|
|
309
|
+
* AWS Whoami plugin: prints the current AWS caller identity (account, arn, userid).
|
|
310
|
+
* Intended to be mounted under the `aws` plugin.
|
|
216
311
|
*/
|
|
312
|
+
declare const awsWhoamiPlugin: () => PluginWithInstanceHelpers<GetDotenvOptions, {}, [], {}, {}>;
|
|
217
313
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
314
|
+
/**
|
|
315
|
+
* Options provided to the batch plugin factory.
|
|
316
|
+
*
|
|
317
|
+
* @public
|
|
318
|
+
*/
|
|
319
|
+
interface BatchPluginOptions {
|
|
320
|
+
/**
|
|
321
|
+
* Scripts table used to resolve command names and optional per-script shell overrides.
|
|
322
|
+
*/
|
|
323
|
+
scripts?: ScriptsTable;
|
|
324
|
+
/**
|
|
325
|
+
* Global shell preference for batch execution; overridden by per-script shell when present.
|
|
326
|
+
*/
|
|
222
327
|
shell?: string | boolean;
|
|
223
|
-
|
|
224
|
-
};
|
|
328
|
+
}
|
|
225
329
|
|
|
226
330
|
/**
|
|
227
331
|
* Batch plugin for the GetDotenv CLI host.
|
|
@@ -229,7 +333,6 @@ type BatchPluginOptions = {
|
|
|
229
333
|
* Mirrors the legacy batch subcommand behavior without altering the shipped CLI.
|
|
230
334
|
* Options:
|
|
231
335
|
* - scripts/shell: used to resolve command and shell behavior per script or global default.
|
|
232
|
-
* - logger: defaults to console.
|
|
233
336
|
*/
|
|
234
337
|
declare const batchPlugin: (opts?: BatchPluginOptions) => PluginWithInstanceHelpers<GetDotenvOptions, {
|
|
235
338
|
scripts?: Record<string, string | {
|
|
@@ -240,34 +343,52 @@ declare const batchPlugin: (opts?: BatchPluginOptions) => PluginWithInstanceHelp
|
|
|
240
343
|
rootPath?: string | undefined;
|
|
241
344
|
globs?: string | undefined;
|
|
242
345
|
pkgCwd?: boolean | undefined;
|
|
243
|
-
}>;
|
|
346
|
+
}, [], {}, {}>;
|
|
244
347
|
|
|
245
|
-
|
|
348
|
+
/**
|
|
349
|
+
* Configuration for the parent-level command alias.
|
|
350
|
+
*
|
|
351
|
+
* @public
|
|
352
|
+
*/
|
|
353
|
+
interface CmdOptionAlias {
|
|
354
|
+
/** Option flags (e.g. "-c, --cmd \<command...\>"). */
|
|
355
|
+
flags: string;
|
|
356
|
+
/** Option description. */
|
|
357
|
+
description?: string;
|
|
358
|
+
/** Whether to expand the alias value before execution. */
|
|
359
|
+
expand?: boolean;
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Options provided to the cmd plugin factory.
|
|
363
|
+
*
|
|
364
|
+
* @public
|
|
365
|
+
*/
|
|
366
|
+
interface CmdPluginOptions {
|
|
246
367
|
/**
|
|
247
|
-
* When true, register as the default subcommand at the root.
|
|
368
|
+
* When true, register as the default subcommand at the root.
|
|
369
|
+
*/
|
|
248
370
|
asDefault?: boolean;
|
|
249
371
|
/**
|
|
250
|
-
* Optional alias option attached to the parent command to invoke the cmd
|
|
372
|
+
* Optional alias option attached to the parent command to invoke the cmd
|
|
373
|
+
* behavior without specifying the subcommand explicitly.
|
|
251
374
|
*/
|
|
252
|
-
optionAlias?: string |
|
|
253
|
-
|
|
254
|
-
description?: string;
|
|
255
|
-
expand?: boolean;
|
|
256
|
-
};
|
|
257
|
-
};
|
|
258
|
-
/**+ Cmd plugin: executes a command using the current getdotenv CLI context.
|
|
259
|
-
*
|
|
260
|
-
* - Joins positional args into a single command string.
|
|
261
|
-
* - Resolves scripts and shell settings using shared helpers.
|
|
262
|
-
* - Forwards merged CLI options to subprocesses via
|
|
263
|
-
* process.env.getDotenvCliOptions for nested CLI behavior. */
|
|
264
|
-
declare const cmdPlugin: (options?: CmdPluginOptions) => PluginWithInstanceHelpers<GetDotenvOptions, {}>;
|
|
375
|
+
optionAlias?: string | CmdOptionAlias;
|
|
376
|
+
}
|
|
265
377
|
|
|
266
|
-
|
|
378
|
+
/**
|
|
379
|
+
* Cmd plugin: executes a command using the current getdotenv CLI context.
|
|
380
|
+
* Registers the `cmd` subcommand and optionally attaches a parent-level alias (e.g. `-c`).
|
|
381
|
+
*
|
|
382
|
+
* @param options - Plugin configuration options.
|
|
383
|
+
*/
|
|
384
|
+
declare const cmdPlugin: (options?: CmdPluginOptions) => PluginWithInstanceHelpers<GetDotenvOptions, {
|
|
385
|
+
expand?: boolean | undefined;
|
|
386
|
+
}, [], {}, {}>;
|
|
267
387
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
388
|
+
/**
|
|
389
|
+
* Init plugin: scaffolds configuration files and a CLI skeleton for get-dotenv.
|
|
390
|
+
* Supports collision detection, interactive prompts, and CI bypass.
|
|
391
|
+
*/
|
|
392
|
+
declare const initPlugin: () => PluginWithInstanceHelpers<GetDotenvOptions, {}, [], {}, {}>;
|
|
272
393
|
|
|
273
|
-
export { awsPlugin, batchPlugin, cmdPlugin,
|
|
394
|
+
export { awsPlugin, awsWhoamiPlugin, batchPlugin, cmdPlugin, initPlugin };
|