@karmaniverous/get-dotenv 5.2.3 → 5.2.5
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 +5 -5
- package/dist/cliHost.cjs +422 -21
- package/dist/cliHost.d.cts +95 -8
- package/dist/cliHost.d.mts +95 -8
- package/dist/cliHost.d.ts +95 -8
- package/dist/cliHost.mjs +423 -22
- package/dist/getdotenv.cli.mjs +10 -6
- package/dist/index.cjs +11 -6
- package/dist/index.d.cts +19 -1
- package/dist/index.d.mts +19 -1
- package/dist/index.d.ts +19 -1
- package/dist/index.mjs +11 -7
- package/dist/plugins-aws.cjs +7 -0
- package/dist/plugins-aws.d.cts +99 -162
- package/dist/plugins-aws.d.mts +99 -162
- package/dist/plugins-aws.d.ts +99 -162
- package/dist/plugins-aws.mjs +7 -0
- package/dist/plugins-batch.cjs +7 -0
- package/dist/plugins-batch.d.cts +99 -162
- package/dist/plugins-batch.d.mts +99 -162
- package/dist/plugins-batch.d.ts +99 -162
- package/dist/plugins-batch.mjs +7 -0
- package/dist/plugins-cmd.cjs +9 -5
- package/dist/plugins-cmd.d.cts +99 -162
- package/dist/plugins-cmd.d.mts +99 -162
- package/dist/plugins-cmd.d.ts +99 -162
- package/dist/plugins-cmd.mjs +9 -5
- package/dist/plugins-demo.cjs +7 -0
- package/dist/plugins-demo.d.cts +99 -162
- package/dist/plugins-demo.d.mts +99 -162
- package/dist/plugins-demo.d.ts +99 -162
- package/dist/plugins-demo.mjs +7 -0
- package/dist/plugins-init.cjs +7 -0
- package/dist/plugins-init.d.cts +99 -162
- package/dist/plugins-init.d.mts +99 -162
- package/dist/plugins-init.d.ts +99 -162
- package/dist/plugins-init.mjs +7 -0
- package/dist/plugins.cjs +9 -5
- package/dist/plugins.d.cts +99 -162
- package/dist/plugins.d.mts +99 -162
- package/dist/plugins.d.ts +99 -162
- package/dist/plugins.mjs +9 -5
- package/package.json +1 -1
package/dist/plugins-aws.d.ts
CHANGED
|
@@ -1,5 +1,75 @@
|
|
|
1
|
-
import { ZodType } from 'zod';
|
|
2
1
|
import { Command } from 'commander';
|
|
2
|
+
import { ZodType } from 'zod';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Minimal root options shape shared by CLI and generator layers.
|
|
6
|
+
* Keep keys optional to respect exactOptionalPropertyTypes semantics.
|
|
7
|
+
*/
|
|
8
|
+
type RootOptionsShape = {
|
|
9
|
+
env?: string;
|
|
10
|
+
vars?: string;
|
|
11
|
+
command?: string;
|
|
12
|
+
outputPath?: string;
|
|
13
|
+
shell?: string | boolean;
|
|
14
|
+
loadProcess?: boolean;
|
|
15
|
+
excludeAll?: boolean;
|
|
16
|
+
excludeDynamic?: boolean;
|
|
17
|
+
excludeEnv?: boolean;
|
|
18
|
+
excludeGlobal?: boolean;
|
|
19
|
+
excludePrivate?: boolean;
|
|
20
|
+
excludePublic?: boolean;
|
|
21
|
+
log?: boolean;
|
|
22
|
+
debug?: boolean;
|
|
23
|
+
capture?: boolean;
|
|
24
|
+
strict?: boolean;
|
|
25
|
+
redact?: boolean;
|
|
26
|
+
warnEntropy?: boolean;
|
|
27
|
+
entropyThreshold?: number;
|
|
28
|
+
entropyMinLength?: number;
|
|
29
|
+
entropyWhitelist?: string[];
|
|
30
|
+
redactPatterns?: string[];
|
|
31
|
+
defaultEnv?: string;
|
|
32
|
+
dotenvToken?: string;
|
|
33
|
+
dynamicPath?: string;
|
|
34
|
+
trace?: boolean | string[];
|
|
35
|
+
paths?: string;
|
|
36
|
+
pathsDelimiter?: string;
|
|
37
|
+
pathsDelimiterPattern?: string;
|
|
38
|
+
privateToken?: string;
|
|
39
|
+
varsDelimiter?: string;
|
|
40
|
+
varsDelimiterPattern?: string;
|
|
41
|
+
varsAssignor?: string;
|
|
42
|
+
varsAssignorPattern?: string;
|
|
43
|
+
scripts?: ScriptsTable;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Scripts table shape (configurable shell type).
|
|
47
|
+
*/
|
|
48
|
+
type ScriptsTable<TShell extends string | boolean = string | boolean> = Record<string, string | {
|
|
49
|
+
cmd: string;
|
|
50
|
+
shell?: TShell;
|
|
51
|
+
}>;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Adapter-layer augmentation: add chainable helpers to GetDotenvCli without
|
|
55
|
+
* coupling the core host to cliCore. Importing this module has side effects:
|
|
56
|
+
* it extends the prototype and merges types for consumers.
|
|
57
|
+
*/
|
|
58
|
+
declare module '../cliHost/GetDotenvCli' {
|
|
59
|
+
interface GetDotenvCli {
|
|
60
|
+
/**
|
|
61
|
+
* Attach legacy root flags to this CLI instance. Defaults come from
|
|
62
|
+
* baseRootOptionDefaults when none are provided. */
|
|
63
|
+
attachRootOptions(defaults?: Partial<RootOptionsShape>, opts?: {
|
|
64
|
+
includeCommandOption?: boolean;
|
|
65
|
+
}): this;
|
|
66
|
+
/**
|
|
67
|
+
* Install a preSubcommand hook that merges CLI flags (including parent
|
|
68
|
+
* round-trip) and resolves the dotenv context before executing actions.
|
|
69
|
+
* Defaults come from baseRootOptionDefaults when none are provided.
|
|
70
|
+
*/ passOptions(defaults?: Partial<RootOptionsShape>): this;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
3
73
|
|
|
4
74
|
/**
|
|
5
75
|
* A minimal representation of an environment key/value mapping.
|
|
@@ -95,93 +165,6 @@ interface GetDotenvOptions {
|
|
|
95
165
|
useConfigLoader?: boolean;
|
|
96
166
|
}
|
|
97
167
|
|
|
98
|
-
type Scripts = Record<string, string | {
|
|
99
|
-
cmd: string;
|
|
100
|
-
shell?: string | boolean;
|
|
101
|
-
}>;
|
|
102
|
-
/**
|
|
103
|
-
* Options passed programmatically to `getDotenvCli`.
|
|
104
|
-
*/
|
|
105
|
-
interface GetDotenvCliOptions extends Omit<GetDotenvOptions, 'paths' | 'vars'> {
|
|
106
|
-
/**
|
|
107
|
-
* Logs CLI internals when true.
|
|
108
|
-
*/
|
|
109
|
-
debug?: boolean;
|
|
110
|
-
/**
|
|
111
|
-
* Strict mode: fail the run when env validation issues are detected
|
|
112
|
-
* (schema or requiredKeys). Warns by default when false or unset.
|
|
113
|
-
*/
|
|
114
|
-
strict?: boolean;
|
|
115
|
-
/**
|
|
116
|
-
* Redaction (presentation): mask secret-like values in logs/trace.
|
|
117
|
-
*/
|
|
118
|
-
redact?: boolean;
|
|
119
|
-
/**
|
|
120
|
-
* Entropy warnings (presentation): emit once-per-key warnings for high-entropy values.
|
|
121
|
-
*/
|
|
122
|
-
warnEntropy?: boolean;
|
|
123
|
-
entropyThreshold?: number;
|
|
124
|
-
entropyMinLength?: number;
|
|
125
|
-
entropyWhitelist?: string[];
|
|
126
|
-
redactPatterns?: string[];
|
|
127
|
-
/**
|
|
128
|
-
* When true, capture child stdout/stderr and re-emit after completion.
|
|
129
|
-
* Useful for tests/CI. Default behavior is streaming via stdio: 'inherit'.
|
|
130
|
-
*/
|
|
131
|
-
capture?: boolean;
|
|
132
|
-
/**
|
|
133
|
-
* A delimited string of paths to dotenv files.
|
|
134
|
-
*/
|
|
135
|
-
paths?: string;
|
|
136
|
-
/**
|
|
137
|
-
* A delimiter string with which to split `paths`. Only used if
|
|
138
|
-
* `pathsDelimiterPattern` is not provided.
|
|
139
|
-
*/
|
|
140
|
-
pathsDelimiter?: string;
|
|
141
|
-
/**
|
|
142
|
-
* A regular expression pattern with which to split `paths`. Supersedes
|
|
143
|
-
* `pathsDelimiter`.
|
|
144
|
-
*/
|
|
145
|
-
pathsDelimiterPattern?: string;
|
|
146
|
-
/**
|
|
147
|
-
* Scripts that can be executed from the CLI, either individually or via the batch subcommand.
|
|
148
|
-
*/
|
|
149
|
-
scripts?: Scripts;
|
|
150
|
-
/**
|
|
151
|
-
* Determines how commands and scripts are executed. If `false` or
|
|
152
|
-
* `undefined`, commands are executed as plain Javascript using the default
|
|
153
|
-
* execa parser. If `true`, commands are executed using the default OS shell
|
|
154
|
-
* parser. Otherwise the user may provide a specific shell string (e.g.
|
|
155
|
-
* `/bin/bash`)
|
|
156
|
-
*/
|
|
157
|
-
shell?: string | boolean;
|
|
158
|
-
/**
|
|
159
|
-
* A delimited string of key-value pairs declaratively specifying variables &
|
|
160
|
-
* values to be loaded in addition to any dotenv files.
|
|
161
|
-
*/
|
|
162
|
-
vars?: string;
|
|
163
|
-
/**
|
|
164
|
-
* A string with which to split keys from values in `vars`. Only used if
|
|
165
|
-
* `varsDelimiterPattern` is not provided.
|
|
166
|
-
*/
|
|
167
|
-
varsAssignor?: string;
|
|
168
|
-
/**
|
|
169
|
-
* A regular expression pattern with which to split variable names from values
|
|
170
|
-
* in `vars`. Supersedes `varsAssignor`.
|
|
171
|
-
*/
|
|
172
|
-
varsAssignorPattern?: string;
|
|
173
|
-
/**
|
|
174
|
-
* A string with which to split `vars` into key-value pairs. Only used if
|
|
175
|
-
* `varsDelimiterPattern` is not provided.
|
|
176
|
-
*/
|
|
177
|
-
varsDelimiter?: string;
|
|
178
|
-
/**
|
|
179
|
-
* A regular expression pattern with which to split `vars` into key-value
|
|
180
|
-
* pairs. Supersedes `varsDelimiter`.
|
|
181
|
-
*/
|
|
182
|
-
varsDelimiterPattern?: string;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
168
|
/** * Per-invocation context shared with plugins and actions. */
|
|
186
169
|
type GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> = {
|
|
187
170
|
optionsResolved: TOptions;
|
|
@@ -189,89 +172,42 @@ type GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> = {
|
|
|
189
172
|
plugins?: Record<string, unknown>;
|
|
190
173
|
pluginConfigs?: Record<string, unknown>;
|
|
191
174
|
};
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* Plugin
|
|
175
|
+
|
|
176
|
+
/** src/cliHost/definePlugin.ts
|
|
177
|
+
* Plugin contracts for the GetDotenv CLI host.
|
|
195
178
|
*
|
|
196
|
-
*
|
|
197
|
-
*
|
|
198
|
-
*
|
|
199
|
-
|
|
200
|
-
|
|
179
|
+
* This module exposes a structural public interface for the host that plugins
|
|
180
|
+
* should use (GetDotenvCliPublic). Using a structural type at the seam avoids
|
|
181
|
+
* nominal class identity issues (private fields) in downstream consumers.
|
|
182
|
+
*/
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Structural public interface for the host exposed to plugins.
|
|
186
|
+
* - Extends Commander.Command so plugins can attach options/commands/hooks.
|
|
187
|
+
* - Adds host-specific helpers used by built-in plugins.
|
|
201
188
|
*
|
|
202
|
-
*
|
|
189
|
+
* Purpose: remove nominal class identity (private fields) from the plugin seam
|
|
190
|
+
* to avoid TS2379 under exactOptionalPropertyTypes in downstream consumers.
|
|
203
191
|
*/
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
constructor(alias?: string);
|
|
213
|
-
/**
|
|
214
|
-
* Resolve options (strict) and compute dotenv context. * Stores the context on the instance under a symbol.
|
|
215
|
-
*/
|
|
216
|
-
resolveAndLoad(customOptions?: Partial<TOptions>): Promise<GetDotenvCliCtx<TOptions>>;
|
|
217
|
-
/**
|
|
218
|
-
* Retrieve the current invocation context (if any).
|
|
219
|
-
*/
|
|
220
|
-
getCtx(): GetDotenvCliCtx<TOptions> | undefined;
|
|
221
|
-
/**
|
|
222
|
-
* Retrieve the merged root CLI options bag (if set by passOptions()).
|
|
223
|
-
* Downstream-safe: no generics required.
|
|
224
|
-
*/
|
|
225
|
-
getOptions(): GetDotenvCliOptions | undefined;
|
|
226
|
-
/** Internal: set the merged root options bag for this run. */
|
|
227
|
-
_setOptionsBag(bag: GetDotenvCliOptions): void;
|
|
228
|
-
/** * Convenience helper to create a namespaced subcommand.
|
|
229
|
-
*/
|
|
230
|
-
ns(name: string): Command;
|
|
231
|
-
/**
|
|
232
|
-
* Tag options added during the provided callback as 'app' for grouped help.
|
|
233
|
-
* Allows downstream apps to demarcate their root-level options.
|
|
234
|
-
*/
|
|
235
|
-
tagAppOptions<T>(fn: (root: Command) => T): T;
|
|
236
|
-
/**
|
|
237
|
-
* Branding helper: set CLI name/description/version and optional help header.
|
|
238
|
-
* If version is omitted and importMetaUrl is provided, attempts to read the
|
|
239
|
-
* nearest package.json version (best-effort; non-fatal on failure).
|
|
240
|
-
*/
|
|
241
|
-
brand(args: {
|
|
242
|
-
name?: string;
|
|
243
|
-
description?: string;
|
|
244
|
-
version?: string;
|
|
245
|
-
importMetaUrl?: string;
|
|
246
|
-
helpHeader?: string;
|
|
247
|
-
}): Promise<this>;
|
|
248
|
-
/**
|
|
249
|
-
* Register a plugin for installation (parent level).
|
|
250
|
-
* Installation occurs on first resolveAndLoad() (or explicit install()).
|
|
251
|
-
*/
|
|
252
|
-
use(plugin: GetDotenvCliPlugin): this;
|
|
192
|
+
type GetDotenvCliPublic<TOptions extends GetDotenvOptions = GetDotenvOptions> = Command & {
|
|
193
|
+
ns: (name: string) => Command;
|
|
194
|
+
getCtx: () => GetDotenvCliCtx<TOptions> | undefined;
|
|
195
|
+
resolveAndLoad: (customOptions?: Partial<TOptions>) => Promise<GetDotenvCliCtx<TOptions>>;
|
|
196
|
+
};
|
|
197
|
+
/** Public plugin contract used by the GetDotenv CLI host. */
|
|
198
|
+
interface GetDotenvCliPlugin {
|
|
199
|
+
id?: string;
|
|
253
200
|
/**
|
|
254
|
-
*
|
|
255
|
-
* Runs
|
|
201
|
+
* Setup phase: register commands and wiring on the provided CLI instance.
|
|
202
|
+
* Runs parent → children (pre-order).
|
|
256
203
|
*/
|
|
257
|
-
|
|
258
|
-
/**
|
|
259
|
-
* Run afterResolve hooks for all plugins (parent → children).
|
|
260
|
-
*/
|
|
261
|
-
private _runAfterResolve;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
/** Public plugin contract used by the GetDotenv CLI host. */ interface GetDotenvCliPlugin {
|
|
265
|
-
id?: string /**
|
|
266
|
-
* Setup phase: register commands and wiring on the provided CLI instance. * Runs parent → children (pre-order).
|
|
267
|
-
*/;
|
|
268
|
-
setup: (cli: GetDotenvCli) => void | Promise<void>;
|
|
204
|
+
setup: (cli: GetDotenvCliPublic) => void | Promise<void>;
|
|
269
205
|
/**
|
|
270
206
|
* After the dotenv context is resolved, initialize any clients/secrets
|
|
271
207
|
* or attach per-plugin state under ctx.plugins (by convention).
|
|
272
208
|
* Runs parent → children (pre-order).
|
|
273
209
|
*/
|
|
274
|
-
afterResolve?: (cli:
|
|
210
|
+
afterResolve?: (cli: GetDotenvCliPublic, ctx: GetDotenvCliCtx) => void | Promise<void>;
|
|
275
211
|
/**
|
|
276
212
|
* Optional Zod schema for this plugin's config slice (from config.plugins[id]).
|
|
277
213
|
* When provided, the host validates the merged config under the guarded loader path.
|
|
@@ -279,7 +215,8 @@ declare class GetDotenvCli<TOptions extends GetDotenvOptions = GetDotenvOptions>
|
|
|
279
215
|
configSchema?: ZodType;
|
|
280
216
|
/**
|
|
281
217
|
* Compositional children. Installed after the parent per pre-order.
|
|
282
|
-
*/
|
|
218
|
+
*/
|
|
219
|
+
children: GetDotenvCliPlugin[];
|
|
283
220
|
/**
|
|
284
221
|
* Compose a child plugin. Returns the parent to enable chaining.
|
|
285
222
|
*/
|
package/dist/plugins-aws.mjs
CHANGED
|
@@ -234,6 +234,13 @@ const buildSpawnEnv = (base, overlay) => {
|
|
|
234
234
|
return out;
|
|
235
235
|
};
|
|
236
236
|
|
|
237
|
+
/** src/cliHost/definePlugin.ts
|
|
238
|
+
* Plugin contracts for the GetDotenv CLI host.
|
|
239
|
+
*
|
|
240
|
+
* This module exposes a structural public interface for the host that plugins
|
|
241
|
+
* should use (GetDotenvCliPublic). Using a structural type at the seam avoids
|
|
242
|
+
* nominal class identity issues (private fields) in downstream consumers.
|
|
243
|
+
*/
|
|
237
244
|
/**
|
|
238
245
|
* Define a GetDotenv CLI plugin with compositional helpers.
|
|
239
246
|
*
|
package/dist/plugins-batch.cjs
CHANGED
|
@@ -7,6 +7,13 @@ var path = require('path');
|
|
|
7
7
|
var execa = require('execa');
|
|
8
8
|
var zod = require('zod');
|
|
9
9
|
|
|
10
|
+
/** src/cliHost/definePlugin.ts
|
|
11
|
+
* Plugin contracts for the GetDotenv CLI host.
|
|
12
|
+
*
|
|
13
|
+
* This module exposes a structural public interface for the host that plugins
|
|
14
|
+
* should use (GetDotenvCliPublic). Using a structural type at the seam avoids
|
|
15
|
+
* nominal class identity issues (private fields) in downstream consumers.
|
|
16
|
+
*/
|
|
10
17
|
/**
|
|
11
18
|
* Define a GetDotenv CLI plugin with compositional helpers.
|
|
12
19
|
*
|
package/dist/plugins-batch.d.cts
CHANGED
|
@@ -1,5 +1,75 @@
|
|
|
1
|
-
import { ZodType } from 'zod';
|
|
2
1
|
import { Command } from 'commander';
|
|
2
|
+
import { ZodType } from 'zod';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Minimal root options shape shared by CLI and generator layers.
|
|
6
|
+
* Keep keys optional to respect exactOptionalPropertyTypes semantics.
|
|
7
|
+
*/
|
|
8
|
+
type RootOptionsShape = {
|
|
9
|
+
env?: string;
|
|
10
|
+
vars?: string;
|
|
11
|
+
command?: string;
|
|
12
|
+
outputPath?: string;
|
|
13
|
+
shell?: string | boolean;
|
|
14
|
+
loadProcess?: boolean;
|
|
15
|
+
excludeAll?: boolean;
|
|
16
|
+
excludeDynamic?: boolean;
|
|
17
|
+
excludeEnv?: boolean;
|
|
18
|
+
excludeGlobal?: boolean;
|
|
19
|
+
excludePrivate?: boolean;
|
|
20
|
+
excludePublic?: boolean;
|
|
21
|
+
log?: boolean;
|
|
22
|
+
debug?: boolean;
|
|
23
|
+
capture?: boolean;
|
|
24
|
+
strict?: boolean;
|
|
25
|
+
redact?: boolean;
|
|
26
|
+
warnEntropy?: boolean;
|
|
27
|
+
entropyThreshold?: number;
|
|
28
|
+
entropyMinLength?: number;
|
|
29
|
+
entropyWhitelist?: string[];
|
|
30
|
+
redactPatterns?: string[];
|
|
31
|
+
defaultEnv?: string;
|
|
32
|
+
dotenvToken?: string;
|
|
33
|
+
dynamicPath?: string;
|
|
34
|
+
trace?: boolean | string[];
|
|
35
|
+
paths?: string;
|
|
36
|
+
pathsDelimiter?: string;
|
|
37
|
+
pathsDelimiterPattern?: string;
|
|
38
|
+
privateToken?: string;
|
|
39
|
+
varsDelimiter?: string;
|
|
40
|
+
varsDelimiterPattern?: string;
|
|
41
|
+
varsAssignor?: string;
|
|
42
|
+
varsAssignorPattern?: string;
|
|
43
|
+
scripts?: ScriptsTable;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Scripts table shape (configurable shell type).
|
|
47
|
+
*/
|
|
48
|
+
type ScriptsTable<TShell extends string | boolean = string | boolean> = Record<string, string | {
|
|
49
|
+
cmd: string;
|
|
50
|
+
shell?: TShell;
|
|
51
|
+
}>;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Adapter-layer augmentation: add chainable helpers to GetDotenvCli without
|
|
55
|
+
* coupling the core host to cliCore. Importing this module has side effects:
|
|
56
|
+
* it extends the prototype and merges types for consumers.
|
|
57
|
+
*/
|
|
58
|
+
declare module '../cliHost/GetDotenvCli' {
|
|
59
|
+
interface GetDotenvCli {
|
|
60
|
+
/**
|
|
61
|
+
* Attach legacy root flags to this CLI instance. Defaults come from
|
|
62
|
+
* baseRootOptionDefaults when none are provided. */
|
|
63
|
+
attachRootOptions(defaults?: Partial<RootOptionsShape>, opts?: {
|
|
64
|
+
includeCommandOption?: boolean;
|
|
65
|
+
}): this;
|
|
66
|
+
/**
|
|
67
|
+
* Install a preSubcommand hook that merges CLI flags (including parent
|
|
68
|
+
* round-trip) and resolves the dotenv context before executing actions.
|
|
69
|
+
* Defaults come from baseRootOptionDefaults when none are provided.
|
|
70
|
+
*/ passOptions(defaults?: Partial<RootOptionsShape>): this;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
3
73
|
|
|
4
74
|
/**
|
|
5
75
|
* A minimal representation of an environment key/value mapping.
|
|
@@ -95,93 +165,6 @@ interface GetDotenvOptions {
|
|
|
95
165
|
useConfigLoader?: boolean;
|
|
96
166
|
}
|
|
97
167
|
|
|
98
|
-
type Scripts$1 = Record<string, string | {
|
|
99
|
-
cmd: string;
|
|
100
|
-
shell?: string | boolean;
|
|
101
|
-
}>;
|
|
102
|
-
/**
|
|
103
|
-
* Options passed programmatically to `getDotenvCli`.
|
|
104
|
-
*/
|
|
105
|
-
interface GetDotenvCliOptions extends Omit<GetDotenvOptions, 'paths' | 'vars'> {
|
|
106
|
-
/**
|
|
107
|
-
* Logs CLI internals when true.
|
|
108
|
-
*/
|
|
109
|
-
debug?: boolean;
|
|
110
|
-
/**
|
|
111
|
-
* Strict mode: fail the run when env validation issues are detected
|
|
112
|
-
* (schema or requiredKeys). Warns by default when false or unset.
|
|
113
|
-
*/
|
|
114
|
-
strict?: boolean;
|
|
115
|
-
/**
|
|
116
|
-
* Redaction (presentation): mask secret-like values in logs/trace.
|
|
117
|
-
*/
|
|
118
|
-
redact?: boolean;
|
|
119
|
-
/**
|
|
120
|
-
* Entropy warnings (presentation): emit once-per-key warnings for high-entropy values.
|
|
121
|
-
*/
|
|
122
|
-
warnEntropy?: boolean;
|
|
123
|
-
entropyThreshold?: number;
|
|
124
|
-
entropyMinLength?: number;
|
|
125
|
-
entropyWhitelist?: string[];
|
|
126
|
-
redactPatterns?: string[];
|
|
127
|
-
/**
|
|
128
|
-
* When true, capture child stdout/stderr and re-emit after completion.
|
|
129
|
-
* Useful for tests/CI. Default behavior is streaming via stdio: 'inherit'.
|
|
130
|
-
*/
|
|
131
|
-
capture?: boolean;
|
|
132
|
-
/**
|
|
133
|
-
* A delimited string of paths to dotenv files.
|
|
134
|
-
*/
|
|
135
|
-
paths?: string;
|
|
136
|
-
/**
|
|
137
|
-
* A delimiter string with which to split `paths`. Only used if
|
|
138
|
-
* `pathsDelimiterPattern` is not provided.
|
|
139
|
-
*/
|
|
140
|
-
pathsDelimiter?: string;
|
|
141
|
-
/**
|
|
142
|
-
* A regular expression pattern with which to split `paths`. Supersedes
|
|
143
|
-
* `pathsDelimiter`.
|
|
144
|
-
*/
|
|
145
|
-
pathsDelimiterPattern?: string;
|
|
146
|
-
/**
|
|
147
|
-
* Scripts that can be executed from the CLI, either individually or via the batch subcommand.
|
|
148
|
-
*/
|
|
149
|
-
scripts?: Scripts$1;
|
|
150
|
-
/**
|
|
151
|
-
* Determines how commands and scripts are executed. If `false` or
|
|
152
|
-
* `undefined`, commands are executed as plain Javascript using the default
|
|
153
|
-
* execa parser. If `true`, commands are executed using the default OS shell
|
|
154
|
-
* parser. Otherwise the user may provide a specific shell string (e.g.
|
|
155
|
-
* `/bin/bash`)
|
|
156
|
-
*/
|
|
157
|
-
shell?: string | boolean;
|
|
158
|
-
/**
|
|
159
|
-
* A delimited string of key-value pairs declaratively specifying variables &
|
|
160
|
-
* values to be loaded in addition to any dotenv files.
|
|
161
|
-
*/
|
|
162
|
-
vars?: string;
|
|
163
|
-
/**
|
|
164
|
-
* A string with which to split keys from values in `vars`. Only used if
|
|
165
|
-
* `varsDelimiterPattern` is not provided.
|
|
166
|
-
*/
|
|
167
|
-
varsAssignor?: string;
|
|
168
|
-
/**
|
|
169
|
-
* A regular expression pattern with which to split variable names from values
|
|
170
|
-
* in `vars`. Supersedes `varsAssignor`.
|
|
171
|
-
*/
|
|
172
|
-
varsAssignorPattern?: string;
|
|
173
|
-
/**
|
|
174
|
-
* A string with which to split `vars` into key-value pairs. Only used if
|
|
175
|
-
* `varsDelimiterPattern` is not provided.
|
|
176
|
-
*/
|
|
177
|
-
varsDelimiter?: string;
|
|
178
|
-
/**
|
|
179
|
-
* A regular expression pattern with which to split `vars` into key-value
|
|
180
|
-
* pairs. Supersedes `varsDelimiter`.
|
|
181
|
-
*/
|
|
182
|
-
varsDelimiterPattern?: string;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
168
|
/** * Per-invocation context shared with plugins and actions. */
|
|
186
169
|
type GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> = {
|
|
187
170
|
optionsResolved: TOptions;
|
|
@@ -189,89 +172,42 @@ type GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> = {
|
|
|
189
172
|
plugins?: Record<string, unknown>;
|
|
190
173
|
pluginConfigs?: Record<string, unknown>;
|
|
191
174
|
};
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* Plugin
|
|
175
|
+
|
|
176
|
+
/** src/cliHost/definePlugin.ts
|
|
177
|
+
* Plugin contracts for the GetDotenv CLI host.
|
|
195
178
|
*
|
|
196
|
-
*
|
|
197
|
-
*
|
|
198
|
-
*
|
|
199
|
-
|
|
200
|
-
|
|
179
|
+
* This module exposes a structural public interface for the host that plugins
|
|
180
|
+
* should use (GetDotenvCliPublic). Using a structural type at the seam avoids
|
|
181
|
+
* nominal class identity issues (private fields) in downstream consumers.
|
|
182
|
+
*/
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Structural public interface for the host exposed to plugins.
|
|
186
|
+
* - Extends Commander.Command so plugins can attach options/commands/hooks.
|
|
187
|
+
* - Adds host-specific helpers used by built-in plugins.
|
|
201
188
|
*
|
|
202
|
-
*
|
|
189
|
+
* Purpose: remove nominal class identity (private fields) from the plugin seam
|
|
190
|
+
* to avoid TS2379 under exactOptionalPropertyTypes in downstream consumers.
|
|
203
191
|
*/
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
constructor(alias?: string);
|
|
213
|
-
/**
|
|
214
|
-
* Resolve options (strict) and compute dotenv context. * Stores the context on the instance under a symbol.
|
|
215
|
-
*/
|
|
216
|
-
resolveAndLoad(customOptions?: Partial<TOptions>): Promise<GetDotenvCliCtx<TOptions>>;
|
|
217
|
-
/**
|
|
218
|
-
* Retrieve the current invocation context (if any).
|
|
219
|
-
*/
|
|
220
|
-
getCtx(): GetDotenvCliCtx<TOptions> | undefined;
|
|
221
|
-
/**
|
|
222
|
-
* Retrieve the merged root CLI options bag (if set by passOptions()).
|
|
223
|
-
* Downstream-safe: no generics required.
|
|
224
|
-
*/
|
|
225
|
-
getOptions(): GetDotenvCliOptions | undefined;
|
|
226
|
-
/** Internal: set the merged root options bag for this run. */
|
|
227
|
-
_setOptionsBag(bag: GetDotenvCliOptions): void;
|
|
228
|
-
/** * Convenience helper to create a namespaced subcommand.
|
|
229
|
-
*/
|
|
230
|
-
ns(name: string): Command;
|
|
231
|
-
/**
|
|
232
|
-
* Tag options added during the provided callback as 'app' for grouped help.
|
|
233
|
-
* Allows downstream apps to demarcate their root-level options.
|
|
234
|
-
*/
|
|
235
|
-
tagAppOptions<T>(fn: (root: Command) => T): T;
|
|
236
|
-
/**
|
|
237
|
-
* Branding helper: set CLI name/description/version and optional help header.
|
|
238
|
-
* If version is omitted and importMetaUrl is provided, attempts to read the
|
|
239
|
-
* nearest package.json version (best-effort; non-fatal on failure).
|
|
240
|
-
*/
|
|
241
|
-
brand(args: {
|
|
242
|
-
name?: string;
|
|
243
|
-
description?: string;
|
|
244
|
-
version?: string;
|
|
245
|
-
importMetaUrl?: string;
|
|
246
|
-
helpHeader?: string;
|
|
247
|
-
}): Promise<this>;
|
|
248
|
-
/**
|
|
249
|
-
* Register a plugin for installation (parent level).
|
|
250
|
-
* Installation occurs on first resolveAndLoad() (or explicit install()).
|
|
251
|
-
*/
|
|
252
|
-
use(plugin: GetDotenvCliPlugin): this;
|
|
192
|
+
type GetDotenvCliPublic<TOptions extends GetDotenvOptions = GetDotenvOptions> = Command & {
|
|
193
|
+
ns: (name: string) => Command;
|
|
194
|
+
getCtx: () => GetDotenvCliCtx<TOptions> | undefined;
|
|
195
|
+
resolveAndLoad: (customOptions?: Partial<TOptions>) => Promise<GetDotenvCliCtx<TOptions>>;
|
|
196
|
+
};
|
|
197
|
+
/** Public plugin contract used by the GetDotenv CLI host. */
|
|
198
|
+
interface GetDotenvCliPlugin {
|
|
199
|
+
id?: string;
|
|
253
200
|
/**
|
|
254
|
-
*
|
|
255
|
-
* Runs
|
|
201
|
+
* Setup phase: register commands and wiring on the provided CLI instance.
|
|
202
|
+
* Runs parent → children (pre-order).
|
|
256
203
|
*/
|
|
257
|
-
|
|
258
|
-
/**
|
|
259
|
-
* Run afterResolve hooks for all plugins (parent → children).
|
|
260
|
-
*/
|
|
261
|
-
private _runAfterResolve;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
/** Public plugin contract used by the GetDotenv CLI host. */ interface GetDotenvCliPlugin {
|
|
265
|
-
id?: string /**
|
|
266
|
-
* Setup phase: register commands and wiring on the provided CLI instance. * Runs parent → children (pre-order).
|
|
267
|
-
*/;
|
|
268
|
-
setup: (cli: GetDotenvCli) => void | Promise<void>;
|
|
204
|
+
setup: (cli: GetDotenvCliPublic) => void | Promise<void>;
|
|
269
205
|
/**
|
|
270
206
|
* After the dotenv context is resolved, initialize any clients/secrets
|
|
271
207
|
* or attach per-plugin state under ctx.plugins (by convention).
|
|
272
208
|
* Runs parent → children (pre-order).
|
|
273
209
|
*/
|
|
274
|
-
afterResolve?: (cli:
|
|
210
|
+
afterResolve?: (cli: GetDotenvCliPublic, ctx: GetDotenvCliCtx) => void | Promise<void>;
|
|
275
211
|
/**
|
|
276
212
|
* Optional Zod schema for this plugin's config slice (from config.plugins[id]).
|
|
277
213
|
* When provided, the host validates the merged config under the guarded loader path.
|
|
@@ -279,7 +215,8 @@ declare class GetDotenvCli<TOptions extends GetDotenvOptions = GetDotenvOptions>
|
|
|
279
215
|
configSchema?: ZodType;
|
|
280
216
|
/**
|
|
281
217
|
* Compositional children. Installed after the parent per pre-order.
|
|
282
|
-
*/
|
|
218
|
+
*/
|
|
219
|
+
children: GetDotenvCliPlugin[];
|
|
283
220
|
/**
|
|
284
221
|
* Compose a child plugin. Returns the parent to enable chaining.
|
|
285
222
|
*/
|