prettier 3.1.1 → 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) {
@@ -3959,9 +3659,9 @@ var require_glob = __commonJS({
3959
3659
  }
3960
3660
  });
3961
3661
 
3962
- // node_modules/rimraf/rimraf.js
3662
+ // node_modules/flat-cache/node_modules/rimraf/rimraf.js
3963
3663
  var require_rimraf = __commonJS({
3964
- "node_modules/rimraf/rimraf.js"(exports, module) {
3664
+ "node_modules/flat-cache/node_modules/rimraf/rimraf.js"(exports, module) {
3965
3665
  var assert = __require("assert");
3966
3666
  var path10 = __require("path");
3967
3667
  var fs6 = __require("fs");
@@ -4700,682 +4400,234 @@ var require_cache2 = __commonJS({
4700
4400
  }
4701
4401
  });
4702
4402
 
4703
- // node_modules/fast-json-stable-stringify/index.js
4704
- var require_fast_json_stable_stringify = __commonJS({
4705
- "node_modules/fast-json-stable-stringify/index.js"(exports, module) {
4706
- "use strict";
4707
- module.exports = function(data, opts) {
4708
- if (!opts)
4709
- opts = {};
4710
- if (typeof opts === "function")
4711
- opts = { cmp: opts };
4712
- var cycles = typeof opts.cycles === "boolean" ? opts.cycles : false;
4713
- var cmp = opts.cmp && function(f) {
4714
- return function(node) {
4715
- return function(a, b) {
4716
- var aobj = { key: a, value: node[a] };
4717
- var bobj = { key: b, value: node[b] };
4718
- return f(aobj, bobj);
4719
- };
4720
- };
4721
- }(opts.cmp);
4722
- var seen = [];
4723
- return function stringify4(node) {
4724
- if (node && node.toJSON && typeof node.toJSON === "function") {
4725
- node = node.toJSON();
4726
- }
4727
- if (node === void 0)
4728
- return;
4729
- if (typeof node == "number")
4730
- return isFinite(node) ? "" + node : "null";
4731
- if (typeof node !== "object")
4732
- return JSON.stringify(node);
4733
- var i, out;
4734
- if (Array.isArray(node)) {
4735
- out = "[";
4736
- for (i = 0; i < node.length; i++) {
4737
- if (i)
4738
- out += ",";
4739
- out += stringify4(node[i]) || "null";
4740
- }
4741
- return out + "]";
4742
- }
4743
- if (node === null)
4744
- return "null";
4745
- if (seen.indexOf(node) !== -1) {
4746
- if (cycles)
4747
- return JSON.stringify("__cycle__");
4748
- throw new TypeError("Converting circular structure to JSON");
4749
- }
4750
- var seenIndex = seen.push(node) - 1;
4751
- var keys = Object.keys(node).sort(cmp && cmp(node));
4752
- out = "";
4753
- for (i = 0; i < keys.length; i++) {
4754
- var key = keys[i];
4755
- var value = stringify4(node[key]);
4756
- if (!value)
4757
- continue;
4758
- if (out)
4759
- out += ",";
4760
- out += JSON.stringify(key) + ":" + value;
4761
- }
4762
- seen.splice(seenIndex, 1);
4763
- return "{" + out + "}";
4764
- }(data);
4765
- };
4766
- }
4767
- });
4768
-
4769
- // src/cli/index.js
4770
- import * as prettier2 from "../index.mjs";
4771
-
4772
- // scripts/build/shims/string-replace-all.js
4773
- var stringReplaceAll = (isOptionalObject, original, pattern, replacement) => {
4774
- if (isOptionalObject && (original === void 0 || original === null)) {
4775
- return;
4776
- }
4777
- if (original.replaceAll) {
4778
- return original.replaceAll(pattern, replacement);
4779
- }
4780
- if (pattern.global) {
4781
- return original.replace(pattern, replacement);
4782
- }
4783
- return original.split(pattern).join(replacement);
4784
- };
4785
- var string_replace_all_default = stringReplaceAll;
4786
-
4787
- // src/cli/logger.js
4788
- import readline from "readline";
4789
-
4790
- // node_modules/chalk/source/vendor/ansi-styles/index.js
4791
- var ANSI_BACKGROUND_OFFSET = 10;
4792
- var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
4793
- var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
4794
- var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
4795
- var styles = {
4796
- modifier: {
4797
- reset: [0, 0],
4798
- // 21 isn't widely supported and 22 does the same thing
4799
- bold: [1, 22],
4800
- dim: [2, 22],
4801
- italic: [3, 23],
4802
- underline: [4, 24],
4803
- overline: [53, 55],
4804
- inverse: [7, 27],
4805
- hidden: [8, 28],
4806
- strikethrough: [9, 29]
4807
- },
4808
- color: {
4809
- black: [30, 39],
4810
- red: [31, 39],
4811
- green: [32, 39],
4812
- yellow: [33, 39],
4813
- blue: [34, 39],
4814
- magenta: [35, 39],
4815
- cyan: [36, 39],
4816
- white: [37, 39],
4817
- // Bright color
4818
- blackBright: [90, 39],
4819
- gray: [90, 39],
4820
- // Alias of `blackBright`
4821
- grey: [90, 39],
4822
- // Alias of `blackBright`
4823
- redBright: [91, 39],
4824
- greenBright: [92, 39],
4825
- yellowBright: [93, 39],
4826
- blueBright: [94, 39],
4827
- magentaBright: [95, 39],
4828
- cyanBright: [96, 39],
4829
- whiteBright: [97, 39]
4830
- },
4831
- bgColor: {
4832
- bgBlack: [40, 49],
4833
- bgRed: [41, 49],
4834
- bgGreen: [42, 49],
4835
- bgYellow: [43, 49],
4836
- bgBlue: [44, 49],
4837
- bgMagenta: [45, 49],
4838
- bgCyan: [46, 49],
4839
- bgWhite: [47, 49],
4840
- // Bright color
4841
- bgBlackBright: [100, 49],
4842
- bgGray: [100, 49],
4843
- // Alias of `bgBlackBright`
4844
- bgGrey: [100, 49],
4845
- // Alias of `bgBlackBright`
4846
- bgRedBright: [101, 49],
4847
- bgGreenBright: [102, 49],
4848
- bgYellowBright: [103, 49],
4849
- bgBlueBright: [104, 49],
4850
- bgMagentaBright: [105, 49],
4851
- bgCyanBright: [106, 49],
4852
- bgWhiteBright: [107, 49]
4853
- }
4854
- };
4855
- var modifierNames = Object.keys(styles.modifier);
4856
- var foregroundColorNames = Object.keys(styles.color);
4857
- var backgroundColorNames = Object.keys(styles.bgColor);
4858
- var colorNames = [...foregroundColorNames, ...backgroundColorNames];
4859
- function assembleStyles() {
4860
- const codes = /* @__PURE__ */ new Map();
4861
- for (const [groupName, group] of Object.entries(styles)) {
4862
- for (const [styleName, style] of Object.entries(group)) {
4863
- styles[styleName] = {
4864
- open: `\x1B[${style[0]}m`,
4865
- close: `\x1B[${style[1]}m`
4866
- };
4867
- group[styleName] = styles[styleName];
4868
- codes.set(style[0], style[1]);
4869
- }
4870
- Object.defineProperty(styles, groupName, {
4871
- value: group,
4872
- enumerable: false
4873
- });
4874
- }
4875
- Object.defineProperty(styles, "codes", {
4876
- value: codes,
4877
- enumerable: false
4878
- });
4879
- styles.color.close = "\x1B[39m";
4880
- styles.bgColor.close = "\x1B[49m";
4881
- styles.color.ansi = wrapAnsi16();
4882
- styles.color.ansi256 = wrapAnsi256();
4883
- styles.color.ansi16m = wrapAnsi16m();
4884
- styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
4885
- styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
4886
- styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
4887
- Object.defineProperties(styles, {
4888
- rgbToAnsi256: {
4889
- value(red, green, blue) {
4890
- if (red === green && green === blue) {
4891
- if (red < 8) {
4892
- return 16;
4893
- }
4894
- if (red > 248) {
4895
- return 231;
4896
- }
4897
- return Math.round((red - 8) / 247 * 24) + 232;
4898
- }
4899
- return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
4900
- },
4901
- enumerable: false
4902
- },
4903
- hexToRgb: {
4904
- value(hex) {
4905
- const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
4906
- if (!matches) {
4907
- return [0, 0, 0];
4908
- }
4909
- let [colorString] = matches;
4910
- if (colorString.length === 3) {
4911
- colorString = [...colorString].map((character) => character + character).join("");
4912
- }
4913
- const integer = Number.parseInt(colorString, 16);
4914
- return [
4915
- /* eslint-disable no-bitwise */
4916
- integer >> 16 & 255,
4917
- integer >> 8 & 255,
4918
- integer & 255
4919
- /* eslint-enable no-bitwise */
4920
- ];
4921
- },
4922
- enumerable: false
4923
- },
4924
- hexToAnsi256: {
4925
- value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
4926
- enumerable: false
4927
- },
4928
- ansi256ToAnsi: {
4929
- value(code) {
4930
- if (code < 8) {
4931
- return 30 + code;
4932
- }
4933
- if (code < 16) {
4934
- return 90 + (code - 8);
4935
- }
4936
- let red;
4937
- let green;
4938
- let blue;
4939
- if (code >= 232) {
4940
- red = ((code - 232) * 10 + 8) / 255;
4941
- green = red;
4942
- blue = red;
4943
- } else {
4944
- code -= 16;
4945
- const remainder = code % 36;
4946
- red = Math.floor(code / 36) / 5;
4947
- green = Math.floor(remainder / 6) / 5;
4948
- blue = remainder % 6 / 5;
4949
- }
4950
- const value = Math.max(red, green, blue) * 2;
4951
- if (value === 0) {
4952
- return 30;
4953
- }
4954
- let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
4955
- if (value === 2) {
4956
- result += 60;
4957
- }
4958
- return result;
4959
- },
4960
- enumerable: false
4961
- },
4962
- rgbToAnsi: {
4963
- value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
4964
- enumerable: false
4965
- },
4966
- hexToAnsi: {
4967
- value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
4968
- enumerable: false
4969
- }
4970
- });
4971
- return styles;
4972
- }
4973
- var ansiStyles = assembleStyles();
4974
- var ansi_styles_default = ansiStyles;
4975
-
4976
- // node_modules/chalk/source/vendor/supports-color/index.js
4977
- import process2 from "process";
4978
- import os from "os";
4979
- import tty from "tty";
4980
- function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process2.argv) {
4981
- const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
4982
- const position = argv.indexOf(prefix + flag);
4983
- const terminatorPosition = argv.indexOf("--");
4984
- return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
4985
- }
4986
- var { env } = process2;
4987
- var flagForceColor;
4988
- if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
4989
- flagForceColor = 0;
4990
- } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
4991
- flagForceColor = 1;
4992
- }
4993
- function envForceColor() {
4994
- if ("FORCE_COLOR" in env) {
4995
- if (env.FORCE_COLOR === "true") {
4996
- return 1;
4997
- }
4998
- if (env.FORCE_COLOR === "false") {
4999
- return 0;
5000
- }
5001
- return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
5002
- }
5003
- }
5004
- function translateLevel(level) {
5005
- if (level === 0) {
5006
- return false;
5007
- }
5008
- return {
5009
- level,
5010
- hasBasic: true,
5011
- has256: level >= 2,
5012
- has16m: level >= 3
5013
- };
5014
- }
5015
- function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
5016
- const noFlagForceColor = envForceColor();
5017
- if (noFlagForceColor !== void 0) {
5018
- flagForceColor = noFlagForceColor;
5019
- }
5020
- const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
5021
- if (forceColor === 0) {
5022
- return 0;
5023
- }
5024
- if (sniffFlags) {
5025
- if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
5026
- return 3;
5027
- }
5028
- if (hasFlag("color=256")) {
5029
- return 2;
5030
- }
5031
- }
5032
- if ("TF_BUILD" in env && "AGENT_NAME" in env) {
5033
- return 1;
5034
- }
5035
- if (haveStream && !streamIsTTY && forceColor === void 0) {
5036
- return 0;
5037
- }
5038
- const min = forceColor || 0;
5039
- if (env.TERM === "dumb") {
5040
- return min;
5041
- }
5042
- if (process2.platform === "win32") {
5043
- const osRelease = os.release().split(".");
5044
- if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
5045
- return Number(osRelease[2]) >= 14931 ? 3 : 2;
5046
- }
5047
- return 1;
5048
- }
5049
- if ("CI" in env) {
5050
- if ("GITHUB_ACTIONS" in env || "GITEA_ACTIONS" in env) {
5051
- return 3;
5052
- }
5053
- if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
5054
- return 1;
5055
- }
5056
- return min;
5057
- }
5058
- if ("TEAMCITY_VERSION" in env) {
5059
- return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
5060
- }
5061
- if (env.COLORTERM === "truecolor") {
5062
- return 3;
5063
- }
5064
- if (env.TERM === "xterm-kitty") {
5065
- return 3;
5066
- }
5067
- if ("TERM_PROGRAM" in env) {
5068
- const version2 = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
5069
- switch (env.TERM_PROGRAM) {
5070
- case "iTerm.app": {
5071
- return version2 >= 3 ? 3 : 2;
5072
- }
5073
- case "Apple_Terminal": {
5074
- return 2;
5075
- }
5076
- }
5077
- }
5078
- if (/-256(color)?$/i.test(env.TERM)) {
5079
- return 2;
5080
- }
5081
- if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
5082
- return 1;
5083
- }
5084
- if ("COLORTERM" in env) {
5085
- return 1;
5086
- }
5087
- return min;
5088
- }
5089
- function createSupportsColor(stream, options = {}) {
5090
- const level = _supportsColor(stream, {
5091
- streamIsTTY: stream && stream.isTTY,
5092
- ...options
5093
- });
5094
- return translateLevel(level);
5095
- }
5096
- var supportsColor = {
5097
- stdout: createSupportsColor({ isTTY: tty.isatty(1) }),
5098
- stderr: createSupportsColor({ isTTY: tty.isatty(2) })
5099
- };
5100
- var supports_color_default = supportsColor;
5101
-
5102
- // node_modules/chalk/source/utilities.js
5103
- function stringReplaceAll2(string, substring, replacer) {
5104
- let index = string.indexOf(substring);
5105
- if (index === -1) {
5106
- return string;
5107
- }
5108
- const substringLength = substring.length;
5109
- let endIndex = 0;
5110
- let returnValue = "";
5111
- do {
5112
- returnValue += string.slice(endIndex, index) + substring + replacer;
5113
- endIndex = index + substringLength;
5114
- index = string.indexOf(substring, endIndex);
5115
- } while (index !== -1);
5116
- returnValue += string.slice(endIndex);
5117
- return returnValue;
5118
- }
5119
- function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
5120
- let endIndex = 0;
5121
- let returnValue = "";
5122
- do {
5123
- const gotCR = string[index - 1] === "\r";
5124
- returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
5125
- endIndex = index + 1;
5126
- index = string.indexOf("\n", endIndex);
5127
- } while (index !== -1);
5128
- returnValue += string.slice(endIndex);
5129
- return returnValue;
5130
- }
5131
-
5132
- // node_modules/chalk/source/index.js
5133
- var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;
5134
- var GENERATOR = Symbol("GENERATOR");
5135
- var STYLER = Symbol("STYLER");
5136
- var IS_EMPTY = Symbol("IS_EMPTY");
5137
- var levelMapping = [
5138
- "ansi",
5139
- "ansi",
5140
- "ansi256",
5141
- "ansi16m"
5142
- ];
5143
- var styles2 = /* @__PURE__ */ Object.create(null);
5144
- var applyOptions = (object, options = {}) => {
5145
- if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
5146
- throw new Error("The `level` option should be an integer from 0 to 3");
5147
- }
5148
- const colorLevel = stdoutColor ? stdoutColor.level : 0;
5149
- object.level = options.level === void 0 ? colorLevel : options.level;
5150
- };
5151
- var chalkFactory = (options) => {
5152
- const chalk2 = (...strings) => strings.join(" ");
5153
- applyOptions(chalk2, options);
5154
- Object.setPrototypeOf(chalk2, createChalk.prototype);
5155
- return chalk2;
5156
- };
5157
- function createChalk(options) {
5158
- return chalkFactory(options);
5159
- }
5160
- Object.setPrototypeOf(createChalk.prototype, Function.prototype);
5161
- for (const [styleName, style] of Object.entries(ansi_styles_default)) {
5162
- styles2[styleName] = {
5163
- get() {
5164
- const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
5165
- Object.defineProperty(this, styleName, { value: builder });
5166
- return builder;
5167
- }
5168
- };
5169
- }
5170
- styles2.visible = {
5171
- get() {
5172
- const builder = createBuilder(this, this[STYLER], true);
5173
- Object.defineProperty(this, "visible", { value: builder });
5174
- return builder;
5175
- }
5176
- };
5177
- var getModelAnsi = (model, level, type, ...arguments_) => {
5178
- if (model === "rgb") {
5179
- if (level === "ansi16m") {
5180
- return ansi_styles_default[type].ansi16m(...arguments_);
5181
- }
5182
- if (level === "ansi256") {
5183
- return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
5184
- }
5185
- return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
5186
- }
5187
- if (model === "hex") {
5188
- return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
5189
- }
5190
- return ansi_styles_default[type][model](...arguments_);
5191
- };
5192
- var usedModels = ["rgb", "hex", "ansi256"];
5193
- for (const model of usedModels) {
5194
- styles2[model] = {
5195
- get() {
5196
- const { level } = this;
5197
- return function(...arguments_) {
5198
- const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
5199
- return createBuilder(this, styler, this[IS_EMPTY]);
5200
- };
5201
- }
5202
- };
5203
- const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
5204
- styles2[bgModel] = {
5205
- get() {
5206
- const { level } = this;
5207
- return function(...arguments_) {
5208
- const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
5209
- return createBuilder(this, styler, this[IS_EMPTY]);
5210
- };
5211
- }
5212
- };
5213
- }
5214
- var proto = Object.defineProperties(() => {
5215
- }, {
5216
- ...styles2,
5217
- level: {
5218
- enumerable: true,
5219
- get() {
5220
- return this[GENERATOR].level;
5221
- },
5222
- set(level) {
5223
- this[GENERATOR].level = level;
5224
- }
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
+ ];
5225
4550
  }
5226
4551
  });
