prettier 3.1.0 → 3.2.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/internal/cli.mjs CHANGED
@@ -55,372 +55,6 @@ var __privateSet = (obj, member, value, setter) => {
55
55
  setter ? setter.call(obj, value) : member.set(obj, value);
56
56
  return value;
57
57
  };
58
- var __privateWrapper = (obj, member, setter, getter) => ({
59
- set _(value) {
60
- __privateSet(obj, member, value, setter);
61
- },
62
- get _() {
63
- return __privateGet(obj, member, getter);
64
- }
65
- });
66
-
67
- // node_modules/clone/clone.js
68
- var require_clone = __commonJS({
69
- "node_modules/clone/clone.js"(exports, module) {
70
- var clone = function() {
71
- "use strict";
72
- function clone2(parent, circular, depth, prototype) {
73
- var filter;
74
- if (typeof circular === "object") {
75
- depth = circular.depth;
76
- prototype = circular.prototype;
77
- filter = circular.filter;
78
- circular = circular.circular;
79
- }
80
- var allParents = [];
81
- var allChildren = [];
82
- var useBuffer = typeof Buffer != "undefined";
83
- if (typeof circular == "undefined")
84
- circular = true;
85
- if (typeof depth == "undefined")
86
- depth = Infinity;
87
- function _clone(parent2, depth2) {
88
- if (parent2 === null)
89
- return null;
90
- if (depth2 == 0)
91
- return parent2;
92
- var child;
93
- var proto2;
94
- if (typeof parent2 != "object") {
95
- return parent2;
96
- }
97
- if (clone2.__isArray(parent2)) {
98
- child = [];
99
- } else if (clone2.__isRegExp(parent2)) {
100
- child = new RegExp(parent2.source, __getRegExpFlags(parent2));
101
- if (parent2.lastIndex)
102
- child.lastIndex = parent2.lastIndex;
103
- } else if (clone2.__isDate(parent2)) {
104
- child = new Date(parent2.getTime());
105
- } else if (useBuffer && Buffer.isBuffer(parent2)) {
106
- if (Buffer.allocUnsafe) {
107
- child = Buffer.allocUnsafe(parent2.length);
108
- } else {
109
- child = new Buffer(parent2.length);
110
- }
111
- parent2.copy(child);
112
- return child;
113
- } else {
114
- if (typeof prototype == "undefined") {
115
- proto2 = Object.getPrototypeOf(parent2);
116
- child = Object.create(proto2);
117
- } else {
118
- child = Object.create(prototype);
119
- proto2 = prototype;
120
- }
121
- }
122
- if (circular) {
123
- var index = allParents.indexOf(parent2);
124
- if (index != -1) {
125
- return allChildren[index];
126
- }
127
- allParents.push(parent2);
128
- allChildren.push(child);
129
- }
130
- for (var i in parent2) {
131
- var attrs;
132
- if (proto2) {
133
- attrs = Object.getOwnPropertyDescriptor(proto2, i);
134
- }
135
- if (attrs && attrs.set == null) {
136
- continue;
137
- }
138
- child[i] = _clone(parent2[i], depth2 - 1);
139
- }
140
- return child;
141
- }
142
- return _clone(parent, depth);
143
- }
144
- clone2.clonePrototype = function clonePrototype(parent) {
145
- if (parent === null)
146
- return null;
147
- var c = function() {
148
- };
149
- c.prototype = parent;
150
- return new c();
151
- };
152
- function __objToStr(o) {
153
- return Object.prototype.toString.call(o);
154
- }
155
- ;
156
- clone2.__objToStr = __objToStr;
157
- function __isDate(o) {
158
- return typeof o === "object" && __objToStr(o) === "[object Date]";
159
- }
160
- ;
161
- clone2.__isDate = __isDate;
162
- function __isArray(o) {
163
- return typeof o === "object" && __objToStr(o) === "[object Array]";
164
- }
165
- ;
166
- clone2.__isArray = __isArray;
167
- function __isRegExp(o) {
168
- return typeof o === "object" && __objToStr(o) === "[object RegExp]";
169
- }
170
- ;
171
- clone2.__isRegExp = __isRegExp;
172
- function __getRegExpFlags(re) {
173
- var flags = "";
174
- if (re.global)
175
- flags += "g";
176
- if (re.ignoreCase)
177
- flags += "i";
178
- if (re.multiline)
179
- flags += "m";
180
- return flags;
181
- }
182
- ;
183
- clone2.__getRegExpFlags = __getRegExpFlags;
184
- return clone2;
185
- }();
186
- if (typeof module === "object" && module.exports) {
187
- module.exports = clone;
188
- }
189
- }
190
- });
191
-
192
- // node_modules/defaults/index.js
193
- var require_defaults = __commonJS({
194
- "node_modules/defaults/index.js"(exports, module) {
195
- var clone = require_clone();
196
- module.exports = function(options, defaults) {
197
- options = options || {};
198
- Object.keys(defaults).forEach(function(key) {
199
- if (typeof options[key] === "undefined") {
200
- options[key] = clone(defaults[key]);
201
- }
202
- });
203
- return options;
204
- };
205
- }
206
- });
207
-
208
- // node_modules/wcwidth/combining.js
209
- var require_combining = __commonJS({
210
- "node_modules/wcwidth/combining.js"(exports, module) {
211
- module.exports = [
212
- [768, 879],
213
- [1155, 1158],
214
- [1160, 1161],
215
- [1425, 1469],
216
- [1471, 1471],
217
- [1473, 1474],
218
- [1476, 1477],
219
- [1479, 1479],
220
- [1536, 1539],
221
- [1552, 1557],
222
- [1611, 1630],
223
- [1648, 1648],
224
- [1750, 1764],
225
- [1767, 1768],
226
- [1770, 1773],
227
- [1807, 1807],
228
- [1809, 1809],
229
- [1840, 1866],
230
- [1958, 1968],
231
- [2027, 2035],
232
- [2305, 2306],
233
- [2364, 2364],
234
- [2369, 2376],
235
- [2381, 2381],
236
- [2385, 2388],
237
- [2402, 2403],
238
- [2433, 2433],
239
- [2492, 2492],
240
- [2497, 2500],
241
- [2509, 2509],
242
- [2530, 2531],
243
- [2561, 2562],
244
- [2620, 2620],
245
- [2625, 2626],
246
- [2631, 2632],
247
- [2635, 2637],
248
- [2672, 2673],
249
- [2689, 2690],
250
- [2748, 2748],
251
- [2753, 2757],
252
- [2759, 2760],
253
- [2765, 2765],
254
- [2786, 2787],
255
- [2817, 2817],
256
- [2876, 2876],
257
- [2879, 2879],
258
- [2881, 2883],
259
- [2893, 2893],
260
- [2902, 2902],
261
- [2946, 2946],
262
- [3008, 3008],
263
- [3021, 3021],
264
- [3134, 3136],
265
- [3142, 3144],
266
- [3146, 3149],
267
- [3157, 3158],
268
- [3260, 3260],
269
- [3263, 3263],
270
- [3270, 3270],
271
- [3276, 3277],
272
- [3298, 3299],
273
- [3393, 3395],
274
- [3405, 3405],
275
- [3530, 3530],
276
- [3538, 3540],
277
- [3542, 3542],
278
- [3633, 3633],
279
- [3636, 3642],
280
- [3655, 3662],
281
- [3761, 3761],
282
- [3764, 3769],
283
- [3771, 3772],
284
- [3784, 3789],
285
- [3864, 3865],
286
- [3893, 3893],
287
- [3895, 3895],
288
- [3897, 3897],
289
- [3953, 3966],
290
- [3968, 3972],
291
- [3974, 3975],
292
- [3984, 3991],
293
- [3993, 4028],
294
- [4038, 4038],
295
- [4141, 4144],
296
- [4146, 4146],
297
- [4150, 4151],
298
- [4153, 4153],
299
- [4184, 4185],
300
- [4448, 4607],
301
- [4959, 4959],
302
- [5906, 5908],
303
- [5938, 5940],
304
- [5970, 5971],
305
- [6002, 6003],
306
- [6068, 6069],
307
- [6071, 6077],
308
- [6086, 6086],
309
- [6089, 6099],
310
- [6109, 6109],
311
- [6155, 6157],
312
- [6313, 6313],
313
- [6432, 6434],
314
- [6439, 6440],
315
- [6450, 6450],
316
- [6457, 6459],
317
- [6679, 6680],
318
- [6912, 6915],
319
- [6964, 6964],
320
- [6966, 6970],
321
- [6972, 6972],
322
- [6978, 6978],
323
- [7019, 7027],
324
- [7616, 7626],
325
- [7678, 7679],
326
- [8203, 8207],
327
- [8234, 8238],
328
- [8288, 8291],
329
- [8298, 8303],
330
- [8400, 8431],
331
- [12330, 12335],
332
- [12441, 12442],
333
- [43014, 43014],
334
- [43019, 43019],
335
- [43045, 43046],
336
- [64286, 64286],
337
- [65024, 65039],
338
- [65056, 65059],
339
- [65279, 65279],
340
- [65529, 65531],
341
- [68097, 68099],
342
- [68101, 68102],
343
- [68108, 68111],
344
- [68152, 68154],
345
- [68159, 68159],
346
- [119143, 119145],
347
- [119155, 119170],
348
- [119173, 119179],
349
- [119210, 119213],
350
- [119362, 119364],
351
- [917505, 917505],
352
- [917536, 917631],
353
- [917760, 917999]
354
- ];
355
- }
356
- });
357
-
358
- // node_modules/wcwidth/index.js
359
- var require_wcwidth = __commonJS({
360
- "node_modules/wcwidth/index.js"(exports, module) {
361
- "use strict";
362
- var defaults = require_defaults();
363
- var combining = require_combining();
364
- var DEFAULTS = {
365
- nul: 0,
366
- control: 0
367
- };
368
- module.exports = function wcwidth3(str) {
369
- return wcswidth(str, DEFAULTS);
370
- };
371
- module.exports.config = function(opts) {
372
- opts = defaults(opts || {}, DEFAULTS);
373
- return function wcwidth3(str) {
374
- return wcswidth(str, opts);
375
- };
376
- };
377
- function wcswidth(str, opts) {
378
- if (typeof str !== "string")
379
- return wcwidth2(str, opts);
380
- var s = 0;
381
- for (var i = 0; i < str.length; i++) {
382
- var n = wcwidth2(str.charCodeAt(i), opts);
383
- if (n < 0)
384
- return -1;
385
- s += n;
386
- }
387
- return s;
388
- }
389
- function wcwidth2(ucs, opts) {
390
- if (ucs === 0)
391
- return opts.nul;
392
- if (ucs < 32 || ucs >= 127 && ucs < 160)
393
- return opts.control;
394
- if (bisearch(ucs))
395
- return 0;
396
- return 1 + (ucs >= 4352 && (ucs <= 4447 || // Hangul Jamo init. consonants
397
- ucs == 9001 || ucs == 9002 || ucs >= 11904 && ucs <= 42191 && ucs != 12351 || // CJK ... Yi
398
- ucs >= 44032 && ucs <= 55203 || // Hangul Syllables
399
- ucs >= 63744 && ucs <= 64255 || // CJK Compatibility Ideographs
400
- ucs >= 65040 && ucs <= 65049 || // Vertical forms
401
- ucs >= 65072 && ucs <= 65135 || // CJK Compatibility Forms
402
- ucs >= 65280 && ucs <= 65376 || // Fullwidth Forms
403
- ucs >= 65504 && ucs <= 65510 || ucs >= 131072 && ucs <= 196605 || ucs >= 196608 && ucs <= 262141));
404
- }
405
- function bisearch(ucs) {
406
- var min = 0;
407
- var max = combining.length - 1;
408
- var mid;
409
- if (ucs < combining[0][0] || ucs > combining[max][1])
410
- return false;
411
- while (max >= min) {
412
- mid = Math.floor((min + max) / 2);
413
- if (ucs > combining[mid][1])
414
- min = mid + 1;
415
- else if (ucs < combining[mid][0])
416
- max = mid - 1;
417
- else
418
- return true;
419
- }
420
- return false;
421
- }
422
- }
423
- });
424
58
 
425
59
  // node_modules/dashify/index.js
