@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-init.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
|
+
}
|
|
11
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
|
+
*/
|
|
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,51 +132,16 @@ 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
|
-
dynamicPath: z.ZodOptional<z.ZodString>;
|
|
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
|
-
|
|
142
|
+
/**
|
|
143
|
+
* Unify Scripts via the generic ScriptsTable<TShell> so shell types propagate.
|
|
144
|
+
*/
|
|
98
145
|
type Scripts = ScriptsTable;
|
|
99
146
|
/**
|
|
100
147
|
* Canonical CLI options type derived from the Zod schema output.
|
|
@@ -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
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,17 +284,51 @@ 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
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
292
|
+
/**
|
|
293
|
+
* Options for planning config template copies.
|
|
294
|
+
*
|
|
295
|
+
* @public
|
|
296
|
+
*/
|
|
297
|
+
interface PlanConfigCopiesOptions {
|
|
298
|
+
/**
|
|
299
|
+
* Desired config format to scaffold.
|
|
300
|
+
*/
|
|
301
|
+
format: 'json' | 'yaml' | 'js' | 'ts';
|
|
302
|
+
/**
|
|
303
|
+
* Whether to include a private .local variant (JSON/YAML only).
|
|
304
|
+
*/
|
|
305
|
+
withLocal: boolean;
|
|
306
|
+
/**
|
|
307
|
+
* Absolute destination project root.
|
|
308
|
+
*/
|
|
309
|
+
destRoot: string;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Options for planning CLI skeleton template copies.
|
|
313
|
+
*
|
|
314
|
+
* @public
|
|
315
|
+
*/
|
|
316
|
+
interface PlanCliCopiesOptions {
|
|
317
|
+
/**
|
|
318
|
+
* CLI command name to substitute into templates.
|
|
319
|
+
*/
|
|
320
|
+
cliName: string;
|
|
321
|
+
/**
|
|
322
|
+
* Absolute destination project root.
|
|
323
|
+
*/
|
|
324
|
+
destRoot: string;
|
|
325
|
+
}
|
|
326
|
+
|
|
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, {}, [], {}, {}>;
|
|
206
332
|
|
|
207
333
|
export { initPlugin };
|
|
208
|
-
export type {
|
|
334
|
+
export type { PlanCliCopiesOptions, PlanConfigCopiesOptions };
|