@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-batch.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,25 +284,130 @@ 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
|
|
|
202
292
|
/**
|
|
203
|
-
*
|
|
204
|
-
*
|
|
293
|
+
* Options provided to the batch plugin factory.
|
|
294
|
+
*
|
|
295
|
+
* @public
|
|
205
296
|
*/
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
scripts?:
|
|
297
|
+
interface BatchPluginOptions {
|
|
298
|
+
/**
|
|
299
|
+
* Scripts table used to resolve command names and optional per-script shell overrides.
|
|
300
|
+
*/
|
|
301
|
+
scripts?: ScriptsTable;
|
|
302
|
+
/**
|
|
303
|
+
* Global shell preference for batch execution; overridden by per-script shell when present.
|
|
304
|
+
*/
|
|
211
305
|
shell?: string | boolean;
|
|
212
|
-
|
|
213
|
-
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Options for discovering batch working directories from a root path and globs.
|
|
309
|
+
*
|
|
310
|
+
* @public
|
|
311
|
+
*/
|
|
312
|
+
interface BatchGlobPathsOptions {
|
|
313
|
+
/**
|
|
314
|
+
* Space-delimited glob patterns relative to {@link BatchGlobPathsOptions.rootPath}.
|
|
315
|
+
* Each pattern is resolved using posix-style separators and must resolve to
|
|
316
|
+
* directories (files are ignored).
|
|
317
|
+
*/
|
|
318
|
+
globs: string;
|
|
319
|
+
/**
|
|
320
|
+
* Logger used for user-facing messages (errors, headings, and listings).
|
|
321
|
+
*/
|
|
322
|
+
logger: Logger;
|
|
323
|
+
/**
|
|
324
|
+
* When true, resolve the batch root from the nearest package directory
|
|
325
|
+
* instead of the current working directory.
|
|
326
|
+
*/
|
|
327
|
+
pkgCwd?: boolean;
|
|
328
|
+
/**
|
|
329
|
+
* Path to the batch root directory, resolved from the current working directory
|
|
330
|
+
* (or package directory when {@link BatchGlobPathsOptions.pkgCwd} is true).
|
|
331
|
+
*/
|
|
332
|
+
rootPath: string;
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Arguments for {@link execShellCommandBatch} — batch execution over discovered working directories.
|
|
336
|
+
*
|
|
337
|
+
* @public
|
|
338
|
+
*/
|
|
339
|
+
interface ExecShellCommandBatchOptions {
|
|
340
|
+
/**
|
|
341
|
+
* Command to execute. A string is interpreted according to the shell preference;
|
|
342
|
+
* an array is treated as argv for shell‑off execution.
|
|
343
|
+
*/
|
|
344
|
+
command?: string | string[];
|
|
345
|
+
/**
|
|
346
|
+
* Merged root CLI options bag (JSON‑serializable) forwarded for nested composition
|
|
347
|
+
* by downstream executors. Used to compute child overlays deterministically.
|
|
348
|
+
*/
|
|
349
|
+
getDotenvCliOptions?: Record<string, unknown>;
|
|
350
|
+
/**
|
|
351
|
+
* Composed dotenv environment (string | undefined values) to inject into each child.
|
|
352
|
+
*/
|
|
353
|
+
dotenvEnv?: Record<string, string | undefined>;
|
|
354
|
+
/**
|
|
355
|
+
* Space‑delimited patterns used to discover target working directories.
|
|
356
|
+
*/
|
|
357
|
+
globs: string;
|
|
358
|
+
/**
|
|
359
|
+
* When true, continue processing remaining paths after a command error.
|
|
360
|
+
*/
|
|
361
|
+
ignoreErrors?: boolean;
|
|
362
|
+
/**
|
|
363
|
+
* When true, list matched directories without executing a command.
|
|
364
|
+
*/
|
|
365
|
+
list?: boolean;
|
|
366
|
+
/**
|
|
367
|
+
* Logger used for headings, listings, and diagnostics.
|
|
368
|
+
*/
|
|
369
|
+
logger: Logger;
|
|
370
|
+
/**
|
|
371
|
+
* Resolve the batch root from the nearest package directory instead of CWD.
|
|
372
|
+
*/
|
|
373
|
+
pkgCwd?: boolean;
|
|
374
|
+
/**
|
|
375
|
+
* Root path (relative to CWD or package directory) for resolving globs.
|
|
376
|
+
*/
|
|
377
|
+
rootPath: string;
|
|
378
|
+
/**
|
|
379
|
+
* Shell to use when executing the command. A string selects a specific shell,
|
|
380
|
+
* `false` disables the shell (plain execution), and `URL` mirrors executor options.
|
|
381
|
+
*/
|
|
382
|
+
shell: string | boolean | URL;
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Flags parsed at the batch parent command level (shared between invoker paths).
|
|
386
|
+
*
|
|
387
|
+
* @public
|
|
388
|
+
*/
|
|
389
|
+
interface BatchParentInvokerFlags {
|
|
390
|
+
/** Command to execute. */
|
|
391
|
+
command?: string;
|
|
392
|
+
/** Space-delimited glob patterns. */
|
|
393
|
+
globs?: string;
|
|
394
|
+
/** List directories without executing. */
|
|
395
|
+
list?: boolean;
|
|
396
|
+
/** Ignore errors and continue. */
|
|
397
|
+
ignoreErrors?: boolean;
|
|
398
|
+
/** Use package directory as root. */
|
|
399
|
+
pkgCwd?: boolean;
|
|
400
|
+
/** Root path for discovery. */
|
|
401
|
+
rootPath?: string;
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Options parsed for the batch "cmd" subcommand.
|
|
405
|
+
* Currently empty; reserved for future extension.
|
|
406
|
+
*
|
|
407
|
+
* @public
|
|
408
|
+
*/
|
|
409
|
+
interface BatchCmdSubcommandOptions {
|
|
410
|
+
}
|
|
214
411
|
|
|
215
412
|
/**
|
|
216
413
|
* Batch plugin for the GetDotenv CLI host.
|
|
@@ -218,7 +415,6 @@ type BatchPluginOptions = {
|
|
|
218
415
|
* Mirrors the legacy batch subcommand behavior without altering the shipped CLI.
|
|
219
416
|
* Options:
|
|
220
417
|
* - scripts/shell: used to resolve command and shell behavior per script or global default.
|
|
221
|
-
* - logger: defaults to console.
|
|
222
418
|
*/
|
|
223
419
|
declare const batchPlugin: (opts?: BatchPluginOptions) => PluginWithInstanceHelpers<GetDotenvOptions, {
|
|
224
420
|
scripts?: Record<string, string | {
|
|
@@ -229,6 +425,7 @@ declare const batchPlugin: (opts?: BatchPluginOptions) => PluginWithInstanceHelp
|
|
|
229
425
|
rootPath?: string | undefined;
|
|
230
426
|
globs?: string | undefined;
|
|
231
427
|
pkgCwd?: boolean | undefined;
|
|
232
|
-
}>;
|
|
428
|
+
}, [], {}, {}>;
|
|
233
429
|
|
|
234
430
|
export { batchPlugin };
|
|
431
|
+
export type { BatchCmdSubcommandOptions, BatchGlobPathsOptions, BatchParentInvokerFlags, ExecShellCommandBatchOptions };
|