5227
- var createStyler = (open, close, parent) => {
5228
- let openAll;
5229
- let closeAll;
5230
- if (parent === void 0) {
5231
- openAll = open;
5232
- closeAll = close;
5233
- } else {
5234
- openAll = parent.openAll + open;
5235
- closeAll = close + parent.closeAll;
5236
- }
5237
- return {
5238
- open,
5239
- close,
5240
- openAll,
5241
- closeAll,
5242
- parent
5243
- };
5244
- };
5245
- var createBuilder = (self, _styler, _isEmpty) => {
5246
- const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
5247
- Object.setPrototypeOf(builder, proto);
5248
- builder[GENERATOR] = self;
5249
- builder[STYLER] = _styler;
5250
- builder[IS_EMPTY] = _isEmpty;
5251
- return builder;
5252
- };
5253
- var applyStyle = (self, string) => {
5254
- if (self.level <= 0 || !string) {
5255
- return self[IS_EMPTY] ? "" : string;
5256
- }
5257
- let styler = self[STYLER];
5258
- if (styler === void 0) {
5259
- return string;
5260
- }
5261
- const { openAll, closeAll } = styler;
5262
- if (string.includes("\x1B")) {
5263
- while (styler !== void 0) {
5264
- string = stringReplaceAll2(string, styler.close, styler.open);
5265
- styler = styler.parent;
5266
- }
5267
- }
5268
- const lfIndex = string.indexOf("\n");
5269
- if (lfIndex !== -1) {
5270
- string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
5271
- }
5272
- return openAll + string + closeAll;
5273
- };
5274
- Object.defineProperties(createChalk.prototype, styles2);
5275
- var chalk = createChalk();
5276
- var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
5277
- var source_default = chalk;
5278
-
5279
- // node_modules/ansi-regex/index.js
5280
- function ansiRegex({ onlyFirst = false } = {}) {
5281
- const pattern = [
5282
- "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
5283
- "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"
5284
- ].join("|");
5285
- return new RegExp(pattern, onlyFirst ? void 0 : "g");
5286
- }
5287
-
5288
- // node_modules/strip-ansi/index.js
5289
- var regex = ansiRegex();
5290
- function stripAnsi(string) {
5291
- if (typeof string !== "string") {
5292
- throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
5293
- }
5294
- return string.replace(regex, "");
5295
- }
5296
4552
 
