@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-batch.d.ts
CHANGED
|
@@ -1,172 +1,413 @@
|
|
|
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
|
-
|
|
131
|
+
type GetDotenvOptions = z.output<typeof getDotenvOptionsSchemaResolved> & {
|
|
19
132
|
/**
|
|
20
|
-
*
|
|
133
|
+
* Compile-time overlay: narrowed logger for DX (schema stores unknown).
|
|
21
134
|
*/
|
|
22
|
-
|
|
135
|
+
logger: Logger;
|
|
23
136
|
/**
|
|
24
|
-
*
|
|
137
|
+
* Compile-time overlay: narrowed dynamic map for DX (schema stores unknown).
|
|
25
138
|
*/
|
|
26
|
-
|
|
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> & {
|
|
27
153
|
/**
|
|
28
|
-
*
|
|
154
|
+
* Compile-only overlay for DX: logger narrowed from unknown.
|
|
29
155
|
*/
|
|
30
|
-
|
|
156
|
+
logger: Logger;
|
|
31
157
|
/**
|
|
32
|
-
*
|
|
33
|
-
* over {@link GetDotenvOptions.dynamicPath}.
|
|
158
|
+
* Compile-only overlay for DX: scripts narrowed from Record\<string, unknown\>.
|
|
34
159
|
*/
|
|
35
|
-
|
|
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> & {
|
|
36
170
|
/**
|
|
37
|
-
*
|
|
171
|
+
* Per‑plugin configuration slices keyed by realized mount path
|
|
172
|
+
* (e.g., `"aws"` or `"aws/whoami"`), used for dynamic help text.
|
|
38
173
|
*/
|
|
39
|
-
|
|
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 {
|
|
40
189
|
/**
|
|
41
|
-
*
|
|
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
|
|
42
195
|
*/
|
|
43
|
-
|
|
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> {
|
|
44
207
|
/**
|
|
45
|
-
*
|
|
208
|
+
* Create a namespaced child command with argument inference.
|
|
209
|
+
* Mirrors Commander generics so downstream chaining remains fully typed.
|
|
46
210
|
*/
|
|
47
|
-
|
|
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;
|
|
48
221
|
/**
|
|
49
|
-
*
|
|
222
|
+
* Create a dynamic option whose description is computed at help time
|
|
223
|
+
* from the resolved configuration.
|
|
50
224
|
*/
|
|
51
|
-
|
|
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 {
|
|
52
234
|
/**
|
|
53
|
-
*
|
|
235
|
+
* Override the default namespace for this plugin instance.
|
|
54
236
|
*/
|
|
55
|
-
|
|
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>;
|
|
56
247
|
/**
|
|
57
|
-
*
|
|
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`.
|
|
58
250
|
*/
|
|
59
|
-
|
|
251
|
+
override: PluginNamespaceOverride | undefined;
|
|
252
|
+
}
|
|
253
|
+
/** Public plugin contract used by the GetDotenv CLI host. */
|
|
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;
|
|
257
|
+
/**
|
|
258
|
+
* Setup phase: register commands and wiring on the provided mount.
|
|
259
|
+
* Runs parent → children (pre-order). Return nothing (void).
|
|
260
|
+
*/
|
|
261
|
+
setup: (cli: GetDotenvCliPublic<TOptions, TArgs, TOpts, TGlobal>) => void | Promise<void>;
|
|
262
|
+
/**
|
|
263
|
+
* After the dotenv context is resolved, initialize any clients/secrets
|
|
264
|
+
* or attach per-plugin state under ctx.plugins (by convention).
|
|
265
|
+
* Runs parent → children (pre-order).
|
|
266
|
+
*/
|
|
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;
|
|
60
270
|
/**
|
|
61
|
-
*
|
|
271
|
+
* Compositional children, with optional per-child overrides (e.g., ns).
|
|
272
|
+
* Installed after the parent per pre-order.
|
|
62
273
|
*/
|
|
63
|
-
|
|
274
|
+
children: Array<PluginChildEntry<TOptions, TArgs, TOpts, TGlobal>>;
|
|
64
275
|
/**
|
|
65
|
-
*
|
|
276
|
+
* Compose a child plugin with optional override (ns). Returns the parent
|
|
277
|
+
* to enable chaining.
|
|
66
278
|
*/
|
|
67
|
-
|
|
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>;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Options provided to the batch plugin factory.
|
|
294
|
+
*
|
|
295
|
+
* @public
|
|
296
|
+
*/
|
|
297
|
+
interface BatchPluginOptions {
|
|
68
298
|
/**
|
|
69
|
-
*
|
|
299
|
+
* Scripts table used to resolve command names and optional per-script shell overrides.
|
|
70
300
|
*/
|
|
71
|
-
|
|
301
|
+
scripts?: ScriptsTable;
|
|
72
302
|
/**
|
|
73
|
-
*
|
|
303
|
+
* Global shell preference for batch execution; overridden by per-script shell when present.
|
|
74
304
|
*/
|
|
75
|
-
|
|
305
|
+
shell?: string | boolean;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Options for discovering batch working directories from a root path and globs.
|
|
309
|
+
*
|
|
310
|
+
* @public
|
|
311
|
+
*/
|
|
312
|
+
interface BatchGlobPathsOptions {
|
|
76
313
|
/**
|
|
77
|
-
*
|
|
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).
|
|
78
317
|
*/
|
|
79
|
-
|
|
318
|
+
globs: string;
|
|
80
319
|
/**
|
|
81
|
-
*
|
|
320
|
+
* Logger used for user-facing messages (errors, headings, and listings).
|
|
82
321
|
*/
|
|
83
|
-
|
|
322
|
+
logger: Logger;
|
|
84
323
|
/**
|
|
85
|
-
*
|
|
324
|
+
* When true, resolve the batch root from the nearest package directory
|
|
325
|
+
* instead of the current working directory.
|
|
86
326
|
*/
|
|
87
|
-
|
|
327
|
+
pkgCwd?: boolean;
|
|
88
328
|
/**
|
|
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.
|
|
329
|
+
* Path to the batch root directory, resolved from the current working directory
|
|
330
|
+
* (or package directory when {@link BatchGlobPathsOptions.pkgCwd} is true).
|
|
94
331
|
*/
|
|
95
|
-
|
|
332
|
+
rootPath: string;
|
|
96
333
|
}
|
|
97
|
-
|
|
98
|
-
/** src/cliHost/definePlugin.ts
|
|
99
|
-
* Plugin contracts for the GetDotenv CLI host.
|
|
100
|
-
*
|
|
101
|
-
* This module exposes a structural public interface for the host that plugins
|
|
102
|
-
* should use (GetDotenvCliPublic). Using a structural type at the seam avoids
|
|
103
|
-
* nominal class identity issues (private fields) in downstream consumers.
|
|
104
|
-
*/
|
|
105
|
-
|
|
106
334
|
/**
|
|
107
|
-
*
|
|
108
|
-
* - Extends Commander.Command so plugins can attach options/commands/hooks.
|
|
109
|
-
* - Adds host-specific helpers used by built-in plugins.
|
|
335
|
+
* Arguments for {@link execShellCommandBatch} — batch execution over discovered working directories.
|
|
110
336
|
*
|
|
111
|
-
*
|
|
112
|
-
* to avoid TS2379 under exactOptionalPropertyTypes in downstream consumers.
|
|
337
|
+
* @public
|
|
113
338
|
*/
|
|
114
|
-
|
|
115
|
-
ns: (name: string) => Command;
|
|
116
|
-
getCtx: () => GetDotenvCliCtx<TOptions> | undefined;
|
|
117
|
-
resolveAndLoad: (customOptions?: Partial<TOptions>) => Promise<GetDotenvCliCtx<TOptions>>;
|
|
118
|
-
};
|
|
119
|
-
/** Public plugin contract used by the GetDotenv CLI host. */
|
|
120
|
-
interface GetDotenvCliPlugin {
|
|
121
|
-
id?: string;
|
|
339
|
+
interface ExecShellCommandBatchOptions {
|
|
122
340
|
/**
|
|
123
|
-
*
|
|
124
|
-
*
|
|
341
|
+
* Command to execute. A string is interpreted according to the shell preference;
|
|
342
|
+
* an array is treated as argv for shell‑off execution.
|
|
125
343
|
*/
|
|
126
|
-
|
|
344
|
+
command?: string | string[];
|
|
127
345
|
/**
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
|
|
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.
|
|
131
360
|
*/
|
|
132
|
-
|
|
361
|
+
ignoreErrors?: boolean;
|
|
133
362
|
/**
|
|
134
|
-
*
|
|
135
|
-
* When provided, the host validates the merged config under the guarded loader path.
|
|
363
|
+
* When true, list matched directories without executing a command.
|
|
136
364
|
*/
|
|
137
|
-
|
|
365
|
+
list?: boolean;
|
|
138
366
|
/**
|
|
139
|
-
*
|
|
367
|
+
* Logger used for headings, listings, and diagnostics.
|
|
140
368
|
*/
|
|
141
|
-
|
|
369
|
+
logger: Logger;
|
|
142
370
|
/**
|
|
143
|
-
*
|
|
371
|
+
* Resolve the batch root from the nearest package directory instead of CWD.
|
|
144
372
|
*/
|
|
145
|
-
|
|
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;
|
|
146
383
|
}
|
|
147
|
-
|
|
148
|
-
/** * Per-invocation context shared with plugins and actions. */
|
|
149
|
-
type GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> = {
|
|
150
|
-
optionsResolved: TOptions;
|
|
151
|
-
dotenv: ProcessEnv;
|
|
152
|
-
plugins?: Record<string, unknown>;
|
|
153
|
-
pluginConfigs?: Record<string, unknown>;
|
|
154
|
-
};
|
|
155
|
-
|
|
156
384
|
/**
|
|
157
|
-
*
|
|
158
|
-
*
|
|
385
|
+
* Flags parsed at the batch parent command level (shared between invoker paths).
|
|
386
|
+
*
|
|
387
|
+
* @public
|
|
159
388
|
*/
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
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
|
+
}
|
|
170
411
|
|
|
171
412
|
/**
|
|
172
413
|
* Batch plugin for the GetDotenv CLI host.
|
|
@@ -174,8 +415,17 @@ type BatchPluginOptions = {
|
|
|
174
415
|
* Mirrors the legacy batch subcommand behavior without altering the shipped CLI.
|
|
175
416
|
* Options:
|
|
176
417
|
* - scripts/shell: used to resolve command and shell behavior per script or global default.
|
|
177
|
-
* - logger: defaults to console.
|
|
178
418
|
*/
|
|
179
|
-
declare const batchPlugin: (opts?: BatchPluginOptions) =>
|
|
419
|
+
declare const batchPlugin: (opts?: BatchPluginOptions) => PluginWithInstanceHelpers<GetDotenvOptions, {
|
|
420
|
+
scripts?: Record<string, string | {
|
|
421
|
+
cmd: string;
|
|
422
|
+
shell?: string | boolean | undefined;
|
|
423
|
+
}> | undefined;
|
|
424
|
+
shell?: string | boolean | undefined;
|
|
425
|
+
rootPath?: string | undefined;
|
|
426
|
+
globs?: string | undefined;
|
|
427
|
+
pkgCwd?: boolean | undefined;
|
|
428
|
+
}, [], {}, {}>;
|
|
180
429
|
|
|
181
430
|
export { batchPlugin };
|
|
431
|
+
export type { BatchCmdSubcommandOptions, BatchGlobPathsOptions, BatchParentInvokerFlags, ExecShellCommandBatchOptions };
|