@olegkuibar/plunk 0.2.3 → 0.3.0-canary.0807dec

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.
Files changed (78) hide show
  1. package/dist/add-4LHIITHV.mjs +14 -0
  2. package/dist/chokidar-LVDD2IK4.mjs +4 -0
  3. package/dist/chunk-2VCW5RWI.mjs +3 -0
  4. package/dist/chunk-4QWBGXB5.mjs +15 -0
  5. package/dist/chunk-4TNTNSAB.mjs +4 -0
  6. package/dist/chunk-6YX2BGO2.mjs +3 -0
  7. package/dist/chunk-7JG555TZ.mjs +3 -0
  8. package/dist/chunk-AR7AKSKG.mjs +3 -0
  9. package/dist/chunk-HW7AEGI3.mjs +3 -0
  10. package/dist/chunk-KVVUZ6KL.mjs +4 -0
  11. package/dist/chunk-LI4HG26F.mjs +4 -0
  12. package/dist/chunk-MBKCCWSD.mjs +3 -0
  13. package/dist/chunk-OL7SNXMX.mjs +7 -0
  14. package/dist/chunk-QUI5JAIH.mjs +3 -0
  15. package/dist/chunk-RITKSDMP.mjs +3 -0
  16. package/dist/chunk-UAGG5WMD.mjs +3 -0
  17. package/dist/chunk-UDONDVIM.mjs +7 -0
  18. package/dist/chunk-ZAUWE3N7.mjs +12 -0
  19. package/dist/chunk-ZIXSXQRE.mjs +3 -0
  20. package/dist/chunk-ZJMZKJNW.mjs +3 -0
  21. package/dist/clean-EWBL6FW2.mjs +3 -0
  22. package/dist/cli.mjs +2 -56
  23. package/dist/dev-NCLIWE2E.mjs +3 -0
  24. package/dist/doctor-PXC45S34.mjs +4 -0
  25. package/dist/index.d.ts +19 -2
  26. package/dist/index.mjs +572 -244
  27. package/dist/init-TZ76GAWN.mjs +7 -0
  28. package/dist/list-CCR7QD7N.mjs +5 -0
  29. package/dist/migrate-6RZ3SEU5.mjs +8 -0
  30. package/dist/publish-4TDT6TTS.mjs +3 -0
  31. package/dist/push-M4RSFETI.mjs +3 -0
  32. package/dist/remove-R55FIXPL.mjs +3 -0
  33. package/dist/restore-XBFOHISI.mjs +11 -0
  34. package/dist/status-GCATYK2I.mjs +4 -0
  35. package/dist/tailwind-source-VPNLLSRJ.mjs +5 -0
  36. package/dist/update-6PLGM37S.mjs +3 -0
  37. package/dist/vite-config-ZMDIOTXC.mjs +10 -0
  38. package/dist/vite-plugin.mjs +2 -1
  39. package/dist/workspace-VREEJZ76.mjs +3 -0
  40. package/package.json +2 -8
  41. package/dist/add-5ZRFUL6Z.mjs +0 -258
  42. package/dist/chokidar-XGAEDN45.mjs +0 -1746
  43. package/dist/chunk-34UXZ622.mjs +0 -98
  44. package/dist/chunk-4O2QOKVO.mjs +0 -1958
  45. package/dist/chunk-CSMZ6DZA.mjs +0 -367
  46. package/dist/chunk-CZM4TNAI.mjs +0 -292
  47. package/dist/chunk-EDUXIQ5W.mjs +0 -1729
  48. package/dist/chunk-GAAB2TLH.mjs +0 -160
  49. package/dist/chunk-HKNM3UWU.mjs +0 -496
  50. package/dist/chunk-I6SN7BBN.mjs +0 -1131
  51. package/dist/chunk-KYDBD2KQ.mjs +0 -39
  52. package/dist/chunk-LKQINKH4.mjs +0 -130
  53. package/dist/chunk-PUSXMPOF.mjs +0 -82
  54. package/dist/chunk-S4HJSJ32.mjs +0 -69
  55. package/dist/chunk-W3C72UKC.mjs +0 -113
  56. package/dist/chunk-WSECI6M7.mjs +0 -85
  57. package/dist/chunk-XMIZ7OUZ.mjs +0 -26
  58. package/dist/chunk-XZK5T4GK.mjs +0 -23
  59. package/dist/chunk-ZOYNYK5Y.mjs +0 -23
  60. package/dist/chunk-ZQCGJUBJ.mjs +0 -92
  61. package/dist/clean-LTR5MZTY.mjs +0 -84
  62. package/dist/dev-LFXQP6SA.mjs +0 -194
  63. package/dist/dist-DUFCZSIL.mjs +0 -813
  64. package/dist/doctor-R7ZVR7PY.mjs +0 -230
  65. package/dist/hash-worker.mjs +0 -65
  66. package/dist/init-SWCNRISY.mjs +0 -310
  67. package/dist/list-B77L2F34.mjs +0 -119
  68. package/dist/migrate-X5TIC5SS.mjs +0 -124
  69. package/dist/prompt-HTPH6HQ7.mjs +0 -756
  70. package/dist/publish-UXCLPNM6.mjs +0 -63
  71. package/dist/push-JI6HGCFG.mjs +0 -197
  72. package/dist/remove-DCR7KKD5.mjs +0 -149
  73. package/dist/restore-SUN3WGSW.mjs +0 -124
  74. package/dist/status-MESRBH54.mjs +0 -103
  75. package/dist/tailwind-source-JBBEIXIJ.mjs +0 -89
  76. package/dist/update-SKDSA673.mjs +0 -100
  77. package/dist/vite-config-BAK67JHB.mjs +0 -128
  78. package/dist/workspace-76HJPAK2.mjs +0 -97