5297
- // src/cli/logger.js
5298
- var import_wcwidth = __toESM(require_wcwidth(), 1);
5299
- var countLines = (stream, text) => {
5300
- const columns = stream.columns || 80;
5301
- let lineCount = 0;
5302
- for (const line of stripAnsi(text).split("\n")) {
5303
- lineCount += Math.max(1, Math.ceil((0, import_wcwidth.default)(line) / columns));
5304
- }
5305
- return lineCount;
5306
- };
5307
- var clear = (stream, text) => () => {
5308
- const lineCount = countLines(stream, text);
5309
- for (let line = 0; line < lineCount; line++) {
5310
- if (line > 0) {
5311
- readline.moveCursor(stream, 0, -1);
5312
- }
5313
- readline.clearLine(stream, 0);
5314
- readline.cursorTo(stream, 0);
5315
- }
5316
- };
5317
- var emptyLogResult = {
5318
- clear() {
5319
- }
5320
- };
5321
- function createLogger(logLevel = "log") {
5322
- return {
5323
- logLevel,
5324
- warn: createLogFunc("warn", "yellow"),
5325
- error: createLogFunc("error", "red"),
5326
- debug: createLogFunc("debug", "blue"),
5327
- log: createLogFunc("log")
5328
- };
5329
- function createLogFunc(loggerName, color) {
5330
- if (!shouldLog(loggerName)) {
5331
- return () => emptyLogResult;
5332
- }
5333
- const stream = process[loggerName === "log" ? "stdout" : "stderr"];
5334
- const chalkInstance = loggerName === "log" ? source_default : chalkStderr;
5335
- const prefix = color ? `[${chalkInstance[color](loggerName)}] ` : "";
5336
- return (message, options) => {
5337
- options = {
5338
- newline: true,
5339
- clearable: false,
5340
- ...options
5341
- };
5342
- message = string_replace_all_default(
5343
- /* isOptionalObject*/
5344
- false,
5345
- message,
5346
- /^/gm,
5347
- prefix
5348
- ) + (options.newline ? "\n" : "");
5349
- stream.write(message);
5350
- if (options.clearable) {
5351
- return {
5352
- clear: clear(stream, message)
5353
- };
5354
- }
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
5355
4560
  };
5356
- }
5357
- function shouldLog(loggerName) {
5358
- switch (logLevel) {
5359
- case "silent":
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])
5360
4566
  return false;
5361
- case "debug":
5362
- if (loggerName === "debug") {
5363
- return true;
5364
- }
5365
- case "log":
5366
- if (loggerName === "log") {
5367
- return true;
5368
- }
5369
- case "warn":
5370
- if (loggerName === "warn") {
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
5371
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
+ }
5372
4610
  }
5373
- case "error":
5374
- return loggerName === "error";
4611
+ n = wcwidth2(h, opts);
4612
+ if (n < 0)
4613
+ return -1;
4614
+ s += n;
4615
+ }
4616
+ return s;
5375
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
+ };
5376
4626
  }
5377
- }
5378
- var logger_default = createLogger;
4627
+ });
4628
+
4629
+ // src/cli/index.js
4630
+ import * as prettier2 from "../index.mjs";
5379
4631
 
5380
4632
  // scripts/build/shims/at.js
