@baton-dx/cli 0.4.4 → 0.6.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.
@@ -1,4526 +0,0 @@
1
- #!/usr/bin/env node
2
- import { n as __require, r as __toESM, t as __commonJSMin } from "./chunk-BbwQpWto.mjs";
3
- import { normalize } from "node:path";
4
- import { Buffer as Buffer$1 } from "node:buffer";
5
- import { spawn } from "child_process";
6
- import { EventEmitter } from "node:events";
7
-
8
- //#region ../../node_modules/.bun/ms@2.1.3/node_modules/ms/index.js
9
- var require_ms = /* @__PURE__ */ __commonJSMin(((exports, module) => {
10
- /**
11
- * Helpers.
12
- */
13
- var s = 1e3;
14
- var m = s * 60;
15
- var h = m * 60;
16
- var d = h * 24;
17
- var w = d * 7;
18
- var y = d * 365.25;
19
- /**
20
- * Parse or format the given `val`.
21
- *
22
- * Options:
23
- *
24
- * - `long` verbose formatting [false]
25
- *
26
- * @param {String|Number} val
27
- * @param {Object} [options]
28
- * @throws {Error} throw an error if val is not a non-empty string or a number
29
- * @return {String|Number}
30
- * @api public
31
- */
32
- module.exports = function(val, options) {
33
- options = options || {};
34
- var type = typeof val;
35
- if (type === "string" && val.length > 0) return parse(val);
36
- else if (type === "number" && isFinite(val)) return options.long ? fmtLong(val) : fmtShort(val);
37
- throw new Error("val is not a non-empty string or a valid number. val=" + JSON.stringify(val));
38
- };
39
- /**
40
- * Parse the given `str` and return milliseconds.
41
- *
42
- * @param {String} str
43
- * @return {Number}
44
- * @api private
45
- */
46
- function parse(str) {
47
- str = String(str);
48
- if (str.length > 100) return;
49
- var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(str);
50
- if (!match) return;
51
- var n = parseFloat(match[1]);
52
- switch ((match[2] || "ms").toLowerCase()) {
53
- case "years":
54
- case "year":
55
- case "yrs":
56
- case "yr":
57
- case "y": return n * y;
58
- case "weeks":
59
- case "week":
60
- case "w": return n * w;
61
- case "days":
62
- case "day":
63
- case "d": return n * d;
64
- case "hours":
65
- case "hour":
66
- case "hrs":
67
- case "hr":
68
- case "h": return n * h;
69
- case "minutes":
70
- case "minute":
71
- case "mins":
72
- case "min":
73
- case "m": return n * m;
74
- case "seconds":
75
- case "second":
76
- case "secs":
77
- case "sec":
78
- case "s": return n * s;
79
- case "milliseconds":
80
- case "millisecond":
81
- case "msecs":
82
- case "msec":
83
- case "ms": return n;
84
- default: return;
85
- }
86
- }
87
- /**
88
- * Short format for `ms`.
89
- *
90
- * @param {Number} ms
91
- * @return {String}
92
- * @api private
93
- */
94
- function fmtShort(ms) {
95
- var msAbs = Math.abs(ms);
96
- if (msAbs >= d) return Math.round(ms / d) + "d";
97
- if (msAbs >= h) return Math.round(ms / h) + "h";
98
- if (msAbs >= m) return Math.round(ms / m) + "m";
99
- if (msAbs >= s) return Math.round(ms / s) + "s";
100
- return ms + "ms";
101
- }
102
- /**
103
- * Long format for `ms`.
104
- *
105
- * @param {Number} ms
106
- * @return {String}
107
- * @api private
108
- */
109
- function fmtLong(ms) {
110
- var msAbs = Math.abs(ms);
111
- if (msAbs >= d) return plural(ms, msAbs, d, "day");
112
- if (msAbs >= h) return plural(ms, msAbs, h, "hour");
113
- if (msAbs >= m) return plural(ms, msAbs, m, "minute");
114
- if (msAbs >= s) return plural(ms, msAbs, s, "second");
115
- return ms + " ms";
116
- }
117
- /**
118
- * Pluralization helper.
119
- */
120
- function plural(ms, msAbs, n, name) {
121
- var isPlural = msAbs >= n * 1.5;
122
- return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
123
- }
124
- }));
125
-
126
- //#endregion
127
- //#region ../../node_modules/.bun/debug@4.4.3/node_modules/debug/src/common.js
128
- var require_common = /* @__PURE__ */ __commonJSMin(((exports, module) => {
129
- /**
130
- * This is the common logic for both the Node.js and web browser
131
- * implementations of `debug()`.
132
- */
133
- function setup(env) {
134
- createDebug.debug = createDebug;
135
- createDebug.default = createDebug;
136
- createDebug.coerce = coerce;
137
- createDebug.disable = disable;
138
- createDebug.enable = enable;
139
- createDebug.enabled = enabled;
140
- createDebug.humanize = require_ms();
141
- createDebug.destroy = destroy;
142
- Object.keys(env).forEach((key) => {
143
- createDebug[key] = env[key];
144
- });
145
- /**
146
- * The currently active debug mode names, and names to skip.
147
- */
148
- createDebug.names = [];
149
- createDebug.skips = [];
150
- /**
151
- * Map of special "%n" handling functions, for the debug "format" argument.
152
- *
153
- * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
154
- */
155
- createDebug.formatters = {};
156
- /**
157
- * Selects a color for a debug namespace
158
- * @param {String} namespace The namespace string for the debug instance to be colored
159
- * @return {Number|String} An ANSI color code for the given namespace
160
- * @api private
161
- */
162
- function selectColor(namespace) {
163
- let hash = 0;
164
- for (let i = 0; i < namespace.length; i++) {
165
- hash = (hash << 5) - hash + namespace.charCodeAt(i);
166
- hash |= 0;
167
- }
168
- return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
169
- }
170
- createDebug.selectColor = selectColor;
171
- /**
172
- * Create a debugger with the given `namespace`.
173
- *
174
- * @param {String} namespace
175
- * @return {Function}
176
- * @api public
177
- */
178
- function createDebug(namespace) {
179
- let prevTime;
180
- let enableOverride = null;
181
- let namespacesCache;
182
- let enabledCache;
183
- function debug(...args) {
184
- if (!debug.enabled) return;
185
- const self = debug;
186
- const curr = Number(/* @__PURE__ */ new Date());
187
- self.diff = curr - (prevTime || curr);
188
- self.prev = prevTime;
189
- self.curr = curr;
190
- prevTime = curr;
191
- args[0] = createDebug.coerce(args[0]);
192
- if (typeof args[0] !== "string") args.unshift("%O");
193
- let index = 0;
194
- args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
195
- if (match === "%%") return "%";
196
- index++;
197
- const formatter = createDebug.formatters[format];
198
- if (typeof formatter === "function") {
199
- const val = args[index];
200
- match = formatter.call(self, val);
201
- args.splice(index, 1);
202
- index--;
203
- }
204
- return match;
205
- });
206
- createDebug.formatArgs.call(self, args);
207
- (self.log || createDebug.log).apply(self, args);
208
- }
209
- debug.namespace = namespace;
210
- debug.useColors = createDebug.useColors();
211
- debug.color = createDebug.selectColor(namespace);
212
- debug.extend = extend;
213
- debug.destroy = createDebug.destroy;
214
- Object.defineProperty(debug, "enabled", {
215
- enumerable: true,
216
- configurable: false,
217
- get: () => {
218
- if (enableOverride !== null) return enableOverride;
219
- if (namespacesCache !== createDebug.namespaces) {
220
- namespacesCache = createDebug.namespaces;
221
- enabledCache = createDebug.enabled(namespace);
222
- }
223
- return enabledCache;
224
- },
225
- set: (v) => {
226
- enableOverride = v;
227
- }
228
- });
229
- if (typeof createDebug.init === "function") createDebug.init(debug);
230
- return debug;
231
- }
232
- function extend(namespace, delimiter) {
233
- const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
234
- newDebug.log = this.log;
235
- return newDebug;
236
- }
237
- /**
238
- * Enables a debug mode by namespaces. This can include modes
239
- * separated by a colon and wildcards.
240
- *
241
- * @param {String} namespaces
242
- * @api public
243
- */
244
- function enable(namespaces) {
245
- createDebug.save(namespaces);
246
- createDebug.namespaces = namespaces;
247
- createDebug.names = [];
248
- createDebug.skips = [];
249
- const split = (typeof namespaces === "string" ? namespaces : "").trim().replace(/\s+/g, ",").split(",").filter(Boolean);
250
- for (const ns of split) if (ns[0] === "-") createDebug.skips.push(ns.slice(1));
251
- else createDebug.names.push(ns);
252
- }
253
- /**
254
- * Checks if the given string matches a namespace template, honoring
255
- * asterisks as wildcards.
256
- *
257
- * @param {String} search
258
- * @param {String} template
259
- * @return {Boolean}
260
- */
261
- function matchesTemplate(search, template) {
262
- let searchIndex = 0;
263
- let templateIndex = 0;
264
- let starIndex = -1;
265
- let matchIndex = 0;
266
- while (searchIndex < search.length) if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === "*")) if (template[templateIndex] === "*") {
267
- starIndex = templateIndex;
268
- matchIndex = searchIndex;
269
- templateIndex++;
270
- } else {
271
- searchIndex++;
272
- templateIndex++;
273
- }
274
- else if (starIndex !== -1) {
275
- templateIndex = starIndex + 1;
276
- matchIndex++;
277
- searchIndex = matchIndex;
278
- } else return false;
279
- while (templateIndex < template.length && template[templateIndex] === "*") templateIndex++;
280
- return templateIndex === template.length;
281
- }
282
- /**
283
- * Disable debug output.
284
- *
285
- * @return {String} namespaces
286
- * @api public
287
- */
288
- function disable() {
289
- const namespaces = [...createDebug.names, ...createDebug.skips.map((namespace) => "-" + namespace)].join(",");
290
- createDebug.enable("");
291
- return namespaces;
292
- }
293
- /**
294
- * Returns true if the given mode name is enabled, false otherwise.
295
- *
296
- * @param {String} name
297
- * @return {Boolean}
298
- * @api public
299
- */
300
- function enabled(name) {
301
- for (const skip of createDebug.skips) if (matchesTemplate(name, skip)) return false;
302
- for (const ns of createDebug.names) if (matchesTemplate(name, ns)) return true;
303
- return false;
304
- }
305
- /**
306
- * Coerce `val`.
307
- *
308
- * @param {Mixed} val
309
- * @return {Mixed}
310
- * @api private
311
- */
312
- function coerce(val) {
313
- if (val instanceof Error) return val.stack || val.message;
314
- return val;
315
- }
316
- /**
317
- * XXX DO NOT USE. This is a temporary stub function.
318
- * XXX It WILL be removed in the next major release.
319
- */
320
- function destroy() {
321
- console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
322
- }
323
- createDebug.enable(createDebug.load());
324
- return createDebug;
325
- }
326
- module.exports = setup;
327
- }));
328
-
329
- //#endregion
330
- //#region ../../node_modules/.bun/debug@4.4.3/node_modules/debug/src/browser.js
331
- var require_browser = /* @__PURE__ */ __commonJSMin(((exports, module) => {
332
- /**
333
- * This is the web browser implementation of `debug()`.
334
- */
335
- exports.formatArgs = formatArgs;
336
- exports.save = save;
337
- exports.load = load;
338
- exports.useColors = useColors;
339
- exports.storage = localstorage();
340
- exports.destroy = (() => {
341
- let warned = false;
342
- return () => {
343
- if (!warned) {
344
- warned = true;
345
- console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
346
- }
347
- };
348
- })();
349
- /**
350
- * Colors.
351
- */
352
- exports.colors = [
353
- "#0000CC",
354
- "#0000FF",
355
- "#0033CC",
356
- "#0033FF",
357
- "#0066CC",
358
- "#0066FF",
359
- "#0099CC",
360
- "#0099FF",
361
- "#00CC00",
362
- "#00CC33",
363
- "#00CC66",
364
- "#00CC99",
365
- "#00CCCC",
366
- "#00CCFF",
367
- "#3300CC",
368
- "#3300FF",
369
- "#3333CC",
370
- "#3333FF",
371
- "#3366CC",
372
- "#3366FF",
373
- "#3399CC",
374
- "#3399FF",
375
- "#33CC00",
376
- "#33CC33",
377
- "#33CC66",
378
- "#33CC99",
379
- "#33CCCC",
380
- "#33CCFF",
381
- "#6600CC",
382
- "#6600FF",
383
- "#6633CC",
384
- "#6633FF",
385
- "#66CC00",
386
- "#66CC33",
387
- "#9900CC",
388
- "#9900FF",
389
- "#9933CC",
390
- "#9933FF",
391
- "#99CC00",
392
- "#99CC33",
393
- "#CC0000",
394
- "#CC0033",
395
- "#CC0066",
396
- "#CC0099",
397
- "#CC00CC",
398
- "#CC00FF",
399
- "#CC3300",
400
- "#CC3333",
401
- "#CC3366",
402
- "#CC3399",
403
- "#CC33CC",
404
- "#CC33FF",
405
- "#CC6600",
406
- "#CC6633",
407
- "#CC9900",
408
- "#CC9933",
409
- "#CCCC00",
410
- "#CCCC33",
411
- "#FF0000",
412
- "#FF0033",
413
- "#FF0066",
414
- "#FF0099",
415
- "#FF00CC",
416
- "#FF00FF",
417
- "#FF3300",
418
- "#FF3333",
419
- "#FF3366",
420
- "#FF3399",
421
- "#FF33CC",
422
- "#FF33FF",
423
- "#FF6600",
424
- "#FF6633",
425
- "#FF9900",
426
- "#FF9933",
427
- "#FFCC00",
428
- "#FFCC33"
429
- ];
430
- /**
431
- * Currently only WebKit-based Web Inspectors, Firefox >= v31,
432
- * and the Firebug extension (any Firefox version) are known
433
- * to support "%c" CSS customizations.
434
- *
435
- * TODO: add a `localStorage` variable to explicitly enable/disable colors
436
- */
437
- function useColors() {
438
- if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) return true;
439
- if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) return false;
440
- let m;
441
- return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || typeof navigator !== "undefined" && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31 || typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
442
- }
443
- /**
444
- * Colorize log arguments if enabled.
445
- *
446
- * @api public
447
- */
448
- function formatArgs(args) {
449
- args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module.exports.humanize(this.diff);
450
- if (!this.useColors) return;
451
- const c = "color: " + this.color;
452
- args.splice(1, 0, c, "color: inherit");
453
- let index = 0;
454
- let lastC = 0;
455
- args[0].replace(/%[a-zA-Z%]/g, (match) => {
456
- if (match === "%%") return;
457
- index++;
458
- if (match === "%c") lastC = index;
459
- });
460
- args.splice(lastC, 0, c);
461
- }
462
- /**
463
- * Invokes `console.debug()` when available.
464
- * No-op when `console.debug` is not a "function".
465
- * If `console.debug` is not available, falls back
466
- * to `console.log`.
467
- *
468
- * @api public
469
- */
470
- exports.log = console.debug || console.log || (() => {});
471
- /**
472
- * Save `namespaces`.
473
- *
474
- * @param {String} namespaces
475
- * @api private
476
- */
477
- function save(namespaces) {
478
- try {
479
- if (namespaces) exports.storage.setItem("debug", namespaces);
480
- else exports.storage.removeItem("debug");
481
- } catch (error) {}
482
- }
483
- /**
484
- * Load `namespaces`.
485
- *
486
- * @return {String} returns the previously persisted debug modes
487
- * @api private
488
- */
489
- function load() {
490
- let r;
491
- try {
492
- r = exports.storage.getItem("debug") || exports.storage.getItem("DEBUG");
493
- } catch (error) {}
494
- if (!r && typeof process !== "undefined" && "env" in process) r = process.env.DEBUG;
495
- return r;
496
- }
497
- /**
498
- * Localstorage attempts to return the localstorage.
499
- *
500
- * This is necessary because safari throws
501
- * when a user disables cookies/localstorage
502
- * and you attempt to access it.
503
- *
504
- * @return {LocalStorage}
505
- * @api private
506
- */
507
- function localstorage() {
508
- try {
509
- return localStorage;
510
- } catch (error) {}
511
- }
512
- module.exports = require_common()(exports);
513
- const { formatters } = module.exports;
514
- /**
515
- * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
516
- */
517
- formatters.j = function(v) {
518
- try {
519
- return JSON.stringify(v);
520
- } catch (error) {
521
- return "[UnexpectedJSONParseError]: " + error.message;
522
- }
523
- };
524
- }));
525
-
526
- //#endregion
527
- //#region ../../node_modules/.bun/has-flag@4.0.0/node_modules/has-flag/index.js
528
- var require_has_flag = /* @__PURE__ */ __commonJSMin(((exports, module) => {
529
- module.exports = (flag, argv = process.argv) => {
530
- const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
531
- const position = argv.indexOf(prefix + flag);
532
- const terminatorPosition = argv.indexOf("--");
533
- return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
534
- };
535
- }));
536
-
537
- //#endregion
538
- //#region ../../node_modules/.bun/supports-color@7.2.0/node_modules/supports-color/index.js
539
- var require_supports_color = /* @__PURE__ */ __commonJSMin(((exports, module) => {
540
- const os = __require("os");
541
- const tty$1 = __require("tty");
542
- const hasFlag = require_has_flag();
543
- const { env } = process;
544
- let forceColor;
545
- if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) forceColor = 0;
546
- else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) forceColor = 1;
547
- if ("FORCE_COLOR" in env) if (env.FORCE_COLOR === "true") forceColor = 1;
548
- else if (env.FORCE_COLOR === "false") forceColor = 0;
549
- else forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
550
- function translateLevel(level) {
551
- if (level === 0) return false;
552
- return {
553
- level,
554
- hasBasic: true,
555
- has256: level >= 2,
556
- has16m: level >= 3
557
- };
558
- }
559
- function supportsColor(haveStream, streamIsTTY) {
560
- if (forceColor === 0) return 0;
561
- if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) return 3;
562
- if (hasFlag("color=256")) return 2;
563
- if (haveStream && !streamIsTTY && forceColor === void 0) return 0;
564
- const min = forceColor || 0;
565
- if (env.TERM === "dumb") return min;
566
- if (process.platform === "win32") {
567
- const osRelease = os.release().split(".");
568
- if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) return Number(osRelease[2]) >= 14931 ? 3 : 2;
569
- return 1;
570
- }
571
- if ("CI" in env) {
572
- if ([
573
- "TRAVIS",
574
- "CIRCLECI",
575
- "APPVEYOR",
576
- "GITLAB_CI",
577
- "GITHUB_ACTIONS",
578
- "BUILDKITE"
579
- ].some((sign) => sign in env) || env.CI_NAME === "codeship") return 1;
580
- return min;
581
- }
582
- if ("TEAMCITY_VERSION" in env) return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
583
- if (env.COLORTERM === "truecolor") return 3;
584
- if ("TERM_PROGRAM" in env) {
585
- const version = parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
586
- switch (env.TERM_PROGRAM) {
587
- case "iTerm.app": return version >= 3 ? 3 : 2;
588
- case "Apple_Terminal": return 2;
589
- }
590
- }
591
- if (/-256(color)?$/i.test(env.TERM)) return 2;
592
- if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) return 1;
593
- if ("COLORTERM" in env) return 1;
594
- return min;
595
- }
596
- function getSupportLevel(stream) {
597
- return translateLevel(supportsColor(stream, stream && stream.isTTY));
598
- }
599
- module.exports = {
600
- supportsColor: getSupportLevel,
601
- stdout: translateLevel(supportsColor(true, tty$1.isatty(1))),
602
- stderr: translateLevel(supportsColor(true, tty$1.isatty(2)))
603
- };
604
- }));
605
-
606
- //#endregion
607
- //#region ../../node_modules/.bun/debug@4.4.3/node_modules/debug/src/node.js
608
- var require_node = /* @__PURE__ */ __commonJSMin(((exports, module) => {
609
- /**
610
- * Module dependencies.
611
- */
612
- const tty = __require("tty");
613
- const util = __require("util");
614
- /**
615
- * This is the Node.js implementation of `debug()`.
616
- */
617
- exports.init = init;
618
- exports.log = log;
619
- exports.formatArgs = formatArgs;
620
- exports.save = save;
621
- exports.load = load;
622
- exports.useColors = useColors;
623
- exports.destroy = util.deprecate(() => {}, "Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
624
- /**
625
- * Colors.
626
- */
627
- exports.colors = [
628
- 6,
629
- 2,
630
- 3,
631
- 4,
632
- 5,
633
- 1
634
- ];
635
- try {
636
- const supportsColor = require_supports_color();
637
- if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) exports.colors = [
638
- 20,
639
- 21,
640
- 26,
641
- 27,
642
- 32,
643
- 33,
644
- 38,
645
- 39,
646
- 40,
647
- 41,
648
- 42,
649
- 43,
650
- 44,
651
- 45,
652
- 56,
653
- 57,
654
- 62,
655
- 63,
656
- 68,
657
- 69,
658
- 74,
659
- 75,
660
- 76,
661
- 77,
662
- 78,
663
- 79,
664
- 80,
665
- 81,
666
- 92,
667
- 93,
668
- 98,
669
- 99,
670
- 112,
671
- 113,
672
- 128,
673
- 129,
674
- 134,
675
- 135,
676
- 148,
677
- 149,
678
- 160,
679
- 161,
680
- 162,
681
- 163,
682
- 164,
683
- 165,
684
- 166,
685
- 167,
686
- 168,
687
- 169,
688
- 170,
689
- 171,
690
- 172,
691
- 173,
692
- 178,
693
- 179,
694
- 184,
695
- 185,
696
- 196,
697
- 197,
698
- 198,
699
- 199,
700
- 200,
701
- 201,
702
- 202,
703
- 203,
704
- 204,
705
- 205,
706
- 206,
707
- 207,
708
- 208,
709
- 209,
710
- 214,
711
- 215,
712
- 220,
713
- 221
714
- ];
715
- } catch (error) {}
716
- /**
717
- * Build up the default `inspectOpts` object from the environment variables.
718
- *
719
- * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
720
- */
721
- exports.inspectOpts = Object.keys(process.env).filter((key) => {
722
- return /^debug_/i.test(key);
723
- }).reduce((obj, key) => {
724
- const prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, (_, k) => {
725
- return k.toUpperCase();
726
- });
727
- let val = process.env[key];
728
- if (/^(yes|on|true|enabled)$/i.test(val)) val = true;
729
- else if (/^(no|off|false|disabled)$/i.test(val)) val = false;
730
- else if (val === "null") val = null;
731
- else val = Number(val);
732
- obj[prop] = val;
733
- return obj;
734
- }, {});
735
- /**
736
- * Is stdout a TTY? Colored output is enabled when `true`.
737
- */
738
- function useColors() {
739
- return "colors" in exports.inspectOpts ? Boolean(exports.inspectOpts.colors) : tty.isatty(process.stderr.fd);
740
- }
741
- /**
742
- * Adds ANSI color escape codes if enabled.
743
- *
744
- * @api public
745
- */
746
- function formatArgs(args) {
747
- const { namespace: name, useColors } = this;
748
- if (useColors) {
749
- const c = this.color;
750
- const colorCode = "\x1B[3" + (c < 8 ? c : "8;5;" + c);
751
- const prefix = ` ${colorCode};1m${name} \u001B[0m`;
752
- args[0] = prefix + args[0].split("\n").join("\n" + prefix);
753
- args.push(colorCode + "m+" + module.exports.humanize(this.diff) + "\x1B[0m");
754
- } else args[0] = getDate() + name + " " + args[0];
755
- }
756
- function getDate() {
757
- if (exports.inspectOpts.hideDate) return "";
758
- return (/* @__PURE__ */ new Date()).toISOString() + " ";
759
- }
760
- /**
761
- * Invokes `util.formatWithOptions()` with the specified arguments and writes to stderr.
762
- */
763
- function log(...args) {
764
- return process.stderr.write(util.formatWithOptions(exports.inspectOpts, ...args) + "\n");
765
- }
766
- /**
767
- * Save `namespaces`.
768
- *
769
- * @param {String} namespaces
770
- * @api private
771
- */
772
- function save(namespaces) {
773
- if (namespaces) process.env.DEBUG = namespaces;
774
- else delete process.env.DEBUG;
775
- }
776
- /**
777
- * Load `namespaces`.
778
- *
779
- * @return {String} returns the previously persisted debug modes
780
- * @api private
781
- */
782
- function load() {
783
- return process.env.DEBUG;
784
- }
785
- /**
786
- * Init logic for `debug` instances.
787
- *
788
- * Create a new `inspectOpts` object in case `useColors` is set
789
- * differently for a particular `debug` instance.
790
- */
791
- function init(debug) {
792
- debug.inspectOpts = {};
793
- const keys = Object.keys(exports.inspectOpts);
794
- for (let i = 0; i < keys.length; i++) debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
795
- }
796
- module.exports = require_common()(exports);
797
- const { formatters } = module.exports;
798
- /**
799
- * Map %o to `util.inspect()`, all on a single line.
800
- */
801
- formatters.o = function(v) {
802
- this.inspectOpts.colors = this.useColors;
803
- return util.inspect(v, this.inspectOpts).split("\n").map((str) => str.trim()).join(" ");
804
- };
805
- /**
806
- * Map %O to `util.inspect()`, allowing multiple lines if needed.
807
- */
808
- formatters.O = function(v) {
809
- this.inspectOpts.colors = this.useColors;
810
- return util.inspect(v, this.inspectOpts);
811
- };
812
- }));
813
-
814
- //#endregion
815
- //#region ../../node_modules/.bun/debug@4.4.3/node_modules/debug/src/index.js
816
- var require_src$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
817
- /**
818
- * Detect Electron renderer / nwjs process, which is node, but we should
819
- * treat as a browser.
820
- */
821
- if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) module.exports = require_browser();
822
- else module.exports = require_node();
823
- }));
824
-
825
- //#endregion
826
- //#region ../../node_modules/.bun/@kwsites+file-exists@1.1.1/node_modules/@kwsites/file-exists/dist/src/index.js
827
- var require_src = /* @__PURE__ */ __commonJSMin(((exports) => {
828
- var __importDefault = exports && exports.__importDefault || function(mod) {
829
- return mod && mod.__esModule ? mod : { "default": mod };
830
- };
831
- Object.defineProperty(exports, "__esModule", { value: true });
832
- const fs_1 = __require("fs");
833
- const log = __importDefault(require_src$1()).default("@kwsites/file-exists");
834
- function check(path, isFile, isDirectory) {
835
- log(`checking %s`, path);
836
- try {
837
- const stat = fs_1.statSync(path);
838
- if (stat.isFile() && isFile) {
839
- log(`[OK] path represents a file`);
840
- return true;
841
- }
842
- if (stat.isDirectory() && isDirectory) {
843
- log(`[OK] path represents a directory`);
844
- return true;
845
- }
846
- log(`[FAIL] path represents something other than a file or directory`);
847
- return false;
848
- } catch (e) {
849
- if (e.code === "ENOENT") {
850
- log(`[FAIL] path is not accessible: %o`, e);
851
- return false;
852
- }
853
- log(`[FATAL] %o`, e);
854
- throw e;
855
- }
856
- }
857
- /**
858
- * Synchronous validation of a path existing either as a file or as a directory.
859
- *
860
- * @param {string} path The path to check
861
- * @param {number} type One or both of the exported numeric constants
862
- */
863
- function exists(path, type = exports.READABLE) {
864
- return check(path, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0);
865
- }
866
- exports.exists = exists;
867
- /**
868
- * Constant representing a file
869
- */
870
- exports.FILE = 1;
871
- /**
872
- * Constant representing a folder
873
- */
874
- exports.FOLDER = 2;
875
- /**
876
- * Constant representing either a file or a folder
877
- */
878
- exports.READABLE = exports.FILE + exports.FOLDER;
879
- }));
880
-
881
- //#endregion
882
- //#region ../../node_modules/.bun/@kwsites+file-exists@1.1.1/node_modules/@kwsites/file-exists/dist/index.js
883
- var require_dist$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
884
- function __export(m) {
885
- for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
886
- }
887
- Object.defineProperty(exports, "__esModule", { value: true });
888
- __export(require_src());
889
- }));
890
-
891
- //#endregion
892
- //#region ../../node_modules/.bun/@kwsites+promise-deferred@1.1.1/node_modules/@kwsites/promise-deferred/dist/index.js
893
- var require_dist = /* @__PURE__ */ __commonJSMin(((exports) => {
894
- Object.defineProperty(exports, "__esModule", { value: true });
895
- exports.createDeferred = exports.deferred = void 0;
896
- /**
897
- * Creates a new `DeferredPromise`
898
- *
899
- * ```typescript
900
- import {deferred} from '@kwsites/promise-deferred`;
901
- ```
902
- */
903
- function deferred() {
904
- let done;
905
- let fail;
906
- let status = "pending";
907
- return {
908
- promise: new Promise((_done, _fail) => {
909
- done = _done;
910
- fail = _fail;
911
- }),
912
- done(result) {
913
- if (status === "pending") {
914
- status = "resolved";
915
- done(result);
916
- }
917
- },
918
- fail(error) {
919
- if (status === "pending") {
920
- status = "rejected";
921
- fail(error);
922
- }
923
- },
924
- get fulfilled() {
925
- return status !== "pending";
926
- },
927
- get status() {
928
- return status;
929
- }
930
- };
931
- }
932
- exports.deferred = deferred;
933
- /**
934
- * Alias of the exported `deferred` function, to help consumers wanting to use `deferred` as the
935
- * local variable name rather than the factory import name, without needing to rename on import.
936
- *
937
- * ```typescript
938
- import {createDeferred} from '@kwsites/promise-deferred`;
939
- ```
940
- */
941
- exports.createDeferred = deferred;
942
- }));
943
-
944
- //#endregion
945
- //#region ../../node_modules/.bun/simple-git@3.30.0/node_modules/simple-git/dist/esm/index.js
946
- var import_dist = require_dist$1();
947
- var import_src = /* @__PURE__ */ __toESM(require_src$1(), 1);
948
- var import_dist$1 = require_dist();
949
- var __defProp = Object.defineProperty;
950
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
951
- var __getOwnPropNames = Object.getOwnPropertyNames;
952
- var __hasOwnProp = Object.prototype.hasOwnProperty;
953
- var __esm = (fn, res) => function __init() {
954
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
955
- };
956
- var __commonJS = (cb, mod) => function __require() {
957
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
958
- };
959
- var __export = (target, all) => {
960
- for (var name in all) __defProp(target, name, {
961
- get: all[name],
962
- enumerable: true
963
- });
964
- };
965
- var __copyProps = (to, from, except, desc) => {
966
- if (from && typeof from === "object" || typeof from === "function") {
967
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
968
- get: () => from[key],
969
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
970
- });
971
- }
972
- return to;
973
- };
974
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
975
- function pathspec(...paths) {
976
- const key = new String(paths);
977
- cache.set(key, paths);
978
- return key;
979
- }
980
- function isPathSpec(path) {
981
- return path instanceof String && cache.has(path);
982
- }
983
- function toPaths(pathSpec) {
984
- return cache.get(pathSpec) || [];
985
- }
986
- var cache;
987
- var init_pathspec = __esm({ "src/lib/args/pathspec.ts"() {
988
- "use strict";
989
- cache = /* @__PURE__ */ new WeakMap();
990
- } });
991
- var GitError;
992
- var init_git_error = __esm({ "src/lib/errors/git-error.ts"() {
993
- "use strict";
994
- GitError = class extends Error {
995
- constructor(task, message) {
996
- super(message);
997
- this.task = task;
998
- Object.setPrototypeOf(this, new.target.prototype);
999
- }
1000
- };
1001
- } });
1002
- var GitResponseError;
1003
- var init_git_response_error = __esm({ "src/lib/errors/git-response-error.ts"() {
1004
- "use strict";
1005
- init_git_error();
1006
- GitResponseError = class extends GitError {
1007
- constructor(git, message) {
1008
- super(void 0, message || String(git));
1009
- this.git = git;
1010
- }
1011
- };
1012
- } });
1013
- var TaskConfigurationError;
1014
- var init_task_configuration_error = __esm({ "src/lib/errors/task-configuration-error.ts"() {
1015
- "use strict";
1016
- init_git_error();
1017
- TaskConfigurationError = class extends GitError {
1018
- constructor(message) {
1019
- super(void 0, message);
1020
- }
1021
- };
1022
- } });
1023
- function asFunction(source) {
1024
- if (typeof source !== "function") return NOOP;
1025
- return source;
1026
- }
1027
- function isUserFunction(source) {
1028
- return typeof source === "function" && source !== NOOP;
1029
- }
1030
- function splitOn(input, char) {
1031
- const index = input.indexOf(char);
1032
- if (index <= 0) return [input, ""];
1033
- return [input.substr(0, index), input.substr(index + 1)];
1034
- }
1035
- function first(input, offset = 0) {
1036
- return isArrayLike(input) && input.length > offset ? input[offset] : void 0;
1037
- }
1038
- function last(input, offset = 0) {
1039
- if (isArrayLike(input) && input.length > offset) return input[input.length - 1 - offset];
1040
- }
1041
- function isArrayLike(input) {
1042
- return filterHasLength(input);
1043
- }
1044
- function toLinesWithContent(input = "", trimmed2 = true, separator = "\n") {
1045
- return input.split(separator).reduce((output, line) => {
1046
- const lineContent = trimmed2 ? line.trim() : line;
1047
- if (lineContent) output.push(lineContent);
1048
- return output;
1049
- }, []);
1050
- }
1051
- function forEachLineWithContent(input, callback) {
1052
- return toLinesWithContent(input, true).map((line) => callback(line));
1053
- }
1054
- function folderExists(path) {
1055
- return (0, import_dist.exists)(path, import_dist.FOLDER);
1056
- }
1057
- function append(target, item) {
1058
- if (Array.isArray(target)) {
1059
- if (!target.includes(item)) target.push(item);
1060
- } else target.add(item);
1061
- return item;
1062
- }
1063
- function including(target, item) {
1064
- if (Array.isArray(target) && !target.includes(item)) target.push(item);
1065
- return target;
1066
- }
1067
- function remove(target, item) {
1068
- if (Array.isArray(target)) {
1069
- const index = target.indexOf(item);
1070
- if (index >= 0) target.splice(index, 1);
1071
- } else target.delete(item);
1072
- return item;
1073
- }
1074
- function asArray(source) {
1075
- return Array.isArray(source) ? source : [source];
1076
- }
1077
- function asCamelCase(str) {
1078
- return str.replace(/[\s-]+(.)/g, (_all, chr) => {
1079
- return chr.toUpperCase();
1080
- });
1081
- }
1082
- function asStringArray(source) {
1083
- return asArray(source).map((item) => {
1084
- return item instanceof String ? item : String(item);
1085
- });
1086
- }
1087
- function asNumber(source, onNaN = 0) {
1088
- if (source == null) return onNaN;
1089
- const num = parseInt(source, 10);
1090
- return Number.isNaN(num) ? onNaN : num;
1091
- }
1092
- function prefixedArray(input, prefix) {
1093
- const output = [];
1094
- for (let i = 0, max = input.length; i < max; i++) output.push(prefix, input[i]);
1095
- return output;
1096
- }
1097
- function bufferToString(input) {
1098
- return (Array.isArray(input) ? Buffer$1.concat(input) : input).toString("utf-8");
1099
- }
1100
- function pick(source, properties) {
1101
- const out = {};
1102
- properties.forEach((key) => {
1103
- if (source[key] !== void 0) out[key] = source[key];
1104
- });
1105
- return out;
1106
- }
1107
- function delay(duration = 0) {
1108
- return new Promise((done) => setTimeout(done, duration));
1109
- }
1110
- function orVoid(input) {
1111
- if (input === false) return;
1112
- return input;
1113
- }
1114
- var NULL, NOOP, objectToString;
1115
- var init_util = __esm({ "src/lib/utils/util.ts"() {
1116
- "use strict";
1117
- init_argument_filters();
1118
- NULL = "\0";
1119
- NOOP = () => {};
1120
- objectToString = Object.prototype.toString.call.bind(Object.prototype.toString);
1121
- } });
1122
- function filterType(input, filter, def) {
1123
- if (filter(input)) return input;
1124
- return arguments.length > 2 ? def : void 0;
1125
- }
1126
- function filterPrimitives(input, omit) {
1127
- const type = isPathSpec(input) ? "string" : typeof input;
1128
- return /number|string|boolean/.test(type) && (!omit || !omit.includes(type));
1129
- }
1130
- function filterPlainObject(input) {
1131
- return !!input && objectToString(input) === "[object Object]";
1132
- }
1133
- function filterFunction(input) {
1134
- return typeof input === "function";
1135
- }
1136
- var filterArray, filterNumber, filterString, filterStringOrStringArray, filterHasLength;
1137
- var init_argument_filters = __esm({ "src/lib/utils/argument-filters.ts"() {
1138
- "use strict";
1139
- init_pathspec();
1140
- init_util();
1141
- filterArray = (input) => {
1142
- return Array.isArray(input);
1143
- };
1144
- filterNumber = (input) => {
1145
- return typeof input === "number";
1146
- };
1147
- filterString = (input) => {
1148
- return typeof input === "string";
1149
- };
1150
- filterStringOrStringArray = (input) => {
1151
- return filterString(input) || Array.isArray(input) && input.every(filterString);
1152
- };
1153
- filterHasLength = (input) => {
1154
- if (input == null || "number|boolean|function".includes(typeof input)) return false;
1155
- return typeof input.length === "number";
1156
- };
1157
- } });
1158
- var ExitCodes;
1159
- var init_exit_codes = __esm({ "src/lib/utils/exit-codes.ts"() {
1160
- "use strict";
1161
- ExitCodes = /* @__PURE__ */ ((ExitCodes2) => {
1162
- ExitCodes2[ExitCodes2["SUCCESS"] = 0] = "SUCCESS";
1163
- ExitCodes2[ExitCodes2["ERROR"] = 1] = "ERROR";
1164
- ExitCodes2[ExitCodes2["NOT_FOUND"] = -2] = "NOT_FOUND";
1165
- ExitCodes2[ExitCodes2["UNCLEAN"] = 128] = "UNCLEAN";
1166
- return ExitCodes2;
1167
- })(ExitCodes || {});
1168
- } });
1169
- var GitOutputStreams;
1170
- var init_git_output_streams = __esm({ "src/lib/utils/git-output-streams.ts"() {
1171
- "use strict";
1172
- GitOutputStreams = class _GitOutputStreams {
1173
- constructor(stdOut, stdErr) {
1174
- this.stdOut = stdOut;
1175
- this.stdErr = stdErr;
1176
- }
1177
- asStrings() {
1178
- return new _GitOutputStreams(this.stdOut.toString("utf8"), this.stdErr.toString("utf8"));
1179
- }
1180
- };
1181
- } });
1182
- function useMatchesDefault() {
1183
- throw new Error(`LineParser:useMatches not implemented`);
1184
- }
1185
- var LineParser, RemoteLineParser;
1186
- var init_line_parser = __esm({ "src/lib/utils/line-parser.ts"() {
1187
- "use strict";
1188
- LineParser = class {
1189
- constructor(regExp, useMatches) {
1190
- this.matches = [];
1191
- this.useMatches = useMatchesDefault;
1192
- this.parse = (line, target) => {
1193
- this.resetMatches();
1194
- if (!this._regExp.every((reg, index) => this.addMatch(reg, index, line(index)))) return false;
1195
- return this.useMatches(target, this.prepareMatches()) !== false;
1196
- };
1197
- this._regExp = Array.isArray(regExp) ? regExp : [regExp];
1198
- if (useMatches) this.useMatches = useMatches;
1199
- }
1200
- resetMatches() {
1201
- this.matches.length = 0;
1202
- }
1203
- prepareMatches() {
1204
- return this.matches;
1205
- }
1206
- addMatch(reg, index, line) {
1207
- const matched = line && reg.exec(line);
1208
- if (matched) this.pushMatch(index, matched);
1209
- return !!matched;
1210
- }
1211
- pushMatch(_index, matched) {
1212
- this.matches.push(...matched.slice(1));
1213
- }
1214
- };
1215
- RemoteLineParser = class extends LineParser {
1216
- addMatch(reg, index, line) {
1217
- return /^remote:\s/.test(String(line)) && super.addMatch(reg, index, line);
1218
- }
1219
- pushMatch(index, matched) {
1220
- if (index > 0 || matched.length > 1) super.pushMatch(index, matched);
1221
- }
1222
- };
1223
- } });
1224
- function createInstanceConfig(...options) {
1225
- const baseDir = process.cwd();
1226
- const config = Object.assign({
1227
- baseDir,
1228
- ...defaultOptions
1229
- }, ...options.filter((o) => typeof o === "object" && o));
1230
- config.baseDir = config.baseDir || baseDir;
1231
- config.trimmed = config.trimmed === true;
1232
- return config;
1233
- }
1234
- var defaultOptions;
1235
- var init_simple_git_options = __esm({ "src/lib/utils/simple-git-options.ts"() {
1236
- "use strict";
1237
- defaultOptions = {
1238
- binary: "git",
1239
- maxConcurrentProcesses: 5,
1240
- config: [],
1241
- trimmed: false
1242
- };
1243
- } });
1244
- function appendTaskOptions(options, commands = []) {
1245
- if (!filterPlainObject(options)) return commands;
1246
- return Object.keys(options).reduce((commands2, key) => {
1247
- const value = options[key];
1248
- if (isPathSpec(value)) commands2.push(value);
1249
- else if (filterPrimitives(value, ["boolean"])) commands2.push(key + "=" + value);
1250
- else if (Array.isArray(value)) {
1251
- for (const v of value) if (!filterPrimitives(v, ["string", "number"])) commands2.push(key + "=" + v);
1252
- } else commands2.push(key);
1253
- return commands2;
1254
- }, commands);
1255
- }
1256
- function getTrailingOptions(args, initialPrimitive = 0, objectOnly = false) {
1257
- const command = [];
1258
- for (let i = 0, max = initialPrimitive < 0 ? args.length : initialPrimitive; i < max; i++) if ("string|number".includes(typeof args[i])) command.push(String(args[i]));
1259
- appendTaskOptions(trailingOptionsArgument(args), command);
1260
- if (!objectOnly) command.push(...trailingArrayArgument(args));
1261
- return command;
1262
- }
1263
- function trailingArrayArgument(args) {
1264
- return asStringArray(filterType(last(args, typeof last(args) === "function" ? 1 : 0), filterArray, []));
1265
- }
1266
- function trailingOptionsArgument(args) {
1267
- return filterType(last(args, filterFunction(last(args)) ? 1 : 0), filterPlainObject);
1268
- }
1269
- function trailingFunctionArgument(args, includeNoop = true) {
1270
- const callback = asFunction(last(args));
1271
- return includeNoop || isUserFunction(callback) ? callback : void 0;
1272
- }
1273
- var init_task_options = __esm({ "src/lib/utils/task-options.ts"() {
1274
- "use strict";
1275
- init_argument_filters();
1276
- init_util();
1277
- init_pathspec();
1278
- } });
1279
- function callTaskParser(parser4, streams) {
1280
- return parser4(streams.stdOut, streams.stdErr);
1281
- }
1282
- function parseStringResponse(result, parsers12, texts, trim = true) {
1283
- asArray(texts).forEach((text) => {
1284
- for (let lines = toLinesWithContent(text, trim), i = 0, max = lines.length; i < max; i++) {
1285
- const line = (offset = 0) => {
1286
- if (i + offset >= max) return;
1287
- return lines[i + offset];
1288
- };
1289
- parsers12.some(({ parse }) => parse(line, result));
1290
- }
1291
- });
1292
- return result;
1293
- }
1294
- var init_task_parser = __esm({ "src/lib/utils/task-parser.ts"() {
1295
- "use strict";
1296
- init_util();
1297
- } });
1298
- var utils_exports = {};
1299
- __export(utils_exports, {
1300
- ExitCodes: () => ExitCodes,
1301
- GitOutputStreams: () => GitOutputStreams,
1302
- LineParser: () => LineParser,
1303
- NOOP: () => NOOP,
1304
- NULL: () => NULL,
1305
- RemoteLineParser: () => RemoteLineParser,
1306
- append: () => append,
1307
- appendTaskOptions: () => appendTaskOptions,
1308
- asArray: () => asArray,
1309
- asCamelCase: () => asCamelCase,
1310
- asFunction: () => asFunction,
1311
- asNumber: () => asNumber,
1312
- asStringArray: () => asStringArray,
1313
- bufferToString: () => bufferToString,
1314
- callTaskParser: () => callTaskParser,
1315
- createInstanceConfig: () => createInstanceConfig,
1316
- delay: () => delay,
1317
- filterArray: () => filterArray,
1318
- filterFunction: () => filterFunction,
1319
- filterHasLength: () => filterHasLength,
1320
- filterNumber: () => filterNumber,
1321
- filterPlainObject: () => filterPlainObject,
1322
- filterPrimitives: () => filterPrimitives,
1323
- filterString: () => filterString,
1324
- filterStringOrStringArray: () => filterStringOrStringArray,
1325
- filterType: () => filterType,
1326
- first: () => first,
1327
- folderExists: () => folderExists,
1328
- forEachLineWithContent: () => forEachLineWithContent,
1329
- getTrailingOptions: () => getTrailingOptions,
1330
- including: () => including,
1331
- isUserFunction: () => isUserFunction,
1332
- last: () => last,
1333
- objectToString: () => objectToString,
1334
- orVoid: () => orVoid,
1335
- parseStringResponse: () => parseStringResponse,
1336
- pick: () => pick,
1337
- prefixedArray: () => prefixedArray,
1338
- remove: () => remove,
1339
- splitOn: () => splitOn,
1340
- toLinesWithContent: () => toLinesWithContent,
1341
- trailingFunctionArgument: () => trailingFunctionArgument,
1342
- trailingOptionsArgument: () => trailingOptionsArgument
1343
- });
1344
- var init_utils = __esm({ "src/lib/utils/index.ts"() {
1345
- "use strict";
1346
- init_argument_filters();
1347
- init_exit_codes();
1348
- init_git_output_streams();
1349
- init_line_parser();
1350
- init_simple_git_options();
1351
- init_task_options();
1352
- init_task_parser();
1353
- init_util();
1354
- } });
1355
- var check_is_repo_exports = {};
1356
- __export(check_is_repo_exports, {
1357
- CheckRepoActions: () => CheckRepoActions,
1358
- checkIsBareRepoTask: () => checkIsBareRepoTask,
1359
- checkIsRepoRootTask: () => checkIsRepoRootTask,
1360
- checkIsRepoTask: () => checkIsRepoTask
1361
- });
1362
- function checkIsRepoTask(action) {
1363
- switch (action) {
1364
- case "bare": return checkIsBareRepoTask();
1365
- case "root": return checkIsRepoRootTask();
1366
- }
1367
- return {
1368
- commands: ["rev-parse", "--is-inside-work-tree"],
1369
- format: "utf-8",
1370
- onError,
1371
- parser
1372
- };
1373
- }
1374
- function checkIsRepoRootTask() {
1375
- return {
1376
- commands: ["rev-parse", "--git-dir"],
1377
- format: "utf-8",
1378
- onError,
1379
- parser(path) {
1380
- return /^\.(git)?$/.test(path.trim());
1381
- }
1382
- };
1383
- }
1384
- function checkIsBareRepoTask() {
1385
- return {
1386
- commands: ["rev-parse", "--is-bare-repository"],
1387
- format: "utf-8",
1388
- onError,
1389
- parser
1390
- };
1391
- }
1392
- function isNotRepoMessage(error) {
1393
- return /(Not a git repository|Kein Git-Repository)/i.test(String(error));
1394
- }
1395
- var CheckRepoActions, onError, parser;
1396
- var init_check_is_repo = __esm({ "src/lib/tasks/check-is-repo.ts"() {
1397
- "use strict";
1398
- init_utils();
1399
- CheckRepoActions = /* @__PURE__ */ ((CheckRepoActions2) => {
1400
- CheckRepoActions2["BARE"] = "bare";
1401
- CheckRepoActions2["IN_TREE"] = "tree";
1402
- CheckRepoActions2["IS_REPO_ROOT"] = "root";
1403
- return CheckRepoActions2;
1404
- })(CheckRepoActions || {});
1405
- onError = ({ exitCode }, error, done, fail) => {
1406
- if (exitCode === 128 && isNotRepoMessage(error)) return done(Buffer.from("false"));
1407
- fail(error);
1408
- };
1409
- parser = (text) => {
1410
- return text.trim() === "true";
1411
- };
1412
- } });
1413
- function cleanSummaryParser(dryRun, text) {
1414
- const summary = new CleanResponse(dryRun);
1415
- const regexp = dryRun ? dryRunRemovalRegexp : removalRegexp;
1416
- toLinesWithContent(text).forEach((line) => {
1417
- const removed = line.replace(regexp, "");
1418
- summary.paths.push(removed);
1419
- (isFolderRegexp.test(removed) ? summary.folders : summary.files).push(removed);
1420
- });
1421
- return summary;
1422
- }
1423
- var CleanResponse, removalRegexp, dryRunRemovalRegexp, isFolderRegexp;
1424
- var init_CleanSummary = __esm({ "src/lib/responses/CleanSummary.ts"() {
1425
- "use strict";
1426
- init_utils();
1427
- CleanResponse = class {
1428
- constructor(dryRun) {
1429
- this.dryRun = dryRun;
1430
- this.paths = [];
1431
- this.files = [];
1432
- this.folders = [];
1433
- }
1434
- };
1435
- removalRegexp = /^[a-z]+\s*/i;
1436
- dryRunRemovalRegexp = /^[a-z]+\s+[a-z]+\s*/i;
1437
- isFolderRegexp = /\/$/;
1438
- } });
1439
- var task_exports = {};
1440
- __export(task_exports, {
1441
- EMPTY_COMMANDS: () => EMPTY_COMMANDS,
1442
- adhocExecTask: () => adhocExecTask,
1443
- configurationErrorTask: () => configurationErrorTask,
1444
- isBufferTask: () => isBufferTask,
1445
- isEmptyTask: () => isEmptyTask,
1446
- straightThroughBufferTask: () => straightThroughBufferTask,
1447
- straightThroughStringTask: () => straightThroughStringTask
1448
- });
1449
- function adhocExecTask(parser4) {
1450
- return {
1451
- commands: EMPTY_COMMANDS,
1452
- format: "empty",
1453
- parser: parser4
1454
- };
1455
- }
1456
- function configurationErrorTask(error) {
1457
- return {
1458
- commands: EMPTY_COMMANDS,
1459
- format: "empty",
1460
- parser() {
1461
- throw typeof error === "string" ? new TaskConfigurationError(error) : error;
1462
- }
1463
- };
1464
- }
1465
- function straightThroughStringTask(commands, trimmed2 = false) {
1466
- return {
1467
- commands,
1468
- format: "utf-8",
1469
- parser(text) {
1470
- return trimmed2 ? String(text).trim() : text;
1471
- }
1472
- };
1473
- }
1474
- function straightThroughBufferTask(commands) {
1475
- return {
1476
- commands,
1477
- format: "buffer",
1478
- parser(buffer) {
1479
- return buffer;
1480
- }
1481
- };
1482
- }
1483
- function isBufferTask(task) {
1484
- return task.format === "buffer";
1485
- }
1486
- function isEmptyTask(task) {
1487
- return task.format === "empty" || !task.commands.length;
1488
- }
1489
- var EMPTY_COMMANDS;
1490
- var init_task = __esm({ "src/lib/tasks/task.ts"() {
1491
- "use strict";
1492
- init_task_configuration_error();
1493
- EMPTY_COMMANDS = [];
1494
- } });
1495
- var clean_exports = {};
1496
- __export(clean_exports, {
1497
- CONFIG_ERROR_INTERACTIVE_MODE: () => CONFIG_ERROR_INTERACTIVE_MODE,
1498
- CONFIG_ERROR_MODE_REQUIRED: () => CONFIG_ERROR_MODE_REQUIRED,
1499
- CONFIG_ERROR_UNKNOWN_OPTION: () => CONFIG_ERROR_UNKNOWN_OPTION,
1500
- CleanOptions: () => CleanOptions,
1501
- cleanTask: () => cleanTask,
1502
- cleanWithOptionsTask: () => cleanWithOptionsTask,
1503
- isCleanOptionsArray: () => isCleanOptionsArray
1504
- });
1505
- function cleanWithOptionsTask(mode, customArgs) {
1506
- const { cleanMode, options, valid } = getCleanOptions(mode);
1507
- if (!cleanMode) return configurationErrorTask(CONFIG_ERROR_MODE_REQUIRED);
1508
- if (!valid.options) return configurationErrorTask(CONFIG_ERROR_UNKNOWN_OPTION + JSON.stringify(mode));
1509
- options.push(...customArgs);
1510
- if (options.some(isInteractiveMode)) return configurationErrorTask(CONFIG_ERROR_INTERACTIVE_MODE);
1511
- return cleanTask(cleanMode, options);
1512
- }
1513
- function cleanTask(mode, customArgs) {
1514
- return {
1515
- commands: [
1516
- "clean",
1517
- `-${mode}`,
1518
- ...customArgs
1519
- ],
1520
- format: "utf-8",
1521
- parser(text) {
1522
- return cleanSummaryParser(mode === "n", text);
1523
- }
1524
- };
1525
- }
1526
- function isCleanOptionsArray(input) {
1527
- return Array.isArray(input) && input.every((test) => CleanOptionValues.has(test));
1528
- }
1529
- function getCleanOptions(input) {
1530
- let cleanMode;
1531
- let options = [];
1532
- let valid = {
1533
- cleanMode: false,
1534
- options: true
1535
- };
1536
- input.replace(/[^a-z]i/g, "").split("").forEach((char) => {
1537
- if (isCleanMode(char)) {
1538
- cleanMode = char;
1539
- valid.cleanMode = true;
1540
- } else valid.options = valid.options && isKnownOption(options[options.length] = `-${char}`);
1541
- });
1542
- return {
1543
- cleanMode,
1544
- options,
1545
- valid
1546
- };
1547
- }
1548
- function isCleanMode(cleanMode) {
1549
- return cleanMode === "f" || cleanMode === "n";
1550
- }
1551
- function isKnownOption(option) {
1552
- return /^-[a-z]$/i.test(option) && CleanOptionValues.has(option.charAt(1));
1553
- }
1554
- function isInteractiveMode(option) {
1555
- if (/^-[^\-]/.test(option)) return option.indexOf("i") > 0;
1556
- return option === "--interactive";
1557
- }
1558
- var CONFIG_ERROR_INTERACTIVE_MODE, CONFIG_ERROR_MODE_REQUIRED, CONFIG_ERROR_UNKNOWN_OPTION, CleanOptions, CleanOptionValues;
1559
- var init_clean = __esm({ "src/lib/tasks/clean.ts"() {
1560
- "use strict";
1561
- init_CleanSummary();
1562
- init_utils();
1563
- init_task();
1564
- CONFIG_ERROR_INTERACTIVE_MODE = "Git clean interactive mode is not supported";
1565
- CONFIG_ERROR_MODE_REQUIRED = "Git clean mode parameter (\"n\" or \"f\") is required";
1566
- CONFIG_ERROR_UNKNOWN_OPTION = "Git clean unknown option found in: ";
1567
- CleanOptions = /* @__PURE__ */ ((CleanOptions2) => {
1568
- CleanOptions2["DRY_RUN"] = "n";
1569
- CleanOptions2["FORCE"] = "f";
1570
- CleanOptions2["IGNORED_INCLUDED"] = "x";
1571
- CleanOptions2["IGNORED_ONLY"] = "X";
1572
- CleanOptions2["EXCLUDING"] = "e";
1573
- CleanOptions2["QUIET"] = "q";
1574
- CleanOptions2["RECURSIVE"] = "d";
1575
- return CleanOptions2;
1576
- })(CleanOptions || {});
1577
- CleanOptionValues = /* @__PURE__ */ new Set(["i", ...asStringArray(Object.values(CleanOptions))]);
1578
- } });
1579
- function configListParser(text) {
1580
- const config = new ConfigList();
1581
- for (const item of configParser(text)) config.addValue(item.file, String(item.key), item.value);
1582
- return config;
1583
- }
1584
- function configGetParser(text, key) {
1585
- let value = null;
1586
- const values = [];
1587
- const scopes = /* @__PURE__ */ new Map();
1588
- for (const item of configParser(text, key)) {
1589
- if (item.key !== key) continue;
1590
- values.push(value = item.value);
1591
- if (!scopes.has(item.file)) scopes.set(item.file, []);
1592
- scopes.get(item.file).push(value);
1593
- }
1594
- return {
1595
- key,
1596
- paths: Array.from(scopes.keys()),
1597
- scopes,
1598
- value,
1599
- values
1600
- };
1601
- }
1602
- function configFilePath(filePath) {
1603
- return filePath.replace(/^(file):/, "");
1604
- }
1605
- function* configParser(text, requestedKey = null) {
1606
- const lines = text.split("\0");
1607
- for (let i = 0, max = lines.length - 1; i < max;) {
1608
- const file = configFilePath(lines[i++]);
1609
- let value = lines[i++];
1610
- let key = requestedKey;
1611
- if (value.includes("\n")) {
1612
- const line = splitOn(value, "\n");
1613
- key = line[0];
1614
- value = line[1];
1615
- }
1616
- yield {
1617
- file,
1618
- key,
1619
- value
1620
- };
1621
- }
1622
- }
1623
- var ConfigList;
1624
- var init_ConfigList = __esm({ "src/lib/responses/ConfigList.ts"() {
1625
- "use strict";
1626
- init_utils();
1627
- ConfigList = class {
1628
- constructor() {
1629
- this.files = [];
1630
- this.values = /* @__PURE__ */ Object.create(null);
1631
- }
1632
- get all() {
1633
- if (!this._all) this._all = this.files.reduce((all, file) => {
1634
- return Object.assign(all, this.values[file]);
1635
- }, {});
1636
- return this._all;
1637
- }
1638
- addFile(file) {
1639
- if (!(file in this.values)) {
1640
- const latest = last(this.files);
1641
- this.values[file] = latest ? Object.create(this.values[latest]) : {};
1642
- this.files.push(file);
1643
- }
1644
- return this.values[file];
1645
- }
1646
- addValue(file, key, value) {
1647
- const values = this.addFile(file);
1648
- if (!Object.hasOwn(values, key)) values[key] = value;
1649
- else if (Array.isArray(values[key])) values[key].push(value);
1650
- else values[key] = [values[key], value];
1651
- this._all = void 0;
1652
- }
1653
- };
1654
- } });
1655
- function asConfigScope(scope, fallback) {
1656
- if (typeof scope === "string" && Object.hasOwn(GitConfigScope, scope)) return scope;
1657
- return fallback;
1658
- }
1659
- function addConfigTask(key, value, append2, scope) {
1660
- const commands = ["config", `--${scope}`];
1661
- if (append2) commands.push("--add");
1662
- commands.push(key, value);
1663
- return {
1664
- commands,
1665
- format: "utf-8",
1666
- parser(text) {
1667
- return text;
1668
- }
1669
- };
1670
- }
1671
- function getConfigTask(key, scope) {
1672
- const commands = [
1673
- "config",
1674
- "--null",
1675
- "--show-origin",
1676
- "--get-all",
1677
- key
1678
- ];
1679
- if (scope) commands.splice(1, 0, `--${scope}`);
1680
- return {
1681
- commands,
1682
- format: "utf-8",
1683
- parser(text) {
1684
- return configGetParser(text, key);
1685
- }
1686
- };
1687
- }
1688
- function listConfigTask(scope) {
1689
- const commands = [
1690
- "config",
1691
- "--list",
1692
- "--show-origin",
1693
- "--null"
1694
- ];
1695
- if (scope) commands.push(`--${scope}`);
1696
- return {
1697
- commands,
1698
- format: "utf-8",
1699
- parser(text) {
1700
- return configListParser(text);
1701
- }
1702
- };
1703
- }
1704
- function config_default() {
1705
- return {
1706
- addConfig(key, value, ...rest) {
1707
- return this._runTask(addConfigTask(key, value, rest[0] === true, asConfigScope(rest[1], "local")), trailingFunctionArgument(arguments));
1708
- },
1709
- getConfig(key, scope) {
1710
- return this._runTask(getConfigTask(key, asConfigScope(scope, void 0)), trailingFunctionArgument(arguments));
1711
- },
1712
- listConfig(...rest) {
1713
- return this._runTask(listConfigTask(asConfigScope(rest[0], void 0)), trailingFunctionArgument(arguments));
1714
- }
1715
- };
1716
- }
1717
- var GitConfigScope;
1718
- var init_config = __esm({ "src/lib/tasks/config.ts"() {
1719
- "use strict";
1720
- init_ConfigList();
1721
- init_utils();
1722
- GitConfigScope = /* @__PURE__ */ ((GitConfigScope2) => {
1723
- GitConfigScope2["system"] = "system";
1724
- GitConfigScope2["global"] = "global";
1725
- GitConfigScope2["local"] = "local";
1726
- GitConfigScope2["worktree"] = "worktree";
1727
- return GitConfigScope2;
1728
- })(GitConfigScope || {});
1729
- } });
1730
- function isDiffNameStatus(input) {
1731
- return diffNameStatus.has(input);
1732
- }
1733
- var DiffNameStatus, diffNameStatus;
1734
- var init_diff_name_status = __esm({ "src/lib/tasks/diff-name-status.ts"() {
1735
- "use strict";
1736
- DiffNameStatus = /* @__PURE__ */ ((DiffNameStatus2) => {
1737
- DiffNameStatus2["ADDED"] = "A";
1738
- DiffNameStatus2["COPIED"] = "C";
1739
- DiffNameStatus2["DELETED"] = "D";
1740
- DiffNameStatus2["MODIFIED"] = "M";
1741
- DiffNameStatus2["RENAMED"] = "R";
1742
- DiffNameStatus2["CHANGED"] = "T";
1743
- DiffNameStatus2["UNMERGED"] = "U";
1744
- DiffNameStatus2["UNKNOWN"] = "X";
1745
- DiffNameStatus2["BROKEN"] = "B";
1746
- return DiffNameStatus2;
1747
- })(DiffNameStatus || {});
1748
- diffNameStatus = new Set(Object.values(DiffNameStatus));
1749
- } });
1750
- function grepQueryBuilder(...params) {
1751
- return new GrepQuery().param(...params);
1752
- }
1753
- function parseGrep(grep) {
1754
- const paths = /* @__PURE__ */ new Set();
1755
- const results = {};
1756
- forEachLineWithContent(grep, (input) => {
1757
- const [path, line, preview] = input.split(NULL);
1758
- paths.add(path);
1759
- (results[path] = results[path] || []).push({
1760
- line: asNumber(line),
1761
- path,
1762
- preview
1763
- });
1764
- });
1765
- return {
1766
- paths,
1767
- results
1768
- };
1769
- }
1770
- function grep_default() {
1771
- return { grep(searchTerm) {
1772
- const then = trailingFunctionArgument(arguments);
1773
- const options = getTrailingOptions(arguments);
1774
- for (const option of disallowedOptions) if (options.includes(option)) return this._runTask(configurationErrorTask(`git.grep: use of "${option}" is not supported.`), then);
1775
- if (typeof searchTerm === "string") searchTerm = grepQueryBuilder().param(searchTerm);
1776
- const commands = [
1777
- "grep",
1778
- "--null",
1779
- "-n",
1780
- "--full-name",
1781
- ...options,
1782
- ...searchTerm
1783
- ];
1784
- return this._runTask({
1785
- commands,
1786
- format: "utf-8",
1787
- parser(stdOut) {
1788
- return parseGrep(stdOut);
1789
- }
1790
- }, then);
1791
- } };
1792
- }
1793
- var disallowedOptions, Query, _a, GrepQuery;
1794
- var init_grep = __esm({ "src/lib/tasks/grep.ts"() {
1795
- "use strict";
1796
- init_utils();
1797
- init_task();
1798
- disallowedOptions = ["-h"];
1799
- Query = Symbol("grepQuery");
1800
- GrepQuery = class {
1801
- constructor() {
1802
- this[_a] = [];
1803
- }
1804
- *[(_a = Query, Symbol.iterator)]() {
1805
- for (const query of this[Query]) yield query;
1806
- }
1807
- and(...and) {
1808
- and.length && this[Query].push("--and", "(", ...prefixedArray(and, "-e"), ")");
1809
- return this;
1810
- }
1811
- param(...param) {
1812
- this[Query].push(...prefixedArray(param, "-e"));
1813
- return this;
1814
- }
1815
- };
1816
- } });
1817
- var reset_exports = {};
1818
- __export(reset_exports, {
1819
- ResetMode: () => ResetMode,
1820
- getResetMode: () => getResetMode,
1821
- resetTask: () => resetTask
1822
- });
1823
- function resetTask(mode, customArgs) {
1824
- const commands = ["reset"];
1825
- if (isValidResetMode(mode)) commands.push(`--${mode}`);
1826
- commands.push(...customArgs);
1827
- return straightThroughStringTask(commands);
1828
- }
1829
- function getResetMode(mode) {
1830
- if (isValidResetMode(mode)) return mode;
1831
- switch (typeof mode) {
1832
- case "string":
1833
- case "undefined": return "soft";
1834
- }
1835
- }
1836
- function isValidResetMode(mode) {
1837
- return typeof mode === "string" && validResetModes.includes(mode);
1838
- }
1839
- var ResetMode, validResetModes;
1840
- var init_reset = __esm({ "src/lib/tasks/reset.ts"() {
1841
- "use strict";
1842
- init_utils();
1843
- init_task();
1844
- ResetMode = /* @__PURE__ */ ((ResetMode2) => {
1845
- ResetMode2["MIXED"] = "mixed";
1846
- ResetMode2["SOFT"] = "soft";
1847
- ResetMode2["HARD"] = "hard";
1848
- ResetMode2["MERGE"] = "merge";
1849
- ResetMode2["KEEP"] = "keep";
1850
- return ResetMode2;
1851
- })(ResetMode || {});
1852
- validResetModes = asStringArray(Object.values(ResetMode));
1853
- } });
1854
- function createLog() {
1855
- return (0, import_src.default)("simple-git");
1856
- }
1857
- function prefixedLogger(to, prefix, forward) {
1858
- if (!prefix || !String(prefix).replace(/\s*/, "")) return !forward ? to : (message, ...args) => {
1859
- to(message, ...args);
1860
- forward(message, ...args);
1861
- };
1862
- return (message, ...args) => {
1863
- to(`%s ${message}`, prefix, ...args);
1864
- if (forward) forward(message, ...args);
1865
- };
1866
- }
1867
- function childLoggerName(name, childDebugger, { namespace: parentNamespace }) {
1868
- if (typeof name === "string") return name;
1869
- const childNamespace = childDebugger && childDebugger.namespace || "";
1870
- if (childNamespace.startsWith(parentNamespace)) return childNamespace.substr(parentNamespace.length + 1);
1871
- return childNamespace || parentNamespace;
1872
- }
1873
- function createLogger(label, verbose, initialStep, infoDebugger = createLog()) {
1874
- const labelPrefix = label && `[${label}]` || "";
1875
- const spawned = [];
1876
- const debugDebugger = typeof verbose === "string" ? infoDebugger.extend(verbose) : verbose;
1877
- const key = childLoggerName(filterType(verbose, filterString), debugDebugger, infoDebugger);
1878
- return step(initialStep);
1879
- function sibling(name, initial) {
1880
- return append(spawned, createLogger(label, key.replace(/^[^:]+/, name), initial, infoDebugger));
1881
- }
1882
- function step(phase) {
1883
- const stepPrefix = phase && `[${phase}]` || "";
1884
- const debug2 = debugDebugger && prefixedLogger(debugDebugger, stepPrefix) || NOOP;
1885
- const info = prefixedLogger(infoDebugger, `${labelPrefix} ${stepPrefix}`, debug2);
1886
- return Object.assign(debugDebugger ? debug2 : info, {
1887
- label,
1888
- sibling,
1889
- info,
1890
- step
1891
- });
1892
- }
1893
- }
1894
- var init_git_logger = __esm({ "src/lib/git-logger.ts"() {
1895
- "use strict";
1896
- init_utils();
1897
- import_src.default.formatters.L = (value) => String(filterHasLength(value) ? value.length : "-");
1898
- import_src.default.formatters.B = (value) => {
1899
- if (Buffer.isBuffer(value)) return value.toString("utf8");
1900
- return objectToString(value);
1901
- };
1902
- } });
1903
- var TasksPendingQueue;
1904
- var init_tasks_pending_queue = __esm({ "src/lib/runners/tasks-pending-queue.ts"() {
1905
- "use strict";
1906
- init_git_error();
1907
- init_git_logger();
1908
- TasksPendingQueue = class _TasksPendingQueue {
1909
- constructor(logLabel = "GitExecutor") {
1910
- this.logLabel = logLabel;
1911
- this._queue = /* @__PURE__ */ new Map();
1912
- }
1913
- withProgress(task) {
1914
- return this._queue.get(task);
1915
- }
1916
- createProgress(task) {
1917
- const name = _TasksPendingQueue.getName(task.commands[0]);
1918
- return {
1919
- task,
1920
- logger: createLogger(this.logLabel, name),
1921
- name
1922
- };
1923
- }
1924
- push(task) {
1925
- const progress = this.createProgress(task);
1926
- progress.logger("Adding task to the queue, commands = %o", task.commands);
1927
- this._queue.set(task, progress);
1928
- return progress;
1929
- }
1930
- fatal(err) {
1931
- for (const [task, { logger }] of Array.from(this._queue.entries())) {
1932
- if (task === err.task) {
1933
- logger.info(`Failed %o`, err);
1934
- logger(`Fatal exception, any as-yet un-started tasks run through this executor will not be attempted`);
1935
- } else logger.info(`A fatal exception occurred in a previous task, the queue has been purged: %o`, err.message);
1936
- this.complete(task);
1937
- }
1938
- if (this._queue.size !== 0) throw new Error(`Queue size should be zero after fatal: ${this._queue.size}`);
1939
- }
1940
- complete(task) {
1941
- if (this.withProgress(task)) this._queue.delete(task);
1942
- }
1943
- attempt(task) {
1944
- const progress = this.withProgress(task);
1945
- if (!progress) throw new GitError(void 0, "TasksPendingQueue: attempt called for an unknown task");
1946
- progress.logger("Starting task");
1947
- return progress;
1948
- }
1949
- static getName(name = "empty") {
1950
- return `task:${name}:${++_TasksPendingQueue.counter}`;
1951
- }
1952
- static {
1953
- this.counter = 0;
1954
- }
1955
- };
1956
- } });
1957
- function pluginContext(task, commands) {
1958
- return {
1959
- method: first(task.commands) || "",
1960
- commands
1961
- };
1962
- }
1963
- function onErrorReceived(target, logger) {
1964
- return (err) => {
1965
- logger(`[ERROR] child process exception %o`, err);
1966
- target.push(Buffer.from(String(err.stack), "ascii"));
1967
- };
1968
- }
1969
- function onDataReceived(target, name, logger, output) {
1970
- return (buffer) => {
1971
- logger(`%s received %L bytes`, name, buffer);
1972
- output(`%B`, buffer);
1973
- target.push(buffer);
1974
- };
1975
- }
1976
- var GitExecutorChain;
1977
- var init_git_executor_chain = __esm({ "src/lib/runners/git-executor-chain.ts"() {
1978
- "use strict";
1979
- init_git_error();
1980
- init_task();
1981
- init_utils();
1982
- init_tasks_pending_queue();
1983
- GitExecutorChain = class {
1984
- constructor(_executor, _scheduler, _plugins) {
1985
- this._executor = _executor;
1986
- this._scheduler = _scheduler;
1987
- this._plugins = _plugins;
1988
- this._chain = Promise.resolve();
1989
- this._queue = new TasksPendingQueue();
1990
- }
1991
- get cwd() {
1992
- return this._cwd || this._executor.cwd;
1993
- }
1994
- set cwd(cwd) {
1995
- this._cwd = cwd;
1996
- }
1997
- get env() {
1998
- return this._executor.env;
1999
- }
2000
- get outputHandler() {
2001
- return this._executor.outputHandler;
2002
- }
2003
- chain() {
2004
- return this;
2005
- }
2006
- push(task) {
2007
- this._queue.push(task);
2008
- return this._chain = this._chain.then(() => this.attemptTask(task));
2009
- }
2010
- async attemptTask(task) {
2011
- const onScheduleComplete = await this._scheduler.next();
2012
- const onQueueComplete = () => this._queue.complete(task);
2013
- try {
2014
- const { logger } = this._queue.attempt(task);
2015
- return await (isEmptyTask(task) ? this.attemptEmptyTask(task, logger) : this.attemptRemoteTask(task, logger));
2016
- } catch (e) {
2017
- throw this.onFatalException(task, e);
2018
- } finally {
2019
- onQueueComplete();
2020
- onScheduleComplete();
2021
- }
2022
- }
2023
- onFatalException(task, e) {
2024
- const gitError = e instanceof GitError ? Object.assign(e, { task }) : new GitError(task, e && String(e));
2025
- this._chain = Promise.resolve();
2026
- this._queue.fatal(gitError);
2027
- return gitError;
2028
- }
2029
- async attemptRemoteTask(task, logger) {
2030
- const binary = this._plugins.exec("spawn.binary", "", pluginContext(task, task.commands));
2031
- const args = this._plugins.exec("spawn.args", [...task.commands], pluginContext(task, task.commands));
2032
- const raw = await this.gitResponse(task, binary, args, this.outputHandler, logger.step("SPAWN"));
2033
- const outputStreams = await this.handleTaskData(task, args, raw, logger.step("HANDLE"));
2034
- logger(`passing response to task's parser as a %s`, task.format);
2035
- if (isBufferTask(task)) return callTaskParser(task.parser, outputStreams);
2036
- return callTaskParser(task.parser, outputStreams.asStrings());
2037
- }
2038
- async attemptEmptyTask(task, logger) {
2039
- logger(`empty task bypassing child process to call to task's parser`);
2040
- return task.parser(this);
2041
- }
2042
- handleTaskData(task, args, result, logger) {
2043
- const { exitCode, rejection, stdOut, stdErr } = result;
2044
- return new Promise((done, fail) => {
2045
- logger(`Preparing to handle process response exitCode=%d stdOut=`, exitCode);
2046
- const { error } = this._plugins.exec("task.error", { error: rejection }, {
2047
- ...pluginContext(task, args),
2048
- ...result
2049
- });
2050
- if (error && task.onError) {
2051
- logger.info(`exitCode=%s handling with custom error handler`);
2052
- return task.onError(result, error, (newStdOut) => {
2053
- logger.info(`custom error handler treated as success`);
2054
- logger(`custom error returned a %s`, objectToString(newStdOut));
2055
- done(new GitOutputStreams(Array.isArray(newStdOut) ? Buffer.concat(newStdOut) : newStdOut, Buffer.concat(stdErr)));
2056
- }, fail);
2057
- }
2058
- if (error) {
2059
- logger.info(`handling as error: exitCode=%s stdErr=%s rejection=%o`, exitCode, stdErr.length, rejection);
2060
- return fail(error);
2061
- }
2062
- logger.info(`retrieving task output complete`);
2063
- done(new GitOutputStreams(Buffer.concat(stdOut), Buffer.concat(stdErr)));
2064
- });
2065
- }
2066
- async gitResponse(task, command, args, outputHandler, logger) {
2067
- const outputLogger = logger.sibling("output");
2068
- const spawnOptions = this._plugins.exec("spawn.options", {
2069
- cwd: this.cwd,
2070
- env: this.env,
2071
- windowsHide: true
2072
- }, pluginContext(task, task.commands));
2073
- return new Promise((done) => {
2074
- const stdOut = [];
2075
- const stdErr = [];
2076
- logger.info(`%s %o`, command, args);
2077
- logger("%O", spawnOptions);
2078
- let rejection = this._beforeSpawn(task, args);
2079
- if (rejection) return done({
2080
- stdOut,
2081
- stdErr,
2082
- exitCode: 9901,
2083
- rejection
2084
- });
2085
- this._plugins.exec("spawn.before", void 0, {
2086
- ...pluginContext(task, args),
2087
- kill(reason) {
2088
- rejection = reason || rejection;
2089
- }
2090
- });
2091
- const spawned = spawn(command, args, spawnOptions);
2092
- spawned.stdout.on("data", onDataReceived(stdOut, "stdOut", logger, outputLogger.step("stdOut")));
2093
- spawned.stderr.on("data", onDataReceived(stdErr, "stdErr", logger, outputLogger.step("stdErr")));
2094
- spawned.on("error", onErrorReceived(stdErr, logger));
2095
- if (outputHandler) {
2096
- logger(`Passing child process stdOut/stdErr to custom outputHandler`);
2097
- outputHandler(command, spawned.stdout, spawned.stderr, [...args]);
2098
- }
2099
- this._plugins.exec("spawn.after", void 0, {
2100
- ...pluginContext(task, args),
2101
- spawned,
2102
- close(exitCode, reason) {
2103
- done({
2104
- stdOut,
2105
- stdErr,
2106
- exitCode,
2107
- rejection: rejection || reason
2108
- });
2109
- },
2110
- kill(reason) {
2111
- if (spawned.killed) return;
2112
- rejection = reason;
2113
- spawned.kill("SIGINT");
2114
- }
2115
- });
2116
- });
2117
- }
2118
- _beforeSpawn(task, args) {
2119
- let rejection;
2120
- this._plugins.exec("spawn.before", void 0, {
2121
- ...pluginContext(task, args),
2122
- kill(reason) {
2123
- rejection = reason || rejection;
2124
- }
2125
- });
2126
- return rejection;
2127
- }
2128
- };
2129
- } });
2130
- var git_executor_exports = {};
2131
- __export(git_executor_exports, { GitExecutor: () => GitExecutor });
2132
- var GitExecutor;
2133
- var init_git_executor = __esm({ "src/lib/runners/git-executor.ts"() {
2134
- "use strict";
2135
- init_git_executor_chain();
2136
- GitExecutor = class {
2137
- constructor(cwd, _scheduler, _plugins) {
2138
- this.cwd = cwd;
2139
- this._scheduler = _scheduler;
2140
- this._plugins = _plugins;
2141
- this._chain = new GitExecutorChain(this, this._scheduler, this._plugins);
2142
- }
2143
- chain() {
2144
- return new GitExecutorChain(this, this._scheduler, this._plugins);
2145
- }
2146
- push(task) {
2147
- return this._chain.push(task);
2148
- }
2149
- };
2150
- } });
2151
- function taskCallback(task, response, callback = NOOP) {
2152
- const onSuccess = (data) => {
2153
- callback(null, data);
2154
- };
2155
- const onError2 = (err) => {
2156
- if (err?.task === task) callback(err instanceof GitResponseError ? addDeprecationNoticeToError(err) : err, void 0);
2157
- };
2158
- response.then(onSuccess, onError2);
2159
- }
2160
- function addDeprecationNoticeToError(err) {
2161
- let log = (name) => {
2162
- console.warn(`simple-git deprecation notice: accessing GitResponseError.${name} should be GitResponseError.git.${name}, this will no longer be available in version 3`);
2163
- log = NOOP;
2164
- };
2165
- return Object.create(err, Object.getOwnPropertyNames(err.git).reduce(descriptorReducer, {}));
2166
- function descriptorReducer(all, name) {
2167
- if (name in err) return all;
2168
- all[name] = {
2169
- enumerable: false,
2170
- configurable: false,
2171
- get() {
2172
- log(name);
2173
- return err.git[name];
2174
- }
2175
- };
2176
- return all;
2177
- }
2178
- }
2179
- var init_task_callback = __esm({ "src/lib/task-callback.ts"() {
2180
- "use strict";
2181
- init_git_response_error();
2182
- init_utils();
2183
- } });
2184
- function changeWorkingDirectoryTask(directory, root) {
2185
- return adhocExecTask((instance) => {
2186
- if (!folderExists(directory)) throw new Error(`Git.cwd: cannot change to non-directory "${directory}"`);
2187
- return (root || instance).cwd = directory;
2188
- });
2189
- }
2190
- var init_change_working_directory = __esm({ "src/lib/tasks/change-working-directory.ts"() {
2191
- "use strict";
2192
- init_utils();
2193
- init_task();
2194
- } });
2195
- function checkoutTask(args) {
2196
- const commands = ["checkout", ...args];
2197
- if (commands[1] === "-b" && commands.includes("-B")) commands[1] = remove(commands, "-B");
2198
- return straightThroughStringTask(commands);
2199
- }
2200
- function checkout_default() {
2201
- return {
2202
- checkout() {
2203
- return this._runTask(checkoutTask(getTrailingOptions(arguments, 1)), trailingFunctionArgument(arguments));
2204
- },
2205
- checkoutBranch(branchName, startPoint) {
2206
- return this._runTask(checkoutTask([
2207
- "-b",
2208
- branchName,
2209
- startPoint,
2210
- ...getTrailingOptions(arguments)
2211
- ]), trailingFunctionArgument(arguments));
2212
- },
2213
- checkoutLocalBranch(branchName) {
2214
- return this._runTask(checkoutTask([
2215
- "-b",
2216
- branchName,
2217
- ...getTrailingOptions(arguments)
2218
- ]), trailingFunctionArgument(arguments));
2219
- }
2220
- };
2221
- }
2222
- var init_checkout = __esm({ "src/lib/tasks/checkout.ts"() {
2223
- "use strict";
2224
- init_utils();
2225
- init_task();
2226
- } });
2227
- function countObjectsResponse() {
2228
- return {
2229
- count: 0,
2230
- garbage: 0,
2231
- inPack: 0,
2232
- packs: 0,
2233
- prunePackable: 0,
2234
- size: 0,
2235
- sizeGarbage: 0,
2236
- sizePack: 0
2237
- };
2238
- }
2239
- function count_objects_default() {
2240
- return { countObjects() {
2241
- return this._runTask({
2242
- commands: ["count-objects", "--verbose"],
2243
- format: "utf-8",
2244
- parser(stdOut) {
2245
- return parseStringResponse(countObjectsResponse(), [parser2], stdOut);
2246
- }
2247
- });
2248
- } };
2249
- }
2250
- var parser2;
2251
- var init_count_objects = __esm({ "src/lib/tasks/count-objects.ts"() {
2252
- "use strict";
2253
- init_utils();
2254
- parser2 = new LineParser(/([a-z-]+): (\d+)$/, (result, [key, value]) => {
2255
- const property = asCamelCase(key);
2256
- if (Object.hasOwn(result, property)) result[property] = asNumber(value);
2257
- });
2258
- } });
2259
- function parseCommitResult(stdOut) {
2260
- return parseStringResponse({
2261
- author: null,
2262
- branch: "",
2263
- commit: "",
2264
- root: false,
2265
- summary: {
2266
- changes: 0,
2267
- insertions: 0,
2268
- deletions: 0
2269
- }
2270
- }, parsers, stdOut);
2271
- }
2272
- var parsers;
2273
- var init_parse_commit = __esm({ "src/lib/parsers/parse-commit.ts"() {
2274
- "use strict";
2275
- init_utils();
2276
- parsers = [
2277
- new LineParser(/^\[([^\s]+)( \([^)]+\))? ([^\]]+)/, (result, [branch, root, commit]) => {
2278
- result.branch = branch;
2279
- result.commit = commit;
2280
- result.root = !!root;
2281
- }),
2282
- new LineParser(/\s*Author:\s(.+)/i, (result, [author]) => {
2283
- const parts = author.split("<");
2284
- const email = parts.pop();
2285
- if (!email || !email.includes("@")) return;
2286
- result.author = {
2287
- email: email.substr(0, email.length - 1),
2288
- name: parts.join("<").trim()
2289
- };
2290
- }),
2291
- new LineParser(/(\d+)[^,]*(?:,\s*(\d+)[^,]*)(?:,\s*(\d+))/g, (result, [changes, insertions, deletions]) => {
2292
- result.summary.changes = parseInt(changes, 10) || 0;
2293
- result.summary.insertions = parseInt(insertions, 10) || 0;
2294
- result.summary.deletions = parseInt(deletions, 10) || 0;
2295
- }),
2296
- new LineParser(/^(\d+)[^,]*(?:,\s*(\d+)[^(]+\(([+-]))?/, (result, [changes, lines, direction]) => {
2297
- result.summary.changes = parseInt(changes, 10) || 0;
2298
- const count = parseInt(lines, 10) || 0;
2299
- if (direction === "-") result.summary.deletions = count;
2300
- else if (direction === "+") result.summary.insertions = count;
2301
- })
2302
- ];
2303
- } });
2304
- function commitTask(message, files, customArgs) {
2305
- return {
2306
- commands: [
2307
- "-c",
2308
- "core.abbrev=40",
2309
- "commit",
2310
- ...prefixedArray(message, "-m"),
2311
- ...files,
2312
- ...customArgs
2313
- ],
2314
- format: "utf-8",
2315
- parser: parseCommitResult
2316
- };
2317
- }
2318
- function commit_default() {
2319
- return { commit(message, ...rest) {
2320
- const next = trailingFunctionArgument(arguments);
2321
- const task = rejectDeprecatedSignatures(message) || commitTask(asArray(message), asArray(filterType(rest[0], filterStringOrStringArray, [])), [...asStringArray(filterType(rest[1], filterArray, [])), ...getTrailingOptions(arguments, 0, true)]);
2322
- return this._runTask(task, next);
2323
- } };
2324
- function rejectDeprecatedSignatures(message) {
2325
- return !filterStringOrStringArray(message) && configurationErrorTask(`git.commit: requires the commit message to be supplied as a string/string[]`);
2326
- }
2327
- }
2328
- var init_commit = __esm({ "src/lib/tasks/commit.ts"() {
2329
- "use strict";
2330
- init_parse_commit();
2331
- init_utils();
2332
- init_task();
2333
- } });
2334
- function first_commit_default() {
2335
- return { firstCommit() {
2336
- return this._runTask(straightThroughStringTask([
2337
- "rev-list",
2338
- "--max-parents=0",
2339
- "HEAD"
2340
- ], true), trailingFunctionArgument(arguments));
2341
- } };
2342
- }
2343
- var init_first_commit = __esm({ "src/lib/tasks/first-commit.ts"() {
2344
- "use strict";
2345
- init_utils();
2346
- init_task();
2347
- } });
2348
- function hashObjectTask(filePath, write) {
2349
- const commands = ["hash-object", filePath];
2350
- if (write) commands.push("-w");
2351
- return straightThroughStringTask(commands, true);
2352
- }
2353
- var init_hash_object = __esm({ "src/lib/tasks/hash-object.ts"() {
2354
- "use strict";
2355
- init_task();
2356
- } });
2357
- function parseInit(bare, path, text) {
2358
- const response = String(text).trim();
2359
- let result;
2360
- if (result = initResponseRegex.exec(response)) return new InitSummary(bare, path, false, result[1]);
2361
- if (result = reInitResponseRegex.exec(response)) return new InitSummary(bare, path, true, result[1]);
2362
- let gitDir = "";
2363
- const tokens = response.split(" ");
2364
- while (tokens.length) if (tokens.shift() === "in") {
2365
- gitDir = tokens.join(" ");
2366
- break;
2367
- }
2368
- return new InitSummary(bare, path, /^re/i.test(response), gitDir);
2369
- }
2370
- var InitSummary, initResponseRegex, reInitResponseRegex;
2371
- var init_InitSummary = __esm({ "src/lib/responses/InitSummary.ts"() {
2372
- "use strict";
2373
- InitSummary = class {
2374
- constructor(bare, path, existing, gitDir) {
2375
- this.bare = bare;
2376
- this.path = path;
2377
- this.existing = existing;
2378
- this.gitDir = gitDir;
2379
- }
2380
- };
2381
- initResponseRegex = /^Init.+ repository in (.+)$/;
2382
- reInitResponseRegex = /^Rein.+ in (.+)$/;
2383
- } });
2384
- function hasBareCommand(command) {
2385
- return command.includes(bareCommand);
2386
- }
2387
- function initTask(bare = false, path, customArgs) {
2388
- const commands = ["init", ...customArgs];
2389
- if (bare && !hasBareCommand(commands)) commands.splice(1, 0, bareCommand);
2390
- return {
2391
- commands,
2392
- format: "utf-8",
2393
- parser(text) {
2394
- return parseInit(commands.includes("--bare"), path, text);
2395
- }
2396
- };
2397
- }
2398
- var bareCommand;
2399
- var init_init = __esm({ "src/lib/tasks/init.ts"() {
2400
- "use strict";
2401
- init_InitSummary();
2402
- bareCommand = "--bare";
2403
- } });
2404
- function logFormatFromCommand(customArgs) {
2405
- for (let i = 0; i < customArgs.length; i++) {
2406
- const format = logFormatRegex.exec(customArgs[i]);
2407
- if (format) return `--${format[1]}`;
2408
- }
2409
- return "";
2410
- }
2411
- function isLogFormat(customArg) {
2412
- return logFormatRegex.test(customArg);
2413
- }
2414
- var logFormatRegex;
2415
- var init_log_format = __esm({ "src/lib/args/log-format.ts"() {
2416
- "use strict";
2417
- logFormatRegex = /^--(stat|numstat|name-only|name-status)(=|$)/;
2418
- } });
2419
- var DiffSummary;
2420
- var init_DiffSummary = __esm({ "src/lib/responses/DiffSummary.ts"() {
2421
- "use strict";
2422
- DiffSummary = class {
2423
- constructor() {
2424
- this.changed = 0;
2425
- this.deletions = 0;
2426
- this.insertions = 0;
2427
- this.files = [];
2428
- }
2429
- };
2430
- } });
2431
- function getDiffParser(format = "") {
2432
- const parser4 = diffSummaryParsers[format];
2433
- return (stdOut) => parseStringResponse(new DiffSummary(), parser4, stdOut, false);
2434
- }
2435
- var statParser, numStatParser, nameOnlyParser, nameStatusParser, diffSummaryParsers;
2436
- var init_parse_diff_summary = __esm({ "src/lib/parsers/parse-diff-summary.ts"() {
2437
- "use strict";
2438
- init_log_format();
2439
- init_DiffSummary();
2440
- init_diff_name_status();
2441
- init_utils();
2442
- statParser = [
2443
- new LineParser(/^(.+)\s+\|\s+(\d+)(\s+[+\-]+)?$/, (result, [file, changes, alterations = ""]) => {
2444
- result.files.push({
2445
- file: file.trim(),
2446
- changes: asNumber(changes),
2447
- insertions: alterations.replace(/[^+]/g, "").length,
2448
- deletions: alterations.replace(/[^-]/g, "").length,
2449
- binary: false
2450
- });
2451
- }),
2452
- new LineParser(/^(.+) \|\s+Bin ([0-9.]+) -> ([0-9.]+) ([a-z]+)/, (result, [file, before, after]) => {
2453
- result.files.push({
2454
- file: file.trim(),
2455
- before: asNumber(before),
2456
- after: asNumber(after),
2457
- binary: true
2458
- });
2459
- }),
2460
- new LineParser(/(\d+) files? changed\s*((?:, \d+ [^,]+){0,2})/, (result, [changed, summary]) => {
2461
- const inserted = /(\d+) i/.exec(summary);
2462
- const deleted = /(\d+) d/.exec(summary);
2463
- result.changed = asNumber(changed);
2464
- result.insertions = asNumber(inserted?.[1]);
2465
- result.deletions = asNumber(deleted?.[1]);
2466
- })
2467
- ];
2468
- numStatParser = [new LineParser(/(\d+)\t(\d+)\t(.+)$/, (result, [changesInsert, changesDelete, file]) => {
2469
- const insertions = asNumber(changesInsert);
2470
- const deletions = asNumber(changesDelete);
2471
- result.changed++;
2472
- result.insertions += insertions;
2473
- result.deletions += deletions;
2474
- result.files.push({
2475
- file,
2476
- changes: insertions + deletions,
2477
- insertions,
2478
- deletions,
2479
- binary: false
2480
- });
2481
- }), new LineParser(/-\t-\t(.+)$/, (result, [file]) => {
2482
- result.changed++;
2483
- result.files.push({
2484
- file,
2485
- after: 0,
2486
- before: 0,
2487
- binary: true
2488
- });
2489
- })];
2490
- nameOnlyParser = [new LineParser(/(.+)$/, (result, [file]) => {
2491
- result.changed++;
2492
- result.files.push({
2493
- file,
2494
- changes: 0,
2495
- insertions: 0,
2496
- deletions: 0,
2497
- binary: false
2498
- });
2499
- })];
2500
- nameStatusParser = [new LineParser(/([ACDMRTUXB])([0-9]{0,3})\t(.[^\t]*)(\t(.[^\t]*))?$/, (result, [status, similarity, from, _to, to]) => {
2501
- result.changed++;
2502
- result.files.push({
2503
- file: to ?? from,
2504
- changes: 0,
2505
- insertions: 0,
2506
- deletions: 0,
2507
- binary: false,
2508
- status: orVoid(isDiffNameStatus(status) && status),
2509
- from: orVoid(!!to && from !== to && from),
2510
- similarity: asNumber(similarity)
2511
- });
2512
- })];
2513
- diffSummaryParsers = {
2514
- [""]: statParser,
2515
- ["--stat"]: statParser,
2516
- ["--numstat"]: numStatParser,
2517
- ["--name-status"]: nameStatusParser,
2518
- ["--name-only"]: nameOnlyParser
2519
- };
2520
- } });
2521
- function lineBuilder(tokens, fields) {
2522
- return fields.reduce((line, field, index) => {
2523
- line[field] = tokens[index] || "";
2524
- return line;
2525
- }, /* @__PURE__ */ Object.create({ diff: null }));
2526
- }
2527
- function createListLogSummaryParser(splitter = SPLITTER, fields = defaultFieldNames, logFormat = "") {
2528
- const parseDiffResult = getDiffParser(logFormat);
2529
- return function(stdOut) {
2530
- const all = toLinesWithContent(stdOut.trim(), false, START_BOUNDARY).map(function(item) {
2531
- const lineDetail = item.split(COMMIT_BOUNDARY);
2532
- const listLogLine = lineBuilder(lineDetail[0].split(splitter), fields);
2533
- if (lineDetail.length > 1 && !!lineDetail[1].trim()) listLogLine.diff = parseDiffResult(lineDetail[1]);
2534
- return listLogLine;
2535
- });
2536
- return {
2537
- all,
2538
- latest: all.length && all[0] || null,
2539
- total: all.length
2540
- };
2541
- };
2542
- }
2543
- var START_BOUNDARY, COMMIT_BOUNDARY, SPLITTER, defaultFieldNames;
2544
- var init_parse_list_log_summary = __esm({ "src/lib/parsers/parse-list-log-summary.ts"() {
2545
- "use strict";
2546
- init_utils();
2547
- init_parse_diff_summary();
2548
- init_log_format();
2549
- START_BOUNDARY = "òòòòòò ";
2550
- COMMIT_BOUNDARY = " òò";
2551
- SPLITTER = " ò ";
2552
- defaultFieldNames = [
2553
- "hash",
2554
- "date",
2555
- "message",
2556
- "refs",
2557
- "author_name",
2558
- "author_email"
2559
- ];
2560
- } });
2561
- var diff_exports = {};
2562
- __export(diff_exports, {
2563
- diffSummaryTask: () => diffSummaryTask,
2564
- validateLogFormatConfig: () => validateLogFormatConfig
2565
- });
2566
- function diffSummaryTask(customArgs) {
2567
- let logFormat = logFormatFromCommand(customArgs);
2568
- const commands = ["diff"];
2569
- if (logFormat === "") {
2570
- logFormat = "--stat";
2571
- commands.push("--stat=4096");
2572
- }
2573
- commands.push(...customArgs);
2574
- return validateLogFormatConfig(commands) || {
2575
- commands,
2576
- format: "utf-8",
2577
- parser: getDiffParser(logFormat)
2578
- };
2579
- }
2580
- function validateLogFormatConfig(customArgs) {
2581
- const flags = customArgs.filter(isLogFormat);
2582
- if (flags.length > 1) return configurationErrorTask(`Summary flags are mutually exclusive - pick one of ${flags.join(",")}`);
2583
- if (flags.length && customArgs.includes("-z")) return configurationErrorTask(`Summary flag ${flags} parsing is not compatible with null termination option '-z'`);
2584
- }
2585
- var init_diff = __esm({ "src/lib/tasks/diff.ts"() {
2586
- "use strict";
2587
- init_log_format();
2588
- init_parse_diff_summary();
2589
- init_task();
2590
- } });
2591
- function prettyFormat(format, splitter) {
2592
- const fields = [];
2593
- const formatStr = [];
2594
- Object.keys(format).forEach((field) => {
2595
- fields.push(field);
2596
- formatStr.push(String(format[field]));
2597
- });
2598
- return [fields, formatStr.join(splitter)];
2599
- }
2600
- function userOptions(input) {
2601
- return Object.keys(input).reduce((out, key) => {
2602
- if (!(key in excludeOptions)) out[key] = input[key];
2603
- return out;
2604
- }, {});
2605
- }
2606
- function parseLogOptions(opt = {}, customArgs = []) {
2607
- const splitter = filterType(opt.splitter, filterString, SPLITTER);
2608
- const [fields, formatStr] = prettyFormat(filterPlainObject(opt.format) ? opt.format : {
2609
- hash: "%H",
2610
- date: opt.strictDate === false ? "%ai" : "%aI",
2611
- message: "%s",
2612
- refs: "%D",
2613
- body: opt.multiLine ? "%B" : "%b",
2614
- author_name: opt.mailMap !== false ? "%aN" : "%an",
2615
- author_email: opt.mailMap !== false ? "%aE" : "%ae"
2616
- }, splitter);
2617
- const suffix = [];
2618
- const command = [`--pretty=format:${START_BOUNDARY}${formatStr}${COMMIT_BOUNDARY}`, ...customArgs];
2619
- const maxCount = opt.n || opt["max-count"] || opt.maxCount;
2620
- if (maxCount) command.push(`--max-count=${maxCount}`);
2621
- if (opt.from || opt.to) {
2622
- const rangeOperator = opt.symmetric !== false ? "..." : "..";
2623
- suffix.push(`${opt.from || ""}${rangeOperator}${opt.to || ""}`);
2624
- }
2625
- if (filterString(opt.file)) command.push("--follow", pathspec(opt.file));
2626
- appendTaskOptions(userOptions(opt), command);
2627
- return {
2628
- fields,
2629
- splitter,
2630
- commands: [...command, ...suffix]
2631
- };
2632
- }
2633
- function logTask(splitter, fields, customArgs) {
2634
- const parser4 = createListLogSummaryParser(splitter, fields, logFormatFromCommand(customArgs));
2635
- return {
2636
- commands: ["log", ...customArgs],
2637
- format: "utf-8",
2638
- parser: parser4
2639
- };
2640
- }
2641
- function log_default() {
2642
- return { log(...rest) {
2643
- const next = trailingFunctionArgument(arguments);
2644
- const options = parseLogOptions(trailingOptionsArgument(arguments), asStringArray(filterType(arguments[0], filterArray, [])));
2645
- const task = rejectDeprecatedSignatures(...rest) || validateLogFormatConfig(options.commands) || createLogTask(options);
2646
- return this._runTask(task, next);
2647
- } };
2648
- function createLogTask(options) {
2649
- return logTask(options.splitter, options.fields, options.commands);
2650
- }
2651
- function rejectDeprecatedSignatures(from, to) {
2652
- return filterString(from) && filterString(to) && configurationErrorTask(`git.log(string, string) should be replaced with git.log({ from: string, to: string })`);
2653
- }
2654
- }
2655
- var excludeOptions;
2656
- var init_log = __esm({ "src/lib/tasks/log.ts"() {
2657
- "use strict";
2658
- init_log_format();
2659
- init_pathspec();
2660
- init_parse_list_log_summary();
2661
- init_utils();
2662
- init_task();
2663
- init_diff();
2664
- excludeOptions = /* @__PURE__ */ ((excludeOptions2) => {
2665
- excludeOptions2[excludeOptions2["--pretty"] = 0] = "--pretty";
2666
- excludeOptions2[excludeOptions2["max-count"] = 1] = "max-count";
2667
- excludeOptions2[excludeOptions2["maxCount"] = 2] = "maxCount";
2668
- excludeOptions2[excludeOptions2["n"] = 3] = "n";
2669
- excludeOptions2[excludeOptions2["file"] = 4] = "file";
2670
- excludeOptions2[excludeOptions2["format"] = 5] = "format";
2671
- excludeOptions2[excludeOptions2["from"] = 6] = "from";
2672
- excludeOptions2[excludeOptions2["to"] = 7] = "to";
2673
- excludeOptions2[excludeOptions2["splitter"] = 8] = "splitter";
2674
- excludeOptions2[excludeOptions2["symmetric"] = 9] = "symmetric";
2675
- excludeOptions2[excludeOptions2["mailMap"] = 10] = "mailMap";
2676
- excludeOptions2[excludeOptions2["multiLine"] = 11] = "multiLine";
2677
- excludeOptions2[excludeOptions2["strictDate"] = 12] = "strictDate";
2678
- return excludeOptions2;
2679
- })(excludeOptions || {});
2680
- } });
2681
- var MergeSummaryConflict, MergeSummaryDetail;
2682
- var init_MergeSummary = __esm({ "src/lib/responses/MergeSummary.ts"() {
2683
- "use strict";
2684
- MergeSummaryConflict = class {
2685
- constructor(reason, file = null, meta) {
2686
- this.reason = reason;
2687
- this.file = file;
2688
- this.meta = meta;
2689
- }
2690
- toString() {
2691
- return `${this.file}:${this.reason}`;
2692
- }
2693
- };
2694
- MergeSummaryDetail = class {
2695
- constructor() {
2696
- this.conflicts = [];
2697
- this.merges = [];
2698
- this.result = "success";
2699
- }
2700
- get failed() {
2701
- return this.conflicts.length > 0;
2702
- }
2703
- get reason() {
2704
- return this.result;
2705
- }
2706
- toString() {
2707
- if (this.conflicts.length) return `CONFLICTS: ${this.conflicts.join(", ")}`;
2708
- return "OK";
2709
- }
2710
- };
2711
- } });
2712
- var PullSummary, PullFailedSummary;
2713
- var init_PullSummary = __esm({ "src/lib/responses/PullSummary.ts"() {
2714
- "use strict";
2715
- PullSummary = class {
2716
- constructor() {
2717
- this.remoteMessages = { all: [] };
2718
- this.created = [];
2719
- this.deleted = [];
2720
- this.files = [];
2721
- this.deletions = {};
2722
- this.insertions = {};
2723
- this.summary = {
2724
- changes: 0,
2725
- deletions: 0,
2726
- insertions: 0
2727
- };
2728
- }
2729
- };
2730
- PullFailedSummary = class {
2731
- constructor() {
2732
- this.remote = "";
2733
- this.hash = {
2734
- local: "",
2735
- remote: ""
2736
- };
2737
- this.branch = {
2738
- local: "",
2739
- remote: ""
2740
- };
2741
- this.message = "";
2742
- }
2743
- toString() {
2744
- return this.message;
2745
- }
2746
- };
2747
- } });
2748
- function objectEnumerationResult(remoteMessages) {
2749
- return remoteMessages.objects = remoteMessages.objects || {
2750
- compressing: 0,
2751
- counting: 0,
2752
- enumerating: 0,
2753
- packReused: 0,
2754
- reused: {
2755
- count: 0,
2756
- delta: 0
2757
- },
2758
- total: {
2759
- count: 0,
2760
- delta: 0
2761
- }
2762
- };
2763
- }
2764
- function asObjectCount(source) {
2765
- const count = /^\s*(\d+)/.exec(source);
2766
- const delta = /delta (\d+)/i.exec(source);
2767
- return {
2768
- count: asNumber(count && count[1] || "0"),
2769
- delta: asNumber(delta && delta[1] || "0")
2770
- };
2771
- }
2772
- var remoteMessagesObjectParsers;
2773
- var init_parse_remote_objects = __esm({ "src/lib/parsers/parse-remote-objects.ts"() {
2774
- "use strict";
2775
- init_utils();
2776
- remoteMessagesObjectParsers = [
2777
- new RemoteLineParser(/^remote:\s*(enumerating|counting|compressing) objects: (\d+),/i, (result, [action, count]) => {
2778
- const key = action.toLowerCase();
2779
- const enumeration = objectEnumerationResult(result.remoteMessages);
2780
- Object.assign(enumeration, { [key]: asNumber(count) });
2781
- }),
2782
- new RemoteLineParser(/^remote:\s*(enumerating|counting|compressing) objects: \d+% \(\d+\/(\d+)\),/i, (result, [action, count]) => {
2783
- const key = action.toLowerCase();
2784
- const enumeration = objectEnumerationResult(result.remoteMessages);
2785
- Object.assign(enumeration, { [key]: asNumber(count) });
2786
- }),
2787
- new RemoteLineParser(/total ([^,]+), reused ([^,]+), pack-reused (\d+)/i, (result, [total, reused, packReused]) => {
2788
- const objects = objectEnumerationResult(result.remoteMessages);
2789
- objects.total = asObjectCount(total);
2790
- objects.reused = asObjectCount(reused);
2791
- objects.packReused = asNumber(packReused);
2792
- })
2793
- ];
2794
- } });
2795
- function parseRemoteMessages(_stdOut, stdErr) {
2796
- return parseStringResponse({ remoteMessages: new RemoteMessageSummary() }, parsers2, stdErr);
2797
- }
2798
- var parsers2, RemoteMessageSummary;
2799
- var init_parse_remote_messages = __esm({ "src/lib/parsers/parse-remote-messages.ts"() {
2800
- "use strict";
2801
- init_utils();
2802
- init_parse_remote_objects();
2803
- parsers2 = [
2804
- new RemoteLineParser(/^remote:\s*(.+)$/, (result, [text]) => {
2805
- result.remoteMessages.all.push(text.trim());
2806
- return false;
2807
- }),
2808
- ...remoteMessagesObjectParsers,
2809
- new RemoteLineParser([/create a (?:pull|merge) request/i, /\s(https?:\/\/\S+)$/], (result, [pullRequestUrl]) => {
2810
- result.remoteMessages.pullRequestUrl = pullRequestUrl;
2811
- }),
2812
- new RemoteLineParser([/found (\d+) vulnerabilities.+\(([^)]+)\)/i, /\s(https?:\/\/\S+)$/], (result, [count, summary, url]) => {
2813
- result.remoteMessages.vulnerabilities = {
2814
- count: asNumber(count),
2815
- summary,
2816
- url
2817
- };
2818
- })
2819
- ];
2820
- RemoteMessageSummary = class {
2821
- constructor() {
2822
- this.all = [];
2823
- }
2824
- };
2825
- } });
2826
- function parsePullErrorResult(stdOut, stdErr) {
2827
- const pullError = parseStringResponse(new PullFailedSummary(), errorParsers, [stdOut, stdErr]);
2828
- return pullError.message && pullError;
2829
- }
2830
- var FILE_UPDATE_REGEX, SUMMARY_REGEX, ACTION_REGEX, parsers3, errorParsers, parsePullDetail, parsePullResult;
2831
- var init_parse_pull = __esm({ "src/lib/parsers/parse-pull.ts"() {
2832
- "use strict";
2833
- init_PullSummary();
2834
- init_utils();
2835
- init_parse_remote_messages();
2836
- FILE_UPDATE_REGEX = /^\s*(.+?)\s+\|\s+\d+\s*(\+*)(-*)/;
2837
- SUMMARY_REGEX = /(\d+)\D+((\d+)\D+\(\+\))?(\D+(\d+)\D+\(-\))?/;
2838
- ACTION_REGEX = /^(create|delete) mode \d+ (.+)/;
2839
- parsers3 = [
2840
- new LineParser(FILE_UPDATE_REGEX, (result, [file, insertions, deletions]) => {
2841
- result.files.push(file);
2842
- if (insertions) result.insertions[file] = insertions.length;
2843
- if (deletions) result.deletions[file] = deletions.length;
2844
- }),
2845
- new LineParser(SUMMARY_REGEX, (result, [changes, , insertions, , deletions]) => {
2846
- if (insertions !== void 0 || deletions !== void 0) {
2847
- result.summary.changes = +changes || 0;
2848
- result.summary.insertions = +insertions || 0;
2849
- result.summary.deletions = +deletions || 0;
2850
- return true;
2851
- }
2852
- return false;
2853
- }),
2854
- new LineParser(ACTION_REGEX, (result, [action, file]) => {
2855
- append(result.files, file);
2856
- append(action === "create" ? result.created : result.deleted, file);
2857
- })
2858
- ];
2859
- errorParsers = [
2860
- new LineParser(/^from\s(.+)$/i, (result, [remote]) => void (result.remote = remote)),
2861
- new LineParser(/^fatal:\s(.+)$/, (result, [message]) => void (result.message = message)),
2862
- new LineParser(/([a-z0-9]+)\.\.([a-z0-9]+)\s+(\S+)\s+->\s+(\S+)$/, (result, [hashLocal, hashRemote, branchLocal, branchRemote]) => {
2863
- result.branch.local = branchLocal;
2864
- result.hash.local = hashLocal;
2865
- result.branch.remote = branchRemote;
2866
- result.hash.remote = hashRemote;
2867
- })
2868
- ];
2869
- parsePullDetail = (stdOut, stdErr) => {
2870
- return parseStringResponse(new PullSummary(), parsers3, [stdOut, stdErr]);
2871
- };
2872
- parsePullResult = (stdOut, stdErr) => {
2873
- return Object.assign(new PullSummary(), parsePullDetail(stdOut, stdErr), parseRemoteMessages(stdOut, stdErr));
2874
- };
2875
- } });
2876
- var parsers4, parseMergeResult, parseMergeDetail;
2877
- var init_parse_merge = __esm({ "src/lib/parsers/parse-merge.ts"() {
2878
- "use strict";
2879
- init_MergeSummary();
2880
- init_utils();
2881
- init_parse_pull();
2882
- parsers4 = [
2883
- new LineParser(/^Auto-merging\s+(.+)$/, (summary, [autoMerge]) => {
2884
- summary.merges.push(autoMerge);
2885
- }),
2886
- new LineParser(/^CONFLICT\s+\((.+)\): Merge conflict in (.+)$/, (summary, [reason, file]) => {
2887
- summary.conflicts.push(new MergeSummaryConflict(reason, file));
2888
- }),
2889
- new LineParser(/^CONFLICT\s+\((.+\/delete)\): (.+) deleted in (.+) and/, (summary, [reason, file, deleteRef]) => {
2890
- summary.conflicts.push(new MergeSummaryConflict(reason, file, { deleteRef }));
2891
- }),
2892
- new LineParser(/^CONFLICT\s+\((.+)\):/, (summary, [reason]) => {
2893
- summary.conflicts.push(new MergeSummaryConflict(reason, null));
2894
- }),
2895
- new LineParser(/^Automatic merge failed;\s+(.+)$/, (summary, [result]) => {
2896
- summary.result = result;
2897
- })
2898
- ];
2899
- parseMergeResult = (stdOut, stdErr) => {
2900
- return Object.assign(parseMergeDetail(stdOut, stdErr), parsePullResult(stdOut, stdErr));
2901
- };
2902
- parseMergeDetail = (stdOut) => {
2903
- return parseStringResponse(new MergeSummaryDetail(), parsers4, stdOut);
2904
- };
2905
- } });
2906
- function mergeTask(customArgs) {
2907
- if (!customArgs.length) return configurationErrorTask("Git.merge requires at least one option");
2908
- return {
2909
- commands: ["merge", ...customArgs],
2910
- format: "utf-8",
2911
- parser(stdOut, stdErr) {
2912
- const merge = parseMergeResult(stdOut, stdErr);
2913
- if (merge.failed) throw new GitResponseError(merge);
2914
- return merge;
2915
- }
2916
- };
2917
- }
2918
- var init_merge = __esm({ "src/lib/tasks/merge.ts"() {
2919
- "use strict";
2920
- init_git_response_error();
2921
- init_parse_merge();
2922
- init_task();
2923
- } });
2924
- function pushResultPushedItem(local, remote, status) {
2925
- const deleted = status.includes("deleted");
2926
- const tag = status.includes("tag") || /^refs\/tags/.test(local);
2927
- const alreadyUpdated = !status.includes("new");
2928
- return {
2929
- deleted,
2930
- tag,
2931
- branch: !tag,
2932
- new: !alreadyUpdated,
2933
- alreadyUpdated,
2934
- local,
2935
- remote
2936
- };
2937
- }
2938
- var parsers5, parsePushResult, parsePushDetail;
2939
- var init_parse_push = __esm({ "src/lib/parsers/parse-push.ts"() {
2940
- "use strict";
2941
- init_utils();
2942
- init_parse_remote_messages();
2943
- parsers5 = [
2944
- new LineParser(/^Pushing to (.+)$/, (result, [repo]) => {
2945
- result.repo = repo;
2946
- }),
2947
- new LineParser(/^updating local tracking ref '(.+)'/, (result, [local]) => {
2948
- result.ref = {
2949
- ...result.ref || {},
2950
- local
2951
- };
2952
- }),
2953
- new LineParser(/^[=*-]\s+([^:]+):(\S+)\s+\[(.+)]$/, (result, [local, remote, type]) => {
2954
- result.pushed.push(pushResultPushedItem(local, remote, type));
2955
- }),
2956
- new LineParser(/^Branch '([^']+)' set up to track remote branch '([^']+)' from '([^']+)'/, (result, [local, remote, remoteName]) => {
2957
- result.branch = {
2958
- ...result.branch || {},
2959
- local,
2960
- remote,
2961
- remoteName
2962
- };
2963
- }),
2964
- new LineParser(/^([^:]+):(\S+)\s+([a-z0-9]+)\.\.([a-z0-9]+)$/, (result, [local, remote, from, to]) => {
2965
- result.update = {
2966
- head: {
2967
- local,
2968
- remote
2969
- },
2970
- hash: {
2971
- from,
2972
- to
2973
- }
2974
- };
2975
- })
2976
- ];
2977
- parsePushResult = (stdOut, stdErr) => {
2978
- const pushDetail = parsePushDetail(stdOut, stdErr);
2979
- const responseDetail = parseRemoteMessages(stdOut, stdErr);
2980
- return {
2981
- ...pushDetail,
2982
- ...responseDetail
2983
- };
2984
- };
2985
- parsePushDetail = (stdOut, stdErr) => {
2986
- return parseStringResponse({ pushed: [] }, parsers5, [stdOut, stdErr]);
2987
- };
2988
- } });
2989
- var push_exports = {};
2990
- __export(push_exports, {
2991
- pushTagsTask: () => pushTagsTask,
2992
- pushTask: () => pushTask
2993
- });
2994
- function pushTagsTask(ref = {}, customArgs) {
2995
- append(customArgs, "--tags");
2996
- return pushTask(ref, customArgs);
2997
- }
2998
- function pushTask(ref = {}, customArgs) {
2999
- const commands = ["push", ...customArgs];
3000
- if (ref.branch) commands.splice(1, 0, ref.branch);
3001
- if (ref.remote) commands.splice(1, 0, ref.remote);
3002
- remove(commands, "-v");
3003
- append(commands, "--verbose");
3004
- append(commands, "--porcelain");
3005
- return {
3006
- commands,
3007
- format: "utf-8",
3008
- parser: parsePushResult
3009
- };
3010
- }
3011
- var init_push = __esm({ "src/lib/tasks/push.ts"() {
3012
- "use strict";
3013
- init_parse_push();
3014
- init_utils();
3015
- } });
3016
- function show_default() {
3017
- return {
3018
- showBuffer() {
3019
- const commands = ["show", ...getTrailingOptions(arguments, 1)];
3020
- if (!commands.includes("--binary")) commands.splice(1, 0, "--binary");
3021
- return this._runTask(straightThroughBufferTask(commands), trailingFunctionArgument(arguments));
3022
- },
3023
- show() {
3024
- const commands = ["show", ...getTrailingOptions(arguments, 1)];
3025
- return this._runTask(straightThroughStringTask(commands), trailingFunctionArgument(arguments));
3026
- }
3027
- };
3028
- }
3029
- var init_show = __esm({ "src/lib/tasks/show.ts"() {
3030
- "use strict";
3031
- init_utils();
3032
- init_task();
3033
- } });
3034
- var fromPathRegex, FileStatusSummary;
3035
- var init_FileStatusSummary = __esm({ "src/lib/responses/FileStatusSummary.ts"() {
3036
- "use strict";
3037
- fromPathRegex = /^(.+)\0(.+)$/;
3038
- FileStatusSummary = class {
3039
- constructor(path, index, working_dir) {
3040
- this.path = path;
3041
- this.index = index;
3042
- this.working_dir = working_dir;
3043
- if (index === "R" || working_dir === "R") {
3044
- const detail = fromPathRegex.exec(path) || [
3045
- null,
3046
- path,
3047
- path
3048
- ];
3049
- this.from = detail[2] || "";
3050
- this.path = detail[1] || "";
3051
- }
3052
- }
3053
- };
3054
- } });
3055
- function renamedFile(line) {
3056
- const [to, from] = line.split(NULL);
3057
- return {
3058
- from: from || to,
3059
- to
3060
- };
3061
- }
3062
- function parser3(indexX, indexY, handler) {
3063
- return [`${indexX}${indexY}`, handler];
3064
- }
3065
- function conflicts(indexX, ...indexY) {
3066
- return indexY.map((y) => parser3(indexX, y, (result, file) => append(result.conflicted, file)));
3067
- }
3068
- function splitLine(result, lineStr) {
3069
- const trimmed2 = lineStr.trim();
3070
- switch (" ") {
3071
- case trimmed2.charAt(2): return data(trimmed2.charAt(0), trimmed2.charAt(1), trimmed2.substr(3));
3072
- case trimmed2.charAt(1): return data(" ", trimmed2.charAt(0), trimmed2.substr(2));
3073
- default: return;
3074
- }
3075
- function data(index, workingDir, path) {
3076
- const raw = `${index}${workingDir}`;
3077
- const handler = parsers6.get(raw);
3078
- if (handler) handler(result, path);
3079
- if (raw !== "##" && raw !== "!!") result.files.push(new FileStatusSummary(path, index, workingDir));
3080
- }
3081
- }
3082
- var StatusSummary, parsers6, parseStatusSummary;
3083
- var init_StatusSummary = __esm({ "src/lib/responses/StatusSummary.ts"() {
3084
- "use strict";
3085
- init_utils();
3086
- init_FileStatusSummary();
3087
- StatusSummary = class {
3088
- constructor() {
3089
- this.not_added = [];
3090
- this.conflicted = [];
3091
- this.created = [];
3092
- this.deleted = [];
3093
- this.ignored = void 0;
3094
- this.modified = [];
3095
- this.renamed = [];
3096
- this.files = [];
3097
- this.staged = [];
3098
- this.ahead = 0;
3099
- this.behind = 0;
3100
- this.current = null;
3101
- this.tracking = null;
3102
- this.detached = false;
3103
- this.isClean = () => {
3104
- return !this.files.length;
3105
- };
3106
- }
3107
- };
3108
- parsers6 = new Map([
3109
- parser3(" ", "A", (result, file) => append(result.created, file)),
3110
- parser3(" ", "D", (result, file) => append(result.deleted, file)),
3111
- parser3(" ", "M", (result, file) => append(result.modified, file)),
3112
- parser3("A", " ", (result, file) => append(result.created, file) && append(result.staged, file)),
3113
- parser3("A", "M", (result, file) => append(result.created, file) && append(result.staged, file) && append(result.modified, file)),
3114
- parser3("D", " ", (result, file) => append(result.deleted, file) && append(result.staged, file)),
3115
- parser3("M", " ", (result, file) => append(result.modified, file) && append(result.staged, file)),
3116
- parser3("M", "M", (result, file) => append(result.modified, file) && append(result.staged, file)),
3117
- parser3("R", " ", (result, file) => {
3118
- append(result.renamed, renamedFile(file));
3119
- }),
3120
- parser3("R", "M", (result, file) => {
3121
- const renamed = renamedFile(file);
3122
- append(result.renamed, renamed);
3123
- append(result.modified, renamed.to);
3124
- }),
3125
- parser3("!", "!", (_result, _file) => {
3126
- append(_result.ignored = _result.ignored || [], _file);
3127
- }),
3128
- parser3("?", "?", (result, file) => append(result.not_added, file)),
3129
- ...conflicts("A", "A", "U"),
3130
- ...conflicts("D", "D", "U"),
3131
- ...conflicts("U", "A", "D", "U"),
3132
- ["##", (result, line) => {
3133
- const aheadReg = /ahead (\d+)/;
3134
- const behindReg = /behind (\d+)/;
3135
- const currentReg = /^(.+?(?=(?:\.{3}|\s|$)))/;
3136
- const trackingReg = /\.{3}(\S*)/;
3137
- const onEmptyBranchReg = /\son\s(\S+?)(?=\.{3}|$)/;
3138
- let regexResult = aheadReg.exec(line);
3139
- result.ahead = regexResult && +regexResult[1] || 0;
3140
- regexResult = behindReg.exec(line);
3141
- result.behind = regexResult && +regexResult[1] || 0;
3142
- regexResult = currentReg.exec(line);
3143
- result.current = filterType(regexResult?.[1], filterString, null);
3144
- regexResult = trackingReg.exec(line);
3145
- result.tracking = filterType(regexResult?.[1], filterString, null);
3146
- regexResult = onEmptyBranchReg.exec(line);
3147
- if (regexResult) result.current = filterType(regexResult?.[1], filterString, result.current);
3148
- result.detached = /\(no branch\)/.test(line);
3149
- }]
3150
- ]);
3151
- parseStatusSummary = function(text) {
3152
- const lines = text.split(NULL);
3153
- const status = new StatusSummary();
3154
- for (let i = 0, l = lines.length; i < l;) {
3155
- let line = lines[i++].trim();
3156
- if (!line) continue;
3157
- if (line.charAt(0) === "R") line += NULL + (lines[i++] || "");
3158
- splitLine(status, line);
3159
- }
3160
- return status;
3161
- };
3162
- } });
3163
- function statusTask(customArgs) {
3164
- return {
3165
- format: "utf-8",
3166
- commands: [
3167
- "status",
3168
- "--porcelain",
3169
- "-b",
3170
- "-u",
3171
- "--null",
3172
- ...customArgs.filter((arg) => !ignoredOptions.includes(arg))
3173
- ],
3174
- parser(text) {
3175
- return parseStatusSummary(text);
3176
- }
3177
- };
3178
- }
3179
- var ignoredOptions;
3180
- var init_status = __esm({ "src/lib/tasks/status.ts"() {
3181
- "use strict";
3182
- init_StatusSummary();
3183
- ignoredOptions = ["--null", "-z"];
3184
- } });
3185
- function versionResponse(major = 0, minor = 0, patch = 0, agent = "", installed = true) {
3186
- return Object.defineProperty({
3187
- major,
3188
- minor,
3189
- patch,
3190
- agent,
3191
- installed
3192
- }, "toString", {
3193
- value() {
3194
- return `${this.major}.${this.minor}.${this.patch}`;
3195
- },
3196
- configurable: false,
3197
- enumerable: false
3198
- });
3199
- }
3200
- function notInstalledResponse() {
3201
- return versionResponse(0, 0, 0, "", false);
3202
- }
3203
- function version_default() {
3204
- return { version() {
3205
- return this._runTask({
3206
- commands: ["--version"],
3207
- format: "utf-8",
3208
- parser: versionParser,
3209
- onError(result, error, done, fail) {
3210
- if (result.exitCode === -2) return done(Buffer.from(NOT_INSTALLED));
3211
- fail(error);
3212
- }
3213
- });
3214
- } };
3215
- }
3216
- function versionParser(stdOut) {
3217
- if (stdOut === NOT_INSTALLED) return notInstalledResponse();
3218
- return parseStringResponse(versionResponse(0, 0, 0, stdOut), parsers7, stdOut);
3219
- }
3220
- var NOT_INSTALLED, parsers7;
3221
- var init_version = __esm({ "src/lib/tasks/version.ts"() {
3222
- "use strict";
3223
- init_utils();
3224
- NOT_INSTALLED = "installed=false";
3225
- parsers7 = [new LineParser(/version (\d+)\.(\d+)\.(\d+)(?:\s*\((.+)\))?/, (result, [major, minor, patch, agent = ""]) => {
3226
- Object.assign(result, versionResponse(asNumber(major), asNumber(minor), asNumber(patch), agent));
3227
- }), new LineParser(/version (\d+)\.(\d+)\.(\D+)(.+)?$/, (result, [major, minor, patch, agent = ""]) => {
3228
- Object.assign(result, versionResponse(asNumber(major), asNumber(minor), patch, agent));
3229
- })];
3230
- } });
3231
- var simple_git_api_exports = {};
3232
- __export(simple_git_api_exports, { SimpleGitApi: () => SimpleGitApi });
3233
- var SimpleGitApi;
3234
- var init_simple_git_api = __esm({ "src/lib/simple-git-api.ts"() {
3235
- "use strict";
3236
- init_task_callback();
3237
- init_change_working_directory();
3238
- init_checkout();
3239
- init_count_objects();
3240
- init_commit();
3241
- init_config();
3242
- init_first_commit();
3243
- init_grep();
3244
- init_hash_object();
3245
- init_init();
3246
- init_log();
3247
- init_merge();
3248
- init_push();
3249
- init_show();
3250
- init_status();
3251
- init_task();
3252
- init_version();
3253
- init_utils();
3254
- SimpleGitApi = class {
3255
- constructor(_executor) {
3256
- this._executor = _executor;
3257
- }
3258
- _runTask(task, then) {
3259
- const chain = this._executor.chain();
3260
- const promise = chain.push(task);
3261
- if (then) taskCallback(task, promise, then);
3262
- return Object.create(this, {
3263
- then: { value: promise.then.bind(promise) },
3264
- catch: { value: promise.catch.bind(promise) },
3265
- _executor: { value: chain }
3266
- });
3267
- }
3268
- add(files) {
3269
- return this._runTask(straightThroughStringTask(["add", ...asArray(files)]), trailingFunctionArgument(arguments));
3270
- }
3271
- cwd(directory) {
3272
- const next = trailingFunctionArgument(arguments);
3273
- if (typeof directory === "string") return this._runTask(changeWorkingDirectoryTask(directory, this._executor), next);
3274
- if (typeof directory?.path === "string") return this._runTask(changeWorkingDirectoryTask(directory.path, directory.root && this._executor || void 0), next);
3275
- return this._runTask(configurationErrorTask("Git.cwd: workingDirectory must be supplied as a string"), next);
3276
- }
3277
- hashObject(path, write) {
3278
- return this._runTask(hashObjectTask(path, write === true), trailingFunctionArgument(arguments));
3279
- }
3280
- init(bare) {
3281
- return this._runTask(initTask(bare === true, this._executor.cwd, getTrailingOptions(arguments)), trailingFunctionArgument(arguments));
3282
- }
3283
- merge() {
3284
- return this._runTask(mergeTask(getTrailingOptions(arguments)), trailingFunctionArgument(arguments));
3285
- }
3286
- mergeFromTo(remote, branch) {
3287
- if (!(filterString(remote) && filterString(branch))) return this._runTask(configurationErrorTask(`Git.mergeFromTo requires that the 'remote' and 'branch' arguments are supplied as strings`));
3288
- return this._runTask(mergeTask([
3289
- remote,
3290
- branch,
3291
- ...getTrailingOptions(arguments)
3292
- ]), trailingFunctionArgument(arguments, false));
3293
- }
3294
- outputHandler(handler) {
3295
- this._executor.outputHandler = handler;
3296
- return this;
3297
- }
3298
- push() {
3299
- const task = pushTask({
3300
- remote: filterType(arguments[0], filterString),
3301
- branch: filterType(arguments[1], filterString)
3302
- }, getTrailingOptions(arguments));
3303
- return this._runTask(task, trailingFunctionArgument(arguments));
3304
- }
3305
- stash() {
3306
- return this._runTask(straightThroughStringTask(["stash", ...getTrailingOptions(arguments)]), trailingFunctionArgument(arguments));
3307
- }
3308
- status() {
3309
- return this._runTask(statusTask(getTrailingOptions(arguments)), trailingFunctionArgument(arguments));
3310
- }
3311
- };
3312
- Object.assign(SimpleGitApi.prototype, checkout_default(), commit_default(), config_default(), count_objects_default(), first_commit_default(), grep_default(), log_default(), show_default(), version_default());
3313
- } });
3314
- var scheduler_exports = {};
3315
- __export(scheduler_exports, { Scheduler: () => Scheduler });
3316
- var createScheduledTask, Scheduler;
3317
- var init_scheduler = __esm({ "src/lib/runners/scheduler.ts"() {
3318
- "use strict";
3319
- init_utils();
3320
- init_git_logger();
3321
- createScheduledTask = /* @__PURE__ */ (() => {
3322
- let id = 0;
3323
- return () => {
3324
- id++;
3325
- const { promise, done } = (0, import_dist$1.createDeferred)();
3326
- return {
3327
- promise,
3328
- done,
3329
- id
3330
- };
3331
- };
3332
- })();
3333
- Scheduler = class {
3334
- constructor(concurrency = 2) {
3335
- this.concurrency = concurrency;
3336
- this.logger = createLogger("", "scheduler");
3337
- this.pending = [];
3338
- this.running = [];
3339
- this.logger(`Constructed, concurrency=%s`, concurrency);
3340
- }
3341
- schedule() {
3342
- if (!this.pending.length || this.running.length >= this.concurrency) {
3343
- this.logger(`Schedule attempt ignored, pending=%s running=%s concurrency=%s`, this.pending.length, this.running.length, this.concurrency);
3344
- return;
3345
- }
3346
- const task = append(this.running, this.pending.shift());
3347
- this.logger(`Attempting id=%s`, task.id);
3348
- task.done(() => {
3349
- this.logger(`Completing id=`, task.id);
3350
- remove(this.running, task);
3351
- this.schedule();
3352
- });
3353
- }
3354
- next() {
3355
- const { promise, id } = append(this.pending, createScheduledTask());
3356
- this.logger(`Scheduling id=%s`, id);
3357
- this.schedule();
3358
- return promise;
3359
- }
3360
- };
3361
- } });
3362
- var apply_patch_exports = {};
3363
- __export(apply_patch_exports, { applyPatchTask: () => applyPatchTask });
3364
- function applyPatchTask(patches, customArgs) {
3365
- return straightThroughStringTask([
3366
- "apply",
3367
- ...customArgs,
3368
- ...patches
3369
- ]);
3370
- }
3371
- var init_apply_patch = __esm({ "src/lib/tasks/apply-patch.ts"() {
3372
- "use strict";
3373
- init_task();
3374
- } });
3375
- function branchDeletionSuccess(branch, hash) {
3376
- return {
3377
- branch,
3378
- hash,
3379
- success: true
3380
- };
3381
- }
3382
- function branchDeletionFailure(branch) {
3383
- return {
3384
- branch,
3385
- hash: null,
3386
- success: false
3387
- };
3388
- }
3389
- var BranchDeletionBatch;
3390
- var init_BranchDeleteSummary = __esm({ "src/lib/responses/BranchDeleteSummary.ts"() {
3391
- "use strict";
3392
- BranchDeletionBatch = class {
3393
- constructor() {
3394
- this.all = [];
3395
- this.branches = {};
3396
- this.errors = [];
3397
- }
3398
- get success() {
3399
- return !this.errors.length;
3400
- }
3401
- };
3402
- } });
3403
- function hasBranchDeletionError(data, processExitCode) {
3404
- return processExitCode === 1 && deleteErrorRegex.test(data);
3405
- }
3406
- var deleteSuccessRegex, deleteErrorRegex, parsers8, parseBranchDeletions;
3407
- var init_parse_branch_delete = __esm({ "src/lib/parsers/parse-branch-delete.ts"() {
3408
- "use strict";
3409
- init_BranchDeleteSummary();
3410
- init_utils();
3411
- deleteSuccessRegex = /(\S+)\s+\(\S+\s([^)]+)\)/;
3412
- deleteErrorRegex = /^error[^']+'([^']+)'/m;
3413
- parsers8 = [new LineParser(deleteSuccessRegex, (result, [branch, hash]) => {
3414
- const deletion = branchDeletionSuccess(branch, hash);
3415
- result.all.push(deletion);
3416
- result.branches[branch] = deletion;
3417
- }), new LineParser(deleteErrorRegex, (result, [branch]) => {
3418
- const deletion = branchDeletionFailure(branch);
3419
- result.errors.push(deletion);
3420
- result.all.push(deletion);
3421
- result.branches[branch] = deletion;
3422
- })];
3423
- parseBranchDeletions = (stdOut, stdErr) => {
3424
- return parseStringResponse(new BranchDeletionBatch(), parsers8, [stdOut, stdErr]);
3425
- };
3426
- } });
3427
- var BranchSummaryResult;
3428
- var init_BranchSummary = __esm({ "src/lib/responses/BranchSummary.ts"() {
3429
- "use strict";
3430
- BranchSummaryResult = class {
3431
- constructor() {
3432
- this.all = [];
3433
- this.branches = {};
3434
- this.current = "";
3435
- this.detached = false;
3436
- }
3437
- push(status, detached, name, commit, label) {
3438
- if (status === "*") {
3439
- this.detached = detached;
3440
- this.current = name;
3441
- }
3442
- this.all.push(name);
3443
- this.branches[name] = {
3444
- current: status === "*",
3445
- linkedWorkTree: status === "+",
3446
- name,
3447
- commit,
3448
- label
3449
- };
3450
- }
3451
- };
3452
- } });
3453
- function branchStatus(input) {
3454
- return input ? input.charAt(0) : "";
3455
- }
3456
- function parseBranchSummary(stdOut, currentOnly = false) {
3457
- return parseStringResponse(new BranchSummaryResult(), currentOnly ? [currentBranchParser] : parsers9, stdOut);
3458
- }
3459
- var parsers9, currentBranchParser;
3460
- var init_parse_branch = __esm({ "src/lib/parsers/parse-branch.ts"() {
3461
- "use strict";
3462
- init_BranchSummary();
3463
- init_utils();
3464
- parsers9 = [new LineParser(/^([*+]\s)?\((?:HEAD )?detached (?:from|at) (\S+)\)\s+([a-z0-9]+)\s(.*)$/, (result, [current, name, commit, label]) => {
3465
- result.push(branchStatus(current), true, name, commit, label);
3466
- }), new LineParser(/^([*+]\s)?(\S+)\s+([a-z0-9]+)\s?(.*)$/s, (result, [current, name, commit, label]) => {
3467
- result.push(branchStatus(current), false, name, commit, label);
3468
- })];
3469
- currentBranchParser = new LineParser(/^(\S+)$/s, (result, [name]) => {
3470
- result.push("*", false, name, "", "");
3471
- });
3472
- } });
3473
- var branch_exports = {};
3474
- __export(branch_exports, {
3475
- branchLocalTask: () => branchLocalTask,
3476
- branchTask: () => branchTask,
3477
- containsDeleteBranchCommand: () => containsDeleteBranchCommand,
3478
- deleteBranchTask: () => deleteBranchTask,
3479
- deleteBranchesTask: () => deleteBranchesTask
3480
- });
3481
- function containsDeleteBranchCommand(commands) {
3482
- const deleteCommands = [
3483
- "-d",
3484
- "-D",
3485
- "--delete"
3486
- ];
3487
- return commands.some((command) => deleteCommands.includes(command));
3488
- }
3489
- function branchTask(customArgs) {
3490
- const isDelete = containsDeleteBranchCommand(customArgs);
3491
- const isCurrentOnly = customArgs.includes("--show-current");
3492
- const commands = ["branch", ...customArgs];
3493
- if (commands.length === 1) commands.push("-a");
3494
- if (!commands.includes("-v")) commands.splice(1, 0, "-v");
3495
- return {
3496
- format: "utf-8",
3497
- commands,
3498
- parser(stdOut, stdErr) {
3499
- if (isDelete) return parseBranchDeletions(stdOut, stdErr).all[0];
3500
- return parseBranchSummary(stdOut, isCurrentOnly);
3501
- }
3502
- };
3503
- }
3504
- function branchLocalTask() {
3505
- return {
3506
- format: "utf-8",
3507
- commands: ["branch", "-v"],
3508
- parser(stdOut) {
3509
- return parseBranchSummary(stdOut);
3510
- }
3511
- };
3512
- }
3513
- function deleteBranchesTask(branches, forceDelete = false) {
3514
- return {
3515
- format: "utf-8",
3516
- commands: [
3517
- "branch",
3518
- "-v",
3519
- forceDelete ? "-D" : "-d",
3520
- ...branches
3521
- ],
3522
- parser(stdOut, stdErr) {
3523
- return parseBranchDeletions(stdOut, stdErr);
3524
- },
3525
- onError({ exitCode, stdOut }, error, done, fail) {
3526
- if (!hasBranchDeletionError(String(error), exitCode)) return fail(error);
3527
- done(stdOut);
3528
- }
3529
- };
3530
- }
3531
- function deleteBranchTask(branch, forceDelete = false) {
3532
- const task = {
3533
- format: "utf-8",
3534
- commands: [
3535
- "branch",
3536
- "-v",
3537
- forceDelete ? "-D" : "-d",
3538
- branch
3539
- ],
3540
- parser(stdOut, stdErr) {
3541
- return parseBranchDeletions(stdOut, stdErr).branches[branch];
3542
- },
3543
- onError({ exitCode, stdErr, stdOut }, error, _, fail) {
3544
- if (!hasBranchDeletionError(String(error), exitCode)) return fail(error);
3545
- throw new GitResponseError(task.parser(bufferToString(stdOut), bufferToString(stdErr)), String(error));
3546
- }
3547
- };
3548
- return task;
3549
- }
3550
- var init_branch = __esm({ "src/lib/tasks/branch.ts"() {
3551
- "use strict";
3552
- init_git_response_error();
3553
- init_parse_branch_delete();
3554
- init_parse_branch();
3555
- init_utils();
3556
- } });
3557
- function toPath(input) {
3558
- const path = input.trim().replace(/^["']|["']$/g, "");
3559
- return path && normalize(path);
3560
- }
3561
- var parseCheckIgnore;
3562
- var init_CheckIgnore = __esm({ "src/lib/responses/CheckIgnore.ts"() {
3563
- "use strict";
3564
- parseCheckIgnore = (text) => {
3565
- return text.split(/\n/g).map(toPath).filter(Boolean);
3566
- };
3567
- } });
3568
- var check_ignore_exports = {};
3569
- __export(check_ignore_exports, { checkIgnoreTask: () => checkIgnoreTask });
3570
- function checkIgnoreTask(paths) {
3571
- return {
3572
- commands: ["check-ignore", ...paths],
3573
- format: "utf-8",
3574
- parser: parseCheckIgnore
3575
- };
3576
- }
3577
- var init_check_ignore = __esm({ "src/lib/tasks/check-ignore.ts"() {
3578
- "use strict";
3579
- init_CheckIgnore();
3580
- } });
3581
- var clone_exports = {};
3582
- __export(clone_exports, {
3583
- cloneMirrorTask: () => cloneMirrorTask,
3584
- cloneTask: () => cloneTask
3585
- });
3586
- function disallowedCommand(command) {
3587
- return /^--upload-pack(=|$)/.test(command);
3588
- }
3589
- function cloneTask(repo, directory, customArgs) {
3590
- const commands = ["clone", ...customArgs];
3591
- filterString(repo) && commands.push(repo);
3592
- filterString(directory) && commands.push(directory);
3593
- if (commands.find(disallowedCommand)) return configurationErrorTask(`git.fetch: potential exploit argument blocked.`);
3594
- return straightThroughStringTask(commands);
3595
- }
3596
- function cloneMirrorTask(repo, directory, customArgs) {
3597
- append(customArgs, "--mirror");
3598
- return cloneTask(repo, directory, customArgs);
3599
- }
3600
- var init_clone = __esm({ "src/lib/tasks/clone.ts"() {
3601
- "use strict";
3602
- init_task();
3603
- init_utils();
3604
- } });
3605
- function parseFetchResult(stdOut, stdErr) {
3606
- return parseStringResponse({
3607
- raw: stdOut,
3608
- remote: null,
3609
- branches: [],
3610
- tags: [],
3611
- updated: [],
3612
- deleted: []
3613
- }, parsers10, [stdOut, stdErr]);
3614
- }
3615
- var parsers10;
3616
- var init_parse_fetch = __esm({ "src/lib/parsers/parse-fetch.ts"() {
3617
- "use strict";
3618
- init_utils();
3619
- parsers10 = [
3620
- new LineParser(/From (.+)$/, (result, [remote]) => {
3621
- result.remote = remote;
3622
- }),
3623
- new LineParser(/\* \[new branch]\s+(\S+)\s*-> (.+)$/, (result, [name, tracking]) => {
3624
- result.branches.push({
3625
- name,
3626
- tracking
3627
- });
3628
- }),
3629
- new LineParser(/\* \[new tag]\s+(\S+)\s*-> (.+)$/, (result, [name, tracking]) => {
3630
- result.tags.push({
3631
- name,
3632
- tracking
3633
- });
3634
- }),
3635
- new LineParser(/- \[deleted]\s+\S+\s*-> (.+)$/, (result, [tracking]) => {
3636
- result.deleted.push({ tracking });
3637
- }),
3638
- new LineParser(/\s*([^.]+)\.\.(\S+)\s+(\S+)\s*-> (.+)$/, (result, [from, to, name, tracking]) => {
3639
- result.updated.push({
3640
- name,
3641
- tracking,
3642
- to,
3643
- from
3644
- });
3645
- })
3646
- ];
3647
- } });
3648
- var fetch_exports = {};
3649
- __export(fetch_exports, { fetchTask: () => fetchTask });
3650
- function disallowedCommand2(command) {
3651
- return /^--upload-pack(=|$)/.test(command);
3652
- }
3653
- function fetchTask(remote, branch, customArgs) {
3654
- const commands = ["fetch", ...customArgs];
3655
- if (remote && branch) commands.push(remote, branch);
3656
- if (commands.find(disallowedCommand2)) return configurationErrorTask(`git.fetch: potential exploit argument blocked.`);
3657
- return {
3658
- commands,
3659
- format: "utf-8",
3660
- parser: parseFetchResult
3661
- };
3662
- }
3663
- var init_fetch = __esm({ "src/lib/tasks/fetch.ts"() {
3664
- "use strict";
3665
- init_parse_fetch();
3666
- init_task();
3667
- } });
3668
- function parseMoveResult(stdOut) {
3669
- return parseStringResponse({ moves: [] }, parsers11, stdOut);
3670
- }
3671
- var parsers11;
3672
- var init_parse_move = __esm({ "src/lib/parsers/parse-move.ts"() {
3673
- "use strict";
3674
- init_utils();
3675
- parsers11 = [new LineParser(/^Renaming (.+) to (.+)$/, (result, [from, to]) => {
3676
- result.moves.push({
3677
- from,
3678
- to
3679
- });
3680
- })];
3681
- } });
3682
- var move_exports = {};
3683
- __export(move_exports, { moveTask: () => moveTask });
3684
- function moveTask(from, to) {
3685
- return {
3686
- commands: [
3687
- "mv",
3688
- "-v",
3689
- ...asArray(from),
3690
- to
3691
- ],
3692
- format: "utf-8",
3693
- parser: parseMoveResult
3694
- };
3695
- }
3696
- var init_move = __esm({ "src/lib/tasks/move.ts"() {
3697
- "use strict";
3698
- init_parse_move();
3699
- init_utils();
3700
- } });
3701
- var pull_exports = {};
3702
- __export(pull_exports, { pullTask: () => pullTask });
3703
- function pullTask(remote, branch, customArgs) {
3704
- const commands = ["pull", ...customArgs];
3705
- if (remote && branch) commands.splice(1, 0, remote, branch);
3706
- return {
3707
- commands,
3708
- format: "utf-8",
3709
- parser(stdOut, stdErr) {
3710
- return parsePullResult(stdOut, stdErr);
3711
- },
3712
- onError(result, _error, _done, fail) {
3713
- const pullError = parsePullErrorResult(bufferToString(result.stdOut), bufferToString(result.stdErr));
3714
- if (pullError) return fail(new GitResponseError(pullError));
3715
- fail(_error);
3716
- }
3717
- };
3718
- }
3719
- var init_pull = __esm({ "src/lib/tasks/pull.ts"() {
3720
- "use strict";
3721
- init_git_response_error();
3722
- init_parse_pull();
3723
- init_utils();
3724
- } });
3725
- function parseGetRemotes(text) {
3726
- const remotes = {};
3727
- forEach(text, ([name]) => remotes[name] = { name });
3728
- return Object.values(remotes);
3729
- }
3730
- function parseGetRemotesVerbose(text) {
3731
- const remotes = {};
3732
- forEach(text, ([name, url, purpose]) => {
3733
- if (!Object.hasOwn(remotes, name)) remotes[name] = {
3734
- name,
3735
- refs: {
3736
- fetch: "",
3737
- push: ""
3738
- }
3739
- };
3740
- if (purpose && url) remotes[name].refs[purpose.replace(/[^a-z]/g, "")] = url;
3741
- });
3742
- return Object.values(remotes);
3743
- }
3744
- function forEach(text, handler) {
3745
- forEachLineWithContent(text, (line) => handler(line.split(/\s+/)));
3746
- }
3747
- var init_GetRemoteSummary = __esm({ "src/lib/responses/GetRemoteSummary.ts"() {
3748
- "use strict";
3749
- init_utils();
3750
- } });
3751
- var remote_exports = {};
3752
- __export(remote_exports, {
3753
- addRemoteTask: () => addRemoteTask,
3754
- getRemotesTask: () => getRemotesTask,
3755
- listRemotesTask: () => listRemotesTask,
3756
- remoteTask: () => remoteTask,
3757
- removeRemoteTask: () => removeRemoteTask
3758
- });
3759
- function addRemoteTask(remoteName, remoteRepo, customArgs) {
3760
- return straightThroughStringTask([
3761
- "remote",
3762
- "add",
3763
- ...customArgs,
3764
- remoteName,
3765
- remoteRepo
3766
- ]);
3767
- }
3768
- function getRemotesTask(verbose) {
3769
- const commands = ["remote"];
3770
- if (verbose) commands.push("-v");
3771
- return {
3772
- commands,
3773
- format: "utf-8",
3774
- parser: verbose ? parseGetRemotesVerbose : parseGetRemotes
3775
- };
3776
- }
3777
- function listRemotesTask(customArgs) {
3778
- const commands = [...customArgs];
3779
- if (commands[0] !== "ls-remote") commands.unshift("ls-remote");
3780
- return straightThroughStringTask(commands);
3781
- }
3782
- function remoteTask(customArgs) {
3783
- const commands = [...customArgs];
3784
- if (commands[0] !== "remote") commands.unshift("remote");
3785
- return straightThroughStringTask(commands);
3786
- }
3787
- function removeRemoteTask(remoteName) {
3788
- return straightThroughStringTask([
3789
- "remote",
3790
- "remove",
3791
- remoteName
3792
- ]);
3793
- }
3794
- var init_remote = __esm({ "src/lib/tasks/remote.ts"() {
3795
- "use strict";
3796
- init_GetRemoteSummary();
3797
- init_task();
3798
- } });
3799
- var stash_list_exports = {};
3800
- __export(stash_list_exports, { stashListTask: () => stashListTask });
3801
- function stashListTask(opt = {}, customArgs) {
3802
- const options = parseLogOptions(opt);
3803
- const commands = [
3804
- "stash",
3805
- "list",
3806
- ...options.commands,
3807
- ...customArgs
3808
- ];
3809
- const parser4 = createListLogSummaryParser(options.splitter, options.fields, logFormatFromCommand(commands));
3810
- return validateLogFormatConfig(commands) || {
3811
- commands,
3812
- format: "utf-8",
3813
- parser: parser4
3814
- };
3815
- }
3816
- var init_stash_list = __esm({ "src/lib/tasks/stash-list.ts"() {
3817
- "use strict";
3818
- init_log_format();
3819
- init_parse_list_log_summary();
3820
- init_diff();
3821
- init_log();
3822
- } });
3823
- var sub_module_exports = {};
3824
- __export(sub_module_exports, {
3825
- addSubModuleTask: () => addSubModuleTask,
3826
- initSubModuleTask: () => initSubModuleTask,
3827
- subModuleTask: () => subModuleTask,
3828
- updateSubModuleTask: () => updateSubModuleTask
3829
- });
3830
- function addSubModuleTask(repo, path) {
3831
- return subModuleTask([
3832
- "add",
3833
- repo,
3834
- path
3835
- ]);
3836
- }
3837
- function initSubModuleTask(customArgs) {
3838
- return subModuleTask(["init", ...customArgs]);
3839
- }
3840
- function subModuleTask(customArgs) {
3841
- const commands = [...customArgs];
3842
- if (commands[0] !== "submodule") commands.unshift("submodule");
3843
- return straightThroughStringTask(commands);
3844
- }
3845
- function updateSubModuleTask(customArgs) {
3846
- return subModuleTask(["update", ...customArgs]);
3847
- }
3848
- var init_sub_module = __esm({ "src/lib/tasks/sub-module.ts"() {
3849
- "use strict";
3850
- init_task();
3851
- } });
3852
- function singleSorted(a, b) {
3853
- const aIsNum = Number.isNaN(a);
3854
- if (aIsNum !== Number.isNaN(b)) return aIsNum ? 1 : -1;
3855
- return aIsNum ? sorted(a, b) : 0;
3856
- }
3857
- function sorted(a, b) {
3858
- return a === b ? 0 : a > b ? 1 : -1;
3859
- }
3860
- function trimmed(input) {
3861
- return input.trim();
3862
- }
3863
- function toNumber(input) {
3864
- if (typeof input === "string") return parseInt(input.replace(/^\D+/g, ""), 10) || 0;
3865
- return 0;
3866
- }
3867
- var TagList, parseTagList;
3868
- var init_TagList = __esm({ "src/lib/responses/TagList.ts"() {
3869
- "use strict";
3870
- TagList = class {
3871
- constructor(all, latest) {
3872
- this.all = all;
3873
- this.latest = latest;
3874
- }
3875
- };
3876
- parseTagList = function(data, customSort = false) {
3877
- const tags = data.split("\n").map(trimmed).filter(Boolean);
3878
- if (!customSort) tags.sort(function(tagA, tagB) {
3879
- const partsA = tagA.split(".");
3880
- const partsB = tagB.split(".");
3881
- if (partsA.length === 1 || partsB.length === 1) return singleSorted(toNumber(partsA[0]), toNumber(partsB[0]));
3882
- for (let i = 0, l = Math.max(partsA.length, partsB.length); i < l; i++) {
3883
- const diff = sorted(toNumber(partsA[i]), toNumber(partsB[i]));
3884
- if (diff) return diff;
3885
- }
3886
- return 0;
3887
- });
3888
- const latest = customSort ? tags[0] : [...tags].reverse().find((tag) => tag.indexOf(".") >= 0);
3889
- return new TagList(tags, latest);
3890
- };
3891
- } });
3892
- var tag_exports = {};
3893
- __export(tag_exports, {
3894
- addAnnotatedTagTask: () => addAnnotatedTagTask,
3895
- addTagTask: () => addTagTask,
3896
- tagListTask: () => tagListTask
3897
- });
3898
- function tagListTask(customArgs = []) {
3899
- const hasCustomSort = customArgs.some((option) => /^--sort=/.test(option));
3900
- return {
3901
- format: "utf-8",
3902
- commands: [
3903
- "tag",
3904
- "-l",
3905
- ...customArgs
3906
- ],
3907
- parser(text) {
3908
- return parseTagList(text, hasCustomSort);
3909
- }
3910
- };
3911
- }
3912
- function addTagTask(name) {
3913
- return {
3914
- format: "utf-8",
3915
- commands: ["tag", name],
3916
- parser() {
3917
- return { name };
3918
- }
3919
- };
3920
- }
3921
- function addAnnotatedTagTask(name, tagMessage) {
3922
- return {
3923
- format: "utf-8",
3924
- commands: [
3925
- "tag",
3926
- "-a",
3927
- "-m",
3928
- tagMessage,
3929
- name
3930
- ],
3931
- parser() {
3932
- return { name };
3933
- }
3934
- };
3935
- }
3936
- var init_tag = __esm({ "src/lib/tasks/tag.ts"() {
3937
- "use strict";
3938
- init_TagList();
3939
- } });
3940
- var require_git = __commonJS({ "src/git.js"(exports, module) {
3941
- "use strict";
3942
- var { GitExecutor: GitExecutor2 } = (init_git_executor(), __toCommonJS(git_executor_exports));
3943
- var { SimpleGitApi: SimpleGitApi2 } = (init_simple_git_api(), __toCommonJS(simple_git_api_exports));
3944
- var { Scheduler: Scheduler2 } = (init_scheduler(), __toCommonJS(scheduler_exports));
3945
- var { configurationErrorTask: configurationErrorTask2 } = (init_task(), __toCommonJS(task_exports));
3946
- var { asArray: asArray2, filterArray: filterArray2, filterPrimitives: filterPrimitives2, filterString: filterString2, filterStringOrStringArray: filterStringOrStringArray2, filterType: filterType2, getTrailingOptions: getTrailingOptions2, trailingFunctionArgument: trailingFunctionArgument2, trailingOptionsArgument: trailingOptionsArgument2 } = (init_utils(), __toCommonJS(utils_exports));
3947
- var { applyPatchTask: applyPatchTask2 } = (init_apply_patch(), __toCommonJS(apply_patch_exports));
3948
- var { branchTask: branchTask2, branchLocalTask: branchLocalTask2, deleteBranchesTask: deleteBranchesTask2, deleteBranchTask: deleteBranchTask2 } = (init_branch(), __toCommonJS(branch_exports));
3949
- var { checkIgnoreTask: checkIgnoreTask2 } = (init_check_ignore(), __toCommonJS(check_ignore_exports));
3950
- var { checkIsRepoTask: checkIsRepoTask2 } = (init_check_is_repo(), __toCommonJS(check_is_repo_exports));
3951
- var { cloneTask: cloneTask2, cloneMirrorTask: cloneMirrorTask2 } = (init_clone(), __toCommonJS(clone_exports));
3952
- var { cleanWithOptionsTask: cleanWithOptionsTask2, isCleanOptionsArray: isCleanOptionsArray2 } = (init_clean(), __toCommonJS(clean_exports));
3953
- var { diffSummaryTask: diffSummaryTask2 } = (init_diff(), __toCommonJS(diff_exports));
3954
- var { fetchTask: fetchTask2 } = (init_fetch(), __toCommonJS(fetch_exports));
3955
- var { moveTask: moveTask2 } = (init_move(), __toCommonJS(move_exports));
3956
- var { pullTask: pullTask2 } = (init_pull(), __toCommonJS(pull_exports));
3957
- var { pushTagsTask: pushTagsTask2 } = (init_push(), __toCommonJS(push_exports));
3958
- var { addRemoteTask: addRemoteTask2, getRemotesTask: getRemotesTask2, listRemotesTask: listRemotesTask2, remoteTask: remoteTask2, removeRemoteTask: removeRemoteTask2 } = (init_remote(), __toCommonJS(remote_exports));
3959
- var { getResetMode: getResetMode2, resetTask: resetTask2 } = (init_reset(), __toCommonJS(reset_exports));
3960
- var { stashListTask: stashListTask2 } = (init_stash_list(), __toCommonJS(stash_list_exports));
3961
- var { addSubModuleTask: addSubModuleTask2, initSubModuleTask: initSubModuleTask2, subModuleTask: subModuleTask2, updateSubModuleTask: updateSubModuleTask2 } = (init_sub_module(), __toCommonJS(sub_module_exports));
3962
- var { addAnnotatedTagTask: addAnnotatedTagTask2, addTagTask: addTagTask2, tagListTask: tagListTask2 } = (init_tag(), __toCommonJS(tag_exports));
3963
- var { straightThroughBufferTask: straightThroughBufferTask2, straightThroughStringTask: straightThroughStringTask2 } = (init_task(), __toCommonJS(task_exports));
3964
- function Git2(options, plugins) {
3965
- this._plugins = plugins;
3966
- this._executor = new GitExecutor2(options.baseDir, new Scheduler2(options.maxConcurrentProcesses), plugins);
3967
- this._trimmed = options.trimmed;
3968
- }
3969
- (Git2.prototype = Object.create(SimpleGitApi2.prototype)).constructor = Git2;
3970
- Git2.prototype.customBinary = function(command) {
3971
- this._plugins.reconfigure("binary", command);
3972
- return this;
3973
- };
3974
- Git2.prototype.env = function(name, value) {
3975
- if (arguments.length === 1 && typeof name === "object") this._executor.env = name;
3976
- else (this._executor.env = this._executor.env || {})[name] = value;
3977
- return this;
3978
- };
3979
- Git2.prototype.stashList = function(options) {
3980
- return this._runTask(stashListTask2(trailingOptionsArgument2(arguments) || {}, filterArray2(options) && options || []), trailingFunctionArgument2(arguments));
3981
- };
3982
- function createCloneTask(api, task, repoPath, localPath) {
3983
- if (typeof repoPath !== "string") return configurationErrorTask2(`git.${api}() requires a string 'repoPath'`);
3984
- return task(repoPath, filterType2(localPath, filterString2), getTrailingOptions2(arguments));
3985
- }
3986
- Git2.prototype.clone = function() {
3987
- return this._runTask(createCloneTask("clone", cloneTask2, ...arguments), trailingFunctionArgument2(arguments));
3988
- };
3989
- Git2.prototype.mirror = function() {
3990
- return this._runTask(createCloneTask("mirror", cloneMirrorTask2, ...arguments), trailingFunctionArgument2(arguments));
3991
- };
3992
- Git2.prototype.mv = function(from, to) {
3993
- return this._runTask(moveTask2(from, to), trailingFunctionArgument2(arguments));
3994
- };
3995
- Git2.prototype.checkoutLatestTag = function(then) {
3996
- var git = this;
3997
- return this.pull(function() {
3998
- git.tags(function(err, tags) {
3999
- git.checkout(tags.latest, then);
4000
- });
4001
- });
4002
- };
4003
- Git2.prototype.pull = function(remote, branch, options, then) {
4004
- return this._runTask(pullTask2(filterType2(remote, filterString2), filterType2(branch, filterString2), getTrailingOptions2(arguments)), trailingFunctionArgument2(arguments));
4005
- };
4006
- Git2.prototype.fetch = function(remote, branch) {
4007
- return this._runTask(fetchTask2(filterType2(remote, filterString2), filterType2(branch, filterString2), getTrailingOptions2(arguments)), trailingFunctionArgument2(arguments));
4008
- };
4009
- Git2.prototype.silent = function(silence) {
4010
- console.warn("simple-git deprecation notice: git.silent: logging should be configured using the `debug` library / `DEBUG` environment variable, this will be an error in version 3");
4011
- return this;
4012
- };
4013
- Git2.prototype.tags = function(options, then) {
4014
- return this._runTask(tagListTask2(getTrailingOptions2(arguments)), trailingFunctionArgument2(arguments));
4015
- };
4016
- Git2.prototype.rebase = function() {
4017
- return this._runTask(straightThroughStringTask2(["rebase", ...getTrailingOptions2(arguments)]), trailingFunctionArgument2(arguments));
4018
- };
4019
- Git2.prototype.reset = function(mode) {
4020
- return this._runTask(resetTask2(getResetMode2(mode), getTrailingOptions2(arguments)), trailingFunctionArgument2(arguments));
4021
- };
4022
- Git2.prototype.revert = function(commit) {
4023
- const next = trailingFunctionArgument2(arguments);
4024
- if (typeof commit !== "string") return this._runTask(configurationErrorTask2("Commit must be a string"), next);
4025
- return this._runTask(straightThroughStringTask2([
4026
- "revert",
4027
- ...getTrailingOptions2(arguments, 0, true),
4028
- commit
4029
- ]), next);
4030
- };
4031
- Git2.prototype.addTag = function(name) {
4032
- const task = typeof name === "string" ? addTagTask2(name) : configurationErrorTask2("Git.addTag requires a tag name");
4033
- return this._runTask(task, trailingFunctionArgument2(arguments));
4034
- };
4035
- Git2.prototype.addAnnotatedTag = function(tagName, tagMessage) {
4036
- return this._runTask(addAnnotatedTagTask2(tagName, tagMessage), trailingFunctionArgument2(arguments));
4037
- };
4038
- Git2.prototype.deleteLocalBranch = function(branchName, forceDelete, then) {
4039
- return this._runTask(deleteBranchTask2(branchName, typeof forceDelete === "boolean" ? forceDelete : false), trailingFunctionArgument2(arguments));
4040
- };
4041
- Git2.prototype.deleteLocalBranches = function(branchNames, forceDelete, then) {
4042
- return this._runTask(deleteBranchesTask2(branchNames, typeof forceDelete === "boolean" ? forceDelete : false), trailingFunctionArgument2(arguments));
4043
- };
4044
- Git2.prototype.branch = function(options, then) {
4045
- return this._runTask(branchTask2(getTrailingOptions2(arguments)), trailingFunctionArgument2(arguments));
4046
- };
4047
- Git2.prototype.branchLocal = function(then) {
4048
- return this._runTask(branchLocalTask2(), trailingFunctionArgument2(arguments));
4049
- };
4050
- Git2.prototype.raw = function(commands) {
4051
- const createRestCommands = !Array.isArray(commands);
4052
- const command = [].slice.call(createRestCommands ? arguments : commands, 0);
4053
- for (let i = 0; i < command.length && createRestCommands; i++) if (!filterPrimitives2(command[i])) {
4054
- command.splice(i, command.length - i);
4055
- break;
4056
- }
4057
- command.push(...getTrailingOptions2(arguments, 0, true));
4058
- var next = trailingFunctionArgument2(arguments);
4059
- if (!command.length) return this._runTask(configurationErrorTask2("Raw: must supply one or more command to execute"), next);
4060
- return this._runTask(straightThroughStringTask2(command, this._trimmed), next);
4061
- };
4062
- Git2.prototype.submoduleAdd = function(repo, path, then) {
4063
- return this._runTask(addSubModuleTask2(repo, path), trailingFunctionArgument2(arguments));
4064
- };
4065
- Git2.prototype.submoduleUpdate = function(args, then) {
4066
- return this._runTask(updateSubModuleTask2(getTrailingOptions2(arguments, true)), trailingFunctionArgument2(arguments));
4067
- };
4068
- Git2.prototype.submoduleInit = function(args, then) {
4069
- return this._runTask(initSubModuleTask2(getTrailingOptions2(arguments, true)), trailingFunctionArgument2(arguments));
4070
- };
4071
- Git2.prototype.subModule = function(options, then) {
4072
- return this._runTask(subModuleTask2(getTrailingOptions2(arguments)), trailingFunctionArgument2(arguments));
4073
- };
4074
- Git2.prototype.listRemote = function() {
4075
- return this._runTask(listRemotesTask2(getTrailingOptions2(arguments)), trailingFunctionArgument2(arguments));
4076
- };
4077
- Git2.prototype.addRemote = function(remoteName, remoteRepo, then) {
4078
- return this._runTask(addRemoteTask2(remoteName, remoteRepo, getTrailingOptions2(arguments)), trailingFunctionArgument2(arguments));
4079
- };
4080
- Git2.prototype.removeRemote = function(remoteName, then) {
4081
- return this._runTask(removeRemoteTask2(remoteName), trailingFunctionArgument2(arguments));
4082
- };
4083
- Git2.prototype.getRemotes = function(verbose, then) {
4084
- return this._runTask(getRemotesTask2(verbose === true), trailingFunctionArgument2(arguments));
4085
- };
4086
- Git2.prototype.remote = function(options, then) {
4087
- return this._runTask(remoteTask2(getTrailingOptions2(arguments)), trailingFunctionArgument2(arguments));
4088
- };
4089
- Git2.prototype.tag = function(options, then) {
4090
- const command = getTrailingOptions2(arguments);
4091
- if (command[0] !== "tag") command.unshift("tag");
4092
- return this._runTask(straightThroughStringTask2(command), trailingFunctionArgument2(arguments));
4093
- };
4094
- Git2.prototype.updateServerInfo = function(then) {
4095
- return this._runTask(straightThroughStringTask2(["update-server-info"]), trailingFunctionArgument2(arguments));
4096
- };
4097
- Git2.prototype.pushTags = function(remote, then) {
4098
- const task = pushTagsTask2({ remote: filterType2(remote, filterString2) }, getTrailingOptions2(arguments));
4099
- return this._runTask(task, trailingFunctionArgument2(arguments));
4100
- };
4101
- Git2.prototype.rm = function(files) {
4102
- return this._runTask(straightThroughStringTask2([
4103
- "rm",
4104
- "-f",
4105
- ...asArray2(files)
4106
- ]), trailingFunctionArgument2(arguments));
4107
- };
4108
- Git2.prototype.rmKeepLocal = function(files) {
4109
- return this._runTask(straightThroughStringTask2([
4110
- "rm",
4111
- "--cached",
4112
- ...asArray2(files)
4113
- ]), trailingFunctionArgument2(arguments));
4114
- };
4115
- Git2.prototype.catFile = function(options, then) {
4116
- return this._catFile("utf-8", arguments);
4117
- };
4118
- Git2.prototype.binaryCatFile = function() {
4119
- return this._catFile("buffer", arguments);
4120
- };
4121
- Git2.prototype._catFile = function(format, args) {
4122
- var handler = trailingFunctionArgument2(args);
4123
- var command = ["cat-file"];
4124
- var options = args[0];
4125
- if (typeof options === "string") return this._runTask(configurationErrorTask2("Git.catFile: options must be supplied as an array of strings"), handler);
4126
- if (Array.isArray(options)) command.push.apply(command, options);
4127
- const task = format === "buffer" ? straightThroughBufferTask2(command) : straightThroughStringTask2(command);
4128
- return this._runTask(task, handler);
4129
- };
4130
- Git2.prototype.diff = function(options, then) {
4131
- const task = filterString2(options) ? configurationErrorTask2("git.diff: supplying options as a single string is no longer supported, switch to an array of strings") : straightThroughStringTask2(["diff", ...getTrailingOptions2(arguments)]);
4132
- return this._runTask(task, trailingFunctionArgument2(arguments));
4133
- };
4134
- Git2.prototype.diffSummary = function() {
4135
- return this._runTask(diffSummaryTask2(getTrailingOptions2(arguments, 1)), trailingFunctionArgument2(arguments));
4136
- };
4137
- Git2.prototype.applyPatch = function(patches) {
4138
- const task = !filterStringOrStringArray2(patches) ? configurationErrorTask2(`git.applyPatch requires one or more string patches as the first argument`) : applyPatchTask2(asArray2(patches), getTrailingOptions2([].slice.call(arguments, 1)));
4139
- return this._runTask(task, trailingFunctionArgument2(arguments));
4140
- };
4141
- Git2.prototype.revparse = function() {
4142
- const commands = ["rev-parse", ...getTrailingOptions2(arguments, true)];
4143
- return this._runTask(straightThroughStringTask2(commands, true), trailingFunctionArgument2(arguments));
4144
- };
4145
- Git2.prototype.clean = function(mode, options, then) {
4146
- const usingCleanOptionsArray = isCleanOptionsArray2(mode);
4147
- const cleanMode = usingCleanOptionsArray && mode.join("") || filterType2(mode, filterString2) || "";
4148
- const customArgs = getTrailingOptions2([].slice.call(arguments, usingCleanOptionsArray ? 1 : 0));
4149
- return this._runTask(cleanWithOptionsTask2(cleanMode, customArgs), trailingFunctionArgument2(arguments));
4150
- };
4151
- Git2.prototype.exec = function(then) {
4152
- return this._runTask({
4153
- commands: [],
4154
- format: "utf-8",
4155
- parser() {
4156
- if (typeof then === "function") then();
4157
- }
4158
- });
4159
- };
4160
- Git2.prototype.clearQueue = function() {
4161
- return this;
4162
- };
4163
- Git2.prototype.checkIgnore = function(pathnames, then) {
4164
- return this._runTask(checkIgnoreTask2(asArray2(filterType2(pathnames, filterStringOrStringArray2, []))), trailingFunctionArgument2(arguments));
4165
- };
4166
- Git2.prototype.checkIsRepo = function(checkType, then) {
4167
- return this._runTask(checkIsRepoTask2(filterType2(checkType, filterString2)), trailingFunctionArgument2(arguments));
4168
- };
4169
- module.exports = Git2;
4170
- } });
4171
- init_pathspec();
4172
- init_git_error();
4173
- var GitConstructError = class extends GitError {
4174
- constructor(config, message) {
4175
- super(void 0, message);
4176
- this.config = config;
4177
- }
4178
- };
4179
- init_git_error();
4180
- init_git_error();
4181
- var GitPluginError = class extends GitError {
4182
- constructor(task, plugin, message) {
4183
- super(task, message);
4184
- this.task = task;
4185
- this.plugin = plugin;
4186
- Object.setPrototypeOf(this, new.target.prototype);
4187
- }
4188
- };
4189
- init_git_response_error();
4190
- init_task_configuration_error();
4191
- init_check_is_repo();
4192
- init_clean();
4193
- init_config();
4194
- init_diff_name_status();
4195
- init_grep();
4196
- init_reset();
4197
- function abortPlugin(signal) {
4198
- if (!signal) return;
4199
- return [{
4200
- type: "spawn.before",
4201
- action(_data, context) {
4202
- if (signal.aborted) context.kill(new GitPluginError(void 0, "abort", "Abort already signaled"));
4203
- }
4204
- }, {
4205
- type: "spawn.after",
4206
- action(_data, context) {
4207
- function kill() {
4208
- context.kill(new GitPluginError(void 0, "abort", "Abort signal received"));
4209
- }
4210
- signal.addEventListener("abort", kill);
4211
- context.spawned.on("close", () => signal.removeEventListener("abort", kill));
4212
- }
4213
- }];
4214
- }
4215
- function isConfigSwitch(arg) {
4216
- return typeof arg === "string" && arg.trim().toLowerCase() === "-c";
4217
- }
4218
- function preventProtocolOverride(arg, next) {
4219
- if (!isConfigSwitch(arg)) return;
4220
- if (!/^\s*protocol(.[a-z]+)?.allow/.test(next)) return;
4221
- throw new GitPluginError(void 0, "unsafe", "Configuring protocol.allow is not permitted without enabling allowUnsafeExtProtocol");
4222
- }
4223
- function preventUploadPack(arg, method) {
4224
- if (/^\s*--(upload|receive)-pack/.test(arg)) throw new GitPluginError(void 0, "unsafe", `Use of --upload-pack or --receive-pack is not permitted without enabling allowUnsafePack`);
4225
- if (method === "clone" && /^\s*-u\b/.test(arg)) throw new GitPluginError(void 0, "unsafe", `Use of clone with option -u is not permitted without enabling allowUnsafePack`);
4226
- if (method === "push" && /^\s*--exec\b/.test(arg)) throw new GitPluginError(void 0, "unsafe", `Use of push with option --exec is not permitted without enabling allowUnsafePack`);
4227
- }
4228
- function blockUnsafeOperationsPlugin({ allowUnsafeProtocolOverride = false, allowUnsafePack = false } = {}) {
4229
- return {
4230
- type: "spawn.args",
4231
- action(args, context) {
4232
- args.forEach((current, index) => {
4233
- const next = index < args.length ? args[index + 1] : "";
4234
- allowUnsafeProtocolOverride || preventProtocolOverride(current, next);
4235
- allowUnsafePack || preventUploadPack(current, context.method);
4236
- });
4237
- return args;
4238
- }
4239
- };
4240
- }
4241
- init_utils();
4242
- function commandConfigPrefixingPlugin(configuration) {
4243
- const prefix = prefixedArray(configuration, "-c");
4244
- return {
4245
- type: "spawn.args",
4246
- action(data) {
4247
- return [...prefix, ...data];
4248
- }
4249
- };
4250
- }
4251
- init_utils();
4252
- var never = (0, import_dist$1.deferred)().promise;
4253
- function completionDetectionPlugin({ onClose = true, onExit = 50 } = {}) {
4254
- function createEvents() {
4255
- let exitCode = -1;
4256
- const events = {
4257
- close: (0, import_dist$1.deferred)(),
4258
- closeTimeout: (0, import_dist$1.deferred)(),
4259
- exit: (0, import_dist$1.deferred)(),
4260
- exitTimeout: (0, import_dist$1.deferred)()
4261
- };
4262
- const result = Promise.race([onClose === false ? never : events.closeTimeout.promise, onExit === false ? never : events.exitTimeout.promise]);
4263
- configureTimeout(onClose, events.close, events.closeTimeout);
4264
- configureTimeout(onExit, events.exit, events.exitTimeout);
4265
- return {
4266
- close(code) {
4267
- exitCode = code;
4268
- events.close.done();
4269
- },
4270
- exit(code) {
4271
- exitCode = code;
4272
- events.exit.done();
4273
- },
4274
- get exitCode() {
4275
- return exitCode;
4276
- },
4277
- result
4278
- };
4279
- }
4280
- function configureTimeout(flag, event, timeout) {
4281
- if (flag === false) return;
4282
- (flag === true ? event.promise : event.promise.then(() => delay(flag))).then(timeout.done);
4283
- }
4284
- return {
4285
- type: "spawn.after",
4286
- async action(_data, { spawned, close }) {
4287
- const events = createEvents();
4288
- let deferClose = true;
4289
- let quickClose = () => void (deferClose = false);
4290
- spawned.stdout?.on("data", quickClose);
4291
- spawned.stderr?.on("data", quickClose);
4292
- spawned.on("error", quickClose);
4293
- spawned.on("close", (code) => events.close(code));
4294
- spawned.on("exit", (code) => events.exit(code));
4295
- try {
4296
- await events.result;
4297
- if (deferClose) await delay(50);
4298
- close(events.exitCode);
4299
- } catch (err) {
4300
- close(events.exitCode, err);
4301
- }
4302
- }
4303
- };
4304
- }
4305
- init_utils();
4306
- var WRONG_NUMBER_ERR = `Invalid value supplied for custom binary, requires a single string or an array containing either one or two strings`;
4307
- var WRONG_CHARS_ERR = `Invalid value supplied for custom binary, restricted characters must be removed or supply the unsafe.allowUnsafeCustomBinary option`;
4308
- function isBadArgument(arg) {
4309
- return !arg || !/^([a-z]:)?([a-z0-9/.\\_-]+)$/i.test(arg);
4310
- }
4311
- function toBinaryConfig(input, allowUnsafe) {
4312
- if (input.length < 1 || input.length > 2) throw new GitPluginError(void 0, "binary", WRONG_NUMBER_ERR);
4313
- if (input.some(isBadArgument)) if (allowUnsafe) console.warn(WRONG_CHARS_ERR);
4314
- else throw new GitPluginError(void 0, "binary", WRONG_CHARS_ERR);
4315
- const [binary, prefix] = input;
4316
- return {
4317
- binary,
4318
- prefix
4319
- };
4320
- }
4321
- function customBinaryPlugin(plugins, input = ["git"], allowUnsafe = false) {
4322
- let config = toBinaryConfig(asArray(input), allowUnsafe);
4323
- plugins.on("binary", (input2) => {
4324
- config = toBinaryConfig(asArray(input2), allowUnsafe);
4325
- });
4326
- plugins.append("spawn.binary", () => {
4327
- return config.binary;
4328
- });
4329
- plugins.append("spawn.args", (data) => {
4330
- return config.prefix ? [config.prefix, ...data] : data;
4331
- });
4332
- }
4333
- init_git_error();
4334
- function isTaskError(result) {
4335
- return !!(result.exitCode && result.stdErr.length);
4336
- }
4337
- function getErrorMessage(result) {
4338
- return Buffer.concat([...result.stdOut, ...result.stdErr]);
4339
- }
4340
- function errorDetectionHandler(overwrite = false, isError = isTaskError, errorMessage = getErrorMessage) {
4341
- return (error, result) => {
4342
- if (!overwrite && error || !isError(result)) return error;
4343
- return errorMessage(result);
4344
- };
4345
- }
4346
- function errorDetectionPlugin(config) {
4347
- return {
4348
- type: "task.error",
4349
- action(data, context) {
4350
- const error = config(data.error, {
4351
- stdErr: context.stdErr,
4352
- stdOut: context.stdOut,
4353
- exitCode: context.exitCode
4354
- });
4355
- if (Buffer.isBuffer(error)) return { error: new GitError(void 0, error.toString("utf-8")) };
4356
- return { error };
4357
- }
4358
- };
4359
- }
4360
- init_utils();
4361
- var PluginStore = class {
4362
- constructor() {
4363
- this.plugins = /* @__PURE__ */ new Set();
4364
- this.events = new EventEmitter();
4365
- }
4366
- on(type, listener) {
4367
- this.events.on(type, listener);
4368
- }
4369
- reconfigure(type, data) {
4370
- this.events.emit(type, data);
4371
- }
4372
- append(type, action) {
4373
- const plugin = append(this.plugins, {
4374
- type,
4375
- action
4376
- });
4377
- return () => this.plugins.delete(plugin);
4378
- }
4379
- add(plugin) {
4380
- const plugins = [];
4381
- asArray(plugin).forEach((plugin2) => plugin2 && this.plugins.add(append(plugins, plugin2)));
4382
- return () => {
4383
- plugins.forEach((plugin2) => this.plugins.delete(plugin2));
4384
- };
4385
- }
4386
- exec(type, data, context) {
4387
- let output = data;
4388
- const contextual = Object.freeze(Object.create(context));
4389
- for (const plugin of this.plugins) if (plugin.type === type) output = plugin.action(output, contextual);
4390
- return output;
4391
- }
4392
- };
4393
- init_utils();
4394
- function progressMonitorPlugin(progress) {
4395
- const progressCommand = "--progress";
4396
- const progressMethods = [
4397
- "checkout",
4398
- "clone",
4399
- "fetch",
4400
- "pull",
4401
- "push"
4402
- ];
4403
- return [{
4404
- type: "spawn.args",
4405
- action(args, context) {
4406
- if (!progressMethods.includes(context.method)) return args;
4407
- return including(args, progressCommand);
4408
- }
4409
- }, {
4410
- type: "spawn.after",
4411
- action(_data, context) {
4412
- if (!context.commands.includes(progressCommand)) return;
4413
- context.spawned.stderr?.on("data", (chunk) => {
4414
- const message = /^([\s\S]+?):\s*(\d+)% \((\d+)\/(\d+)\)/.exec(chunk.toString("utf8"));
4415
- if (!message) return;
4416
- progress({
4417
- method: context.method,
4418
- stage: progressEventStage(message[1]),
4419
- progress: asNumber(message[2]),
4420
- processed: asNumber(message[3]),
4421
- total: asNumber(message[4])
4422
- });
4423
- });
4424
- }
4425
- }];
4426
- }
4427
- function progressEventStage(input) {
4428
- return String(input.toLowerCase().split(" ", 1)) || "unknown";
4429
- }
4430
- init_utils();
4431
- function spawnOptionsPlugin(spawnOptions) {
4432
- const options = pick(spawnOptions, ["uid", "gid"]);
4433
- return {
4434
- type: "spawn.options",
4435
- action(data) {
4436
- return {
4437
- ...options,
4438
- ...data
4439
- };
4440
- }
4441
- };
4442
- }
4443
- function timeoutPlugin({ block, stdErr = true, stdOut = true }) {
4444
- if (block > 0) return {
4445
- type: "spawn.after",
4446
- action(_data, context) {
4447
- let timeout;
4448
- function wait() {
4449
- timeout && clearTimeout(timeout);
4450
- timeout = setTimeout(kill, block);
4451
- }
4452
- function stop() {
4453
- context.spawned.stdout?.off("data", wait);
4454
- context.spawned.stderr?.off("data", wait);
4455
- context.spawned.off("exit", stop);
4456
- context.spawned.off("close", stop);
4457
- timeout && clearTimeout(timeout);
4458
- }
4459
- function kill() {
4460
- stop();
4461
- context.kill(new GitPluginError(void 0, "timeout", `block timeout reached`));
4462
- }
4463
- stdOut && context.spawned.stdout?.on("data", wait);
4464
- stdErr && context.spawned.stderr?.on("data", wait);
4465
- context.spawned.on("exit", stop);
4466
- context.spawned.on("close", stop);
4467
- wait();
4468
- }
4469
- };
4470
- }
4471
- init_pathspec();
4472
- function suffixPathsPlugin() {
4473
- return {
4474
- type: "spawn.args",
4475
- action(data) {
4476
- const prefix = [];
4477
- let suffix;
4478
- function append2(args) {
4479
- (suffix = suffix || []).push(...args);
4480
- }
4481
- for (let i = 0; i < data.length; i++) {
4482
- const param = data[i];
4483
- if (isPathSpec(param)) {
4484
- append2(toPaths(param));
4485
- continue;
4486
- }
4487
- if (param === "--") {
4488
- append2(data.slice(i + 1).flatMap((item) => isPathSpec(item) && toPaths(item) || item));
4489
- break;
4490
- }
4491
- prefix.push(param);
4492
- }
4493
- return !suffix ? prefix : [
4494
- ...prefix,
4495
- "--",
4496
- ...suffix.map(String)
4497
- ];
4498
- }
4499
- };
4500
- }
4501
- init_utils();
4502
- var Git = require_git();
4503
- function gitInstanceFactory(baseDir, options) {
4504
- const plugins = new PluginStore();
4505
- const config = createInstanceConfig(baseDir && (typeof baseDir === "string" ? { baseDir } : baseDir) || {}, options);
4506
- if (!folderExists(config.baseDir)) throw new GitConstructError(config, `Cannot use simple-git on a directory that does not exist`);
4507
- if (Array.isArray(config.config)) plugins.add(commandConfigPrefixingPlugin(config.config));
4508
- plugins.add(blockUnsafeOperationsPlugin(config.unsafe));
4509
- plugins.add(suffixPathsPlugin());
4510
- plugins.add(completionDetectionPlugin(config.completion));
4511
- config.abort && plugins.add(abortPlugin(config.abort));
4512
- config.progress && plugins.add(progressMonitorPlugin(config.progress));
4513
- config.timeout && plugins.add(timeoutPlugin(config.timeout));
4514
- config.spawnOptions && plugins.add(spawnOptionsPlugin(config.spawnOptions));
4515
- plugins.add(errorDetectionPlugin(errorDetectionHandler(true)));
4516
- config.errors && plugins.add(errorDetectionPlugin(config.errors));
4517
- customBinaryPlugin(plugins, config.binary, config.unsafe?.allowUnsafeCustomBinary);
4518
- return new Git(config, plugins);
4519
- }
4520
- init_git_response_error();
4521
- var simpleGit = gitInstanceFactory;
4522
- var esm_default = gitInstanceFactory;
4523
-
4524
- //#endregion
4525
- export { GitConstructError as a, GitResponseError as c, esm_default as d, grepQueryBuilder as f, GitConfigScope as i, ResetMode as l, simpleGit as m, CleanOptions as n, GitError as o, pathspec as p, DiffNameStatus as r, GitPluginError as s, CheckRepoActions as t, TaskConfigurationError as u };
4526
- //# sourceMappingURL=esm-BagM-kVd.mjs.map