workshell 0.2.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +94 -15
- package/dist/index.js +1683 -29
- package/package.json +3 -1
package/dist/index.js
CHANGED
|
@@ -97,6 +97,1524 @@ var require_picocolors = __commonJS({
|
|
|
97
97
|
}
|
|
98
98
|
});
|
|
99
99
|
|
|
100
|
+
// node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/constants.js
|
|
101
|
+
var require_constants = __commonJS({
|
|
102
|
+
"node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/constants.js"(exports, module) {
|
|
103
|
+
"use strict";
|
|
104
|
+
var WIN_SLASH = "\\\\/";
|
|
105
|
+
var WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
106
|
+
var DOT_LITERAL = "\\.";
|
|
107
|
+
var PLUS_LITERAL = "\\+";
|
|
108
|
+
var QMARK_LITERAL = "\\?";
|
|
109
|
+
var SLASH_LITERAL = "\\/";
|
|
110
|
+
var ONE_CHAR = "(?=.)";
|
|
111
|
+
var QMARK = "[^/]";
|
|
112
|
+
var END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
|
|
113
|
+
var START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
|
|
114
|
+
var DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
|
|
115
|
+
var NO_DOT = `(?!${DOT_LITERAL})`;
|
|
116
|
+
var NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
|
|
117
|
+
var NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
|
|
118
|
+
var NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
|
|
119
|
+
var QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
|
|
120
|
+
var STAR = `${QMARK}*?`;
|
|
121
|
+
var SEP = "/";
|
|
122
|
+
var POSIX_CHARS = {
|
|
123
|
+
DOT_LITERAL,
|
|
124
|
+
PLUS_LITERAL,
|
|
125
|
+
QMARK_LITERAL,
|
|
126
|
+
SLASH_LITERAL,
|
|
127
|
+
ONE_CHAR,
|
|
128
|
+
QMARK,
|
|
129
|
+
END_ANCHOR,
|
|
130
|
+
DOTS_SLASH,
|
|
131
|
+
NO_DOT,
|
|
132
|
+
NO_DOTS,
|
|
133
|
+
NO_DOT_SLASH,
|
|
134
|
+
NO_DOTS_SLASH,
|
|
135
|
+
QMARK_NO_DOT,
|
|
136
|
+
STAR,
|
|
137
|
+
START_ANCHOR,
|
|
138
|
+
SEP
|
|
139
|
+
};
|
|
140
|
+
var WINDOWS_CHARS = {
|
|
141
|
+
...POSIX_CHARS,
|
|
142
|
+
SLASH_LITERAL: `[${WIN_SLASH}]`,
|
|
143
|
+
QMARK: WIN_NO_SLASH,
|
|
144
|
+
STAR: `${WIN_NO_SLASH}*?`,
|
|
145
|
+
DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
|
|
146
|
+
NO_DOT: `(?!${DOT_LITERAL})`,
|
|
147
|
+
NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
148
|
+
NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
|
|
149
|
+
NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
150
|
+
QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
|
|
151
|
+
START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
|
|
152
|
+
END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
|
|
153
|
+
SEP: "\\"
|
|
154
|
+
};
|
|
155
|
+
var POSIX_REGEX_SOURCE = {
|
|
156
|
+
alnum: "a-zA-Z0-9",
|
|
157
|
+
alpha: "a-zA-Z",
|
|
158
|
+
ascii: "\\x00-\\x7F",
|
|
159
|
+
blank: " \\t",
|
|
160
|
+
cntrl: "\\x00-\\x1F\\x7F",
|
|
161
|
+
digit: "0-9",
|
|
162
|
+
graph: "\\x21-\\x7E",
|
|
163
|
+
lower: "a-z",
|
|
164
|
+
print: "\\x20-\\x7E ",
|
|
165
|
+
punct: "\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",
|
|
166
|
+
space: " \\t\\r\\n\\v\\f",
|
|
167
|
+
upper: "A-Z",
|
|
168
|
+
word: "A-Za-z0-9_",
|
|
169
|
+
xdigit: "A-Fa-f0-9"
|
|
170
|
+
};
|
|
171
|
+
module.exports = {
|
|
172
|
+
MAX_LENGTH: 1024 * 64,
|
|
173
|
+
POSIX_REGEX_SOURCE,
|
|
174
|
+
// regular expressions
|
|
175
|
+
REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
|
|
176
|
+
REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
|
|
177
|
+
REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
|
|
178
|
+
REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
|
|
179
|
+
REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
|
|
180
|
+
REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
|
|
181
|
+
// Replace globs with equivalent patterns to reduce parsing time.
|
|
182
|
+
REPLACEMENTS: {
|
|
183
|
+
__proto__: null,
|
|
184
|
+
"***": "*",
|
|
185
|
+
"**/**": "**",
|
|
186
|
+
"**/**/**": "**"
|
|
187
|
+
},
|
|
188
|
+
// Digits
|
|
189
|
+
CHAR_0: 48,
|
|
190
|
+
/* 0 */
|
|
191
|
+
CHAR_9: 57,
|
|
192
|
+
/* 9 */
|
|
193
|
+
// Alphabet chars.
|
|
194
|
+
CHAR_UPPERCASE_A: 65,
|
|
195
|
+
/* A */
|
|
196
|
+
CHAR_LOWERCASE_A: 97,
|
|
197
|
+
/* a */
|
|
198
|
+
CHAR_UPPERCASE_Z: 90,
|
|
199
|
+
/* Z */
|
|
200
|
+
CHAR_LOWERCASE_Z: 122,
|
|
201
|
+
/* z */
|
|
202
|
+
CHAR_LEFT_PARENTHESES: 40,
|
|
203
|
+
/* ( */
|
|
204
|
+
CHAR_RIGHT_PARENTHESES: 41,
|
|
205
|
+
/* ) */
|
|
206
|
+
CHAR_ASTERISK: 42,
|
|
207
|
+
/* * */
|
|
208
|
+
// Non-alphabetic chars.
|
|
209
|
+
CHAR_AMPERSAND: 38,
|
|
210
|
+
/* & */
|
|
211
|
+
CHAR_AT: 64,
|
|
212
|
+
/* @ */
|
|
213
|
+
CHAR_BACKWARD_SLASH: 92,
|
|
214
|
+
/* \ */
|
|
215
|
+
CHAR_CARRIAGE_RETURN: 13,
|
|
216
|
+
/* \r */
|
|
217
|
+
CHAR_CIRCUMFLEX_ACCENT: 94,
|
|
218
|
+
/* ^ */
|
|
219
|
+
CHAR_COLON: 58,
|
|
220
|
+
/* : */
|
|
221
|
+
CHAR_COMMA: 44,
|
|
222
|
+
/* , */
|
|
223
|
+
CHAR_DOT: 46,
|
|
224
|
+
/* . */
|
|
225
|
+
CHAR_DOUBLE_QUOTE: 34,
|
|
226
|
+
/* " */
|
|
227
|
+
CHAR_EQUAL: 61,
|
|
228
|
+
/* = */
|
|
229
|
+
CHAR_EXCLAMATION_MARK: 33,
|
|
230
|
+
/* ! */
|
|
231
|
+
CHAR_FORM_FEED: 12,
|
|
232
|
+
/* \f */
|
|
233
|
+
CHAR_FORWARD_SLASH: 47,
|
|
234
|
+
/* / */
|
|
235
|
+
CHAR_GRAVE_ACCENT: 96,
|
|
236
|
+
/* ` */
|
|
237
|
+
CHAR_HASH: 35,
|
|
238
|
+
/* # */
|
|
239
|
+
CHAR_HYPHEN_MINUS: 45,
|
|
240
|
+
/* - */
|
|
241
|
+
CHAR_LEFT_ANGLE_BRACKET: 60,
|
|
242
|
+
/* < */
|
|
243
|
+
CHAR_LEFT_CURLY_BRACE: 123,
|
|
244
|
+
/* { */
|
|
245
|
+
CHAR_LEFT_SQUARE_BRACKET: 91,
|
|
246
|
+
/* [ */
|
|
247
|
+
CHAR_LINE_FEED: 10,
|
|
248
|
+
/* \n */
|
|
249
|
+
CHAR_NO_BREAK_SPACE: 160,
|
|
250
|
+
/* \u00A0 */
|
|
251
|
+
CHAR_PERCENT: 37,
|
|
252
|
+
/* % */
|
|
253
|
+
CHAR_PLUS: 43,
|
|
254
|
+
/* + */
|
|
255
|
+
CHAR_QUESTION_MARK: 63,
|
|
256
|
+
/* ? */
|
|
257
|
+
CHAR_RIGHT_ANGLE_BRACKET: 62,
|
|
258
|
+
/* > */
|
|
259
|
+
CHAR_RIGHT_CURLY_BRACE: 125,
|
|
260
|
+
/* } */
|
|
261
|
+
CHAR_RIGHT_SQUARE_BRACKET: 93,
|
|
262
|
+
/* ] */
|
|
263
|
+
CHAR_SEMICOLON: 59,
|
|
264
|
+
/* ; */
|
|
265
|
+
CHAR_SINGLE_QUOTE: 39,
|
|
266
|
+
/* ' */
|
|
267
|
+
CHAR_SPACE: 32,
|
|
268
|
+
/* */
|
|
269
|
+
CHAR_TAB: 9,
|
|
270
|
+
/* \t */
|
|
271
|
+
CHAR_UNDERSCORE: 95,
|
|
272
|
+
/* _ */
|
|
273
|
+
CHAR_VERTICAL_LINE: 124,
|
|
274
|
+
/* | */
|
|
275
|
+
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
|
|
276
|
+
/* \uFEFF */
|
|
277
|
+
/**
|
|
278
|
+
* Create EXTGLOB_CHARS
|
|
279
|
+
*/
|
|
280
|
+
extglobChars(chars) {
|
|
281
|
+
return {
|
|
282
|
+
"!": { type: "negate", open: "(?:(?!(?:", close: `))${chars.STAR})` },
|
|
283
|
+
"?": { type: "qmark", open: "(?:", close: ")?" },
|
|
284
|
+
"+": { type: "plus", open: "(?:", close: ")+" },
|
|
285
|
+
"*": { type: "star", open: "(?:", close: ")*" },
|
|
286
|
+
"@": { type: "at", open: "(?:", close: ")" }
|
|
287
|
+
};
|
|
288
|
+
},
|
|
289
|
+
/**
|
|
290
|
+
* Create GLOB_CHARS
|
|
291
|
+
*/
|
|
292
|
+
globChars(win32) {
|
|
293
|
+
return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
// node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/utils.js
|
|
300
|
+
var require_utils = __commonJS({
|
|
301
|
+
"node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/utils.js"(exports) {
|
|
302
|
+
"use strict";
|
|
303
|
+
var {
|
|
304
|
+
REGEX_BACKSLASH,
|
|
305
|
+
REGEX_REMOVE_BACKSLASH,
|
|
306
|
+
REGEX_SPECIAL_CHARS,
|
|
307
|
+
REGEX_SPECIAL_CHARS_GLOBAL
|
|
308
|
+
} = require_constants();
|
|
309
|
+
exports.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
|
|
310
|
+
exports.hasRegexChars = (str) => REGEX_SPECIAL_CHARS.test(str);
|
|
311
|
+
exports.isRegexChar = (str) => str.length === 1 && exports.hasRegexChars(str);
|
|
312
|
+
exports.escapeRegex = (str) => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, "\\$1");
|
|
313
|
+
exports.toPosixSlashes = (str) => str.replace(REGEX_BACKSLASH, "/");
|
|
314
|
+
exports.isWindows = () => {
|
|
315
|
+
if (typeof navigator !== "undefined" && navigator.platform) {
|
|
316
|
+
const platform = navigator.platform.toLowerCase();
|
|
317
|
+
return platform === "win32" || platform === "windows";
|
|
318
|
+
}
|
|
319
|
+
if (typeof process !== "undefined" && process.platform) {
|
|
320
|
+
return process.platform === "win32";
|
|
321
|
+
}
|
|
322
|
+
return false;
|
|
323
|
+
};
|
|
324
|
+
exports.removeBackslashes = (str) => {
|
|
325
|
+
return str.replace(REGEX_REMOVE_BACKSLASH, (match2) => {
|
|
326
|
+
return match2 === "\\" ? "" : match2;
|
|
327
|
+
});
|
|
328
|
+
};
|
|
329
|
+
exports.escapeLast = (input, char, lastIdx) => {
|
|
330
|
+
const idx = input.lastIndexOf(char, lastIdx);
|
|
331
|
+
if (idx === -1) return input;
|
|
332
|
+
if (input[idx - 1] === "\\") return exports.escapeLast(input, char, idx - 1);
|
|
333
|
+
return `${input.slice(0, idx)}\\${input.slice(idx)}`;
|
|
334
|
+
};
|
|
335
|
+
exports.removePrefix = (input, state = {}) => {
|
|
336
|
+
let output = input;
|
|
337
|
+
if (output.startsWith("./")) {
|
|
338
|
+
output = output.slice(2);
|
|
339
|
+
state.prefix = "./";
|
|
340
|
+
}
|
|
341
|
+
return output;
|
|
342
|
+
};
|
|
343
|
+
exports.wrapOutput = (input, state = {}, options = {}) => {
|
|
344
|
+
const prepend = options.contains ? "" : "^";
|
|
345
|
+
const append = options.contains ? "" : "$";
|
|
346
|
+
let output = `${prepend}(?:${input})${append}`;
|
|
347
|
+
if (state.negated === true) {
|
|
348
|
+
output = `(?:^(?!${output}).*$)`;
|
|
349
|
+
}
|
|
350
|
+
return output;
|
|
351
|
+
};
|
|
352
|
+
exports.basename = (path, { windows } = {}) => {
|
|
353
|
+
const segs = path.split(windows ? /[\\/]/ : "/");
|
|
354
|
+
const last = segs[segs.length - 1];
|
|
355
|
+
if (last === "") {
|
|
356
|
+
return segs[segs.length - 2];
|
|
357
|
+
}
|
|
358
|
+
return last;
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
// node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/scan.js
|
|
364
|
+
var require_scan = __commonJS({
|
|
365
|
+
"node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/scan.js"(exports, module) {
|
|
366
|
+
"use strict";
|
|
367
|
+
var utils = require_utils();
|
|
368
|
+
var {
|
|
369
|
+
CHAR_ASTERISK,
|
|
370
|
+
/* * */
|
|
371
|
+
CHAR_AT,
|
|
372
|
+
/* @ */
|
|
373
|
+
CHAR_BACKWARD_SLASH,
|
|
374
|
+
/* \ */
|
|
375
|
+
CHAR_COMMA,
|
|
376
|
+
/* , */
|
|
377
|
+
CHAR_DOT,
|
|
378
|
+
/* . */
|
|
379
|
+
CHAR_EXCLAMATION_MARK,
|
|
380
|
+
/* ! */
|
|
381
|
+
CHAR_FORWARD_SLASH,
|
|
382
|
+
/* / */
|
|
383
|
+
CHAR_LEFT_CURLY_BRACE,
|
|
384
|
+
/* { */
|
|
385
|
+
CHAR_LEFT_PARENTHESES,
|
|
386
|
+
/* ( */
|
|
387
|
+
CHAR_LEFT_SQUARE_BRACKET,
|
|
388
|
+
/* [ */
|
|
389
|
+
CHAR_PLUS,
|
|
390
|
+
/* + */
|
|
391
|
+
CHAR_QUESTION_MARK,
|
|
392
|
+
/* ? */
|
|
393
|
+
CHAR_RIGHT_CURLY_BRACE,
|
|
394
|
+
/* } */
|
|
395
|
+
CHAR_RIGHT_PARENTHESES,
|
|
396
|
+
/* ) */
|
|
397
|
+
CHAR_RIGHT_SQUARE_BRACKET
|
|
398
|
+
/* ] */
|
|
399
|
+
} = require_constants();
|
|
400
|
+
var isPathSeparator = (code) => {
|
|
401
|
+
return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
|
|
402
|
+
};
|
|
403
|
+
var depth = (token) => {
|
|
404
|
+
if (token.isPrefix !== true) {
|
|
405
|
+
token.depth = token.isGlobstar ? Infinity : 1;
|
|
406
|
+
}
|
|
407
|
+
};
|
|
408
|
+
var scan = (input, options) => {
|
|
409
|
+
const opts = options || {};
|
|
410
|
+
const length = input.length - 1;
|
|
411
|
+
const scanToEnd = opts.parts === true || opts.scanToEnd === true;
|
|
412
|
+
const slashes = [];
|
|
413
|
+
const tokens = [];
|
|
414
|
+
const parts = [];
|
|
415
|
+
let str = input;
|
|
416
|
+
let index = -1;
|
|
417
|
+
let start = 0;
|
|
418
|
+
let lastIndex = 0;
|
|
419
|
+
let isBrace = false;
|
|
420
|
+
let isBracket = false;
|
|
421
|
+
let isGlob = false;
|
|
422
|
+
let isExtglob = false;
|
|
423
|
+
let isGlobstar = false;
|
|
424
|
+
let braceEscaped = false;
|
|
425
|
+
let backslashes = false;
|
|
426
|
+
let negated = false;
|
|
427
|
+
let negatedExtglob = false;
|
|
428
|
+
let finished = false;
|
|
429
|
+
let braces = 0;
|
|
430
|
+
let prev;
|
|
431
|
+
let code;
|
|
432
|
+
let token = { value: "", depth: 0, isGlob: false };
|
|
433
|
+
const eos = () => index >= length;
|
|
434
|
+
const peek = () => str.charCodeAt(index + 1);
|
|
435
|
+
const advance = () => {
|
|
436
|
+
prev = code;
|
|
437
|
+
return str.charCodeAt(++index);
|
|
438
|
+
};
|
|
439
|
+
while (index < length) {
|
|
440
|
+
code = advance();
|
|
441
|
+
let next;
|
|
442
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
443
|
+
backslashes = token.backslashes = true;
|
|
444
|
+
code = advance();
|
|
445
|
+
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
446
|
+
braceEscaped = true;
|
|
447
|
+
}
|
|
448
|
+
continue;
|
|
449
|
+
}
|
|
450
|
+
if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
|
|
451
|
+
braces++;
|
|
452
|
+
while (eos() !== true && (code = advance())) {
|
|
453
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
454
|
+
backslashes = token.backslashes = true;
|
|
455
|
+
advance();
|
|
456
|
+
continue;
|
|
457
|
+
}
|
|
458
|
+
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
459
|
+
braces++;
|
|
460
|
+
continue;
|
|
461
|
+
}
|
|
462
|
+
if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
|
|
463
|
+
isBrace = token.isBrace = true;
|
|
464
|
+
isGlob = token.isGlob = true;
|
|
465
|
+
finished = true;
|
|
466
|
+
if (scanToEnd === true) {
|
|
467
|
+
continue;
|
|
468
|
+
}
|
|
469
|
+
break;
|
|
470
|
+
}
|
|
471
|
+
if (braceEscaped !== true && code === CHAR_COMMA) {
|
|
472
|
+
isBrace = token.isBrace = true;
|
|
473
|
+
isGlob = token.isGlob = true;
|
|
474
|
+
finished = true;
|
|
475
|
+
if (scanToEnd === true) {
|
|
476
|
+
continue;
|
|
477
|
+
}
|
|
478
|
+
break;
|
|
479
|
+
}
|
|
480
|
+
if (code === CHAR_RIGHT_CURLY_BRACE) {
|
|
481
|
+
braces--;
|
|
482
|
+
if (braces === 0) {
|
|
483
|
+
braceEscaped = false;
|
|
484
|
+
isBrace = token.isBrace = true;
|
|
485
|
+
finished = true;
|
|
486
|
+
break;
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
if (scanToEnd === true) {
|
|
491
|
+
continue;
|
|
492
|
+
}
|
|
493
|
+
break;
|
|
494
|
+
}
|
|
495
|
+
if (code === CHAR_FORWARD_SLASH) {
|
|
496
|
+
slashes.push(index);
|
|
497
|
+
tokens.push(token);
|
|
498
|
+
token = { value: "", depth: 0, isGlob: false };
|
|
499
|
+
if (finished === true) continue;
|
|
500
|
+
if (prev === CHAR_DOT && index === start + 1) {
|
|
501
|
+
start += 2;
|
|
502
|
+
continue;
|
|
503
|
+
}
|
|
504
|
+
lastIndex = index + 1;
|
|
505
|
+
continue;
|
|
506
|
+
}
|
|
507
|
+
if (opts.noext !== true) {
|
|
508
|
+
const isExtglobChar = code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK;
|
|
509
|
+
if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
|
|
510
|
+
isGlob = token.isGlob = true;
|
|
511
|
+
isExtglob = token.isExtglob = true;
|
|
512
|
+
finished = true;
|
|
513
|
+
if (code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
514
|
+
negatedExtglob = true;
|
|
515
|
+
}
|
|
516
|
+
if (scanToEnd === true) {
|
|
517
|
+
while (eos() !== true && (code = advance())) {
|
|
518
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
519
|
+
backslashes = token.backslashes = true;
|
|
520
|
+
code = advance();
|
|
521
|
+
continue;
|
|
522
|
+
}
|
|
523
|
+
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
524
|
+
isGlob = token.isGlob = true;
|
|
525
|
+
finished = true;
|
|
526
|
+
break;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
continue;
|
|
530
|
+
}
|
|
531
|
+
break;
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
if (code === CHAR_ASTERISK) {
|
|
535
|
+
if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
|
|
536
|
+
isGlob = token.isGlob = true;
|
|
537
|
+
finished = true;
|
|
538
|
+
if (scanToEnd === true) {
|
|
539
|
+
continue;
|
|
540
|
+
}
|
|
541
|
+
break;
|
|
542
|
+
}
|
|
543
|
+
if (code === CHAR_QUESTION_MARK) {
|
|
544
|
+
isGlob = token.isGlob = true;
|
|
545
|
+
finished = true;
|
|
546
|
+
if (scanToEnd === true) {
|
|
547
|
+
continue;
|
|
548
|
+
}
|
|
549
|
+
break;
|
|
550
|
+
}
|
|
551
|
+
if (code === CHAR_LEFT_SQUARE_BRACKET) {
|
|
552
|
+
while (eos() !== true && (next = advance())) {
|
|
553
|
+
if (next === CHAR_BACKWARD_SLASH) {
|
|
554
|
+
backslashes = token.backslashes = true;
|
|
555
|
+
advance();
|
|
556
|
+
continue;
|
|
557
|
+
}
|
|
558
|
+
if (next === CHAR_RIGHT_SQUARE_BRACKET) {
|
|
559
|
+
isBracket = token.isBracket = true;
|
|
560
|
+
isGlob = token.isGlob = true;
|
|
561
|
+
finished = true;
|
|
562
|
+
break;
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
if (scanToEnd === true) {
|
|
566
|
+
continue;
|
|
567
|
+
}
|
|
568
|
+
break;
|
|
569
|
+
}
|
|
570
|
+
if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
571
|
+
negated = token.negated = true;
|
|
572
|
+
start++;
|
|
573
|
+
continue;
|
|
574
|
+
}
|
|
575
|
+
if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
|
|
576
|
+
isGlob = token.isGlob = true;
|
|
577
|
+
if (scanToEnd === true) {
|
|
578
|
+
while (eos() !== true && (code = advance())) {
|
|
579
|
+
if (code === CHAR_LEFT_PARENTHESES) {
|
|
580
|
+
backslashes = token.backslashes = true;
|
|
581
|
+
code = advance();
|
|
582
|
+
continue;
|
|
583
|
+
}
|
|
584
|
+
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
585
|
+
finished = true;
|
|
586
|
+
break;
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
continue;
|
|
590
|
+
}
|
|
591
|
+
break;
|
|
592
|
+
}
|
|
593
|
+
if (isGlob === true) {
|
|
594
|
+
finished = true;
|
|
595
|
+
if (scanToEnd === true) {
|
|
596
|
+
continue;
|
|
597
|
+
}
|
|
598
|
+
break;
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
if (opts.noext === true) {
|
|
602
|
+
isExtglob = false;
|
|
603
|
+
isGlob = false;
|
|
604
|
+
}
|
|
605
|
+
let base = str;
|
|
606
|
+
let prefix = "";
|
|
607
|
+
let glob = "";
|
|
608
|
+
if (start > 0) {
|
|
609
|
+
prefix = str.slice(0, start);
|
|
610
|
+
str = str.slice(start);
|
|
611
|
+
lastIndex -= start;
|
|
612
|
+
}
|
|
613
|
+
if (base && isGlob === true && lastIndex > 0) {
|
|
614
|
+
base = str.slice(0, lastIndex);
|
|
615
|
+
glob = str.slice(lastIndex);
|
|
616
|
+
} else if (isGlob === true) {
|
|
617
|
+
base = "";
|
|
618
|
+
glob = str;
|
|
619
|
+
} else {
|
|
620
|
+
base = str;
|
|
621
|
+
}
|
|
622
|
+
if (base && base !== "" && base !== "/" && base !== str) {
|
|
623
|
+
if (isPathSeparator(base.charCodeAt(base.length - 1))) {
|
|
624
|
+
base = base.slice(0, -1);
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
if (opts.unescape === true) {
|
|
628
|
+
if (glob) glob = utils.removeBackslashes(glob);
|
|
629
|
+
if (base && backslashes === true) {
|
|
630
|
+
base = utils.removeBackslashes(base);
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
const state = {
|
|
634
|
+
prefix,
|
|
635
|
+
input,
|
|
636
|
+
start,
|
|
637
|
+
base,
|
|
638
|
+
glob,
|
|
639
|
+
isBrace,
|
|
640
|
+
isBracket,
|
|
641
|
+
isGlob,
|
|
642
|
+
isExtglob,
|
|
643
|
+
isGlobstar,
|
|
644
|
+
negated,
|
|
645
|
+
negatedExtglob
|
|
646
|
+
};
|
|
647
|
+
if (opts.tokens === true) {
|
|
648
|
+
state.maxDepth = 0;
|
|
649
|
+
if (!isPathSeparator(code)) {
|
|
650
|
+
tokens.push(token);
|
|
651
|
+
}
|
|
652
|
+
state.tokens = tokens;
|
|
653
|
+
}
|
|
654
|
+
if (opts.parts === true || opts.tokens === true) {
|
|
655
|
+
let prevIndex;
|
|
656
|
+
for (let idx = 0; idx < slashes.length; idx++) {
|
|
657
|
+
const n = prevIndex ? prevIndex + 1 : start;
|
|
658
|
+
const i = slashes[idx];
|
|
659
|
+
const value = input.slice(n, i);
|
|
660
|
+
if (opts.tokens) {
|
|
661
|
+
if (idx === 0 && start !== 0) {
|
|
662
|
+
tokens[idx].isPrefix = true;
|
|
663
|
+
tokens[idx].value = prefix;
|
|
664
|
+
} else {
|
|
665
|
+
tokens[idx].value = value;
|
|
666
|
+
}
|
|
667
|
+
depth(tokens[idx]);
|
|
668
|
+
state.maxDepth += tokens[idx].depth;
|
|
669
|
+
}
|
|
670
|
+
if (idx !== 0 || value !== "") {
|
|
671
|
+
parts.push(value);
|
|
672
|
+
}
|
|
673
|
+
prevIndex = i;
|
|
674
|
+
}
|
|
675
|
+
if (prevIndex && prevIndex + 1 < input.length) {
|
|
676
|
+
const value = input.slice(prevIndex + 1);
|
|
677
|
+
parts.push(value);
|
|
678
|
+
if (opts.tokens) {
|
|
679
|
+
tokens[tokens.length - 1].value = value;
|
|
680
|
+
depth(tokens[tokens.length - 1]);
|
|
681
|
+
state.maxDepth += tokens[tokens.length - 1].depth;
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
state.slashes = slashes;
|
|
685
|
+
state.parts = parts;
|
|
686
|
+
}
|
|
687
|
+
return state;
|
|
688
|
+
};
|
|
689
|
+
module.exports = scan;
|
|
690
|
+
}
|
|
691
|
+
});
|
|
692
|
+
|
|
693
|
+
// node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/parse.js
|
|
694
|
+
var require_parse = __commonJS({
|
|
695
|
+
"node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/parse.js"(exports, module) {
|
|
696
|
+
"use strict";
|
|
697
|
+
var constants = require_constants();
|
|
698
|
+
var utils = require_utils();
|
|
699
|
+
var {
|
|
700
|
+
MAX_LENGTH,
|
|
701
|
+
POSIX_REGEX_SOURCE,
|
|
702
|
+
REGEX_NON_SPECIAL_CHARS,
|
|
703
|
+
REGEX_SPECIAL_CHARS_BACKREF,
|
|
704
|
+
REPLACEMENTS
|
|
705
|
+
} = constants;
|
|
706
|
+
var expandRange = (args2, options) => {
|
|
707
|
+
if (typeof options.expandRange === "function") {
|
|
708
|
+
return options.expandRange(...args2, options);
|
|
709
|
+
}
|
|
710
|
+
args2.sort();
|
|
711
|
+
const value = `[${args2.join("-")}]`;
|
|
712
|
+
try {
|
|
713
|
+
new RegExp(value);
|
|
714
|
+
} catch (ex) {
|
|
715
|
+
return args2.map((v) => utils.escapeRegex(v)).join("..");
|
|
716
|
+
}
|
|
717
|
+
return value;
|
|
718
|
+
};
|
|
719
|
+
var syntaxError = (type, char) => {
|
|
720
|
+
return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
721
|
+
};
|
|
722
|
+
var parse2 = (input, options) => {
|
|
723
|
+
if (typeof input !== "string") {
|
|
724
|
+
throw new TypeError("Expected a string");
|
|
725
|
+
}
|
|
726
|
+
input = REPLACEMENTS[input] || input;
|
|
727
|
+
const opts = { ...options };
|
|
728
|
+
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
729
|
+
let len = input.length;
|
|
730
|
+
if (len > max) {
|
|
731
|
+
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
732
|
+
}
|
|
733
|
+
const bos = { type: "bos", value: "", output: opts.prepend || "" };
|
|
734
|
+
const tokens = [bos];
|
|
735
|
+
const capture = opts.capture ? "" : "?:";
|
|
736
|
+
const PLATFORM_CHARS = constants.globChars(opts.windows);
|
|
737
|
+
const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS);
|
|
738
|
+
const {
|
|
739
|
+
DOT_LITERAL,
|
|
740
|
+
PLUS_LITERAL,
|
|
741
|
+
SLASH_LITERAL,
|
|
742
|
+
ONE_CHAR,
|
|
743
|
+
DOTS_SLASH,
|
|
744
|
+
NO_DOT,
|
|
745
|
+
NO_DOT_SLASH,
|
|
746
|
+
NO_DOTS_SLASH,
|
|
747
|
+
QMARK,
|
|
748
|
+
QMARK_NO_DOT,
|
|
749
|
+
STAR,
|
|
750
|
+
START_ANCHOR
|
|
751
|
+
} = PLATFORM_CHARS;
|
|
752
|
+
const globstar = (opts2) => {
|
|
753
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts2.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
754
|
+
};
|
|
755
|
+
const nodot = opts.dot ? "" : NO_DOT;
|
|
756
|
+
const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
|
|
757
|
+
let star = opts.bash === true ? globstar(opts) : STAR;
|
|
758
|
+
if (opts.capture) {
|
|
759
|
+
star = `(${star})`;
|
|
760
|
+
}
|
|
761
|
+
if (typeof opts.noext === "boolean") {
|
|
762
|
+
opts.noextglob = opts.noext;
|
|
763
|
+
}
|
|
764
|
+
const state = {
|
|
765
|
+
input,
|
|
766
|
+
index: -1,
|
|
767
|
+
start: 0,
|
|
768
|
+
dot: opts.dot === true,
|
|
769
|
+
consumed: "",
|
|
770
|
+
output: "",
|
|
771
|
+
prefix: "",
|
|
772
|
+
backtrack: false,
|
|
773
|
+
negated: false,
|
|
774
|
+
brackets: 0,
|
|
775
|
+
braces: 0,
|
|
776
|
+
parens: 0,
|
|
777
|
+
quotes: 0,
|
|
778
|
+
globstar: false,
|
|
779
|
+
tokens
|
|
780
|
+
};
|
|
781
|
+
input = utils.removePrefix(input, state);
|
|
782
|
+
len = input.length;
|
|
783
|
+
const extglobs = [];
|
|
784
|
+
const braces = [];
|
|
785
|
+
const stack = [];
|
|
786
|
+
let prev = bos;
|
|
787
|
+
let value;
|
|
788
|
+
const eos = () => state.index === len - 1;
|
|
789
|
+
const peek = state.peek = (n = 1) => input[state.index + n];
|
|
790
|
+
const advance = state.advance = () => input[++state.index] || "";
|
|
791
|
+
const remaining = () => input.slice(state.index + 1);
|
|
792
|
+
const consume = (value2 = "", num = 0) => {
|
|
793
|
+
state.consumed += value2;
|
|
794
|
+
state.index += num;
|
|
795
|
+
};
|
|
796
|
+
const append = (token) => {
|
|
797
|
+
state.output += token.output != null ? token.output : token.value;
|
|
798
|
+
consume(token.value);
|
|
799
|
+
};
|
|
800
|
+
const negate = () => {
|
|
801
|
+
let count = 1;
|
|
802
|
+
while (peek() === "!" && (peek(2) !== "(" || peek(3) === "?")) {
|
|
803
|
+
advance();
|
|
804
|
+
state.start++;
|
|
805
|
+
count++;
|
|
806
|
+
}
|
|
807
|
+
if (count % 2 === 0) {
|
|
808
|
+
return false;
|
|
809
|
+
}
|
|
810
|
+
state.negated = true;
|
|
811
|
+
state.start++;
|
|
812
|
+
return true;
|
|
813
|
+
};
|
|
814
|
+
const increment = (type) => {
|
|
815
|
+
state[type]++;
|
|
816
|
+
stack.push(type);
|
|
817
|
+
};
|
|
818
|
+
const decrement = (type) => {
|
|
819
|
+
state[type]--;
|
|
820
|
+
stack.pop();
|
|
821
|
+
};
|
|
822
|
+
const push = (tok) => {
|
|
823
|
+
if (prev.type === "globstar") {
|
|
824
|
+
const isBrace = state.braces > 0 && (tok.type === "comma" || tok.type === "brace");
|
|
825
|
+
const isExtglob = tok.extglob === true || extglobs.length && (tok.type === "pipe" || tok.type === "paren");
|
|
826
|
+
if (tok.type !== "slash" && tok.type !== "paren" && !isBrace && !isExtglob) {
|
|
827
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
828
|
+
prev.type = "star";
|
|
829
|
+
prev.value = "*";
|
|
830
|
+
prev.output = star;
|
|
831
|
+
state.output += prev.output;
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
if (extglobs.length && tok.type !== "paren") {
|
|
835
|
+
extglobs[extglobs.length - 1].inner += tok.value;
|
|
836
|
+
}
|
|
837
|
+
if (tok.value || tok.output) append(tok);
|
|
838
|
+
if (prev && prev.type === "text" && tok.type === "text") {
|
|
839
|
+
prev.output = (prev.output || prev.value) + tok.value;
|
|
840
|
+
prev.value += tok.value;
|
|
841
|
+
return;
|
|
842
|
+
}
|
|
843
|
+
tok.prev = prev;
|
|
844
|
+
tokens.push(tok);
|
|
845
|
+
prev = tok;
|
|
846
|
+
};
|
|
847
|
+
const extglobOpen = (type, value2) => {
|
|
848
|
+
const token = { ...EXTGLOB_CHARS[value2], conditions: 1, inner: "" };
|
|
849
|
+
token.prev = prev;
|
|
850
|
+
token.parens = state.parens;
|
|
851
|
+
token.output = state.output;
|
|
852
|
+
const output = (opts.capture ? "(" : "") + token.open;
|
|
853
|
+
increment("parens");
|
|
854
|
+
push({ type, value: value2, output: state.output ? "" : ONE_CHAR });
|
|
855
|
+
push({ type: "paren", extglob: true, value: advance(), output });
|
|
856
|
+
extglobs.push(token);
|
|
857
|
+
};
|
|
858
|
+
const extglobClose = (token) => {
|
|
859
|
+
let output = token.close + (opts.capture ? ")" : "");
|
|
860
|
+
let rest;
|
|
861
|
+
if (token.type === "negate") {
|
|
862
|
+
let extglobStar = star;
|
|
863
|
+
if (token.inner && token.inner.length > 1 && token.inner.includes("/")) {
|
|
864
|
+
extglobStar = globstar(opts);
|
|
865
|
+
}
|
|
866
|
+
if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
|
|
867
|
+
output = token.close = `)$))${extglobStar}`;
|
|
868
|
+
}
|
|
869
|
+
if (token.inner.includes("*") && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
|
|
870
|
+
const expression = parse2(rest, { ...options, fastpaths: false }).output;
|
|
871
|
+
output = token.close = `)${expression})${extglobStar})`;
|
|
872
|
+
}
|
|
873
|
+
if (token.prev.type === "bos") {
|
|
874
|
+
state.negatedExtglob = true;
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
push({ type: "paren", extglob: true, value, output });
|
|
878
|
+
decrement("parens");
|
|
879
|
+
};
|
|
880
|
+
if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
|
|
881
|
+
let backslashes = false;
|
|
882
|
+
let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
|
|
883
|
+
if (first === "\\") {
|
|
884
|
+
backslashes = true;
|
|
885
|
+
return m;
|
|
886
|
+
}
|
|
887
|
+
if (first === "?") {
|
|
888
|
+
if (esc) {
|
|
889
|
+
return esc + first + (rest ? QMARK.repeat(rest.length) : "");
|
|
890
|
+
}
|
|
891
|
+
if (index === 0) {
|
|
892
|
+
return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : "");
|
|
893
|
+
}
|
|
894
|
+
return QMARK.repeat(chars.length);
|
|
895
|
+
}
|
|
896
|
+
if (first === ".") {
|
|
897
|
+
return DOT_LITERAL.repeat(chars.length);
|
|
898
|
+
}
|
|
899
|
+
if (first === "*") {
|
|
900
|
+
if (esc) {
|
|
901
|
+
return esc + first + (rest ? star : "");
|
|
902
|
+
}
|
|
903
|
+
return star;
|
|
904
|
+
}
|
|
905
|
+
return esc ? m : `\\${m}`;
|
|
906
|
+
});
|
|
907
|
+
if (backslashes === true) {
|
|
908
|
+
if (opts.unescape === true) {
|
|
909
|
+
output = output.replace(/\\/g, "");
|
|
910
|
+
} else {
|
|
911
|
+
output = output.replace(/\\+/g, (m) => {
|
|
912
|
+
return m.length % 2 === 0 ? "\\\\" : m ? "\\" : "";
|
|
913
|
+
});
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
if (output === input && opts.contains === true) {
|
|
917
|
+
state.output = input;
|
|
918
|
+
return state;
|
|
919
|
+
}
|
|
920
|
+
state.output = utils.wrapOutput(output, state, options);
|
|
921
|
+
return state;
|
|
922
|
+
}
|
|
923
|
+
while (!eos()) {
|
|
924
|
+
value = advance();
|
|
925
|
+
if (value === "\0") {
|
|
926
|
+
continue;
|
|
927
|
+
}
|
|
928
|
+
if (value === "\\") {
|
|
929
|
+
const next = peek();
|
|
930
|
+
if (next === "/" && opts.bash !== true) {
|
|
931
|
+
continue;
|
|
932
|
+
}
|
|
933
|
+
if (next === "." || next === ";") {
|
|
934
|
+
continue;
|
|
935
|
+
}
|
|
936
|
+
if (!next) {
|
|
937
|
+
value += "\\";
|
|
938
|
+
push({ type: "text", value });
|
|
939
|
+
continue;
|
|
940
|
+
}
|
|
941
|
+
const match2 = /^\\+/.exec(remaining());
|
|
942
|
+
let slashes = 0;
|
|
943
|
+
if (match2 && match2[0].length > 2) {
|
|
944
|
+
slashes = match2[0].length;
|
|
945
|
+
state.index += slashes;
|
|
946
|
+
if (slashes % 2 !== 0) {
|
|
947
|
+
value += "\\";
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
if (opts.unescape === true) {
|
|
951
|
+
value = advance();
|
|
952
|
+
} else {
|
|
953
|
+
value += advance();
|
|
954
|
+
}
|
|
955
|
+
if (state.brackets === 0) {
|
|
956
|
+
push({ type: "text", value });
|
|
957
|
+
continue;
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
if (state.brackets > 0 && (value !== "]" || prev.value === "[" || prev.value === "[^")) {
|
|
961
|
+
if (opts.posix !== false && value === ":") {
|
|
962
|
+
const inner = prev.value.slice(1);
|
|
963
|
+
if (inner.includes("[")) {
|
|
964
|
+
prev.posix = true;
|
|
965
|
+
if (inner.includes(":")) {
|
|
966
|
+
const idx = prev.value.lastIndexOf("[");
|
|
967
|
+
const pre = prev.value.slice(0, idx);
|
|
968
|
+
const rest2 = prev.value.slice(idx + 2);
|
|
969
|
+
const posix = POSIX_REGEX_SOURCE[rest2];
|
|
970
|
+
if (posix) {
|
|
971
|
+
prev.value = pre + posix;
|
|
972
|
+
state.backtrack = true;
|
|
973
|
+
advance();
|
|
974
|
+
if (!bos.output && tokens.indexOf(prev) === 1) {
|
|
975
|
+
bos.output = ONE_CHAR;
|
|
976
|
+
}
|
|
977
|
+
continue;
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
if (value === "[" && peek() !== ":" || value === "-" && peek() === "]") {
|
|
983
|
+
value = `\\${value}`;
|
|
984
|
+
}
|
|
985
|
+
if (value === "]" && (prev.value === "[" || prev.value === "[^")) {
|
|
986
|
+
value = `\\${value}`;
|
|
987
|
+
}
|
|
988
|
+
if (opts.posix === true && value === "!" && prev.value === "[") {
|
|
989
|
+
value = "^";
|
|
990
|
+
}
|
|
991
|
+
prev.value += value;
|
|
992
|
+
append({ value });
|
|
993
|
+
continue;
|
|
994
|
+
}
|
|
995
|
+
if (state.quotes === 1 && value !== '"') {
|
|
996
|
+
value = utils.escapeRegex(value);
|
|
997
|
+
prev.value += value;
|
|
998
|
+
append({ value });
|
|
999
|
+
continue;
|
|
1000
|
+
}
|
|
1001
|
+
if (value === '"') {
|
|
1002
|
+
state.quotes = state.quotes === 1 ? 0 : 1;
|
|
1003
|
+
if (opts.keepQuotes === true) {
|
|
1004
|
+
push({ type: "text", value });
|
|
1005
|
+
}
|
|
1006
|
+
continue;
|
|
1007
|
+
}
|
|
1008
|
+
if (value === "(") {
|
|
1009
|
+
increment("parens");
|
|
1010
|
+
push({ type: "paren", value });
|
|
1011
|
+
continue;
|
|
1012
|
+
}
|
|
1013
|
+
if (value === ")") {
|
|
1014
|
+
if (state.parens === 0 && opts.strictBrackets === true) {
|
|
1015
|
+
throw new SyntaxError(syntaxError("opening", "("));
|
|
1016
|
+
}
|
|
1017
|
+
const extglob = extglobs[extglobs.length - 1];
|
|
1018
|
+
if (extglob && state.parens === extglob.parens + 1) {
|
|
1019
|
+
extglobClose(extglobs.pop());
|
|
1020
|
+
continue;
|
|
1021
|
+
}
|
|
1022
|
+
push({ type: "paren", value, output: state.parens ? ")" : "\\)" });
|
|
1023
|
+
decrement("parens");
|
|
1024
|
+
continue;
|
|
1025
|
+
}
|
|
1026
|
+
if (value === "[") {
|
|
1027
|
+
if (opts.nobracket === true || !remaining().includes("]")) {
|
|
1028
|
+
if (opts.nobracket !== true && opts.strictBrackets === true) {
|
|
1029
|
+
throw new SyntaxError(syntaxError("closing", "]"));
|
|
1030
|
+
}
|
|
1031
|
+
value = `\\${value}`;
|
|
1032
|
+
} else {
|
|
1033
|
+
increment("brackets");
|
|
1034
|
+
}
|
|
1035
|
+
push({ type: "bracket", value });
|
|
1036
|
+
continue;
|
|
1037
|
+
}
|
|
1038
|
+
if (value === "]") {
|
|
1039
|
+
if (opts.nobracket === true || prev && prev.type === "bracket" && prev.value.length === 1) {
|
|
1040
|
+
push({ type: "text", value, output: `\\${value}` });
|
|
1041
|
+
continue;
|
|
1042
|
+
}
|
|
1043
|
+
if (state.brackets === 0) {
|
|
1044
|
+
if (opts.strictBrackets === true) {
|
|
1045
|
+
throw new SyntaxError(syntaxError("opening", "["));
|
|
1046
|
+
}
|
|
1047
|
+
push({ type: "text", value, output: `\\${value}` });
|
|
1048
|
+
continue;
|
|
1049
|
+
}
|
|
1050
|
+
decrement("brackets");
|
|
1051
|
+
const prevValue = prev.value.slice(1);
|
|
1052
|
+
if (prev.posix !== true && prevValue[0] === "^" && !prevValue.includes("/")) {
|
|
1053
|
+
value = `/${value}`;
|
|
1054
|
+
}
|
|
1055
|
+
prev.value += value;
|
|
1056
|
+
append({ value });
|
|
1057
|
+
if (opts.literalBrackets === false || utils.hasRegexChars(prevValue)) {
|
|
1058
|
+
continue;
|
|
1059
|
+
}
|
|
1060
|
+
const escaped = utils.escapeRegex(prev.value);
|
|
1061
|
+
state.output = state.output.slice(0, -prev.value.length);
|
|
1062
|
+
if (opts.literalBrackets === true) {
|
|
1063
|
+
state.output += escaped;
|
|
1064
|
+
prev.value = escaped;
|
|
1065
|
+
continue;
|
|
1066
|
+
}
|
|
1067
|
+
prev.value = `(${capture}${escaped}|${prev.value})`;
|
|
1068
|
+
state.output += prev.value;
|
|
1069
|
+
continue;
|
|
1070
|
+
}
|
|
1071
|
+
if (value === "{" && opts.nobrace !== true) {
|
|
1072
|
+
increment("braces");
|
|
1073
|
+
const open = {
|
|
1074
|
+
type: "brace",
|
|
1075
|
+
value,
|
|
1076
|
+
output: "(",
|
|
1077
|
+
outputIndex: state.output.length,
|
|
1078
|
+
tokensIndex: state.tokens.length
|
|
1079
|
+
};
|
|
1080
|
+
braces.push(open);
|
|
1081
|
+
push(open);
|
|
1082
|
+
continue;
|
|
1083
|
+
}
|
|
1084
|
+
if (value === "}") {
|
|
1085
|
+
const brace = braces[braces.length - 1];
|
|
1086
|
+
if (opts.nobrace === true || !brace) {
|
|
1087
|
+
push({ type: "text", value, output: value });
|
|
1088
|
+
continue;
|
|
1089
|
+
}
|
|
1090
|
+
let output = ")";
|
|
1091
|
+
if (brace.dots === true) {
|
|
1092
|
+
const arr = tokens.slice();
|
|
1093
|
+
const range = [];
|
|
1094
|
+
for (let i = arr.length - 1; i >= 0; i--) {
|
|
1095
|
+
tokens.pop();
|
|
1096
|
+
if (arr[i].type === "brace") {
|
|
1097
|
+
break;
|
|
1098
|
+
}
|
|
1099
|
+
if (arr[i].type !== "dots") {
|
|
1100
|
+
range.unshift(arr[i].value);
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
output = expandRange(range, opts);
|
|
1104
|
+
state.backtrack = true;
|
|
1105
|
+
}
|
|
1106
|
+
if (brace.comma !== true && brace.dots !== true) {
|
|
1107
|
+
const out = state.output.slice(0, brace.outputIndex);
|
|
1108
|
+
const toks = state.tokens.slice(brace.tokensIndex);
|
|
1109
|
+
brace.value = brace.output = "\\{";
|
|
1110
|
+
value = output = "\\}";
|
|
1111
|
+
state.output = out;
|
|
1112
|
+
for (const t of toks) {
|
|
1113
|
+
state.output += t.output || t.value;
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
push({ type: "brace", value, output });
|
|
1117
|
+
decrement("braces");
|
|
1118
|
+
braces.pop();
|
|
1119
|
+
continue;
|
|
1120
|
+
}
|
|
1121
|
+
if (value === "|") {
|
|
1122
|
+
if (extglobs.length > 0) {
|
|
1123
|
+
extglobs[extglobs.length - 1].conditions++;
|
|
1124
|
+
}
|
|
1125
|
+
push({ type: "text", value });
|
|
1126
|
+
continue;
|
|
1127
|
+
}
|
|
1128
|
+
if (value === ",") {
|
|
1129
|
+
let output = value;
|
|
1130
|
+
const brace = braces[braces.length - 1];
|
|
1131
|
+
if (brace && stack[stack.length - 1] === "braces") {
|
|
1132
|
+
brace.comma = true;
|
|
1133
|
+
output = "|";
|
|
1134
|
+
}
|
|
1135
|
+
push({ type: "comma", value, output });
|
|
1136
|
+
continue;
|
|
1137
|
+
}
|
|
1138
|
+
if (value === "/") {
|
|
1139
|
+
if (prev.type === "dot" && state.index === state.start + 1) {
|
|
1140
|
+
state.start = state.index + 1;
|
|
1141
|
+
state.consumed = "";
|
|
1142
|
+
state.output = "";
|
|
1143
|
+
tokens.pop();
|
|
1144
|
+
prev = bos;
|
|
1145
|
+
continue;
|
|
1146
|
+
}
|
|
1147
|
+
push({ type: "slash", value, output: SLASH_LITERAL });
|
|
1148
|
+
continue;
|
|
1149
|
+
}
|
|
1150
|
+
if (value === ".") {
|
|
1151
|
+
if (state.braces > 0 && prev.type === "dot") {
|
|
1152
|
+
if (prev.value === ".") prev.output = DOT_LITERAL;
|
|
1153
|
+
const brace = braces[braces.length - 1];
|
|
1154
|
+
prev.type = "dots";
|
|
1155
|
+
prev.output += value;
|
|
1156
|
+
prev.value += value;
|
|
1157
|
+
brace.dots = true;
|
|
1158
|
+
continue;
|
|
1159
|
+
}
|
|
1160
|
+
if (state.braces + state.parens === 0 && prev.type !== "bos" && prev.type !== "slash") {
|
|
1161
|
+
push({ type: "text", value, output: DOT_LITERAL });
|
|
1162
|
+
continue;
|
|
1163
|
+
}
|
|
1164
|
+
push({ type: "dot", value, output: DOT_LITERAL });
|
|
1165
|
+
continue;
|
|
1166
|
+
}
|
|
1167
|
+
if (value === "?") {
|
|
1168
|
+
const isGroup = prev && prev.value === "(";
|
|
1169
|
+
if (!isGroup && opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
1170
|
+
extglobOpen("qmark", value);
|
|
1171
|
+
continue;
|
|
1172
|
+
}
|
|
1173
|
+
if (prev && prev.type === "paren") {
|
|
1174
|
+
const next = peek();
|
|
1175
|
+
let output = value;
|
|
1176
|
+
if (prev.value === "(" && !/[!=<:]/.test(next) || next === "<" && !/<([!=]|\w+>)/.test(remaining())) {
|
|
1177
|
+
output = `\\${value}`;
|
|
1178
|
+
}
|
|
1179
|
+
push({ type: "text", value, output });
|
|
1180
|
+
continue;
|
|
1181
|
+
}
|
|
1182
|
+
if (opts.dot !== true && (prev.type === "slash" || prev.type === "bos")) {
|
|
1183
|
+
push({ type: "qmark", value, output: QMARK_NO_DOT });
|
|
1184
|
+
continue;
|
|
1185
|
+
}
|
|
1186
|
+
push({ type: "qmark", value, output: QMARK });
|
|
1187
|
+
continue;
|
|
1188
|
+
}
|
|
1189
|
+
if (value === "!") {
|
|
1190
|
+
if (opts.noextglob !== true && peek() === "(") {
|
|
1191
|
+
if (peek(2) !== "?" || !/[!=<:]/.test(peek(3))) {
|
|
1192
|
+
extglobOpen("negate", value);
|
|
1193
|
+
continue;
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
if (opts.nonegate !== true && state.index === 0) {
|
|
1197
|
+
negate();
|
|
1198
|
+
continue;
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
if (value === "+") {
|
|
1202
|
+
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
1203
|
+
extglobOpen("plus", value);
|
|
1204
|
+
continue;
|
|
1205
|
+
}
|
|
1206
|
+
if (prev && prev.value === "(" || opts.regex === false) {
|
|
1207
|
+
push({ type: "plus", value, output: PLUS_LITERAL });
|
|
1208
|
+
continue;
|
|
1209
|
+
}
|
|
1210
|
+
if (prev && (prev.type === "bracket" || prev.type === "paren" || prev.type === "brace") || state.parens > 0) {
|
|
1211
|
+
push({ type: "plus", value });
|
|
1212
|
+
continue;
|
|
1213
|
+
}
|
|
1214
|
+
push({ type: "plus", value: PLUS_LITERAL });
|
|
1215
|
+
continue;
|
|
1216
|
+
}
|
|
1217
|
+
if (value === "@") {
|
|
1218
|
+
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
1219
|
+
push({ type: "at", extglob: true, value, output: "" });
|
|
1220
|
+
continue;
|
|
1221
|
+
}
|
|
1222
|
+
push({ type: "text", value });
|
|
1223
|
+
continue;
|
|
1224
|
+
}
|
|
1225
|
+
if (value !== "*") {
|
|
1226
|
+
if (value === "$" || value === "^") {
|
|
1227
|
+
value = `\\${value}`;
|
|
1228
|
+
}
|
|
1229
|
+
const match2 = REGEX_NON_SPECIAL_CHARS.exec(remaining());
|
|
1230
|
+
if (match2) {
|
|
1231
|
+
value += match2[0];
|
|
1232
|
+
state.index += match2[0].length;
|
|
1233
|
+
}
|
|
1234
|
+
push({ type: "text", value });
|
|
1235
|
+
continue;
|
|
1236
|
+
}
|
|
1237
|
+
if (prev && (prev.type === "globstar" || prev.star === true)) {
|
|
1238
|
+
prev.type = "star";
|
|
1239
|
+
prev.star = true;
|
|
1240
|
+
prev.value += value;
|
|
1241
|
+
prev.output = star;
|
|
1242
|
+
state.backtrack = true;
|
|
1243
|
+
state.globstar = true;
|
|
1244
|
+
consume(value);
|
|
1245
|
+
continue;
|
|
1246
|
+
}
|
|
1247
|
+
let rest = remaining();
|
|
1248
|
+
if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
|
|
1249
|
+
extglobOpen("star", value);
|
|
1250
|
+
continue;
|
|
1251
|
+
}
|
|
1252
|
+
if (prev.type === "star") {
|
|
1253
|
+
if (opts.noglobstar === true) {
|
|
1254
|
+
consume(value);
|
|
1255
|
+
continue;
|
|
1256
|
+
}
|
|
1257
|
+
const prior = prev.prev;
|
|
1258
|
+
const before = prior.prev;
|
|
1259
|
+
const isStart = prior.type === "slash" || prior.type === "bos";
|
|
1260
|
+
const afterStar = before && (before.type === "star" || before.type === "globstar");
|
|
1261
|
+
if (opts.bash === true && (!isStart || rest[0] && rest[0] !== "/")) {
|
|
1262
|
+
push({ type: "star", value, output: "" });
|
|
1263
|
+
continue;
|
|
1264
|
+
}
|
|
1265
|
+
const isBrace = state.braces > 0 && (prior.type === "comma" || prior.type === "brace");
|
|
1266
|
+
const isExtglob = extglobs.length && (prior.type === "pipe" || prior.type === "paren");
|
|
1267
|
+
if (!isStart && prior.type !== "paren" && !isBrace && !isExtglob) {
|
|
1268
|
+
push({ type: "star", value, output: "" });
|
|
1269
|
+
continue;
|
|
1270
|
+
}
|
|
1271
|
+
while (rest.slice(0, 3) === "/**") {
|
|
1272
|
+
const after = input[state.index + 4];
|
|
1273
|
+
if (after && after !== "/") {
|
|
1274
|
+
break;
|
|
1275
|
+
}
|
|
1276
|
+
rest = rest.slice(3);
|
|
1277
|
+
consume("/**", 3);
|
|
1278
|
+
}
|
|
1279
|
+
if (prior.type === "bos" && eos()) {
|
|
1280
|
+
prev.type = "globstar";
|
|
1281
|
+
prev.value += value;
|
|
1282
|
+
prev.output = globstar(opts);
|
|
1283
|
+
state.output = prev.output;
|
|
1284
|
+
state.globstar = true;
|
|
1285
|
+
consume(value);
|
|
1286
|
+
continue;
|
|
1287
|
+
}
|
|
1288
|
+
if (prior.type === "slash" && prior.prev.type !== "bos" && !afterStar && eos()) {
|
|
1289
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
1290
|
+
prior.output = `(?:${prior.output}`;
|
|
1291
|
+
prev.type = "globstar";
|
|
1292
|
+
prev.output = globstar(opts) + (opts.strictSlashes ? ")" : "|$)");
|
|
1293
|
+
prev.value += value;
|
|
1294
|
+
state.globstar = true;
|
|
1295
|
+
state.output += prior.output + prev.output;
|
|
1296
|
+
consume(value);
|
|
1297
|
+
continue;
|
|
1298
|
+
}
|
|
1299
|
+
if (prior.type === "slash" && prior.prev.type !== "bos" && rest[0] === "/") {
|
|
1300
|
+
const end = rest[1] !== void 0 ? "|$" : "";
|
|
1301
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
1302
|
+
prior.output = `(?:${prior.output}`;
|
|
1303
|
+
prev.type = "globstar";
|
|
1304
|
+
prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
|
|
1305
|
+
prev.value += value;
|
|
1306
|
+
state.output += prior.output + prev.output;
|
|
1307
|
+
state.globstar = true;
|
|
1308
|
+
consume(value + advance());
|
|
1309
|
+
push({ type: "slash", value: "/", output: "" });
|
|
1310
|
+
continue;
|
|
1311
|
+
}
|
|
1312
|
+
if (prior.type === "bos" && rest[0] === "/") {
|
|
1313
|
+
prev.type = "globstar";
|
|
1314
|
+
prev.value += value;
|
|
1315
|
+
prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
|
|
1316
|
+
state.output = prev.output;
|
|
1317
|
+
state.globstar = true;
|
|
1318
|
+
consume(value + advance());
|
|
1319
|
+
push({ type: "slash", value: "/", output: "" });
|
|
1320
|
+
continue;
|
|
1321
|
+
}
|
|
1322
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
1323
|
+
prev.type = "globstar";
|
|
1324
|
+
prev.output = globstar(opts);
|
|
1325
|
+
prev.value += value;
|
|
1326
|
+
state.output += prev.output;
|
|
1327
|
+
state.globstar = true;
|
|
1328
|
+
consume(value);
|
|
1329
|
+
continue;
|
|
1330
|
+
}
|
|
1331
|
+
const token = { type: "star", value, output: star };
|
|
1332
|
+
if (opts.bash === true) {
|
|
1333
|
+
token.output = ".*?";
|
|
1334
|
+
if (prev.type === "bos" || prev.type === "slash") {
|
|
1335
|
+
token.output = nodot + token.output;
|
|
1336
|
+
}
|
|
1337
|
+
push(token);
|
|
1338
|
+
continue;
|
|
1339
|
+
}
|
|
1340
|
+
if (prev && (prev.type === "bracket" || prev.type === "paren") && opts.regex === true) {
|
|
1341
|
+
token.output = value;
|
|
1342
|
+
push(token);
|
|
1343
|
+
continue;
|
|
1344
|
+
}
|
|
1345
|
+
if (state.index === state.start || prev.type === "slash" || prev.type === "dot") {
|
|
1346
|
+
if (prev.type === "dot") {
|
|
1347
|
+
state.output += NO_DOT_SLASH;
|
|
1348
|
+
prev.output += NO_DOT_SLASH;
|
|
1349
|
+
} else if (opts.dot === true) {
|
|
1350
|
+
state.output += NO_DOTS_SLASH;
|
|
1351
|
+
prev.output += NO_DOTS_SLASH;
|
|
1352
|
+
} else {
|
|
1353
|
+
state.output += nodot;
|
|
1354
|
+
prev.output += nodot;
|
|
1355
|
+
}
|
|
1356
|
+
if (peek() !== "*") {
|
|
1357
|
+
state.output += ONE_CHAR;
|
|
1358
|
+
prev.output += ONE_CHAR;
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
push(token);
|
|
1362
|
+
}
|
|
1363
|
+
while (state.brackets > 0) {
|
|
1364
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "]"));
|
|
1365
|
+
state.output = utils.escapeLast(state.output, "[");
|
|
1366
|
+
decrement("brackets");
|
|
1367
|
+
}
|
|
1368
|
+
while (state.parens > 0) {
|
|
1369
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", ")"));
|
|
1370
|
+
state.output = utils.escapeLast(state.output, "(");
|
|
1371
|
+
decrement("parens");
|
|
1372
|
+
}
|
|
1373
|
+
while (state.braces > 0) {
|
|
1374
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "}"));
|
|
1375
|
+
state.output = utils.escapeLast(state.output, "{");
|
|
1376
|
+
decrement("braces");
|
|
1377
|
+
}
|
|
1378
|
+
if (opts.strictSlashes !== true && (prev.type === "star" || prev.type === "bracket")) {
|
|
1379
|
+
push({ type: "maybe_slash", value: "", output: `${SLASH_LITERAL}?` });
|
|
1380
|
+
}
|
|
1381
|
+
if (state.backtrack === true) {
|
|
1382
|
+
state.output = "";
|
|
1383
|
+
for (const token of state.tokens) {
|
|
1384
|
+
state.output += token.output != null ? token.output : token.value;
|
|
1385
|
+
if (token.suffix) {
|
|
1386
|
+
state.output += token.suffix;
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
return state;
|
|
1391
|
+
};
|
|
1392
|
+
parse2.fastpaths = (input, options) => {
|
|
1393
|
+
const opts = { ...options };
|
|
1394
|
+
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
1395
|
+
const len = input.length;
|
|
1396
|
+
if (len > max) {
|
|
1397
|
+
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
1398
|
+
}
|
|
1399
|
+
input = REPLACEMENTS[input] || input;
|
|
1400
|
+
const {
|
|
1401
|
+
DOT_LITERAL,
|
|
1402
|
+
SLASH_LITERAL,
|
|
1403
|
+
ONE_CHAR,
|
|
1404
|
+
DOTS_SLASH,
|
|
1405
|
+
NO_DOT,
|
|
1406
|
+
NO_DOTS,
|
|
1407
|
+
NO_DOTS_SLASH,
|
|
1408
|
+
STAR,
|
|
1409
|
+
START_ANCHOR
|
|
1410
|
+
} = constants.globChars(opts.windows);
|
|
1411
|
+
const nodot = opts.dot ? NO_DOTS : NO_DOT;
|
|
1412
|
+
const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
|
|
1413
|
+
const capture = opts.capture ? "" : "?:";
|
|
1414
|
+
const state = { negated: false, prefix: "" };
|
|
1415
|
+
let star = opts.bash === true ? ".*?" : STAR;
|
|
1416
|
+
if (opts.capture) {
|
|
1417
|
+
star = `(${star})`;
|
|
1418
|
+
}
|
|
1419
|
+
const globstar = (opts2) => {
|
|
1420
|
+
if (opts2.noglobstar === true) return star;
|
|
1421
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts2.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
1422
|
+
};
|
|
1423
|
+
const create = (str) => {
|
|
1424
|
+
switch (str) {
|
|
1425
|
+
case "*":
|
|
1426
|
+
return `${nodot}${ONE_CHAR}${star}`;
|
|
1427
|
+
case ".*":
|
|
1428
|
+
return `${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1429
|
+
case "*.*":
|
|
1430
|
+
return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1431
|
+
case "*/*":
|
|
1432
|
+
return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
|
|
1433
|
+
case "**":
|
|
1434
|
+
return nodot + globstar(opts);
|
|
1435
|
+
case "**/*":
|
|
1436
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
|
|
1437
|
+
case "**/*.*":
|
|
1438
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1439
|
+
case "**/.*":
|
|
1440
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1441
|
+
default: {
|
|
1442
|
+
const match2 = /^(.*?)\.(\w+)$/.exec(str);
|
|
1443
|
+
if (!match2) return;
|
|
1444
|
+
const source2 = create(match2[1]);
|
|
1445
|
+
if (!source2) return;
|
|
1446
|
+
return source2 + DOT_LITERAL + match2[2];
|
|
1447
|
+
}
|
|
1448
|
+
}
|
|
1449
|
+
};
|
|
1450
|
+
const output = utils.removePrefix(input, state);
|
|
1451
|
+
let source = create(output);
|
|
1452
|
+
if (source && opts.strictSlashes !== true) {
|
|
1453
|
+
source += `${SLASH_LITERAL}?`;
|
|
1454
|
+
}
|
|
1455
|
+
return source;
|
|
1456
|
+
};
|
|
1457
|
+
module.exports = parse2;
|
|
1458
|
+
}
|
|
1459
|
+
});
|
|
1460
|
+
|
|
1461
|
+
// node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/picomatch.js
|
|
1462
|
+
var require_picomatch = __commonJS({
|
|
1463
|
+
"node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/picomatch.js"(exports, module) {
|
|
1464
|
+
"use strict";
|
|
1465
|
+
var scan = require_scan();
|
|
1466
|
+
var parse2 = require_parse();
|
|
1467
|
+
var utils = require_utils();
|
|
1468
|
+
var constants = require_constants();
|
|
1469
|
+
var isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
|
|
1470
|
+
var picomatch2 = (glob, options, returnState = false) => {
|
|
1471
|
+
if (Array.isArray(glob)) {
|
|
1472
|
+
const fns = glob.map((input) => picomatch2(input, options, returnState));
|
|
1473
|
+
const arrayMatcher = (str) => {
|
|
1474
|
+
for (const isMatch of fns) {
|
|
1475
|
+
const state2 = isMatch(str);
|
|
1476
|
+
if (state2) return state2;
|
|
1477
|
+
}
|
|
1478
|
+
return false;
|
|
1479
|
+
};
|
|
1480
|
+
return arrayMatcher;
|
|
1481
|
+
}
|
|
1482
|
+
const isState = isObject(glob) && glob.tokens && glob.input;
|
|
1483
|
+
if (glob === "" || typeof glob !== "string" && !isState) {
|
|
1484
|
+
throw new TypeError("Expected pattern to be a non-empty string");
|
|
1485
|
+
}
|
|
1486
|
+
const opts = options || {};
|
|
1487
|
+
const posix = opts.windows;
|
|
1488
|
+
const regex = isState ? picomatch2.compileRe(glob, options) : picomatch2.makeRe(glob, options, false, true);
|
|
1489
|
+
const state = regex.state;
|
|
1490
|
+
delete regex.state;
|
|
1491
|
+
let isIgnored = () => false;
|
|
1492
|
+
if (opts.ignore) {
|
|
1493
|
+
const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
|
|
1494
|
+
isIgnored = picomatch2(opts.ignore, ignoreOpts, returnState);
|
|
1495
|
+
}
|
|
1496
|
+
const matcher = (input, returnObject = false) => {
|
|
1497
|
+
const { isMatch, match: match2, output } = picomatch2.test(input, regex, options, { glob, posix });
|
|
1498
|
+
const result = { glob, state, regex, posix, input, output, match: match2, isMatch };
|
|
1499
|
+
if (typeof opts.onResult === "function") {
|
|
1500
|
+
opts.onResult(result);
|
|
1501
|
+
}
|
|
1502
|
+
if (isMatch === false) {
|
|
1503
|
+
result.isMatch = false;
|
|
1504
|
+
return returnObject ? result : false;
|
|
1505
|
+
}
|
|
1506
|
+
if (isIgnored(input)) {
|
|
1507
|
+
if (typeof opts.onIgnore === "function") {
|
|
1508
|
+
opts.onIgnore(result);
|
|
1509
|
+
}
|
|
1510
|
+
result.isMatch = false;
|
|
1511
|
+
return returnObject ? result : false;
|
|
1512
|
+
}
|
|
1513
|
+
if (typeof opts.onMatch === "function") {
|
|
1514
|
+
opts.onMatch(result);
|
|
1515
|
+
}
|
|
1516
|
+
return returnObject ? result : true;
|
|
1517
|
+
};
|
|
1518
|
+
if (returnState) {
|
|
1519
|
+
matcher.state = state;
|
|
1520
|
+
}
|
|
1521
|
+
return matcher;
|
|
1522
|
+
};
|
|
1523
|
+
picomatch2.test = (input, regex, options, { glob, posix } = {}) => {
|
|
1524
|
+
if (typeof input !== "string") {
|
|
1525
|
+
throw new TypeError("Expected input to be a string");
|
|
1526
|
+
}
|
|
1527
|
+
if (input === "") {
|
|
1528
|
+
return { isMatch: false, output: "" };
|
|
1529
|
+
}
|
|
1530
|
+
const opts = options || {};
|
|
1531
|
+
const format = opts.format || (posix ? utils.toPosixSlashes : null);
|
|
1532
|
+
let match2 = input === glob;
|
|
1533
|
+
let output = match2 && format ? format(input) : input;
|
|
1534
|
+
if (match2 === false) {
|
|
1535
|
+
output = format ? format(input) : input;
|
|
1536
|
+
match2 = output === glob;
|
|
1537
|
+
}
|
|
1538
|
+
if (match2 === false || opts.capture === true) {
|
|
1539
|
+
if (opts.matchBase === true || opts.basename === true) {
|
|
1540
|
+
match2 = picomatch2.matchBase(input, regex, options, posix);
|
|
1541
|
+
} else {
|
|
1542
|
+
match2 = regex.exec(output);
|
|
1543
|
+
}
|
|
1544
|
+
}
|
|
1545
|
+
return { isMatch: Boolean(match2), match: match2, output };
|
|
1546
|
+
};
|
|
1547
|
+
picomatch2.matchBase = (input, glob, options) => {
|
|
1548
|
+
const regex = glob instanceof RegExp ? glob : picomatch2.makeRe(glob, options);
|
|
1549
|
+
return regex.test(utils.basename(input));
|
|
1550
|
+
};
|
|
1551
|
+
picomatch2.isMatch = (str, patterns, options) => picomatch2(patterns, options)(str);
|
|
1552
|
+
picomatch2.parse = (pattern, options) => {
|
|
1553
|
+
if (Array.isArray(pattern)) return pattern.map((p) => picomatch2.parse(p, options));
|
|
1554
|
+
return parse2(pattern, { ...options, fastpaths: false });
|
|
1555
|
+
};
|
|
1556
|
+
picomatch2.scan = (input, options) => scan(input, options);
|
|
1557
|
+
picomatch2.compileRe = (state, options, returnOutput = false, returnState = false) => {
|
|
1558
|
+
if (returnOutput === true) {
|
|
1559
|
+
return state.output;
|
|
1560
|
+
}
|
|
1561
|
+
const opts = options || {};
|
|
1562
|
+
const prepend = opts.contains ? "" : "^";
|
|
1563
|
+
const append = opts.contains ? "" : "$";
|
|
1564
|
+
let source = `${prepend}(?:${state.output})${append}`;
|
|
1565
|
+
if (state && state.negated === true) {
|
|
1566
|
+
source = `^(?!${source}).*$`;
|
|
1567
|
+
}
|
|
1568
|
+
const regex = picomatch2.toRegex(source, options);
|
|
1569
|
+
if (returnState === true) {
|
|
1570
|
+
regex.state = state;
|
|
1571
|
+
}
|
|
1572
|
+
return regex;
|
|
1573
|
+
};
|
|
1574
|
+
picomatch2.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
|
|
1575
|
+
if (!input || typeof input !== "string") {
|
|
1576
|
+
throw new TypeError("Expected a non-empty string");
|
|
1577
|
+
}
|
|
1578
|
+
let parsed = { negated: false, fastpaths: true };
|
|
1579
|
+
if (options.fastpaths !== false && (input[0] === "." || input[0] === "*")) {
|
|
1580
|
+
parsed.output = parse2.fastpaths(input, options);
|
|
1581
|
+
}
|
|
1582
|
+
if (!parsed.output) {
|
|
1583
|
+
parsed = parse2(input, options);
|
|
1584
|
+
}
|
|
1585
|
+
return picomatch2.compileRe(parsed, options, returnOutput, returnState);
|
|
1586
|
+
};
|
|
1587
|
+
picomatch2.toRegex = (source, options) => {
|
|
1588
|
+
try {
|
|
1589
|
+
const opts = options || {};
|
|
1590
|
+
return new RegExp(source, opts.flags || (opts.nocase ? "i" : ""));
|
|
1591
|
+
} catch (err) {
|
|
1592
|
+
if (options && options.debug === true) throw err;
|
|
1593
|
+
return /$^/;
|
|
1594
|
+
}
|
|
1595
|
+
};
|
|
1596
|
+
picomatch2.constants = constants;
|
|
1597
|
+
module.exports = picomatch2;
|
|
1598
|
+
}
|
|
1599
|
+
});
|
|
1600
|
+
|
|
1601
|
+
// node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/index.js
|
|
1602
|
+
var require_picomatch2 = __commonJS({
|
|
1603
|
+
"node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/index.js"(exports, module) {
|
|
1604
|
+
"use strict";
|
|
1605
|
+
var pico = require_picomatch();
|
|
1606
|
+
var utils = require_utils();
|
|
1607
|
+
function picomatch2(glob, options, returnState = false) {
|
|
1608
|
+
if (options && (options.windows === null || options.windows === void 0)) {
|
|
1609
|
+
options = { ...options, windows: utils.isWindows() };
|
|
1610
|
+
}
|
|
1611
|
+
return pico(glob, options, returnState);
|
|
1612
|
+
}
|
|
1613
|
+
Object.assign(picomatch2, pico);
|
|
1614
|
+
module.exports = picomatch2;
|
|
1615
|
+
}
|
|
1616
|
+
});
|
|
1617
|
+
|
|
100
1618
|
// node_modules/.pnpm/ansi-regex@5.0.1/node_modules/ansi-regex/index.js
|
|
101
1619
|
var require_ansi_regex = __commonJS({
|
|
102
1620
|
"node_modules/.pnpm/ansi-regex@5.0.1/node_modules/ansi-regex/index.js"(exports, module) {
|
|
@@ -1511,7 +3029,7 @@ var require_getBorderCharacters = __commonJS({
|
|
|
1511
3029
|
});
|
|
1512
3030
|
|
|
1513
3031
|
// node_modules/.pnpm/table@6.9.0/node_modules/table/dist/src/utils.js
|
|
1514
|
-
var
|
|
3032
|
+
var require_utils2 = __commonJS({
|
|
1515
3033
|
"node_modules/.pnpm/table@6.9.0/node_modules/table/dist/src/utils.js"(exports) {
|
|
1516
3034
|
"use strict";
|
|
1517
3035
|
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
@@ -1623,7 +3141,7 @@ var require_alignString = __commonJS({
|
|
|
1623
3141
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1624
3142
|
exports.alignString = void 0;
|
|
1625
3143
|
var string_width_1 = __importDefault(require_string_width());
|
|
1626
|
-
var utils_1 =
|
|
3144
|
+
var utils_1 = require_utils2();
|
|
1627
3145
|
var alignLeft = (subject, width) => {
|
|
1628
3146
|
return subject + " ".repeat(width);
|
|
1629
3147
|
};
|
|
@@ -1776,7 +3294,7 @@ var require_wrapCell = __commonJS({
|
|
|
1776
3294
|
"use strict";
|
|
1777
3295
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1778
3296
|
exports.wrapCell = void 0;
|
|
1779
|
-
var utils_1 =
|
|
3297
|
+
var utils_1 = require_utils2();
|
|
1780
3298
|
var wrapString_1 = require_wrapString();
|
|
1781
3299
|
var wrapWord_1 = require_wrapWord();
|
|
1782
3300
|
var wrapCell = (cellValue, cellWidth, useWrapWord) => {
|
|
@@ -1818,7 +3336,7 @@ var require_calculateRowHeights = __commonJS({
|
|
|
1818
3336
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1819
3337
|
exports.calculateRowHeights = void 0;
|
|
1820
3338
|
var calculateCellHeight_1 = require_calculateCellHeight();
|
|
1821
|
-
var utils_1 =
|
|
3339
|
+
var utils_1 = require_utils2();
|
|
1822
3340
|
var calculateRowHeights = (rows, config) => {
|
|
1823
3341
|
const rowHeights = [];
|
|
1824
3342
|
for (const [rowIndex, row] of rows.entries()) {
|
|
@@ -4749,7 +6267,7 @@ var require_makeStreamConfig = __commonJS({
|
|
|
4749
6267
|
"use strict";
|
|
4750
6268
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4751
6269
|
exports.makeStreamConfig = void 0;
|
|
4752
|
-
var utils_1 =
|
|
6270
|
+
var utils_1 = require_utils2();
|
|
4753
6271
|
var validateConfig_1 = require_validateConfig();
|
|
4754
6272
|
var makeColumnsConfig = (columnCount, columns = {}, columnDefault) => {
|
|
4755
6273
|
return Array.from({ length: columnCount }).map((_, index) => {
|
|
@@ -4789,7 +6307,7 @@ var require_mapDataUsingRowHeights = __commonJS({
|
|
|
4789
6307
|
"use strict";
|
|
4790
6308
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4791
6309
|
exports.mapDataUsingRowHeights = exports.padCellVertically = void 0;
|
|
4792
|
-
var utils_1 =
|
|
6310
|
+
var utils_1 = require_utils2();
|
|
4793
6311
|
var wrapCell_1 = require_wrapCell();
|
|
4794
6312
|
var createEmptyStrings = (length) => {
|
|
4795
6313
|
return new Array(length).fill("");
|
|
@@ -4878,7 +6396,7 @@ var require_stringifyTableData = __commonJS({
|
|
|
4878
6396
|
"use strict";
|
|
4879
6397
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4880
6398
|
exports.stringifyTableData = void 0;
|
|
4881
|
-
var utils_1 =
|
|
6399
|
+
var utils_1 = require_utils2();
|
|
4882
6400
|
var stringifyTableData = (rows) => {
|
|
4883
6401
|
return rows.map((cells) => {
|
|
4884
6402
|
return cells.map((cell) => {
|
|
@@ -5153,7 +6671,7 @@ var require_createStream = __commonJS({
|
|
|
5153
6671
|
var padTableData_1 = require_padTableData();
|
|
5154
6672
|
var stringifyTableData_1 = require_stringifyTableData();
|
|
5155
6673
|
var truncateTableData_1 = require_truncateTableData();
|
|
5156
|
-
var utils_1 =
|
|
6674
|
+
var utils_1 = require_utils2();
|
|
5157
6675
|
var prepareData = (data, config) => {
|
|
5158
6676
|
let rows = (0, stringifyTableData_1.stringifyTableData)(data);
|
|
5159
6677
|
rows = (0, truncateTableData_1.truncateTableData)(rows, (0, utils_1.extractTruncates)(config));
|
|
@@ -5240,7 +6758,7 @@ var require_drawTable = __commonJS({
|
|
|
5240
6758
|
var drawBorder_1 = require_drawBorder();
|
|
5241
6759
|
var drawContent_1 = require_drawContent();
|
|
5242
6760
|
var drawRow_1 = require_drawRow();
|
|
5243
|
-
var utils_1 =
|
|
6761
|
+
var utils_1 = require_utils2();
|
|
5244
6762
|
var drawTable = (rows, outputColumnWidths, rowHeights, config) => {
|
|
5245
6763
|
const { drawHorizontalLine, singleLine } = config;
|
|
5246
6764
|
const contents = (0, utils_1.groupBySizes)(rows, rowHeights).map((group, groupIndex) => {
|
|
@@ -5322,7 +6840,7 @@ var require_calculateMaximumColumnWidths = __commonJS({
|
|
|
5322
6840
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5323
6841
|
exports.calculateMaximumColumnWidths = exports.calculateMaximumCellWidth = void 0;
|
|
5324
6842
|
var string_width_1 = __importDefault(require_string_width());
|
|
5325
|
-
var utils_1 =
|
|
6843
|
+
var utils_1 = require_utils2();
|
|
5326
6844
|
var calculateMaximumCellWidth = (cell) => {
|
|
5327
6845
|
return Math.max(...cell.split("\n").map(string_width_1.default));
|
|
5328
6846
|
};
|
|
@@ -5366,7 +6884,7 @@ var require_alignSpanningCell = __commonJS({
|
|
|
5366
6884
|
var mapDataUsingRowHeights_1 = require_mapDataUsingRowHeights();
|
|
5367
6885
|
var padTableData_1 = require_padTableData();
|
|
5368
6886
|
var truncateTableData_1 = require_truncateTableData();
|
|
5369
|
-
var utils_1 =
|
|
6887
|
+
var utils_1 = require_utils2();
|
|
5370
6888
|
var wrapCell_1 = require_wrapCell();
|
|
5371
6889
|
var wrapRangeContent = (rangeConfig, rangeWidth, context) => {
|
|
5372
6890
|
const { topLeft, paddingRight, paddingLeft, truncate, wrapWord, alignment } = rangeConfig;
|
|
@@ -5407,7 +6925,7 @@ var require_calculateSpanningCellWidth = __commonJS({
|
|
|
5407
6925
|
"use strict";
|
|
5408
6926
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5409
6927
|
exports.calculateSpanningCellWidth = void 0;
|
|
5410
|
-
var utils_1 =
|
|
6928
|
+
var utils_1 = require_utils2();
|
|
5411
6929
|
var calculateSpanningCellWidth = (rangeConfig, dependencies) => {
|
|
5412
6930
|
const { columnsConfig, drawVerticalLine } = dependencies;
|
|
5413
6931
|
const { topLeft, bottomRight } = rangeConfig;
|
|
@@ -5433,7 +6951,7 @@ var require_makeRangeConfig = __commonJS({
|
|
|
5433
6951
|
"use strict";
|
|
5434
6952
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5435
6953
|
exports.makeRangeConfig = void 0;
|
|
5436
|
-
var utils_1 =
|
|
6954
|
+
var utils_1 = require_utils2();
|
|
5437
6955
|
var makeRangeConfig = (spanningCellConfig, columnsConfig) => {
|
|
5438
6956
|
var _a;
|
|
5439
6957
|
const { topLeft, bottomRight } = (0, utils_1.calculateRangeCoordinate)(spanningCellConfig);
|
|
@@ -5461,7 +6979,7 @@ var require_spanningCellManager = __commonJS({
|
|
|
5461
6979
|
var alignSpanningCell_1 = require_alignSpanningCell();
|
|
5462
6980
|
var calculateSpanningCellWidth_1 = require_calculateSpanningCellWidth();
|
|
5463
6981
|
var makeRangeConfig_1 = require_makeRangeConfig();
|
|
5464
|
-
var utils_1 =
|
|
6982
|
+
var utils_1 = require_utils2();
|
|
5465
6983
|
var findRangeConfig = (cell, rangeConfigs) => {
|
|
5466
6984
|
return rangeConfigs.find((rangeCoordinate) => {
|
|
5467
6985
|
return (0, utils_1.isCellInRange)(cell, rangeCoordinate);
|
|
@@ -5565,7 +7083,7 @@ var require_validateSpanningCellConfig = __commonJS({
|
|
|
5565
7083
|
"use strict";
|
|
5566
7084
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5567
7085
|
exports.validateSpanningCellConfig = void 0;
|
|
5568
|
-
var utils_1 =
|
|
7086
|
+
var utils_1 = require_utils2();
|
|
5569
7087
|
var inRange = (start, end, value) => {
|
|
5570
7088
|
return start <= value && value <= end;
|
|
5571
7089
|
};
|
|
@@ -5615,7 +7133,7 @@ var require_makeTableConfig = __commonJS({
|
|
|
5615
7133
|
exports.makeTableConfig = void 0;
|
|
5616
7134
|
var calculateMaximumColumnWidths_1 = require_calculateMaximumColumnWidths();
|
|
5617
7135
|
var spanningCellManager_1 = require_spanningCellManager();
|
|
5618
|
-
var utils_1 =
|
|
7136
|
+
var utils_1 = require_utils2();
|
|
5619
7137
|
var validateConfig_1 = require_validateConfig();
|
|
5620
7138
|
var validateSpanningCellConfig_1 = require_validateSpanningCellConfig();
|
|
5621
7139
|
var makeColumnsConfig = (rows, columns, columnDefault, spanningCellConfigs) => {
|
|
@@ -5672,7 +7190,7 @@ var require_validateTableData = __commonJS({
|
|
|
5672
7190
|
"use strict";
|
|
5673
7191
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5674
7192
|
exports.validateTableData = void 0;
|
|
5675
|
-
var utils_1 =
|
|
7193
|
+
var utils_1 = require_utils2();
|
|
5676
7194
|
var validateTableData = (rows) => {
|
|
5677
7195
|
if (!Array.isArray(rows)) {
|
|
5678
7196
|
throw new TypeError("Table data must be an array.");
|
|
@@ -5718,7 +7236,7 @@ var require_table = __commonJS({
|
|
|
5718
7236
|
var padTableData_1 = require_padTableData();
|
|
5719
7237
|
var stringifyTableData_1 = require_stringifyTableData();
|
|
5720
7238
|
var truncateTableData_1 = require_truncateTableData();
|
|
5721
|
-
var utils_1 =
|
|
7239
|
+
var utils_1 = require_utils2();
|
|
5722
7240
|
var validateTableData_1 = require_validateTableData();
|
|
5723
7241
|
var table2 = (data, userConfig = {}) => {
|
|
5724
7242
|
(0, validateTableData_1.validateTableData)(data);
|
|
@@ -5783,6 +7301,7 @@ var require_src = __commonJS({
|
|
|
5783
7301
|
|
|
5784
7302
|
// index.ts
|
|
5785
7303
|
var import_picocolors4 = __toESM(require_picocolors(), 1);
|
|
7304
|
+
import { spawnSync as spawnSync2 } from "child_process";
|
|
5786
7305
|
|
|
5787
7306
|
// commands/new.ts
|
|
5788
7307
|
import { basename as basename3, dirname as dirname3, join as join3 } from "path";
|
|
@@ -6604,7 +8123,8 @@ function loadConfig() {
|
|
|
6604
8123
|
|
|
6605
8124
|
// utils.ts
|
|
6606
8125
|
var import_picocolors = __toESM(require_picocolors(), 1);
|
|
6607
|
-
|
|
8126
|
+
var import_picomatch = __toESM(require_picomatch2(), 1);
|
|
8127
|
+
import { execSync as execSync2, execFileSync, spawnSync } from "child_process";
|
|
6608
8128
|
import { existsSync as existsSync2, readSync, openSync, mkdirSync as mkdirSync2, writeFileSync as writeFileSync2, rmSync, lstatSync, readdirSync, readlinkSync } from "fs";
|
|
6609
8129
|
import { basename as basename2, dirname as dirname2, join as join2 } from "path";
|
|
6610
8130
|
import { tmpdir } from "os";
|
|
@@ -6749,6 +8269,9 @@ function isInsideWorktree() {
|
|
|
6749
8269
|
return false;
|
|
6750
8270
|
}
|
|
6751
8271
|
}
|
|
8272
|
+
function isInsideWorkshell() {
|
|
8273
|
+
return process.env.WK_WORKSHELL === "1";
|
|
8274
|
+
}
|
|
6752
8275
|
function hasUncommittedChanges() {
|
|
6753
8276
|
try {
|
|
6754
8277
|
const status = execSync2("git status --porcelain", { encoding: "utf-8" }).trim();
|
|
@@ -6942,13 +8465,14 @@ end
|
|
|
6942
8465
|
# wk setup script
|
|
6943
8466
|
${setupCommand}
|
|
6944
8467
|
` : "";
|
|
8468
|
+
const workshellEnv = { ...process.env, WK_WORKSHELL: "1" };
|
|
6945
8469
|
if (shell.endsWith("zsh")) {
|
|
6946
8470
|
const tmpDir = join2(tmpdir(), `wk-${process.pid}`);
|
|
6947
8471
|
mkdirSync2(tmpDir, { recursive: true });
|
|
6948
8472
|
try {
|
|
6949
8473
|
writeFileSync2(join2(tmpDir, ".zshrc"), `[[ -f "$HOME/.zshrc" ]] && source "$HOME/.zshrc"
|
|
6950
8474
|
${zshScript}${setupSection}`);
|
|
6951
|
-
spawnSync(shell, ["-l"], { cwd, stdio: "inherit", env: { ...
|
|
8475
|
+
spawnSync(shell, ["-l"], { cwd, stdio: "inherit", env: { ...workshellEnv, ZDOTDIR: tmpDir } });
|
|
6952
8476
|
} finally {
|
|
6953
8477
|
rmSync(tmpDir, { recursive: true, force: true });
|
|
6954
8478
|
}
|
|
@@ -6959,7 +8483,7 @@ ${zshScript}${setupSection}`);
|
|
|
6959
8483
|
const rcFile = join2(tmpDir, ".bashrc");
|
|
6960
8484
|
writeFileSync2(rcFile, `[[ -f "$HOME/.bashrc" ]] && source "$HOME/.bashrc"
|
|
6961
8485
|
${bashScript}${setupSection}`);
|
|
6962
|
-
spawnSync(shell, ["--rcfile", rcFile, "-il"], { cwd, stdio: "inherit" });
|
|
8486
|
+
spawnSync(shell, ["--rcfile", rcFile, "-il"], { cwd, stdio: "inherit", env: workshellEnv });
|
|
6963
8487
|
} finally {
|
|
6964
8488
|
rmSync(tmpDir, { recursive: true, force: true });
|
|
6965
8489
|
}
|
|
@@ -6967,7 +8491,7 @@ ${bashScript}${setupSection}`);
|
|
|
6967
8491
|
const fishInit = setupCommand ? `${fishScript}
|
|
6968
8492
|
# wk setup script
|
|
6969
8493
|
${setupCommand}` : fishScript;
|
|
6970
|
-
spawnSync(shell, ["--init-command", fishInit], { cwd, stdio: "inherit" });
|
|
8494
|
+
spawnSync(shell, ["--init-command", fishInit], { cwd, stdio: "inherit", env: workshellEnv });
|
|
6971
8495
|
} else {
|
|
6972
8496
|
console.error(`Error: Unsupported shell '${shell}'`);
|
|
6973
8497
|
console.error("wk requires bash, zsh, or fish.");
|
|
@@ -6976,6 +8500,47 @@ ${setupCommand}` : fishScript;
|
|
|
6976
8500
|
}
|
|
6977
8501
|
var success = (text) => import_picocolors.default.green(import_picocolors.default.bold("\u2713")) + " " + text;
|
|
6978
8502
|
var warn = (text) => import_picocolors.default.yellow(import_picocolors.default.bold("\u26A0")) + " " + text;
|
|
8503
|
+
function hasBinary(name) {
|
|
8504
|
+
try {
|
|
8505
|
+
execSync2(`command -v ${name}`, { stdio: "ignore" });
|
|
8506
|
+
return true;
|
|
8507
|
+
} catch {
|
|
8508
|
+
return false;
|
|
8509
|
+
}
|
|
8510
|
+
}
|
|
8511
|
+
function detectJsPackageManager(cwd) {
|
|
8512
|
+
if (existsSync2(join2(cwd, "pnpm-lock.yaml")) && hasBinary("pnpm")) return "pnpm";
|
|
8513
|
+
if (existsSync2(join2(cwd, "yarn.lock")) && hasBinary("yarn")) return "yarn";
|
|
8514
|
+
if ((existsSync2(join2(cwd, "bun.lockb")) || existsSync2(join2(cwd, "bun.lock"))) && hasBinary("bun")) return "bun";
|
|
8515
|
+
if (existsSync2(join2(cwd, "package-lock.json")) && hasBinary("npm")) return "npm";
|
|
8516
|
+
return null;
|
|
8517
|
+
}
|
|
8518
|
+
function detectPythonPackageManager(cwd) {
|
|
8519
|
+
if (existsSync2(join2(cwd, "uv.lock")) && hasBinary("uv")) return "uv";
|
|
8520
|
+
if (existsSync2(join2(cwd, "poetry.lock")) && hasBinary("poetry")) return "poetry";
|
|
8521
|
+
if (existsSync2(join2(cwd, "Pipfile.lock")) && hasBinary("pipenv")) return "pipenv";
|
|
8522
|
+
if (existsSync2(join2(cwd, "pdm.lock")) && hasBinary("pdm")) return "pdm";
|
|
8523
|
+
return null;
|
|
8524
|
+
}
|
|
8525
|
+
var installCmds = {
|
|
8526
|
+
npm: "npm install",
|
|
8527
|
+
yarn: "yarn install",
|
|
8528
|
+
pnpm: "pnpm install",
|
|
8529
|
+
bun: "bun install",
|
|
8530
|
+
uv: "uv sync",
|
|
8531
|
+
poetry: "poetry install",
|
|
8532
|
+
pipenv: "pipenv install",
|
|
8533
|
+
pdm: "pdm install"
|
|
8534
|
+
};
|
|
8535
|
+
function runPackageManagerInstall(pm, cwd) {
|
|
8536
|
+
const cmd2 = installCmds[pm];
|
|
8537
|
+
console.log(dim(`Running ${cmd2}...`));
|
|
8538
|
+
try {
|
|
8539
|
+
execSync2(cmd2, { cwd, stdio: "inherit" });
|
|
8540
|
+
} catch {
|
|
8541
|
+
console.error(warn(`${cmd2} failed \u2014 you may need to run it manually`));
|
|
8542
|
+
}
|
|
8543
|
+
}
|
|
6979
8544
|
var fail = (text) => import_picocolors.default.red(import_picocolors.default.bold("\u2717")) + " " + text;
|
|
6980
8545
|
var dim = (text) => import_picocolors.default.dim(text);
|
|
6981
8546
|
var bold = (text) => import_picocolors.default.bold(text);
|
|
@@ -6983,6 +8548,72 @@ var green = (text) => import_picocolors.default.green(text);
|
|
|
6983
8548
|
var cyan = (text) => import_picocolors.default.cyan(text);
|
|
6984
8549
|
var yellow = (text) => import_picocolors.default.yellow(text);
|
|
6985
8550
|
var red = (text) => import_picocolors.default.red(text);
|
|
8551
|
+
function cpCow(src, dest) {
|
|
8552
|
+
try {
|
|
8553
|
+
if (process.platform === "darwin") {
|
|
8554
|
+
execFileSync("cp", ["-RPc", src, dest], { stdio: "ignore" });
|
|
8555
|
+
} else if (process.platform === "linux") {
|
|
8556
|
+
execFileSync("cp", ["-RP", "--reflink=auto", src, dest], { stdio: "ignore" });
|
|
8557
|
+
} else {
|
|
8558
|
+
execFileSync("cp", ["-RP", src, dest], { stdio: "ignore" });
|
|
8559
|
+
}
|
|
8560
|
+
} catch (err) {
|
|
8561
|
+
if (err && typeof err === "object" && "code" in err && err.code === "ENOENT") {
|
|
8562
|
+
return;
|
|
8563
|
+
}
|
|
8564
|
+
if (process.platform === "darwin") {
|
|
8565
|
+
try {
|
|
8566
|
+
execFileSync("cp", ["-RP", src, dest], { stdio: "ignore" });
|
|
8567
|
+
return;
|
|
8568
|
+
} catch {
|
|
8569
|
+
}
|
|
8570
|
+
}
|
|
8571
|
+
console.error(warn(`Failed to copy ${src}: ${err instanceof Error ? err.message : String(err)}`));
|
|
8572
|
+
}
|
|
8573
|
+
}
|
|
8574
|
+
var DEFAULT_COPY_PATTERNS = [
|
|
8575
|
+
".env*",
|
|
8576
|
+
".npmrc*",
|
|
8577
|
+
".yarnrc*",
|
|
8578
|
+
".pnpmfile.*",
|
|
8579
|
+
".pnpmrc*",
|
|
8580
|
+
".tool-versions",
|
|
8581
|
+
".node-version",
|
|
8582
|
+
".nvmrc",
|
|
8583
|
+
".ruby-version",
|
|
8584
|
+
".python-version",
|
|
8585
|
+
".mise*.toml",
|
|
8586
|
+
".dir-locals.el",
|
|
8587
|
+
".editorconfig.local"
|
|
8588
|
+
];
|
|
8589
|
+
function getIgnoredFiles(repoPath) {
|
|
8590
|
+
try {
|
|
8591
|
+
const output = execFileSync(
|
|
8592
|
+
"git",
|
|
8593
|
+
["ls-files", "--others", "--ignored", "--exclude-standard"],
|
|
8594
|
+
{ cwd: repoPath, encoding: "utf-8" }
|
|
8595
|
+
);
|
|
8596
|
+
return output.split("\n").filter((p) => p.length > 0 && !p.startsWith(".git/"));
|
|
8597
|
+
} catch {
|
|
8598
|
+
return [];
|
|
8599
|
+
}
|
|
8600
|
+
}
|
|
8601
|
+
function copyIgnoredFiles(repoPath, worktreePath, patterns) {
|
|
8602
|
+
const raw = patterns ?? DEFAULT_COPY_PATTERNS;
|
|
8603
|
+
if (raw.length === 0) return;
|
|
8604
|
+
const globs = raw.map((p) => p.includes("/") ? p : `**/${p}`);
|
|
8605
|
+
const isMatch = (0, import_picomatch.default)(globs, { dot: true });
|
|
8606
|
+
const allFiles = getIgnoredFiles(repoPath);
|
|
8607
|
+
const items = allFiles.filter((file) => isMatch(file));
|
|
8608
|
+
if (items.length === 0) return;
|
|
8609
|
+
console.log(dim(`Copying config files:`));
|
|
8610
|
+
for (const item of items) {
|
|
8611
|
+
console.log(dim(` ${item}`));
|
|
8612
|
+
const dest = join2(worktreePath, item);
|
|
8613
|
+
mkdirSync2(dirname2(dest), { recursive: true });
|
|
8614
|
+
cpCow(join2(repoPath, item), dest);
|
|
8615
|
+
}
|
|
8616
|
+
}
|
|
6986
8617
|
function autoCleanupWorktree(worktreeId, path, store, saveStore2) {
|
|
6987
8618
|
const branch = getWorktreeBranch(path);
|
|
6988
8619
|
const status = getWorktreeStatus(path);
|
|
@@ -7075,6 +8706,12 @@ function newCommand(branchName, fromBranch) {
|
|
|
7075
8706
|
mkdirSync3(dirname3(worktreePath), { recursive: true });
|
|
7076
8707
|
createWorktree(branch, worktreePath, fromBranch);
|
|
7077
8708
|
initSubmodules(worktreePath);
|
|
8709
|
+
const config = loadConfig();
|
|
8710
|
+
copyIgnoredFiles(mainWorktree, worktreePath, config?.copy);
|
|
8711
|
+
const jsPm = config?.setup ? null : detectJsPackageManager(mainWorktree);
|
|
8712
|
+
const pyPm = config?.setup ? null : detectPythonPackageManager(mainWorktree);
|
|
8713
|
+
if (jsPm) runPackageManagerInstall(jsPm, worktreePath);
|
|
8714
|
+
if (pyPm) runPackageManagerInstall(pyPm, worktreePath);
|
|
7078
8715
|
setWorktreeMeta(store, worktreeId, {
|
|
7079
8716
|
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
7080
8717
|
});
|
|
@@ -7185,6 +8822,12 @@ function openBranch(branch, prNumber) {
|
|
|
7185
8822
|
mkdirSync4(dirname4(worktreePath), { recursive: true });
|
|
7186
8823
|
createWorktreeForExistingBranch(branch, worktreePath);
|
|
7187
8824
|
initSubmodules(worktreePath);
|
|
8825
|
+
const config = loadConfig();
|
|
8826
|
+
copyIgnoredFiles(mainWorktree, worktreePath, config?.copy);
|
|
8827
|
+
const jsPm = config?.setup ? null : detectJsPackageManager(mainWorktree);
|
|
8828
|
+
const pyPm = config?.setup ? null : detectPythonPackageManager(mainWorktree);
|
|
8829
|
+
if (jsPm) runPackageManagerInstall(jsPm, worktreePath);
|
|
8830
|
+
if (pyPm) runPackageManagerInstall(pyPm, worktreePath);
|
|
7188
8831
|
setWorktreeMeta(store, worktreeId, {
|
|
7189
8832
|
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
7190
8833
|
});
|
|
@@ -7211,10 +8854,10 @@ function openBranch(branch, prNumber) {
|
|
|
7211
8854
|
console.log();
|
|
7212
8855
|
}
|
|
7213
8856
|
function openCommand(ref) {
|
|
7214
|
-
if (
|
|
8857
|
+
if (isInsideWorkshell()) {
|
|
7215
8858
|
const currentBranch = getCurrentBranch();
|
|
7216
8859
|
console.log();
|
|
7217
|
-
console.log(warn(`You're inside a
|
|
8860
|
+
console.log(warn(`You're inside a workshell (branch: ${cyan(currentBranch)})`));
|
|
7218
8861
|
console.log(` This will nest subshells (subshell inside subshell).`);
|
|
7219
8862
|
console.log();
|
|
7220
8863
|
if (!confirm("Continue?")) {
|
|
@@ -8316,7 +9959,7 @@ function promptChoice() {
|
|
|
8316
9959
|
}
|
|
8317
9960
|
|
|
8318
9961
|
// index.ts
|
|
8319
|
-
var VERSION = "0.
|
|
9962
|
+
var VERSION = "0.5.0";
|
|
8320
9963
|
function printHelp() {
|
|
8321
9964
|
const dim2 = import_picocolors4.default.dim;
|
|
8322
9965
|
const cyan2 = import_picocolors4.default.cyan;
|
|
@@ -8328,7 +9971,7 @@ ${import_picocolors4.default.bold("Usage:")} ${cyan2("wk")} ${dim2("<command>")}
|
|
|
8328
9971
|
${import_picocolors4.default.bold("Commands:")}
|
|
8329
9972
|
${green2("new")} ${dim2("[branch]")} Create a branch and open it ${dim2("[--from <branch>]")}
|
|
8330
9973
|
${green2("open")} ${dim2("<ref>")} Open a branch or PR in an ephemeral subshell
|
|
8331
|
-
${green2("close")} Exit current
|
|
9974
|
+
${green2("close")} Exit current workshell
|
|
8332
9975
|
${green2("ls")} List open branches
|
|
8333
9976
|
${green2("status")} Show current branch
|
|
8334
9977
|
${green2("rm")} ${dim2("<branch>")} Remove a branch's worktree
|
|
@@ -8459,7 +10102,7 @@ ${import_picocolors4.default.bold("Description:")}
|
|
|
8459
10102
|
function printCloseHelp() {
|
|
8460
10103
|
const dim2 = import_picocolors4.default.dim;
|
|
8461
10104
|
const cyan2 = import_picocolors4.default.cyan;
|
|
8462
|
-
console.log(`${import_picocolors4.default.bold("wk close")} - Exit current
|
|
10105
|
+
console.log(`${import_picocolors4.default.bold("wk close")} - Exit current workshell
|
|
8463
10106
|
|
|
8464
10107
|
${import_picocolors4.default.bold("Usage:")} ${cyan2("wk close")} ${dim2("[options]")}
|
|
8465
10108
|
|
|
@@ -8467,7 +10110,7 @@ ${import_picocolors4.default.bold("Options:")}
|
|
|
8467
10110
|
${cyan2("-f")}, ${cyan2("--force")} Discard uncommitted changes and exit
|
|
8468
10111
|
|
|
8469
10112
|
${import_picocolors4.default.bold("Description:")}
|
|
8470
|
-
Exits the current
|
|
10113
|
+
Exits the current workshell and returns to the parent.
|
|
8471
10114
|
|
|
8472
10115
|
On exit, if the branch is clean:
|
|
8473
10116
|
- Worktree is pruned (branch is kept)
|
|
@@ -8575,7 +10218,18 @@ switch (cmd) {
|
|
|
8575
10218
|
printCloseHelp();
|
|
8576
10219
|
process.exit(0);
|
|
8577
10220
|
}
|
|
8578
|
-
|
|
10221
|
+
if (!isInsideWorkshell() && isInsideWorktree()) {
|
|
10222
|
+
const currentBranch = getCurrentBranch();
|
|
10223
|
+
const mainWorktree = getMainWorktree();
|
|
10224
|
+
const shell = process.env.SHELL || "/bin/bash";
|
|
10225
|
+
console.log();
|
|
10226
|
+
console.log(dim(`You're in a worktree (branch: ${cyan(currentBranch)}) but not a workshell.`));
|
|
10227
|
+
console.log(dim(`Opening repo root in a fresh shell...`));
|
|
10228
|
+
console.log();
|
|
10229
|
+
spawnSync2(shell, [], { cwd: mainWorktree, stdio: "inherit" });
|
|
10230
|
+
process.exit(0);
|
|
10231
|
+
}
|
|
10232
|
+
console.error(fail("'wk close' only works inside a workshell."));
|
|
8579
10233
|
process.exit(1);
|
|
8580
10234
|
break;
|
|
8581
10235
|
case "__preclose":
|