5381
4633
  var at = (isOptionalObject, object, index) => {
@@ -5393,21 +4645,6 @@ var at_default = at;
5393
4645
  var import_dashify = __toESM(require_dashify(), 1);
5394
4646
  import { getSupportInfo } from "../index.mjs";
5395
4647
 
5396
- // src/cli/prettier-internal.js
5397
- import { __internal as sharedWithCli } from "../index.mjs";
5398
- var {
5399
- errors,
5400
- optionCategories,
5401
- createIsIgnoredFunction,
5402
- formatOptionsHiddenDefaults,
5403
- normalizeOptions,
5404
- getSupportInfoWithoutPlugins,
5405
- normalizeOptionSettings,
5406
- vnopts,
5407
- fastGlob,
5408
- mockable
5409
- } = sharedWithCli;
5410
-
5411
4648
  // src/cli/cli-options.evaluate.js
5412
4649
  var cli_options_evaluate_default = {
5413
4650
  "cache": {
@@ -5563,297 +4800,816 @@ var cli_options_evaluate_default = {
5563
4800
  "description": "Print Prettier version.",
5564
4801
  "type": "boolean"
5565
4802
  },
5566
- "withNodeModules": {
5567
- "category": "Config",
5568
- "description": "Process files inside 'node_modules' directory.",
5569
- "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]
5570
5165
  },
5571
- "write": {
5572
- "alias": "w",
5573
- "category": "Output",
5574
- "description": "Edit files in-place. (Beware!)",
5575
- "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]
5576
5188
  }
5577
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;
5578
5310
 
5579
- // src/cli/options/get-context-options.js
5580
- var detailedCliOptions = normalizeOptionSettings(cli_options_evaluate_default).map(
5581
- (option) => normalizeDetailedOption(option)
5582
- );
5583
- function apiOptionToCliOption(apiOption) {
5584
- const cliOption = {
5585
- ...apiOption,
5586
- description: apiOption.cliDescription ?? apiOption.description,
5587
- category: apiOption.cliCategory ?? optionCategories.CATEGORY_FORMAT,
5588
- forwardToApi: apiOption.name
5589
- };
5590
- if (apiOption.deprecated) {
5591
- delete cliOption.forwardToApi;
5592
- delete cliOption.description;
5593
- delete cliOption.oppositeDescription;
5594
- cliOption.deprecated = true;
5595
- }
5596
- 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);
5597
5320
  }
5598
- function normalizeDetailedOption(option) {
5599
- var _a;
5600
- return {
5601
- category: optionCategories.CATEGORY_OTHER,
5602
- ...option,
5603
- name: option.cliName ?? (0, import_dashify.default)(option.name),
5604
- choices: (_a = option.choices) == null ? void 0 : _a.map((choice) => {
5605
- const newChoice = {
5606
- description: "",
5607
- deprecated: false,
5608
- ...typeof choice === "object" ? choice : { value: choice }
5609
- };
5610
- if (newChoice.value === true) {
5611
- newChoice.value = "";
5612
- }
5613
- return newChoice;
5614
- })
5615
- };
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;
5616
5327
  }
5617
- function supportInfoToContextOptions({ options: supportOptions, languages }) {
5618
- const detailedOptions = [
5619
- ...detailedCliOptions,
5620
- ...supportOptions.map((apiOption) => apiOptionToCliOption(apiOption))
5621
- ];
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
+ }
5622
5343
  return {
5623
- supportOptions,
5624
- languages,
5625
- detailedOptions
5344
+ level,
5345
+ hasBasic: true,
5346
+ has256: level >= 2,
5347
+ has16m: level >= 3
5626
5348
  };
5627
5349
  }
5628
- async function getContextOptions(plugins) {
5629
- const supportInfo = await getSupportInfo({
5630
- showDeprecated: true,
5631
- plugins
5632
- });
5633
- return supportInfoToContextOptions(supportInfo);
5634
- }
5635
- function getContextOptionsWithoutPlugins() {
5636
- const supportInfo = getSupportInfoWithoutPlugins();
5637
- return supportInfoToContextOptions(supportInfo);
5638
- }
5639
-
5640
- // node_modules/camelcase/index.js
5641
- var UPPERCASE = /[\p{Lu}]/u;
5642
- var LOWERCASE = /[\p{Ll}]/u;
5643
- var LEADING_CAPITAL = /^[\p{Lu}](?![\p{Lu}])/gu;
5644
- var IDENTIFIER = /([\p{Alpha}\p{N}_]|$)/u;
5645
- var SEPARATORS = /[_.\- ]+/;
5646
- var LEADING_SEPARATORS = new RegExp("^" + SEPARATORS.source);
5647
- var SEPARATORS_AND_IDENTIFIER = new RegExp(SEPARATORS.source + IDENTIFIER.source, "gu");
5648
- var NUMBERS_AND_IDENTIFIER = new RegExp("\\d+" + IDENTIFIER.source, "gu");
5649
- var preserveCamelCase = (string, toLowerCase, toUpperCase, preserveConsecutiveUppercase2) => {
5650
- let isLastCharLower = false;
5651
- let isLastCharUpper = false;
5652
- let isLastLastCharUpper = false;
5653
- let isLastLastCharPreserved = false;
5654
- for (let index = 0; index < string.length; index++) {
5655
- const character = string[index];
5656
- isLastLastCharPreserved = index > 2 ? string[index - 3] === "-" : true;
5657
- if (isLastCharLower && UPPERCASE.test(character)) {
5658
- string = string.slice(0, index) + "-" + string.slice(index);
5659
- isLastCharLower = false;
5660
- isLastLastCharUpper = isLastCharUpper;
5661
- isLastCharUpper = true;
5662
- index++;
5663
- } else if (isLastCharUpper && isLastLastCharUpper && LOWERCASE.test(character) && (!isLastLastCharPreserved || preserveConsecutiveUppercase2)) {
5664
- string = string.slice(0, index - 1) + "-" + string.slice(index - 1);
5665
- isLastLastCharUpper = isLastCharUpper;
5666
- isLastCharUpper = false;
5667
- isLastCharLower = true;
5668
- } else {
5669
- isLastCharLower = toLowerCase(character) === character && toUpperCase(character) !== character;
5670
- isLastLastCharUpper = isLastCharUpper;
5671
- 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;
5672
5365
  }
5673
5366
  }
5674
- return string;
5675
- };
5676
- var preserveConsecutiveUppercase = (input, toLowerCase) => {
5677
- LEADING_CAPITAL.lastIndex = 0;
5678
- return string_replace_all_default(
5679
- /* isOptionalObject*/
5680
- false,
5681
- input,
5682
- LEADING_CAPITAL,
5683
- (match) => toLowerCase(match)
5684
- );
5685
- };
5686
- var postProcess = (input, toUpperCase) => {
5687
- SEPARATORS_AND_IDENTIFIER.lastIndex = 0;
5688
- NUMBERS_AND_IDENTIFIER.lastIndex = 0;
5689
- return string_replace_all_default(
5690
- /* isOptionalObject*/
5691
- false,
5692
- string_replace_all_default(
5693
- /* isOptionalObject*/
5694
- false,
5695
- input,
5696
- NUMBERS_AND_IDENTIFIER,
5697
- (match, pattern, offset) => ["_", "-"].includes(input.charAt(offset + match.length)) ? match : toUpperCase(match)
5698
- ),
5699
- SEPARATORS_AND_IDENTIFIER,
5700
- (_, identifier) => toUpperCase(identifier)
5701
- );
5702
- };
5703
- function camelCase(input, options) {
5704
- if (!(typeof input === "string" || Array.isArray(input))) {
5705
- throw new TypeError("Expected the input to be `string | string[]`");
5367
+ if ("TF_BUILD" in env && "AGENT_NAME" in env) {
5368
+ return 1;
5706
5369
  }
5707
- options = {
5708
- pascalCase: false,
5709
- preserveConsecutiveUppercase: false,
5710
- ...options
5711
- };
5712
- if (Array.isArray(input)) {
5713
- input = input.map((x) => x.trim()).filter((x) => x.length).join("-");
5714
- } else {
5715
- input = input.trim();
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;
5716
5392
  }
5717
- if (input.length === 0) {
5718
- return "";
5393
+ if ("TEAMCITY_VERSION" in env) {
5394
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
5719
5395
  }
5720
- const toLowerCase = options.locale === false ? (string) => string.toLowerCase() : (string) => string.toLocaleLowerCase(options.locale);
5721
- const toUpperCase = options.locale === false ? (string) => string.toUpperCase() : (string) => string.toLocaleUpperCase(options.locale);
5722
- if (input.length === 1) {
5723
- if (SEPARATORS.test(input)) {
5724
- return "";
5396
+ if (env.COLORTERM === "truecolor") {
5397
+ return 3;
5398
+ }
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
+ }
5725
5411
  }
5726
- return options.pascalCase ? toUpperCase(input) : toLowerCase(input);
5727
5412
  }
5728
- const hasUpperCase = input !== toLowerCase(input);
5729
- if (hasUpperCase) {
5730
- input = preserveCamelCase(input, toLowerCase, toUpperCase, options.preserveConsecutiveUppercase);
5413
+ if (/-256(color)?$/i.test(env.TERM)) {
5414
+ return 2;
5731
5415
  }
5732
- input = input.replace(LEADING_SEPARATORS, "");
5733
- input = options.preserveConsecutiveUppercase ? preserveConsecutiveUppercase(input, toLowerCase) : toLowerCase(input);
5734
- if (options.pascalCase) {
5735
- 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;
5736
5418
  }
5737
- return postProcess(input, toUpperCase);
5738
- }
5739
-
5740
- // src/cli/utils.js
5741
- import fs from "fs/promises";
5742
- import path from "path";
5743
-
5744
- // node_modules/sdbm/index.js
5745
- function sdbm(string) {
5746
- let hash = 0;
5747
- for (let i = 0; i < string.length; i++) {
5748
- hash = string.charCodeAt(i) + (hash << 6) + (hash << 16) - hash;
5419
+ if ("COLORTERM" in env) {
5420
+ return 1;
5749
5421
  }
5750
- 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);
5751
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;
5752
5436
 
5753
- // src/cli/utils.js
5754
- import { __internal as sharedWithCli2 } from "../index.mjs";
5755
- var printToScreen = console.log.bind(console);
5756
- function groupBy(array2, iteratee) {
5757
- const result = /* @__PURE__ */ Object.create(null);
5758
- for (const value of array2) {
5759
- const key = iteratee(value);
5760
- if (Array.isArray(result[key])) {
5761
- result[key].push(value);
5762
- } else {
5763
- result[key] = [value];
5764
- }
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;
5765
5442
  }
5766
- 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;
5767
5453
  }
5768
- function pick(object, keys) {
5769
- const entries = keys.map((key) => [key, object[key]]);
5770
- 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;
5771
5465
  }
5772
- function createHash(source) {
5773
- 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);
5774
5494
  }
5775
- async function statSafe(filePath) {
5776
- try {
5777
- return await fs.stat(filePath);
5778
- } catch (error) {
5779
- if (error.code !== "ENOENT") {
5780
- 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;
5781
5502
  }
5782
- }
5503
+ };
5783
5504
  }
5784
- async function lstatSafe(filePath) {
5785
- try {
5786
- return await fs.lstat(filePath);
5787
- } catch (error) {
5788
- if (error.code !== "ENOENT") {
5789
- 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_);
5516
+ }
5517
+ if (level === "ansi256") {
5518
+ return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
5790
5519
  }
5520
+ return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
5791
5521
  }
5792
- }
5793
- function isJson(value) {
5794
- try {
5795
- JSON.parse(value);
5796
- return true;
5797
- } catch {
5798
- return false;
5522
+ if (model === "hex") {
5523
+ return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
5799
5524
  }
5800
- }
5801
- var normalizeToPosix = path.sep === "\\" ? (filepath) => string_replace_all_default(
5802
- /* isOptionalObject*/
5803
- false,
5804
- filepath,
5805
- "\\",
5806
- "/"
5807
- ) : (filepath) => filepath;
5808
- var {
5809
- isNonEmptyArray,
5810
- partition,
5811
- omit
5812
- } = sharedWithCli2.utils;
5813
-
5814
- // src/cli/options/minimist.js
5815
- var import_minimist = __toESM(require_minimist(), 1);
5816
- var PLACEHOLDER = null;
5817
- function minimistParse(args, options) {
5818
- const boolean = options.boolean ?? [];
5819
- const defaults = options.default ?? {};
5820
- const booleanWithoutDefault = boolean.filter((key) => !(key in defaults));
5821
- const newDefaults = {
5822
- ...defaults,
5823
- ...Object.fromEntries(
5824
- booleanWithoutDefault.map((key) => [key, PLACEHOLDER])
5825
- )
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
+ }
5826
5537
  };
5827
- const parsed = (0, import_minimist.default)(args, { ...options, default: newDefaults });
5828
- return Object.fromEntries(
5829
- Object.entries(parsed).filter(([, value]) => value !== PLACEHOLDER)
5830
- );
5831
- }
5832
-
5833
- // src/cli/options/create-minimist-options.js
5834
- function createMinimistOptions(detailedOptions) {
5835
- const booleanNames = [];
5836
- const stringNames = [];
5837
- const defaultValues = {};
5838
- for (const option of detailedOptions) {
5839
- const { name, alias, type } = option;
5840
- const names = type === "boolean" ? booleanNames : stringNames;
5841
- names.push(name);
5842
- if (alias) {
5843
- 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
+ };
5844
5546
  }
5845
- if (!option.deprecated && (!option.forwardToApi || name === "plugin") && option.default !== void 0) {
5846
- 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;
5847
5559
  }
5848
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
+ }
5849
5572
  return {
5850
- // we use vnopts' AliasSchema to handle aliases for better error messages
5851
- alias: {},
5852
- boolean: booleanNames,
5853
- string: stringNames,
5854
- default: defaultValues
5573
+ open,
5574
+ close,
5575
+ openAll,
5576
+ closeAll,
5577
+ parent
5855
5578
  };
5856
- }
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;
5857
5613
 
