@karmaniverous/get-dotenv 5.0.0 → 5.2.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 +14 -0
- package/dist/cliHost.cjs +393 -21
- package/dist/cliHost.d.cts +132 -3
- package/dist/cliHost.d.mts +132 -3
- package/dist/cliHost.d.ts +132 -3
- package/dist/cliHost.mjs +393 -22
- package/dist/config.cjs +10 -5
- package/dist/config.d.cts +2 -0
- package/dist/config.d.mts +2 -0
- package/dist/config.d.ts +2 -0
- package/dist/config.mjs +10 -5
- package/dist/env-overlay.d.cts +2 -0
- package/dist/env-overlay.d.mts +2 -0
- package/dist/env-overlay.d.ts +2 -0
- package/dist/getdotenv.cli.mjs +678 -39
- package/dist/index.cjs +604 -245
- package/dist/index.d.cts +36 -1
- package/dist/index.d.mts +36 -1
- package/dist/index.d.ts +36 -1
- package/dist/index.mjs +604 -246
- package/dist/plugins-aws.cjs +43 -1
- package/dist/plugins-aws.d.cts +115 -0
- package/dist/plugins-aws.d.mts +115 -0
- package/dist/plugins-aws.d.ts +115 -0
- package/dist/plugins-aws.mjs +43 -1
- package/dist/plugins-batch.cjs +46 -6
- package/dist/plugins-batch.d.cts +115 -0
- package/dist/plugins-batch.d.mts +115 -0
- package/dist/plugins-batch.d.ts +115 -0
- package/dist/plugins-batch.mjs +46 -6
- package/dist/plugins-init.d.cts +115 -0
- package/dist/plugins-init.d.mts +115 -0
- package/dist/plugins-init.d.ts +115 -0
- package/package.json +25 -24
package/dist/plugins-batch.d.cts
CHANGED
|
@@ -95,6 +95,93 @@ interface GetDotenvOptions {
|
|
|
95
95
|
useConfigLoader?: boolean;
|
|
96
96
|
}
|
|
97
97
|
|
|
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
|
+
|
|
98
185
|
/** * Per-invocation context shared with plugins and actions. */
|
|
99
186
|
type GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> = {
|
|
100
187
|
optionsResolved: TOptions;
|
|
@@ -102,6 +189,7 @@ type GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> = {
|
|
|
102
189
|
plugins?: Record<string, unknown>;
|
|
103
190
|
pluginConfigs?: Record<string, unknown>;
|
|
104
191
|
};
|
|
192
|
+
declare const HELP_HEADER_SYMBOL: unique symbol;
|
|
105
193
|
/**
|
|
106
194
|
* Plugin-first CLI host for get-dotenv. Extends Commander.Command.
|
|
107
195
|
*
|
|
@@ -114,10 +202,13 @@ type GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> = {
|
|
|
114
202
|
* NOTE: This host is additive and does not alter the legacy CLI.
|
|
115
203
|
*/
|
|
116
204
|
declare class GetDotenvCli<TOptions extends GetDotenvOptions = GetDotenvOptions> extends Command {
|
|
205
|
+
#private;
|
|
117
206
|
/** Registered top-level plugins (composition happens via .use()) */
|
|
118
207
|
private _plugins;
|
|
119
208
|
/** One-time installation guard */
|
|
120
209
|
private _installed;
|
|
210
|
+
/** Optional header line to prepend in help output */
|
|
211
|
+
private [HELP_HEADER_SYMBOL];
|
|
121
212
|
constructor(alias?: string);
|
|
122
213
|
/**
|
|
123
214
|
* Resolve options (strict) and compute dotenv context. * Stores the context on the instance under a symbol.
|
|
@@ -127,9 +218,33 @@ declare class GetDotenvCli<TOptions extends GetDotenvOptions = GetDotenvOptions>
|
|
|
127
218
|
* Retrieve the current invocation context (if any).
|
|
128
219
|
*/
|
|
129
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;
|
|
130
228
|
/** * Convenience helper to create a namespaced subcommand.
|
|
131
229
|
*/
|
|
132
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>;
|
|
133
248
|
/**
|
|
134
249
|
* Register a plugin for installation (parent level).
|
|
135
250
|
* Installation occurs on first resolveAndLoad() (or explicit install()).
|
package/dist/plugins-batch.d.mts
CHANGED
|
@@ -95,6 +95,93 @@ interface GetDotenvOptions {
|
|
|
95
95
|
useConfigLoader?: boolean;
|
|
96
96
|
}
|
|
97
97
|
|
|
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
|
+
|
|
98
185
|
/** * Per-invocation context shared with plugins and actions. */
|
|
99
186
|
type GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> = {
|
|
100
187
|
optionsResolved: TOptions;
|
|
@@ -102,6 +189,7 @@ type GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> = {
|
|
|
102
189
|
plugins?: Record<string, unknown>;
|
|
103
190
|
pluginConfigs?: Record<string, unknown>;
|
|
104
191
|
};
|
|
192
|
+
declare const HELP_HEADER_SYMBOL: unique symbol;
|
|
105
193
|
/**
|
|
106
194
|
* Plugin-first CLI host for get-dotenv. Extends Commander.Command.
|
|
107
195
|
*
|
|
@@ -114,10 +202,13 @@ type GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> = {
|
|
|
114
202
|
* NOTE: This host is additive and does not alter the legacy CLI.
|
|
115
203
|
*/
|
|
116
204
|
declare class GetDotenvCli<TOptions extends GetDotenvOptions = GetDotenvOptions> extends Command {
|
|
205
|
+
#private;
|
|
117
206
|
/** Registered top-level plugins (composition happens via .use()) */
|
|
118
207
|
private _plugins;
|
|
119
208
|
/** One-time installation guard */
|
|
120
209
|
private _installed;
|
|
210
|
+
/** Optional header line to prepend in help output */
|
|
211
|
+
private [HELP_HEADER_SYMBOL];
|
|
121
212
|
constructor(alias?: string);
|
|
122
213
|
/**
|
|
123
214
|
* Resolve options (strict) and compute dotenv context. * Stores the context on the instance under a symbol.
|
|
@@ -127,9 +218,33 @@ declare class GetDotenvCli<TOptions extends GetDotenvOptions = GetDotenvOptions>
|
|
|
127
218
|
* Retrieve the current invocation context (if any).
|
|
128
219
|
*/
|
|
129
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;
|
|
130
228
|
/** * Convenience helper to create a namespaced subcommand.
|
|
131
229
|
*/
|
|
132
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>;
|
|
133
248
|
/**
|
|
134
249
|
* Register a plugin for installation (parent level).
|
|
135
250
|
* Installation occurs on first resolveAndLoad() (or explicit install()).
|
package/dist/plugins-batch.d.ts
CHANGED
|
@@ -95,6 +95,93 @@ interface GetDotenvOptions {
|
|
|
95
95
|
useConfigLoader?: boolean;
|
|
96
96
|
}
|
|
97
97
|
|
|
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
|
+
|
|
98
185
|
/** * Per-invocation context shared with plugins and actions. */
|
|
99
186
|
type GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> = {
|
|
100
187
|
optionsResolved: TOptions;
|
|
@@ -102,6 +189,7 @@ type GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> = {
|
|
|
102
189
|
plugins?: Record<string, unknown>;
|
|
103
190
|
pluginConfigs?: Record<string, unknown>;
|
|
104
191
|
};
|
|
192
|
+
declare const HELP_HEADER_SYMBOL: unique symbol;
|
|
105
193
|
/**
|
|
106
194
|
* Plugin-first CLI host for get-dotenv. Extends Commander.Command.
|
|
107
195
|
*
|
|
@@ -114,10 +202,13 @@ type GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> = {
|
|
|
114
202
|
* NOTE: This host is additive and does not alter the legacy CLI.
|
|
115
203
|
*/
|
|
116
204
|
declare class GetDotenvCli<TOptions extends GetDotenvOptions = GetDotenvOptions> extends Command {
|
|
205
|
+
#private;
|
|
117
206
|
/** Registered top-level plugins (composition happens via .use()) */
|
|
118
207
|
private _plugins;
|
|
119
208
|
/** One-time installation guard */
|
|
120
209
|
private _installed;
|
|
210
|
+
/** Optional header line to prepend in help output */
|
|
211
|
+
private [HELP_HEADER_SYMBOL];
|
|
121
212
|
constructor(alias?: string);
|
|
122
213
|
/**
|
|
123
214
|
* Resolve options (strict) and compute dotenv context. * Stores the context on the instance under a symbol.
|
|
@@ -127,9 +218,33 @@ declare class GetDotenvCli<TOptions extends GetDotenvOptions = GetDotenvOptions>
|
|
|
127
218
|
* Retrieve the current invocation context (if any).
|
|
128
219
|
*/
|
|
129
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;
|
|
130
228
|
/** * Convenience helper to create a namespaced subcommand.
|
|
131
229
|
*/
|
|
132
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>;
|
|
133
248
|
/**
|
|
134
249
|
* Register a plugin for installation (parent level).
|
|
135
250
|
* Installation occurs on first resolveAndLoad() (or explicit install()).
|
package/dist/plugins-batch.mjs
CHANGED
|
@@ -163,6 +163,48 @@ const runCommand = async (command, shell, opts) => {
|
|
|
163
163
|
}
|
|
164
164
|
};
|
|
165
165
|
|
|
166
|
+
const dropUndefined = (bag) => Object.fromEntries(Object.entries(bag).filter((e) => typeof e[1] === 'string'));
|
|
167
|
+
/** Build a sanitized env for child processes from base + overlay. */
|
|
168
|
+
const buildSpawnEnv = (base, overlay) => {
|
|
169
|
+
const raw = {
|
|
170
|
+
...(base ?? {}),
|
|
171
|
+
...(overlay ?? {}),
|
|
172
|
+
};
|
|
173
|
+
// Drop undefined first
|
|
174
|
+
const entries = Object.entries(dropUndefined(raw));
|
|
175
|
+
if (process.platform === 'win32') {
|
|
176
|
+
// Windows: keys are case-insensitive; collapse duplicates
|
|
177
|
+
const byLower = new Map();
|
|
178
|
+
for (const [k, v] of entries) {
|
|
179
|
+
byLower.set(k.toLowerCase(), [k, v]); // last wins; preserve latest casing
|
|
180
|
+
}
|
|
181
|
+
const out = {};
|
|
182
|
+
for (const [, [k, v]] of byLower)
|
|
183
|
+
out[k] = v;
|
|
184
|
+
// HOME fallback from USERPROFILE (common expectation)
|
|
185
|
+
if (!Object.prototype.hasOwnProperty.call(out, 'HOME')) {
|
|
186
|
+
const up = out['USERPROFILE'];
|
|
187
|
+
if (typeof up === 'string' && up.length > 0)
|
|
188
|
+
out['HOME'] = up;
|
|
189
|
+
}
|
|
190
|
+
// Normalize TMP/TEMP coherence (pick any present; reflect to both)
|
|
191
|
+
const tmp = out['TMP'] ?? out['TEMP'];
|
|
192
|
+
if (typeof tmp === 'string' && tmp.length > 0) {
|
|
193
|
+
out['TMP'] = tmp;
|
|
194
|
+
out['TEMP'] = tmp;
|
|
195
|
+
}
|
|
196
|
+
return out;
|
|
197
|
+
}
|
|
198
|
+
// POSIX: keep keys as-is
|
|
199
|
+
const out = Object.fromEntries(entries);
|
|
200
|
+
// Ensure TMPDIR exists when any temp key is present (best-effort)
|
|
201
|
+
const tmpdir = out['TMPDIR'] ?? out['TMP'] ?? out['TEMP'];
|
|
202
|
+
if (typeof tmpdir === 'string' && tmpdir.length > 0) {
|
|
203
|
+
out['TMPDIR'] = tmpdir;
|
|
204
|
+
}
|
|
205
|
+
return out;
|
|
206
|
+
};
|
|
207
|
+
|
|
166
208
|
const globPaths = async ({ globs, logger, pkgCwd, rootPath, }) => {
|
|
167
209
|
let cwd = process.cwd();
|
|
168
210
|
if (pkgCwd) {
|
|
@@ -235,14 +277,12 @@ const execShellCommandBatch = async ({ command, getDotenvCliOptions, globs, igno
|
|
|
235
277
|
const hasCmd = (typeof command === 'string' && command.length > 0) ||
|
|
236
278
|
(Array.isArray(command) && command.length > 0);
|
|
237
279
|
if (hasCmd) {
|
|
280
|
+
const envBag = getDotenvCliOptions !== undefined
|
|
281
|
+
? { getDotenvCliOptions: JSON.stringify(getDotenvCliOptions) }
|
|
282
|
+
: undefined;
|
|
238
283
|
await runCommand(command, shell, {
|
|
239
284
|
cwd: path,
|
|
240
|
-
env:
|
|
241
|
-
...process.env,
|
|
242
|
-
getDotenvCliOptions: getDotenvCliOptions
|
|
243
|
-
? JSON.stringify(getDotenvCliOptions)
|
|
244
|
-
: undefined,
|
|
245
|
-
},
|
|
285
|
+
env: buildSpawnEnv(process.env, envBag),
|
|
246
286
|
stdio: capture ? 'pipe' : 'inherit',
|
|
247
287
|
});
|
|
248
288
|
}
|
package/dist/plugins-init.d.cts
CHANGED
|
@@ -95,6 +95,93 @@ interface GetDotenvOptions {
|
|
|
95
95
|
useConfigLoader?: boolean;
|
|
96
96
|
}
|
|
97
97
|
|
|
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
|
+
|
|
98
185
|
/** * Per-invocation context shared with plugins and actions. */
|
|
99
186
|
type GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> = {
|
|
100
187
|
optionsResolved: TOptions;
|
|
@@ -102,6 +189,7 @@ type GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> = {
|
|
|
102
189
|
plugins?: Record<string, unknown>;
|
|
103
190
|
pluginConfigs?: Record<string, unknown>;
|
|
104
191
|
};
|
|
192
|
+
declare const HELP_HEADER_SYMBOL: unique symbol;
|
|
105
193
|
/**
|
|
106
194
|
* Plugin-first CLI host for get-dotenv. Extends Commander.Command.
|
|
107
195
|
*
|
|
@@ -114,10 +202,13 @@ type GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> = {
|
|
|
114
202
|
* NOTE: This host is additive and does not alter the legacy CLI.
|
|
115
203
|
*/
|
|
116
204
|
declare class GetDotenvCli<TOptions extends GetDotenvOptions = GetDotenvOptions> extends Command {
|
|
205
|
+
#private;
|
|
117
206
|
/** Registered top-level plugins (composition happens via .use()) */
|
|
118
207
|
private _plugins;
|
|
119
208
|
/** One-time installation guard */
|
|
120
209
|
private _installed;
|
|
210
|
+
/** Optional header line to prepend in help output */
|
|
211
|
+
private [HELP_HEADER_SYMBOL];
|
|
121
212
|
constructor(alias?: string);
|
|
122
213
|
/**
|
|
123
214
|
* Resolve options (strict) and compute dotenv context. * Stores the context on the instance under a symbol.
|
|
@@ -127,9 +218,33 @@ declare class GetDotenvCli<TOptions extends GetDotenvOptions = GetDotenvOptions>
|
|
|
127
218
|
* Retrieve the current invocation context (if any).
|
|
128
219
|
*/
|
|
129
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;
|
|
130
228
|
/** * Convenience helper to create a namespaced subcommand.
|
|
131
229
|
*/
|
|
132
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>;
|
|
133
248
|
/**
|
|
134
249
|
* Register a plugin for installation (parent level).
|
|
135
250
|
* Installation occurs on first resolveAndLoad() (or explicit install()).
|