@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-init.d.ts
CHANGED
|
@@ -1,162 +1,334 @@
|
|
|
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;
|
|
131
|
+
type GetDotenvOptions = z.output<typeof getDotenvOptionsSchemaResolved> & {
|
|
23
132
|
/**
|
|
24
|
-
*
|
|
133
|
+
* Compile-time overlay: narrowed logger for DX (schema stores unknown).
|
|
25
134
|
*/
|
|
26
|
-
|
|
135
|
+
logger: Logger;
|
|
27
136
|
/**
|
|
28
|
-
*
|
|
29
|
-
*/
|
|
30
|
-
dynamicPath?: string;
|
|
31
|
-
/**
|
|
32
|
-
* Programmatic dynamic variables map. When provided, this takes precedence
|
|
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
|
|
154
|
+
* Compile-only overlay for DX: logger narrowed from unknown.
|
|
46
155
|
*/
|
|
47
|
-
|
|
156
|
+
logger: Logger;
|
|
48
157
|
/**
|
|
49
|
-
*
|
|
158
|
+
* Compile-only overlay for DX: scripts narrowed from Record\<string, unknown\>.
|
|
50
159
|
*/
|
|
51
|
-
|
|
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> & {
|
|
52
170
|
/**
|
|
53
|
-
*
|
|
171
|
+
* Per‑plugin configuration slices keyed by realized mount path
|
|
172
|
+
* (e.g., `"aws"` or `"aws/whoami"`), used for dynamic help text.
|
|
54
173
|
*/
|
|
55
|
-
|
|
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 {
|
|
56
189
|
/**
|
|
57
|
-
*
|
|
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
|
|
58
195
|
*/
|
|
59
|
-
|
|
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> {
|
|
60
207
|
/**
|
|
61
|
-
*
|
|
208
|
+
* Create a namespaced child command with argument inference.
|
|
209
|
+
* Mirrors Commander generics so downstream chaining remains fully typed.
|
|
62
210
|
*/
|
|
63
|
-
|
|
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;
|
|
64
221
|
/**
|
|
65
|
-
*
|
|
222
|
+
* Create a dynamic option whose description is computed at help time
|
|
223
|
+
* from the resolved configuration.
|
|
66
224
|
*/
|
|
67
|
-
|
|
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 {
|
|
68
234
|
/**
|
|
69
|
-
*
|
|
235
|
+
* Override the default namespace for this plugin instance.
|
|
70
236
|
*/
|
|
71
|
-
|
|
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>;
|
|
72
247
|
/**
|
|
73
|
-
*
|
|
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`.
|
|
74
250
|
*/
|
|
75
|
-
|
|
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;
|
|
76
257
|
/**
|
|
77
|
-
*
|
|
258
|
+
* Setup phase: register commands and wiring on the provided mount.
|
|
259
|
+
* Runs parent → children (pre-order). Return nothing (void).
|
|
78
260
|
*/
|
|
79
|
-
|
|
261
|
+
setup: (cli: GetDotenvCliPublic<TOptions, TArgs, TOpts, TGlobal>) => void | Promise<void>;
|
|
80
262
|
/**
|
|
81
|
-
*
|
|
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).
|
|
82
266
|
*/
|
|
83
|
-
|
|
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;
|
|
84
270
|
/**
|
|
85
|
-
*
|
|
271
|
+
* Compositional children, with optional per-child overrides (e.g., ns).
|
|
272
|
+
* Installed after the parent per pre-order.
|
|
86
273
|
*/
|
|
87
|
-
|
|
274
|
+
children: Array<PluginChildEntry<TOptions, TArgs, TOpts, TGlobal>>;
|
|
88
275
|
/**
|
|
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.
|
|
276
|
+
* Compose a child plugin with optional override (ns). Returns the parent
|
|
277
|
+
* to enable chaining.
|
|
94
278
|
*/
|
|
95
|
-
|
|
279
|
+
use: (child: GetDotenvCliPlugin<TOptions, TArgs, TOpts, TGlobal>, override?: PluginNamespaceOverride) => GetDotenvCliPlugin<TOptions, TArgs, TOpts, TGlobal>;
|
|
96
280
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
* should use (GetDotenvCliPublic). Using a structural type at the seam avoids
|
|
103
|
-
* nominal class identity issues (private fields) in downstream consumers.
|
|
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.
|
|
104
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
|
+
}
|
|
105
291
|
|
|
106
292
|
/**
|
|
107
|
-
*
|
|
108
|
-
* - Extends Commander.Command so plugins can attach options/commands/hooks.
|
|
109
|
-
* - Adds host-specific helpers used by built-in plugins.
|
|
293
|
+
* Options for planning config template copies.
|
|
110
294
|
*
|
|
111
|
-
*
|
|
112
|
-
* to avoid TS2379 under exactOptionalPropertyTypes in downstream consumers.
|
|
295
|
+
* @public
|
|
113
296
|
*/
|
|
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;
|
|
297
|
+
interface PlanConfigCopiesOptions {
|
|
122
298
|
/**
|
|
123
|
-
*
|
|
124
|
-
* Runs parent → children (pre-order).
|
|
299
|
+
* Desired config format to scaffold.
|
|
125
300
|
*/
|
|
126
|
-
|
|
301
|
+
format: 'json' | 'yaml' | 'js' | 'ts';
|
|
127
302
|
/**
|
|
128
|
-
*
|
|
129
|
-
* or attach per-plugin state under ctx.plugins (by convention).
|
|
130
|
-
* Runs parent → children (pre-order).
|
|
303
|
+
* Whether to include a private .local variant (JSON/YAML only).
|
|
131
304
|
*/
|
|
132
|
-
|
|
305
|
+
withLocal: boolean;
|
|
133
306
|
/**
|
|
134
|
-
*
|
|
135
|
-
* When provided, the host validates the merged config under the guarded loader path.
|
|
307
|
+
* Absolute destination project root.
|
|
136
308
|
*/
|
|
137
|
-
|
|
309
|
+
destRoot: string;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Options for planning CLI skeleton template copies.
|
|
313
|
+
*
|
|
314
|
+
* @public
|
|
315
|
+
*/
|
|
316
|
+
interface PlanCliCopiesOptions {
|
|
138
317
|
/**
|
|
139
|
-
*
|
|
318
|
+
* CLI command name to substitute into templates.
|
|
140
319
|
*/
|
|
141
|
-
|
|
320
|
+
cliName: string;
|
|
142
321
|
/**
|
|
143
|
-
*
|
|
322
|
+
* Absolute destination project root.
|
|
144
323
|
*/
|
|
145
|
-
|
|
324
|
+
destRoot: string;
|
|
146
325
|
}
|
|
147
326
|
|
|
148
|
-
/**
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
pluginConfigs?: Record<string, unknown>;
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
type InitPluginOptions = {
|
|
157
|
-
logger?: Logger;
|
|
158
|
-
};
|
|
159
|
-
declare const initPlugin: (opts?: InitPluginOptions) => GetDotenvCliPlugin;
|
|
327
|
+
/**
|
|
328
|
+
* Init plugin: scaffolds configuration files and a CLI skeleton for get-dotenv.
|
|
329
|
+
* Supports collision detection, interactive prompts, and CI bypass.
|
|
330
|
+
*/
|
|
331
|
+
declare const initPlugin: () => PluginWithInstanceHelpers<GetDotenvOptions, {}, [], {}, {}>;
|
|
160
332
|
|
|
161
333
|
export { initPlugin };
|
|
162
|
-
export type {
|
|
334
|
+
export type { PlanCliCopiesOptions, PlanConfigCopiesOptions };
|