5858
5614
  // node_modules/leven/index.js
5859
5615
  var array = [];
@@ -5965,238 +5721,140 @@ function parseArgv(rawArguments, detailedOptions, logger, keys) {
5965
5721
  Object.entries(normalized).map(([key, value]) => {
5966
5722
  const option = detailedOptions.find(({ name }) => name === key) || {};
5967
5723
  return [option.forwardToApi || camelCase(key), value];
5968
- })
5969
- ),
5970
- _: (_a = normalized._) == null ? void 0 : _a.map(String),
5971
- get __raw() {
5972
- return argv;
5973
- }
5974
- };
5975
- }
5976
- var { detailedOptions: detailedOptionsWithoutPlugins } = getContextOptionsWithoutPlugins();
5977
- function parseArgvWithoutPlugins(rawArguments, logger, keys) {
5978
- return parseArgv(
5979
- rawArguments,
5980
- detailedOptionsWithoutPlugins,
5981
- logger,
5982
- typeof keys === "string" ? [keys] : keys
5983
- );
5984
- }
5985
-
5986
- // src/cli/context.js
5987
- var _stack;
5988
- var Context = class {
5989
- constructor({
5990
- rawArguments,
5991
- logger
5992
- }) {
5993
- __privateAdd(this, _stack, []);
5994
- this.rawArguments = rawArguments;
5995
- this.logger = logger;
5996
- }
5997
- async init() {
5998
- const {
5999
- rawArguments,
6000
- logger
6001
- } = this;
6002
- const {
6003
- plugins
6004
- } = parseArgvWithoutPlugins(rawArguments, logger, ["plugin"]);
6005
- await this.pushContextPlugins(plugins);
6006
- const argv = parseArgv(rawArguments, this.detailedOptions, logger);
6007
- this.argv = argv;
6008
- this.filePatterns = argv._;
6009
- }
6010
- /**
6011
- * @param {string[]} plugins
6012
- */
6013
- async pushContextPlugins(plugins) {
6014
- const options = await getContextOptions(plugins);
6015
- __privateGet(this, _stack).push(options);
6016
- Object.assign(this, options);
6017
- }
6018
- popContextPlugins() {
6019
- __privateGet(this, _stack).pop();
6020
- Object.assign(this, at_default(
6021
- /* isOptionalObject*/
6022
- false,
6023
- __privateGet(this, _stack),
6024
- -1
6025
- ));
6026
- }
6027
- // eslint-disable-next-line getter-return
6028
- get performanceTestFlag() {
6029
- const {
6030
- debugBenchmark,
6031
- debugRepeat
6032
- } = this.argv;
6033
- if (debugBenchmark) {
6034
- return {
6035
- name: "--debug-benchmark",
6036
- debugBenchmark: true
6037
- };
6038
- }
6039
- if (debugRepeat > 0) {
6040
- return {
6041
- name: "--debug-repeat",
6042
- debugRepeat
6043
- };
6044
- }
6045
- const {
6046
- PRETTIER_PERF_REPEAT
6047
- } = process.env;
6048
- if (PRETTIER_PERF_REPEAT && /^\d+$/.test(PRETTIER_PERF_REPEAT)) {
6049
- return {
6050
- name: "PRETTIER_PERF_REPEAT (environment variable)",
6051
- debugRepeat: Number(PRETTIER_PERF_REPEAT)
6052
- };
6053
- }
6054
- }
6055
- };
6056
- _stack = new WeakMap();
6057
- var context_default = Context;
6058
-
6059
- // src/cli/constants.evaluate.js
6060
- var categoryOrder = [
6061
- "Output",
6062
- "Format",
6063
- "Config",
6064
- "Editor",
6065
- "Other"
6066
- ];
6067
- 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.";
6068
-
6069
- // src/cli/usage.js
6070
- var OPTION_USAGE_THRESHOLD = 25;
6071
- var CHOICE_USAGE_MARGIN = 3;
6072
- var CHOICE_USAGE_INDENTATION = 2;
6073
- function indent(str, spaces) {
6074
- return string_replace_all_default(
6075
- /* isOptionalObject*/
6076
- false,
6077
- str,
6078
- /^/gm,
6079
- " ".repeat(spaces)
6080
- );
6081
- }
6082
- function createDefaultValueDisplay(value) {
6083
- return Array.isArray(value) ? `[${value.map(createDefaultValueDisplay).join(", ")}]` : value;
6084
- }
6085
- function getOptionDefaultValue(context, optionName) {
6086
- var _a;
6087
- const option = context.detailedOptions.find(({
6088
- name
6089
- }) => name === optionName);
6090
- if ((option == null ? void 0 : option.default) !== void 0) {
6091
- return option.default;
6092
- }
6093
- const optionCamelName = camelCase(optionName);
6094
- return formatOptionsHiddenDefaults[optionCamelName] ?? ((_a = context.supportOptions.find((option2) => !option2.deprecated && option2.name === optionCamelName)) == null ? void 0 : _a.default);
6095
- }
6096
- function createOptionUsageHeader(option) {
6097
- const name = `--${option.name}`;
6098
- const alias = option.alias ? `-${option.alias},` : null;
6099
- const type = createOptionUsageType(option);
6100
- return [alias, name, type].filter(Boolean).join(" ");
6101
- }
6102
- function createOptionUsageRow(header, content, threshold) {
6103
- const separator = header.length >= threshold ? `
6104
- ${" ".repeat(threshold)}` : " ".repeat(threshold - header.length);
6105
- const description = string_replace_all_default(
6106
- /* isOptionalObject*/
6107
- false,
6108
- content,
6109
- "\n",
6110
- `
6111
- ${" ".repeat(threshold)}`
6112
- );
6113
- return `${header}${separator}${description}`;
6114
- }
6115
- function createOptionUsageType(option) {
6116
- switch (option.type) {
6117
- case "boolean":
6118
- return null;
6119
- case "choice":
6120
- return `<${option.choices.filter((choice) => !choice.deprecated).map((choice) => choice.value).join("|")}>`;
6121
- default:
6122
- return `<${option.type}>`;
6123
- }
6124
- }
6125
- function createChoiceUsages(choices, margin, indentation) {
6126
- const activeChoices = choices.filter((choice) => !choice.deprecated);
6127
- const threshold = Math.max(0, ...activeChoices.map((choice) => choice.value.length)) + margin;
6128
- return activeChoices.map((choice) => indent(createOptionUsageRow(choice.value, choice.description, threshold), indentation));
6129
- }
6130
- function createOptionUsage(context, option, threshold) {
6131
- const header = createOptionUsageHeader(option);
6132
- const optionDefaultValue = getOptionDefaultValue(context, option.name);
6133
- return createOptionUsageRow(header, `${option.description}${optionDefaultValue === void 0 ? "" : `
6134
- Defaults to ${createDefaultValueDisplay(optionDefaultValue)}.`}`, threshold);
6135
- }
6136
- function getOptionsWithOpposites(options) {
6137
- const optionsWithOpposites = options.map((option) => [option.description ? option : null, option.oppositeDescription ? {
6138
- ...option,
6139
- name: `no-${option.name}`,
6140
- type: "boolean",
6141
- description: option.oppositeDescription
6142
- } : null]);
6143
- return optionsWithOpposites.flat().filter(Boolean);
6144
- }
6145
- function createUsage(context) {
6146
- const sortedOptions = context.detailedOptions.sort((optionA, optionB) => optionA.name.localeCompare(optionB.name));
6147
- const options = getOptionsWithOpposites(sortedOptions).filter(
6148
- // remove unnecessary option (e.g. `semi`, `color`, etc.), which is only used for --help <flag>
6149
- (option) => !(option.type === "boolean" && option.oppositeDescription && !option.name.startsWith("no-"))
6150
- );
6151
- const groupedOptions = groupBy(options, (option) => option.category);
6152
- const firstCategories = categoryOrder.slice(0, -1);
6153
- const lastCategories = categoryOrder.slice(-1);
6154
- const restCategories = Object.keys(groupedOptions).filter((category) => !categoryOrder.includes(category));
6155
- const allCategories = [...firstCategories, ...restCategories, ...lastCategories];
6156
- const optionsUsage = allCategories.map((category) => {
6157
- const categoryOptions = groupedOptions[category].map((option) => createOptionUsage(context, option, OPTION_USAGE_THRESHOLD)).join("\n");
6158
- return `${category} options:
6159
-
6160
- ${indent(categoryOptions, 2)}`;
6161
- });
6162
- return [usageSummary, ...optionsUsage, ""].join("\n\n");
5724
+ })
5725
+ ),
5726
+ _: (_a = normalized._) == null ? void 0 : _a.map(String),
5727
+ get __raw() {
5728
+ return argv;
5729
+ }
5730
+ };
6163
5731
  }
