@karmaniverous/get-dotenv 5.2.5 → 6.0.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 +63 -67
- package/dist/cliHost.cjs +765 -549
- package/dist/cliHost.d.cts +128 -84
- package/dist/cliHost.d.mts +128 -84
- package/dist/cliHost.d.ts +128 -84
- package/dist/cliHost.mjs +765 -549
- package/dist/getdotenv.cli.mjs +915 -685
- package/dist/index.cjs +959 -1006
- package/dist/index.d.cts +18 -178
- package/dist/index.d.mts +18 -178
- package/dist/index.d.ts +18 -178
- package/dist/index.mjs +960 -1006
- package/dist/plugins-aws.cjs +0 -1
- package/dist/plugins-aws.d.cts +8 -78
- package/dist/plugins-aws.d.mts +8 -78
- package/dist/plugins-aws.d.ts +8 -78
- package/dist/plugins-aws.mjs +0 -1
- package/dist/plugins-batch.cjs +53 -11
- package/dist/plugins-batch.d.cts +10 -79
- package/dist/plugins-batch.d.mts +10 -79
- package/dist/plugins-batch.d.ts +10 -79
- package/dist/plugins-batch.mjs +53 -11
- package/dist/plugins-cmd.cjs +162 -1555
- package/dist/plugins-cmd.d.cts +8 -78
- package/dist/plugins-cmd.d.mts +8 -78
- package/dist/plugins-cmd.d.ts +8 -78
- package/dist/plugins-cmd.mjs +162 -1554
- package/dist/plugins-demo.cjs +52 -7
- package/dist/plugins-demo.d.cts +8 -78
- package/dist/plugins-demo.d.mts +8 -78
- package/dist/plugins-demo.d.ts +8 -78
- package/dist/plugins-demo.mjs +52 -7
- package/dist/plugins-init.d.cts +8 -78
- package/dist/plugins-init.d.mts +8 -78
- package/dist/plugins-init.d.ts +8 -78
- package/dist/plugins.cjs +283 -1630
- package/dist/plugins.d.cts +10 -79
- package/dist/plugins.d.mts +10 -79
- package/dist/plugins.d.ts +10 -79
- package/dist/plugins.mjs +285 -1631
- package/package.json +4 -2
package/dist/plugins-aws.cjs
CHANGED
|
@@ -496,7 +496,6 @@ const awsPlugin = () => definePlugin({
|
|
|
496
496
|
cli
|
|
497
497
|
.ns('aws')
|
|
498
498
|
.description('Establish an AWS session and optionally forward to the AWS CLI')
|
|
499
|
-
.configureHelp({ showGlobalOptions: true })
|
|
500
499
|
.enablePositionalOptions()
|
|
501
500
|
.passThroughOptions()
|
|
502
501
|
.allowUnknownOption(true)
|
package/dist/plugins-aws.d.cts
CHANGED
|
@@ -1,76 +1,6 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { ZodType } from 'zod';
|
|
3
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
|
-
}
|
|
73
|
-
|
|
74
4
|
/**
|
|
75
5
|
* A minimal representation of an environment key/value mapping.
|
|
76
6
|
* Values may be `undefined` to represent "unset". */ type ProcessEnv = Record<string, string | undefined>;
|
|
@@ -165,14 +95,6 @@ interface GetDotenvOptions {
|
|
|
165
95
|
useConfigLoader?: boolean;
|
|
166
96
|
}
|
|
167
97
|
|
|
168
|
-
/** * Per-invocation context shared with plugins and actions. */
|
|
169
|
-
type GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> = {
|
|
170
|
-
optionsResolved: TOptions;
|
|
171
|
-
dotenv: ProcessEnv;
|
|
172
|
-
plugins?: Record<string, unknown>;
|
|
173
|
-
pluginConfigs?: Record<string, unknown>;
|
|
174
|
-
};
|
|
175
|
-
|
|
176
98
|
/** src/cliHost/definePlugin.ts
|
|
177
99
|
* Plugin contracts for the GetDotenv CLI host.
|
|
178
100
|
*
|
|
@@ -223,6 +145,14 @@ interface GetDotenvCliPlugin {
|
|
|
223
145
|
use: (child: GetDotenvCliPlugin) => GetDotenvCliPlugin;
|
|
224
146
|
}
|
|
225
147
|
|
|
148
|
+
/** * Per-invocation context shared with plugins and actions. */
|
|
149
|
+
type GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> = {
|
|
150
|
+
optionsResolved: TOptions;
|
|
151
|
+
dotenv: ProcessEnv;
|
|
152
|
+
plugins?: Record<string, unknown>;
|
|
153
|
+
pluginConfigs?: Record<string, unknown>;
|
|
154
|
+
};
|
|
155
|
+
|
|
226
156
|
declare const awsPlugin: () => GetDotenvCliPlugin;
|
|
227
157
|
|
|
228
158
|
export { awsPlugin };
|
package/dist/plugins-aws.d.mts
CHANGED
|
@@ -1,76 +1,6 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { ZodType } from 'zod';
|
|
3
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
|
-
}
|
|
73
|
-
|
|
74
4
|
/**
|
|
75
5
|
* A minimal representation of an environment key/value mapping.
|
|
76
6
|
* Values may be `undefined` to represent "unset". */ type ProcessEnv = Record<string, string | undefined>;
|
|
@@ -165,14 +95,6 @@ interface GetDotenvOptions {
|
|
|
165
95
|
useConfigLoader?: boolean;
|
|
166
96
|
}
|
|
167
97
|
|
|
168
|
-
/** * Per-invocation context shared with plugins and actions. */
|
|
169
|
-
type GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> = {
|
|
170
|
-
optionsResolved: TOptions;
|
|
171
|
-
dotenv: ProcessEnv;
|
|
172
|
-
plugins?: Record<string, unknown>;
|
|
173
|
-
pluginConfigs?: Record<string, unknown>;
|
|
174
|
-
};
|
|
175
|
-
|
|
176
98
|
/** src/cliHost/definePlugin.ts
|
|
177
99
|
* Plugin contracts for the GetDotenv CLI host.
|
|
178
100
|
*
|
|
@@ -223,6 +145,14 @@ interface GetDotenvCliPlugin {
|
|
|
223
145
|
use: (child: GetDotenvCliPlugin) => GetDotenvCliPlugin;
|
|
224
146
|
}
|
|
225
147
|
|
|
148
|
+
/** * Per-invocation context shared with plugins and actions. */
|
|
149
|
+
type GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> = {
|
|
150
|
+
optionsResolved: TOptions;
|
|
151
|
+
dotenv: ProcessEnv;
|
|
152
|
+
plugins?: Record<string, unknown>;
|
|
153
|
+
pluginConfigs?: Record<string, unknown>;
|
|
154
|
+
};
|
|
155
|
+
|
|
226
156
|
declare const awsPlugin: () => GetDotenvCliPlugin;
|
|
227
157
|
|
|
228
158
|
export { awsPlugin };
|
package/dist/plugins-aws.d.ts
CHANGED
|
@@ -1,76 +1,6 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { ZodType } from 'zod';
|
|
3
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
|
-
}
|
|
73
|
-
|
|
74
4
|
/**
|
|
75
5
|
* A minimal representation of an environment key/value mapping.
|
|
76
6
|
* Values may be `undefined` to represent "unset". */ type ProcessEnv = Record<string, string | undefined>;
|
|
@@ -165,14 +95,6 @@ interface GetDotenvOptions {
|
|
|
165
95
|
useConfigLoader?: boolean;
|
|
166
96
|
}
|
|
167
97
|
|
|
168
|
-
/** * Per-invocation context shared with plugins and actions. */
|
|
169
|
-
type GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> = {
|
|
170
|
-
optionsResolved: TOptions;
|
|
171
|
-
dotenv: ProcessEnv;
|
|
172
|
-
plugins?: Record<string, unknown>;
|
|
173
|
-
pluginConfigs?: Record<string, unknown>;
|
|
174
|
-
};
|
|
175
|
-
|
|
176
98
|
/** src/cliHost/definePlugin.ts
|
|
177
99
|
* Plugin contracts for the GetDotenv CLI host.
|
|
178
100
|
*
|
|
@@ -223,6 +145,14 @@ interface GetDotenvCliPlugin {
|
|
|
223
145
|
use: (child: GetDotenvCliPlugin) => GetDotenvCliPlugin;
|
|
224
146
|
}
|
|
225
147
|
|
|
148
|
+
/** * Per-invocation context shared with plugins and actions. */
|
|
149
|
+
type GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> = {
|
|
150
|
+
optionsResolved: TOptions;
|
|
151
|
+
dotenv: ProcessEnv;
|
|
152
|
+
plugins?: Record<string, unknown>;
|
|
153
|
+
pluginConfigs?: Record<string, unknown>;
|
|
154
|
+
};
|
|
155
|
+
|
|
226
156
|
declare const awsPlugin: () => GetDotenvCliPlugin;
|
|
227
157
|
|
|
228
158
|
export { awsPlugin };
|
package/dist/plugins-aws.mjs
CHANGED
|
@@ -494,7 +494,6 @@ const awsPlugin = () => definePlugin({
|
|
|
494
494
|
cli
|
|
495
495
|
.ns('aws')
|
|
496
496
|
.description('Establish an AWS session and optionally forward to the AWS CLI')
|
|
497
|
-
.configureHelp({ showGlobalOptions: true })
|
|
498
497
|
.enablePositionalOptions()
|
|
499
498
|
.passThroughOptions()
|
|
500
499
|
.allowUnknownOption(true)
|
package/dist/plugins-batch.cjs
CHANGED
|
@@ -237,9 +237,10 @@ const globPaths = async ({ globs, logger, pkgCwd, rootPath, }) => {
|
|
|
237
237
|
}
|
|
238
238
|
return { absRootPath, paths };
|
|
239
239
|
};
|
|
240
|
-
const execShellCommandBatch = async ({ command, getDotenvCliOptions, globs, ignoreErrors, list, logger, pkgCwd, rootPath, shell, }) => {
|
|
240
|
+
const execShellCommandBatch = async ({ command, getDotenvCliOptions, dotenvEnv, globs, ignoreErrors, list, logger, pkgCwd, rootPath, shell, }) => {
|
|
241
241
|
const capture = process.env.GETDOTENV_STDIO === 'pipe' ||
|
|
242
|
-
Boolean(getDotenvCliOptions?.capture);
|
|
242
|
+
Boolean(getDotenvCliOptions?.capture);
|
|
243
|
+
// Require a command only when not listing. In list mode, a command is optional.
|
|
243
244
|
if (!command && !list) {
|
|
244
245
|
logger.error(`No command provided. Use --command or --list.`);
|
|
245
246
|
process.exit(0);
|
|
@@ -286,12 +287,25 @@ const execShellCommandBatch = async ({ command, getDotenvCliOptions, globs, igno
|
|
|
286
287
|
const hasCmd = (typeof command === 'string' && command.length > 0) ||
|
|
287
288
|
(Array.isArray(command) && command.length > 0);
|
|
288
289
|
if (hasCmd) {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
290
|
+
// Compose child env overlay from dotenv (drop undefined) and merged options
|
|
291
|
+
const overlay = {};
|
|
292
|
+
if (dotenvEnv) {
|
|
293
|
+
for (const [k, v] of Object.entries(dotenvEnv)) {
|
|
294
|
+
if (typeof v === 'string')
|
|
295
|
+
overlay[k] = v;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
if (getDotenvCliOptions !== undefined) {
|
|
299
|
+
try {
|
|
300
|
+
overlay.getDotenvCliOptions = JSON.stringify(getDotenvCliOptions);
|
|
301
|
+
}
|
|
302
|
+
catch {
|
|
303
|
+
// best-effort: omit if serialization fails
|
|
304
|
+
}
|
|
305
|
+
}
|
|
292
306
|
await runCommand(command, shell, {
|
|
293
307
|
cwd: path,
|
|
294
|
-
env: buildSpawnEnv(process.env,
|
|
308
|
+
env: buildSpawnEnv(process.env, overlay),
|
|
295
309
|
stdio: capture ? 'pipe' : 'inherit',
|
|
296
310
|
});
|
|
297
311
|
}
|
|
@@ -357,6 +371,7 @@ const buildDefaultCmdAction = (cli, batchCmd, opts) => async (commandParts, _sub
|
|
|
357
371
|
const ctx = cli.getCtx();
|
|
358
372
|
const cfgRaw = (ctx?.pluginConfigs?.['batch'] ?? {});
|
|
359
373
|
const cfg = (cfgRaw || {});
|
|
374
|
+
const dotenvEnv = (ctx?.dotenv ?? {});
|
|
360
375
|
// Resolve batch flags from the captured parent (batch) command.
|
|
361
376
|
const raw = batchCmd.opts();
|
|
362
377
|
const listFromParent = !!raw.list;
|
|
@@ -375,6 +390,7 @@ const buildDefaultCmdAction = (cli, batchCmd, opts) => async (commandParts, _sub
|
|
|
375
390
|
if (typeof commandOpt === 'string') {
|
|
376
391
|
await execShellCommandBatch({
|
|
377
392
|
command: resolveCommand(scripts, commandOpt),
|
|
393
|
+
dotenvEnv,
|
|
378
394
|
globs,
|
|
379
395
|
ignoreErrors,
|
|
380
396
|
list: false,
|
|
@@ -386,6 +402,7 @@ const buildDefaultCmdAction = (cli, batchCmd, opts) => async (commandParts, _sub
|
|
|
386
402
|
return;
|
|
387
403
|
}
|
|
388
404
|
if (raw.list || localList) {
|
|
405
|
+
const shellBag = ((batchCmd.parent ?? undefined)?.getDotenvCliOptions ?? {});
|
|
389
406
|
await execShellCommandBatch({
|
|
390
407
|
globs,
|
|
391
408
|
ignoreErrors,
|
|
@@ -393,7 +410,7 @@ const buildDefaultCmdAction = (cli, batchCmd, opts) => async (commandParts, _sub
|
|
|
393
410
|
logger: loggerLocal,
|
|
394
411
|
...(pkgCwd ? { pkgCwd } : {}),
|
|
395
412
|
rootPath,
|
|
396
|
-
shell: (shell ?? false),
|
|
413
|
+
shell: (shell ?? shellBag.shell ?? false),
|
|
397
414
|
});
|
|
398
415
|
return;
|
|
399
416
|
}
|
|
@@ -460,6 +477,7 @@ const buildDefaultCmdAction = (cli, batchCmd, opts) => async (commandParts, _sub
|
|
|
460
477
|
}
|
|
461
478
|
await execShellCommandBatch({
|
|
462
479
|
command: commandArg,
|
|
480
|
+
dotenvEnv,
|
|
463
481
|
...(envBag ? { getDotenvCliOptions: envBag } : {}),
|
|
464
482
|
globs,
|
|
465
483
|
ignoreErrors,
|
|
@@ -478,6 +496,7 @@ const buildParentAction = (cli, opts) => async (commandParts, thisCommand) => {
|
|
|
478
496
|
const logger = opts.logger ?? console;
|
|
479
497
|
// Ensure context exists (host preSubcommand on root creates if missing).
|
|
480
498
|
const ctx = cli.getCtx();
|
|
499
|
+
const dotenvEnv = (ctx?.dotenv ?? {});
|
|
481
500
|
const cfgRaw = (ctx?.pluginConfigs?.['batch'] ?? {});
|
|
482
501
|
const cfg = (cfgRaw || {});
|
|
483
502
|
const raw = thisCommand.opts();
|
|
@@ -500,6 +519,7 @@ const buildParentAction = (cli, opts) => async (commandParts, thisCommand) => {
|
|
|
500
519
|
const commandArg = resolved;
|
|
501
520
|
await execShellCommandBatch({
|
|
502
521
|
command: commandArg,
|
|
522
|
+
dotenvEnv,
|
|
503
523
|
globs,
|
|
504
524
|
ignoreErrors,
|
|
505
525
|
list: false,
|
|
@@ -537,6 +557,7 @@ const buildParentAction = (cli, opts) => async (commandParts, thisCommand) => {
|
|
|
537
557
|
const shellOpt = opts.shell ?? cfg.shell ?? mergedBag.shell;
|
|
538
558
|
await execShellCommandBatch({
|
|
539
559
|
command: resolveCommand(scriptsOpt, commandOpt),
|
|
560
|
+
dotenvEnv,
|
|
540
561
|
globs,
|
|
541
562
|
ignoreErrors,
|
|
542
563
|
list,
|
|
@@ -580,7 +601,8 @@ const BatchConfigSchema = zod.z.object({
|
|
|
580
601
|
/**
|
|
581
602
|
* Batch plugin for the GetDotenv CLI host.
|
|
582
603
|
*
|
|
583
|
-
* Mirrors the legacy batch subcommand behavior without altering the shipped CLI.
|
|
604
|
+
* Mirrors the legacy batch subcommand behavior without altering the shipped CLI.
|
|
605
|
+
* Options:
|
|
584
606
|
* - scripts/shell: used to resolve command and shell behavior per script or global default.
|
|
585
607
|
* - logger: defaults to console.
|
|
586
608
|
*/
|
|
@@ -592,12 +614,32 @@ const batchPlugin = (opts = {}) => definePlugin({
|
|
|
592
614
|
setup(cli) {
|
|
593
615
|
const ns = cli.ns('batch');
|
|
594
616
|
const batchCmd = ns; // capture the parent "batch" command for default-subcommand context
|
|
617
|
+
const host = cli;
|
|
618
|
+
const pluginId = 'batch';
|
|
619
|
+
const GROUP = `plugin:${pluginId}`;
|
|
595
620
|
ns.description('Batch command execution across multiple working directories.')
|
|
596
621
|
.enablePositionalOptions()
|
|
597
622
|
.passThroughOptions()
|
|
598
|
-
|
|
599
|
-
.
|
|
600
|
-
.
|
|
623
|
+
// Dynamic help: show effective defaults from the merged/interpolated plugin config slice.
|
|
624
|
+
.addOption((() => {
|
|
625
|
+
const opt = host.createDynamicOption('-p, --pkg-cwd', (cfg) => {
|
|
626
|
+
const slice = cfg.plugins.batch ?? {};
|
|
627
|
+
const on = !!slice.pkgCwd;
|
|
628
|
+
return `use nearest package directory as current working directory${on ? ' (default)' : ''}`;
|
|
629
|
+
});
|
|
630
|
+
opt.__group = GROUP;
|
|
631
|
+
return opt;
|
|
632
|
+
})())
|
|
633
|
+
.addOption((() => {
|
|
634
|
+
const opt = host.createDynamicOption('-r, --root-path <string>', (cfg) => `path to batch root directory from current working directory (default: ${JSON.stringify(cfg.plugins.batch?.rootPath || './')})`);
|
|
635
|
+
opt.__group = GROUP;
|
|
636
|
+
return opt;
|
|
637
|
+
})())
|
|
638
|
+
.addOption((() => {
|
|
639
|
+
const opt = host.createDynamicOption('-g, --globs <string>', (cfg) => `space-delimited globs from root path (default: ${JSON.stringify(cfg.plugins.batch?.globs || '*')})`);
|
|
640
|
+
opt.__group = GROUP;
|
|
641
|
+
return opt;
|
|
642
|
+
})())
|
|
601
643
|
.option('-c, --command <string>', 'command executed according to the base shell resolution')
|
|
602
644
|
.option('-l, --list', 'list working directories without executing command')
|
|
603
645
|
.option('-e, --ignore-errors', 'ignore errors and continue with next path')
|
package/dist/plugins-batch.d.cts
CHANGED
|
@@ -1,76 +1,6 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { ZodType } from 'zod';
|
|
3
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
|
-
}
|
|
73
|
-
|
|
74
4
|
/**
|
|
75
5
|
* A minimal representation of an environment key/value mapping.
|
|
76
6
|
* Values may be `undefined` to represent "unset". */ type ProcessEnv = Record<string, string | undefined>;
|
|
@@ -165,14 +95,6 @@ interface GetDotenvOptions {
|
|
|
165
95
|
useConfigLoader?: boolean;
|
|
166
96
|
}
|
|
167
97
|
|
|
168
|
-
/** * Per-invocation context shared with plugins and actions. */
|
|
169
|
-
type GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> = {
|
|
170
|
-
optionsResolved: TOptions;
|
|
171
|
-
dotenv: ProcessEnv;
|
|
172
|
-
plugins?: Record<string, unknown>;
|
|
173
|
-
pluginConfigs?: Record<string, unknown>;
|
|
174
|
-
};
|
|
175
|
-
|
|
176
98
|
/** src/cliHost/definePlugin.ts
|
|
177
99
|
* Plugin contracts for the GetDotenv CLI host.
|
|
178
100
|
*
|
|
@@ -223,6 +145,14 @@ interface GetDotenvCliPlugin {
|
|
|
223
145
|
use: (child: GetDotenvCliPlugin) => GetDotenvCliPlugin;
|
|
224
146
|
}
|
|
225
147
|
|
|
148
|
+
/** * Per-invocation context shared with plugins and actions. */
|
|
149
|
+
type GetDotenvCliCtx<TOptions extends GetDotenvOptions = GetDotenvOptions> = {
|
|
150
|
+
optionsResolved: TOptions;
|
|
151
|
+
dotenv: ProcessEnv;
|
|
152
|
+
plugins?: Record<string, unknown>;
|
|
153
|
+
pluginConfigs?: Record<string, unknown>;
|
|
154
|
+
};
|
|
155
|
+
|
|
226
156
|
/**
|
|
227
157
|
* Batch services (neutral): resolve command and shell settings.
|
|
228
158
|
* Shared by the generator path and the batch plugin to avoid circular deps.
|
|
@@ -241,7 +171,8 @@ type BatchPluginOptions = {
|
|
|
241
171
|
/**
|
|
242
172
|
* Batch plugin for the GetDotenv CLI host.
|
|
243
173
|
*
|
|
244
|
-
* Mirrors the legacy batch subcommand behavior without altering the shipped CLI.
|
|
174
|
+
* Mirrors the legacy batch subcommand behavior without altering the shipped CLI.
|
|
175
|
+
* Options:
|
|
245
176
|
* - scripts/shell: used to resolve command and shell behavior per script or global default.
|
|
246
177
|
* - logger: defaults to console.
|
|
247
178
|
*/
|