@karmaniverous/get-dotenv 7.0.7 → 7.0.9
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/dist/chunks/{createCli-DRgcaM2D.mjs → createCli-CCxTLJ1j.mjs} +57 -10
- package/dist/chunks/index-Cay5Gzhu.mjs +111 -0
- package/dist/chunks/{index-BzoCat8h.mjs → index-xqvxTkr9.mjs} +6 -6
- package/dist/chunks/{loader-V1vbmtyw.mjs → loader-C3DtD6HB.mjs} +4 -2
- package/dist/chunks/{readDotenvCascade-Dgx4SC1p.mjs → readDotenvCascade-CfFPgLCp.mjs} +52 -21
- package/dist/chunks/{readMergedOptions-x80ltQO_.mjs → readMergedOptions-_hjyCNZ7.mjs} +54 -14
- package/dist/chunks/{resolveCliOptions-CR-BEUmS.mjs → resolveCliOptions-Dp7wPY1K.mjs} +1 -1
- package/dist/chunks/{spawnEnv-CKgnHGpr.mjs → spawnEnv-DvisqPiU.mjs} +28 -3
- package/dist/chunks/{types-poB1VAs_.mjs → types-zXDNhcST.mjs} +1 -1
- package/dist/cli.d.ts +9 -5
- package/dist/cli.mjs +10 -15
- package/dist/cliHost.d.ts +9 -5
- package/dist/cliHost.mjs +6 -6
- package/dist/config.d.ts +1 -1
- package/dist/config.mjs +1 -1
- package/dist/env-overlay.d.ts +13 -9
- package/dist/env-overlay.mjs +2 -2
- package/dist/getdotenv.cli.mjs +10 -15
- package/dist/index.d.ts +10 -6
- package/dist/index.mjs +30 -23
- package/dist/plugins-aws.d.ts +1 -1
- package/dist/plugins-aws.mjs +4 -4
- package/dist/plugins-batch.d.ts +17 -1
- package/dist/plugins-batch.mjs +202 -68
- package/dist/plugins-cmd.d.ts +1 -1
- package/dist/plugins-cmd.mjs +6 -6
- package/dist/plugins-init.d.ts +1 -1
- package/dist/plugins-init.mjs +3 -3
- package/dist/plugins.d.ts +3 -1
- package/dist/plugins.mjs +9 -14
- package/package.json +40 -40
- package/schema/getdotenv.config.schema.json +207 -0
- package/dist/chunks/AwsRestJsonProtocol-BWWvLZiw.mjs +0 -1026
- package/dist/chunks/externalDataInterceptor-Bbvq4sdd.mjs +0 -19
- package/dist/chunks/getSSOTokenFromFile-ClTzvS3i.mjs +0 -22
- package/dist/chunks/index-4kbkrHS9.mjs +0 -12529
- package/dist/chunks/index-B5GwHCSX.mjs +0 -669
- package/dist/chunks/index-Cl6wXPYD.mjs +0 -82
- package/dist/chunks/index-D7Lv-lxm.mjs +0 -349
- package/dist/chunks/index-DFNP_Nrx.mjs +0 -188
- package/dist/chunks/index-DO68RbZ8.mjs +0 -103
- package/dist/chunks/index-Db08BBL5.mjs +0 -519
- package/dist/chunks/index-De2jIOhi.mjs +0 -541
- package/dist/chunks/index-IOQ1o3w3.mjs +0 -290
- package/dist/chunks/index-Tm4WDj9R.mjs +0 -383
- package/dist/chunks/index-fNrNPp4e.mjs +0 -946
- package/dist/chunks/index-w8gK2SKP.mjs +0 -31
- package/dist/chunks/loadSso-Ce3ChPPj.mjs +0 -488
- package/dist/chunks/package-DbbYaehr.mjs +0 -5
- package/dist/chunks/parseKnownFiles-BCL0L7aP.mjs +0 -23
- package/dist/chunks/sdk-stream-mixin-B_ajKWho.mjs +0 -307
package/dist/plugins-batch.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as readMergedOptions,
|
|
1
|
+
import { r as readMergedOptions, d as definePlugin } from './chunks/readMergedOptions-_hjyCNZ7.mjs';
|
|
2
2
|
import 'execa';
|
|
3
3
|
import 'radash';
|
|
4
4
|
import 'node:buffer';
|
|
@@ -10,16 +10,56 @@ import 'url';
|
|
|
10
10
|
import { Command } from '@commander-js/extra-typings';
|
|
11
11
|
import 'nanoid';
|
|
12
12
|
import 'dotenv';
|
|
13
|
-
import './chunks/loader-
|
|
13
|
+
import './chunks/loader-C3DtD6HB.mjs';
|
|
14
14
|
import { packageDirectory } from 'package-directory';
|
|
15
15
|
import 'yaml';
|
|
16
16
|
import { z } from 'zod';
|
|
17
17
|
import { c as composeNestedEnv, m as maybePreserveNodeEvalArgv } from './chunks/invoke-DuRPU1oC.mjs';
|
|
18
|
-
import { c as runCommand,
|
|
18
|
+
import { b as buildSpawnEnv, c as runCommand, d as runCommandResult, a as resolveShell, r as resolveCommand } from './chunks/spawnEnv-DvisqPiU.mjs';
|
|
19
19
|
import { globby } from 'globby';
|
|
20
|
-
import '
|
|
20
|
+
import os from 'os';
|
|
21
|
+
import './chunks/readDotenvCascade-CfFPgLCp.mjs';
|
|
21
22
|
import './chunks/loadModuleDefault-Dj8B3Stt.mjs';
|
|
22
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Default concurrency limit for parallel batch execution.
|
|
26
|
+
* Uses `os.availableParallelism()` when available, otherwise falls back to CPU count.
|
|
27
|
+
*/
|
|
28
|
+
const defaultConcurrency = typeof os.availableParallelism === 'function'
|
|
29
|
+
? os.availableParallelism()
|
|
30
|
+
: os.cpus().length;
|
|
31
|
+
/**
|
|
32
|
+
* Zod schema for a single script entry (string or object).
|
|
33
|
+
*/
|
|
34
|
+
const ScriptSchema = z.union([
|
|
35
|
+
z.string(),
|
|
36
|
+
z.object({
|
|
37
|
+
/** Command string to execute. */
|
|
38
|
+
cmd: z.string(),
|
|
39
|
+
/** Optional shell override for this script entry. */
|
|
40
|
+
shell: z.union([z.string(), z.boolean()]).optional(),
|
|
41
|
+
}),
|
|
42
|
+
]);
|
|
43
|
+
/**
|
|
44
|
+
* Zod schema for batch plugin configuration.
|
|
45
|
+
*/
|
|
46
|
+
const batchPluginConfigSchema = z.object({
|
|
47
|
+
/** Maximum concurrent executions in parallel mode. */
|
|
48
|
+
concurrency: z.number().int().positive().optional(),
|
|
49
|
+
/** Optional scripts table scoped to the batch plugin. */
|
|
50
|
+
scripts: z.record(z.string(), ScriptSchema).optional(),
|
|
51
|
+
/** Optional default shell for batch execution (overridden by per-script shell when present). */
|
|
52
|
+
shell: z.union([z.string(), z.boolean()]).optional(),
|
|
53
|
+
/** Root path for discovery, relative to CWD (or package root when pkgCwd is true). */
|
|
54
|
+
rootPath: z.string().optional(),
|
|
55
|
+
/** Space-delimited glob patterns used to discover directories. */
|
|
56
|
+
globs: z.string().optional(),
|
|
57
|
+
/** Execute commands in parallel across discovered directories. */
|
|
58
|
+
parallel: z.boolean().optional(),
|
|
59
|
+
/** When true, resolve the batch root from the nearest package directory. */
|
|
60
|
+
pkgCwd: z.boolean().optional(),
|
|
61
|
+
});
|
|
62
|
+
|
|
23
63
|
const globPaths = async ({ globs, logger, pkgCwd, rootPath, }) => {
|
|
24
64
|
let cwd = process.cwd();
|
|
25
65
|
if (pkgCwd) {
|
|
@@ -47,7 +87,7 @@ const globPaths = async ({ globs, logger, pkgCwd, rootPath, }) => {
|
|
|
47
87
|
* Execute a batch of commands across multiple directories.
|
|
48
88
|
* Discovers targets via globs/rootPath and runs the command in each.
|
|
49
89
|
*/
|
|
50
|
-
const execShellCommandBatch = async ({ command, getDotenvCliOptions, dotenvEnv, globs, ignoreErrors, list, logger, pkgCwd, rootPath, shell, }) => {
|
|
90
|
+
const execShellCommandBatch = async ({ command, concurrency, getDotenvCliOptions, dotenvEnv, globs, ignoreErrors, list, logger, parallel, pkgCwd, rootPath, shell, }) => {
|
|
51
91
|
const capture = process.env.GETDOTENV_STDIO === 'pipe' ||
|
|
52
92
|
Boolean(getDotenvCliOptions?.capture);
|
|
53
93
|
// Require a command only when not listing. In list mode, a command is optional.
|
|
@@ -64,7 +104,9 @@ const execShellCommandBatch = async ({ command, getDotenvCliOptions, dotenvEnv,
|
|
|
64
104
|
});
|
|
65
105
|
const headerTitle = list
|
|
66
106
|
? 'Listing working directories...'
|
|
67
|
-
:
|
|
107
|
+
: parallel
|
|
108
|
+
? 'Executing command batch (parallel)...'
|
|
109
|
+
: 'Executing command batch...';
|
|
68
110
|
logger.info('');
|
|
69
111
|
const headerRootPath = `ROOT: ${absRootPath}`;
|
|
70
112
|
const headerGlobs = `GLOBS: ${globs}`;
|
|
@@ -81,39 +123,130 @@ const execShellCommandBatch = async ({ command, getDotenvCliOptions, dotenvEnv,
|
|
|
81
123
|
logger.info(headerRootPath);
|
|
82
124
|
logger.info(headerGlobs);
|
|
83
125
|
logger.info(headerCommand);
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
logger.info(pathLabel);
|
|
89
|
-
continue;
|
|
126
|
+
// List mode: no parallelism needed.
|
|
127
|
+
if (list) {
|
|
128
|
+
for (const p of paths) {
|
|
129
|
+
logger.info(`CWD: ${p}`);
|
|
90
130
|
}
|
|
91
131
|
logger.info('');
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
// Narrow command to a non-empty string or array after validation.
|
|
135
|
+
const validCommand = typeof command === 'string' && command.length > 0
|
|
136
|
+
? command
|
|
137
|
+
: Array.isArray(command) && command.length > 0
|
|
138
|
+
? command
|
|
139
|
+
: undefined;
|
|
140
|
+
if (!validCommand) {
|
|
141
|
+
logger.error(`No command provided. Use --command or --list.`);
|
|
142
|
+
process.exit(0);
|
|
143
|
+
}
|
|
144
|
+
// Compose child env overlay once (shared across all paths).
|
|
145
|
+
const overlay = composeNestedEnv(getDotenvCliOptions ?? {}, dotenvEnv ?? {});
|
|
146
|
+
const spawnEnv = buildSpawnEnv(process.env, overlay);
|
|
147
|
+
if (parallel) {
|
|
148
|
+
// Parallel execution with concurrency-limited pool.
|
|
149
|
+
const limit = concurrency ?? defaultConcurrency;
|
|
150
|
+
const results = [];
|
|
151
|
+
// Simple semaphore-based concurrency pool.
|
|
152
|
+
let active = 0;
|
|
153
|
+
let nextIdx = 0;
|
|
154
|
+
const total = paths.length;
|
|
155
|
+
results.length = total;
|
|
156
|
+
await new Promise((resolveAll, rejectAll) => {
|
|
157
|
+
let settled = false;
|
|
158
|
+
let completedCount = 0;
|
|
159
|
+
const tryLaunch = () => {
|
|
160
|
+
while (active < limit && nextIdx < total) {
|
|
161
|
+
const idx = nextIdx++;
|
|
162
|
+
const dirPath = paths[idx];
|
|
163
|
+
active++;
|
|
164
|
+
runCommandResult(validCommand, shell, {
|
|
165
|
+
cwd: dirPath,
|
|
166
|
+
env: spawnEnv,
|
|
167
|
+
})
|
|
168
|
+
.then((res) => {
|
|
169
|
+
results[idx] = {
|
|
170
|
+
dirPath,
|
|
171
|
+
exitCode: res.exitCode,
|
|
172
|
+
stdout: res.stdout,
|
|
173
|
+
stderr: res.stderr,
|
|
174
|
+
};
|
|
175
|
+
})
|
|
176
|
+
.catch((err) => {
|
|
177
|
+
results[idx] = {
|
|
178
|
+
dirPath,
|
|
179
|
+
exitCode: 1,
|
|
180
|
+
stdout: '',
|
|
181
|
+
stderr: String(err),
|
|
182
|
+
error: err,
|
|
183
|
+
};
|
|
184
|
+
})
|
|
185
|
+
.finally(() => {
|
|
186
|
+
active--;
|
|
187
|
+
completedCount++;
|
|
188
|
+
if (completedCount === total && !settled) {
|
|
189
|
+
settled = true;
|
|
190
|
+
resolveAll();
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
tryLaunch();
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
if (total === 0) {
|
|
199
|
+
resolveAll();
|
|
107
200
|
}
|
|
108
201
|
else {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
202
|
+
tryLaunch();
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
// Print results in discovery order.
|
|
206
|
+
const failures = [];
|
|
207
|
+
for (const result of results) {
|
|
208
|
+
const pathLabel = `CWD: ${result.dirPath}`;
|
|
209
|
+
logger.info('');
|
|
210
|
+
logger.info('*'.repeat(pathLabel.length));
|
|
211
|
+
logger.info(pathLabel);
|
|
212
|
+
logger.info(headerCommand);
|
|
213
|
+
if (result.stdout) {
|
|
214
|
+
process.stdout.write(result.stdout + (result.stdout.endsWith('\n') ? '' : '\n'));
|
|
215
|
+
}
|
|
216
|
+
if (result.stderr) {
|
|
217
|
+
process.stderr.write(result.stderr + (result.stderr.endsWith('\n') ? '' : '\n'));
|
|
218
|
+
}
|
|
219
|
+
if (result.exitCode !== 0) {
|
|
220
|
+
failures.push(result);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
if (failures.length > 0 && !ignoreErrors) {
|
|
224
|
+
logger.error('');
|
|
225
|
+
logger.error(`${String(failures.length)} of ${String(total)} directories failed:`);
|
|
226
|
+
for (const f of failures) {
|
|
227
|
+
logger.error(` ${f.dirPath} (exit code ${String(f.exitCode)})`);
|
|
112
228
|
}
|
|
113
229
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
// Sequential execution (original behavior).
|
|
233
|
+
for (const p of paths) {
|
|
234
|
+
const pathLabel = `CWD: ${p}`;
|
|
235
|
+
logger.info('');
|
|
236
|
+
logger.info('*'.repeat(pathLabel.length));
|
|
237
|
+
logger.info(pathLabel);
|
|
238
|
+
logger.info(headerCommand);
|
|
239
|
+
try {
|
|
240
|
+
await runCommand(validCommand, shell, {
|
|
241
|
+
cwd: p,
|
|
242
|
+
env: spawnEnv,
|
|
243
|
+
stdio: capture ? 'pipe' : 'inherit',
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
catch (error) {
|
|
247
|
+
if (!ignoreErrors) {
|
|
248
|
+
throw error;
|
|
249
|
+
}
|
|
117
250
|
}
|
|
118
251
|
}
|
|
119
252
|
}
|
|
@@ -153,6 +286,8 @@ const attachBatchCmdAction = (plugin, cli, batchCmd, pluginOpts, cmd) => {
|
|
|
153
286
|
: typeof cfg.rootPath === 'string'
|
|
154
287
|
? cfg.rootPath
|
|
155
288
|
: './';
|
|
289
|
+
const parallel = g.parallel !== undefined ? g.parallel : Boolean(cfg.parallel);
|
|
290
|
+
const concurrency = typeof g.concurrency === 'number' ? g.concurrency : cfg.concurrency;
|
|
156
291
|
// Resolve scripts/shell with precedence:
|
|
157
292
|
// plugin opts → plugin config → merged root CLI options
|
|
158
293
|
const scripts = pluginOpts.scripts ?? cfg.scripts ?? mergedBag.scripts ?? undefined;
|
|
@@ -163,11 +298,13 @@ const attachBatchCmdAction = (plugin, cli, batchCmd, pluginOpts, cmd) => {
|
|
|
163
298
|
if (typeof commandOpt === 'string') {
|
|
164
299
|
await execShellCommandBatch({
|
|
165
300
|
command: resolveCommand(scripts, commandOpt),
|
|
301
|
+
...(concurrency !== undefined ? { concurrency } : {}),
|
|
166
302
|
dotenvEnv,
|
|
167
303
|
globs,
|
|
168
304
|
ignoreErrors,
|
|
169
305
|
list: false,
|
|
170
306
|
logger,
|
|
307
|
+
parallel,
|
|
171
308
|
...(pkgCwd ? { pkgCwd } : {}),
|
|
172
309
|
rootPath,
|
|
173
310
|
shell: resolveShell(scripts, commandOpt, shell),
|
|
@@ -183,10 +320,12 @@ const attachBatchCmdAction = (plugin, cli, batchCmd, pluginOpts, cmd) => {
|
|
|
183
320
|
? rootShell
|
|
184
321
|
: false;
|
|
185
322
|
await execShellCommandBatch({
|
|
323
|
+
...(concurrency !== undefined ? { concurrency } : {}),
|
|
186
324
|
globs,
|
|
187
325
|
ignoreErrors,
|
|
188
326
|
list: true,
|
|
189
327
|
logger,
|
|
328
|
+
parallel,
|
|
190
329
|
...(pkgCwd ? { pkgCwd } : {}),
|
|
191
330
|
rootPath,
|
|
192
331
|
shell: listShell,
|
|
@@ -208,23 +347,29 @@ const attachBatchCmdAction = (plugin, cli, batchCmd, pluginOpts, cmd) => {
|
|
|
208
347
|
const shellExec = shell ?? mergedBag.shell;
|
|
209
348
|
const resolved = resolveCommand(scriptsExec, input);
|
|
210
349
|
const shellSetting = resolveShell(scriptsExec, input, shellExec);
|
|
211
|
-
// Preserve argv array
|
|
212
|
-
//
|
|
213
|
-
//
|
|
350
|
+
// Preserve argv array to avoid lossy re-tokenization (Windows/
|
|
351
|
+
// PowerShell quoting). When the command was not resolved to a script
|
|
352
|
+
// (i.e. resolved === input), keep the original argv tokens so that
|
|
353
|
+
// _execNormalized can pass them individually to execa — both in
|
|
354
|
+
// shell-off mode (where stripOuterQuotes handles argv) and in shell
|
|
355
|
+
// mode (where execa applies per-platform shell escaping per arg).
|
|
214
356
|
let commandArg = resolved;
|
|
215
|
-
if (
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
357
|
+
if (resolved === input) {
|
|
358
|
+
// Always pass the argv array to avoid lossy re-tokenization.
|
|
359
|
+
// For shell-off + node -e, apply outer-quote stripping first.
|
|
360
|
+
commandArg =
|
|
361
|
+
shellSetting === false ? maybePreserveNodeEvalArgv(args) : args;
|
|
219
362
|
}
|
|
220
363
|
await execShellCommandBatch({
|
|
221
364
|
command: commandArg,
|
|
365
|
+
...(concurrency !== undefined ? { concurrency } : {}),
|
|
222
366
|
dotenvEnv,
|
|
223
367
|
...(envBag ? { getDotenvCliOptions: envBag } : {}),
|
|
224
368
|
globs,
|
|
225
369
|
ignoreErrors,
|
|
226
370
|
list: false,
|
|
227
371
|
logger,
|
|
372
|
+
parallel,
|
|
228
373
|
...(pkgCwd ? { pkgCwd } : {}),
|
|
229
374
|
rootPath,
|
|
230
375
|
shell: shellSetting,
|
|
@@ -279,6 +424,8 @@ const attachBatchDefaultAction = (plugin, cli, pluginOpts, parent) => {
|
|
|
279
424
|
const ignoreErrors = Boolean(opts.ignoreErrors);
|
|
280
425
|
let globs = typeof opts.globs === 'string' ? opts.globs : (cfg.globs ?? '*');
|
|
281
426
|
const list = Boolean(opts.list);
|
|
427
|
+
const parallel = opts.parallel !== undefined ? opts.parallel : Boolean(cfg.parallel);
|
|
428
|
+
const concurrency = typeof opts.concurrency === 'number' ? opts.concurrency : cfg.concurrency;
|
|
282
429
|
const pkgCwd = opts.pkgCwd !== undefined ? opts.pkgCwd : Boolean(cfg.pkgCwd);
|
|
283
430
|
const rootPath = typeof opts.rootPath === 'string'
|
|
284
431
|
? opts.rootPath
|
|
@@ -297,11 +444,13 @@ const attachBatchDefaultAction = (plugin, cli, pluginOpts, parent) => {
|
|
|
297
444
|
const commandArg = resolved;
|
|
298
445
|
await execShellCommandBatch({
|
|
299
446
|
command: commandArg,
|
|
447
|
+
...(concurrency !== undefined ? { concurrency } : {}),
|
|
300
448
|
dotenvEnv,
|
|
301
449
|
globs,
|
|
302
450
|
ignoreErrors,
|
|
303
451
|
list: false,
|
|
304
452
|
logger,
|
|
453
|
+
parallel,
|
|
305
454
|
...(pkgCwd ? { pkgCwd } : {}),
|
|
306
455
|
rootPath,
|
|
307
456
|
shell: shellSetting,
|
|
@@ -316,10 +465,12 @@ const attachBatchDefaultAction = (plugin, cli, pluginOpts, parent) => {
|
|
|
316
465
|
globs = [globs, extra].filter(Boolean).join(' ');
|
|
317
466
|
const shellMerged = pluginOpts.shell ?? cfg.shell ?? merged.shell ?? false;
|
|
318
467
|
await execShellCommandBatch({
|
|
468
|
+
...(concurrency !== undefined ? { concurrency } : {}),
|
|
319
469
|
globs,
|
|
320
470
|
ignoreErrors,
|
|
321
471
|
list: true,
|
|
322
472
|
logger,
|
|
473
|
+
parallel,
|
|
323
474
|
...(pkgCwd ? { pkgCwd } : {}),
|
|
324
475
|
rootPath,
|
|
325
476
|
shell: shellMerged,
|
|
@@ -336,11 +487,13 @@ const attachBatchDefaultAction = (plugin, cli, pluginOpts, parent) => {
|
|
|
336
487
|
const shellOpt = pluginOpts.shell ?? cfg.shell ?? merged.shell;
|
|
337
488
|
await execShellCommandBatch({
|
|
338
489
|
command: resolveCommand(scriptsOpt, commandOpt),
|
|
490
|
+
...(concurrency !== undefined ? { concurrency } : {}),
|
|
339
491
|
dotenvEnv,
|
|
340
492
|
globs,
|
|
341
493
|
ignoreErrors,
|
|
342
494
|
list,
|
|
343
495
|
logger,
|
|
496
|
+
parallel,
|
|
344
497
|
...(pkgCwd ? { pkgCwd } : {}),
|
|
345
498
|
rootPath,
|
|
346
499
|
shell: resolveShell(scriptsOpt, commandOpt, shellOpt),
|
|
@@ -351,10 +504,12 @@ const attachBatchDefaultAction = (plugin, cli, pluginOpts, parent) => {
|
|
|
351
504
|
// list only (explicit --list without --command)
|
|
352
505
|
const shellOnly = pluginOpts.shell ?? cfg.shell ?? merged.shell ?? false;
|
|
353
506
|
await execShellCommandBatch({
|
|
507
|
+
...(concurrency !== undefined ? { concurrency } : {}),
|
|
354
508
|
globs,
|
|
355
509
|
ignoreErrors,
|
|
356
510
|
list: true,
|
|
357
511
|
logger,
|
|
512
|
+
parallel,
|
|
358
513
|
...(pkgCwd ? { pkgCwd } : {}),
|
|
359
514
|
rootPath,
|
|
360
515
|
shell: shellOnly,
|
|
@@ -399,37 +554,16 @@ function attachBatchOptions(plugin, cli) {
|
|
|
399
554
|
.option('-c, --command <string>', 'command executed according to the base shell resolution')
|
|
400
555
|
.option('-l, --list', 'list working directories without executing command')
|
|
401
556
|
.option('-e, --ignore-errors', 'ignore errors and continue with next path')
|
|
557
|
+
.option('-P, --parallel', 'execute commands in parallel across directories')
|
|
558
|
+
.option('-C, --concurrency <n>', `max concurrent executions in parallel mode (default: ${String(defaultConcurrency)})`, (v) => {
|
|
559
|
+
const n = Number.parseInt(v, 10);
|
|
560
|
+
if (Number.isNaN(n) || n < 1)
|
|
561
|
+
throw new Error(`invalid concurrency: ${v}`);
|
|
562
|
+
return n;
|
|
563
|
+
})
|
|
402
564
|
.argument('[command...]'));
|
|
403
565
|
}
|
|
404
566
|
|
|
405
|
-
/**
|
|
406
|
-
* Zod schema for a single script entry (string or object).
|
|
407
|
-
*/
|
|
408
|
-
const ScriptSchema = z.union([
|
|
409
|
-
z.string(),
|
|
410
|
-
z.object({
|
|
411
|
-
/** Command string to execute. */
|
|
412
|
-
cmd: z.string(),
|
|
413
|
-
/** Optional shell override for this script entry. */
|
|
414
|
-
shell: z.union([z.string(), z.boolean()]).optional(),
|
|
415
|
-
}),
|
|
416
|
-
]);
|
|
417
|
-
/**
|
|
418
|
-
* Zod schema for batch plugin configuration.
|
|
419
|
-
*/
|
|
420
|
-
const batchPluginConfigSchema = z.object({
|
|
421
|
-
/** Optional scripts table scoped to the batch plugin. */
|
|
422
|
-
scripts: z.record(z.string(), ScriptSchema).optional(),
|
|
423
|
-
/** Optional default shell for batch execution (overridden by per-script shell when present). */
|
|
424
|
-
shell: z.union([z.string(), z.boolean()]).optional(),
|
|
425
|
-
/** Root path for discovery, relative to CWD (or package root when pkgCwd is true). */
|
|
426
|
-
rootPath: z.string().optional(),
|
|
427
|
-
/** Space-delimited glob patterns used to discover directories. */
|
|
428
|
-
globs: z.string().optional(),
|
|
429
|
-
/** When true, resolve the batch root from the nearest package directory. */
|
|
430
|
-
pkgCwd: z.boolean().optional(),
|
|
431
|
-
});
|
|
432
|
-
|
|
433
567
|
/**
|
|
434
568
|
* @packageDocumentation
|
|
435
569
|
* Batch plugin subpath. Provides the `batch` command for executing a command
|
package/dist/plugins-cmd.d.ts
CHANGED
|
@@ -272,7 +272,7 @@ type ProcessEnv = Record<string, string | undefined>;
|
|
|
272
272
|
* and the selected environment (if any), and returns either a string to set
|
|
273
273
|
* or `undefined` to unset/skip the variable.
|
|
274
274
|
*/
|
|
275
|
-
type GetDotenvDynamicFunction = (vars: ProcessEnv, env: string | undefined) => string | undefined;
|
|
275
|
+
type GetDotenvDynamicFunction = (vars: ProcessEnv, env: string | undefined) => string | null | undefined;
|
|
276
276
|
/**
|
|
277
277
|
* A map of dynamic variable definitions.
|
|
278
278
|
* Keys are variable names; values are either literal strings or functions.
|
package/dist/plugins-cmd.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'radash';
|
|
2
|
-
import './chunks/readMergedOptions-
|
|
2
|
+
import './chunks/readMergedOptions-_hjyCNZ7.mjs';
|
|
3
3
|
import 'execa';
|
|
4
4
|
import 'node:buffer';
|
|
5
5
|
import 'fs-extra';
|
|
@@ -10,13 +10,13 @@ import 'url';
|
|
|
10
10
|
import '@commander-js/extra-typings';
|
|
11
11
|
import 'nanoid';
|
|
12
12
|
import 'dotenv';
|
|
13
|
-
import './chunks/loader-
|
|
13
|
+
import './chunks/loader-C3DtD6HB.mjs';
|
|
14
14
|
import 'package-directory';
|
|
15
15
|
import 'yaml';
|
|
16
16
|
import 'zod';
|
|
17
|
-
export { c as cmdPlugin } from './chunks/index-
|
|
18
|
-
import './chunks/readDotenvCascade-
|
|
17
|
+
export { c as cmdPlugin } from './chunks/index-xqvxTkr9.mjs';
|
|
18
|
+
import './chunks/readDotenvCascade-CfFPgLCp.mjs';
|
|
19
19
|
import './chunks/loadModuleDefault-Dj8B3Stt.mjs';
|
|
20
|
-
import './chunks/spawnEnv-
|
|
20
|
+
import './chunks/spawnEnv-DvisqPiU.mjs';
|
|
21
21
|
import './chunks/invoke-DuRPU1oC.mjs';
|
|
22
|
-
import './chunks/resolveCliOptions-
|
|
22
|
+
import './chunks/resolveCliOptions-Dp7wPY1K.mjs';
|
package/dist/plugins-init.d.ts
CHANGED
|
@@ -272,7 +272,7 @@ type ProcessEnv = Record<string, string | undefined>;
|
|
|
272
272
|
* and the selected environment (if any), and returns either a string to set
|
|
273
273
|
* or `undefined` to unset/skip the variable.
|
|
274
274
|
*/
|
|
275
|
-
type GetDotenvDynamicFunction = (vars: ProcessEnv, env: string | undefined) => string | undefined;
|
|
275
|
+
type GetDotenvDynamicFunction = (vars: ProcessEnv, env: string | undefined) => string | null | undefined;
|
|
276
276
|
/**
|
|
277
277
|
* A map of dynamic variable definitions.
|
|
278
278
|
* Keys are variable names; values are either literal strings or functions.
|
package/dist/plugins-init.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as readMergedOptions,
|
|
1
|
+
import { r as readMergedOptions, d as definePlugin } from './chunks/readMergedOptions-_hjyCNZ7.mjs';
|
|
2
2
|
import 'execa';
|
|
3
3
|
import 'radash';
|
|
4
4
|
import 'node:buffer';
|
|
@@ -10,14 +10,14 @@ import 'url';
|
|
|
10
10
|
import '@commander-js/extra-typings';
|
|
11
11
|
import 'nanoid';
|
|
12
12
|
import 'dotenv';
|
|
13
|
-
import './chunks/loader-
|
|
13
|
+
import './chunks/loader-C3DtD6HB.mjs';
|
|
14
14
|
import { packageDirectory } from 'package-directory';
|
|
15
15
|
import 'yaml';
|
|
16
16
|
import 'zod';
|
|
17
17
|
import { stdin, stdout } from 'node:process';
|
|
18
18
|
import { createInterface } from 'readline/promises';
|
|
19
19
|
import { fileURLToPath } from 'node:url';
|
|
20
|
-
import './chunks/readDotenvCascade-
|
|
20
|
+
import './chunks/readDotenvCascade-CfFPgLCp.mjs';
|
|
21
21
|
import './chunks/loadModuleDefault-Dj8B3Stt.mjs';
|
|
22
22
|
|
|
23
23
|
/**
|
package/dist/plugins.d.ts
CHANGED
|
@@ -272,7 +272,7 @@ type ProcessEnv = Record<string, string | undefined>;
|
|
|
272
272
|
* and the selected environment (if any), and returns either a string to set
|
|
273
273
|
* or `undefined` to unset/skip the variable.
|
|
274
274
|
*/
|
|
275
|
-
type GetDotenvDynamicFunction = (vars: ProcessEnv, env: string | undefined) => string | undefined;
|
|
275
|
+
type GetDotenvDynamicFunction = (vars: ProcessEnv, env: string | undefined) => string | null | undefined;
|
|
276
276
|
/**
|
|
277
277
|
* A map of dynamic variable definitions.
|
|
278
278
|
* Keys are variable names; values are either literal strings or functions.
|
|
@@ -570,6 +570,7 @@ interface BatchPluginOptions {
|
|
|
570
570
|
* - scripts/shell: used to resolve command and shell behavior per script or global default.
|
|
571
571
|
*/
|
|
572
572
|
declare const batchPlugin: (opts?: BatchPluginOptions) => PluginWithInstanceHelpers<GetDotenvOptions, {
|
|
573
|
+
concurrency?: number | undefined;
|
|
573
574
|
scripts?: Record<string, string | {
|
|
574
575
|
cmd: string;
|
|
575
576
|
shell?: string | boolean | undefined;
|
|
@@ -577,6 +578,7 @@ declare const batchPlugin: (opts?: BatchPluginOptions) => PluginWithInstanceHelp
|
|
|
577
578
|
shell?: string | boolean | undefined;
|
|
578
579
|
rootPath?: string | undefined;
|
|
579
580
|
globs?: string | undefined;
|
|
581
|
+
parallel?: boolean | undefined;
|
|
580
582
|
pkgCwd?: boolean | undefined;
|
|
581
583
|
}, [], {}, {}>;
|
|
582
584
|
|
package/dist/plugins.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export { awsPlugin, getAwsRegion } from './plugins-aws.mjs';
|
|
2
|
-
export {
|
|
2
|
+
export { a as awsWhoamiPlugin } from './chunks/index-Cay5Gzhu.mjs';
|
|
3
3
|
export { batchPlugin } from './plugins-batch.mjs';
|
|
4
|
-
export { c as cmdPlugin } from './chunks/index-
|
|
4
|
+
export { c as cmdPlugin } from './chunks/index-xqvxTkr9.mjs';
|
|
5
5
|
export { initPlugin } from './plugins-init.mjs';
|
|
6
|
-
import './chunks/readMergedOptions-
|
|
6
|
+
import './chunks/readMergedOptions-_hjyCNZ7.mjs';
|
|
7
7
|
import 'zod';
|
|
8
8
|
import '@commander-js/extra-typings';
|
|
9
|
-
import './chunks/readDotenvCascade-
|
|
9
|
+
import './chunks/readDotenvCascade-CfFPgLCp.mjs';
|
|
10
10
|
import 'fs-extra';
|
|
11
11
|
import 'radash';
|
|
12
12
|
import 'node:buffer';
|
|
@@ -17,20 +17,15 @@ import 'path';
|
|
|
17
17
|
import 'url';
|
|
18
18
|
import 'dotenv';
|
|
19
19
|
import 'nanoid';
|
|
20
|
-
import './chunks/loader-
|
|
20
|
+
import './chunks/loader-C3DtD6HB.mjs';
|
|
21
21
|
import 'package-directory';
|
|
22
22
|
import 'yaml';
|
|
23
23
|
import 'execa';
|
|
24
|
-
import './chunks/spawnEnv-
|
|
25
|
-
import 'node:os';
|
|
26
|
-
import 'node:fs/promises';
|
|
27
|
-
import 'node:stream';
|
|
28
|
-
import 'node:crypto';
|
|
29
|
-
import 'node:fs';
|
|
30
|
-
import 'node:https';
|
|
31
|
-
import 'node:process';
|
|
24
|
+
import './chunks/spawnEnv-DvisqPiU.mjs';
|
|
32
25
|
import './chunks/invoke-DuRPU1oC.mjs';
|
|
33
26
|
import 'globby';
|
|
34
|
-
import '
|
|
27
|
+
import 'os';
|
|
28
|
+
import './chunks/resolveCliOptions-Dp7wPY1K.mjs';
|
|
29
|
+
import 'node:process';
|
|
35
30
|
import 'readline/promises';
|
|
36
31
|
import 'node:url';
|