6164
- function createPluginDefaults(pluginDefaults) {
6165
- if (!pluginDefaults || Object.keys(pluginDefaults).length === 0) {
6166
- return "";
6167
- }
6168
- const defaults = Object.entries(pluginDefaults).sort(([pluginNameA], [pluginNameB]) => pluginNameA.localeCompare(pluginNameB)).map(([plugin, value]) => `* ${plugin}: ${createDefaultValueDisplay(value)}`).join("\n");
6169
- return `
6170
- Plugin defaults:
6171
- ${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
+ );
6172
5740
  }
6173
- function createDetailedUsage(context, flag) {
6174
- const option = getOptionsWithOpposites(context.detailedOptions).find((option2) => option2.name === flag || option2.alias === flag);
6175
- const header = createOptionUsageHeader(option);
6176
- const description = `
6177
-
6178
- ${indent(option.description, 2)}`;
6179
- const choices = option.type !== "choice" ? "" : `
6180
5741
 
6181
- 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;
6182
5814
 
6183
- ${createChoiceUsages(option.choices, CHOICE_USAGE_MARGIN, CHOICE_USAGE_INDENTATION).join("\n")}`;
6184
- const optionDefaultValue = getOptionDefaultValue(context, option.name);
6185
- 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;
6186
5835
 
6187
- Default: ${createDefaultValueDisplay(optionDefaultValue)}` : "";
6188
- const pluginDefaults = createPluginDefaults(option.pluginDefaults);
6189
- 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
+ }
6190
5847
  }
5848
+ var find_config_path_default = logResolvedConfigPathOrDie;
6191
5849
 
6192
5850
  // src/cli/format.js
6193
5851
  import fs5 from "fs/promises";
6194
- import path8 from "path";
5852
+ import path9 from "path";
6195
5853
  var import_diff = __toESM(require_create(), 1);
6196
5854
  import * as prettier from "../index.mjs";
6197
5855
 
6198
5856
  // src/cli/expand-patterns.js
6199
- import path2 from "path";
5857
+ import path3 from "path";
6200
5858
  async function* expandPatterns(context) {
6201
5859
  const seen = /* @__PURE__ */ new Set();
6202
5860
  let noResults = true;
@@ -6212,7 +5870,7 @@ async function* expandPatterns(context) {
6212
5870
  };
6213
5871
  continue;
6214
5872
  }
6215
- const filename = path2.resolve(filePath);
5873
+ const filename = path3.resolve(filePath);
6216
5874
  if (seen.has(filename)) {
6217
5875
  continue;
6218
5876
  }