@@ -1,1958 +0,0 @@
1
- #!/usr/bin/env node
2
- import{createRequire as __cr}from"node:module";globalThis.require=__cr(import.meta.url);
3
- import {
4
- readMeta
5
- } from "./chunk-W3C72UKC.mjs";
6
- import {
7
- getStoreEntryPath,
8
- withFileLock
9
- } from "./chunk-EDUXIQ5W.mjs";
10
- import {
11
- computeContentHash,
12
- copyWithCoW,
13
- ensureDir,
14
- ensurePrivateDir,
15
- exists,
16
- isNodeError,
17
- moveDir,
18
- pLimit,
19
- removeDir
20
- } from "./chunk-HKNM3UWU.mjs";
21
- import {
22
- consola,
23
- verbose
24
- } from "./chunk-I6SN7BBN.mjs";
25
- import {
26
- __commonJS,
27
- __toESM
28
- } from "./chunk-KYDBD2KQ.mjs";
29
-
30
- // node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/constants.js
31
- var require_constants = __commonJS({
32
- "node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/constants.js"(exports, module) {
33
- "use strict";
34
- var WIN_SLASH = "\\\\/";
35
- var WIN_NO_SLASH = `[^${WIN_SLASH}]`;
36
- var DOT_LITERAL = "\\.";
37
- var PLUS_LITERAL = "\\+";
38
- var QMARK_LITERAL = "\\?";
39
- var SLASH_LITERAL = "\\/";
40
- var ONE_CHAR = "(?=.)";
41
- var QMARK = "[^/]";
42
- var END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
43
- var START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
44
- var DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
45
- var NO_DOT = `(?!${DOT_LITERAL})`;
46
- var NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
47
- var NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
48
- var NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
49
- var QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
50
- var STAR = `${QMARK}*?`;
51
- var SEP = "/";
52
- var POSIX_CHARS = {
53
- DOT_LITERAL,
54
- PLUS_LITERAL,
55
- QMARK_LITERAL,
56
- SLASH_LITERAL,
57
- ONE_CHAR,
58
- QMARK,
59
- END_ANCHOR,
60
- DOTS_SLASH,
61
- NO_DOT,
62
- NO_DOTS,
63
- NO_DOT_SLASH,
64
- NO_DOTS_SLASH,
65
- QMARK_NO_DOT,
66
- STAR,
67
- START_ANCHOR,
68
- SEP
69
- };
70
- var WINDOWS_CHARS = {
71
- ...POSIX_CHARS,
72
- SLASH_LITERAL: `[${WIN_SLASH}]`,
73
- QMARK: WIN_NO_SLASH,
74
- STAR: `${WIN_NO_SLASH}*?`,
75
- DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
76
- NO_DOT: `(?!${DOT_LITERAL})`,
77
- NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
78
- NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
79
- NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
80
- QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
81
- START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
82
- END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
83
- SEP: "\\"
84
- };
85
- var POSIX_REGEX_SOURCE = {
86
- alnum: "a-zA-Z0-9",
87
- alpha: "a-zA-Z",
88
- ascii: "\\x00-\\x7F",
89
- blank: " \\t",
90
- cntrl: "\\x00-\\x1F\\x7F",
91
- digit: "0-9",
92
- graph: "\\x21-\\x7E",
93
- lower: "a-z",
94
- print: "\\x20-\\x7E ",
95
- punct: "\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",
96
- space: " \\t\\r\\n\\v\\f",
97
- upper: "A-Z",
98
- word: "A-Za-z0-9_",
99
- xdigit: "A-Fa-f0-9"
100
- };
101
- module.exports = {
102
- MAX_LENGTH: 1024 * 64,
103
- POSIX_REGEX_SOURCE,
104
- // regular expressions
105
- REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
106
- REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
107
- REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
108
- REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
109
- REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
110
- REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
111
- // Replace globs with equivalent patterns to reduce parsing time.
112
- REPLACEMENTS: {
113
- __proto__: null,
114
- "***": "*",
115
- "**/**": "**",
116
- "**/**/**": "**"
117
- },
118
- // Digits
119
- CHAR_0: 48,
120
- /* 0 */
121
- CHAR_9: 57,
122
- /* 9 */
123
- // Alphabet chars.
124
- CHAR_UPPERCASE_A: 65,
125
- /* A */
126
- CHAR_LOWERCASE_A: 97,
127
- /* a */
128
- CHAR_UPPERCASE_Z: 90,
129
- /* Z */
130
- CHAR_LOWERCASE_Z: 122,
131
- /* z */
132
- CHAR_LEFT_PARENTHESES: 40,
133
- /* ( */
134
- CHAR_RIGHT_PARENTHESES: 41,
135
- /* ) */
136
- CHAR_ASTERISK: 42,
137
- /* * */
138
- // Non-alphabetic chars.
139
- CHAR_AMPERSAND: 38,
140
- /* & */
141
- CHAR_AT: 64,
142
- /* @ */
143
- CHAR_BACKWARD_SLASH: 92,
144
- /* \ */
145
- CHAR_CARRIAGE_RETURN: 13,
146
- /* \r */
147
- CHAR_CIRCUMFLEX_ACCENT: 94,
148
- /* ^ */
149
- CHAR_COLON: 58,
150
- /* : */
151
- CHAR_COMMA: 44,
152
- /* , */
153
- CHAR_DOT: 46,
154
- /* . */
155
- CHAR_DOUBLE_QUOTE: 34,
156
- /* " */
157
- CHAR_EQUAL: 61,
158
- /* = */
159
- CHAR_EXCLAMATION_MARK: 33,
160
- /* ! */
161
- CHAR_FORM_FEED: 12,
162
- /* \f */
163
- CHAR_FORWARD_SLASH: 47,
164
- /* / */
165
- CHAR_GRAVE_ACCENT: 96,
166
- /* ` */
167
- CHAR_HASH: 35,
168
- /* # */
169
- CHAR_HYPHEN_MINUS: 45,
170
- /* - */
171
- CHAR_LEFT_ANGLE_BRACKET: 60,
172
- /* < */
173
- CHAR_LEFT_CURLY_BRACE: 123,
174
- /* { */
175
- CHAR_LEFT_SQUARE_BRACKET: 91,
176
- /* [ */
177
- CHAR_LINE_FEED: 10,
178
- /* \n */
179
- CHAR_NO_BREAK_SPACE: 160,
180
- /* \u00A0 */
181
- CHAR_PERCENT: 37,
182
- /* % */
183
- CHAR_PLUS: 43,
184
- /* + */
185
- CHAR_QUESTION_MARK: 63,
186
- /* ? */
187
- CHAR_RIGHT_ANGLE_BRACKET: 62,
188
- /* > */
189
- CHAR_RIGHT_CURLY_BRACE: 125,
190
- /* } */
191
- CHAR_RIGHT_SQUARE_BRACKET: 93,
192
- /* ] */
193
- CHAR_SEMICOLON: 59,
194
- /* ; */
195
- CHAR_SINGLE_QUOTE: 39,
196
- /* ' */
197
- CHAR_SPACE: 32,
198
- /* */
199
- CHAR_TAB: 9,
200
- /* \t */
201
- CHAR_UNDERSCORE: 95,
202
- /* _ */
203
- CHAR_VERTICAL_LINE: 124,
204
- /* | */
205
- CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
206
- /* \uFEFF */
207
- /**
208
- * Create EXTGLOB_CHARS
209
- */
210
- extglobChars(chars) {
211
- return {
212
- "!": { type: "negate", open: "(?:(?!(?:", close: `))${chars.STAR})` },
213
- "?": { type: "qmark", open: "(?:", close: ")?" },
214
- "+": { type: "plus", open: "(?:", close: ")+" },
215
- "*": { type: "star", open: "(?:", close: ")*" },
216
- "@": { type: "at", open: "(?:", close: ")" }
217
- };
218
- },
219
- /**
220
- * Create GLOB_CHARS
221
- */
222
- globChars(win32) {
223
- return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
224
- }
225
- };
226
- }
227
- });
228
-
229
- // node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/utils.js
230
- var require_utils = __commonJS({
231
- "node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/utils.js"(exports) {
232
- "use strict";
233
- var {
234
- REGEX_BACKSLASH,
235
- REGEX_REMOVE_BACKSLASH,
236
- REGEX_SPECIAL_CHARS,
237
- REGEX_SPECIAL_CHARS_GLOBAL
238
- } = require_constants();
239
- exports.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
240
- exports.hasRegexChars = (str) => REGEX_SPECIAL_CHARS.test(str);
241
- exports.isRegexChar = (str) => str.length === 1 && exports.hasRegexChars(str);
242
- exports.escapeRegex = (str) => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, "\\$1");
243
- exports.toPosixSlashes = (str) => str.replace(REGEX_BACKSLASH, "/");
244
- exports.isWindows = () => {
245
- if (typeof navigator !== "undefined" && navigator.platform) {
246
- const platform2 = navigator.platform.toLowerCase();
247
- return platform2 === "win32" || platform2 === "windows";
248
- }
249
- if (typeof process !== "undefined" && process.platform) {
250
- return process.platform === "win32";
251
- }
252
- return false;
253
- };
254
- exports.removeBackslashes = (str) => {
255
- return str.replace(REGEX_REMOVE_BACKSLASH, (match) => {
256
- return match === "\\" ? "" : match;
257
- });
258
- };
259
- exports.escapeLast = (input, char, lastIdx) => {
260
- const idx = input.lastIndexOf(char, lastIdx);
261
- if (idx === -1) return input;
262
- if (input[idx - 1] === "\\") return exports.escapeLast(input, char, idx - 1);
263
- return `${input.slice(0, idx)}\\${input.slice(idx)}`;
264
- };
265
- exports.removePrefix = (input, state = {}) => {
266
- let output = input;
267
- if (output.startsWith("./")) {
268
- output = output.slice(2);
269
- state.prefix = "./";
270
- }
271
- return output;
272
- };
273
- exports.wrapOutput = (input, state = {}, options = {}) => {
274
- const prepend = options.contains ? "" : "^";
275
- const append = options.contains ? "" : "$";
276
- let output = `${prepend}(?:${input})${append}`;
277
- if (state.negated === true) {
278
- output = `(?:^(?!${output}).*$)`;
279
- }
280
- return output;
281
- };
282
- exports.basename = (path, { windows } = {}) => {
283
- const segs = path.split(windows ? /[\\/]/ : "/");
284
- const last = segs[segs.length - 1];
285
- if (last === "") {
286
- return segs[segs.length - 2];
287
- }
288
- return last;
289
- };
290
- }
291
- });
292
-
293
- // node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/scan.js
294
- var require_scan = __commonJS({
295
- "node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/scan.js"(exports, module) {
296
- "use strict";
297
- var utils = require_utils();
298
- var {
299
- CHAR_ASTERISK,
300
- /* * */
301
- CHAR_AT,
302
- /* @ */
303
- CHAR_BACKWARD_SLASH,
304
- /* \ */
305
- CHAR_COMMA,
306
- /* , */
307
- CHAR_DOT,
308
- /* . */
309
- CHAR_EXCLAMATION_MARK,
310
- /* ! */
311
- CHAR_FORWARD_SLASH,
312
- /* / */
313
- CHAR_LEFT_CURLY_BRACE,
314
- /* { */
315
- CHAR_LEFT_PARENTHESES,
316
- /* ( */
317
- CHAR_LEFT_SQUARE_BRACKET,
318
- /* [ */
319
- CHAR_PLUS,
320
- /* + */
321
- CHAR_QUESTION_MARK,
322
- /* ? */
323
- CHAR_RIGHT_CURLY_BRACE,
324
- /* } */
325
- CHAR_RIGHT_PARENTHESES,
326
- /* ) */
327
- CHAR_RIGHT_SQUARE_BRACKET
328
- /* ] */
329
- } = require_constants();
330
- var isPathSeparator = (code) => {
331
- return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
332
- };
333
- var depth = (token) => {
334
- if (token.isPrefix !== true) {
335
- token.depth = token.isGlobstar ? Infinity : 1;
336
- }
337
- };
338
- var scan = (input, options) => {
339
- const opts = options || {};
340
- const length = input.length - 1;
341
- const scanToEnd = opts.parts === true || opts.scanToEnd === true;
342
- const slashes = [];
343
- const tokens = [];
344
- const parts = [];
345
- let str = input;
346
- let index = -1;
347
- let start = 0;
348
- let lastIndex = 0;
349
- let isBrace = false;
350
- let isBracket = false;
351
- let isGlob = false;
352
- let isExtglob = false;
353
- let isGlobstar = false;
354
- let braceEscaped = false;
355
- let backslashes = false;
356
- let negated = false;
357
- let negatedExtglob = false;
358
- let finished = false;
359
- let braces = 0;
360
- let prev;
361
- let code;
362
- let token = { value: "", depth: 0, isGlob: false };
363
- const eos = () => index >= length;
364
- const peek = () => str.charCodeAt(index + 1);
365
- const advance = () => {
366
- prev = code;
367
- return str.charCodeAt(++index);
368
- };
369
- while (index < length) {
370
- code = advance();
371
- let next;
372
- if (code === CHAR_BACKWARD_SLASH) {
373
- backslashes = token.backslashes = true;
374
- code = advance();
375
- if (code === CHAR_LEFT_CURLY_BRACE) {
376
- braceEscaped = true;
377
- }
378
- continue;
379
- }
380
- if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
381
- braces++;
382
- while (eos() !== true && (code = advance())) {
383
- if (code === CHAR_BACKWARD_SLASH) {
384
- backslashes = token.backslashes = true;
385
- advance();
386
- continue;
387
- }
388
- if (code === CHAR_LEFT_CURLY_BRACE) {
389
- braces++;
390
- continue;
391
- }
392
- if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
393
- isBrace = token.isBrace = true;
394
- isGlob = token.isGlob = true;
395
- finished = true;
396
- if (scanToEnd === true) {
397
- continue;
398
- }
399
- break;
400
- }
401
- if (braceEscaped !== true && code === CHAR_COMMA) {
402
- isBrace = token.isBrace = true;
403
- isGlob = token.isGlob = true;
404
- finished = true;
405
- if (scanToEnd === true) {
406
- continue;
407
- }
408
- break;
409
- }
410
- if (code === CHAR_RIGHT_CURLY_BRACE) {
411
- braces--;
412
- if (braces === 0) {
413
- braceEscaped = false;
414
- isBrace = token.isBrace = true;
415
- finished = true;
416
- break;
417
- }
418
- }
419
- }
420
- if (scanToEnd === true) {
421
- continue;
422
- }
423
- break;
424
- }
425
- if (code === CHAR_FORWARD_SLASH) {
426
- slashes.push(index);
427
- tokens.push(token);
428
- token = { value: "", depth: 0, isGlob: false };
429
- if (finished === true) continue;
430
- if (prev === CHAR_DOT && index === start + 1) {
431
- start += 2;
432
- continue;
433
- }
434
- lastIndex = index + 1;
435
- continue;
436
- }
437
- if (opts.noext !== true) {
438
- const isExtglobChar = code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK;
439
- if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
440
- isGlob = token.isGlob = true;
441
- isExtglob = token.isExtglob = true;
442
- finished = true;
443
- if (code === CHAR_EXCLAMATION_MARK && index === start) {
444
- negatedExtglob = true;
445
- }
446
- if (scanToEnd === true) {
447
- while (eos() !== true && (code = advance())) {
448
- if (code === CHAR_BACKWARD_SLASH) {
449
- backslashes = token.backslashes = true;
450
- code = advance();
451
- continue;
452
- }
453
- if (code === CHAR_RIGHT_PARENTHESES) {
454
- isGlob = token.isGlob = true;
455
- finished = true;
456
- break;
457
- }
458
- }
459
- continue;
460
- }
461
- break;
462
- }
463
- }
464
- if (code === CHAR_ASTERISK) {
465
- if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
466
- isGlob = token.isGlob = true;
467
- finished = true;
468
- if (scanToEnd === true) {
469
- continue;
470
- }
471
- break;
472
- }
473
- if (code === CHAR_QUESTION_MARK) {
474
- isGlob = token.isGlob = true;
475
- finished = true;
476
- if (scanToEnd === true) {
477
- continue;
478
- }
479
- break;
480
- }
481
- if (code === CHAR_LEFT_SQUARE_BRACKET) {
482
- while (eos() !== true && (next = advance())) {
483
- if (next === CHAR_BACKWARD_SLASH) {
484
- backslashes = token.backslashes = true;
485
- advance();
486
- continue;
487
- }
488
- if (next === CHAR_RIGHT_SQUARE_BRACKET) {
489
- isBracket = token.isBracket = true;
490
- isGlob = token.isGlob = true;
491
- finished = true;
492
- break;
493
- }
494
- }
495
- if (scanToEnd === true) {
496
- continue;
497
- }
498
- break;
499
- }
500
- if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
501
- negated = token.negated = true;
502
- start++;
503
- continue;
504
- }
505
- if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
506
- isGlob = token.isGlob = true;
507
- if (scanToEnd === true) {
508
- while (eos() !== true && (code = advance())) {
509
- if (code === CHAR_LEFT_PARENTHESES) {
510
- backslashes = token.backslashes = true;
511
- code = advance();
512
- continue;
513
- }
514
- if (code === CHAR_RIGHT_PARENTHESES) {
515
- finished = true;
516
- break;
517
- }
518
- }
519
- continue;
520
- }
521
- break;
522
- }
523
- if (isGlob === true) {
524
- finished = true;
525
- if (scanToEnd === true) {
526
- continue;
527
- }
528
- break;
529
- }
530
- }
531
- if (opts.noext === true) {
532
- isExtglob = false;
533
- isGlob = false;
534
- }
535
- let base = str;
536
- let prefix = "";
537
- let glob = "";
538
- if (start > 0) {
539
- prefix = str.slice(0, start);
540
- str = str.slice(start);
541
- lastIndex -= start;
542
- }
543
- if (base && isGlob === true && lastIndex > 0) {
544
- base = str.slice(0, lastIndex);
545
- glob = str.slice(lastIndex);
546
- } else if (isGlob === true) {
547
- base = "";
548
- glob = str;
549
- } else {
550
- base = str;
551
- }
552
- if (base && base !== "" && base !== "/" && base !== str) {
553
- if (isPathSeparator(base.charCodeAt(base.length - 1))) {
554
- base = base.slice(0, -1);
555
- }
556
- }
557
- if (opts.unescape === true) {
558
- if (glob) glob = utils.removeBackslashes(glob);
559
- if (base && backslashes === true) {
560
- base = utils.removeBackslashes(base);
561
- }
562
- }
563
- const state = {
564
- prefix,
565
- input,
566
- start,
567
- base,
568
- glob,
569
- isBrace,
570
- isBracket,
571
- isGlob,
572
- isExtglob,
573
- isGlobstar,
574
- negated,
575
- negatedExtglob
576
- };
577
- if (opts.tokens === true) {
578
- state.maxDepth = 0;
579
- if (!isPathSeparator(code)) {
580
- tokens.push(token);
581
- }
582
- state.tokens = tokens;
583
- }
584
- if (opts.parts === true || opts.tokens === true) {
585
- let prevIndex;
586
- for (let idx = 0; idx < slashes.length; idx++) {
587
- const n = prevIndex ? prevIndex + 1 : start;
588
- const i = slashes[idx];
589
- const value = input.slice(n, i);
590
- if (opts.tokens) {
591
- if (idx === 0 && start !== 0) {
592
- tokens[idx].isPrefix = true;
593
- tokens[idx].value = prefix;
594
- } else {
595
- tokens[idx].value = value;
596
- }
597
- depth(tokens[idx]);
598
- state.maxDepth += tokens[idx].depth;
599
- }
600
- if (idx !== 0 || value !== "") {
601
- parts.push(value);
602
- }
603
- prevIndex = i;
604
- }
605
- if (prevIndex && prevIndex + 1 < input.length) {
606
- const value = input.slice(prevIndex + 1);
607
- parts.push(value);
608
- if (opts.tokens) {
609
- tokens[tokens.length - 1].value = value;
610
- depth(tokens[tokens.length - 1]);
611
- state.maxDepth += tokens[tokens.length - 1].depth;
612
- }
613
- }
614
- state.slashes = slashes;
615
- state.parts = parts;
616
- }
617
- return state;
618
- };
619
- module.exports = scan;
620
- }
621
- });
622
-
623
- // node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/parse.js
624
- var require_parse = __commonJS({
625
- "node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/parse.js"(exports, module) {
626
- "use strict";
627
- var constants = require_constants();
628
- var utils = require_utils();
629
- var {
630
- MAX_LENGTH,
631
- POSIX_REGEX_SOURCE,
632
- REGEX_NON_SPECIAL_CHARS,
633
- REGEX_SPECIAL_CHARS_BACKREF,
634
- REPLACEMENTS
635
- } = constants;
636
- var expandRange = (args, options) => {
637
- if (typeof options.expandRange === "function") {
638
- return options.expandRange(...args, options);
639
- }
640
- args.sort();
641
- const value = `[${args.join("-")}]`;
642
- try {
643
- new RegExp(value);
644
- } catch (ex) {
645
- return args.map((v) => utils.escapeRegex(v)).join("..");
646
- }
647
- return value;
648
- };
649
- var syntaxError = (type, char) => {
650
- return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
651
- };
652
- var parse = (input, options) => {
653
- if (typeof input !== "string") {
654
- throw new TypeError("Expected a string");
655
- }
656
- input = REPLACEMENTS[input] || input;
657
- const opts = { ...options };
658
- const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
659
- let len = input.length;
660
- if (len > max) {
661
- throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
662
- }
663
- const bos = { type: "bos", value: "", output: opts.prepend || "" };
664
- const tokens = [bos];
665
- const capture = opts.capture ? "" : "?:";
666
- const PLATFORM_CHARS = constants.globChars(opts.windows);
667
- const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS);
668
- const {
669
- DOT_LITERAL,
670
- PLUS_LITERAL,
671
- SLASH_LITERAL,
672
- ONE_CHAR,
673
- DOTS_SLASH,
674
- NO_DOT,
675
- NO_DOT_SLASH,
676
- NO_DOTS_SLASH,
677
- QMARK,
678
- QMARK_NO_DOT,
679
- STAR,
680
- START_ANCHOR
681
- } = PLATFORM_CHARS;
682
- const globstar = (opts2) => {
683
- return `(${capture}(?:(?!${START_ANCHOR}${opts2.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
684
- };
685
- const nodot = opts.dot ? "" : NO_DOT;
686
- const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
687
- let star = opts.bash === true ? globstar(opts) : STAR;
688
- if (opts.capture) {
689
- star = `(${star})`;
690
- }
691
- if (typeof opts.noext === "boolean") {
692
- opts.noextglob = opts.noext;
693
- }
694
- const state = {
695
- input,
696
- index: -1,
697
- start: 0,
698
- dot: opts.dot === true,
699
- consumed: "",
700
- output: "",
701
- prefix: "",
702
- backtrack: false,
703
- negated: false,
704
- brackets: 0,
705
- braces: 0,
706
- parens: 0,
707
- quotes: 0,
708
- globstar: false,
709
- tokens
710
- };
711
- input = utils.removePrefix(input, state);
712
- len = input.length;
713
- const extglobs = [];
714
- const braces = [];
715
- const stack = [];
716
- let prev = bos;
717
- let value;
718
- const eos = () => state.index === len - 1;
719
- const peek = state.peek = (n = 1) => input[state.index + n];
720
- const advance = state.advance = () => input[++state.index] || "";
721
- const remaining = () => input.slice(state.index + 1);
722
- const consume = (value2 = "", num = 0) => {
723
- state.consumed += value2;
724
- state.index += num;
725
- };
726
- const append = (token) => {
727
- state.output += token.output != null ? token.output : token.value;
728
- consume(token.value);
729
- };
730
- const negate = () => {
731
- let count = 1;
732
- while (peek() === "!" && (peek(2) !== "(" || peek(3) === "?")) {
733
- advance();
734
- state.start++;
735
- count++;
736
- }
737
- if (count % 2 === 0) {
738
- return false;
739
- }
740
- state.negated = true;
741
- state.start++;
742
- return true;
743
- };
744
- const increment = (type) => {
745
- state[type]++;
746
- stack.push(type);
747
- };
748
- const decrement = (type) => {
749
- state[type]--;
750
- stack.pop();
751
- };
752
- const push = (tok) => {
753
- if (prev.type === "globstar") {
754
- const isBrace = state.braces > 0 && (tok.type === "comma" || tok.type === "brace");
755
- const isExtglob = tok.extglob === true || extglobs.length && (tok.type === "pipe" || tok.type === "paren");
756
- if (tok.type !== "slash" && tok.type !== "paren" && !isBrace && !isExtglob) {
757
- state.output = state.output.slice(0, -prev.output.length);
758
- prev.type = "star";
759
- prev.value = "*";
760
- prev.output = star;
761
- state.output += prev.output;
762
- }
763
- }
764
- if (extglobs.length && tok.type !== "paren") {
765
- extglobs[extglobs.length - 1].inner += tok.value;
766
- }
767
- if (tok.value || tok.output) append(tok);
768
- if (prev && prev.type === "text" && tok.type === "text") {
769
- prev.output = (prev.output || prev.value) + tok.value;
770
- prev.value += tok.value;
771
- return;
772
- }
773
- tok.prev = prev;
774
- tokens.push(tok);
775
- prev = tok;
776
- };
777
- const extglobOpen = (type, value2) => {
778
- const token = { ...EXTGLOB_CHARS[value2], conditions: 1, inner: "" };
779
- token.prev = prev;
780
- token.parens = state.parens;
781
- token.output = state.output;
782
- const output = (opts.capture ? "(" : "") + token.open;
783
- increment("parens");
784
- push({ type, value: value2, output: state.output ? "" : ONE_CHAR });
785
- push({ type: "paren", extglob: true, value: advance(), output });
786
- extglobs.push(token);
787
- };
788
- const extglobClose = (token) => {
789
- let output = token.close + (opts.capture ? ")" : "");
790
- let rest;
791
- if (token.type === "negate") {
792
- let extglobStar = star;
793
- if (token.inner && token.inner.length > 1 && token.inner.includes("/")) {
794
- extglobStar = globstar(opts);
795
- }
796
- if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
797
- output = token.close = `)$))${extglobStar}`;
798
- }
799
- if (token.inner.includes("*") && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
800
- const expression = parse(rest, { ...options, fastpaths: false }).output;
801
- output = token.close = `)${expression})${extglobStar})`;
802
- }
803
- if (token.prev.type === "bos") {
804
- state.negatedExtglob = true;
805
- }
806
- }
807
- push({ type: "paren", extglob: true, value, output });
808
- decrement("parens");
809
- };
810
- if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
811
- let backslashes = false;
812
- let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
813
- if (first === "\\") {
814
- backslashes = true;
815
- return m;
816
- }
817
- if (first === "?") {
818
- if (esc) {
819
- return esc + first + (rest ? QMARK.repeat(rest.length) : "");
820
- }
821
- if (index === 0) {
822
- return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : "");
823
- }
824
- return QMARK.repeat(chars.length);
825
- }
826
- if (first === ".") {
827
- return DOT_LITERAL.repeat(chars.length);
828
- }
829
- if (first === "*") {
830
- if (esc) {
831
- return esc + first + (rest ? star : "");
832
- }
833
- return star;
834
- }
835
- return esc ? m : `\\${m}`;
836
- });
837
- if (backslashes === true) {
838
- if (opts.unescape === true) {
839
- output = output.replace(/\\/g, "");
840
- } else {
841
- output = output.replace(/\\+/g, (m) => {
842
- return m.length % 2 === 0 ? "\\\\" : m ? "\\" : "";
843
- });
844
- }
845
- }
846
- if (output === input && opts.contains === true) {
847
- state.output = input;
848
- return state;
849
- }
850
- state.output = utils.wrapOutput(output, state, options);
851
- return state;
852
- }
853
- while (!eos()) {
854
- value = advance();
855
- if (value === "\0") {
856
- continue;
857
- }
858
- if (value === "\\") {
859
- const next = peek();
860
- if (next === "/" && opts.bash !== true) {
861
- continue;
862
- }
863
- if (next === "." || next === ";") {
864
- continue;
865
- }
866
- if (!next) {
867
- value += "\\";
868
- push({ type: "text", value });
869
- continue;
870
- }
871
- const match = /^\\+/.exec(remaining());
872
- let slashes = 0;
873
- if (match && match[0].length > 2) {
874
- slashes = match[0].length;
875
- state.index += slashes;
876
- if (slashes % 2 !== 0) {
877
- value += "\\";
878
- }
879
- }
880
- if (opts.unescape === true) {
881
- value = advance();
882
- } else {
883
- value += advance();
884
- }
885
- if (state.brackets === 0) {
886
- push({ type: "text", value });
887
- continue;
888
- }
889
- }
890
- if (state.brackets > 0 && (value !== "]" || prev.value === "[" || prev.value === "[^")) {
891
- if (opts.posix !== false && value === ":") {
892
- const inner = prev.value.slice(1);
893
- if (inner.includes("[")) {
894
- prev.posix = true;
895
- if (inner.includes(":")) {
896
- const idx = prev.value.lastIndexOf("[");
897
- const pre = prev.value.slice(0, idx);
898
- const rest2 = prev.value.slice(idx + 2);
899
- const posix = POSIX_REGEX_SOURCE[rest2];
900
- if (posix) {
901
- prev.value = pre + posix;
902
- state.backtrack = true;
903
- advance();
904
- if (!bos.output && tokens.indexOf(prev) === 1) {
905
- bos.output = ONE_CHAR;
906
- }
907
- continue;
908
- }
909
- }
910
- }
911
- }
912
- if (value === "[" && peek() !== ":" || value === "-" && peek() === "]") {
913
- value = `\\${value}`;
914
- }
915
- if (value === "]" && (prev.value === "[" || prev.value === "[^")) {
916
- value = `\\${value}`;
917
- }
918
- if (opts.posix === true && value === "!" && prev.value === "[") {
919
- value = "^";
920
- }
921
- prev.value += value;
922
- append({ value });
923
- continue;
924
- }
925
- if (state.quotes === 1 && value !== '"') {
926
- value = utils.escapeRegex(value);
927
- prev.value += value;
928
- append({ value });
929
- continue;
930
- }
931
- if (value === '"') {
932
- state.quotes = state.quotes === 1 ? 0 : 1;
933
- if (opts.keepQuotes === true) {
934
- push({ type: "text", value });
935
- }
936
- continue;
937
- }
938
- if (value === "(") {
939
- increment("parens");
940
- push({ type: "paren", value });
941
- continue;
942
- }
943
- if (value === ")") {
944
- if (state.parens === 0 && opts.strictBrackets === true) {
945
- throw new SyntaxError(syntaxError("opening", "("));
946
- }
947
- const extglob = extglobs[extglobs.length - 1];
948
- if (extglob && state.parens === extglob.parens + 1) {
949
- extglobClose(extglobs.pop());
950
- continue;
951
- }
952
- push({ type: "paren", value, output: state.parens ? ")" : "\\)" });
953
- decrement("parens");
954
- continue;
955
- }
956
- if (value === "[") {
957
- if (opts.nobracket === true || !remaining().includes("]")) {
958
- if (opts.nobracket !== true && opts.strictBrackets === true) {
959
- throw new SyntaxError(syntaxError("closing", "]"));
960
- }
961
- value = `\\${value}`;
962
- } else {
963
- increment("brackets");
964
- }
965
- push({ type: "bracket", value });
966
- continue;
967
- }
968
- if (value === "]") {
969
- if (opts.nobracket === true || prev && prev.type === "bracket" && prev.value.length === 1) {
970
- push({ type: "text", value, output: `\\${value}` });
971
- continue;
972
- }
973
- if (state.brackets === 0) {
974
- if (opts.strictBrackets === true) {
975
- throw new SyntaxError(syntaxError("opening", "["));
976
- }
977
- push({ type: "text", value, output: `\\${value}` });
978
- continue;
979
- }
980
- decrement("brackets");
981
- const prevValue = prev.value.slice(1);
982
- if (prev.posix !== true && prevValue[0] === "^" && !prevValue.includes("/")) {
983
- value = `/${value}`;
984
- }
985
- prev.value += value;
986
- append({ value });
987
- if (opts.literalBrackets === false || utils.hasRegexChars(prevValue)) {
988
- continue;
989
- }
990
- const escaped = utils.escapeRegex(prev.value);
991
- state.output = state.output.slice(0, -prev.value.length);
992
- if (opts.literalBrackets === true) {
993
- state.output += escaped;
994
- prev.value = escaped;
995
- continue;
996
- }
997
- prev.value = `(${capture}${escaped}|${prev.value})`;
998
- state.output += prev.value;
999
- continue;
1000
- }
1001
- if (value === "{" && opts.nobrace !== true) {
1002
- increment("braces");
1003
- const open = {
1004
- type: "brace",
1005
- value,
1006
- output: "(",
1007
- outputIndex: state.output.length,
1008
- tokensIndex: state.tokens.length
1009
- };
1010
- braces.push(open);
1011
- push(open);
1012
- continue;
1013
- }
1014
- if (value === "}") {
1015
- const brace = braces[braces.length - 1];
1016
- if (opts.nobrace === true || !brace) {
1017
- push({ type: "text", value, output: value });
1018
- continue;
1019
- }
1020
- let output = ")";
1021
- if (brace.dots === true) {
1022
- const arr = tokens.slice();
1023
- const range = [];
1024
- for (let i = arr.length - 1; i >= 0; i--) {
1025
- tokens.pop();
1026
- if (arr[i].type === "brace") {
1027
- break;
1028
- }
1029
- if (arr[i].type !== "dots") {
1030
- range.unshift(arr[i].value);
1031
- }
1032
- }
1033
- output = expandRange(range, opts);
1034
- state.backtrack = true;
1035
- }
1036
- if (brace.comma !== true && brace.dots !== true) {
1037
- const out = state.output.slice(0, brace.outputIndex);
1038
- const toks = state.tokens.slice(brace.tokensIndex);
1039
- brace.value = brace.output = "\\{";
1040
- value = output = "\\}";
1041
- state.output = out;
1042
- for (const t of toks) {
1043
- state.output += t.output || t.value;
1044
- }
1045
- }
1046
- push({ type: "brace", value, output });
1047
- decrement("braces");
1048
- braces.pop();
1049
- continue;
1050
- }
1051
- if (value === "|") {
1052
- if (extglobs.length > 0) {
1053
- extglobs[extglobs.length - 1].conditions++;
1054
- }
1055
- push({ type: "text", value });
1056
- continue;
1057
- }
1058
- if (value === ",") {
1059
- let output = value;
1060
- const brace = braces[braces.length - 1];
1061
- if (brace && stack[stack.length - 1] === "braces") {
1062
- brace.comma = true;
1063
- output = "|";
1064
- }
1065
- push({ type: "comma", value, output });
1066
- continue;
1067
- }
1068
- if (value === "/") {
1069
- if (prev.type === "dot" && state.index === state.start + 1) {
1070
- state.start = state.index + 1;
1071
- state.consumed = "";
1072
- state.output = "";
1073
- tokens.pop();
1074
- prev = bos;
1075
- continue;
1076
- }
1077
- push({ type: "slash", value, output: SLASH_LITERAL });
1078
- continue;
1079
- }
1080
- if (value === ".") {
1081
- if (state.braces > 0 && prev.type === "dot") {
1082
- if (prev.value === ".") prev.output = DOT_LITERAL;
1083
- const brace = braces[braces.length - 1];
1084
- prev.type = "dots";
1085
- prev.output += value;
1086
- prev.value += value;
1087
- brace.dots = true;
1088
- continue;
1089
- }
1090
- if (state.braces + state.parens === 0 && prev.type !== "bos" && prev.type !== "slash") {
1091
- push({ type: "text", value, output: DOT_LITERAL });
1092
- continue;
1093
- }
1094
- push({ type: "dot", value, output: DOT_LITERAL });
1095
- continue;
1096
- }
1097
- if (value === "?") {
1098
- const isGroup = prev && prev.value === "(";
1099
- if (!isGroup && opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
1100
- extglobOpen("qmark", value);
1101
- continue;
1102
- }
1103
- if (prev && prev.type === "paren") {
1104
- const next = peek();
1105
- let output = value;
1106
- if (prev.value === "(" && !/[!=<:]/.test(next) || next === "<" && !/<([!=]|\w+>)/.test(remaining())) {
1107
- output = `\\${value}`;
1108
- }
1109
- push({ type: "text", value, output });
1110
- continue;
1111
- }
1112
- if (opts.dot !== true && (prev.type === "slash" || prev.type === "bos")) {
1113
- push({ type: "qmark", value, output: QMARK_NO_DOT });
1114
- continue;
1115
- }
1116
- push({ type: "qmark", value, output: QMARK });
1117
- continue;
1118
- }
1119
- if (value === "!") {
1120
- if (opts.noextglob !== true && peek() === "(") {
1121
- if (peek(2) !== "?" || !/[!=<:]/.test(peek(3))) {
1122
- extglobOpen("negate", value);
1123
- continue;
1124
- }
1125
- }
1126
- if (opts.nonegate !== true && state.index === 0) {
1127
- negate();
1128
- continue;
1129
- }
1130
- }
1131
- if (value === "+") {
1132
- if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
1133
- extglobOpen("plus", value);
1134
- continue;
1135
- }
1136
- if (prev && prev.value === "(" || opts.regex === false) {
1137
- push({ type: "plus", value, output: PLUS_LITERAL });
1138
- continue;
1139
- }
1140
- if (prev && (prev.type === "bracket" || prev.type === "paren" || prev.type === "brace") || state.parens > 0) {
1141
- push({ type: "plus", value });
1142
- continue;
1143
- }
1144
- push({ type: "plus", value: PLUS_LITERAL });
1145
- continue;
1146
- }
1147
- if (value === "@") {
1148
- if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
1149
- push({ type: "at", extglob: true, value, output: "" });
1150
- continue;
1151
- }
1152
- push({ type: "text", value });
1153
- continue;
1154
- }
1155
- if (value !== "*") {
1156
- if (value === "$" || value === "^") {
1157
- value = `\\${value}`;
1158
- }
1159
- const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
1160
- if (match) {
1161
- value += match[0];
1162
- state.index += match[0].length;
1163
- }
1164
- push({ type: "text", value });
1165
- continue;
1166
- }
1167
- if (prev && (prev.type === "globstar" || prev.star === true)) {
1168
- prev.type = "star";
1169
- prev.star = true;
1170
- prev.value += value;
1171
- prev.output = star;
1172
- state.backtrack = true;
1173
- state.globstar = true;
1174
- consume(value);
1175
- continue;
1176
- }
1177
- let rest = remaining();
1178
- if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
1179
- extglobOpen("star", value);
1180
- continue;
1181
- }
1182
- if (prev.type === "star") {
1183
- if (opts.noglobstar === true) {
1184
- consume(value);
1185
- continue;
1186
- }
1187
- const prior = prev.prev;
1188
- const before = prior.prev;
1189
- const isStart = prior.type === "slash" || prior.type === "bos";
1190
- const afterStar = before && (before.type === "star" || before.type === "globstar");
1191
- if (opts.bash === true && (!isStart || rest[0] && rest[0] !== "/")) {
1192
- push({ type: "star", value, output: "" });
1193
- continue;
1194
- }
1195
- const isBrace = state.braces > 0 && (prior.type === "comma" || prior.type === "brace");
1196
- const isExtglob = extglobs.length && (prior.type === "pipe" || prior.type === "paren");
1197
- if (!isStart && prior.type !== "paren" && !isBrace && !isExtglob) {
1198
- push({ type: "star", value, output: "" });
1199
- continue;
1200
- }
1201
- while (rest.slice(0, 3) === "/**") {
1202
- const after = input[state.index + 4];
1203
- if (after && after !== "/") {
1204
- break;
1205
- }
1206
- rest = rest.slice(3);
1207
- consume("/**", 3);
1208
- }
1209
- if (prior.type === "bos" && eos()) {
1210
- prev.type = "globstar";
1211
- prev.value += value;
1212
- prev.output = globstar(opts);
1213
- state.output = prev.output;
1214
- state.globstar = true;
1215
- consume(value);
1216
- continue;
1217
- }
1218
- if (prior.type === "slash" && prior.prev.type !== "bos" && !afterStar && eos()) {
1219
- state.output = state.output.slice(0, -(prior.output + prev.output).length);
1220
- prior.output = `(?:${prior.output}`;
1221
- prev.type = "globstar";
1222
- prev.output = globstar(opts) + (opts.strictSlashes ? ")" : "|$)");
1223
- prev.value += value;
1224
- state.globstar = true;
1225
- state.output += prior.output + prev.output;
1226
- consume(value);
1227
- continue;
1228
- }
1229
- if (prior.type === "slash" && prior.prev.type !== "bos" && rest[0] === "/") {
1230
- const end = rest[1] !== void 0 ? "|$" : "";
1231
- state.output = state.output.slice(0, -(prior.output + prev.output).length);
1232
- prior.output = `(?:${prior.output}`;
1233
- prev.type = "globstar";
1234
- prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
1235
- prev.value += value;
1236
- state.output += prior.output + prev.output;
1237
- state.globstar = true;
1238
- consume(value + advance());
1239
- push({ type: "slash", value: "/", output: "" });
1240
- continue;
1241
- }
1242
- if (prior.type === "bos" && rest[0] === "/") {
1243
- prev.type = "globstar";
1244
- prev.value += value;
1245
- prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
1246
- state.output = prev.output;
1247
- state.globstar = true;
1248
- consume(value + advance());
1249
- push({ type: "slash", value: "/", output: "" });
1250
- continue;
1251
- }
1252
- state.output = state.output.slice(0, -prev.output.length);
1253
- prev.type = "globstar";
1254
- prev.output = globstar(opts);
1255
- prev.value += value;
1256
- state.output += prev.output;
1257
- state.globstar = true;
1258
- consume(value);
1259
- continue;
1260
- }
1261
- const token = { type: "star", value, output: star };
1262
- if (opts.bash === true) {
1263
- token.output = ".*?";
1264
- if (prev.type === "bos" || prev.type === "slash") {
1265
- token.output = nodot + token.output;
1266
- }
1267
- push(token);
1268
- continue;
1269
- }
1270
- if (prev && (prev.type === "bracket" || prev.type === "paren") && opts.regex === true) {
1271
- token.output = value;
1272
- push(token);
1273
- continue;
1274
- }
1275
- if (state.index === state.start || prev.type === "slash" || prev.type === "dot") {
1276
- if (prev.type === "dot") {
1277
- state.output += NO_DOT_SLASH;
1278
- prev.output += NO_DOT_SLASH;
1279
- } else if (opts.dot === true) {
1280
- state.output += NO_DOTS_SLASH;
1281
- prev.output += NO_DOTS_SLASH;
1282
- } else {
1283
- state.output += nodot;
1284
- prev.output += nodot;
1285
- }
1286
- if (peek() !== "*") {
1287
- state.output += ONE_CHAR;
1288
- prev.output += ONE_CHAR;
1289
- }
1290
- }
1291
- push(token);
1292
- }
1293
- while (state.brackets > 0) {
1294
- if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "]"));
1295
- state.output = utils.escapeLast(state.output, "[");
1296
- decrement("brackets");
1297
- }
1298
- while (state.parens > 0) {
1299
- if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", ")"));
1300
- state.output = utils.escapeLast(state.output, "(");
1301
- decrement("parens");
1302
- }
1303
- while (state.braces > 0) {
1304
- if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "}"));
1305
- state.output = utils.escapeLast(state.output, "{");
1306
- decrement("braces");
1307
- }
1308
- if (opts.strictSlashes !== true && (prev.type === "star" || prev.type === "bracket")) {
1309
- push({ type: "maybe_slash", value: "", output: `${SLASH_LITERAL}?` });
1310
- }
1311
- if (state.backtrack === true) {
1312
- state.output = "";
1313
- for (const token of state.tokens) {
1314
- state.output += token.output != null ? token.output : token.value;
1315
- if (token.suffix) {
1316
- state.output += token.suffix;
1317
- }
1318
- }
1319
- }
1320
- return state;
1321
- };
1322
- parse.fastpaths = (input, options) => {
1323
- const opts = { ...options };
1324
- const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
1325
- const len = input.length;
1326
- if (len > max) {
1327
- throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
1328
- }
1329
- input = REPLACEMENTS[input] || input;
1330
- const {
1331
- DOT_LITERAL,
1332
- SLASH_LITERAL,
1333
- ONE_CHAR,
1334
- DOTS_SLASH,
1335
- NO_DOT,
1336
- NO_DOTS,
1337
- NO_DOTS_SLASH,
1338
- STAR,
1339
- START_ANCHOR
1340
- } = constants.globChars(opts.windows);
1341
- const nodot = opts.dot ? NO_DOTS : NO_DOT;
1342
- const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
1343
- const capture = opts.capture ? "" : "?:";
1344
- const state = { negated: false, prefix: "" };
1345
- let star = opts.bash === true ? ".*?" : STAR;
1346
- if (opts.capture) {
1347
- star = `(${star})`;
1348
- }
1349
- const globstar = (opts2) => {
1350
- if (opts2.noglobstar === true) return star;
1351
- return `(${capture}(?:(?!${START_ANCHOR}${opts2.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
1352
- };
1353
- const create = (str) => {
1354
- switch (str) {
1355
- case "*":
1356
- return `${nodot}${ONE_CHAR}${star}`;
1357
- case ".*":
1358
- return `${DOT_LITERAL}${ONE_CHAR}${star}`;
1359
- case "*.*":
1360
- return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
1361
- case "*/*":
1362
- return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
1363
- case "**":
1364
- return nodot + globstar(opts);
1365
- case "**/*":
1366
- return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
1367
- case "**/*.*":
1368
- return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
1369
- case "**/.*":
1370
- return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
1371
- default: {
1372
- const match = /^(.*?)\.(\w+)$/.exec(str);
1373
- if (!match) return;
1374
- const source2 = create(match[1]);
1375
- if (!source2) return;
1376
- return source2 + DOT_LITERAL + match[2];
1377
- }
1378
- }
1379
- };
1380
- const output = utils.removePrefix(input, state);
1381
- let source = create(output);
1382
- if (source && opts.strictSlashes !== true) {
1383
- source += `${SLASH_LITERAL}?`;
1384
- }
1385
- return source;
1386
- };
1387
- module.exports = parse;
1388
- }
1389
- });
1390
-
1391
- // node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/picomatch.js
1392
- var require_picomatch = __commonJS({
1393
- "node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/picomatch.js"(exports, module) {
1394
- "use strict";
1395
- var scan = require_scan();
1396
- var parse = require_parse();
1397
- var utils = require_utils();
1398
- var constants = require_constants();
1399
- var isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
1400
- var picomatch2 = (glob, options, returnState = false) => {
1401
- if (Array.isArray(glob)) {
1402
- const fns = glob.map((input) => picomatch2(input, options, returnState));
1403
- const arrayMatcher = (str) => {
1404
- for (const isMatch of fns) {
1405
- const state2 = isMatch(str);
1406
- if (state2) return state2;
1407
- }
1408
- return false;
1409
- };
1410
- return arrayMatcher;
1411
- }
1412
- const isState = isObject(glob) && glob.tokens && glob.input;
1413
- if (glob === "" || typeof glob !== "string" && !isState) {
1414
- throw new TypeError("Expected pattern to be a non-empty string");
1415
- }
1416
- const opts = options || {};
1417
- const posix = opts.windows;
1418
- const regex = isState ? picomatch2.compileRe(glob, options) : picomatch2.makeRe(glob, options, false, true);
1419
- const state = regex.state;
1420
- delete regex.state;
1421
- let isIgnored = () => false;
1422
- if (opts.ignore) {
1423
- const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
1424
- isIgnored = picomatch2(opts.ignore, ignoreOpts, returnState);
1425
- }
1426
- const matcher = (input, returnObject = false) => {
1427
- const { isMatch, match, output } = picomatch2.test(input, regex, options, { glob, posix });
1428
- const result = { glob, state, regex, posix, input, output, match, isMatch };
1429
- if (typeof opts.onResult === "function") {
1430
- opts.onResult(result);
1431
- }
1432
- if (isMatch === false) {
1433
- result.isMatch = false;
1434
- return returnObject ? result : false;
1435
- }
1436
- if (isIgnored(input)) {
1437
- if (typeof opts.onIgnore === "function") {
1438
- opts.onIgnore(result);
1439
- }
1440
- result.isMatch = false;
1441
- return returnObject ? result : false;
1442
- }
1443
- if (typeof opts.onMatch === "function") {
1444
- opts.onMatch(result);
1445
- }
1446
- return returnObject ? result : true;
1447
- };
1448
- if (returnState) {
1449
- matcher.state = state;
1450
- }
1451
- return matcher;
1452
- };
1453
- picomatch2.test = (input, regex, options, { glob, posix } = {}) => {
1454
- if (typeof input !== "string") {
1455
- throw new TypeError("Expected input to be a string");
1456
- }
1457
- if (input === "") {
1458
- return { isMatch: false, output: "" };
1459
- }
1460
- const opts = options || {};
1461
- const format = opts.format || (posix ? utils.toPosixSlashes : null);
1462
- let match = input === glob;
1463
- let output = match && format ? format(input) : input;
1464
- if (match === false) {
1465
- output = format ? format(input) : input;
1466
- match = output === glob;
1467
- }
1468
- if (match === false || opts.capture === true) {
1469
- if (opts.matchBase === true || opts.basename === true) {
1470
- match = picomatch2.matchBase(input, regex, options, posix);
1471
- } else {
1472
- match = regex.exec(output);
1473
- }
1474
- }
1475
- return { isMatch: Boolean(match), match, output };
1476
- };
1477
- picomatch2.matchBase = (input, glob, options) => {
1478
- const regex = glob instanceof RegExp ? glob : picomatch2.makeRe(glob, options);
1479
- return regex.test(utils.basename(input));
1480
- };
1481
- picomatch2.isMatch = (str, patterns, options) => picomatch2(patterns, options)(str);
1482
- picomatch2.parse = (pattern, options) => {
1483
- if (Array.isArray(pattern)) return pattern.map((p) => picomatch2.parse(p, options));
1484
- return parse(pattern, { ...options, fastpaths: false });
1485
- };
1486
- picomatch2.scan = (input, options) => scan(input, options);
1487
- picomatch2.compileRe = (state, options, returnOutput = false, returnState = false) => {
1488
- if (returnOutput === true) {
1489
- return state.output;
1490
- }
1491
- const opts = options || {};
1492
- const prepend = opts.contains ? "" : "^";
1493
- const append = opts.contains ? "" : "$";
1494
- let source = `${prepend}(?:${state.output})${append}`;
1495
- if (state && state.negated === true) {
1496
- source = `^(?!${source}).*$`;
1497
- }
1498
- const regex = picomatch2.toRegex(source, options);
1499
- if (returnState === true) {
1500
- regex.state = state;
1501
- }
1502
- return regex;
1503
- };
1504
- picomatch2.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
1505
- if (!input || typeof input !== "string") {
1506
- throw new TypeError("Expected a non-empty string");
1507
- }
1508
- let parsed = { negated: false, fastpaths: true };
1509
- if (options.fastpaths !== false && (input[0] === "." || input[0] === "*")) {
1510
- parsed.output = parse.fastpaths(input, options);
1511
- }
1512
- if (!parsed.output) {
1513
- parsed = parse(input, options);
1514
- }
1515
- return picomatch2.compileRe(parsed, options, returnOutput, returnState);
1516
- };
1517
- picomatch2.toRegex = (source, options) => {
1518
- try {
1519
- const opts = options || {};
1520
- return new RegExp(source, opts.flags || (opts.nocase ? "i" : ""));
1521
- } catch (err) {
1522
- if (options && options.debug === true) throw err;
1523
- return /$^/;
1524
- }
1525
- };
1526
- picomatch2.constants = constants;
1527
- module.exports = picomatch2;
1528
- }
1529
- });
1530
-
1531
- // node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/index.js
1532
- var require_picomatch2 = __commonJS({
1533
- "node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/index.js"(exports, module) {
1534
- "use strict";
1535
- var pico = require_picomatch();
1536
- var utils = require_utils();
1537
- function picomatch2(glob, options, returnState = false) {
1538
- if (options && (options.windows === null || options.windows === void 0)) {
1539
- options = { ...options, windows: utils.isWindows() };
1540
- }
1541
- return pico(glob, options, returnState);
1542
- }
1543
- Object.assign(picomatch2, pico);
1544
- module.exports = picomatch2;
1545
- }
1546
- });
1547
-
1548
- // src/core/publisher.ts
1549
- import { readFile as readFile2, writeFile, rename } from "fs/promises";
1550
- import { randomBytes } from "crypto";
1551
- import { join as join2, relative as relative2, dirname } from "path";
1552
- import { spawn } from "child_process";
1553
- import { platform } from "os";
1554
- import { availableParallelism } from "os";
1555
-
1556
- // src/utils/pack-list.ts
1557
- var import_picomatch = __toESM(require_picomatch2(), 1);
1558
- import { readFile, readdir, stat } from "fs/promises";
1559
- import { join, relative, resolve, sep } from "path";
1560
- async function resolvePackFiles(packageDir, pkg) {
1561
- const files = [];
1562
- const absDir = resolve(packageDir);
1563
- files.push(join(absDir, "package.json"));
1564
- const allFiles = await collectAllFiles(absDir);
1565
- const allRelPaths = allFiles.map((f) => relative(absDir, f).replace(/\\/g, "/"));
1566
- if (pkg.files && pkg.files.length > 0) {
1567
- for (const pattern of pkg.files) {
1568
- const target = join(absDir, pattern);
1569
- const resolved = resolve(target);
1570
- if (!resolved.startsWith(absDir + sep) && resolved !== absDir) {
1571
- consola.warn(`files pattern "${pattern}" escapes package directory, skipping`);
1572
- continue;
1573
- }
1574
- let matched = false;
1575
- try {
1576
- const s = await stat(target);
1577
- if (s.isDirectory()) {
1578
- const prefix = relative(absDir, target).replace(/\\/g, "/") + "/";
1579
- for (let i = 0; i < allRelPaths.length; i++) {
1580
- if (allRelPaths[i].startsWith(prefix)) {
1581
- files.push(allFiles[i]);
1582
- }
1583
- }
1584
- matched = true;
1585
- } else {
1586
- files.push(target);
1587
- matched = true;
1588
- }
1589
- } catch (err) {
1590
- if (isNodeError(err) && err.code !== "ENOENT") {
1591
- throw err;
1592
- }
1593
- }
1594
- if (!matched) {
1595
- const isMatch = (0, import_picomatch.default)(pattern, { dot: true });
1596
- let globMatched = 0;
1597
- for (let i = 0; i < allRelPaths.length; i++) {
1598
- if (isMatch(allRelPaths[i])) {
1599
- const absFile = resolve(allFiles[i]);
1600
- if (!absFile.startsWith(absDir + sep) && absFile !== absDir) continue;
1601
- files.push(allFiles[i]);
1602
- globMatched++;
1603
- }
1604
- }
1605
- if (globMatched === 0) {
1606
- consola.warn(`files pattern "${pattern}" matched no files`);
1607
- }
1608
- }
1609
- }
1610
- } else {
1611
- const ignoreMatchers = await loadNpmIgnore(absDir);
1612
- for (let i = 0; i < allRelPaths.length; i++) {
1613
- if (!shouldIgnore(allRelPaths[i], ignoreMatchers)) {
1614
- files.push(allFiles[i]);
1615
- }
1616
- }
1617
- }
1618
- const fileSet = new Set(files);
1619
- for (const name of ["README.md", "README", "LICENSE", "LICENCE", "CHANGELOG.md"]) {
1620
- const p = join(absDir, name);
1621
- if (fileSet.has(p)) continue;
1622
- try {
1623
- await stat(p);
1624
- files.push(p);
1625
- fileSet.add(p);
1626
- } catch (err) {
1627
- if (isNodeError(err) && err.code !== "ENOENT") {
1628
- throw err;
1629
- }
1630
- }
1631
- }
1632
- return [...fileSet];
1633
- }
1634
- var DEFAULT_IGNORES = /* @__PURE__ */ new Set([
1635
- "node_modules",
1636
- ".git",
1637
- ".svn",
1638
- ".hg",
1639
- ".DS_Store",
1640
- ".npmrc",
1641
- ".plunk",
1642
- "test",
1643
- "tests",
1644
- "__tests__",
1645
- ".github",
1646
- ".vscode",
1647
- ".idea",
1648
- "coverage",
1649
- ".nyc_output",
1650
- "tsconfig.json",
1651
- "tsconfig.build.json",
1652
- ".eslintrc",
1653
- ".eslintrc.js",
1654
- ".eslintrc.json",
1655
- ".prettierrc",
1656
- ".prettierrc.js",
1657
- "jest.config.js",
1658
- "jest.config.ts",
1659
- "vitest.config.ts",
1660
- "vitest.config.js"
1661
- ]);
1662
- function shouldIgnore(relPath, matchers) {
1663
- const parts = relPath.split(/[\\/]/);
1664
- for (const part of parts) {
1665
- if (DEFAULT_IGNORES.has(part)) return true;
1666
- if (matchers.literals.has(part)) return true;
1667
- }
1668
- if (matchers.literals.has(relPath)) return true;
1669
- for (const isMatch of matchers.patterns) {
1670
- if (isMatch(relPath)) return true;
1671
- }
1672
- for (const isMatch of matchers.negations) {
1673
- if (isMatch(relPath)) return false;
1674
- }
1675
- return false;
1676
- }
1677
- async function loadNpmIgnore(dir) {
1678
- const matchers = { literals: /* @__PURE__ */ new Set(), patterns: [], negations: [] };
1679
- try {
1680
- const content = await readFile(join(dir, ".npmignore"), "utf-8");
1681
- for (const line of content.split("\n")) {
1682
- const trimmed = line.trim();
1683
- if (!trimmed || trimmed.startsWith("#")) continue;
1684
- if (trimmed.startsWith("!")) {
1685
- const pat = trimmed.slice(1);
1686
- if (hasGlobChars(pat)) {
1687
- matchers.negations.push((0, import_picomatch.default)(pat, { dot: true }));
1688
- } else {
1689
- matchers.negations.push((0, import_picomatch.default)(pat, { dot: true }));
1690
- }
1691
- } else if (hasGlobChars(trimmed)) {
1692
- matchers.patterns.push((0, import_picomatch.default)(trimmed, { dot: true }));
1693
- } else {
1694
- matchers.literals.add(trimmed.replace(/\/$/, ""));
1695
- }
1696
- }
1697
- } catch (err) {
1698
- if (isNodeError(err) && err.code !== "ENOENT") {
1699
- throw err;
1700
- }
1701
- }
1702
- return matchers;
1703
- }
1704
- function hasGlobChars(pattern) {
1705
- return /[*?[\]{}()]/.test(pattern);
1706
- }
1707
- async function collectAllFiles(dir) {
1708
- const results = [];
1709
- try {
1710
- const entries = await readdir(dir, { withFileTypes: true });
1711
- for (const entry of entries) {
1712
- const full = join(dir, entry.name);
1713
- if (entry.isDirectory()) {
1714
- if (entry.name === "node_modules" || entry.name === ".git") continue;
1715
- if (entry.isSymbolicLink()) continue;
1716
- results.push(...await collectAllFiles(full));
1717
- } else if (!entry.isSymbolicLink()) {
1718
- results.push(full);
1719
- }
1720
- }
1721
- } catch (err) {
1722
- if (isNodeError(err) && err.code === "ENOENT") {
1723
- return [];
1724
- }
1725
- throw err;
1726
- }
1727
- return results;
1728
- }
1729
-
1730
- // src/core/publisher.ts
1731
- var copyLimit = pLimit(Math.max(availableParallelism(), 8));
1732
- async function publish(packageDir, options = {}) {
1733
- const pkgPath = join2(packageDir, "package.json");
1734
- let pkgContent;
1735
- try {
1736
- pkgContent = await readFile2(pkgPath, "utf-8");
1737
- } catch {
1738
- throw new Error(`No package.json found in ${packageDir}`);
1739
- }
1740
- const pkg = JSON.parse(pkgContent);
1741
- if (!pkg.name) throw new Error("package.json missing 'name' field");
1742
- if (!pkg.version) throw new Error("package.json missing 'version' field");
1743
- if (pkg.private && !options.allowPrivate) {
1744
- throw new Error(
1745
- `Package "${pkg.name}" is private. Use --private flag to publish private packages.`
1746
- );
1747
- }
1748
- await runLifecycleHook(packageDir, pkg, "preplunk");
1749
- const files = await resolvePackFiles(packageDir, pkg);
1750
- if (files.length === 0) {
1751
- throw new Error("No publishable files found");
1752
- }
1753
- verbose(`[publish] Resolved ${files.length} files for ${pkg.name}@${pkg.version}`);
1754
- const contentHash = await computeContentHash(files, packageDir);
1755
- await preloadCatalogs(pkg, packageDir);
1756
- const existingMeta = await readMeta(pkg.name, pkg.version);
1757
- if (existingMeta && existingMeta.contentHash === contentHash) {
1758
- consola.info(`${pkg.name}@${pkg.version} already up to date`);
1759
- return {
1760
- name: pkg.name,
1761
- version: pkg.version,
1762
- fileCount: files.length,
1763
- skipped: true,
1764
- contentHash,
1765
- buildId: existingMeta.buildId ?? ""
1766
- };
1767
- }
1768
- const storeEntryDir = getStoreEntryPath(pkg.name, pkg.version);
1769
- const result = await withFileLock(
1770
- storeEntryDir + ".lock",
1771
- async () => {
1772
- const metaUnderLock = await readMeta(pkg.name, pkg.version);
1773
- if (metaUnderLock && metaUnderLock.contentHash === contentHash) {
1774
- consola.info(`${pkg.name}@${pkg.version} already up to date`);
1775
- return {
1776
- name: pkg.name,
1777
- version: pkg.version,
1778
- fileCount: files.length,
1779
- skipped: true,
1780
- contentHash,
1781
- buildId: metaUnderLock.buildId ?? ""
1782
- };
1783
- }
1784
- const tmpDir = storeEntryDir + ".tmp-" + Date.now();
1785
- const tmpPackageDir = join2(tmpDir, "package");
1786
- const buildId = randomBytes(4).toString("hex");
1787
- try {
1788
- await ensurePrivateDir(tmpPackageDir);
1789
- const processedPkg = rewriteProtocolVersions(pkg, packageDir);
1790
- verbose(`[publish] Copying files to temp store...`);
1791
- const uniqueDirs = new Set(
1792
- files.map((file) => dirname(join2(tmpPackageDir, relative2(packageDir, file))))
1793
- );
1794
- await Promise.all([...uniqueDirs].map((d) => ensureDir(d)));
1795
- await Promise.all(
1796
- files.map(
1797
- (file) => copyLimit(async () => {
1798
- const rel = relative2(packageDir, file);
1799
- const dest = join2(tmpPackageDir, rel);
1800
- if (rel === "package.json" && processedPkg !== pkg) {
1801
- await writeFile(dest, JSON.stringify(processedPkg, null, 2));
1802
- } else {
1803
- await copyWithCoW(file, dest);
1804
- }
1805
- })
1806
- )
1807
- );
1808
- const meta = {
1809
- contentHash,
1810
- publishedAt: (/* @__PURE__ */ new Date()).toISOString(),
1811
- sourcePath: packageDir,
1812
- buildId
1813
- };
1814
- await writeFile(
1815
- join2(tmpDir, ".plunk-meta.json"),
1816
- JSON.stringify(meta, null, 2)
1817
- );
1818
- const hadOld = await exists(storeEntryDir);
1819
- const oldDir = storeEntryDir + ".old-" + Date.now();
1820
- if (hadOld) await rename(storeEntryDir, oldDir);
1821
- await moveDir(tmpDir, storeEntryDir);
1822
- if (hadOld) await removeDir(oldDir);
1823
- verbose(`[publish] Stored at ${storeEntryDir}`);
1824
- } catch (err) {
1825
- await removeDir(tmpDir);
1826
- throw err;
1827
- }
1828
- return {
1829
- name: pkg.name,
1830
- version: pkg.version,
1831
- fileCount: files.length,
1832
- skipped: false,
1833
- contentHash,
1834
- buildId
1835
- };
1836
- },
1837
- { stale: 6e4 }
1838
- );
1839
- if (result.skipped) return result;
1840
- await runLifecycleHook(packageDir, pkg, "postplunk");
1841
- consola.success(
1842
- `Published ${pkg.name}@${pkg.version} (${files.length} files) [${result.buildId}]`
1843
- );
1844
- return result;
1845
- }
1846
- var HOOK_TIMEOUT = parseInt(process.env.PLUNK_HOOK_TIMEOUT ?? "30000", 10);
1847
- async function runLifecycleHook(packageDir, pkg, hookName) {
1848
- const script = pkg.scripts?.[hookName];
1849
- if (!script) return;
1850
- verbose(`[lifecycle] Running ${hookName}: ${script}`);
1851
- return new Promise((resolve2, reject) => {
1852
- const isWin = platform() === "win32";
1853
- const shell = isWin ? "cmd" : "sh";
1854
- const shellFlag = isWin ? "/c" : "-c";
1855
- const child = spawn(shell, [shellFlag, script], {
1856
- cwd: packageDir,
1857
- stdio: "inherit"
1858
- });
1859
- const timer = setTimeout(() => {
1860
- child.kill("SIGTERM");
1861
- reject(new Error(`${hookName} script timed out after ${HOOK_TIMEOUT}ms`));
1862
- }, HOOK_TIMEOUT);
1863
- child.on("close", (code) => {
1864
- clearTimeout(timer);
1865
- if (code === 0) {
1866
- resolve2();
1867
- } else {
1868
- reject(new Error(`${hookName} script failed with exit code ${code}`));
1869
- }
1870
- });
1871
- child.on("error", (err) => {
1872
- clearTimeout(timer);
1873
- reject(new Error(`${hookName} script error: ${err.message}`));
1874
- });
1875
- });
1876
- }
1877
- function rewriteProtocolVersions(pkg, packageDir) {
1878
- let changed = false;
1879
- const result = { ...pkg };
1880
- let catalogs = null;
1881
- let catalogsLoaded = false;
1882
- for (const depField of [
1883
- "dependencies",
1884
- "devDependencies",
1885
- "peerDependencies"
1886
- ]) {
1887
- const deps = pkg[depField];
1888
- if (!deps) continue;
1889
- let fieldChanged = false;
1890
- const newDeps = { ...deps };
1891
- for (const [name, version] of Object.entries(deps)) {
1892
- if (version.startsWith("workspace:")) {
1893
- const versionPart = version.slice("workspace:".length);
1894
- if (versionPart === "*" || versionPart === "^" || versionPart === "~") {
1895
- newDeps[name] = versionPart === "*" ? pkg.version : versionPart + pkg.version;
1896
- } else {
1897
- newDeps[name] = versionPart;
1898
- }
1899
- fieldChanged = true;
1900
- changed = true;
1901
- } else if (version.startsWith("catalog:")) {
1902
- if (!catalogsLoaded) {
1903
- catalogs = loadCatalogsSync(packageDir);
1904
- catalogsLoaded = true;
1905
- }
1906
- if (catalogs) {
1907
- const resolved = resolveCatalogVersion(version, name, catalogs);
1908
- if (resolved) {
1909
- newDeps[name] = resolved;
1910
- fieldChanged = true;
1911
- changed = true;
1912
- } else {
1913
- verbose(`[publish] catalog: specifier for "${name}" not found, leaving as-is`);
1914
- }
1915
- } else {
1916
- verbose(`[publish] No pnpm-workspace.yaml found, cannot resolve catalog: for "${name}"`);
1917
- }
1918
- }
1919
- }
1920
- if (fieldChanged) {
1921
- result[depField] = newDeps;
1922
- }
1923
- }
1924
- return changed ? result : pkg;
1925
- }
1926
- function resolveCatalogVersion(specifier, depName, catalogs) {
1927
- const catalogRef = specifier.slice("catalog:".length);
1928
- if (catalogRef === "" || catalogRef === "default") {
1929
- return catalogs.default[depName] ?? null;
1930
- }
1931
- return catalogs.named[catalogRef]?.[depName] ?? null;
1932
- }
1933
- var _cachedCatalogs = null;
1934
- function loadCatalogsSync(packageDir) {
1935
- return _cachedCatalogs?.catalogs ?? null;
1936
- }
1937
- async function preloadCatalogs(pkg, packageDir) {
1938
- const hasCatalog = ["dependencies", "devDependencies", "peerDependencies"].some(
1939
- (field) => {
1940
- const deps = pkg[field];
1941
- return deps && Object.values(deps).some((v) => v.startsWith("catalog:"));
1942
- }
1943
- );
1944
- if (!hasCatalog) return;
1945
- const { findWorkspaceRoot, parseCatalogs } = await import("./workspace-76HJPAK2.mjs");
1946
- const root = await findWorkspaceRoot(packageDir);
1947
- if (!root) {
1948
- _cachedCatalogs = null;
1949
- return;
1950
- }
1951
- if (_cachedCatalogs?.root === root) return;
1952
- const catalogs = await parseCatalogs(root);
1953
- _cachedCatalogs = { root, catalogs };
1954
- }
1955
-
1956
- export {
1957
- publish
1958
- };