@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.
- package/README.md +86 -334
- package/dist/cli.d.ts +569 -0
- package/dist/cli.mjs +18788 -0
- package/dist/cliHost.d.ts +548 -253
- package/dist/cliHost.mjs +1990 -1458
- package/dist/config.d.ts +192 -14
- package/dist/config.mjs +256 -81
- package/dist/env-overlay.d.ts +226 -18
- package/dist/env-overlay.mjs +181 -22
- package/dist/getdotenv.cli.mjs +18166 -3437
- package/dist/index.d.ts +729 -136
- package/dist/index.mjs +18207 -3457
- package/dist/plugins-aws.d.ts +289 -104
- package/dist/plugins-aws.mjs +2462 -350
- package/dist/plugins-batch.d.ts +355 -105
- package/dist/plugins-batch.mjs +2595 -420
- package/dist/plugins-cmd.d.ts +287 -118
- package/dist/plugins-cmd.mjs +2661 -839
- package/dist/plugins-init.d.ts +272 -100
- package/dist/plugins-init.mjs +2152 -37
- package/dist/plugins.d.ts +323 -140
- package/dist/plugins.mjs +18006 -2025
- package/dist/templates/cli/index.ts +26 -0
- package/dist/templates/cli/plugins/hello.ts +43 -0
- 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 +43 -0
- package/dist/templates/index.ts +26 -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 +43 -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 +52 -89
- package/templates/cli/index.ts +26 -0
- package/templates/cli/plugins/hello.ts +43 -0
- package/templates/config/js/getdotenv.config.js +9 -4
- 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 +17 -5
- package/templates/config/yaml/public/getdotenv.config.yaml +0 -3
- package/dist/cliHost.cjs +0 -2078
- package/dist/cliHost.d.cts +0 -451
- package/dist/cliHost.d.mts +0 -451
- 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 -4077
- package/dist/index.d.cts +0 -318
- package/dist/index.d.mts +0 -318
- package/dist/plugins-aws.cjs +0 -666
- package/dist/plugins-aws.d.cts +0 -158
- package/dist/plugins-aws.d.mts +0 -158
- package/dist/plugins-batch.cjs +0 -658
- package/dist/plugins-batch.d.cts +0 -181
- package/dist/plugins-batch.d.mts +0 -181
- package/dist/plugins-cmd.cjs +0 -1112
- package/dist/plugins-cmd.d.cts +0 -178
- package/dist/plugins-cmd.d.mts +0 -178
- package/dist/plugins-demo.cjs +0 -352
- package/dist/plugins-demo.d.cts +0 -158
- package/dist/plugins-demo.d.mts +0 -158
- package/dist/plugins-demo.d.ts +0 -158
- package/dist/plugins-demo.mjs +0 -350
- 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 -2327
- package/dist/plugins.d.cts +0 -211
- package/dist/plugins.d.mts +0 -211
- package/templates/cli/ts/index.ts +0 -9
- package/templates/cli/ts/plugins/hello.ts +0 -17
package/dist/plugins.d.ts
CHANGED
|
@@ -1,174 +1,331 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import {
|
|
1
|
+
import { OptionValues, Command, InferCommandArguments, Option } from '@commander-js/extra-typings';
|
|
2
|
+
import { z, ZodObject } from 'zod';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Definition for a single script entry.
|
|
6
|
+
*/
|
|
7
|
+
interface ScriptDef<TShell extends string | boolean = string | boolean> {
|
|
8
|
+
/** The command string to execute. */
|
|
9
|
+
cmd: string;
|
|
10
|
+
/** Shell override for this script. */
|
|
11
|
+
shell?: TShell | undefined;
|
|
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>;
|
|
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
|
+
*/
|
|
77
|
+
declare const getDotenvOptionsSchemaResolved: z.ZodObject<{
|
|
78
|
+
defaultEnv: z.ZodOptional<z.ZodString>;
|
|
79
|
+
dotenvToken: z.ZodOptional<z.ZodString>;
|
|
80
|
+
dynamicPath: z.ZodOptional<z.ZodString>;
|
|
81
|
+
dynamic: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
82
|
+
env: z.ZodOptional<z.ZodString>;
|
|
83
|
+
excludeDynamic: z.ZodOptional<z.ZodBoolean>;
|
|
84
|
+
excludeEnv: z.ZodOptional<z.ZodBoolean>;
|
|
85
|
+
excludeGlobal: z.ZodOptional<z.ZodBoolean>;
|
|
86
|
+
excludePrivate: z.ZodOptional<z.ZodBoolean>;
|
|
87
|
+
excludePublic: z.ZodOptional<z.ZodBoolean>;
|
|
88
|
+
loadProcess: z.ZodOptional<z.ZodBoolean>;
|
|
89
|
+
log: z.ZodOptional<z.ZodBoolean>;
|
|
90
|
+
logger: z.ZodDefault<z.ZodUnknown>;
|
|
91
|
+
outputPath: z.ZodOptional<z.ZodString>;
|
|
92
|
+
paths: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
93
|
+
privateToken: z.ZodOptional<z.ZodString>;
|
|
94
|
+
vars: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodOptional<z.ZodString>>>;
|
|
95
|
+
}, z.core.$strip>;
|
|
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
|
+
*/
|
|
3
106
|
|
|
4
107
|
/**
|
|
5
108
|
* A minimal representation of an environment key/value mapping.
|
|
6
|
-
* Values may be `undefined` to represent "unset".
|
|
109
|
+
* Values may be `undefined` to represent "unset".
|
|
110
|
+
*/
|
|
111
|
+
type ProcessEnv = Record<string, string | undefined>;
|
|
7
112
|
/**
|
|
8
113
|
* Dynamic variable function signature. Receives the current expanded variables
|
|
9
114
|
* and the selected environment (if any), and returns either a string to set
|
|
10
115
|
* or `undefined` to unset/skip the variable.
|
|
11
116
|
*/
|
|
12
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
|
+
*/
|
|
13
122
|
type GetDotenvDynamic = Record<string, GetDotenvDynamicFunction | ReturnType<GetDotenvDynamicFunction>>;
|
|
123
|
+
/**
|
|
124
|
+
* Logger interface compatible with `console` or a subset thereof.
|
|
125
|
+
*/
|
|
14
126
|
type Logger = Record<string, (...args: unknown[]) => void> | typeof console;
|
|
15
127
|
/**
|
|
16
|
-
*
|
|
128
|
+
* Canonical programmatic options type (schema-derived).
|
|
129
|
+
* This type is the single source of truth for programmatic options.
|
|
17
130
|
*/
|
|
18
|
-
|
|
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;
|
|
131
|
+
type GetDotenvOptions = z.output<typeof getDotenvOptionsSchemaResolved> & {
|
|
27
132
|
/**
|
|
28
|
-
*
|
|
133
|
+
* Compile-time overlay: narrowed logger for DX (schema stores unknown).
|
|
29
134
|
*/
|
|
30
|
-
|
|
135
|
+
logger: Logger;
|
|
31
136
|
/**
|
|
32
|
-
*
|
|
33
|
-
* over {@link GetDotenvOptions.dynamicPath}.
|
|
137
|
+
* Compile-time overlay: narrowed dynamic map for DX (schema stores unknown).
|
|
34
138
|
*/
|
|
35
139
|
dynamic?: GetDotenvDynamic;
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Unify Scripts via the generic ScriptsTable<TShell> so shell types propagate.
|
|
144
|
+
*/
|
|
145
|
+
type Scripts = ScriptsTable;
|
|
146
|
+
/**
|
|
147
|
+
* Canonical CLI options type derived from the Zod schema output.
|
|
148
|
+
* Includes CLI-only flags (debug/strict/capture/trace/redaction/entropy),
|
|
149
|
+
* stringly paths/vars, and inherited programmatic fields (minus normalized
|
|
150
|
+
* shapes that are handled by resolution).
|
|
151
|
+
*/
|
|
152
|
+
type GetDotenvCliOptions = z.output<typeof getDotenvCliOptionsSchemaResolved> & {
|
|
36
153
|
/**
|
|
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)
|
|
154
|
+
* Compile-only overlay for DX: logger narrowed from unknown.
|
|
70
155
|
*/
|
|
71
|
-
logger
|
|
156
|
+
logger: Logger;
|
|
72
157
|
/**
|
|
73
|
-
*
|
|
158
|
+
* Compile-only overlay for DX: scripts narrowed from Record\<string, unknown\>.
|
|
74
159
|
*/
|
|
75
|
-
|
|
160
|
+
scripts?: Scripts;
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Configuration context used for generating dynamic help descriptions.
|
|
165
|
+
* Contains merged CLI options and plugin configuration slices.
|
|
166
|
+
*
|
|
167
|
+
* @public
|
|
168
|
+
*/
|
|
169
|
+
type ResolvedHelpConfig = Partial<GetDotenvCliOptions> & {
|
|
76
170
|
/**
|
|
77
|
-
*
|
|
171
|
+
* Per‑plugin configuration slices keyed by realized mount path
|
|
172
|
+
* (e.g., `"aws"` or `"aws/whoami"`), used for dynamic help text.
|
|
78
173
|
*/
|
|
79
|
-
|
|
174
|
+
plugins: Record<string, unknown>;
|
|
175
|
+
};
|
|
176
|
+
|
|
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.
|
|
181
|
+
*/
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Options for resolving and loading the configuration.
|
|
185
|
+
*
|
|
186
|
+
* @public
|
|
187
|
+
*/
|
|
188
|
+
interface ResolveAndLoadOptions {
|
|
80
189
|
/**
|
|
81
|
-
*
|
|
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
|
|
82
195
|
*/
|
|
83
|
-
|
|
196
|
+
runAfterResolve?: boolean;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Structural public interface for the host exposed to plugins.
|
|
200
|
+
* - Extends Commander.Command so plugins can attach options/commands/hooks.
|
|
201
|
+
* - Adds host-specific helpers used by built-in plugins.
|
|
202
|
+
*
|
|
203
|
+
* Purpose: remove nominal class identity (private fields) from the plugin seam
|
|
204
|
+
* to avoid TS2379 under exactOptionalPropertyTypes in downstream consumers.
|
|
205
|
+
*/
|
|
206
|
+
interface GetDotenvCliPublic<TOptions extends GetDotenvOptions = GetDotenvOptions, TArgs extends unknown[] = [], TOpts extends OptionValues = {}, TGlobal extends OptionValues = {}> extends Command<TArgs, TOpts, TGlobal> {
|
|
84
207
|
/**
|
|
85
|
-
*
|
|
208
|
+
* Create a namespaced child command with argument inference.
|
|
209
|
+
* Mirrors Commander generics so downstream chaining remains fully typed.
|
|
86
210
|
*/
|
|
87
|
-
|
|
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>>;
|
|
220
|
+
setOptionGroup(opt: Option, group: string): void;
|
|
88
221
|
/**
|
|
89
|
-
*
|
|
90
|
-
*
|
|
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.
|
|
222
|
+
* Create a dynamic option whose description is computed at help time
|
|
223
|
+
* from the resolved configuration.
|
|
94
224
|
*/
|
|
95
|
-
|
|
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>;
|
|
96
227
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
* Plugin contracts for the GetDotenv CLI host.
|
|
228
|
+
/**
|
|
229
|
+
* Optional overrides for plugin composition.
|
|
100
230
|
*
|
|
101
|
-
*
|
|
102
|
-
* should use (GetDotenvCliPublic). Using a structural type at the seam avoids
|
|
103
|
-
* nominal class identity issues (private fields) in downstream consumers.
|
|
231
|
+
* @public
|
|
104
232
|
*/
|
|
105
|
-
|
|
233
|
+
interface PluginNamespaceOverride {
|
|
234
|
+
/**
|
|
235
|
+
* Override the default namespace for this plugin instance.
|
|
236
|
+
*/
|
|
237
|
+
ns?: string;
|
|
238
|
+
}
|
|
106
239
|
/**
|
|
107
|
-
*
|
|
108
|
-
* - Extends Commander.Command so plugins can attach options/commands/hooks.
|
|
109
|
-
* - Adds host-specific helpers used by built-in plugins.
|
|
240
|
+
* An entry in the plugin children array.
|
|
110
241
|
*
|
|
111
|
-
*
|
|
112
|
-
* to avoid TS2379 under exactOptionalPropertyTypes in downstream consumers.
|
|
242
|
+
* @public
|
|
113
243
|
*/
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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;
|
|
252
|
+
}
|
|
119
253
|
/** Public plugin contract used by the GetDotenv CLI host. */
|
|
120
|
-
interface GetDotenvCliPlugin {
|
|
121
|
-
|
|
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;
|
|
122
257
|
/**
|
|
123
|
-
* Setup phase: register commands and wiring on the provided
|
|
124
|
-
* 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).
|
|
125
260
|
*/
|
|
126
|
-
setup: (cli: GetDotenvCliPublic) => void | Promise<void>;
|
|
261
|
+
setup: (cli: GetDotenvCliPublic<TOptions, TArgs, TOpts, TGlobal>) => void | Promise<void>;
|
|
127
262
|
/**
|
|
128
263
|
* After the dotenv context is resolved, initialize any clients/secrets
|
|
129
264
|
* or attach per-plugin state under ctx.plugins (by convention).
|
|
130
265
|
* Runs parent → children (pre-order).
|
|
131
266
|
*/
|
|
132
|
-
afterResolve?: (cli: GetDotenvCliPublic, ctx: GetDotenvCliCtx) => void | Promise<void>;
|
|
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[…]). */
|
|
269
|
+
configSchema?: ZodObject;
|
|
133
270
|
/**
|
|
134
|
-
*
|
|
135
|
-
*
|
|
271
|
+
* Compositional children, with optional per-child overrides (e.g., ns).
|
|
272
|
+
* Installed after the parent per pre-order.
|
|
136
273
|
*/
|
|
137
|
-
|
|
274
|
+
children: Array<PluginChildEntry<TOptions, TArgs, TOpts, TGlobal>>;
|
|
138
275
|
/**
|
|
139
|
-
*
|
|
276
|
+
* Compose a child plugin with optional override (ns). Returns the parent
|
|
277
|
+
* to enable chaining.
|
|
140
278
|
*/
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
279
|
+
use: (child: GetDotenvCliPlugin<TOptions, TArgs, TOpts, TGlobal>, override?: PluginNamespaceOverride) => GetDotenvCliPlugin<TOptions, TArgs, TOpts, TGlobal>;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Compile-time helper type: the plugin object returned by definePlugin always
|
|
283
|
+
* includes the instance-bound helpers as required members. Keeping the public
|
|
284
|
+
* interface optional preserves compatibility for ad-hoc/test plugins, while
|
|
285
|
+
* return types from definePlugin provide stronger DX for shipped/typed plugins.
|
|
286
|
+
*/
|
|
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>;
|
|
146
290
|
}
|
|
147
291
|
|
|
148
|
-
/**
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
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
|
+
*/
|
|
297
|
+
declare const awsPlugin: () => PluginWithInstanceHelpers<GetDotenvOptions, {
|
|
298
|
+
profile?: string | undefined;
|
|
299
|
+
region?: string | undefined;
|
|
300
|
+
defaultRegion?: string | undefined;
|
|
301
|
+
profileKey?: string | undefined;
|
|
302
|
+
profileFallbackKey?: string | undefined;
|
|
303
|
+
regionKey?: string | undefined;
|
|
304
|
+
strategy?: "cli-export" | "none" | undefined;
|
|
305
|
+
loginOnDemand?: boolean | undefined;
|
|
306
|
+
}, [], {}, {}>;
|
|
157
307
|
|
|
158
308
|
/**
|
|
159
|
-
*
|
|
160
|
-
*
|
|
309
|
+
* AWS Whoami plugin: prints the current AWS caller identity (account, arn, userid).
|
|
310
|
+
* Intended to be mounted under the `aws` plugin.
|
|
161
311
|
*/
|
|
162
|
-
|
|
163
|
-
cmd: string;
|
|
164
|
-
shell?: string | boolean | undefined;
|
|
165
|
-
}>;
|
|
312
|
+
declare const awsWhoamiPlugin: () => PluginWithInstanceHelpers<GetDotenvOptions, {}, [], {}, {}>;
|
|
166
313
|
|
|
167
|
-
|
|
168
|
-
|
|
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
|
+
*/
|
|
169
327
|
shell?: string | boolean;
|
|
170
|
-
|
|
171
|
-
};
|
|
328
|
+
}
|
|
172
329
|
|
|
173
330
|
/**
|
|
174
331
|
* Batch plugin for the GetDotenv CLI host.
|
|
@@ -176,36 +333,62 @@ type BatchPluginOptions = {
|
|
|
176
333
|
* Mirrors the legacy batch subcommand behavior without altering the shipped CLI.
|
|
177
334
|
* Options:
|
|
178
335
|
* - scripts/shell: used to resolve command and shell behavior per script or global default.
|
|
179
|
-
* - logger: defaults to console.
|
|
180
336
|
*/
|
|
181
|
-
declare const batchPlugin: (opts?: BatchPluginOptions) =>
|
|
337
|
+
declare const batchPlugin: (opts?: BatchPluginOptions) => PluginWithInstanceHelpers<GetDotenvOptions, {
|
|
338
|
+
scripts?: Record<string, string | {
|
|
339
|
+
cmd: string;
|
|
340
|
+
shell?: string | boolean | undefined;
|
|
341
|
+
}> | undefined;
|
|
342
|
+
shell?: string | boolean | undefined;
|
|
343
|
+
rootPath?: string | undefined;
|
|
344
|
+
globs?: string | undefined;
|
|
345
|
+
pkgCwd?: boolean | undefined;
|
|
346
|
+
}, [], {}, {}>;
|
|
182
347
|
|
|
183
|
-
|
|
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 {
|
|
184
367
|
/**
|
|
185
|
-
* When true, register as the default subcommand at the root.
|
|
368
|
+
* When true, register as the default subcommand at the root.
|
|
369
|
+
*/
|
|
186
370
|
asDefault?: boolean;
|
|
187
371
|
/**
|
|
188
|
-
* 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.
|
|
189
374
|
*/
|
|
190
|
-
optionAlias?: string |
|
|
191
|
-
|
|
192
|
-
description?: string;
|
|
193
|
-
expand?: boolean;
|
|
194
|
-
};
|
|
195
|
-
};
|
|
196
|
-
/**+ Cmd plugin: executes a command using the current getdotenv CLI context.
|
|
197
|
-
*
|
|
198
|
-
* - Joins positional args into a single command string.
|
|
199
|
-
* - Resolves scripts and shell settings using shared helpers.
|
|
200
|
-
* - Forwards merged CLI options to subprocesses via
|
|
201
|
-
* process.env.getDotenvCliOptions for nested CLI behavior. */
|
|
202
|
-
declare const cmdPlugin: (options?: CmdPluginOptions) => GetDotenvCliPlugin;
|
|
375
|
+
optionAlias?: string | CmdOptionAlias;
|
|
376
|
+
}
|
|
203
377
|
|
|
204
|
-
|
|
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
|
+
}, [], {}, {}>;
|
|
205
387
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
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, {}, [], {}, {}>;
|
|
210
393
|
|
|
211
|
-
export { awsPlugin, batchPlugin, cmdPlugin,
|
|
394
|
+
export { awsPlugin, awsWhoamiPlugin, batchPlugin, cmdPlugin, initPlugin };
|