@@ -6241,7 +5899,7 @@ async function* expandPatternsInternal(context) {
6241
5899
  const cwd2 = process.cwd();
6242
5900
  const entries = [];
6243
5901
  for (const pattern of context.filePatterns) {
6244
- const absolutePath = path2.resolve(cwd2, pattern);
5902
+ const absolutePath = path3.resolve(cwd2, pattern);
6245
5903
  if (containsIgnoredPathSegment(absolutePath, cwd2, silentlyIgnoredDirs)) {
6246
5904
  continue;
6247
5905
  }
@@ -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",
@@ -6322,234 +5980,64 @@ var errorMessages = {
6322
5980
  emptyResults: {
6323
5981
  file: "Explicitly specified file was ignored due to negative glob patterns",
6324
5982
  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${filePath ? ` 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);
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
- function isTTY() {
6469
- 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
+ );
6470
6015
  }
6016
+ var fixWindowsSlashes = normalizeToPosix;
6471
6017
 
6472
6018
  // src/cli/find-cache-file.js
6473
6019
  import fs4 from "fs/promises";
6474
6020
  import os2 from "os";
6475
- import path7 from "path";
6021
+ import path8 from "path";
6476
6022
 
6477
6023
  // node_modules/find-cache-dir/index.js
6478
6024
  var import_common_path_prefix = __toESM(require_common_path_prefix(), 1);
6479
6025
  import process4 from "process";
6480
- import path6 from "path";
6026
+ import path7 from "path";
6481
6027
  import fs3 from "fs";
6482
6028
 
6483
6029
  // node_modules/pkg-dir/index.js
6484
- import path5 from "path";
6030
+ import path6 from "path";
6485
6031
 
6486
6032
  // node_modules/pkg-dir/node_modules/find-up/index.js
6487
- import path4 from "path";
6033
+ import path5 from "path";
6488
6034
  import { fileURLToPath as fileURLToPath2 } from "url";
6489
6035
 
6490
6036
  // node_modules/pkg-dir/node_modules/locate-path/index.js
6491
6037
  import process3 from "process";
6492
- import path3 from "path";
6038
+ import path4 from "path";
6493
6039
  import fs2, { promises as fsPromises } from "fs";
6494
6040
  import { fileURLToPath } from "url";
6495
-
6496
- // node_modules/pkg-dir/node_modules/yocto-queue/index.js
6497
- var Node = class {
6498
- value;
6499
- next;
6500
- constructor(value) {
6501
- this.value = value;
6502
- }
6503
- };
6504
- var _head, _tail, _size;
6505
- var Queue = class {
6506
- constructor() {
6507
- __privateAdd(this, _head, void 0);
6508
- __privateAdd(this, _tail, void 0);
6509
- __privateAdd(this, _size, void 0);
6510
- this.clear();
6511
- }
6512
- enqueue(value) {
6513
- const node = new Node(value);
6514
- if (__privateGet(this, _head)) {
6515
- __privateGet(this, _tail).next = node;
6516
- __privateSet(this, _tail, node);
6517
- } else {
6518
- __privateSet(this, _head, node);
6519
- __privateSet(this, _tail, node);
6520
- }
6521
- __privateWrapper(this, _size)._++;
6522
- }
6523
- dequeue() {
6524
- const current = __privateGet(this, _head);
6525
- if (!current) {
6526
- return;
6527
- }
6528
- __privateSet(this, _head, __privateGet(this, _head).next);
6529
- __privateWrapper(this, _size)._--;
6530
- return current.value;
6531
- }
6532
- clear() {
6533
- __privateSet(this, _head, void 0);
6534
- __privateSet(this, _tail, void 0);
6535
- __privateSet(this, _size, 0);
6536
- }
6537
- get size() {
6538
- return __privateGet(this, _size);
6539
- }
6540
- *[Symbol.iterator]() {
6541
- let current = __privateGet(this, _head);
6542
- while (current) {
6543
- yield current.value;
6544
- current = current.next;
6545
- }
6546
- }
6547
- };
6548
- _head = new WeakMap();
6549
- _tail = new WeakMap();
6550
- _size = new WeakMap();
6551
-
6552
- // node_modules/pkg-dir/node_modules/locate-path/index.js
6553
6041
  var typeMappings = {
6554
6042
  directory: "isDirectory",
6555
6043
  file: "isFile"
@@ -6572,7 +6060,7 @@ function locatePathSync(paths, {
6572
6060
  const statFunction = allowSymlinks ? fs2.statSync : fs2.lstatSync;
6573
6061
  for (const path_ of paths) {
6574
6062
  try {
6575
- const stat = statFunction(path3.resolve(cwd2, path_), {
6063
+ const stat = statFunction(path4.resolve(cwd2, path_), {
6576
6064
  throwIfNoEntry: false
6577
6065
  });
6578
6066
  if (!stat) {
@@ -6590,8 +6078,8 @@ function locatePathSync(paths, {
6590
6078
  var toPath2 = (urlOrPath) => urlOrPath instanceof URL ? fileURLToPath2(urlOrPath) : urlOrPath;
6591
6079
  var findUpStop = Symbol("findUpStop");
6592
6080
  function findUpMultipleSync(name, options = {}) {
6593
- let directory = path4.resolve(toPath2(options.cwd) || "");
6594
- const { root } = path4.parse(directory);
6081
+ let directory = path5.resolve(toPath2(options.cwd) || "");
6082
+ const { root } = path5.parse(directory);
6595
6083
  const stopAt = options.stopAt || root;
6596
6084
  const limit = options.limit || Number.POSITIVE_INFINITY;
6597
6085
  const paths = [name].flat();
@@ -6612,12 +6100,12 @@ function findUpMultipleSync(name, options = {}) {
6612
6100
  break;
6613
6101
  }
6614
6102
  if (foundPath) {
6615
- matches.push(path4.resolve(directory, foundPath));
6103
+ matches.push(path5.resolve(directory, foundPath));
6616
6104
  }
6617
6105
  if (directory === stopAt || matches.length >= limit) {
6618
6106
  break;
6619
6107
  }
6620
- directory = path4.dirname(directory);
6108
+ directory = path5.dirname(directory);
6621
6109
  }
6622
6110
  return matches;
6623
6111
  }
@@ -6629,7 +6117,7 @@ function findUpSync(name, options = {}) {
6629
6117
  // node_modules/pkg-dir/index.js
6630
6118
  function packageDirectorySync({ cwd: cwd2 } = {}) {
6631
6119
  const filePath = findUpSync("package.json", { cwd: cwd2 });
6632
- return filePath && path5.dirname(filePath);
6120
+ return filePath && path6.dirname(filePath);
6633
6121
  }
6634
6122
 
6635
6123
  // node_modules/find-cache-dir/index.js
@@ -6649,22 +6137,22 @@ function useDirectory(directory, options) {
6649
6137
  return directory;
6650
6138
  }
6651
6139
  function getNodeModuleDirectory(directory) {
6652
- const nodeModules = path6.join(directory, "node_modules");
6653
- 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)))) {
6654
6142
  return;
6655
6143
  }
6656
6144
  return nodeModules;
6657
6145
  }
6658
6146
  function findCacheDirectory(options = {}) {
6659
6147
  if (env2.CACHE_DIR && !["true", "false", "1", "0"].includes(env2.CACHE_DIR)) {
6660
- return useDirectory(path6.join(env2.CACHE_DIR, options.name), options);
6148
+ return useDirectory(path7.join(env2.CACHE_DIR, options.name), options);
6661
6149
  }
6662
6150
  let { cwd: directory = cwd(), files } = options;
6663
6151
  if (files) {
6664
6152
  if (!Array.isArray(files)) {
6665
6153
  throw new TypeError(`Expected \`files\` option to be an array, got \`${typeof files}\`.`);
6666
6154
  }
6667
- 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)));
6668
6156
  }
6669
6157
  directory = packageDirectorySync({ cwd: directory });