426
60
  var require_dashify = __commonJS({
@@ -656,27 +290,93 @@ var require_minimist = __commonJS({
656
290
  }
657
291
  });
658
292
 
659
- // node_modules/diff/lib/diff/base.js
660
- var require_base = __commonJS({
661
- "node_modules/diff/lib/diff/base.js"(exports) {
293
+ // node_modules/fast-json-stable-stringify/index.js
294
+ var require_fast_json_stable_stringify = __commonJS({
295
+ "node_modules/fast-json-stable-stringify/index.js"(exports, module) {
662
296
  "use strict";
663
- Object.defineProperty(exports, "__esModule", {
664
- value: true
665
- });
666
- exports["default"] = Diff;
667
- function Diff() {
668
- }
669
- Diff.prototype = {
670
- /*istanbul ignore start*/
671
- /*istanbul ignore end*/
672
- diff: function diff2(oldString, newString) {
673
- var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
674
- var callback = options.callback;
675
- if (typeof options === "function") {
676
- callback = options;
677
- options = {};
678
- }
679
- this.options = options;
297
+ module.exports = function(data, opts) {
298
+ if (!opts)
299
+ opts = {};
300
+ if (typeof opts === "function")
301
+ opts = { cmp: opts };
302
+ var cycles = typeof opts.cycles === "boolean" ? opts.cycles : false;
303
+ var cmp = opts.cmp && /* @__PURE__ */ function(f) {
304
+ return function(node) {
305
+ return function(a, b) {
306
+ var aobj = { key: a, value: node[a] };
307
+ var bobj = { key: b, value: node[b] };
308
+ return f(aobj, bobj);
309
+ };
310
+ };
311
+ }(opts.cmp);
312
+ var seen = [];
313
+ return function stringify4(node) {
314
+ if (node && node.toJSON && typeof node.toJSON === "function") {
315
+ node = node.toJSON();
316
+ }
317
+ if (node === void 0)
318
+ return;
319
+ if (typeof node == "number")
320
+ return isFinite(node) ? "" + node : "null";
321
+ if (typeof node !== "object")
322
+ return JSON.stringify(node);
323
+ var i, out;
324
+ if (Array.isArray(node)) {
325
+ out = "[";
326
+ for (i = 0; i < node.length; i++) {
327
+ if (i)
328
+ out += ",";
329
+ out += stringify4(node[i]) || "null";
330
+ }
331
+ return out + "]";
332
+ }
333
+ if (node === null)
334
+ return "null";
335
+ if (seen.indexOf(node) !== -1) {
336
+ if (cycles)
337
+ return JSON.stringify("__cycle__");
338
+ throw new TypeError("Converting circular structure to JSON");
339
+ }
340
+ var seenIndex = seen.push(node) - 1;
341
+ var keys = Object.keys(node).sort(cmp && cmp(node));
342
+ out = "";
343
+ for (i = 0; i < keys.length; i++) {
344
+ var key = keys[i];
345
+ var value = stringify4(node[key]);
346
+ if (!value)
347
+ continue;
348
+ if (out)
349
+ out += ",";
350
+ out += JSON.stringify(key) + ":" + value;
351
+ }
352
+ seen.splice(seenIndex, 1);
353
+ return "{" + out + "}";
354
+ }(data);
355
+ };
356
+ }
357
+ });
358
+
359
+ // node_modules/diff/lib/diff/base.js
360
+ var require_base = __commonJS({
361
+ "node_modules/diff/lib/diff/base.js"(exports) {
362
+ "use strict";
363
+ Object.defineProperty(exports, "__esModule", {
364
+ value: true
365
+ });
366
+ exports["default"] = Diff;
367
+ function Diff() {
368
+ }
369
+ Diff.prototype = {
370
+ /*istanbul ignore start*/
371
+ /*istanbul ignore end*/
372
+ diff: function diff2(oldString, newString) {
373
+ var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
374
+ var callback = options.callback;
375
+ if (typeof options === "function") {
376
+ callback = options;
377
+ options = {};
378
+ }
379
+ this.options = options;
680
380
  var self = this;
681
381
  function done(value) {
682
382
  if (callback) {
@@ -1371,23 +1071,19 @@ var require_src = __commonJS({
1371
1071
  return void 0;
1372
1072
  }
1373
1073
  if (isArray) {
1374
- const result = [];
1375
- for (let row of data) {
1074
+ return data.map((row, index) => {
1376
1075
  if (typeof row === "string") {
1377
1076
  row = this.opts.deserialize(row);
1378
1077
  }
1379
1078
  if (row === void 0 || row === null) {
1380
- result.push(void 0);
1381
- continue;
1079
+ return void 0;
1382
1080
  }
1383
1081
  if (typeof row.expires === "number" && Date.now() > row.expires) {
1384
- this.delete(key).then(() => void 0);
1385
- result.push(void 0);
1386
- } else {
1387
- result.push(options && options.raw ? row : row.value);
1082
+ this.delete(key[index]).then(() => void 0);
1083
+ return void 0;
1388
1084
  }
1389
- }
1390
- return result;
1085
+ return options && options.raw ? row : row.value;
1086
+ });
1391
1087
  }
1392
1088
  if (typeof data.expires === "number" && Date.now() > data.expires) {
1393
1089
  return this.delete(key).then(() => void 0);
@@ -3963,9 +3659,9 @@ var require_glob = __commonJS({
3963
3659
  }
3964
3660
  });
3965
3661
 
3966
- // node_modules/rimraf/rimraf.js
3662
+ // node_modules/flat-cache/node_modules/rimraf/rimraf.js
3967
3663
  var require_rimraf = __commonJS({
3968
- "node_modules/rimraf/rimraf.js"(exports, module) {
3664
+ "node_modules/flat-cache/node_modules/rimraf/rimraf.js"(exports, module) {
3969
3665
  var assert = __require("assert");
3970
3666
  var path10 = __require("path");
3971
3667
  var fs6 = __require("fs");
@@ -4704,682 +4400,234 @@ var require_cache2 = __commonJS({
4704
4400
  }
4705
4401
  });
4706
4402
 
4707
- // node_modules/fast-json-stable-stringify/index.js
4708
- var require_fast_json_stable_stringify = __commonJS({
4709
- "node_modules/fast-json-stable-stringify/index.js"(exports, module) {
4710
- "use strict";
4711
- module.exports = function(data, opts) {
4712
- if (!opts)
4713
- opts = {};
4714
- if (typeof opts === "function")
4715
- opts = { cmp: opts };
4716
- var cycles = typeof opts.cycles === "boolean" ? opts.cycles : false;
4717
- var cmp = opts.cmp && function(f) {
4718
- return function(node) {
4719
- return function(a, b) {
4720
- var aobj = { key: a, value: node[a] };
4721
- var bobj = { key: b, value: node[b] };
4722
- return f(aobj, bobj);
4723
- };
4724
- };
4725
- }(opts.cmp);
4726
- var seen = [];
4727
- return function stringify4(node) {
4728
- if (node && node.toJSON && typeof node.toJSON === "function") {
4729
- node = node.toJSON();
4730
- }
4731
- if (node === void 0)
4732
- return;
4733
- if (typeof node == "number")
4734
- return isFinite(node) ? "" + node : "null";
4735
- if (typeof node !== "object")
4736
- return JSON.stringify(node);
4737
- var i, out;
4738
- if (Array.isArray(node)) {
4739
- out = "[";
4740
- for (i = 0; i < node.length; i++) {
4741
- if (i)
4742
- out += ",";
4743
- out += stringify4(node[i]) || "null";
4744
- }
4745
- return out + "]";
4746
- }
4747
- if (node === null)
4748
- return "null";
4749
- if (seen.indexOf(node) !== -1) {
4750
- if (cycles)
4751
- return JSON.stringify("__cycle__");
4752
- throw new TypeError("Converting circular structure to JSON");
4753
- }
4754
- var seenIndex = seen.push(node) - 1;
4755
- var keys = Object.keys(node).sort(cmp && cmp(node));
4756
- out = "";
4757
- for (i = 0; i < keys.length; i++) {
4758
- var key = keys[i];
4759
- var value = stringify4(node[key]);
4760
- if (!value)
4761
- continue;
4762
- if (out)
4763
- out += ",";
4764
- out += JSON.stringify(key) + ":" + value;
4765
- }
4766
- seen.splice(seenIndex, 1);
4767
- return "{" + out + "}";
4768
- }(data);
4769
- };
4770
- }
4771
- });
4772
-
4773
- // src/cli/index.js
4774
- import * as prettier2 from "../index.mjs";
4775
-
4776
- // scripts/build/shims/string-replace-all.js
4777
- var stringReplaceAll = (isOptionalObject, original, pattern, replacement) => {
4778
- if (isOptionalObject && (original === void 0 || original === null)) {
4779
- return;
4780
- }
4781
- if (original.replaceAll) {
4782
- return original.replaceAll(pattern, replacement);
4783
- }
4784
- if (pattern.global) {
4785
- return original.replace(pattern, replacement);
4786
- }
4787
- return original.split(pattern).join(replacement);
4788
- };
4789
- var string_replace_all_default = stringReplaceAll;
4790
-
4791
- // src/cli/logger.js
4792
- import readline from "readline";
4793
-
4794
- // node_modules/chalk/source/vendor/ansi-styles/index.js
4795
- var ANSI_BACKGROUND_OFFSET = 10;
4796
- var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
4797
- var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
4798
- var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
4799
- var styles = {
4800
- modifier: {
4801
- reset: [0, 0],
4802
- // 21 isn't widely supported and 22 does the same thing
4803
- bold: [1, 22],
4804
- dim: [2, 22],
4805
- italic: [3, 23],
4806
- underline: [4, 24],
4807
- overline: [53, 55],
4808
- inverse: [7, 27],
4809
- hidden: [8, 28],
4810
- strikethrough: [9, 29]
4811
- },
4812
- color: {
4813
- black: [30, 39],
4814
- red: [31, 39],
4815
- green: [32, 39],
4816
- yellow: [33, 39],
4817
- blue: [34, 39],
4818
- magenta: [35, 39],
4819
- cyan: [36, 39],
4820
- white: [37, 39],
4821
- // Bright color
4822
- blackBright: [90, 39],
4823
- gray: [90, 39],
4824
- // Alias of `blackBright`
4825
- grey: [90, 39],
4826
- // Alias of `blackBright`
4827
- redBright: [91, 39],
4828
- greenBright: [92, 39],
4829
- yellowBright: [93, 39],
4830
- blueBright: [94, 39],
4831
- magentaBright: [95, 39],
4832
- cyanBright: [96, 39],
4833
- whiteBright: [97, 39]
4834
- },
4835
- bgColor: {
4836
- bgBlack: [40, 49],
4837
- bgRed: [41, 49],
4838
- bgGreen: [42, 49],
4839
- bgYellow: [43, 49],
4840
- bgBlue: [44, 49],
4841
- bgMagenta: [45, 49],
4842
- bgCyan: [46, 49],
4843
- bgWhite: [47, 49],
4844
- // Bright color
4845
- bgBlackBright: [100, 49],
4846
- bgGray: [100, 49],
4847
- // Alias of `bgBlackBright`
4848
- bgGrey: [100, 49],
4849
- // Alias of `bgBlackBright`
4850
- bgRedBright: [101, 49],
4851
- bgGreenBright: [102, 49],
4852
- bgYellowBright: [103, 49],
4853
- bgBlueBright: [104, 49],
4854
- bgMagentaBright: [105, 49],
4855
- bgCyanBright: [106, 49],
4856
- bgWhiteBright: [107, 49]
4857
- }
4858
- };
4859
- var modifierNames = Object.keys(styles.modifier);
4860
- var foregroundColorNames = Object.keys(styles.color);
4861
- var backgroundColorNames = Object.keys(styles.bgColor);
4862
- var colorNames = [...foregroundColorNames, ...backgroundColorNames];
4863
- function assembleStyles() {
4864
- const codes = /* @__PURE__ */ new Map();
4865
- for (const [groupName, group] of Object.entries(styles)) {
4866
- for (const [styleName, style] of Object.entries(group)) {
4867
- styles[styleName] = {
4868
- open: `\x1B[${style[0]}m`,
4869
- close: `\x1B[${style[1]}m`
4870
- };
4871
- group[styleName] = styles[styleName];
4872
- codes.set(style[0], style[1]);
4873
- }
4874
- Object.defineProperty(styles, groupName, {
4875
- value: group,
4876
- enumerable: false
4877
- });
4878
- }
4879
- Object.defineProperty(styles, "codes", {
4880
- value: codes,
4881
- enumerable: false
4882
- });
4883
- styles.color.close = "\x1B[39m";
4884
- styles.bgColor.close = "\x1B[49m";
4885
- styles.color.ansi = wrapAnsi16();
4886
- styles.color.ansi256 = wrapAnsi256();
4887
- styles.color.ansi16m = wrapAnsi16m();
4888
- styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
4889
- styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
4890
- styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
4891
- Object.defineProperties(styles, {
4892
- rgbToAnsi256: {
4893
- value(red, green, blue) {
4894
- if (red === green && green === blue) {
4895
- if (red < 8) {
4896
- return 16;
4897
- }
4898
- if (red > 248) {
4899
- return 231;
4900
- }
4901
- return Math.round((red - 8) / 247 * 24) + 232;
4902
- }
4903
- return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
4904
- },
4905
- enumerable: false
4906
- },
4907
- hexToRgb: {
4908
- value(hex) {
4909
- const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
4910
- if (!matches) {
4911
- return [0, 0, 0];
4912
- }
4913
- let [colorString] = matches;
4914
- if (colorString.length === 3) {
4915
- colorString = [...colorString].map((character) => character + character).join("");
4916
- }
4917
- const integer = Number.parseInt(colorString, 16);
4918
- return [
4919
- /* eslint-disable no-bitwise */
4920
- integer >> 16 & 255,
4921
- integer >> 8 & 255,
4922
- integer & 255
4923
- /* eslint-enable no-bitwise */
4924
- ];
4925
- },
4926
- enumerable: false
4927
- },
4928
- hexToAnsi256: {
4929
- value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
4930
- enumerable: false
4931
- },
4932
- ansi256ToAnsi: {
4933
- value(code) {
4934
- if (code < 8) {
4935
- return 30 + code;
4936
- }
4937
- if (code < 16) {
4938
- return 90 + (code - 8);
4939
- }
4940
- let red;
4941
- let green;
4942
- let blue;
4943
- if (code >= 232) {
4944
- red = ((code - 232) * 10 + 8) / 255;
4945
- green = red;
4946
- blue = red;
4947
- } else {
4948
- code -= 16;
4949
- const remainder = code % 36;
4950
- red = Math.floor(code / 36) / 5;
4951
- green = Math.floor(remainder / 6) / 5;
4952
- blue = remainder % 6 / 5;
4953
- }
4954
- const value = Math.max(red, green, blue) * 2;
4955
- if (value === 0) {
4956
- return 30;
4957
- }
4958
- let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
4959
- if (value === 2) {
4960
- result += 60;
4961
- }
4962
- return result;
4963
- },
4964
- enumerable: false
4965
- },
4966
- rgbToAnsi: {
4967
- value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
4968
- enumerable: false
4969
- },
4970
- hexToAnsi: {
4971
- value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
4972
- enumerable: false
4973
- }
4974
- });
4975
- return styles;
4976
- }
4977
- var ansiStyles = assembleStyles();
4978
- var ansi_styles_default = ansiStyles;
4979
-
4980
- // node_modules/chalk/source/vendor/supports-color/index.js
4981
- import process2 from "process";
4982
- import os from "os";
4983
- import tty from "tty";
4984
- function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process2.argv) {
4985
- const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
4986
- const position = argv.indexOf(prefix + flag);
4987
- const terminatorPosition = argv.indexOf("--");
4988
- return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
4989
- }
4990
- var { env } = process2;
4991
- var flagForceColor;
4992
- if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
4993
- flagForceColor = 0;
4994
- } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
4995
- flagForceColor = 1;
4996
- }
4997
- function envForceColor() {
4998
- if ("FORCE_COLOR" in env) {
4999
- if (env.FORCE_COLOR === "true") {
5000
- return 1;
5001
- }
5002
- if (env.FORCE_COLOR === "false") {
5003
- return 0;
5004
- }
5005
- return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
5006
- }
5007
- }
5008
- function translateLevel(level) {
5009
- if (level === 0) {
5010
- return false;
5011
- }
5012
- return {
5013
- level,
5014
- hasBasic: true,
5015
- has256: level >= 2,
5016
- has16m: level >= 3
5017
- };
5018
- }
5019
- function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
5020
- const noFlagForceColor = envForceColor();
5021
- if (noFlagForceColor !== void 0) {
5022
- flagForceColor = noFlagForceColor;
5023
- }
5024
- const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
5025
- if (forceColor === 0) {
5026
- return 0;
5027
- }
5028
- if (sniffFlags) {
5029
- if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
5030
- return 3;
5031
- }
5032
- if (hasFlag("color=256")) {
5033
- return 2;
5034
- }
5035
- }
5036
- if ("TF_BUILD" in env && "AGENT_NAME" in env) {
5037
- return 1;
5038
- }
5039
- if (haveStream && !streamIsTTY && forceColor === void 0) {
5040
- return 0;
5041
- }
5042
- const min = forceColor || 0;
5043
- if (env.TERM === "dumb") {
5044
- return min;
5045
- }
5046
- if (process2.platform === "win32") {
5047
- const osRelease = os.release().split(".");
5048
- if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
5049
- return Number(osRelease[2]) >= 14931 ? 3 : 2;
5050
- }
5051
- return 1;
5052
- }
5053
- if ("CI" in env) {
5054
- if ("GITHUB_ACTIONS" in env || "GITEA_ACTIONS" in env) {
5055
- return 3;
5056
- }
5057
- if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
5058
- return 1;
5059
- }
5060
- return min;
5061
- }
5062
- if ("TEAMCITY_VERSION" in env) {
5063
- return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
5064
- }
5065
- if (env.COLORTERM === "truecolor") {
5066
- return 3;
5067
- }
5068
- if (env.TERM === "xterm-kitty") {
5069
- return 3;
5070
- }
5071
- if ("TERM_PROGRAM" in env) {
5072
- const version2 = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
5073
- switch (env.TERM_PROGRAM) {
5074
- case "iTerm.app": {
5075
- return version2 >= 3 ? 3 : 2;
5076
- }
5077
- case "Apple_Terminal": {
5078
- return 2;
5079
- }
5080
- }
5081
- }
5082
- if (/-256(color)?$/i.test(env.TERM)) {
5083
- return 2;
5084
- }
5085
- if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
5086
- return 1;
5087
- }
5088
- if ("COLORTERM" in env) {
5089
- return 1;
5090
- }
5091
- return min;
5092
- }
5093
- function createSupportsColor(stream, options = {}) {
5094
- const level = _supportsColor(stream, {
5095
- streamIsTTY: stream && stream.isTTY,
5096
- ...options
5097
- });
5098
- return translateLevel(level);
5099
- }
5100
- var supportsColor = {
5101
- stdout: createSupportsColor({ isTTY: tty.isatty(1) }),
5102
- stderr: createSupportsColor({ isTTY: tty.isatty(2) })
5103
- };
5104
- var supports_color_default = supportsColor;
5105
-
5106
- // node_modules/chalk/source/utilities.js
5107
- function stringReplaceAll2(string, substring, replacer) {
5108
- let index = string.indexOf(substring);
5109
- if (index === -1) {
5110
- return string;
5111
- }
5112
- const substringLength = substring.length;
5113
- let endIndex = 0;
5114
- let returnValue = "";
5115
- do {
5116
- returnValue += string.slice(endIndex, index) + substring + replacer;
5117
- endIndex = index + substringLength;
5118
- index = string.indexOf(substring, endIndex);
5119
- } while (index !== -1);
5120
- returnValue += string.slice(endIndex);
5121
- return returnValue;
5122
- }
5123
- function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
5124
- let endIndex = 0;
5125
- let returnValue = "";
5126
- do {
5127
- const gotCR = string[index - 1] === "\r";
5128
- returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
5129
- endIndex = index + 1;
5130
- index = string.indexOf("\n", endIndex);
5131
- } while (index !== -1);
5132
- returnValue += string.slice(endIndex);
5133
- return returnValue;
5134
- }
5135
-
5136
- // node_modules/chalk/source/index.js
5137
- var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;
5138
- var GENERATOR = Symbol("GENERATOR");
5139
- var STYLER = Symbol("STYLER");
5140
- var IS_EMPTY = Symbol("IS_EMPTY");
5141
- var levelMapping = [
5142
- "ansi",
5143
- "ansi",
5144
- "ansi256",
5145
- "ansi16m"
5146
- ];
5147
- var styles2 = /* @__PURE__ */ Object.create(null);
5148
- var applyOptions = (object, options = {}) => {
5149
- if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
5150
- throw new Error("The `level` option should be an integer from 0 to 3");
5151
- }
5152
- const colorLevel = stdoutColor ? stdoutColor.level : 0;
5153
- object.level = options.level === void 0 ? colorLevel : options.level;
5154
- };
5155
- var chalkFactory = (options) => {
5156
- const chalk2 = (...strings) => strings.join(" ");
5157
- applyOptions(chalk2, options);
5158
- Object.setPrototypeOf(chalk2, createChalk.prototype);
5159
- return chalk2;
5160
- };
5161
- function createChalk(options) {
5162
- return chalkFactory(options);
5163
- }
5164
- Object.setPrototypeOf(createChalk.prototype, Function.prototype);
5165
- for (const [styleName, style] of Object.entries(ansi_styles_default)) {
5166
- styles2[styleName] = {
5167
- get() {
5168
- const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
5169
- Object.defineProperty(this, styleName, { value: builder });
5170
- return builder;
5171
- }
5172
- };
5173
- }
5174
- styles2.visible = {
5175
- get() {
5176
- const builder = createBuilder(this, this[STYLER], true);
5177
- Object.defineProperty(this, "visible", { value: builder });
5178
- return builder;
5179
- }
5180
- };
5181
- var getModelAnsi = (model, level, type, ...arguments_) => {
5182
- if (model === "rgb") {
5183
- if (level === "ansi16m") {
5184
- return ansi_styles_default[type].ansi16m(...arguments_);
5185
- }
5186
- if (level === "ansi256") {
5187
- return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
5188
- }
5189
- return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
5190
- }
5191
- if (model === "hex") {
5192
- return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
5193
- }
5194
- return ansi_styles_default[type][model](...arguments_);
5195
- };
5196
- var usedModels = ["rgb", "hex", "ansi256"];
5197
- for (const model of usedModels) {
5198
- styles2[model] = {
5199
- get() {
5200
- const { level } = this;
5201
- return function(...arguments_) {
5202
- const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
5203
- return createBuilder(this, styler, this[IS_EMPTY]);
5204
- };
5205
- }
5206
- };
5207
- const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
5208
- styles2[bgModel] = {
5209
- get() {
5210
- const { level } = this;
5211
- return function(...arguments_) {
5212
- const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
5213
- return createBuilder(this, styler, this[IS_EMPTY]);
5214
- };
5215
- }
5216
- };
5217
- }
5218
- var proto = Object.defineProperties(() => {
5219
- }, {
5220
- ...styles2,
5221
- level: {
5222
- enumerable: true,
5223
- get() {
5224
- return this[GENERATOR].level;
5225
- },
5226
- set(level) {
5227
- this[GENERATOR].level = level;
5228
- }
4403
+ // node_modules/wcwidth.js/combining.js
4404
+ var require_combining = __commonJS({
4405
+ "node_modules/wcwidth.js/combining.js"(exports, module) {
4406
+ module.exports = [
4407
+ [768, 879],
4408
+ [1155, 1158],
4409
+ [1160, 1161],
4410
+ [1425, 1469],
4411
+ [1471, 1471],
4412
+ [1473, 1474],
4413
+ [1476, 1477],
4414
+ [1479, 1479],
4415
+ [1536, 1539],
4416
+ [1552, 1557],
4417
+ [1611, 1630],
4418
+ [1648, 1648],
4419
+ [1750, 1764],
4420
+ [1767, 1768],
4421
+ [1770, 1773],
4422
+ [1807, 1807],
4423
+ [1809, 1809],
4424
+ [1840, 1866],
4425
+ [1958, 1968],
4426
+ [2027, 2035],
4427
+ [2305, 2306],
4428
+ [2364, 2364],
4429
+ [2369, 2376],
4430
+ [2381, 2381],
4431
+ [2385, 2388],
4432
+ [2402, 2403],
4433
+ [2433, 2433],
4434
+ [2492, 2492],
4435
+ [2497, 2500],
4436
+ [2509, 2509],
4437
+ [2530, 2531],
4438
+ [2561, 2562],
4439
+ [2620, 2620],
4440
+ [2625, 2626],
4441
+ [2631, 2632],
4442
+ [2635, 2637],
4443
+ [2672, 2673],
4444
+ [2689, 2690],
4445
+ [2748, 2748],
4446
+ [2753, 2757],
4447
+ [2759, 2760],
4448
+ [2765, 2765],
4449
+ [2786, 2787],
4450
+ [2817, 2817],
4451
+ [2876, 2876],
4452
+ [2879, 2879],
4453
+ [2881, 2883],
4454
+ [2893, 2893],
4455
+ [2902, 2902],
4456
+ [2946, 2946],
4457
+ [3008, 3008],
4458
+ [3021, 3021],
4459
+ [3134, 3136],
4460
+ [3142, 3144],
4461
+ [3146, 3149],
4462
+ [3157, 3158],
4463
+ [3260, 3260],
4464
+ [3263, 3263],
4465
+ [3270, 3270],
4466
+ [3276, 3277],
4467
+ [3298, 3299],
4468
+ [3393, 3395],
4469
+ [3405, 3405],
4470
+ [3530, 3530],
4471
+ [3538, 3540],
4472
+ [3542, 3542],
4473
+ [3633, 3633],
4474
+ [3636, 3642],
4475
+ [3655, 3662],
4476
+ [3761, 3761],
4477
+ [3764, 3769],
4478
+ [3771, 3772],
4479
+ [3784, 3789],
4480
+ [3864, 3865],
4481
+ [3893, 3893],
4482
+ [3895, 3895],
4483
+ [3897, 3897],
4484
+ [3953, 3966],
4485
+ [3968, 3972],
4486
+ [3974, 3975],
4487
+ [3984, 3991],
4488
+ [3993, 4028],
4489
+ [4038, 4038],
4490
+ [4141, 4144],
4491
+ [4146, 4146],
4492
+ [4150, 4151],
4493
+ [4153, 4153],
4494
+ [4184, 4185],
4495
+ [4448, 4607],
4496
+ [4959, 4959],
4497
+ [5906, 5908],
4498
+ [5938, 5940],
4499
+ [5970, 5971],
4500
+ [6002, 6003],
4501
+ [6068, 6069],
4502
+ [6071, 6077],
4503
+ [6086, 6086],
4504
+ [6089, 6099],
4505
+ [6109, 6109],
4506
+ [6155, 6157],
4507
+ [6313, 6313],
4508
+ [6432, 6434],
4509
+ [6439, 6440],
4510
+ [6450, 6450],
4511
+ [6457, 6459],
4512
+ [6679, 6680],
4513
+ [6912, 6915],
4514
+ [6964, 6964],
4515
+ [6966, 6970],
4516
+ [6972, 6972],
4517
+ [6978, 6978],
4518
+ [7019, 7027],
4519
+ [7616, 7626],
4520
+ [7678, 7679],
4521
+ [8203, 8207],
4522
+ [8234, 8238],
4523
+ [8288, 8291],
4524
+ [8298, 8303],
4525
+ [8400, 8431],
4526
+ [12330, 12335],
4527
+ [12441, 12442],
4528
+ [43014, 43014],
4529
+ [43019, 43019],
4530
+ [43045, 43046],
4531
+ [64286, 64286],
4532
+ [65024, 65039],
4533
+ [65056, 65059],
4534
+ [65279, 65279],
4535
+ [65529, 65531],
4536
+ [68097, 68099],
4537
+ [68101, 68102],
4538
+ [68108, 68111],
4539
+ [68152, 68154],
4540
+ [68159, 68159],
4541
+ [119143, 119145],
4542
+ [119155, 119170],
4543
+ [119173, 119179],
4544
+ [119210, 119213],
4545
+ [119362, 119364],
4546
+ [917505, 917505],
4547
+ [917536, 917631],
4548
+ [917760, 917999]
4549
+ ];
5229
4550
  }
5230
4551
  });
5231
- var createStyler = (open, close, parent) => {
5232
- let openAll;
5233
- let closeAll;
5234
- if (parent === void 0) {
5235
- openAll = open;
5236
- closeAll = close;
5237
- } else {
5238
- openAll = parent.openAll + open;
5239
- closeAll = close + parent.closeAll;
5240
- }
5241
- return {
5242
- open,
5243
- close,
5244
- openAll,
5245
- closeAll,
5246
- parent
5247
- };
5248
- };
5249
- var createBuilder = (self, _styler, _isEmpty) => {
5250
- const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
5251
- Object.setPrototypeOf(builder, proto);
5252
- builder[GENERATOR] = self;
5253
- builder[STYLER] = _styler;
5254
- builder[IS_EMPTY] = _isEmpty;
5255
- return builder;
5256
- };
5257
- var applyStyle = (self, string) => {
5258
- if (self.level <= 0 || !string) {
5259
- return self[IS_EMPTY] ? "" : string;
5260
- }
5261
- let styler = self[STYLER];
5262
- if (styler === void 0) {
5263
- return string;
5264
- }
5265
- const { openAll, closeAll } = styler;
5266
- if (string.includes("\x1B")) {
5267
- while (styler !== void 0) {
5268
- string = stringReplaceAll2(string, styler.close, styler.open);
5269
- styler = styler.parent;
5270
- }
5271
- }
5272
- const lfIndex = string.indexOf("\n");
5273
- if (lfIndex !== -1) {
5274
- string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
5275
- }
5276
- return openAll + string + closeAll;
5277
- };
5278
- Object.defineProperties(createChalk.prototype, styles2);
5279
- var chalk = createChalk();
5280
- var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
5281
- var source_default = chalk;
5282
-
5283
- // node_modules/ansi-regex/index.js
5284
- function ansiRegex({ onlyFirst = false } = {}) {
5285
- const pattern = [
5286
- "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
5287
- "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"
5288
- ].join("|");
5289
- return new RegExp(pattern, onlyFirst ? void 0 : "g");
5290
- }
5291
-
5292
- // node_modules/strip-ansi/index.js
5293
- var regex = ansiRegex();
5294
- function stripAnsi(string) {
5295
- if (typeof string !== "string") {
5296
- throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
5297
- }
5298
- return string.replace(regex, "");
5299
- }
5300
4552
 
5301
- // src/cli/logger.js
5302
- var import_wcwidth = __toESM(require_wcwidth(), 1);
5303
- var countLines = (stream, text) => {
5304
- const columns = stream.columns || 80;
5305
- let lineCount = 0;
5306
- for (const line of stripAnsi(text).split("\n")) {
5307
- lineCount += Math.max(1, Math.ceil((0, import_wcwidth.default)(line) / columns));
5308
- }
5309
- return lineCount;
5310
- };
5311
- var clear = (stream, text) => () => {
5312
- const lineCount = countLines(stream, text);
5313
- for (let line = 0; line < lineCount; line++) {
5314
- if (line > 0) {
5315
- readline.moveCursor(stream, 0, -1);
5316
- }
5317
- readline.clearLine(stream, 0);
5318
- readline.cursorTo(stream, 0);
5319
- }
5320
- };
5321
- var emptyLogResult = {
5322
- clear() {
5323
- }
5324
- };
5325
- function createLogger(logLevel = "log") {
5326
- return {
5327
- logLevel,
5328
- warn: createLogFunc("warn", "yellow"),
5329
- error: createLogFunc("error", "red"),
5330
- debug: createLogFunc("debug", "blue"),
5331
- log: createLogFunc("log")
5332
- };
5333
- function createLogFunc(loggerName, color) {
5334
- if (!shouldLog(loggerName)) {
5335
- return () => emptyLogResult;
5336
- }
5337
- const stream = process[loggerName === "log" ? "stdout" : "stderr"];
5338
- const chalkInstance = loggerName === "log" ? source_default : chalkStderr;
5339
- const prefix = color ? `[${chalkInstance[color](loggerName)}] ` : "";
5340
- return (message, options) => {
5341
- options = {
5342
- newline: true,
5343
- clearable: false,
5344
- ...options
5345
- };
5346
- message = string_replace_all_default(
5347
- /* isOptionalObject*/
5348
- false,
5349
- message,
5350
- /^/gm,
5351
- prefix
5352
- ) + (options.newline ? "\n" : "");
5353
- stream.write(message);
5354
- if (options.clearable) {
5355
- return {
5356
- clear: clear(stream, message)
5357
- };
5358
- }
5359
- };
5360
- }
5361
- function shouldLog(loggerName) {
5362
- switch (logLevel) {
5363
- case "silent":
5364
- return false;
5365
- case "debug":
5366
- if (loggerName === "debug") {
5367
- return true;
5368
- }
5369
- case "log":
5370
- if (loggerName === "log") {
5371
- return true;
5372
- }
5373
- case "warn":
5374
- if (loggerName === "warn") {
4553
+ // node_modules/wcwidth.js/index.js
4554
+ var require_wcwidth = __commonJS({
4555
+ "node_modules/wcwidth.js/index.js"(exports, module) {
4556
+ var combining = require_combining();
4557
+ var DEFAULTS = {
4558
+ nul: 0,
4559
+ control: 0
4560
+ };
4561
+ function bisearch(ucs) {
4562
+ let min = 0;
4563
+ let max = combining.length - 1;
4564
+ let mid;
4565
+ if (ucs < combining[0][0] || ucs > combining[max][1])
4566
+ return false;
4567
+ while (max >= min) {
4568
+ mid = Math.floor((min + max) / 2);
4569
+ if (ucs > combining[mid][1])
4570
+ min = mid + 1;
4571
+ else if (ucs < combining[mid][0])
4572
+ max = mid - 1;
4573
+ else
5375
4574
  return true;
4575
+ }
4576
+ return false;
4577
+ }
4578
+ function wcwidth2(ucs, opts) {
4579
+ if (ucs === 0)
4580
+ return opts.nul;
4581
+ if (ucs < 32 || ucs >= 127 && ucs < 160)
4582
+ return opts.control;
4583
+ if (bisearch(ucs))
4584
+ return 0;
4585
+ return 1 + (ucs >= 4352 && (ucs <= 4447 || // Hangul Jamo init. consonants
4586
+ ucs == 9001 || ucs == 9002 || ucs >= 11904 && ucs <= 42191 && ucs != 12351 || // CJK ... Yi
4587
+ ucs >= 44032 && ucs <= 55203 || // Hangul Syllables
4588
+ ucs >= 63744 && ucs <= 64255 || // CJK Compatibility Ideographs
4589
+ ucs >= 65040 && ucs <= 65049 || // Vertical forms
4590
+ ucs >= 65072 && ucs <= 65135 || // CJK Compatibility Forms
4591
+ ucs >= 65280 && ucs <= 65376 || // Fullwidth Forms
4592
+ ucs >= 65504 && ucs <= 65510 || ucs >= 131072 && ucs <= 196605 || ucs >= 196608 && ucs <= 262141));
4593
+ }
4594
+ function wcswidth(str, opts) {
4595
+ let h;
4596
+ let l;
4597
+ let s = 0;
4598
+ let n;
4599
+ if (typeof str !== "string")
4600
+ return wcwidth2(str, opts);
4601
+ for (let i = 0; i < str.length; i++) {
4602
+ h = str.charCodeAt(i);
4603
+ if (h >= 55296 && h <= 56319) {
4604
+ l = str.charCodeAt(++i);
4605
+ if (l >= 56320 && l <= 57343) {
4606
+ h = (h - 55296) * 1024 + (l - 56320) + 65536;
4607
+ } else {
4608
+ i--;
4609
+ }
5376
4610
  }
5377
- case "error":
5378
- return loggerName === "error";
4611
+ n = wcwidth2(h, opts);
4612
+ if (n < 0)
4613
+ return -1;
4614
+ s += n;
4615
+ }
4616
+ return s;
5379
4617
  }
4618
+ module.exports = (str) => wcswidth(str, DEFAULTS);
4619
+ module.exports.config = (opts = {}) => {
4620
+ opts = {
4621
+ ...DEFAULTS,
4622
+ ...opts
4623
+ };
4624
+ return (str) => wcswidth(str, opts);
4625
+ };
5380
4626
  }
5381
- }
5382
- var logger_default = createLogger;
4627
+ });
4628
+
4629
+ // src/cli/index.js
4630
+ import * as prettier2 from "../index.mjs";
5383
4631
 
5384
4632
  // scripts/build/shims/at.js
5385
4633
  var at = (isOptionalObject, object, index) => {
@@ -5397,20 +4645,6 @@ var at_default = at;
5397
4645
  var import_dashify = __toESM(require_dashify(), 1);
5398
4646
  import { getSupportInfo } from "../index.mjs";
5399
4647
 
5400
- // src/cli/prettier-internal.js
5401
- import { __internal as sharedWithCli } from "../index.mjs";
5402
- var {
5403
- errors,
5404
- optionCategories,
5405
- createIsIgnoredFunction,
5406
- formatOptionsHiddenDefaults,
5407
- normalizeOptions,
5408
- getSupportInfoWithoutPlugins,
5409
- normalizeOptionSettings,
5410
- vnopts,
5411
- fastGlob
5412
- } = sharedWithCli;
5413
-
5414
4648
  // src/cli/cli-options.evaluate.js
5415
4649
  var cli_options_evaluate_default = {
5416
4650
  "cache": {
@@ -5566,297 +4800,816 @@ var cli_options_evaluate_default = {
5566
4800
  "description": "Print Prettier version.",
5567
4801
  "type": "boolean"
5568
4802
  },
5569
- "withNodeModules": {
5570
- "category": "Config",
5571
- "description": "Process files inside 'node_modules' directory.",
5572
- "type": "boolean"
4803
+ "withNodeModules": {
4804
+ "category": "Config",
4805
+ "description": "Process files inside 'node_modules' directory.",
4806
+ "type": "boolean"
4807
+ },
4808
+ "write": {
4809
+ "alias": "w",
4810
+ "category": "Output",
4811
+ "description": "Edit files in-place. (Beware!)",
4812
+ "type": "boolean"
4813
+ }
4814
+ };
4815
+
4816
+ // src/cli/prettier-internal.js
4817
+ import { __internal as sharedWithCli } from "../index.mjs";
4818
+ var {
4819
+ errors,
4820
+ optionCategories,
4821
+ createIsIgnoredFunction,
4822
+ formatOptionsHiddenDefaults,
4823
+ normalizeOptions,
4824
+ getSupportInfoWithoutPlugins,
4825
+ normalizeOptionSettings,
4826
+ vnopts,
4827
+ fastGlob,
4828
+ mockable
4829
+ } = sharedWithCli;
4830
+
4831
+ // src/cli/options/get-context-options.js
4832
+ var detailedCliOptions = normalizeOptionSettings(cli_options_evaluate_default).map(
4833
+ (option) => normalizeDetailedOption(option)
4834
+ );
4835
+ function apiOptionToCliOption(apiOption) {
4836
+ const cliOption = {
4837
+ ...apiOption,
4838
+ description: apiOption.cliDescription ?? apiOption.description,
4839
+ category: apiOption.cliCategory ?? optionCategories.CATEGORY_FORMAT,
4840
+ forwardToApi: apiOption.name
4841
+ };
4842
+ if (apiOption.deprecated) {
4843
+ delete cliOption.forwardToApi;
4844
+ delete cliOption.description;
4845
+ delete cliOption.oppositeDescription;
4846
+ cliOption.deprecated = true;
4847
+ }
4848
+ return normalizeDetailedOption(cliOption);
4849
+ }
4850
+ function normalizeDetailedOption(option) {
4851
+ var _a;
4852
+ return {
4853
+ category: optionCategories.CATEGORY_OTHER,
4854
+ ...option,
4855
+ name: option.cliName ?? (0, import_dashify.default)(option.name),
4856
+ choices: (_a = option.choices) == null ? void 0 : _a.map((choice) => {
4857
+ const newChoice = {
4858
+ description: "",
4859
+ deprecated: false,
4860
+ ...typeof choice === "object" ? choice : { value: choice }
4861
+ };
4862
+ if (newChoice.value === true) {
4863
+ newChoice.value = "";
4864
+ }
4865
+ return newChoice;
4866
+ })
4867
+ };
4868
+ }
4869
+ function supportInfoToContextOptions({ options: supportOptions, languages }) {
4870
+ const detailedOptions = [
4871
+ ...detailedCliOptions,
4872
+ ...supportOptions.map((apiOption) => apiOptionToCliOption(apiOption))
4873
+ ];
4874
+ return {
4875
+ supportOptions,
4876
+ languages,
4877
+ detailedOptions
4878
+ };
4879
+ }
4880
+ async function getContextOptions(plugins) {
4881
+ const supportInfo = await getSupportInfo({
4882
+ showDeprecated: true,
4883
+ plugins
4884
+ });
4885
+ return supportInfoToContextOptions(supportInfo);
4886
+ }
4887
+ function getContextOptionsWithoutPlugins() {
4888
+ const supportInfo = getSupportInfoWithoutPlugins();
4889
+ return supportInfoToContextOptions(supportInfo);
4890
+ }
4891
+
4892
+ // scripts/build/shims/string-replace-all.js
4893
+ var stringReplaceAll = (isOptionalObject, original, pattern, replacement) => {
4894
+ if (isOptionalObject && (original === void 0 || original === null)) {
4895
+ return;
4896
+ }
4897
+ if (original.replaceAll) {
4898
+ return original.replaceAll(pattern, replacement);
4899
+ }
4900
+ if (pattern.global) {
4901
+ return original.replace(pattern, replacement);
4902
+ }
4903
+ return original.split(pattern).join(replacement);
4904
+ };
4905
+ var string_replace_all_default = stringReplaceAll;
4906
+
4907
+ // node_modules/camelcase/index.js
4908
+ var UPPERCASE = /[\p{Lu}]/u;
4909
+ var LOWERCASE = /[\p{Ll}]/u;
4910
+ var LEADING_CAPITAL = /^[\p{Lu}](?![\p{Lu}])/gu;
4911
+ var IDENTIFIER = /([\p{Alpha}\p{N}_]|$)/u;
4912
+ var SEPARATORS = /[_.\- ]+/;
4913
+ var LEADING_SEPARATORS = new RegExp("^" + SEPARATORS.source);
4914
+ var SEPARATORS_AND_IDENTIFIER = new RegExp(SEPARATORS.source + IDENTIFIER.source, "gu");
4915
+ var NUMBERS_AND_IDENTIFIER = new RegExp("\\d+" + IDENTIFIER.source, "gu");
4916
+ var preserveCamelCase = (string, toLowerCase, toUpperCase, preserveConsecutiveUppercase2) => {
4917
+ let isLastCharLower = false;
4918
+ let isLastCharUpper = false;
4919
+ let isLastLastCharUpper = false;
4920
+ let isLastLastCharPreserved = false;
4921
+ for (let index = 0; index < string.length; index++) {
4922
+ const character = string[index];
4923
+ isLastLastCharPreserved = index > 2 ? string[index - 3] === "-" : true;
4924
+ if (isLastCharLower && UPPERCASE.test(character)) {
4925
+ string = string.slice(0, index) + "-" + string.slice(index);
4926
+ isLastCharLower = false;
4927
+ isLastLastCharUpper = isLastCharUpper;
4928
+ isLastCharUpper = true;
4929
+ index++;
4930
+ } else if (isLastCharUpper && isLastLastCharUpper && LOWERCASE.test(character) && (!isLastLastCharPreserved || preserveConsecutiveUppercase2)) {
4931
+ string = string.slice(0, index - 1) + "-" + string.slice(index - 1);
4932
+ isLastLastCharUpper = isLastCharUpper;
4933
+ isLastCharUpper = false;
4934
+ isLastCharLower = true;
4935
+ } else {
4936
+ isLastCharLower = toLowerCase(character) === character && toUpperCase(character) !== character;
4937
+ isLastLastCharUpper = isLastCharUpper;
4938
+ isLastCharUpper = toUpperCase(character) === character && toLowerCase(character) !== character;
4939
+ }
4940
+ }
4941
+ return string;
4942
+ };
4943
+ var preserveConsecutiveUppercase = (input, toLowerCase) => {
4944
+ LEADING_CAPITAL.lastIndex = 0;
4945
+ return string_replace_all_default(
4946
+ /* isOptionalObject*/
4947
+ false,
4948
+ input,
4949
+ LEADING_CAPITAL,
4950
+ (match) => toLowerCase(match)
4951
+ );
4952
+ };
4953
+ var postProcess = (input, toUpperCase) => {
4954
+ SEPARATORS_AND_IDENTIFIER.lastIndex = 0;
4955
+ NUMBERS_AND_IDENTIFIER.lastIndex = 0;
4956
+ return string_replace_all_default(
4957
+ /* isOptionalObject*/
4958
+ false,
4959
+ string_replace_all_default(
4960
+ /* isOptionalObject*/
4961
+ false,
4962
+ input,
4963
+ NUMBERS_AND_IDENTIFIER,
4964
+ (match, pattern, offset) => ["_", "-"].includes(input.charAt(offset + match.length)) ? match : toUpperCase(match)
4965
+ ),
4966
+ SEPARATORS_AND_IDENTIFIER,
4967
+ (_, identifier) => toUpperCase(identifier)
4968
+ );
4969
+ };
4970
+ function camelCase(input, options) {
4971
+ if (!(typeof input === "string" || Array.isArray(input))) {
4972
+ throw new TypeError("Expected the input to be `string | string[]`");
4973
+ }
4974
+ options = {
4975
+ pascalCase: false,
4976
+ preserveConsecutiveUppercase: false,
4977
+ ...options
4978
+ };
4979
+ if (Array.isArray(input)) {
4980
+ input = input.map((x) => x.trim()).filter((x) => x.length).join("-");
4981
+ } else {
4982
+ input = input.trim();
4983
+ }
4984
+ if (input.length === 0) {
4985
+ return "";
4986
+ }
4987
+ const toLowerCase = options.locale === false ? (string) => string.toLowerCase() : (string) => string.toLocaleLowerCase(options.locale);
4988
+ const toUpperCase = options.locale === false ? (string) => string.toUpperCase() : (string) => string.toLocaleUpperCase(options.locale);
4989
+ if (input.length === 1) {
4990
+ if (SEPARATORS.test(input)) {
4991
+ return "";
4992
+ }
4993
+ return options.pascalCase ? toUpperCase(input) : toLowerCase(input);
4994
+ }
4995
+ const hasUpperCase = input !== toLowerCase(input);
4996
+ if (hasUpperCase) {
4997
+ input = preserveCamelCase(input, toLowerCase, toUpperCase, options.preserveConsecutiveUppercase);
4998
+ }
4999
+ input = input.replace(LEADING_SEPARATORS, "");
5000
+ input = options.preserveConsecutiveUppercase ? preserveConsecutiveUppercase(input, toLowerCase) : toLowerCase(input);
5001
+ if (options.pascalCase) {
5002
+ input = toUpperCase(input.charAt(0)) + input.slice(1);
5003
+ }
5004
+ return postProcess(input, toUpperCase);
5005
+ }
5006
+
5007
+ // src/cli/utils.js
5008
+ import fs from "fs/promises";
5009
+ import path from "path";
5010
+
5011
+ // node_modules/sdbm/index.js
5012
+ function sdbm(string) {
5013
+ let hash = 0;
5014
+ for (let i = 0; i < string.length; i++) {
5015
+ hash = string.charCodeAt(i) + (hash << 6) + (hash << 16) - hash;
5016
+ }
5017
+ return hash >>> 0;
5018
+ }
5019
+
5020
+ // src/cli/utils.js
5021
+ import { __internal as sharedWithCli2 } from "../index.mjs";
5022
+ var printToScreen = console.log.bind(console);
5023
+ function groupBy(array2, iteratee) {
5024
+ const result = /* @__PURE__ */ Object.create(null);
5025
+ for (const value of array2) {
5026
+ const key = iteratee(value);
5027
+ if (Array.isArray(result[key])) {
5028
+ result[key].push(value);
5029
+ } else {
5030
+ result[key] = [value];
5031
+ }
5032
+ }
5033
+ return result;
5034
+ }
5035
+ function pick(object, keys) {
5036
+ const entries = keys.map((key) => [key, object[key]]);
5037
+ return Object.fromEntries(entries);
5038
+ }
5039
+ function createHash(source) {
5040
+ return String(sdbm(source));
5041
+ }
5042
+ async function statSafe(filePath) {
5043
+ try {
5044
+ return await fs.stat(filePath);
5045
+ } catch (error) {
5046
+ if (error.code !== "ENOENT") {
5047
+ throw error;
5048
+ }
5049
+ }
5050
+ }
5051
+ async function lstatSafe(filePath) {
5052
+ try {
5053
+ return await fs.lstat(filePath);
5054
+ } catch (error) {
5055
+ if (error.code !== "ENOENT") {
5056
+ throw error;
5057
+ }
5058
+ }
5059
+ }
5060
+ function isJson(value) {
5061
+ try {
5062
+ JSON.parse(value);
5063
+ return true;
5064
+ } catch {
5065
+ return false;
5066
+ }
5067
+ }
5068
+ var normalizeToPosix = path.sep === "\\" ? (filepath) => string_replace_all_default(
5069
+ /* isOptionalObject*/
5070
+ false,
5071
+ filepath,
5072
+ "\\",
5073
+ "/"
5074
+ ) : (filepath) => filepath;
5075
+ var {
5076
+ isNonEmptyArray,
5077
+ partition,
5078
+ omit
5079
+ } = sharedWithCli2.utils;
5080
+
5081
+ // src/cli/options/create-minimist-options.js
5082
+ function createMinimistOptions(detailedOptions) {
5083
+ const booleanNames = [];
5084
+ const stringNames = [];
5085
+ const defaultValues = {};
5086
+ for (const option of detailedOptions) {
5087
+ const { name, alias, type } = option;
5088
+ const names = type === "boolean" ? booleanNames : stringNames;
5089
+ names.push(name);
5090
+ if (alias) {
5091
+ names.push(alias);
5092
+ }
5093
+ if (!option.deprecated && (!option.forwardToApi || name === "plugin") && option.default !== void 0) {
5094
+ defaultValues[option.name] = option.default;
5095
+ }
5096
+ }
5097
+ return {
5098
+ // we use vnopts' AliasSchema to handle aliases for better error messages
5099
+ alias: {},
5100
+ boolean: booleanNames,
5101
+ string: stringNames,
5102
+ default: defaultValues
5103
+ };
5104
+ }
5105
+
5106
+ // src/cli/options/minimist.js
5107
+ var import_minimist = __toESM(require_minimist(), 1);
5108
+ var PLACEHOLDER = null;
5109
+ function minimistParse(args, options) {
5110
+ const boolean = options.boolean ?? [];
5111
+ const defaults = options.default ?? {};
5112
+ const booleanWithoutDefault = boolean.filter((key) => !(key in defaults));
5113
+ const newDefaults = {
5114
+ ...defaults,
5115
+ ...Object.fromEntries(
5116
+ booleanWithoutDefault.map((key) => [key, PLACEHOLDER])
5117
+ )
5118
+ };
5119
+ const parsed = (0, import_minimist.default)(args, { ...options, default: newDefaults });
5120
+ return Object.fromEntries(
5121
+ Object.entries(parsed).filter(([, value]) => value !== PLACEHOLDER)
5122
+ );
5123
+ }
5124
+
5125
+ // node_modules/chalk/source/vendor/ansi-styles/index.js
5126
+ var ANSI_BACKGROUND_OFFSET = 10;
5127
+ var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
5128
+ var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
5129
+ var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
5130
+ var styles = {
5131
+ modifier: {
5132
+ reset: [0, 0],
5133
+ // 21 isn't widely supported and 22 does the same thing
5134
+ bold: [1, 22],
5135
+ dim: [2, 22],
5136
+ italic: [3, 23],
5137
+ underline: [4, 24],
5138
+ overline: [53, 55],
5139
+ inverse: [7, 27],
5140
+ hidden: [8, 28],
5141
+ strikethrough: [9, 29]
5142
+ },
5143
+ color: {
5144
+ black: [30, 39],
5145
+ red: [31, 39],
5146
+ green: [32, 39],
5147
+ yellow: [33, 39],
5148
+ blue: [34, 39],
5149
+ magenta: [35, 39],
5150
+ cyan: [36, 39],
5151
+ white: [37, 39],
5152
+ // Bright color
5153
+ blackBright: [90, 39],
5154
+ gray: [90, 39],
5155
+ // Alias of `blackBright`
5156
+ grey: [90, 39],
5157
+ // Alias of `blackBright`
5158
+ redBright: [91, 39],
5159
+ greenBright: [92, 39],
5160
+ yellowBright: [93, 39],
5161
+ blueBright: [94, 39],
5162
+ magentaBright: [95, 39],
5163
+ cyanBright: [96, 39],
5164
+ whiteBright: [97, 39]
5573
5165
  },
5574
- "write": {
5575
- "alias": "w",
5576
- "category": "Output",
5577
- "description": "Edit files in-place. (Beware!)",
5578
- "type": "boolean"
5166
+ bgColor: {
5167
+ bgBlack: [40, 49],
5168
+ bgRed: [41, 49],
5169
+ bgGreen: [42, 49],
5170
+ bgYellow: [43, 49],
5171
+ bgBlue: [44, 49],
5172
+ bgMagenta: [45, 49],
5173
+ bgCyan: [46, 49],
5174
+ bgWhite: [47, 49],
5175
+ // Bright color
5176
+ bgBlackBright: [100, 49],
5177
+ bgGray: [100, 49],
5178
+ // Alias of `bgBlackBright`
5179
+ bgGrey: [100, 49],
5180
+ // Alias of `bgBlackBright`
5181
+ bgRedBright: [101, 49],
5182
+ bgGreenBright: [102, 49],
5183
+ bgYellowBright: [103, 49],
5184
+ bgBlueBright: [104, 49],
5185
+ bgMagentaBright: [105, 49],
5186
+ bgCyanBright: [106, 49],
5187
+ bgWhiteBright: [107, 49]
5579
5188
  }
5580
5189
  };
5190
+ var modifierNames = Object.keys(styles.modifier);
5191
+ var foregroundColorNames = Object.keys(styles.color);
5192
+ var backgroundColorNames = Object.keys(styles.bgColor);
5193
+ var colorNames = [...foregroundColorNames, ...backgroundColorNames];
5194
+ function assembleStyles() {
5195
+ const codes = /* @__PURE__ */ new Map();
5196
+ for (const [groupName, group] of Object.entries(styles)) {
5197
+ for (const [styleName, style] of Object.entries(group)) {
5198
+ styles[styleName] = {
5199
+ open: `\x1B[${style[0]}m`,
5200
+ close: `\x1B[${style[1]}m`
5201
+ };
5202
+ group[styleName] = styles[styleName];
5203
+ codes.set(style[0], style[1]);
5204
+ }
5205
+ Object.defineProperty(styles, groupName, {
5206
+ value: group,
5207
+ enumerable: false
5208
+ });
5209
+ }
5210
+ Object.defineProperty(styles, "codes", {
5211
+ value: codes,
5212
+ enumerable: false
5213
+ });
5214
+ styles.color.close = "\x1B[39m";
5215
+ styles.bgColor.close = "\x1B[49m";
5216
+ styles.color.ansi = wrapAnsi16();
5217
+ styles.color.ansi256 = wrapAnsi256();
5218
+ styles.color.ansi16m = wrapAnsi16m();
5219
+ styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
5220
+ styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
5221
+ styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
5222
+ Object.defineProperties(styles, {
5223
+ rgbToAnsi256: {
5224
+ value(red, green, blue) {
5225
+ if (red === green && green === blue) {
5226
+ if (red < 8) {
5227
+ return 16;
5228
+ }
5229
+ if (red > 248) {
5230
+ return 231;
5231
+ }
5232
+ return Math.round((red - 8) / 247 * 24) + 232;
5233
+ }
5234
+ return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
5235
+ },
5236
+ enumerable: false
5237
+ },
5238
+ hexToRgb: {
5239
+ value(hex) {
5240
+ const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
5241
+ if (!matches) {
5242
+ return [0, 0, 0];
5243
+ }
5244
+ let [colorString] = matches;
5245
+ if (colorString.length === 3) {
5246
+ colorString = [...colorString].map((character) => character + character).join("");
5247
+ }
5248
+ const integer = Number.parseInt(colorString, 16);
5249
+ return [
5250
+ /* eslint-disable no-bitwise */
5251
+ integer >> 16 & 255,
5252
+ integer >> 8 & 255,
5253
+ integer & 255
5254
+ /* eslint-enable no-bitwise */
5255
+ ];
5256
+ },
5257
+ enumerable: false
5258
+ },
5259
+ hexToAnsi256: {
5260
+ value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
5261
+ enumerable: false
5262
+ },
5263
+ ansi256ToAnsi: {
5264
+ value(code) {
5265
+ if (code < 8) {
5266
+ return 30 + code;
5267
+ }
5268
+ if (code < 16) {
5269
+ return 90 + (code - 8);
5270
+ }
5271
+ let red;
5272
+ let green;
5273
+ let blue;
5274
+ if (code >= 232) {
5275
+ red = ((code - 232) * 10 + 8) / 255;
5276
+ green = red;
5277
+ blue = red;
5278
+ } else {
5279
+ code -= 16;
5280
+ const remainder = code % 36;
5281
+ red = Math.floor(code / 36) / 5;
5282
+ green = Math.floor(remainder / 6) / 5;
5283
+ blue = remainder % 6 / 5;
5284
+ }
5285
+ const value = Math.max(red, green, blue) * 2;
5286
+ if (value === 0) {
5287
+ return 30;
5288
+ }
5289
+ let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
5290
+ if (value === 2) {
5291
+ result += 60;
5292
+ }
5293
+ return result;
5294
+ },
5295
+ enumerable: false
5296
+ },
5297
+ rgbToAnsi: {
5298
+ value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
5299
+ enumerable: false
5300
+ },
5301
+ hexToAnsi: {
5302
+ value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
5303
+ enumerable: false
5304
+ }
5305
+ });
5306
+ return styles;
5307
+ }
5308
+ var ansiStyles = assembleStyles();
5309
+ var ansi_styles_default = ansiStyles;
5581
5310
 
5582
- // src/cli/options/get-context-options.js
5583
- var detailedCliOptions = normalizeOptionSettings(cli_options_evaluate_default).map(
5584
- (option) => normalizeDetailedOption(option)
5585
- );
5586
- function apiOptionToCliOption(apiOption) {
5587
- const cliOption = {
5588
- ...apiOption,
5589
- description: apiOption.cliDescription ?? apiOption.description,
5590
- category: apiOption.cliCategory ?? optionCategories.CATEGORY_FORMAT,
5591
- forwardToApi: apiOption.name
5592
- };
5593
- if (apiOption.deprecated) {
5594
- delete cliOption.forwardToApi;
5595
- delete cliOption.description;
5596
- delete cliOption.oppositeDescription;
5597
- cliOption.deprecated = true;
5598
- }
5599
- return normalizeDetailedOption(cliOption);
5311
+ // node_modules/chalk/source/vendor/supports-color/index.js
5312
+ import process2 from "process";
5313
+ import os from "os";
5314
+ import tty from "tty";
5315
+ function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process2.argv) {
5316
+ const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
5317
+ const position = argv.indexOf(prefix + flag);
5318
+ const terminatorPosition = argv.indexOf("--");
5319
+ return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
5600
5320
  }
5601
- function normalizeDetailedOption(option) {
5602
- var _a;
5603
- return {
5604
- category: optionCategories.CATEGORY_OTHER,
5605
- ...option,
5606
- name: option.cliName ?? (0, import_dashify.default)(option.name),
5607
- choices: (_a = option.choices) == null ? void 0 : _a.map((choice) => {
5608
- const newChoice = {
5609
- description: "",
5610
- deprecated: false,
5611
- ...typeof choice === "object" ? choice : { value: choice }
5612
- };
5613
- if (newChoice.value === true) {
5614
- newChoice.value = "";
5615
- }
5616
- return newChoice;
5617
- })
5618
- };
5321
+ var { env } = process2;
5322
+ var flagForceColor;
5323
+ if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
5324
+ flagForceColor = 0;
5325
+ } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
5326
+ flagForceColor = 1;
5619
5327
  }
5620
- function supportInfoToContextOptions({ options: supportOptions, languages }) {
5621
- const detailedOptions = [
5622
- ...detailedCliOptions,
5623
- ...supportOptions.map((apiOption) => apiOptionToCliOption(apiOption))
5624
- ];
5328
+ function envForceColor() {
5329
+ if ("FORCE_COLOR" in env) {
5330
+ if (env.FORCE_COLOR === "true") {
5331
+ return 1;
5332
+ }
5333
+ if (env.FORCE_COLOR === "false") {
5334
+ return 0;
5335
+ }
5336
+ return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
5337
+ }
5338
+ }
5339
+ function translateLevel(level) {
5340
+ if (level === 0) {
5341
+ return false;
5342
+ }
5625
5343
  return {
5626
- supportOptions,
5627
- languages,
5628
- detailedOptions
5344
+ level,
5345
+ hasBasic: true,
5346
+ has256: level >= 2,
5347
+ has16m: level >= 3
5629
5348
  };
5630
5349
  }
5631
- async function getContextOptions(plugins) {
5632
- const supportInfo = await getSupportInfo({
5633
- showDeprecated: true,
5634
- plugins
5635
- });
5636
- return supportInfoToContextOptions(supportInfo);
5637
- }
5638
- function getContextOptionsWithoutPlugins() {
5639
- const supportInfo = getSupportInfoWithoutPlugins();
5640
- return supportInfoToContextOptions(supportInfo);
5641
- }
5642
-
5643
- // node_modules/camelcase/index.js
5644
- var UPPERCASE = /[\p{Lu}]/u;
5645
- var LOWERCASE = /[\p{Ll}]/u;
5646
- var LEADING_CAPITAL = /^[\p{Lu}](?![\p{Lu}])/gu;
5647
- var IDENTIFIER = /([\p{Alpha}\p{N}_]|$)/u;
5648
- var SEPARATORS = /[_.\- ]+/;
5649
- var LEADING_SEPARATORS = new RegExp("^" + SEPARATORS.source);
5650
- var SEPARATORS_AND_IDENTIFIER = new RegExp(SEPARATORS.source + IDENTIFIER.source, "gu");
5651
- var NUMBERS_AND_IDENTIFIER = new RegExp("\\d+" + IDENTIFIER.source, "gu");
5652
- var preserveCamelCase = (string, toLowerCase, toUpperCase, preserveConsecutiveUppercase2) => {
5653
- let isLastCharLower = false;
5654
- let isLastCharUpper = false;
5655
- let isLastLastCharUpper = false;
5656
- let isLastLastCharPreserved = false;
5657
- for (let index = 0; index < string.length; index++) {
5658
- const character = string[index];
5659
- isLastLastCharPreserved = index > 2 ? string[index - 3] === "-" : true;
5660
- if (isLastCharLower && UPPERCASE.test(character)) {
5661
- string = string.slice(0, index) + "-" + string.slice(index);
5662
- isLastCharLower = false;
5663
- isLastLastCharUpper = isLastCharUpper;
5664
- isLastCharUpper = true;
5665
- index++;
5666
- } else if (isLastCharUpper && isLastLastCharUpper && LOWERCASE.test(character) && (!isLastLastCharPreserved || preserveConsecutiveUppercase2)) {
5667
- string = string.slice(0, index - 1) + "-" + string.slice(index - 1);
5668
- isLastLastCharUpper = isLastCharUpper;
5669
- isLastCharUpper = false;
5670
- isLastCharLower = true;
5671
- } else {
5672
- isLastCharLower = toLowerCase(character) === character && toUpperCase(character) !== character;
5673
- isLastLastCharUpper = isLastCharUpper;
5674
- isLastCharUpper = toUpperCase(character) === character && toLowerCase(character) !== character;
5350
+ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
5351
+ const noFlagForceColor = envForceColor();
5352
+ if (noFlagForceColor !== void 0) {
5353
+ flagForceColor = noFlagForceColor;
5354
+ }
5355
+ const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
5356
+ if (forceColor === 0) {
5357
+ return 0;
5358
+ }
5359
+ if (sniffFlags) {
5360
+ if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
5361
+ return 3;
5362
+ }
5363
+ if (hasFlag("color=256")) {
5364
+ return 2;
5675
5365
  }
5676
5366
  }
5677
- return string;
5678
- };
5679
- var preserveConsecutiveUppercase = (input, toLowerCase) => {
5680
- LEADING_CAPITAL.lastIndex = 0;
5681
- return string_replace_all_default(
5682
- /* isOptionalObject*/
5683
- false,
5684
- input,
5685
- LEADING_CAPITAL,
5686
- (match) => toLowerCase(match)
5687
- );
5688
- };
5689
- var postProcess = (input, toUpperCase) => {
5690
- SEPARATORS_AND_IDENTIFIER.lastIndex = 0;
5691
- NUMBERS_AND_IDENTIFIER.lastIndex = 0;
5692
- return string_replace_all_default(
5693
- /* isOptionalObject*/
5694
- false,
5695
- string_replace_all_default(
5696
- /* isOptionalObject*/
5697
- false,
5698
- input,
5699
- NUMBERS_AND_IDENTIFIER,
5700
- (match, pattern, offset) => ["_", "-"].includes(input.charAt(offset + match.length)) ? match : toUpperCase(match)
5701
- ),
5702
- SEPARATORS_AND_IDENTIFIER,
5703
- (_, identifier) => toUpperCase(identifier)
5704
- );
5705
- };
5706
- function camelCase(input, options) {
5707
- if (!(typeof input === "string" || Array.isArray(input))) {
5708
- throw new TypeError("Expected the input to be `string | string[]`");
5367
+ if ("TF_BUILD" in env && "AGENT_NAME" in env) {
5368
+ return 1;
5369
+ }
5370
+ if (haveStream && !streamIsTTY && forceColor === void 0) {
5371
+ return 0;
5372
+ }
5373
+ const min = forceColor || 0;
5374
+ if (env.TERM === "dumb") {
5375
+ return min;
5376
+ }
5377
+ if (process2.platform === "win32") {
5378
+ const osRelease = os.release().split(".");
5379
+ if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
5380
+ return Number(osRelease[2]) >= 14931 ? 3 : 2;
5381
+ }
5382
+ return 1;
5383
+ }
5384
+ if ("CI" in env) {
5385
+ if ("GITHUB_ACTIONS" in env || "GITEA_ACTIONS" in env) {
5386
+ return 3;
5387
+ }
5388
+ if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
5389
+ return 1;
5390
+ }
5391
+ return min;
5709
5392
  }
5710
- options = {
5711
- pascalCase: false,
5712
- preserveConsecutiveUppercase: false,
5713
- ...options
5714
- };
5715
- if (Array.isArray(input)) {
5716
- input = input.map((x) => x.trim()).filter((x) => x.length).join("-");
5717
- } else {
5718
- input = input.trim();
5393
+ if ("TEAMCITY_VERSION" in env) {
5394
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
5719
5395
  }
5720
- if (input.length === 0) {
5721
- return "";
5396
+ if (env.COLORTERM === "truecolor") {
5397
+ return 3;
5722
5398
  }
5723
- const toLowerCase = options.locale === false ? (string) => string.toLowerCase() : (string) => string.toLocaleLowerCase(options.locale);
5724
- const toUpperCase = options.locale === false ? (string) => string.toUpperCase() : (string) => string.toLocaleUpperCase(options.locale);
5725
- if (input.length === 1) {
5726
- if (SEPARATORS.test(input)) {
5727
- return "";
5399
+ if (env.TERM === "xterm-kitty") {
5400
+ return 3;
5401
+ }
5402
+ if ("TERM_PROGRAM" in env) {
5403
+ const version2 = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
5404
+ switch (env.TERM_PROGRAM) {
5405
+ case "iTerm.app": {
5406
+ return version2 >= 3 ? 3 : 2;
5407
+ }
5408
+ case "Apple_Terminal": {
5409
+ return 2;
5410
+ }
5728
5411
  }
5729
- return options.pascalCase ? toUpperCase(input) : toLowerCase(input);
5730
5412
  }
5731
- const hasUpperCase = input !== toLowerCase(input);
5732
- if (hasUpperCase) {
5733
- input = preserveCamelCase(input, toLowerCase, toUpperCase, options.preserveConsecutiveUppercase);
5413
+ if (/-256(color)?$/i.test(env.TERM)) {
5414
+ return 2;
5734
5415
  }
5735
- input = input.replace(LEADING_SEPARATORS, "");
5736
- input = options.preserveConsecutiveUppercase ? preserveConsecutiveUppercase(input, toLowerCase) : toLowerCase(input);
5737
- if (options.pascalCase) {
5738
- input = toUpperCase(input.charAt(0)) + input.slice(1);
5416
+ if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
5417
+ return 1;
5739
5418
  }
5740
- return postProcess(input, toUpperCase);
5741
- }
5742
-
5743
- // src/cli/utils.js
5744
- import fs from "fs/promises";
5745
- import path from "path";
5746
-
5747
- // node_modules/sdbm/index.js
5748
- function sdbm(string) {
5749
- let hash = 0;
5750
- for (let i = 0; i < string.length; i++) {
5751
- hash = string.charCodeAt(i) + (hash << 6) + (hash << 16) - hash;
5419
+ if ("COLORTERM" in env) {
5420
+ return 1;
5752
5421
  }
5753
- return hash >>> 0;
5422
+ return min;
5423
+ }
5424
+ function createSupportsColor(stream, options = {}) {
5425
+ const level = _supportsColor(stream, {
5426
+ streamIsTTY: stream && stream.isTTY,
5427
+ ...options
5428
+ });
5429
+ return translateLevel(level);
5754
5430
  }
5431
+ var supportsColor = {
5432
+ stdout: createSupportsColor({ isTTY: tty.isatty(1) }),
5433
+ stderr: createSupportsColor({ isTTY: tty.isatty(2) })
5434
+ };
5435
+ var supports_color_default = supportsColor;
5755
5436
 
5756
- // src/cli/utils.js
5757
- import { __internal as sharedWithCli2 } from "../index.mjs";
5758
- var printToScreen = console.log.bind(console);
5759
- function groupBy(array2, iteratee) {
5760
- const result = /* @__PURE__ */ Object.create(null);
5761
- for (const value of array2) {
5762
- const key = iteratee(value);
5763
- if (Array.isArray(result[key])) {
5764
- result[key].push(value);
5765
- } else {
5766
- result[key] = [value];
5767
- }
5437
+ // node_modules/chalk/source/utilities.js
5438
+ function stringReplaceAll2(string, substring, replacer) {
5439
+ let index = string.indexOf(substring);
5440
+ if (index === -1) {
5441
+ return string;
5768
5442
  }
5769
- return result;
5443
+ const substringLength = substring.length;
5444
+ let endIndex = 0;
5445
+ let returnValue = "";
5446
+ do {
5447
+ returnValue += string.slice(endIndex, index) + substring + replacer;
5448
+ endIndex = index + substringLength;
5449
+ index = string.indexOf(substring, endIndex);
5450
+ } while (index !== -1);
5451
+ returnValue += string.slice(endIndex);
5452
+ return returnValue;
5770
5453
  }
5771
- function pick(object, keys) {
5772
- const entries = keys.map((key) => [key, object[key]]);
5773
- return Object.fromEntries(entries);
5454
+ function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
5455
+ let endIndex = 0;
5456
+ let returnValue = "";
5457
+ do {
5458
+ const gotCR = string[index - 1] === "\r";
5459
+ returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
5460
+ endIndex = index + 1;
5461
+ index = string.indexOf("\n", endIndex);
5462
+ } while (index !== -1);
5463
+ returnValue += string.slice(endIndex);
5464
+ return returnValue;
5774
5465
  }
5775
- function createHash(source) {
5776
- return String(sdbm(source));
5466
+
5467
+ // node_modules/chalk/source/index.js
5468
+ var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;
5469
+ var GENERATOR = Symbol("GENERATOR");
5470
+ var STYLER = Symbol("STYLER");
5471
+ var IS_EMPTY = Symbol("IS_EMPTY");
5472
+ var levelMapping = [
5473
+ "ansi",
5474
+ "ansi",
5475
+ "ansi256",
5476
+ "ansi16m"
5477
+ ];
5478
+ var styles2 = /* @__PURE__ */ Object.create(null);
5479
+ var applyOptions = (object, options = {}) => {
5480
+ if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
5481
+ throw new Error("The `level` option should be an integer from 0 to 3");
5482
+ }
5483
+ const colorLevel = stdoutColor ? stdoutColor.level : 0;
5484
+ object.level = options.level === void 0 ? colorLevel : options.level;
5485
+ };
5486
+ var chalkFactory = (options) => {
5487
+ const chalk2 = (...strings) => strings.join(" ");
5488
+ applyOptions(chalk2, options);
5489
+ Object.setPrototypeOf(chalk2, createChalk.prototype);
5490
+ return chalk2;
5491
+ };
5492
+ function createChalk(options) {
5493
+ return chalkFactory(options);
5777
5494
  }
5778
- async function statSafe(filePath) {
5779
- try {
5780
- return await fs.stat(filePath);
5781
- } catch (error) {
5782
- if (error.code !== "ENOENT") {
5783
- throw error;
5495
+ Object.setPrototypeOf(createChalk.prototype, Function.prototype);
5496
+ for (const [styleName, style] of Object.entries(ansi_styles_default)) {
5497
+ styles2[styleName] = {
5498
+ get() {
5499
+ const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
5500
+ Object.defineProperty(this, styleName, { value: builder });
5501
+ return builder;
5784
5502
  }
5785
- }
5503
+ };
5786
5504
  }
5787
- async function lstatSafe(filePath) {
5788
- try {
5789
- return await fs.lstat(filePath);
5790
- } catch (error) {
5791
- if (error.code !== "ENOENT") {
5792
- throw error;
5505
+ styles2.visible = {
5506
+ get() {
5507
+ const builder = createBuilder(this, this[STYLER], true);
5508
+ Object.defineProperty(this, "visible", { value: builder });
5509
+ return builder;
5510
+ }
5511
+ };
5512
+ var getModelAnsi = (model, level, type, ...arguments_) => {
5513
+ if (model === "rgb") {
5514
+ if (level === "ansi16m") {
5515
+ return ansi_styles_default[type].ansi16m(...arguments_);
5793
5516
  }
5517
+ if (level === "ansi256") {
5518
+ return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
5519
+ }
5520
+ return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
5794
5521
  }
5795
- }
5796
- function isJson(value) {
5797
- try {
5798
- JSON.parse(value);
5799
- return true;
5800
- } catch {
5801
- return false;
5522
+ if (model === "hex") {
5523
+ return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
5802
5524
  }
5803
- }
5804
- var normalizeToPosix = path.sep === "\\" ? (filepath) => string_replace_all_default(
5805
- /* isOptionalObject*/
5806
- false,
5807
- filepath,
5808
- "\\",
5809
- "/"
5810
- ) : (filepath) => filepath;
5811
- var {
5812
- isNonEmptyArray,
5813
- partition,
5814
- omit
5815
- } = sharedWithCli2.utils;
5816
-
5817
- // src/cli/options/minimist.js
5818
- var import_minimist = __toESM(require_minimist(), 1);
5819
- var PLACEHOLDER = null;
5820
- function minimistParse(args, options) {
5821
- const boolean = options.boolean ?? [];
5822
- const defaults = options.default ?? {};
5823
- const booleanWithoutDefault = boolean.filter((key) => !(key in defaults));
5824
- const newDefaults = {
5825
- ...defaults,
5826
- ...Object.fromEntries(
5827
- booleanWithoutDefault.map((key) => [key, PLACEHOLDER])
5828
- )
5525
+ return ansi_styles_default[type][model](...arguments_);
5526
+ };
5527
+ var usedModels = ["rgb", "hex", "ansi256"];
5528
+ for (const model of usedModels) {
5529
+ styles2[model] = {
5530
+ get() {
5531
+ const { level } = this;
5532
+ return function(...arguments_) {
5533
+ const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
5534
+ return createBuilder(this, styler, this[IS_EMPTY]);
5535
+ };
5536
+ }
5829
5537
  };
5830
- const parsed = (0, import_minimist.default)(args, { ...options, default: newDefaults });
5831
- return Object.fromEntries(
5832
- Object.entries(parsed).filter(([, value]) => value !== PLACEHOLDER)
5833
- );
5834
- }
5835
-
5836
- // src/cli/options/create-minimist-options.js
5837
- function createMinimistOptions(detailedOptions) {
5838
- const booleanNames = [];
5839
- const stringNames = [];
5840
- const defaultValues = {};
5841
- for (const option of detailedOptions) {
5842
- const { name, alias, type } = option;
5843
- const names = type === "boolean" ? booleanNames : stringNames;
5844
- names.push(name);
5845
- if (alias) {
5846
- names.push(alias);
5538
+ const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
5539
+ styles2[bgModel] = {
5540
+ get() {
5541
+ const { level } = this;
5542
+ return function(...arguments_) {
5543
+ const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
5544
+ return createBuilder(this, styler, this[IS_EMPTY]);
5545
+ };
5847
5546
  }
5848
- if (!option.deprecated && (!option.forwardToApi || name === "plugin") && option.default !== void 0) {
5849
- defaultValues[option.name] = option.default;
5547
+ };
5548
+ }
5549
+ var proto = Object.defineProperties(() => {
5550
+ }, {
5551
+ ...styles2,
5552
+ level: {
5553
+ enumerable: true,
5554
+ get() {
5555
+ return this[GENERATOR].level;
5556
+ },
5557
+ set(level) {
5558
+ this[GENERATOR].level = level;
5850
5559
  }
5851
5560
  }
5561
+ });
5562
+ var createStyler = (open, close, parent) => {
5563
+ let openAll;
5564
+ let closeAll;
5565
+ if (parent === void 0) {
5566
+ openAll = open;
5567
+ closeAll = close;
5568
+ } else {
5569
+ openAll = parent.openAll + open;
5570
+ closeAll = close + parent.closeAll;
5571
+ }
5852
5572
  return {
5853
- // we use vnopts' AliasSchema to handle aliases for better error messages
5854
- alias: {},
5855
- boolean: booleanNames,
5856
- string: stringNames,
5857
- default: defaultValues
5573
+ open,
5574
+ close,
5575
+ openAll,
5576
+ closeAll,
5577
+ parent
5858
5578
  };
5859
- }
5579
+ };
5580
+ var createBuilder = (self, _styler, _isEmpty) => {
5581
+ const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
5582
+ Object.setPrototypeOf(builder, proto);
5583
+ builder[GENERATOR] = self;
5584
+ builder[STYLER] = _styler;
5585
+ builder[IS_EMPTY] = _isEmpty;
5586
+ return builder;
5587
+ };
5588
+ var applyStyle = (self, string) => {
5589
+ if (self.level <= 0 || !string) {
5590
+ return self[IS_EMPTY] ? "" : string;
5591
+ }
5592
+ let styler = self[STYLER];
5593
+ if (styler === void 0) {
5594
+ return string;
5595
+ }
5596
+ const { openAll, closeAll } = styler;
5597
+ if (string.includes("\x1B")) {
5598
+ while (styler !== void 0) {
5599
+ string = stringReplaceAll2(string, styler.close, styler.open);
5600
+ styler = styler.parent;
5601
+ }
5602
+ }
5603
+ const lfIndex = string.indexOf("\n");
5604
+ if (lfIndex !== -1) {
5605
+ string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
5606
+ }
5607
+ return openAll + string + closeAll;
5608
+ };
5609
+ Object.defineProperties(createChalk.prototype, styles2);
5610
+ var chalk = createChalk();
5611
+ var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
5612
+ var source_default = chalk;
5860
5613
 
5861
5614
  // node_modules/leven/index.js
5862
5615
  var array = [];
@@ -5973,234 +5726,135 @@ function parseArgv(rawArguments, detailedOptions, logger, keys) {
5973
5726
  _: (_a = normalized._) == null ? void 0 : _a.map(String),
5974
5727
  get __raw() {
5975
5728
  return argv;
5976
- }
5977
- };
5978
- }
5979
- var { detailedOptions: detailedOptionsWithoutPlugins } = getContextOptionsWithoutPlugins();
5980
- function parseArgvWithoutPlugins(rawArguments, logger, keys) {
5981
- return parseArgv(
5982
- rawArguments,
5983
- detailedOptionsWithoutPlugins,
5984
- logger,
5985
- typeof keys === "string" ? [keys] : keys
5986
- );
5987
- }
5988
-
5989
- // src/cli/context.js
5990
- var _stack;
5991
- var Context = class {
5992
- constructor({
5993
- rawArguments,
5994
- logger
5995
- }) {
5996
- __privateAdd(this, _stack, []);
5997
- this.rawArguments = rawArguments;
5998
- this.logger = logger;
5999
- }
6000
- async init() {
6001
- const {
6002
- rawArguments,
6003
- logger
6004
- } = this;
6005
- const {
6006
- plugins
6007
- } = parseArgvWithoutPlugins(rawArguments, logger, ["plugin"]);
6008
- await this.pushContextPlugins(plugins);
6009
- const argv = parseArgv(rawArguments, this.detailedOptions, logger);
6010
- this.argv = argv;
6011
- this.filePatterns = argv._;
6012
- }
6013
- /**
6014
- * @param {string[]} plugins
6015
- */
6016
- async pushContextPlugins(plugins) {
6017
- const options = await getContextOptions(plugins);
6018
- __privateGet(this, _stack).push(options);
6019
- Object.assign(this, options);
6020
- }
6021
- popContextPlugins() {
6022
- __privateGet(this, _stack).pop();
6023
- Object.assign(this, at_default(
6024
- /* isOptionalObject*/
6025
- false,
6026
- __privateGet(this, _stack),
6027
- -1
6028
- ));
6029
- }
6030
- // eslint-disable-next-line getter-return
6031
- get performanceTestFlag() {
6032
- const {
6033
- debugBenchmark,
6034
- debugRepeat
6035
- } = this.argv;
6036
- if (debugBenchmark) {
6037
- return {
6038
- name: "--debug-benchmark",
6039
- debugBenchmark: true
6040
- };
6041
- }
6042
- if (debugRepeat > 0) {
6043
- return {
6044
- name: "--debug-repeat",
6045
- debugRepeat
6046
- };
6047
- }
6048
- const {
6049
- PRETTIER_PERF_REPEAT
6050
- } = process.env;
6051
- if (PRETTIER_PERF_REPEAT && /^\d+$/.test(PRETTIER_PERF_REPEAT)) {
6052
- return {
6053
- name: "PRETTIER_PERF_REPEAT (environment variable)",
6054
- debugRepeat: Number(PRETTIER_PERF_REPEAT)
6055
- };
6056
- }
6057
- }
6058
- };
6059
- _stack = new WeakMap();
6060
- var context_default = Context;
6061
-
6062
- // src/cli/constants.evaluate.js
6063
- var categoryOrder = [
6064
- "Output",
6065
- "Format",
6066
- "Config",
6067
- "Editor",
6068
- "Other"
6069
- ];
6070
- var usageSummary = "Usage: prettier [options] [file/dir/glob ...]\n\nBy default, output is written to stdout.\nStdin is read if it is piped to Prettier and no files are given.";
6071
-
6072
- // src/cli/usage.js
6073
- var OPTION_USAGE_THRESHOLD = 25;
6074
- var CHOICE_USAGE_MARGIN = 3;
6075
- var CHOICE_USAGE_INDENTATION = 2;
6076
- function indent(str, spaces) {
6077
- return string_replace_all_default(
6078
- /* isOptionalObject*/
6079
- false,
6080
- str,
6081
- /^/gm,
6082
- " ".repeat(spaces)
6083
- );
6084
- }
6085
- function createDefaultValueDisplay(value) {
6086
- return Array.isArray(value) ? `[${value.map(createDefaultValueDisplay).join(", ")}]` : value;
6087
- }
6088
- function getOptionDefaultValue(context, optionName) {
6089
- var _a;
6090
- const option = context.detailedOptions.find(({
6091
- name
6092
- }) => name === optionName);
6093
- if ((option == null ? void 0 : option.default) !== void 0) {
6094
- return option.default;
6095
- }
6096
- const optionCamelName = camelCase(optionName);
6097
- return formatOptionsHiddenDefaults[optionCamelName] ?? ((_a = context.supportOptions.find((option2) => !option2.deprecated && option2.name === optionCamelName)) == null ? void 0 : _a.default);
6098
- }
6099
- function createOptionUsageHeader(option) {
6100
- const name = `--${option.name}`;
6101
- const alias = option.alias ? `-${option.alias},` : null;
6102
- const type = createOptionUsageType(option);
6103
- return [alias, name, type].filter(Boolean).join(" ");
6104
- }
6105
- function createOptionUsageRow(header, content, threshold) {
6106
- const separator = header.length >= threshold ? `
6107
- ${" ".repeat(threshold)}` : " ".repeat(threshold - header.length);
6108
- const description = string_replace_all_default(
6109
- /* isOptionalObject*/
6110
- false,
6111
- content,
6112
- "\n",
6113
- `
6114
- ${" ".repeat(threshold)}`
6115
- );
6116
- return `${header}${separator}${description}`;
6117
- }
6118
- function createOptionUsageType(option) {
6119
- switch (option.type) {
6120
- case "boolean":
6121
- return null;
6122
- case "choice":
6123
- return `<${option.choices.filter((choice) => !choice.deprecated).map((choice) => choice.value).join("|")}>`;
6124
- default:
6125
- return `<${option.type}>`;
6126
- }
6127
- }
6128
- function createChoiceUsages(choices, margin, indentation) {
6129
- const activeChoices = choices.filter((choice) => !choice.deprecated);
6130
- const threshold = Math.max(0, ...activeChoices.map((choice) => choice.value.length)) + margin;
6131
- return activeChoices.map((choice) => indent(createOptionUsageRow(choice.value, choice.description, threshold), indentation));
6132
- }
6133
- function createOptionUsage(context, option, threshold) {
6134
- const header = createOptionUsageHeader(option);
6135
- const optionDefaultValue = getOptionDefaultValue(context, option.name);
6136
- return createOptionUsageRow(header, `${option.description}${optionDefaultValue === void 0 ? "" : `
6137
- Defaults to ${createDefaultValueDisplay(optionDefaultValue)}.`}`, threshold);
6138
- }
6139
- function getOptionsWithOpposites(options) {
6140
- const optionsWithOpposites = options.map((option) => [option.description ? option : null, option.oppositeDescription ? {
6141
- ...option,
6142
- name: `no-${option.name}`,
6143
- type: "boolean",
6144
- description: option.oppositeDescription
6145
- } : null]);
6146
- return optionsWithOpposites.flat().filter(Boolean);
6147
- }
6148
- function createUsage(context) {
6149
- const sortedOptions = context.detailedOptions.sort((optionA, optionB) => optionA.name.localeCompare(optionB.name));
6150
- const options = getOptionsWithOpposites(sortedOptions).filter(
6151
- // remove unnecessary option (e.g. `semi`, `color`, etc.), which is only used for --help <flag>
6152
- (option) => !(option.type === "boolean" && option.oppositeDescription && !option.name.startsWith("no-"))
6153
- );
6154
- const groupedOptions = groupBy(options, (option) => option.category);
6155
- const firstCategories = categoryOrder.slice(0, -1);
6156
- const lastCategories = categoryOrder.slice(-1);
6157
- const restCategories = Object.keys(groupedOptions).filter((category) => !categoryOrder.includes(category));
6158
- const allCategories = [...firstCategories, ...restCategories, ...lastCategories];
6159
- const optionsUsage = allCategories.map((category) => {
6160
- const categoryOptions = groupedOptions[category].map((option) => createOptionUsage(context, option, OPTION_USAGE_THRESHOLD)).join("\n");
6161
- return `${category} options:
6162
-
6163
- ${indent(categoryOptions, 2)}`;
6164
- });
6165
- return [usageSummary, ...optionsUsage, ""].join("\n\n");
5729
+ }
5730
+ };
6166
5731
  }
6167
- function createPluginDefaults(pluginDefaults) {
6168
- if (!pluginDefaults || Object.keys(pluginDefaults).length === 0) {
6169
- return "";
6170
- }
6171
- const defaults = Object.entries(pluginDefaults).sort(([pluginNameA], [pluginNameB]) => pluginNameA.localeCompare(pluginNameB)).map(([plugin, value]) => `* ${plugin}: ${createDefaultValueDisplay(value)}`).join("\n");
6172
- return `
6173
- Plugin defaults:
6174
- ${defaults}`;
5732
+ var { detailedOptions: detailedOptionsWithoutPlugins } = getContextOptionsWithoutPlugins();
5733
+ function parseArgvWithoutPlugins(rawArguments, logger, keys) {
5734
+ return parseArgv(
5735
+ rawArguments,
5736
+ detailedOptionsWithoutPlugins,
5737
+ logger,
5738
+ typeof keys === "string" ? [keys] : keys
5739
+ );
6175
5740
  }
6176
- function createDetailedUsage(context, flag) {
6177
- const option = getOptionsWithOpposites(context.detailedOptions).find((option2) => option2.name === flag || option2.alias === flag);
6178
- const header = createOptionUsageHeader(option);
6179
- const description = `
6180
-
6181
- ${indent(option.description, 2)}`;
6182
- const choices = option.type !== "choice" ? "" : `
6183
5741
 
6184
- Valid options:
5742
+ // src/cli/context.js
5743
+ var _stack;
5744
+ var Context = class {
5745
+ constructor({
5746
+ rawArguments,
5747
+ logger
5748
+ }) {
5749
+ __privateAdd(this, _stack, []);
5750
+ this.rawArguments = rawArguments;
5751
+ this.logger = logger;
5752
+ }
5753
+ async init() {
5754
+ const {
5755
+ rawArguments,
5756
+ logger
5757
+ } = this;
5758
+ const {
5759
+ plugins
5760
+ } = parseArgvWithoutPlugins(rawArguments, logger, ["plugin"]);
5761
+ await this.pushContextPlugins(plugins);
5762
+ const argv = parseArgv(rawArguments, this.detailedOptions, logger);
5763
+ this.argv = argv;
5764
+ this.filePatterns = argv._;
5765
+ }
5766
+ /**
5767
+ * @param {string[]} plugins
5768
+ */
5769
+ async pushContextPlugins(plugins) {
5770
+ const options = await getContextOptions(plugins);
5771
+ __privateGet(this, _stack).push(options);
5772
+ Object.assign(this, options);
5773
+ }
5774
+ popContextPlugins() {
5775
+ __privateGet(this, _stack).pop();
5776
+ Object.assign(this, at_default(
5777
+ /* isOptionalObject*/
5778
+ false,
5779
+ __privateGet(this, _stack),
5780
+ -1
5781
+ ));
5782
+ }
5783
+ // eslint-disable-next-line getter-return
5784
+ get performanceTestFlag() {
5785
+ const {
5786
+ debugBenchmark,
5787
+ debugRepeat
5788
+ } = this.argv;
5789
+ if (debugBenchmark) {
5790
+ return {
5791
+ name: "--debug-benchmark",
5792
+ debugBenchmark: true
5793
+ };
5794
+ }
5795
+ if (debugRepeat > 0) {
5796
+ return {
5797
+ name: "--debug-repeat",
5798
+ debugRepeat
5799
+ };
5800
+ }
5801
+ const {
5802
+ PRETTIER_PERF_REPEAT
5803
+ } = process.env;
5804
+ if (PRETTIER_PERF_REPEAT && /^\d+$/.test(PRETTIER_PERF_REPEAT)) {
5805
+ return {
5806
+ name: "PRETTIER_PERF_REPEAT (environment variable)",
5807
+ debugRepeat: Number(PRETTIER_PERF_REPEAT)
5808
+ };
5809
+ }
5810
+ }
5811
+ };
5812
+ _stack = new WeakMap();
5813
+ var context_default = Context;
6185
5814
 
6186
- ${createChoiceUsages(option.choices, CHOICE_USAGE_MARGIN, CHOICE_USAGE_INDENTATION).join("\n")}`;
6187
- const optionDefaultValue = getOptionDefaultValue(context, option.name);
6188
- const defaults = optionDefaultValue !== void 0 ? `
5815
+ // src/cli/file-info.js
5816
+ var import_fast_json_stable_stringify = __toESM(require_fast_json_stable_stringify(), 1);
5817
+ import { format, getFileInfo } from "../index.mjs";
5818
+ async function logFileInfoOrDie(context) {
5819
+ const {
5820
+ fileInfo: file,
5821
+ ignorePath,
5822
+ withNodeModules,
5823
+ plugins,
5824
+ config
5825
+ } = context.argv;
5826
+ const fileInfo = await getFileInfo(file, {
5827
+ ignorePath,
5828
+ withNodeModules,
5829
+ plugins,
5830
+ resolveConfig: config !== false
5831
+ });
5832
+ printToScreen(await format((0, import_fast_json_stable_stringify.default)(fileInfo), { parser: "json" }));
5833
+ }
5834
+ var file_info_default = logFileInfoOrDie;
6189
5835
 
6190
- Default: ${createDefaultValueDisplay(optionDefaultValue)}` : "";
6191
- const pluginDefaults = createPluginDefaults(option.pluginDefaults);
6192
- return `${header}${description}${choices}${defaults}${pluginDefaults}`;
5836
+ // src/cli/find-config-path.js
5837
+ import path2 from "path";
5838
+ import { resolveConfigFile } from "../index.mjs";
5839
+ async function logResolvedConfigPathOrDie(context) {
5840
+ const file = context.argv.findConfigPath;
5841
+ const configFile = await resolveConfigFile(file);
5842
+ if (configFile) {
5843
+ printToScreen(normalizeToPosix(path2.relative(process.cwd(), configFile)));
5844
+ } else {
5845
+ throw new Error(`Can not find configure file for "${file}".`);
5846
+ }
6193
5847
  }
5848
+ var find_config_path_default = logResolvedConfigPathOrDie;
6194
5849
 
6195
5850
  // src/cli/format.js
6196
5851
  import fs5 from "fs/promises";
6197
- import path8 from "path";
5852
+ import path9 from "path";
6198
5853
  var import_diff = __toESM(require_create(), 1);
6199
5854
  import * as prettier from "../index.mjs";
6200
- import mockable2 from "./internal.mjs";
6201
5855
 
6202
5856
  // src/cli/expand-patterns.js
6203
- import path2 from "path";
5857
+ import path3 from "path";
6204
5858
  async function* expandPatterns(context) {
6205
5859
  const seen = /* @__PURE__ */ new Set();
6206
5860
  let noResults = true;
@@ -6216,7 +5870,7 @@ async function* expandPatterns(context) {
6216
5870
  };
6217
5871
  continue;
6218
5872
  }
6219
- const filename = path2.resolve(filePath);
5873
+ const filename = path3.resolve(filePath);
6220
5874
  if (seen.has(filename)) {
6221
5875
  continue;
6222
5876
  }
@@ -6245,16 +5899,20 @@ async function* expandPatternsInternal(context) {
6245
5899
  const cwd2 = process.cwd();
6246
5900
  const entries = [];
6247
5901
  for (const pattern of context.filePatterns) {
6248
- const absolutePath = path2.resolve(cwd2, pattern);
5902
+ const absolutePath = path3.resolve(cwd2, pattern);
6249
5903
  if (containsIgnoredPathSegment(absolutePath, cwd2, silentlyIgnoredDirs)) {
6250
5904
  continue;
6251
5905
  }
6252
5906
  const stat = await lstatSafe(absolutePath);
6253
5907
  if (stat) {
6254
5908
  if (stat.isSymbolicLink()) {
6255
- yield {
6256
- error: `Explicitly specified pattern "${pattern}" is a symbolic link.`
6257
- };
5909
+ if (context.argv.errorOnUnmatchedPattern !== false) {
5910
+ yield {
5911
+ error: `Explicitly specified pattern "${pattern}" is a symbolic link.`
5912
+ };
5913
+ } else {
5914
+ context.logger.debug(`Skipping pattern "${pattern}", as it is a symbolic link.`);
5915
+ }
6258
5916
  } else if (stat.isFile()) {
6259
5917
  entries.push({
6260
5918
  type: "file",
@@ -6262,7 +5920,7 @@ async function* expandPatternsInternal(context) {
6262
5920
  input: pattern
6263
5921
  });
6264
5922
  } else if (stat.isDirectory()) {
6265
- const relativePath = path2.relative(cwd2, absolutePath) || ".";
5923
+ const relativePath = path3.relative(cwd2, absolutePath) || ".";
6266
5924
  const prefix = escapePathForGlob(fixWindowsSlashes(relativePath));
6267
5925
  entries.push({
6268
5926
  type: "dir",
@@ -6321,236 +5979,65 @@ var errorMessages = {
6321
5979
  },
6322
5980
  emptyResults: {
6323
5981
  file: "Explicitly specified file was ignored due to negative glob patterns",
6324
- dir: "No supported files were found in the directory",
6325
- glob: "No files matching the pattern were found"
6326
- }
6327
- };
6328
- function containsIgnoredPathSegment(absolutePath, cwd2, ignoredDirectories) {
6329
- return path2.relative(cwd2, absolutePath).split(path2.sep).some((dir) => ignoredDirectories.includes(dir));
6330
- }
6331
- function sortPaths(paths) {
6332
- return paths.sort((a, b) => a.localeCompare(b));
6333
- }
6334
- function escapePathForGlob(path10) {
6335
- return string_replace_all_default(
6336
- /* isOptionalObject*/
6337
- false,
6338
- string_replace_all_default(
6339
- /* isOptionalObject*/
6340
- false,
6341
- fastGlob.escapePath(
6342
- string_replace_all_default(
6343
- /* isOptionalObject*/
6344
- false,
6345
- path10,
6346
- "\\",
6347
- "\0"
6348
- )
6349
- // Workaround for fast-glob#262 (part 1)
6350
- ),
6351
- "\\!",
6352
- "@(!)"
6353
- ),
6354
- "\0",
6355
- "@(\\\\)"
6356
- );
6357
- }
6358
- var fixWindowsSlashes = normalizeToPosix;
6359
-
6360
- // src/cli/options/get-options-for-file.js
6361
- var import_dashify2 = __toESM(require_dashify(), 1);
6362
- import { resolveConfig } from "../index.mjs";
6363
- function getOptions(argv, detailedOptions) {
6364
- return Object.fromEntries(
6365
- detailedOptions.filter(({ forwardToApi }) => forwardToApi).map(({ forwardToApi, name }) => [forwardToApi, argv[name]])
6366
- );
6367
- }
6368
- function cliifyOptions(object, apiDetailedOptionMap) {
6369
- return Object.fromEntries(
6370
- Object.entries(object || {}).map(([key, value]) => {
6371
- const apiOption = apiDetailedOptionMap[key];
6372
- const cliKey = apiOption ? apiOption.name : key;
6373
- return [(0, import_dashify2.default)(cliKey), value];
6374
- })
6375
- );
6376
- }
6377
- function createApiDetailedOptionMap(detailedOptions) {
6378
- return Object.fromEntries(
6379
- detailedOptions.filter(
6380
- (option) => option.forwardToApi && option.forwardToApi !== option.name
6381
- ).map((option) => [option.forwardToApi, option])
6382
- );
6383
- }
6384
- function parseArgsToOptions(context, overrideDefaults) {
6385
- const minimistOptions = createMinimistOptions(context.detailedOptions);
6386
- const apiDetailedOptionMap = createApiDetailedOptionMap(
6387
- context.detailedOptions
6388
- );
6389
- return getOptions(
6390
- normalize_cli_options_default(
6391
- minimistParse(context.rawArguments, {
6392
- string: minimistOptions.string,
6393
- boolean: minimistOptions.boolean,
6394
- default: cliifyOptions(overrideDefaults, apiDetailedOptionMap)
6395
- }),
6396
- context.detailedOptions,
6397
- { logger: false }
6398
- ),
6399
- context.detailedOptions
6400
- );
6401
- }
6402
- async function getOptionsOrDie(context, filePath) {
6403
- try {
6404
- if (context.argv.config === false) {
6405
- context.logger.debug(
6406
- "'--no-config' option found, skip loading config file."
6407
- );
6408
- return null;
6409
- }
6410
- context.logger.debug(
6411
- context.argv.config ? `load config file from '${context.argv.config}'` : `resolve config from '${filePath}'`
6412
- );
6413
- const options = await resolveConfig(filePath, {
6414
- editorconfig: context.argv.editorconfig,
6415
- config: context.argv.config
6416
- });
6417
- context.logger.debug("loaded options `" + JSON.stringify(options) + "`");
6418
- return options;
6419
- } catch (error) {
6420
- context.logger.error(
6421
- `Invalid configuration for file "${filePath}":
6422
- ` + error.message
6423
- );
6424
- process.exit(2);
6425
- }
6426
- }
6427
- function applyConfigPrecedence(context, options) {
6428
- try {
6429
- switch (context.argv.configPrecedence) {
6430
- case "cli-override":
6431
- return parseArgsToOptions(context, options);
6432
- case "file-override":
6433
- return { ...parseArgsToOptions(context), ...options };
6434
- case "prefer-file":
6435
- return options || parseArgsToOptions(context);
6436
- }
6437
- } catch (error) {
6438
- context.logger.error(error.toString());
6439
- process.exit(2);
5982
+ dir: "No supported files were found in the directory",
5983
+ glob: "No files matching the pattern were found"
6440
5984
  }
5985
+ };
5986
+ function containsIgnoredPathSegment(absolutePath, cwd2, ignoredDirectories) {
5987
+ return path3.relative(cwd2, absolutePath).split(path3.sep).some((dir) => ignoredDirectories.includes(dir));
6441
5988
  }
6442
- async function getOptionsForFile(context, filepath) {
6443
- const options = await getOptionsOrDie(context, filepath);
6444
- const hasPlugins = options == null ? void 0 : options.plugins;
6445
- if (hasPlugins) {
6446
- await context.pushContextPlugins(options.plugins);
6447
- }
6448
- const appliedOptions = {
6449
- filepath,
6450
- ...applyConfigPrecedence(
6451
- context,
6452
- options && normalizeOptions(options, context.supportOptions, {
6453
- logger: context.logger
6454
- })
6455
- )
6456
- };
6457
- context.logger.debug(
6458
- `applied config-precedence (${context.argv.configPrecedence}): ${JSON.stringify(appliedOptions)}`
6459
- );
6460
- if (hasPlugins) {
6461
- context.popContextPlugins();
6462
- }
6463
- return appliedOptions;
5989
+ function sortPaths(paths) {
5990
+ return paths.sort((a, b) => a.localeCompare(b));
6464
5991
  }
6465
- var get_options_for_file_default = getOptionsForFile;
6466
-
6467
- // src/cli/is-tty.js
6468
- import mockable from "./internal.mjs";
6469
- function isTTY() {
6470
- return process.stdout.isTTY && !mockable.isCI();
5992
+ function escapePathForGlob(path10) {
5993
+ return string_replace_all_default(
5994
+ /* isOptionalObject*/
5995
+ false,
5996
+ string_replace_all_default(
5997
+ /* isOptionalObject*/
5998
+ false,
5999
+ fastGlob.escapePath(
6000
+ string_replace_all_default(
6001
+ /* isOptionalObject*/
6002
+ false,
6003
+ path10,
6004
+ "\\",
6005
+ "\0"
6006
+ )
6007
+ // Workaround for fast-glob#262 (part 1)
6008
+ ),
6009
+ "\\!",
6010
+ "@(!)"
6011
+ ),
6012
+ "\0",
6013
+ "@(\\\\)"
6014
+ );
6471
6015
  }
6016
+ var fixWindowsSlashes = normalizeToPosix;
6472
6017
 
6473
6018
  // src/cli/find-cache-file.js
6474
6019
  import fs4 from "fs/promises";
6475
6020
  import os2 from "os";
6476
- import path7 from "path";
6021
+ import path8 from "path";
6477
6022
 
6478
6023
  // node_modules/find-cache-dir/index.js
6479
6024
  var import_common_path_prefix = __toESM(require_common_path_prefix(), 1);
6480
6025
  import process4 from "process";
6481
- import path6 from "path";
6026
+ import path7 from "path";
6482
6027
  import fs3 from "fs";
6483
6028
 
6484
6029
  // node_modules/pkg-dir/index.js
6485
- import path5 from "path";
6030
+ import path6 from "path";
6486
6031
 
6487
6032
  // node_modules/pkg-dir/node_modules/find-up/index.js
6488
- import path4 from "path";
6033
+ import path5 from "path";
6489
6034
  import { fileURLToPath as fileURLToPath2 } from "url";
6490
6035
 
6491
6036
  // node_modules/pkg-dir/node_modules/locate-path/index.js
6492
6037
  import process3 from "process";
6493
- import path3 from "path";
6038
+ import path4 from "path";
6494
6039
  import fs2, { promises as fsPromises } from "fs";
6495
6040
  import { fileURLToPath } from "url";
6496
-
6497
- // node_modules/pkg-dir/node_modules/yocto-queue/index.js
6498
- var Node = class {
6499
- value;
6500
- next;
6501
- constructor(value) {
6502
- this.value = value;
6503
- }
6504
- };
6505
- var _head, _tail, _size;
6506
- var Queue = class {
6507
- constructor() {
6508
- __privateAdd(this, _head, void 0);
6509
- __privateAdd(this, _tail, void 0);
6510
- __privateAdd(this, _size, void 0);
6511
- this.clear();
6512
- }
6513
- enqueue(value) {
6514
- const node = new Node(value);
6515
- if (__privateGet(this, _head)) {
6516
- __privateGet(this, _tail).next = node;
6517
- __privateSet(this, _tail, node);
6518
- } else {
6519
- __privateSet(this, _head, node);
6520
- __privateSet(this, _tail, node);
6521
- }
6522
- __privateWrapper(this, _size)._++;
6523
- }
6524
- dequeue() {
6525
- const current = __privateGet(this, _head);
6526
- if (!current) {
6527
- return;
6528
- }
6529
- __privateSet(this, _head, __privateGet(this, _head).next);
6530
- __privateWrapper(this, _size)._--;
6531
- return current.value;
6532
- }
6533
- clear() {
6534
- __privateSet(this, _head, void 0);
6535
- __privateSet(this, _tail, void 0);
6536
- __privateSet(this, _size, 0);
6537
- }
6538
- get size() {
6539
- return __privateGet(this, _size);
6540
- }
6541
- *[Symbol.iterator]() {
6542
- let current = __privateGet(this, _head);
6543
- while (current) {
6544
- yield current.value;
6545
- current = current.next;
6546
- }
6547
- }
6548
- };
6549
- _head = new WeakMap();
6550
- _tail = new WeakMap();
6551
- _size = new WeakMap();
6552
-
6553
- // node_modules/pkg-dir/node_modules/locate-path/index.js
6554
6041
  var typeMappings = {
6555
6042
  directory: "isDirectory",
6556
6043
  file: "isFile"
@@ -6573,7 +6060,7 @@ function locatePathSync(paths, {
6573
6060
  const statFunction = allowSymlinks ? fs2.statSync : fs2.lstatSync;
6574
6061
  for (const path_ of paths) {
6575
6062
  try {
6576
- const stat = statFunction(path3.resolve(cwd2, path_), {
6063
+ const stat = statFunction(path4.resolve(cwd2, path_), {
6577
6064
  throwIfNoEntry: false
6578
6065
  });
6579
6066
  if (!stat) {
@@ -6591,8 +6078,8 @@ function locatePathSync(paths, {
6591
6078
  var toPath2 = (urlOrPath) => urlOrPath instanceof URL ? fileURLToPath2(urlOrPath) : urlOrPath;
6592
6079
  var findUpStop = Symbol("findUpStop");
6593
6080
  function findUpMultipleSync(name, options = {}) {
6594
- let directory = path4.resolve(toPath2(options.cwd) || "");
6595
- const { root } = path4.parse(directory);
6081
+ let directory = path5.resolve(toPath2(options.cwd) || "");
6082
+ const { root } = path5.parse(directory);
6596
6083
  const stopAt = options.stopAt || root;
6597
6084
  const limit = options.limit || Number.POSITIVE_INFINITY;
6598
6085
  const paths = [name].flat();
@@ -6613,12 +6100,12 @@ function findUpMultipleSync(name, options = {}) {
6613
6100
  break;
6614
6101
  }
6615
6102
  if (foundPath) {
6616
- matches.push(path4.resolve(directory, foundPath));
6103
+ matches.push(path5.resolve(directory, foundPath));
6617
6104
  }
6618
6105
  if (directory === stopAt || matches.length >= limit) {
6619
6106
  break;
6620
6107
  }
6621
- directory = path4.dirname(directory);
6108
+ directory = path5.dirname(directory);
6622
6109
  }
6623
6110
  return matches;
6624
6111
  }
@@ -6630,7 +6117,7 @@ function findUpSync(name, options = {}) {
6630
6117
  // node_modules/pkg-dir/index.js
6631
6118
  function packageDirectorySync({ cwd: cwd2 } = {}) {
6632
6119
  const filePath = findUpSync("package.json", { cwd: cwd2 });
6633
- return filePath && path5.dirname(filePath);
6120
+ return filePath && path6.dirname(filePath);
6634
6121
  }
6635
6122
 
6636
6123
  // node_modules/find-cache-dir/index.js
@@ -6650,22 +6137,22 @@ function useDirectory(directory, options) {
6650
6137
  return directory;
6651
6138
  }
6652
6139
  function getNodeModuleDirectory(directory) {
6653
- const nodeModules = path6.join(directory, "node_modules");
6654
- if (!isWritable(nodeModules) && (fs3.existsSync(nodeModules) || !isWritable(path6.join(directory)))) {
6140
+ const nodeModules = path7.join(directory, "node_modules");
6141
+ if (!isWritable(nodeModules) && (fs3.existsSync(nodeModules) || !isWritable(path7.join(directory)))) {
6655
6142
  return;
6656
6143
  }
6657
6144
  return nodeModules;
6658
6145
  }
6659
6146
  function findCacheDirectory(options = {}) {
6660
6147
  if (env2.CACHE_DIR && !["true", "false", "1", "0"].includes(env2.CACHE_DIR)) {
6661
- return useDirectory(path6.join(env2.CACHE_DIR, options.name), options);
6148
+ return useDirectory(path7.join(env2.CACHE_DIR, options.name), options);
6662
6149
  }
6663
6150
  let { cwd: directory = cwd(), files } = options;
6664
6151
  if (files) {
6665
6152
  if (!Array.isArray(files)) {
6666
6153
  throw new TypeError(`Expected \`files\` option to be an array, got \`${typeof files}\`.`);
6667
6154
  }
6668
- directory = (0, import_common_path_prefix.default)(files.map((file) => path6.resolve(directory, file)));
6155
+ directory = (0, import_common_path_prefix.default)(files.map((file) => path7.resolve(directory, file)));
6669
6156
  }
6670
6157
  directory = packageDirectorySync({ cwd: directory });
6671
6158
  if (!directory) {
@@ -6675,17 +6162,17 @@ function findCacheDirectory(options = {}) {
6675
6162
  if (!nodeModules) {
6676
6163
  return;
6677
6164
  }
6678
- return useDirectory(path6.join(directory, "node_modules", ".cache", options.name), options);
6165
+ return useDirectory(path7.join(directory, "node_modules", ".cache", options.name), options);
6679
6166
  }
6680
6167
 
6681
6168
  // src/cli/find-cache-file.js
6682
6169
  function findDefaultCacheFile() {
6683
6170
  const cacheDir = findCacheDirectory({ name: "prettier", create: true }) || os2.tmpdir();
6684
- const cacheFilePath = path7.join(cacheDir, ".prettier-cache");
6171
+ const cacheFilePath = path8.join(cacheDir, ".prettier-cache");
6685
6172
  return cacheFilePath;
6686
6173
  }
6687
6174
  async function findCacheFileFromOption(cacheLocation) {
6688
- const cacheFile = path7.resolve(cacheLocation);
6175
+ const cacheFile = path8.resolve(cacheLocation);
6689
6176
  const stat = await statSafe(cacheFile);
6690
6177
  if (stat) {
6691
6178
  if (stat.isDirectory()) {
@@ -6710,8 +6197,8 @@ async function findCacheFile(cacheLocation) {
6710
6197
  var find_cache_file_default = findCacheFile;
6711
6198
 
6712
6199
  // src/cli/format-results-cache.js
6200
+ var import_fast_json_stable_stringify2 = __toESM(require_fast_json_stable_stringify(), 1);
6713
6201
  var import_file_entry_cache = __toESM(require_cache2(), 1);
6714
- var import_fast_json_stable_stringify = __toESM(require_fast_json_stable_stringify(), 1);
6715
6202
  import { version as prettierVersion } from "../index.mjs";
6716
6203
  var optionsHashCache = /* @__PURE__ */ new WeakMap();
6717
6204
  var nodeVersion = process.version;
@@ -6720,7 +6207,7 @@ function getHashOfOptions(options) {
6720
6207
  return optionsHashCache.get(options);
6721
6208
  }
6722
6209
  const hash = createHash(
6723
- `${prettierVersion}_${nodeVersion}_${(0, import_fast_json_stable_stringify.default)(options)}`
6210
+ `${prettierVersion}_${nodeVersion}_${(0, import_fast_json_stable_stringify2.default)(options)}`
6724
6211
  );
6725
6212
  optionsHashCache.set(options, hash);
6726
6213
  return hash;
@@ -6783,8 +6270,120 @@ var FormatResultsCache = class {
6783
6270
  _fileEntryCache = new WeakMap();
6784
6271
  var format_results_cache_default = FormatResultsCache;
6785
6272
 
6273
+ // src/cli/is-tty.js
6274
+ function isTTY() {
6275
+ return process.stdout.isTTY && !mockable.isCI();
6276
+ }
6277
+
6278
+ // src/cli/options/get-options-for-file.js
6279
+ var import_dashify2 = __toESM(require_dashify(), 1);
6280
+ import { resolveConfig } from "../index.mjs";
6281
+ function getOptions(argv, detailedOptions) {
6282
+ return Object.fromEntries(
6283
+ detailedOptions.filter(({ forwardToApi }) => forwardToApi).map(({ forwardToApi, name }) => [forwardToApi, argv[name]])
6284
+ );
6285
+ }
6286
+ function cliifyOptions(object, apiDetailedOptionMap) {
6287
+ return Object.fromEntries(
6288
+ Object.entries(object || {}).map(([key, value]) => {
6289
+ const apiOption = apiDetailedOptionMap[key];
6290
+ const cliKey = apiOption ? apiOption.name : key;
6291
+ return [(0, import_dashify2.default)(cliKey), value];
6292
+ })
6293
+ );
6294
+ }
6295
+ function createApiDetailedOptionMap(detailedOptions) {
6296
+ return Object.fromEntries(
6297
+ detailedOptions.filter(
6298
+ (option) => option.forwardToApi && option.forwardToApi !== option.name
6299
+ ).map((option) => [option.forwardToApi, option])
6300
+ );
6301
+ }
6302
+ function parseArgsToOptions(context, overrideDefaults) {
6303
+ const minimistOptions = createMinimistOptions(context.detailedOptions);
6304
+ const apiDetailedOptionMap = createApiDetailedOptionMap(
6305
+ context.detailedOptions
6306
+ );
6307
+ return getOptions(
6308
+ normalize_cli_options_default(
6309
+ minimistParse(context.rawArguments, {
6310
+ string: minimistOptions.string,
6311
+ boolean: minimistOptions.boolean,
6312
+ default: cliifyOptions(overrideDefaults, apiDetailedOptionMap)
6313
+ }),
6314
+ context.detailedOptions,
6315
+ { logger: false }
6316
+ ),
6317
+ context.detailedOptions
6318
+ );
6319
+ }
6320
+ async function getOptionsOrDie(context, filePath) {
6321
+ try {
6322
+ if (context.argv.config === false) {
6323
+ context.logger.debug(
6324
+ "'--no-config' option found, skip loading config file."
6325
+ );
6326
+ return null;
6327
+ }
6328
+ context.logger.debug(
6329
+ context.argv.config ? `load config file from '${context.argv.config}'` : `resolve config from '${filePath}'`
6330
+ );
6331
+ const options = await resolveConfig(filePath, {
6332
+ editorconfig: context.argv.editorconfig,
6333
+ config: context.argv.config
6334
+ });
6335
+ context.logger.debug("loaded options `" + JSON.stringify(options) + "`");
6336
+ return options;
6337
+ } catch (error) {
6338
+ context.logger.error(
6339
+ `Invalid configuration${filePath ? ` for file "${filePath}"` : ""}:
6340
+ ` + error.message
6341
+ );
6342
+ process.exit(2);
6343
+ }
6344
+ }
6345
+ function applyConfigPrecedence(context, options) {
6346
+ try {
6347
+ switch (context.argv.configPrecedence) {
6348
+ case "cli-override":
6349
+ return parseArgsToOptions(context, options);
6350
+ case "file-override":
6351
+ return { ...parseArgsToOptions(context), ...options };
6352
+ case "prefer-file":
6353
+ return options || parseArgsToOptions(context);
6354
+ }
6355
+ } catch (error) {
6356
+ context.logger.error(error.toString());
6357
+ process.exit(2);
6358
+ }
6359
+ }
6360
+ async function getOptionsForFile(context, filepath) {
6361
+ const options = await getOptionsOrDie(context, filepath);
6362
+ const hasPlugins = options == null ? void 0 : options.plugins;
6363
+ if (hasPlugins) {
6364
+ await context.pushContextPlugins(options.plugins);
6365
+ }
6366
+ const appliedOptions = {
6367
+ filepath,
6368
+ ...applyConfigPrecedence(
6369
+ context,
6370
+ options && normalizeOptions(options, context.supportOptions, {
6371
+ logger: context.logger
6372
+ })
6373
+ )
6374
+ };
6375
+ context.logger.debug(
6376
+ `applied config-precedence (${context.argv.configPrecedence}): ${JSON.stringify(appliedOptions)}`
6377
+ );
6378
+ if (hasPlugins) {
6379
+ context.popContextPlugins();
6380
+ }
6381
+ return appliedOptions;
6382
+ }
6383
+ var get_options_for_file_default = getOptionsForFile;
6384
+
6786
6385
  // src/cli/format.js
6787
- var { getStdin, writeFormattedFile } = mockable2;
6386
+ var { getStdin, writeFormattedFile } = mockable;
6788
6387
  function diff(a, b) {
6789
6388
  return (0, import_diff.createTwoFilesPatch)("", "", a, b, "", "", { context: 2 });
6790
6389
  }
@@ -6847,7 +6446,7 @@ async function listDifferent(context, input, options, filename) {
6847
6446
  }
6848
6447
  return true;
6849
6448
  }
6850
- async function format2(context, input, opt) {
6449
+ async function format3(context, input, opt) {
6851
6450
  if (context.argv.debugPrintDoc) {
6852
6451
  const doc = await prettier.__debug.printToDoc(input, opt);
6853
6452
  return { formatted: await prettier.__debug.formatDoc(doc) + "\n" };
@@ -6980,12 +6579,12 @@ async function formatStdin(context) {
6980
6579
  }
6981
6580
  const options = await get_options_for_file_default(
6982
6581
  context,
6983
- filepath ? path8.resolve(process.cwd(), filepath) : process.cwd()
6582
+ filepath ? path9.resolve(filepath) : void 0
6984
6583
  );
6985
6584
  if (await listDifferent(context, input, options, "(stdin)")) {
6986
6585
  return;
6987
6586
  }
6988
- const formatted = await format2(context, input, options);
6587
+ const formatted = await format3(context, input, options);
6989
6588
  const { performanceTestFlag } = context;
6990
6589
  if (performanceTestFlag) {
6991
6590
  context.logger.log(
@@ -7035,7 +6634,7 @@ async function formatFiles(context) {
7035
6634
  ...await get_options_for_file_default(context, filename),
7036
6635
  filepath: filename
7037
6636
  };
7038
- const fileNameToDisplay = normalizeToPosix(path8.relative(cwd2, filename));
6637
+ const fileNameToDisplay = normalizeToPosix(path9.relative(cwd2, filename));
7039
6638
  let printedFilename;
7040
6639
  if (isTTY()) {
7041
6640
  printedFilename = context.logger.log(fileNameToDisplay, {
@@ -7071,7 +6670,7 @@ ${error2.message}`
7071
6670
  if (isCacheExists) {
7072
6671
  result = { formatted: input };
7073
6672
  } else {
7074
- result = await format2(context, input, options);
6673
+ result = await format3(context, input, options);
7075
6674
  }
7076
6675
  output = result.formatted;
7077
6676
  } catch (error2) {
@@ -7125,74 +6724,143 @@ ${error2.message}`
7125
6724
  } else if (!context.argv.check && !context.argv.listDifferent) {
7126
6725
  writeOutput(context, result, options);
7127
6726
  }
7128
- if (shouldSetCache) {
7129
- formatResultsCache == null ? void 0 : formatResultsCache.setFormatResultsCache(filename, options);
7130
- } else {
7131
- formatResultsCache == null ? void 0 : formatResultsCache.removeFormatResultsCache(filename);
6727
+ if (shouldSetCache) {
6728
+ formatResultsCache == null ? void 0 : formatResultsCache.setFormatResultsCache(filename, options);
6729
+ } else {
6730
+ formatResultsCache == null ? void 0 : formatResultsCache.removeFormatResultsCache(filename);
6731
+ }
6732
+ if (isDifferent) {
6733
+ if (context.argv.check) {
6734
+ context.logger.warn(fileNameToDisplay);
6735
+ } else if (context.argv.listDifferent) {
6736
+ context.logger.log(fileNameToDisplay);
6737
+ }
6738
+ numberOfUnformattedFilesFound += 1;
6739
+ }
6740
+ }
6741
+ formatResultsCache == null ? void 0 : formatResultsCache.reconcile();
6742
+ if (context.argv.check) {
6743
+ if (numberOfUnformattedFilesFound === 0) {
6744
+ context.logger.log("All matched files use Prettier code style!");
6745
+ } else {
6746
+ const files = numberOfUnformattedFilesFound === 1 ? "the above file" : `${numberOfUnformattedFilesFound} files`;
6747
+ context.logger.warn(
6748
+ context.argv.write ? `Code style issues fixed in ${files}.` : `Code style issues found in ${files}. Run Prettier to fix.`
6749
+ );
6750
+ }
6751
+ }
6752
+ if ((context.argv.check || context.argv.listDifferent) && numberOfUnformattedFilesFound > 0 && !process.exitCode && !context.argv.write) {
6753
+ process.exitCode = 1;
6754
+ }
6755
+ }
6756
+
6757
+ // src/cli/logger.js
6758
+ import readline from "readline";
6759
+
6760
+ // node_modules/ansi-regex/index.js
6761
+ function ansiRegex({ onlyFirst = false } = {}) {
6762
+ const pattern = [
6763
+ "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
6764
+ "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"
6765
+ ].join("|");
6766
+ return new RegExp(pattern, onlyFirst ? void 0 : "g");
6767
+ }
6768
+
6769
+ // node_modules/strip-ansi/index.js
6770
+ var regex = ansiRegex();
6771
+ function stripAnsi(string) {
6772
+ if (typeof string !== "string") {
6773
+ throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
6774
+ }
6775
+ return string.replace(regex, "");
6776
+ }
6777
+
6778
+ // src/cli/logger.js
6779
+ var import_wcwidth = __toESM(require_wcwidth(), 1);
6780
+ var countLines = (stream, text) => {
6781
+ const columns = stream.columns || 80;
6782
+ let lineCount = 0;
6783
+ for (const line of stripAnsi(text).split("\n")) {
6784
+ lineCount += Math.max(1, Math.ceil((0, import_wcwidth.default)(line) / columns));
6785
+ }
6786
+ return lineCount;
6787
+ };
6788
+ var clear = (stream, text) => () => {
6789
+ const lineCount = countLines(stream, text);
6790
+ for (let line = 0; line < lineCount; line++) {
6791
+ if (line > 0) {
6792
+ readline.moveCursor(stream, 0, -1);
6793
+ }
6794
+ readline.clearLine(stream, 0);
6795
+ readline.cursorTo(stream, 0);
6796
+ }
6797
+ };
6798
+ var emptyLogResult = {
6799
+ clear() {
6800
+ }
6801
+ };
6802
+ function createLogger(logLevel = "log") {
6803
+ return {
6804
+ logLevel,
6805
+ warn: createLogFunc("warn", "yellow"),
6806
+ error: createLogFunc("error", "red"),
6807
+ debug: createLogFunc("debug", "blue"),
6808
+ log: createLogFunc("log")
6809
+ };
6810
+ function createLogFunc(loggerName, color) {
6811
+ if (!shouldLog(loggerName)) {
6812
+ return () => emptyLogResult;
7132
6813
  }
7133
- if (isDifferent) {
7134
- if (context.argv.check) {
7135
- context.logger.warn(fileNameToDisplay);
7136
- } else if (context.argv.listDifferent) {
7137
- context.logger.log(fileNameToDisplay);
6814
+ const stream = process[loggerName === "log" ? "stdout" : "stderr"];
6815
+ const chalkInstance = loggerName === "log" ? source_default : chalkStderr;
6816
+ const prefix = color ? `[${chalkInstance[color](loggerName)}] ` : "";
6817
+ return (message, options) => {
6818
+ options = {
6819
+ newline: true,
6820
+ clearable: false,
6821
+ ...options
6822
+ };
6823
+ message = string_replace_all_default(
6824
+ /* isOptionalObject*/
6825
+ false,
6826
+ message,
6827
+ /^/gm,
6828
+ prefix
6829
+ ) + (options.newline ? "\n" : "");
6830
+ stream.write(message);
6831
+ if (options.clearable) {
6832
+ return {
6833
+ clear: clear(stream, message)
6834
+ };
7138
6835
  }
7139
- numberOfUnformattedFilesFound += 1;
7140
- }
6836
+ };
7141
6837
  }
7142
- formatResultsCache == null ? void 0 : formatResultsCache.reconcile();
7143
- if (context.argv.check) {
7144
- if (numberOfUnformattedFilesFound === 0) {
7145
- context.logger.log("All matched files use Prettier code style!");
7146
- } else {
7147
- const files = numberOfUnformattedFilesFound === 1 ? "the above file" : `${numberOfUnformattedFilesFound} files`;
7148
- context.logger.warn(
7149
- context.argv.write ? `Code style issues fixed in ${files}.` : `Code style issues found in ${files}. Run Prettier to fix.`
7150
- );
6838
+ function shouldLog(loggerName) {
6839
+ switch (logLevel) {
6840
+ case "silent":
6841
+ return false;
6842
+ case "debug":
6843
+ if (loggerName === "debug") {
6844
+ return true;
6845
+ }
6846
+ case "log":
6847
+ if (loggerName === "log") {
6848
+ return true;
6849
+ }
6850
+ case "warn":
6851
+ if (loggerName === "warn") {
6852
+ return true;
6853
+ }
6854
+ case "error":
6855
+ return loggerName === "error";
7151
6856
  }
7152
6857
  }
7153
- if ((context.argv.check || context.argv.listDifferent) && numberOfUnformattedFilesFound > 0 && !process.exitCode && !context.argv.write) {
7154
- process.exitCode = 1;
7155
- }
7156
- }
7157
-
7158
- // src/cli/file-info.js
7159
- var import_fast_json_stable_stringify2 = __toESM(require_fast_json_stable_stringify(), 1);
7160
- import { format as format3, getFileInfo } from "../index.mjs";
7161
- async function logFileInfoOrDie(context) {
7162
- const {
7163
- fileInfo: file,
7164
- ignorePath,
7165
- withNodeModules,
7166
- plugins,
7167
- config
7168
- } = context.argv;
7169
- const fileInfo = await getFileInfo(file, {
7170
- ignorePath,
7171
- withNodeModules,
7172
- plugins,
7173
- resolveConfig: config !== false
7174
- });
7175
- printToScreen(await format3((0, import_fast_json_stable_stringify2.default)(fileInfo), { parser: "json" }));
7176
- }
7177
- var file_info_default = logFileInfoOrDie;
7178
-
7179
- // src/cli/find-config-path.js
7180
- import path9 from "path";
7181
- import { resolveConfigFile } from "../index.mjs";
7182
- async function logResolvedConfigPathOrDie(context) {
7183
- const file = context.argv.findConfigPath;
7184
- const configFile = await resolveConfigFile(file);
7185
- if (configFile) {
7186
- printToScreen(normalizeToPosix(path9.relative(process.cwd(), configFile)));
7187
- } else {
7188
- throw new Error(`Can not find configure file for "${file}".`);
7189
- }
7190
6858
  }
7191
- var find_config_path_default = logResolvedConfigPathOrDie;
6859
+ var logger_default = createLogger;
7192
6860
 
7193
6861
  // src/cli/print-support-info.js
7194
6862
  var import_fast_json_stable_stringify3 = __toESM(require_fast_json_stable_stringify(), 1);
7195
- import { getSupportInfo as getSupportInfo2, format as format4 } from "../index.mjs";
6863
+ import { format as format4, getSupportInfo as getSupportInfo2 } from "../index.mjs";
7196
6864
  var sortByName = (array2) => array2.sort((a, b) => a.name.localeCompare(b.name));
7197
6865
  async function printSupportInfo() {
7198
6866
  const { languages, options } = await getSupportInfo2();
@@ -7206,6 +6874,139 @@ async function printSupportInfo() {
7206
6874
  }
7207
6875
  var print_support_info_default = printSupportInfo;
7208
6876
 
6877
+ // src/cli/constants.evaluate.js
6878
+ var categoryOrder = [
6879
+ "Output",
6880
+ "Format",
6881
+ "Config",
6882
+ "Editor",
6883
+ "Other"
6884
+ ];
6885
+ var usageSummary = "Usage: prettier [options] [file/dir/glob ...]\n\nBy default, output is written to stdout.\nStdin is read if it is piped to Prettier and no files are given.";
6886
+
6887
+ // src/cli/usage.js
6888
+ var OPTION_USAGE_THRESHOLD = 25;
6889
+ var CHOICE_USAGE_MARGIN = 3;
6890
+ var CHOICE_USAGE_INDENTATION = 2;
6891
+ function indent(str, spaces) {
6892
+ return string_replace_all_default(
6893
+ /* isOptionalObject*/
6894
+ false,
6895
+ str,
6896
+ /^/gm,
6897
+ " ".repeat(spaces)
6898
+ );
6899
+ }
6900
+ function createDefaultValueDisplay(value) {
6901
+ return Array.isArray(value) ? `[${value.map(createDefaultValueDisplay).join(", ")}]` : value;
6902
+ }
6903
+ function getOptionDefaultValue(context, optionName) {
6904
+ var _a;
6905
+ const option = context.detailedOptions.find(({
6906
+ name
6907
+ }) => name === optionName);
6908
+ if ((option == null ? void 0 : option.default) !== void 0) {
6909
+ return option.default;
6910
+ }
6911
+ const optionCamelName = camelCase(optionName);
6912
+ return formatOptionsHiddenDefaults[optionCamelName] ?? ((_a = context.supportOptions.find((option2) => !option2.deprecated && option2.name === optionCamelName)) == null ? void 0 : _a.default);
6913
+ }
6914
+ function createOptionUsageHeader(option) {
6915
+ const name = `--${option.name}`;
6916
+ const alias = option.alias ? `-${option.alias},` : null;
6917
+ const type = createOptionUsageType(option);
6918
+ return [alias, name, type].filter(Boolean).join(" ");
6919
+ }
6920
+ function createOptionUsageRow(header, content, threshold) {
6921
+ const separator = header.length >= threshold ? `
6922
+ ${" ".repeat(threshold)}` : " ".repeat(threshold - header.length);
6923
+ const description = string_replace_all_default(
6924
+ /* isOptionalObject*/
6925
+ false,
6926
+ content,
6927
+ "\n",
6928
+ `
6929
+ ${" ".repeat(threshold)}`
6930
+ );
6931
+ return `${header}${separator}${description}`;
6932
+ }
6933
+ function createOptionUsageType(option) {
6934
+ switch (option.type) {
6935
+ case "boolean":
6936
+ return null;
6937
+ case "choice":
6938
+ return `<${option.choices.filter((choice) => !choice.deprecated).map((choice) => choice.value).join("|")}>`;
6939
+ default:
6940
+ return `<${option.type}>`;
6941
+ }
6942
+ }
6943
+ function createChoiceUsages(choices, margin, indentation) {
6944
+ const activeChoices = choices.filter((choice) => !choice.deprecated);
6945
+ const threshold = Math.max(0, ...activeChoices.map((choice) => choice.value.length)) + margin;
6946
+ return activeChoices.map((choice) => indent(createOptionUsageRow(choice.value, choice.description, threshold), indentation));
6947
+ }
6948
+ function createOptionUsage(context, option, threshold) {
6949
+ const header = createOptionUsageHeader(option);
6950
+ const optionDefaultValue = getOptionDefaultValue(context, option.name);
6951
+ return createOptionUsageRow(header, `${option.description}${optionDefaultValue === void 0 ? "" : `
6952
+ Defaults to ${createDefaultValueDisplay(optionDefaultValue)}.`}`, threshold);
6953
+ }
6954
+ function getOptionsWithOpposites(options) {
6955
+ const optionsWithOpposites = options.map((option) => [option.description ? option : null, option.oppositeDescription ? {
6956
+ ...option,
6957
+ name: `no-${option.name}`,
6958
+ type: "boolean",
6959
+ description: option.oppositeDescription
6960
+ } : null]);
6961
+ return optionsWithOpposites.flat().filter(Boolean);
6962
+ }
6963
+ function createUsage(context) {
6964
+ const sortedOptions = context.detailedOptions.sort((optionA, optionB) => optionA.name.localeCompare(optionB.name));
6965
+ const options = getOptionsWithOpposites(sortedOptions).filter(
6966
+ // remove unnecessary option (e.g. `semi`, `color`, etc.), which is only used for --help <flag>
6967
+ (option) => !(option.type === "boolean" && option.oppositeDescription && !option.name.startsWith("no-"))
6968
+ );
6969
+ const groupedOptions = groupBy(options, (option) => option.category);
6970
+ const firstCategories = categoryOrder.slice(0, -1);
6971
+ const lastCategories = categoryOrder.slice(-1);
6972
+ const restCategories = Object.keys(groupedOptions).filter((category) => !categoryOrder.includes(category));
6973
+ const allCategories = [...firstCategories, ...restCategories, ...lastCategories];
6974
+ const optionsUsage = allCategories.map((category) => {
6975
+ const categoryOptions = groupedOptions[category].map((option) => createOptionUsage(context, option, OPTION_USAGE_THRESHOLD)).join("\n");
6976
+ return `${category} options:
6977
+
6978
+ ${indent(categoryOptions, 2)}`;
6979
+ });
6980
+ return [usageSummary, ...optionsUsage, ""].join("\n\n");
6981
+ }
6982
+ function createPluginDefaults(pluginDefaults) {
6983
+ if (!pluginDefaults || Object.keys(pluginDefaults).length === 0) {
6984
+ return "";
6985
+ }
6986
+ const defaults = Object.entries(pluginDefaults).sort(([pluginNameA], [pluginNameB]) => pluginNameA.localeCompare(pluginNameB)).map(([plugin, value]) => `* ${plugin}: ${createDefaultValueDisplay(value)}`).join("\n");
6987
+ return `
6988
+ Plugin defaults:
6989
+ ${defaults}`;
6990
+ }
6991
+ function createDetailedUsage(context, flag) {
6992
+ const option = getOptionsWithOpposites(context.detailedOptions).find((option2) => option2.name === flag || option2.alias === flag);
6993
+ const header = createOptionUsageHeader(option);
6994
+ const description = `
6995
+
6996
+ ${indent(option.description, 2)}`;
6997
+ const choices = option.type !== "choice" ? "" : `
6998
+
6999
+ Valid options:
7000
+
7001
+ ${createChoiceUsages(option.choices, CHOICE_USAGE_MARGIN, CHOICE_USAGE_INDENTATION).join("\n")}`;
7002
+ const optionDefaultValue = getOptionDefaultValue(context, option.name);
7003
+ const defaults = optionDefaultValue !== void 0 ? `
7004
+
7005
+ Default: ${createDefaultValueDisplay(optionDefaultValue)}` : "";
7006
+ const pluginDefaults = createPluginDefaults(option.pluginDefaults);
7007
+ return `${header}${description}${choices}${defaults}${pluginDefaults}`;
7008
+ }
7009
+
7209
7010
  // src/cli/index.js
7210
7011
  async function run(rawArguments = process.argv.slice(2)) {
7211
7012
  let logger = logger_default();