6670
6158
  if (!directory) {
@@ -6674,17 +6162,17 @@ function findCacheDirectory(options = {}) {
6674
6162
  if (!nodeModules) {
6675
6163
  return;
6676
6164
  }
6677
- return useDirectory(path6.join(directory, "node_modules", ".cache", options.name), options);
6165
+ return useDirectory(path7.join(directory, "node_modules", ".cache", options.name), options);
6678
6166
  }
6679
6167
 
6680
6168
  // src/cli/find-cache-file.js
6681
6169
  function findDefaultCacheFile() {
6682
6170
  const cacheDir = findCacheDirectory({ name: "prettier", create: true }) || os2.tmpdir();
6683
- const cacheFilePath = path7.join(cacheDir, ".prettier-cache");
6171
+ const cacheFilePath = path8.join(cacheDir, ".prettier-cache");
6684
6172
  return cacheFilePath;
6685
6173
  }
6686
6174
  async function findCacheFileFromOption(cacheLocation) {
6687
- const cacheFile = path7.resolve(cacheLocation);
6175
+ const cacheFile = path8.resolve(cacheLocation);
6688
6176
  const stat = await statSafe(cacheFile);
6689
6177
  if (stat) {
6690
6178
  if (stat.isDirectory()) {
@@ -6709,8 +6197,8 @@ async function findCacheFile(cacheLocation) {
6709
6197
  var find_cache_file_default = findCacheFile;
6710
6198
 
6711
6199
  // src/cli/format-results-cache.js
6200
+ var import_fast_json_stable_stringify2 = __toESM(require_fast_json_stable_stringify(), 1);
6712
6201
  var import_file_entry_cache = __toESM(require_cache2(), 1);
6713
- var import_fast_json_stable_stringify = __toESM(require_fast_json_stable_stringify(), 1);
6714
6202
  import { version as prettierVersion } from "../index.mjs";
6715
6203
  var optionsHashCache = /* @__PURE__ */ new WeakMap();
6716
6204
  var nodeVersion = process.version;
@@ -6719,7 +6207,7 @@ function getHashOfOptions(options) {
6719
6207
  return optionsHashCache.get(options);
6720
6208
  }
6721
6209
  const hash = createHash(
6722
- `${prettierVersion}_${nodeVersion}_${(0, import_fast_json_stable_stringify.default)(options)}`
6210
+ `${prettierVersion}_${nodeVersion}_${(0, import_fast_json_stable_stringify2.default)(options)}`
6723
6211
  );
6724
6212
  optionsHashCache.set(options, hash);
6725
6213
  return hash;
@@ -6782,6 +6270,118 @@ var FormatResultsCache = class {
6782
6270
  _fileEntryCache = new WeakMap();
6783
6271
  var format_results_cache_default = FormatResultsCache;
6784
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
+
6785
6385
  // src/cli/format.js
6786
6386
  var { getStdin, writeFormattedFile } = mockable;
6787
6387
  function diff(a, b) {
@@ -6846,7 +6446,7 @@ async function listDifferent(context, input, options, filename) {
6846
6446
  }
6847
6447
  return true;
6848
6448
  }
6849
- async function format2(context, input, opt) {
6449
+ async function format3(context, input, opt) {
6850
6450
  if (context.argv.debugPrintDoc) {
6851
6451
  const doc = await prettier.__debug.printToDoc(input, opt);
6852
6452
  return { formatted: await prettier.__debug.formatDoc(doc) + "\n" };
@@ -6979,12 +6579,12 @@ async function formatStdin(context) {
6979
6579
  }
6980
6580
  const options = await get_options_for_file_default(
6981
6581
  context,
6982
- filepath ? path8.resolve(filepath) : void 0
6582
+ filepath ? path9.resolve(filepath) : void 0
6983
6583
  );
6984
6584
  if (await listDifferent(context, input, options, "(stdin)")) {
6985
6585
  return;
6986
6586
  }
6987
- const formatted = await format2(context, input, options);
6587
+ const formatted = await format3(context, input, options);
6988
6588
  const { performanceTestFlag } = context;
6989
6589
  if (performanceTestFlag) {
6990
6590
  context.logger.log(
@@ -7034,7 +6634,7 @@ async function formatFiles(context) {
7034
6634
  ...await get_options_for_file_default(context, filename),
7035
6635
  filepath: filename
7036
6636
  };
7037
- const fileNameToDisplay = normalizeToPosix(path8.relative(cwd2, filename));
6637
+ const fileNameToDisplay = normalizeToPosix(path9.relative(cwd2, filename));
7038
6638
  let printedFilename;
7039
6639
  if (isTTY()) {
7040
6640
  printedFilename = context.logger.log(fileNameToDisplay, {
@@ -7070,7 +6670,7 @@ ${error2.message}`
7070
6670
  if (isCacheExists) {
7071
6671
  result = { formatted: input };
7072
6672
  } else {
7073
- result = await format2(context, input, options);
6673
+ result = await format3(context, input, options);
7074
6674
  }
7075
6675
  output = result.formatted;
7076
6676
  } catch (error2) {
@@ -7124,74 +6724,143 @@ ${error2.message}`
7124
6724
  } else if (!context.argv.check && !context.argv.listDifferent) {
7125
6725
  writeOutput(context, result, options);
7126
6726
  }
7127
- if (shouldSetCache) {
7128
- formatResultsCache == null ? void 0 : formatResultsCache.setFormatResultsCache(filename, options);
7129
- } else {
7130
- 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;
7131
6813
  }
7132
- if (isDifferent) {
7133
- if (context.argv.check) {
7134
- context.logger.warn(fileNameToDisplay);
7135
- } else if (context.argv.listDifferent) {
7136
- 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
+ };
7137
6835
  }
7138
- numberOfUnformattedFilesFound += 1;
7139
- }
6836
+ };
7140
6837
  }
7141
- formatResultsCache == null ? void 0 : formatResultsCache.reconcile();
7142
- if (context.argv.check) {
7143
- if (numberOfUnformattedFilesFound === 0) {
7144
- context.logger.log("All matched files use Prettier code style!");
7145
- } else {
7146
- const files = numberOfUnformattedFilesFound === 1 ? "the above file" : `${numberOfUnformattedFilesFound} files`;
7147
- context.logger.warn(
7148
- context.argv.write ? `Code style issues fixed in ${files}.` : `Code style issues found in ${files}. Run Prettier to fix.`
7149
- );
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";
7150
6856
  }
7151
6857
  }
7152
- if ((context.argv.check || context.argv.listDifferent) && numberOfUnformattedFilesFound > 0 && !process.exitCode && !context.argv.write) {
7153
- process.exitCode = 1;
7154
- }
7155
- }
7156
-
7157
- // src/cli/file-info.js
7158
- var import_fast_json_stable_stringify2 = __toESM(require_fast_json_stable_stringify(), 1);
7159
- import { format as format3, getFileInfo } from "../index.mjs";
7160
- async function logFileInfoOrDie(context) {
7161
- const {
7162
- fileInfo: file,
7163
- ignorePath,
7164
- withNodeModules,
7165
- plugins,
7166
- config
7167
- } = context.argv;
7168
- const fileInfo = await getFileInfo(file, {
7169
- ignorePath,
7170
- withNodeModules,
7171
- plugins,
7172
- resolveConfig: config !== false
7173
- });
7174
- printToScreen(await format3((0, import_fast_json_stable_stringify2.default)(fileInfo), { parser: "json" }));
7175
- }
7176
- var file_info_default = logFileInfoOrDie;
7177
-
7178
- // src/cli/find-config-path.js
7179
- import path9 from "path";
7180
- import { resolveConfigFile } from "../index.mjs";
7181
- async function logResolvedConfigPathOrDie(context) {
7182
- const file = context.argv.findConfigPath;
7183
- const configFile = await resolveConfigFile(file);
7184
- if (configFile) {
7185
- printToScreen(normalizeToPosix(path9.relative(process.cwd(), configFile)));
7186
- } else {
7187
- throw new Error(`Can not find configure file for "${file}".`);
7188
- }
7189
6858
  }
7190
- var find_config_path_default = logResolvedConfigPathOrDie;
6859
+ var logger_default = createLogger;
7191
6860
 
7192
6861
  // src/cli/print-support-info.js
7193
6862
  var import_fast_json_stable_stringify3 = __toESM(require_fast_json_stable_stringify(), 1);
7194
- import { getSupportInfo as getSupportInfo2, format as format4 } from "../index.mjs";
6863
+ import { format as format4, getSupportInfo as getSupportInfo2 } from "../index.mjs";
7195
6864
  var sortByName = (array2) => array2.sort((a, b) => a.name.localeCompare(b.name));
7196
6865
  async function printSupportInfo() {
7197
6866
  const { languages, options } = await getSupportInfo2();
@@ -7205,6 +6874,139 @@ async function printSupportInfo() {
7205
6874
  }
7206
6875
  var print_support_info_default = printSupportInfo;
7207
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
+
7208
7010
  // src/cli/index.js
7209
7011
  async function run(rawArguments = process.argv.slice(2)) {
7210
7012
  let logger = logger_default();