prettier 4.0.0-alpha.6 → 4.0.0-alpha.8

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
@@ -64,232 +64,6 @@ var __privateWrapper = (obj, member, setter, getter) => ({
64
64
  }
65
65
  });
66
66
 
67
- // node_modules/wcwidth.js/combining.js
68
- var require_combining = __commonJS({
69
- "node_modules/wcwidth.js/combining.js"(exports, module) {
70
- module.exports = [
71
- [768, 879],
72
- [1155, 1158],
73
- [1160, 1161],
74
- [1425, 1469],
75
- [1471, 1471],
76
- [1473, 1474],
77
- [1476, 1477],
78
- [1479, 1479],
79
- [1536, 1539],
80
- [1552, 1557],
81
- [1611, 1630],
82
- [1648, 1648],
83
- [1750, 1764],
84
- [1767, 1768],
85
- [1770, 1773],
86
- [1807, 1807],
87
- [1809, 1809],
88
- [1840, 1866],
89
- [1958, 1968],
90
- [2027, 2035],
91
- [2305, 2306],
92
- [2364, 2364],
93
- [2369, 2376],
94
- [2381, 2381],
95
- [2385, 2388],
96
- [2402, 2403],
97
- [2433, 2433],
98
- [2492, 2492],
99
- [2497, 2500],
100
- [2509, 2509],
101
- [2530, 2531],
102
- [2561, 2562],
103
- [2620, 2620],
104
- [2625, 2626],
105
- [2631, 2632],
106
- [2635, 2637],
107
- [2672, 2673],
108
- [2689, 2690],
109
- [2748, 2748],
110
- [2753, 2757],
111
- [2759, 2760],
112
- [2765, 2765],
113
- [2786, 2787],
114
- [2817, 2817],
115
- [2876, 2876],
116
- [2879, 2879],
117
- [2881, 2883],
118
- [2893, 2893],
119
- [2902, 2902],
120
- [2946, 2946],
121
- [3008, 3008],
122
- [3021, 3021],
123
- [3134, 3136],
124
- [3142, 3144],
125
- [3146, 3149],
126
- [3157, 3158],
127
- [3260, 3260],
128
- [3263, 3263],
129
- [3270, 3270],
130
- [3276, 3277],
131
- [3298, 3299],
132
- [3393, 3395],
133
- [3405, 3405],
134
- [3530, 3530],
135
- [3538, 3540],
136
- [3542, 3542],
137
- [3633, 3633],
138
- [3636, 3642],
139
- [3655, 3662],
140
- [3761, 3761],
141
- [3764, 3769],
142
- [3771, 3772],
143
- [3784, 3789],
144
- [3864, 3865],
145
- [3893, 3893],
146
- [3895, 3895],
147
- [3897, 3897],
148
- [3953, 3966],
149
- [3968, 3972],
150
- [3974, 3975],
151
- [3984, 3991],
152
- [3993, 4028],
153
- [4038, 4038],
154
- [4141, 4144],
155
- [4146, 4146],
156
- [4150, 4151],
157
- [4153, 4153],
158
- [4184, 4185],
159
- [4448, 4607],
160
- [4959, 4959],
161
- [5906, 5908],
162
- [5938, 5940],
163
- [5970, 5971],
164
- [6002, 6003],
165
- [6068, 6069],
166
- [6071, 6077],
167
- [6086, 6086],
168
- [6089, 6099],
169
- [6109, 6109],
170
- [6155, 6157],
171
- [6313, 6313],
172
- [6432, 6434],
173
- [6439, 6440],
174
- [6450, 6450],
175
- [6457, 6459],
176
- [6679, 6680],
177
- [6912, 6915],
178
- [6964, 6964],
179
- [6966, 6970],
180
- [6972, 6972],
181
- [6978, 6978],
182
- [7019, 7027],
183
- [7616, 7626],
184
- [7678, 7679],
185
- [8203, 8207],
186
- [8234, 8238],
187
- [8288, 8291],
188
- [8298, 8303],
189
- [8400, 8431],
190
- [12330, 12335],
191
- [12441, 12442],
192
- [43014, 43014],
193
- [43019, 43019],
194
- [43045, 43046],
195
- [64286, 64286],
196
- [65024, 65039],
197
- [65056, 65059],
198
- [65279, 65279],
199
- [65529, 65531],
200
- [68097, 68099],
201
- [68101, 68102],
202
- [68108, 68111],
203
- [68152, 68154],
204
- [68159, 68159],
205
- [119143, 119145],
206
- [119155, 119170],
207
- [119173, 119179],
208
- [119210, 119213],
209
- [119362, 119364],
210
- [917505, 917505],
211
- [917536, 917631],
212
- [917760, 917999]
213
- ];
214
- }
215
- });
216
-
217
- // node_modules/wcwidth.js/index.js
218
- var require_wcwidth = __commonJS({
219
- "node_modules/wcwidth.js/index.js"(exports, module) {
220
- var combining = require_combining();
221
- var DEFAULTS = {
222
- nul: 0,
223
- control: 0
224
- };
225
- function bisearch(ucs) {
226
- let min = 0;
227
- let max = combining.length - 1;
228
- let mid;
229
- if (ucs < combining[0][0] || ucs > combining[max][1])
230
- return false;
231
- while (max >= min) {
232
- mid = Math.floor((min + max) / 2);
233
- if (ucs > combining[mid][1])
234
- min = mid + 1;
235
- else if (ucs < combining[mid][0])
236
- max = mid - 1;
237
- else
238
- return true;
239
- }
240
- return false;
241
- }
242
- function wcwidth2(ucs, opts) {
243
- if (ucs === 0)
244
- return opts.nul;
245
- if (ucs < 32 || ucs >= 127 && ucs < 160)
246
- return opts.control;
247
- if (bisearch(ucs))
248
- return 0;
249
- return 1 + (ucs >= 4352 && (ucs <= 4447 || // Hangul Jamo init. consonants
250
- ucs == 9001 || ucs == 9002 || ucs >= 11904 && ucs <= 42191 && ucs != 12351 || // CJK ... Yi
251
- ucs >= 44032 && ucs <= 55203 || // Hangul Syllables
252
- ucs >= 63744 && ucs <= 64255 || // CJK Compatibility Ideographs
253
- ucs >= 65040 && ucs <= 65049 || // Vertical forms
254
- ucs >= 65072 && ucs <= 65135 || // CJK Compatibility Forms
255
- ucs >= 65280 && ucs <= 65376 || // Fullwidth Forms
256
- ucs >= 65504 && ucs <= 65510 || ucs >= 131072 && ucs <= 196605 || ucs >= 196608 && ucs <= 262141));
257
- }
258
- function wcswidth(str, opts) {
259
- let h;
260
- let l;
261
- let s = 0;
262
- let n;
263
- if (typeof str !== "string")
264
- return wcwidth2(str, opts);
265
- for (let i = 0; i < str.length; i++) {
266
- h = str.charCodeAt(i);
267
- if (h >= 55296 && h <= 56319) {
268
- l = str.charCodeAt(++i);
269
- if (l >= 56320 && l <= 57343) {
270
- h = (h - 55296) * 1024 + (l - 56320) + 65536;
271
- } else {
272
- i--;
273
- }
274
- }
275
- n = wcwidth2(h, opts);
276
- if (n < 0)
277
- return -1;
278
- s += n;
279
- }
280
- return s;
281
- }
282
- module.exports = (str) => wcswidth(str, DEFAULTS);
283
- module.exports.config = (opts = {}) => {
284
- opts = {
285
- ...DEFAULTS,
286
- ...opts
287
- };
288
- return (str) => wcswidth(str, opts);
289
- };
290
- }
291
- });
292
-
293
67
  // node_modules/dashify/index.js
294
68
  var require_dashify = __commonJS({
295
69
  "node_modules/dashify/index.js"(exports, module) {
@@ -524,34 +298,100 @@ var require_minimist = __commonJS({
524
298
  }
525
299
  });
526
300
 
527
- // node_modules/diff/lib/diff/base.js
528
- var require_base = __commonJS({
529
- "node_modules/diff/lib/diff/base.js"(exports) {
301
+ // node_modules/fast-json-stable-stringify/index.js
302
+ var require_fast_json_stable_stringify = __commonJS({
303
+ "node_modules/fast-json-stable-stringify/index.js"(exports, module) {
530
304
  "use strict";
531
- Object.defineProperty(exports, "__esModule", {
532
- value: true
533
- });
534
- exports["default"] = Diff;
535
- function Diff() {
536
- }
537
- Diff.prototype = {
538
- /*istanbul ignore start*/
539
- /*istanbul ignore end*/
540
- diff: function diff2(oldString, newString) {
541
- var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
542
- var callback = options.callback;
543
- if (typeof options === "function") {
544
- callback = options;
545
- options = {};
546
- }
547
- this.options = options;
548
- var self = this;
549
- function done(value) {
550
- if (callback) {
551
- setTimeout(function() {
552
- callback(void 0, value);
553
- }, 0);
554
- return true;
305
+ module.exports = function(data, opts) {
306
+ if (!opts)
307
+ opts = {};
308
+ if (typeof opts === "function")
309
+ opts = { cmp: opts };
310
+ var cycles = typeof opts.cycles === "boolean" ? opts.cycles : false;
311
+ var cmp = opts.cmp && /* @__PURE__ */ function(f) {
312
+ return function(node) {
313
+ return function(a, b) {
314
+ var aobj = { key: a, value: node[a] };
315
+ var bobj = { key: b, value: node[b] };
316
+ return f(aobj, bobj);
317
+ };
318
+ };
319
+ }(opts.cmp);
320
+ var seen = [];
321
+ return function stringify4(node) {
322
+ if (node && node.toJSON && typeof node.toJSON === "function") {
323
+ node = node.toJSON();
324
+ }
325
+ if (node === void 0)
326
+ return;
327
+ if (typeof node == "number")
328
+ return isFinite(node) ? "" + node : "null";
329
+ if (typeof node !== "object")
330
+ return JSON.stringify(node);
331
+ var i, out;
332
+ if (Array.isArray(node)) {
333
+ out = "[";
334
+ for (i = 0; i < node.length; i++) {
335
+ if (i)
336
+ out += ",";
337
+ out += stringify4(node[i]) || "null";
338
+ }
339
+ return out + "]";
340
+ }
341
+ if (node === null)
342
+ return "null";
343
+ if (seen.indexOf(node) !== -1) {
344
+ if (cycles)
345
+ return JSON.stringify("__cycle__");
346
+ throw new TypeError("Converting circular structure to JSON");
347
+ }
348
+ var seenIndex = seen.push(node) - 1;
349
+ var keys = Object.keys(node).sort(cmp && cmp(node));
350
+ out = "";
351
+ for (i = 0; i < keys.length; i++) {
352
+ var key = keys[i];
353
+ var value = stringify4(node[key]);
354
+ if (!value)
355
+ continue;
356
+ if (out)
357
+ out += ",";
358
+ out += JSON.stringify(key) + ":" + value;
359
+ }
360
+ seen.splice(seenIndex, 1);
361
+ return "{" + out + "}";
362
+ }(data);
363
+ };
364
+ }
365
+ });
366
+
367
+ // node_modules/diff/lib/diff/base.js
368
+ var require_base = __commonJS({
369
+ "node_modules/diff/lib/diff/base.js"(exports) {
370
+ "use strict";
371
+ Object.defineProperty(exports, "__esModule", {
372
+ value: true
373
+ });
374
+ exports["default"] = Diff;
375
+ function Diff() {
376
+ }
377
+ Diff.prototype = {
378
+ /*istanbul ignore start*/
379
+ /*istanbul ignore end*/
380
+ diff: function diff2(oldString, newString) {
381
+ var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
382
+ var callback = options.callback;
383
+ if (typeof options === "function") {
384
+ callback = options;
385
+ options = {};
386
+ }
387
+ this.options = options;
388
+ var self = this;
389
+ function done(value) {
390
+ if (callback) {
391
+ setTimeout(function() {
392
+ callback(void 0, value);
393
+ }, 0);
394
+ return true;
555
395
  } else {
556
396
  return value;
557
397
  }
@@ -4568,1160 +4408,1216 @@ var require_cache2 = __commonJS({
4568
4408
  }
4569
4409
  });
4570
4410
 
4571
- // node_modules/fast-json-stable-stringify/index.js
4572
- var require_fast_json_stable_stringify = __commonJS({
4573
- "node_modules/fast-json-stable-stringify/index.js"(exports, module) {
4574
- "use strict";
4575
- module.exports = function(data, opts) {
4576
- if (!opts)
4577
- opts = {};
4578
- if (typeof opts === "function")
4579
- opts = { cmp: opts };
4580
- var cycles = typeof opts.cycles === "boolean" ? opts.cycles : false;
4581
- var cmp = opts.cmp && /* @__PURE__ */ function(f) {
4582
- return function(node) {
4583
- return function(a, b) {
4584
- var aobj = { key: a, value: node[a] };
4585
- var bobj = { key: b, value: node[b] };
4586
- return f(aobj, bobj);
4587
- };
4588
- };
4589
- }(opts.cmp);
4590
- var seen = [];
4591
- return function stringify4(node) {
4592
- if (node && node.toJSON && typeof node.toJSON === "function") {
4593
- node = node.toJSON();
4594
- }
4595
- if (node === void 0)
4596
- return;
4597
- if (typeof node == "number")
4598
- return isFinite(node) ? "" + node : "null";
4599
- if (typeof node !== "object")
4600
- return JSON.stringify(node);
4601
- var i, out;
4602
- if (Array.isArray(node)) {
4603
- out = "[";
4604
- for (i = 0; i < node.length; i++) {
4605
- if (i)
4606
- out += ",";
4607
- out += stringify4(node[i]) || "null";
4608
- }
4609
- return out + "]";
4610
- }
4611
- if (node === null)
4612
- return "null";
4613
- if (seen.indexOf(node) !== -1) {
4614
- if (cycles)
4615
- return JSON.stringify("__cycle__");
4616
- throw new TypeError("Converting circular structure to JSON");
4617
- }
4618
- var seenIndex = seen.push(node) - 1;
4619
- var keys = Object.keys(node).sort(cmp && cmp(node));
4620
- out = "";
4621
- for (i = 0; i < keys.length; i++) {
4622
- var key = keys[i];
4623
- var value = stringify4(node[key]);
4624
- if (!value)
4625
- continue;
4626
- if (out)
4627
- out += ",";
4628
- out += JSON.stringify(key) + ":" + value;
4629
- }
4630
- seen.splice(seenIndex, 1);
4631
- return "{" + out + "}";
4632
- }(data);
4633
- };
4634
- }
4635
- });
4636
-
4637
- // src/cli/index.js
4638
- import * as prettier2 from "../index.mjs";
4639
-
4640
- // scripts/build/shims/string-replace-all.js
4641
- var stringReplaceAll = (isOptionalObject, original, pattern, replacement) => {
4642
- if (isOptionalObject && (original === void 0 || original === null)) {
4643
- return;
4644
- }
4645
- if (original.replaceAll) {
4646
- return original.replaceAll(pattern, replacement);
4647
- }
4648
- if (pattern.global) {
4649
- return original.replace(pattern, replacement);
4650
- }
4651
- return original.split(pattern).join(replacement);
4652
- };
4653
- var string_replace_all_default = stringReplaceAll;
4654
-
4655
- // src/cli/logger.js
4656
- import readline from "readline";
4657
-
4658
- // node_modules/chalk/source/vendor/ansi-styles/index.js
4659
- var ANSI_BACKGROUND_OFFSET = 10;
4660
- var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
4661
- var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
4662
- var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
4663
- var styles = {
4664
- modifier: {
4665
- reset: [0, 0],
4666
- // 21 isn't widely supported and 22 does the same thing
4667
- bold: [1, 22],
4668
- dim: [2, 22],
4669
- italic: [3, 23],
4670
- underline: [4, 24],
4671
- overline: [53, 55],
4672
- inverse: [7, 27],
4673
- hidden: [8, 28],
4674
- strikethrough: [9, 29]
4675
- },
4676
- color: {
4677
- black: [30, 39],
4678
- red: [31, 39],
4679
- green: [32, 39],
4680
- yellow: [33, 39],
4681
- blue: [34, 39],
4682
- magenta: [35, 39],
4683
- cyan: [36, 39],
4684
- white: [37, 39],
4685
- // Bright color
4686
- blackBright: [90, 39],
4687
- gray: [90, 39],
4688
- // Alias of `blackBright`
4689
- grey: [90, 39],
4690
- // Alias of `blackBright`
4691
- redBright: [91, 39],
4692
- greenBright: [92, 39],
4693
- yellowBright: [93, 39],
4694
- blueBright: [94, 39],
4695
- magentaBright: [95, 39],
4696
- cyanBright: [96, 39],
4697
- whiteBright: [97, 39]
4698
- },
4699
- bgColor: {
4700
- bgBlack: [40, 49],
4701
- bgRed: [41, 49],
4702
- bgGreen: [42, 49],
4703
- bgYellow: [43, 49],
4704
- bgBlue: [44, 49],
4705
- bgMagenta: [45, 49],
4706
- bgCyan: [46, 49],
4707
- bgWhite: [47, 49],
4708
- // Bright color
4709
- bgBlackBright: [100, 49],
4710
- bgGray: [100, 49],
4711
- // Alias of `bgBlackBright`
4712
- bgGrey: [100, 49],
4713
- // Alias of `bgBlackBright`
4714
- bgRedBright: [101, 49],
4715
- bgGreenBright: [102, 49],
4716
- bgYellowBright: [103, 49],
4717
- bgBlueBright: [104, 49],
4718
- bgMagentaBright: [105, 49],
4719
- bgCyanBright: [106, 49],
4720
- bgWhiteBright: [107, 49]
4721
- }
4722
- };
4723
- var modifierNames = Object.keys(styles.modifier);
4724
- var foregroundColorNames = Object.keys(styles.color);
4725
- var backgroundColorNames = Object.keys(styles.bgColor);
4726
- var colorNames = [...foregroundColorNames, ...backgroundColorNames];
4727
- function assembleStyles() {
4728
- const codes = /* @__PURE__ */ new Map();
4729
- for (const [groupName, group] of Object.entries(styles)) {
4730
- for (const [styleName, style] of Object.entries(group)) {
4731
- styles[styleName] = {
4732
- open: `\x1B[${style[0]}m`,
4733
- close: `\x1B[${style[1]}m`
4734
- };
4735
- group[styleName] = styles[styleName];
4736
- codes.set(style[0], style[1]);
4737
- }
4738
- Object.defineProperty(styles, groupName, {
4739
- value: group,
4740
- enumerable: false
4741
- });
4411
+ // node_modules/wcwidth.js/combining.js
4412
+ var require_combining = __commonJS({
4413
+ "node_modules/wcwidth.js/combining.js"(exports, module) {
4414
+ module.exports = [
4415
+ [768, 879],
4416
+ [1155, 1158],
4417
+ [1160, 1161],
4418
+ [1425, 1469],
4419
+ [1471, 1471],
4420
+ [1473, 1474],
4421
+ [1476, 1477],
4422
+ [1479, 1479],
4423
+ [1536, 1539],
4424
+ [1552, 1557],
4425
+ [1611, 1630],
4426
+ [1648, 1648],
4427
+ [1750, 1764],
4428
+ [1767, 1768],
4429
+ [1770, 1773],
4430
+ [1807, 1807],
4431
+ [1809, 1809],
4432
+ [1840, 1866],
4433
+ [1958, 1968],
4434
+ [2027, 2035],
4435
+ [2305, 2306],
4436
+ [2364, 2364],
4437
+ [2369, 2376],
4438
+ [2381, 2381],
4439
+ [2385, 2388],
4440
+ [2402, 2403],
4441
+ [2433, 2433],
4442
+ [2492, 2492],
4443
+ [2497, 2500],
4444
+ [2509, 2509],
4445
+ [2530, 2531],
4446
+ [2561, 2562],
4447
+ [2620, 2620],
4448
+ [2625, 2626],
4449
+ [2631, 2632],
4450
+ [2635, 2637],
4451
+ [2672, 2673],
4452
+ [2689, 2690],
4453
+ [2748, 2748],
4454
+ [2753, 2757],
4455
+ [2759, 2760],
4456
+ [2765, 2765],
4457
+ [2786, 2787],
4458
+ [2817, 2817],
4459
+ [2876, 2876],
4460
+ [2879, 2879],
4461
+ [2881, 2883],
4462
+ [2893, 2893],
4463
+ [2902, 2902],
4464
+ [2946, 2946],
4465
+ [3008, 3008],
4466
+ [3021, 3021],
4467
+ [3134, 3136],
4468
+ [3142, 3144],
4469
+ [3146, 3149],
4470
+ [3157, 3158],
4471
+ [3260, 3260],
4472
+ [3263, 3263],
4473
+ [3270, 3270],
4474
+ [3276, 3277],
4475
+ [3298, 3299],
4476
+ [3393, 3395],
4477
+ [3405, 3405],
4478
+ [3530, 3530],
4479
+ [3538, 3540],
4480
+ [3542, 3542],
4481
+ [3633, 3633],
4482
+ [3636, 3642],
4483
+ [3655, 3662],
4484
+ [3761, 3761],
4485
+ [3764, 3769],
4486
+ [3771, 3772],
4487
+ [3784, 3789],
4488
+ [3864, 3865],
4489
+ [3893, 3893],
4490
+ [3895, 3895],
4491
+ [3897, 3897],
4492
+ [3953, 3966],
4493
+ [3968, 3972],
4494
+ [3974, 3975],
4495
+ [3984, 3991],
4496
+ [3993, 4028],
4497
+ [4038, 4038],
4498
+ [4141, 4144],
4499
+ [4146, 4146],
4500
+ [4150, 4151],
4501
+ [4153, 4153],
4502
+ [4184, 4185],
4503
+ [4448, 4607],
4504
+ [4959, 4959],
4505
+ [5906, 5908],
4506
+ [5938, 5940],
4507
+ [5970, 5971],
4508
+ [6002, 6003],
4509
+ [6068, 6069],
4510
+ [6071, 6077],
4511
+ [6086, 6086],
4512
+ [6089, 6099],
4513
+ [6109, 6109],
4514
+ [6155, 6157],
4515
+ [6313, 6313],
4516
+ [6432, 6434],
4517
+ [6439, 6440],
4518
+ [6450, 6450],
4519
+ [6457, 6459],
4520
+ [6679, 6680],
4521
+ [6912, 6915],
4522
+ [6964, 6964],
4523
+ [6966, 6970],
4524
+ [6972, 6972],
4525
+ [6978, 6978],
4526
+ [7019, 7027],
4527
+ [7616, 7626],
4528
+ [7678, 7679],
4529
+ [8203, 8207],
4530
+ [8234, 8238],
4531
+ [8288, 8291],
4532
+ [8298, 8303],
4533
+ [8400, 8431],
4534
+ [12330, 12335],
4535
+ [12441, 12442],
4536
+ [43014, 43014],
4537
+ [43019, 43019],
4538
+ [43045, 43046],
4539
+ [64286, 64286],
4540
+ [65024, 65039],
4541
+ [65056, 65059],
4542
+ [65279, 65279],
4543
+ [65529, 65531],
4544
+ [68097, 68099],
4545
+ [68101, 68102],
4546
+ [68108, 68111],
4547
+ [68152, 68154],
4548
+ [68159, 68159],
4549
+ [119143, 119145],
4550
+ [119155, 119170],
4551
+ [119173, 119179],
4552
+ [119210, 119213],
4553
+ [119362, 119364],
4554
+ [917505, 917505],
4555
+ [917536, 917631],
4556
+ [917760, 917999]
4557
+ ];
4742
4558
  }
4743
- Object.defineProperty(styles, "codes", {
4744
- value: codes,
4745
- enumerable: false
4746
- });
4747
- styles.color.close = "\x1B[39m";
4748
- styles.bgColor.close = "\x1B[49m";
4749
- styles.color.ansi = wrapAnsi16();
4750
- styles.color.ansi256 = wrapAnsi256();
4751
- styles.color.ansi16m = wrapAnsi16m();
4752
- styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
4753
- styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
4754
- styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
4755
- Object.defineProperties(styles, {
4756
- rgbToAnsi256: {
4757
- value(red, green, blue) {
4758
- if (red === green && green === blue) {
4759
- if (red < 8) {
4760
- return 16;
4761
- }
4762
- if (red > 248) {
4763
- return 231;
4764
- }
4765
- return Math.round((red - 8) / 247 * 24) + 232;
4766
- }
4767
- return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
4768
- },
4769
- enumerable: false
4770
- },
4771
- hexToRgb: {
4772
- value(hex) {
4773
- const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
4774
- if (!matches) {
4775
- return [0, 0, 0];
4776
- }
4777
- let [colorString] = matches;
4778
- if (colorString.length === 3) {
4779
- colorString = [...colorString].map((character) => character + character).join("");
4780
- }
4781
- const integer = Number.parseInt(colorString, 16);
4782
- return [
4783
- /* eslint-disable no-bitwise */
4784
- integer >> 16 & 255,
4785
- integer >> 8 & 255,
4786
- integer & 255
4787
- /* eslint-enable no-bitwise */
4788
- ];
4789
- },
4790
- enumerable: false
4791
- },
4792
- hexToAnsi256: {
4793
- value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
4794
- enumerable: false
4795
- },
4796
- ansi256ToAnsi: {
4797
- value(code) {
4798
- if (code < 8) {
4799
- return 30 + code;
4800
- }
4801
- if (code < 16) {
4802
- return 90 + (code - 8);
4803
- }
4804
- let red;
4805
- let green;
4806
- let blue;
4807
- if (code >= 232) {
4808
- red = ((code - 232) * 10 + 8) / 255;
4809
- green = red;
4810
- blue = red;
4811
- } else {
4812
- code -= 16;
4813
- const remainder = code % 36;
4814
- red = Math.floor(code / 36) / 5;
4815
- green = Math.floor(remainder / 6) / 5;
4816
- blue = remainder % 6 / 5;
4817
- }
4818
- const value = Math.max(red, green, blue) * 2;
4819
- if (value === 0) {
4820
- return 30;
4821
- }
4822
- let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
4823
- if (value === 2) {
4824
- result += 60;
4825
- }
4826
- return result;
4827
- },
4828
- enumerable: false
4829
- },
4830
- rgbToAnsi: {
4831
- value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
4832
- enumerable: false
4833
- },
4834
- hexToAnsi: {
4835
- value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
4836
- enumerable: false
4837
- }
4838
- });
4839
- return styles;
4840
- }
4841
- var ansiStyles = assembleStyles();
4842
- var ansi_styles_default = ansiStyles;
4559
+ });
4843
4560
 
4844
- // node_modules/chalk/source/vendor/supports-color/index.js
4845
- import process2 from "process";
4846
- import os from "os";
4847
- import tty from "tty";
4848
- function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process2.argv) {
4849
- const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
4850
- const position = argv.indexOf(prefix + flag);
4851
- const terminatorPosition = argv.indexOf("--");
4852
- return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
4853
- }
4854
- var { env } = process2;
4855
- var flagForceColor;
4856
- if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
4857
- flagForceColor = 0;
4858
- } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
4859
- flagForceColor = 1;
4860
- }
4861
- function envForceColor() {
4862
- if ("FORCE_COLOR" in env) {
4863
- if (env.FORCE_COLOR === "true") {
4864
- return 1;
4865
- }
4866
- if (env.FORCE_COLOR === "false") {
4867
- return 0;
4868
- }
4869
- return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
4870
- }
4871
- }
4872
- function translateLevel(level) {
4873
- if (level === 0) {
4874
- return false;
4875
- }
4876
- return {
4877
- level,
4878
- hasBasic: true,
4879
- has256: level >= 2,
4880
- has16m: level >= 3
4881
- };
4882
- }
4883
- function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
4884
- const noFlagForceColor = envForceColor();
4885
- if (noFlagForceColor !== void 0) {
4886
- flagForceColor = noFlagForceColor;
4887
- }
4888
- const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
4889
- if (forceColor === 0) {
4890
- return 0;
4891
- }
4892
- if (sniffFlags) {
4893
- if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
4894
- return 3;
4895
- }
4896
- if (hasFlag("color=256")) {
4897
- return 2;
4898
- }
4899
- }
4900
- if ("TF_BUILD" in env && "AGENT_NAME" in env) {
4901
- return 1;
4902
- }
4903
- if (haveStream && !streamIsTTY && forceColor === void 0) {
4904
- return 0;
4905
- }
4906
- const min = forceColor || 0;
4907
- if (env.TERM === "dumb") {
4908
- return min;
4909
- }
4910
- if (process2.platform === "win32") {
4911
- const osRelease = os.release().split(".");
4912
- if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
4913
- return Number(osRelease[2]) >= 14931 ? 3 : 2;
4561
+ // node_modules/wcwidth.js/index.js
4562
+ var require_wcwidth = __commonJS({
4563
+ "node_modules/wcwidth.js/index.js"(exports, module) {
4564
+ var combining = require_combining();
4565
+ var DEFAULTS = {
4566
+ nul: 0,
4567
+ control: 0
4568
+ };
4569
+ function bisearch(ucs) {
4570
+ let min = 0;
4571
+ let max = combining.length - 1;
4572
+ let mid;
4573
+ if (ucs < combining[0][0] || ucs > combining[max][1])
4574
+ return false;
4575
+ while (max >= min) {
4576
+ mid = Math.floor((min + max) / 2);
4577
+ if (ucs > combining[mid][1])
4578
+ min = mid + 1;
4579
+ else if (ucs < combining[mid][0])
4580
+ max = mid - 1;
4581
+ else
4582
+ return true;
4583
+ }
4584
+ return false;
4914
4585
  }
4915
- return 1;
4916
- }
4917
- if ("CI" in env) {
4918
- if ("GITHUB_ACTIONS" in env || "GITEA_ACTIONS" in env) {
4919
- return 3;
4586
+ function wcwidth2(ucs, opts) {
4587
+ if (ucs === 0)
4588
+ return opts.nul;
4589
+ if (ucs < 32 || ucs >= 127 && ucs < 160)
4590
+ return opts.control;
4591
+ if (bisearch(ucs))
4592
+ return 0;
4593
+ return 1 + (ucs >= 4352 && (ucs <= 4447 || // Hangul Jamo init. consonants
4594
+ ucs == 9001 || ucs == 9002 || ucs >= 11904 && ucs <= 42191 && ucs != 12351 || // CJK ... Yi
4595
+ ucs >= 44032 && ucs <= 55203 || // Hangul Syllables
4596
+ ucs >= 63744 && ucs <= 64255 || // CJK Compatibility Ideographs
4597
+ ucs >= 65040 && ucs <= 65049 || // Vertical forms
4598
+ ucs >= 65072 && ucs <= 65135 || // CJK Compatibility Forms
4599
+ ucs >= 65280 && ucs <= 65376 || // Fullwidth Forms
4600
+ ucs >= 65504 && ucs <= 65510 || ucs >= 131072 && ucs <= 196605 || ucs >= 196608 && ucs <= 262141));
4920
4601
  }
4921
- if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
4922
- return 1;
4602
+ function wcswidth(str, opts) {
4603
+ let h;
4604
+ let l;
4605
+ let s = 0;
4606
+ let n;
4607
+ if (typeof str !== "string")
4608
+ return wcwidth2(str, opts);
4609
+ for (let i = 0; i < str.length; i++) {
4610
+ h = str.charCodeAt(i);
4611
+ if (h >= 55296 && h <= 56319) {
4612
+ l = str.charCodeAt(++i);
4613
+ if (l >= 56320 && l <= 57343) {
4614
+ h = (h - 55296) * 1024 + (l - 56320) + 65536;
4615
+ } else {
4616
+ i--;
4617
+ }
4618
+ }
4619
+ n = wcwidth2(h, opts);
4620
+ if (n < 0)
4621
+ return -1;
4622
+ s += n;
4623
+ }
4624
+ return s;
4923
4625
  }
4924
- return min;
4925
- }
4926
- if ("TEAMCITY_VERSION" in env) {
4927
- return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
4626
+ module.exports = (str) => wcswidth(str, DEFAULTS);
4627
+ module.exports.config = (opts = {}) => {
4628
+ opts = {
4629
+ ...DEFAULTS,
4630
+ ...opts
4631
+ };
4632
+ return (str) => wcswidth(str, opts);
4633
+ };
4928
4634
  }
4929
- if (env.COLORTERM === "truecolor") {
4930
- return 3;
4635
+ });
4636
+
4637
+ // src/cli/index.js
4638
+ import * as prettier2 from "../index.mjs";
4639
+
4640
+ // scripts/build/shims/at.js
4641
+ var at = (isOptionalObject, object, index) => {
4642
+ if (isOptionalObject && (object === void 0 || object === null)) {
4643
+ return;
4931
4644
  }
4932
- if (env.TERM === "xterm-kitty") {
4933
- return 3;
4645
+ if (Array.isArray(object) || typeof object === "string") {
4646
+ return object[index < 0 ? object.length + index : index];
4934
4647
  }
4935
- if ("TERM_PROGRAM" in env) {
4936
- const version2 = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
4937
- switch (env.TERM_PROGRAM) {
4938
- case "iTerm.app": {
4939
- return version2 >= 3 ? 3 : 2;
4648
+ return object.at(index);
4649
+ };
4650
+ var at_default = at;
4651
+
4652
+ // src/cli/options/get-context-options.js
4653
+ var import_dashify = __toESM(require_dashify(), 1);
4654
+ import { getSupportInfo } from "../index.mjs";
4655
+
4656
+ // src/cli/cli-options.evaluate.js
4657
+ var cli_options_evaluate_default = {
4658
+ "cache": {
4659
+ "default": false,
4660
+ "description": "Only format changed files. Cannot use with --stdin-filepath.",
4661
+ "type": "boolean"
4662
+ },
4663
+ "cacheLocation": {
4664
+ "description": "Path to the cache file.",
4665
+ "type": "path"
4666
+ },
4667
+ "cacheStrategy": {
4668
+ "choices": [
4669
+ {
4670
+ "description": "Use the file metadata such as timestamps as cache keys",
4671
+ "value": "metadata"
4672
+ },
4673
+ {
4674
+ "description": "Use the file content as cache keys",
4675
+ "value": "content"
4940
4676
  }
4941
- case "Apple_Terminal": {
4942
- return 2;
4677
+ ],
4678
+ "description": "Strategy for the cache to use for detecting changed files.",
4679
+ "type": "choice"
4680
+ },
4681
+ "check": {
4682
+ "alias": "c",
4683
+ "category": "Output",
4684
+ "description": "Check if the given files are formatted, print a human-friendly summary\nmessage and paths to unformatted files (see also --list-different).",
4685
+ "type": "boolean"
4686
+ },
4687
+ "color": {
4688
+ "default": true,
4689
+ "description": "Colorize error messages.",
4690
+ "oppositeDescription": "Do not colorize error messages.",
4691
+ "type": "boolean"
4692
+ },
4693
+ "config": {
4694
+ "category": "Config",
4695
+ "description": "Path to a Prettier configuration file (.prettierrc, package.json, prettier.config.js).",
4696
+ "exception": (value) => value === false,
4697
+ "oppositeDescription": "Do not look for a configuration file.",
4698
+ "type": "path"
4699
+ },
4700
+ "configPrecedence": {
4701
+ "category": "Config",
4702
+ "choices": [
4703
+ {
4704
+ "description": "CLI options take precedence over config file",
4705
+ "value": "cli-override"
4706
+ },
4707
+ {
4708
+ "description": "Config file take precedence over CLI options",
4709
+ "value": "file-override"
4710
+ },
4711
+ {
4712
+ "description": "If a config file is found will evaluate it and ignore other CLI options.\nIf no config file is found CLI options will evaluate as normal.",
4713
+ "value": "prefer-file"
4943
4714
  }
4944
- }
4945
- }
4946
- if (/-256(color)?$/i.test(env.TERM)) {
4947
- return 2;
4948
- }
4949
- if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
4950
- return 1;
4951
- }
4952
- if ("COLORTERM" in env) {
4953
- return 1;
4715
+ ],
4716
+ "default": "cli-override",
4717
+ "description": "Define in which order config files and CLI options should be evaluated.",
4718
+ "type": "choice"
4719
+ },
4720
+ "debugBenchmark": {
4721
+ "type": "boolean"
4722
+ },
4723
+ "debugCheck": {
4724
+ "type": "boolean"
4725
+ },
4726
+ "debugPrintAst": {
4727
+ "type": "boolean"
4728
+ },
4729
+ "debugPrintComments": {
4730
+ "type": "boolean"
4731
+ },
4732
+ "debugPrintDoc": {
4733
+ "type": "boolean"
4734
+ },
4735
+ "debugRepeat": {
4736
+ "default": 0,
4737
+ "type": "int"
4738
+ },
4739
+ "editorconfig": {
4740
+ "category": "Config",
4741
+ "default": true,
4742
+ "description": "Take .editorconfig into account when parsing configuration.",
4743
+ "oppositeDescription": "Don't take .editorconfig into account when parsing configuration.",
4744
+ "type": "boolean"
4745
+ },
4746
+ "errorOnUnmatchedPattern": {
4747
+ "oppositeDescription": "Prevent errors when pattern is unmatched.",
4748
+ "type": "boolean"
4749
+ },
4750
+ "fileInfo": {
4751
+ "description": "Extract the following info (as JSON) for a given file path. Reported fields:\n* ignored (boolean) - true if file path is filtered by --ignore-path\n* inferredParser (string | null) - name of parser inferred from file path",
4752
+ "type": "path"
4753
+ },
4754
+ "findConfigPath": {
4755
+ "category": "Config",
4756
+ "description": "Find and print the path to a configuration file for the given input file.",
4757
+ "type": "path"
4758
+ },
4759
+ "help": {
4760
+ "alias": "h",
4761
+ "description": "Show CLI usage, or details about the given flag.\nExample: --help write",
4762
+ "exception": (value) => value === "",
4763
+ "type": "flag"
4764
+ },
4765
+ "ignorePath": {
4766
+ "array": true,
4767
+ "category": "Config",
4768
+ "default": [
4769
+ {
4770
+ "value": [
4771
+ ".gitignore",
4772
+ ".prettierignore"
4773
+ ]
4774
+ }
4775
+ ],
4776
+ "description": "Path to a file with patterns describing files to ignore.\nMultiple values are accepted.",
4777
+ "type": "path"
4778
+ },
4779
+ "ignoreUnknown": {
4780
+ "alias": "u",
4781
+ "description": "Ignore unknown files.",
4782
+ "type": "boolean"
4783
+ },
4784
+ "listDifferent": {
4785
+ "alias": "l",
4786
+ "category": "Output",
4787
+ "description": "Print the names of files that are different from Prettier's formatting (see also --check).",
4788
+ "type": "boolean"
4789
+ },
4790
+ "logLevel": {
4791
+ "choices": [
4792
+ "silent",
4793
+ "error",
4794
+ "warn",
4795
+ "log",
4796
+ "debug"
4797
+ ],
4798
+ "default": "log",
4799
+ "description": "What level of logs to report.",
4800
+ "type": "choice"
4801
+ },
4802
+ "supportInfo": {
4803
+ "description": "Print support information as JSON.",
4804
+ "type": "boolean"
4805
+ },
4806
+ "version": {
4807
+ "alias": "v",
4808
+ "description": "Print Prettier version.",
4809
+ "type": "boolean"
4810
+ },
4811
+ "withNodeModules": {
4812
+ "category": "Config",
4813
+ "description": "Process files inside 'node_modules' directory.",
4814
+ "type": "boolean"
4815
+ },
4816
+ "write": {
4817
+ "alias": "w",
4818
+ "category": "Output",
4819
+ "description": "Edit files in-place. (Beware!)",
4820
+ "type": "boolean"
4954
4821
  }
4955
- return min;
4956
- }
4957
- function createSupportsColor(stream, options = {}) {
4958
- const level = _supportsColor(stream, {
4959
- streamIsTTY: stream && stream.isTTY,
4960
- ...options
4961
- });
4962
- return translateLevel(level);
4963
- }
4964
- var supportsColor = {
4965
- stdout: createSupportsColor({ isTTY: tty.isatty(1) }),
4966
- stderr: createSupportsColor({ isTTY: tty.isatty(2) })
4967
4822
  };
4968
- var supports_color_default = supportsColor;
4969
4823
 
4970
- // node_modules/chalk/source/utilities.js
4971
- function stringReplaceAll2(string, substring, replacer) {
4972
- let index = string.indexOf(substring);
4973
- if (index === -1) {
4974
- return string;
4975
- }
4976
- const substringLength = substring.length;
4977
- let endIndex = 0;
4978
- let returnValue = "";
4979
- do {
4980
- returnValue += string.slice(endIndex, index) + substring + replacer;
4981
- endIndex = index + substringLength;
4982
- index = string.indexOf(substring, endIndex);
4983
- } while (index !== -1);
4984
- returnValue += string.slice(endIndex);
4985
- return returnValue;
4986
- }
4987
- function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
4988
- let endIndex = 0;
4989
- let returnValue = "";
4990
- do {
4991
- const gotCR = string[index - 1] === "\r";
4992
- returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
4993
- endIndex = index + 1;
4994
- index = string.indexOf("\n", endIndex);
4995
- } while (index !== -1);
4996
- returnValue += string.slice(endIndex);
4997
- return returnValue;
4998
- }
4824
+ // src/cli/prettier-internal.js
4825
+ import { __internal as sharedWithCli } from "../index.mjs";
4826
+ var {
4827
+ errors,
4828
+ optionCategories,
4829
+ createIsIgnoredFunction,
4830
+ formatOptionsHiddenDefaults,
4831
+ normalizeOptions,
4832
+ getSupportInfoWithoutPlugins,
4833
+ normalizeOptionSettings,
4834
+ vnopts,
4835
+ fastGlob,
4836
+ mockable
4837
+ } = sharedWithCli;
4999
4838
 
5000
- // node_modules/chalk/source/index.js
5001
- var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;
5002
- var GENERATOR = Symbol("GENERATOR");
5003
- var STYLER = Symbol("STYLER");
5004
- var IS_EMPTY = Symbol("IS_EMPTY");
5005
- var levelMapping = [
5006
- "ansi",
5007
- "ansi",
5008
- "ansi256",
5009
- "ansi16m"
5010
- ];
5011
- var styles2 = /* @__PURE__ */ Object.create(null);
5012
- var applyOptions = (object, options = {}) => {
5013
- if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
5014
- throw new Error("The `level` option should be an integer from 0 to 3");
4839
+ // src/cli/options/get-context-options.js
4840
+ var detailedCliOptions = normalizeOptionSettings(cli_options_evaluate_default).map(
4841
+ (option) => normalizeDetailedOption(option)
4842
+ );
4843
+ function apiOptionToCliOption(apiOption) {
4844
+ const cliOption = {
4845
+ ...apiOption,
4846
+ description: apiOption.cliDescription ?? apiOption.description,
4847
+ category: apiOption.cliCategory ?? optionCategories.CATEGORY_FORMAT,
4848
+ forwardToApi: apiOption.name
4849
+ };
4850
+ if (apiOption.deprecated) {
4851
+ delete cliOption.forwardToApi;
4852
+ delete cliOption.description;
4853
+ delete cliOption.oppositeDescription;
4854
+ cliOption.deprecated = true;
5015
4855
  }
5016
- const colorLevel = stdoutColor ? stdoutColor.level : 0;
5017
- object.level = options.level === void 0 ? colorLevel : options.level;
5018
- };
5019
- var chalkFactory = (options) => {
5020
- const chalk2 = (...strings) => strings.join(" ");
5021
- applyOptions(chalk2, options);
5022
- Object.setPrototypeOf(chalk2, createChalk.prototype);
5023
- return chalk2;
5024
- };
5025
- function createChalk(options) {
5026
- return chalkFactory(options);
4856
+ return normalizeDetailedOption(cliOption);
5027
4857
  }
5028
- Object.setPrototypeOf(createChalk.prototype, Function.prototype);
5029
- for (const [styleName, style] of Object.entries(ansi_styles_default)) {
5030
- styles2[styleName] = {
5031
- get() {
5032
- const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
5033
- Object.defineProperty(this, styleName, { value: builder });
5034
- return builder;
5035
- }
4858
+ function normalizeDetailedOption(option) {
4859
+ var _a;
4860
+ return {
4861
+ category: optionCategories.CATEGORY_OTHER,
4862
+ ...option,
4863
+ name: option.cliName ?? (0, import_dashify.default)(option.name),
4864
+ choices: (_a = option.choices) == null ? void 0 : _a.map((choice) => {
4865
+ const newChoice = {
4866
+ description: "",
4867
+ deprecated: false,
4868
+ ...typeof choice === "object" ? choice : { value: choice }
4869
+ };
4870
+ if (newChoice.value === true) {
4871
+ newChoice.value = "";
4872
+ }
4873
+ return newChoice;
4874
+ })
5036
4875
  };
5037
4876
  }
5038
- styles2.visible = {
5039
- get() {
5040
- const builder = createBuilder(this, this[STYLER], true);
5041
- Object.defineProperty(this, "visible", { value: builder });
5042
- return builder;
4877
+ function supportInfoToContextOptions({ options: supportOptions, languages }) {
4878
+ const detailedOptions = [
4879
+ ...detailedCliOptions,
4880
+ ...supportOptions.map((apiOption) => apiOptionToCliOption(apiOption))
4881
+ ];
4882
+ return {
4883
+ supportOptions,
4884
+ languages,
4885
+ detailedOptions
4886
+ };
4887
+ }
4888
+ async function getContextOptions(plugins) {
4889
+ const supportInfo = await getSupportInfo({
4890
+ showDeprecated: true,
4891
+ plugins
4892
+ });
4893
+ return supportInfoToContextOptions(supportInfo);
4894
+ }
4895
+ function getContextOptionsWithoutPlugins() {
4896
+ const supportInfo = getSupportInfoWithoutPlugins();
4897
+ return supportInfoToContextOptions(supportInfo);
4898
+ }
4899
+
4900
+ // scripts/build/shims/string-replace-all.js
4901
+ var stringReplaceAll = (isOptionalObject, original, pattern, replacement) => {
4902
+ if (isOptionalObject && (original === void 0 || original === null)) {
4903
+ return;
5043
4904
  }
5044
- };
5045
- var getModelAnsi = (model, level, type, ...arguments_) => {
5046
- if (model === "rgb") {
5047
- if (level === "ansi16m") {
5048
- return ansi_styles_default[type].ansi16m(...arguments_);
5049
- }
5050
- if (level === "ansi256") {
5051
- return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
5052
- }
5053
- return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
4905
+ if (original.replaceAll) {
4906
+ return original.replaceAll(pattern, replacement);
5054
4907
  }
5055
- if (model === "hex") {
5056
- return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
4908
+ if (pattern.global) {
4909
+ return original.replace(pattern, replacement);
5057
4910
  }
5058
- return ansi_styles_default[type][model](...arguments_);
4911
+ return original.split(pattern).join(replacement);
5059
4912
  };
5060
- var usedModels = ["rgb", "hex", "ansi256"];
5061
- for (const model of usedModels) {
5062
- styles2[model] = {
5063
- get() {
5064
- const { level } = this;
5065
- return function(...arguments_) {
5066
- const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
5067
- return createBuilder(this, styler, this[IS_EMPTY]);
5068
- };
5069
- }
5070
- };
5071
- const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
5072
- styles2[bgModel] = {
5073
- get() {
5074
- const { level } = this;
5075
- return function(...arguments_) {
5076
- const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
5077
- return createBuilder(this, styler, this[IS_EMPTY]);
5078
- };
5079
- }
5080
- };
5081
- }
5082
- var proto = Object.defineProperties(() => {
5083
- }, {
5084
- ...styles2,
5085
- level: {
5086
- enumerable: true,
5087
- get() {
5088
- return this[GENERATOR].level;
5089
- },
5090
- set(level) {
5091
- this[GENERATOR].level = level;
5092
- }
5093
- }
5094
- });
5095
- var createStyler = (open, close, parent) => {
5096
- let openAll;
5097
- let closeAll;
5098
- if (parent === void 0) {
5099
- openAll = open;
5100
- closeAll = close;
5101
- } else {
5102
- openAll = parent.openAll + open;
5103
- closeAll = close + parent.closeAll;
4913
+ var string_replace_all_default = stringReplaceAll;
4914
+
4915
+ // node_modules/camelcase/index.js
4916
+ var UPPERCASE = /[\p{Lu}]/u;
4917
+ var LOWERCASE = /[\p{Ll}]/u;
4918
+ var LEADING_CAPITAL = /^[\p{Lu}](?![\p{Lu}])/gu;
4919
+ var IDENTIFIER = /([\p{Alpha}\p{N}_]|$)/u;
4920
+ var SEPARATORS = /[_.\- ]+/;
4921
+ var LEADING_SEPARATORS = new RegExp("^" + SEPARATORS.source);
4922
+ var SEPARATORS_AND_IDENTIFIER = new RegExp(SEPARATORS.source + IDENTIFIER.source, "gu");
4923
+ var NUMBERS_AND_IDENTIFIER = new RegExp("\\d+" + IDENTIFIER.source, "gu");
4924
+ var preserveCamelCase = (string, toLowerCase, toUpperCase, preserveConsecutiveUppercase2) => {
4925
+ let isLastCharLower = false;
4926
+ let isLastCharUpper = false;
4927
+ let isLastLastCharUpper = false;
4928
+ let isLastLastCharPreserved = false;
4929
+ for (let index = 0; index < string.length; index++) {
4930
+ const character = string[index];
4931
+ isLastLastCharPreserved = index > 2 ? string[index - 3] === "-" : true;
4932
+ if (isLastCharLower && UPPERCASE.test(character)) {
4933
+ string = string.slice(0, index) + "-" + string.slice(index);
4934
+ isLastCharLower = false;
4935
+ isLastLastCharUpper = isLastCharUpper;
4936
+ isLastCharUpper = true;
4937
+ index++;
4938
+ } else if (isLastCharUpper && isLastLastCharUpper && LOWERCASE.test(character) && (!isLastLastCharPreserved || preserveConsecutiveUppercase2)) {
4939
+ string = string.slice(0, index - 1) + "-" + string.slice(index - 1);
4940
+ isLastLastCharUpper = isLastCharUpper;
4941
+ isLastCharUpper = false;
4942
+ isLastCharLower = true;
4943
+ } else {
4944
+ isLastCharLower = toLowerCase(character) === character && toUpperCase(character) !== character;
4945
+ isLastLastCharUpper = isLastCharUpper;
4946
+ isLastCharUpper = toUpperCase(character) === character && toLowerCase(character) !== character;
4947
+ }
5104
4948
  }
5105
- return {
5106
- open,
5107
- close,
5108
- openAll,
5109
- closeAll,
5110
- parent
5111
- };
4949
+ return string;
5112
4950
  };
5113
- var createBuilder = (self, _styler, _isEmpty) => {
5114
- const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
5115
- Object.setPrototypeOf(builder, proto);
5116
- builder[GENERATOR] = self;
5117
- builder[STYLER] = _styler;
5118
- builder[IS_EMPTY] = _isEmpty;
5119
- return builder;
4951
+ var preserveConsecutiveUppercase = (input, toLowerCase) => {
4952
+ LEADING_CAPITAL.lastIndex = 0;
4953
+ return string_replace_all_default(
4954
+ /* isOptionalObject*/
4955
+ false,
4956
+ input,
4957
+ LEADING_CAPITAL,
4958
+ (match) => toLowerCase(match)
4959
+ );
5120
4960
  };
5121
- var applyStyle = (self, string) => {
5122
- if (self.level <= 0 || !string) {
5123
- return self[IS_EMPTY] ? "" : string;
4961
+ var postProcess = (input, toUpperCase) => {
4962
+ SEPARATORS_AND_IDENTIFIER.lastIndex = 0;
4963
+ NUMBERS_AND_IDENTIFIER.lastIndex = 0;
4964
+ return string_replace_all_default(
4965
+ /* isOptionalObject*/
4966
+ false,
4967
+ string_replace_all_default(
4968
+ /* isOptionalObject*/
4969
+ false,
4970
+ input,
4971
+ NUMBERS_AND_IDENTIFIER,
4972
+ (match, pattern, offset) => ["_", "-"].includes(input.charAt(offset + match.length)) ? match : toUpperCase(match)
4973
+ ),
4974
+ SEPARATORS_AND_IDENTIFIER,
4975
+ (_, identifier) => toUpperCase(identifier)
4976
+ );
4977
+ };
4978
+ function camelCase(input, options) {
4979
+ if (!(typeof input === "string" || Array.isArray(input))) {
4980
+ throw new TypeError("Expected the input to be `string | string[]`");
5124
4981
  }
5125
- let styler = self[STYLER];
5126
- if (styler === void 0) {
5127
- return string;
4982
+ options = {
4983
+ pascalCase: false,
4984
+ preserveConsecutiveUppercase: false,
4985
+ ...options
4986
+ };
4987
+ if (Array.isArray(input)) {
4988
+ input = input.map((x) => x.trim()).filter((x) => x.length).join("-");
4989
+ } else {
4990
+ input = input.trim();
5128
4991
  }
5129
- const { openAll, closeAll } = styler;
5130
- if (string.includes("\x1B")) {
5131
- while (styler !== void 0) {
5132
- string = stringReplaceAll2(string, styler.close, styler.open);
5133
- styler = styler.parent;
4992
+ if (input.length === 0) {
4993
+ return "";
4994
+ }
4995
+ const toLowerCase = options.locale === false ? (string) => string.toLowerCase() : (string) => string.toLocaleLowerCase(options.locale);
4996
+ const toUpperCase = options.locale === false ? (string) => string.toUpperCase() : (string) => string.toLocaleUpperCase(options.locale);
4997
+ if (input.length === 1) {
4998
+ if (SEPARATORS.test(input)) {
4999
+ return "";
5134
5000
  }
5001
+ return options.pascalCase ? toUpperCase(input) : toLowerCase(input);
5135
5002
  }
5136
- const lfIndex = string.indexOf("\n");
5137
- if (lfIndex !== -1) {
5138
- string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
5003
+ const hasUpperCase = input !== toLowerCase(input);
5004
+ if (hasUpperCase) {
5005
+ input = preserveCamelCase(input, toLowerCase, toUpperCase, options.preserveConsecutiveUppercase);
5139
5006
  }
5140
- return openAll + string + closeAll;
5141
- };
5142
- Object.defineProperties(createChalk.prototype, styles2);
5143
- var chalk = createChalk();
5144
- var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
5145
- var source_default = chalk;
5146
-
5147
- // node_modules/ansi-regex/index.js
5148
- function ansiRegex({ onlyFirst = false } = {}) {
5149
- const pattern = [
5150
- "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
5151
- "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"
5152
- ].join("|");
5153
- return new RegExp(pattern, onlyFirst ? void 0 : "g");
5007
+ input = input.replace(LEADING_SEPARATORS, "");
5008
+ input = options.preserveConsecutiveUppercase ? preserveConsecutiveUppercase(input, toLowerCase) : toLowerCase(input);
5009
+ if (options.pascalCase) {
5010
+ input = toUpperCase(input.charAt(0)) + input.slice(1);
5011
+ }
5012
+ return postProcess(input, toUpperCase);
5154
5013
  }
5155
5014
 
5156
- // node_modules/strip-ansi/index.js
5157
- var regex = ansiRegex();
5158
- function stripAnsi(string) {
5159
- if (typeof string !== "string") {
5160
- throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
5015
+ // src/cli/utils.js
5016
+ import fs from "fs/promises";
5017
+ import path from "path";
5018
+
5019
+ // node_modules/sdbm/index.js
5020
+ function sdbm(string) {
5021
+ let hash = 0;
5022
+ for (let i = 0; i < string.length; i++) {
5023
+ hash = string.charCodeAt(i) + (hash << 6) + (hash << 16) - hash;
5161
5024
  }
5162
- return string.replace(regex, "");
5025
+ return hash >>> 0;
5163
5026
  }
5164
5027
 
5165
- // src/cli/logger.js
5166
- var import_wcwidth = __toESM(require_wcwidth(), 1);
5167
- var countLines = (stream, text) => {
5168
- const columns = stream.columns || 80;
5169
- let lineCount = 0;
5170
- for (const line of stripAnsi(text).split("\n")) {
5171
- lineCount += Math.max(1, Math.ceil((0, import_wcwidth.default)(line) / columns));
5172
- }
5173
- return lineCount;
5174
- };
5175
- var clear = (stream, text) => () => {
5176
- const lineCount = countLines(stream, text);
5177
- for (let line = 0; line < lineCount; line++) {
5178
- if (line > 0) {
5179
- readline.moveCursor(stream, 0, -1);
5028
+ // src/cli/utils.js
5029
+ import { __internal as sharedWithCli2 } from "../index.mjs";
5030
+ var printToScreen = console.log.bind(console);
5031
+ function groupBy(array2, iteratee) {
5032
+ const result = /* @__PURE__ */ Object.create(null);
5033
+ for (const value of array2) {
5034
+ const key = iteratee(value);
5035
+ if (Array.isArray(result[key])) {
5036
+ result[key].push(value);
5037
+ } else {
5038
+ result[key] = [value];
5180
5039
  }
5181
- readline.clearLine(stream, 0);
5182
- readline.cursorTo(stream, 0);
5183
5040
  }
5184
- };
5185
- var emptyLogResult = {
5186
- clear() {
5041
+ return result;
5042
+ }
5043
+ function pick(object, keys) {
5044
+ const entries = keys.map((key) => [key, object[key]]);
5045
+ return Object.fromEntries(entries);
5046
+ }
5047
+ function createHash(source) {
5048
+ return String(sdbm(source));
5049
+ }
5050
+ async function statSafe(filePath) {
5051
+ try {
5052
+ return await fs.stat(filePath);
5053
+ } catch (error) {
5054
+ if (error.code !== "ENOENT") {
5055
+ throw error;
5056
+ }
5187
5057
  }
5188
- };
5189
- function createLogger(logLevel = "log") {
5190
- return {
5191
- logLevel,
5192
- warn: createLogFunc("warn", "yellow"),
5193
- error: createLogFunc("error", "red"),
5194
- debug: createLogFunc("debug", "blue"),
5195
- log: createLogFunc("log")
5196
- };
5197
- function createLogFunc(loggerName, color) {
5198
- if (!shouldLog(loggerName)) {
5199
- return () => emptyLogResult;
5058
+ }
5059
+ async function lstatSafe(filePath) {
5060
+ try {
5061
+ return await fs.lstat(filePath);
5062
+ } catch (error) {
5063
+ if (error.code !== "ENOENT") {
5064
+ throw error;
5200
5065
  }
5201
- const stream = process[loggerName === "log" ? "stdout" : "stderr"];
5202
- const chalkInstance = loggerName === "log" ? source_default : chalkStderr;
5203
- const prefix = color ? `[${chalkInstance[color](loggerName)}] ` : "";
5204
- return (message, options) => {
5205
- options = {
5206
- newline: true,
5207
- clearable: false,
5208
- ...options
5209
- };
5210
- message = string_replace_all_default(
5211
- /* isOptionalObject*/
5212
- false,
5213
- message,
5214
- /^/gm,
5215
- prefix
5216
- ) + (options.newline ? "\n" : "");
5217
- stream.write(message);
5218
- if (options.clearable) {
5219
- return {
5220
- clear: clear(stream, message)
5221
- };
5222
- }
5223
- };
5224
5066
  }
5225
- function shouldLog(loggerName) {
5226
- switch (logLevel) {
5227
- case "silent":
5228
- return false;
5229
- case "debug":
5230
- if (loggerName === "debug") {
5231
- return true;
5232
- }
5233
- case "log":
5234
- if (loggerName === "log") {
5235
- return true;
5236
- }
5237
- case "warn":
5238
- if (loggerName === "warn") {
5239
- return true;
5240
- }
5241
- case "error":
5242
- return loggerName === "error";
5067
+ }
5068
+ function isJson(value) {
5069
+ try {
5070
+ JSON.parse(value);
5071
+ return true;
5072
+ } catch {
5073
+ return false;
5074
+ }
5075
+ }
5076
+ var normalizeToPosix = path.sep === "\\" ? (filepath) => string_replace_all_default(
5077
+ /* isOptionalObject*/
5078
+ false,
5079
+ filepath,
5080
+ "\\",
5081
+ "/"
5082
+ ) : (filepath) => filepath;
5083
+ var {
5084
+ isNonEmptyArray,
5085
+ partition,
5086
+ omit
5087
+ } = sharedWithCli2.utils;
5088
+
5089
+ // src/cli/options/create-minimist-options.js
5090
+ function createMinimistOptions(detailedOptions) {
5091
+ const booleanNames = [];
5092
+ const stringNames = [];
5093
+ const defaultValues = {};
5094
+ for (const option of detailedOptions) {
5095
+ const { name, alias, type } = option;
5096
+ const names = type === "boolean" ? booleanNames : stringNames;
5097
+ names.push(name);
5098
+ if (alias) {
5099
+ names.push(alias);
5100
+ }
5101
+ if (!option.deprecated && (!option.forwardToApi || name === "plugin") && option.default !== void 0) {
5102
+ defaultValues[option.name] = option.default;
5243
5103
  }
5244
5104
  }
5105
+ return {
5106
+ // we use vnopts' AliasSchema to handle aliases for better error messages
5107
+ alias: {},
5108
+ boolean: booleanNames,
5109
+ string: stringNames,
5110
+ default: defaultValues
5111
+ };
5245
5112
  }
5246
- var logger_default = createLogger;
5247
-
5248
- // scripts/build/shims/at.js
5249
- var at = (isOptionalObject, object, index) => {
5250
- if (isOptionalObject && (object === void 0 || object === null)) {
5251
- return;
5252
- }
5253
- if (Array.isArray(object) || typeof object === "string") {
5254
- return object[index < 0 ? object.length + index : index];
5255
- }
5256
- return object.at(index);
5257
- };
5258
- var at_default = at;
5259
5113
 
5260
- // src/cli/options/get-context-options.js
5261
- var import_dashify = __toESM(require_dashify(), 1);
5262
- import { getSupportInfo } from "../index.mjs";
5263
-
5264
- // src/cli/prettier-internal.js
5265
- import { __internal as sharedWithCli } from "../index.mjs";
5266
- var {
5267
- errors,
5268
- optionCategories,
5269
- createIsIgnoredFunction,
5270
- formatOptionsHiddenDefaults,
5271
- normalizeOptions,
5272
- getSupportInfoWithoutPlugins,
5273
- normalizeOptionSettings,
5274
- vnopts,
5275
- fastGlob,
5276
- mockable
5277
- } = sharedWithCli;
5114
+ // src/cli/options/minimist.js
5115
+ var import_minimist = __toESM(require_minimist(), 1);
5116
+ var PLACEHOLDER = null;
5117
+ function minimistParse(args, options) {
5118
+ const boolean = options.boolean ?? [];
5119
+ const defaults = options.default ?? {};
5120
+ const booleanWithoutDefault = boolean.filter((key) => !(key in defaults));
5121
+ const newDefaults = {
5122
+ ...defaults,
5123
+ ...Object.fromEntries(
5124
+ booleanWithoutDefault.map((key) => [key, PLACEHOLDER])
5125
+ )
5126
+ };
5127
+ const parsed = (0, import_minimist.default)(args, { ...options, default: newDefaults });
5128
+ return Object.fromEntries(
5129
+ Object.entries(parsed).filter(([, value]) => value !== PLACEHOLDER)
5130
+ );
5131
+ }
5278
5132
 
5279
- // src/cli/cli-options.evaluate.js
5280
- var cli_options_evaluate_default = {
5281
- "cache": {
5282
- "default": false,
5283
- "description": "Only format changed files. Cannot use with --stdin-filepath.",
5284
- "type": "boolean"
5285
- },
5286
- "cacheLocation": {
5287
- "description": "Path to the cache file.",
5288
- "type": "path"
5289
- },
5290
- "cacheStrategy": {
5291
- "choices": [
5292
- {
5293
- "description": "Use the file metadata such as timestamps as cache keys",
5294
- "value": "metadata"
5295
- },
5296
- {
5297
- "description": "Use the file content as cache keys",
5298
- "value": "content"
5299
- }
5300
- ],
5301
- "description": "Strategy for the cache to use for detecting changed files.",
5302
- "type": "choice"
5303
- },
5304
- "check": {
5305
- "alias": "c",
5306
- "category": "Output",
5307
- "description": "Check if the given files are formatted, print a human-friendly summary\nmessage and paths to unformatted files (see also --list-different).",
5308
- "type": "boolean"
5309
- },
5310
- "color": {
5311
- "default": true,
5312
- "description": "Colorize error messages.",
5313
- "oppositeDescription": "Do not colorize error messages.",
5314
- "type": "boolean"
5315
- },
5316
- "config": {
5317
- "category": "Config",
5318
- "description": "Path to a Prettier configuration file (.prettierrc, package.json, prettier.config.js).",
5319
- "exception": (value) => value === false,
5320
- "oppositeDescription": "Do not look for a configuration file.",
5321
- "type": "path"
5322
- },
5323
- "configPrecedence": {
5324
- "category": "Config",
5325
- "choices": [
5326
- {
5327
- "description": "CLI options take precedence over config file",
5328
- "value": "cli-override"
5329
- },
5330
- {
5331
- "description": "Config file take precedence over CLI options",
5332
- "value": "file-override"
5333
- },
5334
- {
5335
- "description": "If a config file is found will evaluate it and ignore other CLI options.\nIf no config file is found CLI options will evaluate as normal.",
5336
- "value": "prefer-file"
5337
- }
5338
- ],
5339
- "default": "cli-override",
5340
- "description": "Define in which order config files and CLI options should be evaluated.",
5341
- "type": "choice"
5342
- },
5343
- "debugBenchmark": {
5344
- "type": "boolean"
5345
- },
5346
- "debugCheck": {
5347
- "type": "boolean"
5348
- },
5349
- "debugPrintAst": {
5350
- "type": "boolean"
5351
- },
5352
- "debugPrintComments": {
5353
- "type": "boolean"
5354
- },
5355
- "debugPrintDoc": {
5356
- "type": "boolean"
5357
- },
5358
- "debugRepeat": {
5359
- "default": 0,
5360
- "type": "int"
5361
- },
5362
- "editorconfig": {
5363
- "category": "Config",
5364
- "default": true,
5365
- "description": "Take .editorconfig into account when parsing configuration.",
5366
- "oppositeDescription": "Don't take .editorconfig into account when parsing configuration.",
5367
- "type": "boolean"
5368
- },
5369
- "errorOnUnmatchedPattern": {
5370
- "oppositeDescription": "Prevent errors when pattern is unmatched.",
5371
- "type": "boolean"
5372
- },
5373
- "fileInfo": {
5374
- "description": "Extract the following info (as JSON) for a given file path. Reported fields:\n* ignored (boolean) - true if file path is filtered by --ignore-path\n* inferredParser (string | null) - name of parser inferred from file path",
5375
- "type": "path"
5376
- },
5377
- "findConfigPath": {
5378
- "category": "Config",
5379
- "description": "Find and print the path to a configuration file for the given input file.",
5380
- "type": "path"
5381
- },
5382
- "help": {
5383
- "alias": "h",
5384
- "description": "Show CLI usage, or details about the given flag.\nExample: --help write",
5385
- "exception": (value) => value === "",
5386
- "type": "flag"
5387
- },
5388
- "ignorePath": {
5389
- "array": true,
5390
- "category": "Config",
5391
- "default": [
5392
- {
5393
- "value": [
5394
- ".gitignore",
5395
- ".prettierignore"
5396
- ]
5397
- }
5398
- ],
5399
- "description": "Path to a file with patterns describing files to ignore.\nMultiple values are accepted.",
5400
- "type": "path"
5401
- },
5402
- "ignoreUnknown": {
5403
- "alias": "u",
5404
- "description": "Ignore unknown files.",
5405
- "type": "boolean"
5406
- },
5407
- "listDifferent": {
5408
- "alias": "l",
5409
- "category": "Output",
5410
- "description": "Print the names of files that are different from Prettier's formatting (see also --check).",
5411
- "type": "boolean"
5412
- },
5413
- "logLevel": {
5414
- "choices": [
5415
- "silent",
5416
- "error",
5417
- "warn",
5418
- "log",
5419
- "debug"
5420
- ],
5421
- "default": "log",
5422
- "description": "What level of logs to report.",
5423
- "type": "choice"
5424
- },
5425
- "supportInfo": {
5426
- "description": "Print support information as JSON.",
5427
- "type": "boolean"
5428
- },
5429
- "version": {
5430
- "alias": "v",
5431
- "description": "Print Prettier version.",
5432
- "type": "boolean"
5133
+ // node_modules/chalk/source/vendor/ansi-styles/index.js
5134
+ var ANSI_BACKGROUND_OFFSET = 10;
5135
+ var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
5136
+ var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
5137
+ var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
5138
+ var styles = {
5139
+ modifier: {
5140
+ reset: [0, 0],
5141
+ // 21 isn't widely supported and 22 does the same thing
5142
+ bold: [1, 22],
5143
+ dim: [2, 22],
5144
+ italic: [3, 23],
5145
+ underline: [4, 24],
5146
+ overline: [53, 55],
5147
+ inverse: [7, 27],
5148
+ hidden: [8, 28],
5149
+ strikethrough: [9, 29]
5433
5150
  },
5434
- "withNodeModules": {
5435
- "category": "Config",
5436
- "description": "Process files inside 'node_modules' directory.",
5437
- "type": "boolean"
5151
+ color: {
5152
+ black: [30, 39],
5153
+ red: [31, 39],
5154
+ green: [32, 39],
5155
+ yellow: [33, 39],
5156
+ blue: [34, 39],
5157
+ magenta: [35, 39],
5158
+ cyan: [36, 39],
5159
+ white: [37, 39],
5160
+ // Bright color
5161
+ blackBright: [90, 39],
5162
+ gray: [90, 39],
5163
+ // Alias of `blackBright`
5164
+ grey: [90, 39],
5165
+ // Alias of `blackBright`
5166
+ redBright: [91, 39],
5167
+ greenBright: [92, 39],
5168
+ yellowBright: [93, 39],
5169
+ blueBright: [94, 39],
5170
+ magentaBright: [95, 39],
5171
+ cyanBright: [96, 39],
5172
+ whiteBright: [97, 39]
5438
5173
  },
5439
- "write": {
5440
- "alias": "w",
5441
- "category": "Output",
5442
- "description": "Edit files in-place. (Beware!)",
5443
- "type": "boolean"
5174
+ bgColor: {
5175
+ bgBlack: [40, 49],
5176
+ bgRed: [41, 49],
5177
+ bgGreen: [42, 49],
5178
+ bgYellow: [43, 49],
5179
+ bgBlue: [44, 49],
5180
+ bgMagenta: [45, 49],
5181
+ bgCyan: [46, 49],
5182
+ bgWhite: [47, 49],
5183
+ // Bright color
5184
+ bgBlackBright: [100, 49],
5185
+ bgGray: [100, 49],
5186
+ // Alias of `bgBlackBright`
5187
+ bgGrey: [100, 49],
5188
+ // Alias of `bgBlackBright`
5189
+ bgRedBright: [101, 49],
5190
+ bgGreenBright: [102, 49],
5191
+ bgYellowBright: [103, 49],
5192
+ bgBlueBright: [104, 49],
5193
+ bgMagentaBright: [105, 49],
5194
+ bgCyanBright: [106, 49],
5195
+ bgWhiteBright: [107, 49]
5444
5196
  }
5445
5197
  };
5446
-
5447
- // src/cli/options/get-context-options.js
5448
- var detailedCliOptions = normalizeOptionSettings(cli_options_evaluate_default).map(
5449
- (option) => normalizeDetailedOption(option)
5450
- );
5451
- function apiOptionToCliOption(apiOption) {
5452
- const cliOption = {
5453
- ...apiOption,
5454
- description: apiOption.cliDescription ?? apiOption.description,
5455
- category: apiOption.cliCategory ?? optionCategories.CATEGORY_FORMAT,
5456
- forwardToApi: apiOption.name
5457
- };
5458
- if (apiOption.deprecated) {
5459
- delete cliOption.forwardToApi;
5460
- delete cliOption.description;
5461
- delete cliOption.oppositeDescription;
5462
- cliOption.deprecated = true;
5463
- }
5464
- return normalizeDetailedOption(cliOption);
5465
- }
5466
- function normalizeDetailedOption(option) {
5467
- var _a;
5468
- return {
5469
- category: optionCategories.CATEGORY_OTHER,
5470
- ...option,
5471
- name: option.cliName ?? (0, import_dashify.default)(option.name),
5472
- choices: (_a = option.choices) == null ? void 0 : _a.map((choice) => {
5473
- const newChoice = {
5474
- description: "",
5475
- deprecated: false,
5476
- ...typeof choice === "object" ? choice : { value: choice }
5198
+ var modifierNames = Object.keys(styles.modifier);
5199
+ var foregroundColorNames = Object.keys(styles.color);
5200
+ var backgroundColorNames = Object.keys(styles.bgColor);
5201
+ var colorNames = [...foregroundColorNames, ...backgroundColorNames];
5202
+ function assembleStyles() {
5203
+ const codes = /* @__PURE__ */ new Map();
5204
+ for (const [groupName, group] of Object.entries(styles)) {
5205
+ for (const [styleName, style] of Object.entries(group)) {
5206
+ styles[styleName] = {
5207
+ open: `\x1B[${style[0]}m`,
5208
+ close: `\x1B[${style[1]}m`
5477
5209
  };
5478
- if (newChoice.value === true) {
5479
- newChoice.value = "";
5480
- }
5481
- return newChoice;
5482
- })
5483
- };
5484
- }
5485
- function supportInfoToContextOptions({ options: supportOptions, languages }) {
5486
- const detailedOptions = [
5487
- ...detailedCliOptions,
5488
- ...supportOptions.map((apiOption) => apiOptionToCliOption(apiOption))
5489
- ];
5490
- return {
5491
- supportOptions,
5492
- languages,
5493
- detailedOptions
5494
- };
5495
- }
5496
- async function getContextOptions(plugins) {
5497
- const supportInfo = await getSupportInfo({
5498
- showDeprecated: true,
5499
- plugins
5210
+ group[styleName] = styles[styleName];
5211
+ codes.set(style[0], style[1]);
5212
+ }
5213
+ Object.defineProperty(styles, groupName, {
5214
+ value: group,
5215
+ enumerable: false
5216
+ });
5217
+ }
5218
+ Object.defineProperty(styles, "codes", {
5219
+ value: codes,
5220
+ enumerable: false
5500
5221
  });
5501
- return supportInfoToContextOptions(supportInfo);
5502
- }
5503
- function getContextOptionsWithoutPlugins() {
5504
- const supportInfo = getSupportInfoWithoutPlugins();
5505
- return supportInfoToContextOptions(supportInfo);
5222
+ styles.color.close = "\x1B[39m";
5223
+ styles.bgColor.close = "\x1B[49m";
5224
+ styles.color.ansi = wrapAnsi16();
5225
+ styles.color.ansi256 = wrapAnsi256();
5226
+ styles.color.ansi16m = wrapAnsi16m();
5227
+ styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
5228
+ styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
5229
+ styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
5230
+ Object.defineProperties(styles, {
5231
+ rgbToAnsi256: {
5232
+ value(red, green, blue) {
5233
+ if (red === green && green === blue) {
5234
+ if (red < 8) {
5235
+ return 16;
5236
+ }
5237
+ if (red > 248) {
5238
+ return 231;
5239
+ }
5240
+ return Math.round((red - 8) / 247 * 24) + 232;
5241
+ }
5242
+ return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
5243
+ },
5244
+ enumerable: false
5245
+ },
5246
+ hexToRgb: {
5247
+ value(hex) {
5248
+ const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
5249
+ if (!matches) {
5250
+ return [0, 0, 0];
5251
+ }
5252
+ let [colorString] = matches;
5253
+ if (colorString.length === 3) {
5254
+ colorString = [...colorString].map((character) => character + character).join("");
5255
+ }
5256
+ const integer = Number.parseInt(colorString, 16);
5257
+ return [
5258
+ /* eslint-disable no-bitwise */
5259
+ integer >> 16 & 255,
5260
+ integer >> 8 & 255,
5261
+ integer & 255
5262
+ /* eslint-enable no-bitwise */
5263
+ ];
5264
+ },
5265
+ enumerable: false
5266
+ },
5267
+ hexToAnsi256: {
5268
+ value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
5269
+ enumerable: false
5270
+ },
5271
+ ansi256ToAnsi: {
5272
+ value(code) {
5273
+ if (code < 8) {
5274
+ return 30 + code;
5275
+ }
5276
+ if (code < 16) {
5277
+ return 90 + (code - 8);
5278
+ }
5279
+ let red;
5280
+ let green;
5281
+ let blue;
5282
+ if (code >= 232) {
5283
+ red = ((code - 232) * 10 + 8) / 255;
5284
+ green = red;
5285
+ blue = red;
5286
+ } else {
5287
+ code -= 16;
5288
+ const remainder = code % 36;
5289
+ red = Math.floor(code / 36) / 5;
5290
+ green = Math.floor(remainder / 6) / 5;
5291
+ blue = remainder % 6 / 5;
5292
+ }
5293
+ const value = Math.max(red, green, blue) * 2;
5294
+ if (value === 0) {
5295
+ return 30;
5296
+ }
5297
+ let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
5298
+ if (value === 2) {
5299
+ result += 60;
5300
+ }
5301
+ return result;
5302
+ },
5303
+ enumerable: false
5304
+ },
5305
+ rgbToAnsi: {
5306
+ value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
5307
+ enumerable: false
5308
+ },
5309
+ hexToAnsi: {
5310
+ value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
5311
+ enumerable: false
5312
+ }
5313
+ });
5314
+ return styles;
5506
5315
  }
5316
+ var ansiStyles = assembleStyles();
5317
+ var ansi_styles_default = ansiStyles;
5507
5318
 
5508
- // node_modules/camelcase/index.js
5509
- var UPPERCASE = /[\p{Lu}]/u;
5510
- var LOWERCASE = /[\p{Ll}]/u;
5511
- var LEADING_CAPITAL = /^[\p{Lu}](?![\p{Lu}])/gu;
5512
- var IDENTIFIER = /([\p{Alpha}\p{N}_]|$)/u;
5513
- var SEPARATORS = /[_.\- ]+/;
5514
- var LEADING_SEPARATORS = new RegExp("^" + SEPARATORS.source);
5515
- var SEPARATORS_AND_IDENTIFIER = new RegExp(SEPARATORS.source + IDENTIFIER.source, "gu");
5516
- var NUMBERS_AND_IDENTIFIER = new RegExp("\\d+" + IDENTIFIER.source, "gu");
5517
- var preserveCamelCase = (string, toLowerCase, toUpperCase, preserveConsecutiveUppercase2) => {
5518
- let isLastCharLower = false;
5519
- let isLastCharUpper = false;
5520
- let isLastLastCharUpper = false;
5521
- let isLastLastCharPreserved = false;
5522
- for (let index = 0; index < string.length; index++) {
5523
- const character = string[index];
5524
- isLastLastCharPreserved = index > 2 ? string[index - 3] === "-" : true;
5525
- if (isLastCharLower && UPPERCASE.test(character)) {
5526
- string = string.slice(0, index) + "-" + string.slice(index);
5527
- isLastCharLower = false;
5528
- isLastLastCharUpper = isLastCharUpper;
5529
- isLastCharUpper = true;
5530
- index++;
5531
- } else if (isLastCharUpper && isLastLastCharUpper && LOWERCASE.test(character) && (!isLastLastCharPreserved || preserveConsecutiveUppercase2)) {
5532
- string = string.slice(0, index - 1) + "-" + string.slice(index - 1);
5533
- isLastLastCharUpper = isLastCharUpper;
5534
- isLastCharUpper = false;
5535
- isLastCharLower = true;
5536
- } else {
5537
- isLastCharLower = toLowerCase(character) === character && toUpperCase(character) !== character;
5538
- isLastLastCharUpper = isLastCharUpper;
5539
- isLastCharUpper = toUpperCase(character) === character && toLowerCase(character) !== character;
5319
+ // node_modules/chalk/source/vendor/supports-color/index.js
5320
+ import process2 from "process";
5321
+ import os from "os";
5322
+ import tty from "tty";
5323
+ function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process2.argv) {
5324
+ const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
5325
+ const position = argv.indexOf(prefix + flag);
5326
+ const terminatorPosition = argv.indexOf("--");
5327
+ return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
5328
+ }
5329
+ var { env } = process2;
5330
+ var flagForceColor;
5331
+ if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
5332
+ flagForceColor = 0;
5333
+ } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
5334
+ flagForceColor = 1;
5335
+ }
5336
+ function envForceColor() {
5337
+ if ("FORCE_COLOR" in env) {
5338
+ if (env.FORCE_COLOR === "true") {
5339
+ return 1;
5540
5340
  }
5341
+ if (env.FORCE_COLOR === "false") {
5342
+ return 0;
5343
+ }
5344
+ return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
5541
5345
  }
5542
- return string;
5543
- };
5544
- var preserveConsecutiveUppercase = (input, toLowerCase) => {
5545
- LEADING_CAPITAL.lastIndex = 0;
5546
- return string_replace_all_default(
5547
- /* isOptionalObject*/
5548
- false,
5549
- input,
5550
- LEADING_CAPITAL,
5551
- (match) => toLowerCase(match)
5552
- );
5553
- };
5554
- var postProcess = (input, toUpperCase) => {
5555
- SEPARATORS_AND_IDENTIFIER.lastIndex = 0;
5556
- NUMBERS_AND_IDENTIFIER.lastIndex = 0;
5557
- return string_replace_all_default(
5558
- /* isOptionalObject*/
5559
- false,
5560
- string_replace_all_default(
5561
- /* isOptionalObject*/
5562
- false,
5563
- input,
5564
- NUMBERS_AND_IDENTIFIER,
5565
- (match, pattern, offset) => ["_", "-"].includes(input.charAt(offset + match.length)) ? match : toUpperCase(match)
5566
- ),
5567
- SEPARATORS_AND_IDENTIFIER,
5568
- (_, identifier) => toUpperCase(identifier)
5569
- );
5570
- };
5571
- function camelCase(input, options) {
5572
- if (!(typeof input === "string" || Array.isArray(input))) {
5573
- throw new TypeError("Expected the input to be `string | string[]`");
5346
+ }
5347
+ function translateLevel(level) {
5348
+ if (level === 0) {
5349
+ return false;
5574
5350
  }
5575
- options = {
5576
- pascalCase: false,
5577
- preserveConsecutiveUppercase: false,
5578
- ...options
5351
+ return {
5352
+ level,
5353
+ hasBasic: true,
5354
+ has256: level >= 2,
5355
+ has16m: level >= 3
5579
5356
  };
5580
- if (Array.isArray(input)) {
5581
- input = input.map((x) => x.trim()).filter((x) => x.length).join("-");
5582
- } else {
5583
- input = input.trim();
5357
+ }
5358
+ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
5359
+ const noFlagForceColor = envForceColor();
5360
+ if (noFlagForceColor !== void 0) {
5361
+ flagForceColor = noFlagForceColor;
5584
5362
  }
5585
- if (input.length === 0) {
5586
- return "";
5363
+ const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
5364
+ if (forceColor === 0) {
5365
+ return 0;
5587
5366
  }
5588
- const toLowerCase = options.locale === false ? (string) => string.toLowerCase() : (string) => string.toLocaleLowerCase(options.locale);
5589
- const toUpperCase = options.locale === false ? (string) => string.toUpperCase() : (string) => string.toLocaleUpperCase(options.locale);
5590
- if (input.length === 1) {
5591
- if (SEPARATORS.test(input)) {
5592
- return "";
5367
+ if (sniffFlags) {
5368
+ if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
5369
+ return 3;
5370
+ }
5371
+ if (hasFlag("color=256")) {
5372
+ return 2;
5593
5373
  }
5594
- return options.pascalCase ? toUpperCase(input) : toLowerCase(input);
5595
5374
  }
5596
- const hasUpperCase = input !== toLowerCase(input);
5597
- if (hasUpperCase) {
5598
- input = preserveCamelCase(input, toLowerCase, toUpperCase, options.preserveConsecutiveUppercase);
5375
+ if ("TF_BUILD" in env && "AGENT_NAME" in env) {
5376
+ return 1;
5599
5377
  }
5600
- input = input.replace(LEADING_SEPARATORS, "");
5601
- input = options.preserveConsecutiveUppercase ? preserveConsecutiveUppercase(input, toLowerCase) : toLowerCase(input);
5602
- if (options.pascalCase) {
5603
- input = toUpperCase(input.charAt(0)) + input.slice(1);
5378
+ if (haveStream && !streamIsTTY && forceColor === void 0) {
5379
+ return 0;
5604
5380
  }
5605
- return postProcess(input, toUpperCase);
5381
+ const min = forceColor || 0;
5382
+ if (env.TERM === "dumb") {
5383
+ return min;
5384
+ }
5385
+ if (process2.platform === "win32") {
5386
+ const osRelease = os.release().split(".");
5387
+ if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
5388
+ return Number(osRelease[2]) >= 14931 ? 3 : 2;
5389
+ }
5390
+ return 1;
5391
+ }
5392
+ if ("CI" in env) {
5393
+ if ("GITHUB_ACTIONS" in env || "GITEA_ACTIONS" in env) {
5394
+ return 3;
5395
+ }
5396
+ if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
5397
+ return 1;
5398
+ }
5399
+ return min;
5400
+ }
5401
+ if ("TEAMCITY_VERSION" in env) {
5402
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
5403
+ }
5404
+ if (env.COLORTERM === "truecolor") {
5405
+ return 3;
5406
+ }
5407
+ if (env.TERM === "xterm-kitty") {
5408
+ return 3;
5409
+ }
5410
+ if ("TERM_PROGRAM" in env) {
5411
+ const version2 = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
5412
+ switch (env.TERM_PROGRAM) {
5413
+ case "iTerm.app": {
5414
+ return version2 >= 3 ? 3 : 2;
5415
+ }
5416
+ case "Apple_Terminal": {
5417
+ return 2;
5418
+ }
5419
+ }
5420
+ }
5421
+ if (/-256(color)?$/i.test(env.TERM)) {
5422
+ return 2;
5423
+ }
5424
+ if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
5425
+ return 1;
5426
+ }
5427
+ if ("COLORTERM" in env) {
5428
+ return 1;
5429
+ }
5430
+ return min;
5606
5431
  }
5432
+ function createSupportsColor(stream, options = {}) {
5433
+ const level = _supportsColor(stream, {
5434
+ streamIsTTY: stream && stream.isTTY,
5435
+ ...options
5436
+ });
5437
+ return translateLevel(level);
5438
+ }
5439
+ var supportsColor = {
5440
+ stdout: createSupportsColor({ isTTY: tty.isatty(1) }),
5441
+ stderr: createSupportsColor({ isTTY: tty.isatty(2) })
5442
+ };
5443
+ var supports_color_default = supportsColor;
5607
5444
 
5608
- // src/cli/utils.js
5609
- import fs from "fs/promises";
5610
- import path from "path";
5611
-
5612
- // node_modules/sdbm/index.js
5613
- function sdbm(string) {
5614
- let hash = 0;
5615
- for (let i = 0; i < string.length; i++) {
5616
- hash = string.charCodeAt(i) + (hash << 6) + (hash << 16) - hash;
5445
+ // node_modules/chalk/source/utilities.js
5446
+ function stringReplaceAll2(string, substring, replacer) {
5447
+ let index = string.indexOf(substring);
5448
+ if (index === -1) {
5449
+ return string;
5617
5450
  }
5618
- return hash >>> 0;
5451
+ const substringLength = substring.length;
5452
+ let endIndex = 0;
5453
+ let returnValue = "";
5454
+ do {
5455
+ returnValue += string.slice(endIndex, index) + substring + replacer;
5456
+ endIndex = index + substringLength;
5457
+ index = string.indexOf(substring, endIndex);
5458
+ } while (index !== -1);
5459
+ returnValue += string.slice(endIndex);
5460
+ return returnValue;
5461
+ }
5462
+ function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
5463
+ let endIndex = 0;
5464
+ let returnValue = "";
5465
+ do {
5466
+ const gotCR = string[index - 1] === "\r";
5467
+ returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
5468
+ endIndex = index + 1;
5469
+ index = string.indexOf("\n", endIndex);
5470
+ } while (index !== -1);
5471
+ returnValue += string.slice(endIndex);
5472
+ return returnValue;
5619
5473
  }
5620
5474
 
5621
- // src/cli/utils.js
5622
- import { __internal as sharedWithCli2 } from "../index.mjs";
5623
- var printToScreen = console.log.bind(console);
5624
- function groupBy(array2, iteratee) {
5625
- const result = /* @__PURE__ */ Object.create(null);
5626
- for (const value of array2) {
5627
- const key = iteratee(value);
5628
- if (Array.isArray(result[key])) {
5629
- result[key].push(value);
5630
- } else {
5631
- result[key] = [value];
5632
- }
5475
+ // node_modules/chalk/source/index.js
5476
+ var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;
5477
+ var GENERATOR = Symbol("GENERATOR");
5478
+ var STYLER = Symbol("STYLER");
5479
+ var IS_EMPTY = Symbol("IS_EMPTY");
5480
+ var levelMapping = [
5481
+ "ansi",
5482
+ "ansi",
5483
+ "ansi256",
5484
+ "ansi16m"
5485
+ ];
5486
+ var styles2 = /* @__PURE__ */ Object.create(null);
5487
+ var applyOptions = (object, options = {}) => {
5488
+ if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
5489
+ throw new Error("The `level` option should be an integer from 0 to 3");
5633
5490
  }
5634
- return result;
5635
- }
5636
- function pick(object, keys) {
5637
- const entries = keys.map((key) => [key, object[key]]);
5638
- return Object.fromEntries(entries);
5491
+ const colorLevel = stdoutColor ? stdoutColor.level : 0;
5492
+ object.level = options.level === void 0 ? colorLevel : options.level;
5493
+ };
5494
+ var chalkFactory = (options) => {
5495
+ const chalk2 = (...strings) => strings.join(" ");
5496
+ applyOptions(chalk2, options);
5497
+ Object.setPrototypeOf(chalk2, createChalk.prototype);
5498
+ return chalk2;
5499
+ };
5500
+ function createChalk(options) {
5501
+ return chalkFactory(options);
5639
5502
  }
5640
- function createHash(source) {
5641
- return String(sdbm(source));
5503
+ Object.setPrototypeOf(createChalk.prototype, Function.prototype);
5504
+ for (const [styleName, style] of Object.entries(ansi_styles_default)) {
5505
+ styles2[styleName] = {
5506
+ get() {
5507
+ const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
5508
+ Object.defineProperty(this, styleName, { value: builder });
5509
+ return builder;
5510
+ }
5511
+ };
5642
5512
  }
5643
- async function statSafe(filePath) {
5644
- try {
5645
- return await fs.stat(filePath);
5646
- } catch (error) {
5647
- if (error.code !== "ENOENT") {
5648
- throw error;
5513
+ styles2.visible = {
5514
+ get() {
5515
+ const builder = createBuilder(this, this[STYLER], true);
5516
+ Object.defineProperty(this, "visible", { value: builder });
5517
+ return builder;
5518
+ }
5519
+ };
5520
+ var getModelAnsi = (model, level, type, ...arguments_) => {
5521
+ if (model === "rgb") {
5522
+ if (level === "ansi16m") {
5523
+ return ansi_styles_default[type].ansi16m(...arguments_);
5649
5524
  }
5650
- }
5651
- }
5652
- async function lstatSafe(filePath) {
5653
- try {
5654
- return await fs.lstat(filePath);
5655
- } catch (error) {
5656
- if (error.code !== "ENOENT") {
5657
- throw error;
5525
+ if (level === "ansi256") {
5526
+ return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
5658
5527
  }
5528
+ return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
5659
5529
  }
5660
- }
5661
- function isJson(value) {
5662
- try {
5663
- JSON.parse(value);
5664
- return true;
5665
- } catch {
5666
- return false;
5530
+ if (model === "hex") {
5531
+ return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
5667
5532
  }
5668
- }
5669
- var normalizeToPosix = path.sep === "\\" ? (filepath) => string_replace_all_default(
5670
- /* isOptionalObject*/
5671
- false,
5672
- filepath,
5673
- "\\",
5674
- "/"
5675
- ) : (filepath) => filepath;
5676
- var {
5677
- isNonEmptyArray,
5678
- partition,
5679
- omit
5680
- } = sharedWithCli2.utils;
5681
-
5682
- // src/cli/options/minimist.js
5683
- var import_minimist = __toESM(require_minimist(), 1);
5684
- var PLACEHOLDER = null;
5685
- function minimistParse(args, options) {
5686
- const boolean = options.boolean ?? [];
5687
- const defaults = options.default ?? {};
5688
- const booleanWithoutDefault = boolean.filter((key) => !(key in defaults));
5689
- const newDefaults = {
5690
- ...defaults,
5691
- ...Object.fromEntries(
5692
- booleanWithoutDefault.map((key) => [key, PLACEHOLDER])
5693
- )
5533
+ return ansi_styles_default[type][model](...arguments_);
5534
+ };
5535
+ var usedModels = ["rgb", "hex", "ansi256"];
5536
+ for (const model of usedModels) {
5537
+ styles2[model] = {
5538
+ get() {
5539
+ const { level } = this;
5540
+ return function(...arguments_) {
5541
+ const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
5542
+ return createBuilder(this, styler, this[IS_EMPTY]);
5543
+ };
5544
+ }
5694
5545
  };
5695
- const parsed = (0, import_minimist.default)(args, { ...options, default: newDefaults });
5696
- return Object.fromEntries(
5697
- Object.entries(parsed).filter(([, value]) => value !== PLACEHOLDER)
5698
- );
5699
- }
5700
-
5701
- // src/cli/options/create-minimist-options.js
5702
- function createMinimistOptions(detailedOptions) {
5703
- const booleanNames = [];
5704
- const stringNames = [];
5705
- const defaultValues = {};
5706
- for (const option of detailedOptions) {
5707
- const { name, alias, type } = option;
5708
- const names = type === "boolean" ? booleanNames : stringNames;
5709
- names.push(name);
5710
- if (alias) {
5711
- names.push(alias);
5546
+ const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
5547
+ styles2[bgModel] = {
5548
+ get() {
5549
+ const { level } = this;
5550
+ return function(...arguments_) {
5551
+ const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
5552
+ return createBuilder(this, styler, this[IS_EMPTY]);
5553
+ };
5712
5554
  }
5713
- if (!option.deprecated && (!option.forwardToApi || name === "plugin") && option.default !== void 0) {
5714
- defaultValues[option.name] = option.default;
5555
+ };
5556
+ }
5557
+ var proto = Object.defineProperties(() => {
5558
+ }, {
5559
+ ...styles2,
5560
+ level: {
5561
+ enumerable: true,
5562
+ get() {
5563
+ return this[GENERATOR].level;
5564
+ },
5565
+ set(level) {
5566
+ this[GENERATOR].level = level;
5715
5567
  }
5716
5568
  }
5569
+ });
5570
+ var createStyler = (open, close, parent) => {
5571
+ let openAll;
5572
+ let closeAll;
5573
+ if (parent === void 0) {
5574
+ openAll = open;
5575
+ closeAll = close;
5576
+ } else {
5577
+ openAll = parent.openAll + open;
5578
+ closeAll = close + parent.closeAll;
5579
+ }
5717
5580
  return {
5718
- // we use vnopts' AliasSchema to handle aliases for better error messages
5719
- alias: {},
5720
- boolean: booleanNames,
5721
- string: stringNames,
5722
- default: defaultValues
5581
+ open,
5582
+ close,
5583
+ openAll,
5584
+ closeAll,
5585
+ parent
5723
5586
  };
5724
- }
5587
+ };
5588
+ var createBuilder = (self, _styler, _isEmpty) => {
5589
+ const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
5590
+ Object.setPrototypeOf(builder, proto);
5591
+ builder[GENERATOR] = self;
5592
+ builder[STYLER] = _styler;
5593
+ builder[IS_EMPTY] = _isEmpty;
5594
+ return builder;
5595
+ };
5596
+ var applyStyle = (self, string) => {
5597
+ if (self.level <= 0 || !string) {
5598
+ return self[IS_EMPTY] ? "" : string;
5599
+ }
5600
+ let styler = self[STYLER];
5601
+ if (styler === void 0) {
5602
+ return string;
5603
+ }
5604
+ const { openAll, closeAll } = styler;
5605
+ if (string.includes("\x1B")) {
5606
+ while (styler !== void 0) {
5607
+ string = stringReplaceAll2(string, styler.close, styler.open);
5608
+ styler = styler.parent;
5609
+ }
5610
+ }
5611
+ const lfIndex = string.indexOf("\n");
5612
+ if (lfIndex !== -1) {
5613
+ string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
5614
+ }
5615
+ return openAll + string + closeAll;
5616
+ };
5617
+ Object.defineProperties(createChalk.prototype, styles2);
5618
+ var chalk = createChalk();
5619
+ var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
5620
+ var source_default = chalk;
5725
5621
 
5726
5622
  // node_modules/leven/index.js
5727
5623
  var array = [];
@@ -5886,185 +5782,87 @@ var Context = class {
5886
5782
  popContextPlugins() {
5887
5783
  __privateGet(this, _stack).pop();
5888
5784
  Object.assign(this, at_default(
5889
- /* isOptionalObject*/
5890
- false,
5891
- __privateGet(this, _stack),
5892
- -1
5893
- ));
5894
- }
5895
- // eslint-disable-next-line getter-return
5896
- get performanceTestFlag() {
5897
- const {
5898
- debugBenchmark,
5899
- debugRepeat
5900
- } = this.argv;
5901
- if (debugBenchmark) {
5902
- return {
5903
- name: "--debug-benchmark",
5904
- debugBenchmark: true
5905
- };
5906
- }
5907
- if (debugRepeat > 0) {
5908
- return {
5909
- name: "--debug-repeat",
5910
- debugRepeat
5911
- };
5912
- }
5913
- const {
5914
- PRETTIER_PERF_REPEAT
5915
- } = process.env;
5916
- if (PRETTIER_PERF_REPEAT && /^\d+$/.test(PRETTIER_PERF_REPEAT)) {
5917
- return {
5918
- name: "PRETTIER_PERF_REPEAT (environment variable)",
5919
- debugRepeat: Number(PRETTIER_PERF_REPEAT)
5920
- };
5921
- }
5922
- }
5923
- };
5924
- _stack = new WeakMap();
5925
- var context_default = Context;
5926
-
5927
- // src/cli/constants.evaluate.js
5928
- var categoryOrder = [
5929
- "Output",
5930
- "Format",
5931
- "Config",
5932
- "Editor",
5933
- "Other"
5934
- ];
5935
- 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.";
5936
-
5937
- // src/cli/usage.js
5938
- var OPTION_USAGE_THRESHOLD = 25;
5939
- var CHOICE_USAGE_MARGIN = 3;
5940
- var CHOICE_USAGE_INDENTATION = 2;
5941
- function indent(str, spaces) {
5942
- return string_replace_all_default(
5943
- /* isOptionalObject*/
5944
- false,
5945
- str,
5946
- /^/gm,
5947
- " ".repeat(spaces)
5948
- );
5949
- }
5950
- function createDefaultValueDisplay(value) {
5951
- return Array.isArray(value) ? `[${value.map(createDefaultValueDisplay).join(", ")}]` : value;
5952
- }
5953
- function getOptionDefaultValue(context, optionName) {
5954
- var _a;
5955
- const option = context.detailedOptions.find(({
5956
- name
5957
- }) => name === optionName);
5958
- if ((option == null ? void 0 : option.default) !== void 0) {
5959
- return option.default;
5960
- }
5961
- const optionCamelName = camelCase(optionName);
5962
- return formatOptionsHiddenDefaults[optionCamelName] ?? ((_a = context.supportOptions.find((option2) => !option2.deprecated && option2.name === optionCamelName)) == null ? void 0 : _a.default);
5963
- }
5964
- function createOptionUsageHeader(option) {
5965
- const name = `--${option.name}`;
5966
- const alias = option.alias ? `-${option.alias},` : null;
5967
- const type = createOptionUsageType(option);
5968
- return [alias, name, type].filter(Boolean).join(" ");
5969
- }
5970
- function createOptionUsageRow(header, content, threshold) {
5971
- const separator = header.length >= threshold ? `
5972
- ${" ".repeat(threshold)}` : " ".repeat(threshold - header.length);
5973
- const description = string_replace_all_default(
5974
- /* isOptionalObject*/
5975
- false,
5976
- content,
5977
- "\n",
5978
- `
5979
- ${" ".repeat(threshold)}`
5980
- );
5981
- return `${header}${separator}${description}`;
5982
- }
5983
- function createOptionUsageType(option) {
5984
- switch (option.type) {
5985
- case "boolean":
5986
- return null;
5987
- case "choice":
5988
- return `<${option.choices.filter((choice) => !choice.deprecated).map((choice) => choice.value).join("|")}>`;
5989
- default:
5990
- return `<${option.type}>`;
5785
+ /* isOptionalObject*/
5786
+ false,
5787
+ __privateGet(this, _stack),
5788
+ -1
5789
+ ));
5991
5790
  }
5992
- }
5993
- function createChoiceUsages(choices, margin, indentation) {
5994
- const activeChoices = choices.filter((choice) => !choice.deprecated);
5995
- const threshold = Math.max(0, ...activeChoices.map((choice) => choice.value.length)) + margin;
5996
- return activeChoices.map((choice) => indent(createOptionUsageRow(choice.value, choice.description, threshold), indentation));
5997
- }
5998
- function createOptionUsage(context, option, threshold) {
5999
- const header = createOptionUsageHeader(option);
6000
- const optionDefaultValue = getOptionDefaultValue(context, option.name);
6001
- return createOptionUsageRow(header, `${option.description}${optionDefaultValue === void 0 ? "" : `
6002
- Defaults to ${createDefaultValueDisplay(optionDefaultValue)}.`}`, threshold);
6003
- }
6004
- function getOptionsWithOpposites(options) {
6005
- const optionsWithOpposites = options.map((option) => [option.description ? option : null, option.oppositeDescription ? {
6006
- ...option,
6007
- name: `no-${option.name}`,
6008
- type: "boolean",
6009
- description: option.oppositeDescription
6010
- } : null]);
6011
- return optionsWithOpposites.flat().filter(Boolean);
6012
- }
6013
- function createUsage(context) {
6014
- const sortedOptions = context.detailedOptions.sort((optionA, optionB) => optionA.name.localeCompare(optionB.name));
6015
- const options = getOptionsWithOpposites(sortedOptions).filter(
6016
- // remove unnecessary option (e.g. `semi`, `color`, etc.), which is only used for --help <flag>
6017
- (option) => !(option.type === "boolean" && option.oppositeDescription && !option.name.startsWith("no-"))
6018
- );
6019
- const groupedOptions = groupBy(options, (option) => option.category);
6020
- const firstCategories = categoryOrder.slice(0, -1);
6021
- const lastCategories = categoryOrder.slice(-1);
6022
- const restCategories = Object.keys(groupedOptions).filter((category) => !categoryOrder.includes(category));
6023
- const allCategories = [...firstCategories, ...restCategories, ...lastCategories];
6024
- const optionsUsage = allCategories.map((category) => {
6025
- const categoryOptions = groupedOptions[category].map((option) => createOptionUsage(context, option, OPTION_USAGE_THRESHOLD)).join("\n");
6026
- return `${category} options:
5791
+ // eslint-disable-next-line getter-return
5792
+ get performanceTestFlag() {
5793
+ const {
5794
+ debugBenchmark,
5795
+ debugRepeat
5796
+ } = this.argv;
5797
+ if (debugBenchmark) {
5798
+ return {
5799
+ name: "--debug-benchmark",
5800
+ debugBenchmark: true
5801
+ };
5802
+ }
5803
+ if (debugRepeat > 0) {
5804
+ return {
5805
+ name: "--debug-repeat",
5806
+ debugRepeat
5807
+ };
5808
+ }
5809
+ const {
5810
+ PRETTIER_PERF_REPEAT
5811
+ } = process.env;
5812
+ if (PRETTIER_PERF_REPEAT && /^\d+$/.test(PRETTIER_PERF_REPEAT)) {
5813
+ return {
5814
+ name: "PRETTIER_PERF_REPEAT (environment variable)",
5815
+ debugRepeat: Number(PRETTIER_PERF_REPEAT)
5816
+ };
5817
+ }
5818
+ }
5819
+ };
5820
+ _stack = new WeakMap();
5821
+ var context_default = Context;
6027
5822
 
6028
- ${indent(categoryOptions, 2)}`;
5823
+ // src/cli/file-info.js
5824
+ var import_fast_json_stable_stringify = __toESM(require_fast_json_stable_stringify(), 1);
5825
+ import { format, getFileInfo } from "../index.mjs";
5826
+ async function logFileInfoOrDie(context) {
5827
+ const {
5828
+ fileInfo: file,
5829
+ ignorePath,
5830
+ withNodeModules,
5831
+ plugins,
5832
+ config
5833
+ } = context.argv;
5834
+ const fileInfo = await getFileInfo(file, {
5835
+ ignorePath,
5836
+ withNodeModules,
5837
+ plugins,
5838
+ resolveConfig: config !== false
6029
5839
  });
6030
- return [usageSummary, ...optionsUsage, ""].join("\n\n");
6031
- }
6032
- function createPluginDefaults(pluginDefaults) {
6033
- if (!pluginDefaults || Object.keys(pluginDefaults).length === 0) {
6034
- return "";
6035
- }
6036
- const defaults = Object.entries(pluginDefaults).sort(([pluginNameA], [pluginNameB]) => pluginNameA.localeCompare(pluginNameB)).map(([plugin, value]) => `* ${plugin}: ${createDefaultValueDisplay(value)}`).join("\n");
6037
- return `
6038
- Plugin defaults:
6039
- ${defaults}`;
5840
+ printToScreen(await format((0, import_fast_json_stable_stringify.default)(fileInfo), { parser: "json" }));
6040
5841
  }
6041
- function createDetailedUsage(context, flag) {
6042
- const option = getOptionsWithOpposites(context.detailedOptions).find((option2) => option2.name === flag || option2.alias === flag);
6043
- const header = createOptionUsageHeader(option);
6044
- const description = `
6045
-
6046
- ${indent(option.description, 2)}`;
6047
- const choices = option.type !== "choice" ? "" : `
6048
-
6049
- Valid options:
6050
-
6051
- ${createChoiceUsages(option.choices, CHOICE_USAGE_MARGIN, CHOICE_USAGE_INDENTATION).join("\n")}`;
6052
- const optionDefaultValue = getOptionDefaultValue(context, option.name);
6053
- const defaults = optionDefaultValue !== void 0 ? `
5842
+ var file_info_default = logFileInfoOrDie;
6054
5843
 
6055
- Default: ${createDefaultValueDisplay(optionDefaultValue)}` : "";
6056
- const pluginDefaults = createPluginDefaults(option.pluginDefaults);
6057
- return `${header}${description}${choices}${defaults}${pluginDefaults}`;
5844
+ // src/cli/find-config-path.js
5845
+ import path2 from "path";
5846
+ import { resolveConfigFile } from "../index.mjs";
5847
+ async function logResolvedConfigPathOrDie(context) {
5848
+ const file = context.argv.findConfigPath;
5849
+ const configFile = await resolveConfigFile(file);
5850
+ if (configFile) {
5851
+ printToScreen(normalizeToPosix(path2.relative(process.cwd(), configFile)));
5852
+ } else {
5853
+ throw new Error(`Can not find configure file for "${file}".`);
5854
+ }
6058
5855
  }
5856
+ var find_config_path_default = logResolvedConfigPathOrDie;
6059
5857
 
6060
5858
  // src/cli/format.js
6061
5859
  import fs5 from "fs/promises";
6062
- import path8 from "path";
5860
+ import path9 from "path";
6063
5861
  var import_diff = __toESM(require_create(), 1);
6064
5862
  import * as prettier from "../index.mjs";
6065
5863
 
6066
5864
  // src/cli/expand-patterns.js
6067
- import path2 from "path";
5865
+ import path3 from "path";
6068
5866
  async function* expandPatterns(context) {
6069
5867
  const seen = /* @__PURE__ */ new Set();
6070
5868
  let noResults = true;
@@ -6080,7 +5878,7 @@ async function* expandPatterns(context) {
6080
5878
  };
6081
5879
  continue;
6082
5880
  }
6083
- const filename = path2.resolve(filePath);
5881
+ const filename = path3.resolve(filePath);
6084
5882
  if (seen.has(filename)) {
6085
5883
  continue;
6086
5884
  }
@@ -6109,7 +5907,7 @@ async function* expandPatternsInternal(context) {
6109
5907
  const cwd2 = process.cwd();
6110
5908
  const entries = [];
6111
5909
  for (const pattern of context.filePatterns) {
6112
- const absolutePath = path2.resolve(cwd2, pattern);
5910
+ const absolutePath = path3.resolve(cwd2, pattern);
6113
5911
  if (containsIgnoredPathSegment(absolutePath, cwd2, silentlyIgnoredDirs)) {
6114
5912
  continue;
6115
5913
  }
@@ -6130,7 +5928,7 @@ async function* expandPatternsInternal(context) {
6130
5928
  input: pattern
6131
5929
  });
6132
5930
  } else if (stat.isDirectory()) {
6133
- const relativePath = path2.relative(cwd2, absolutePath) || ".";
5931
+ const relativePath = path3.relative(cwd2, absolutePath) || ".";
6134
5932
  const prefix = escapePathForGlob(fixWindowsSlashes(relativePath));
6135
5933
  entries.push({
6136
5934
  type: "dir",
@@ -6173,191 +5971,79 @@ ${message}`
6173
5971
  error: `${errorMessages.emptyResults[type]}: "${input}".`
6174
5972
  };
6175
5973
  }
6176
- } else {
6177
- yield* sortPaths(result).map((filePath) => ({
6178
- filePath,
6179
- ignoreUnknown
6180
- }));
6181
- }
6182
- }
6183
- }
6184
- var errorMessages = {
6185
- globError: {
6186
- file: "Unable to resolve file",
6187
- dir: "Unable to expand directory",
6188
- glob: "Unable to expand glob pattern"
6189
- },
6190
- emptyResults: {
6191
- file: "Explicitly specified file was ignored due to negative glob patterns",
6192
- dir: "No supported files were found in the directory",
6193
- glob: "No files matching the pattern were found"
6194
- }
6195
- };
6196
- function containsIgnoredPathSegment(absolutePath, cwd2, ignoredDirectories) {
6197
- return path2.relative(cwd2, absolutePath).split(path2.sep).some((dir) => ignoredDirectories.includes(dir));
6198
- }
6199
- function sortPaths(paths) {
6200
- return paths.sort((a, b) => a.localeCompare(b));
6201
- }
6202
- function escapePathForGlob(path10) {
6203
- return string_replace_all_default(
6204
- /* isOptionalObject*/
6205
- false,
6206
- string_replace_all_default(
6207
- /* isOptionalObject*/
6208
- false,
6209
- fastGlob.escapePath(
6210
- string_replace_all_default(
6211
- /* isOptionalObject*/
6212
- false,
6213
- path10,
6214
- "\\",
6215
- "\0"
6216
- )
6217
- // Workaround for fast-glob#262 (part 1)
6218
- ),
6219
- "\\!",
6220
- "@(!)"
6221
- ),
6222
- "\0",
6223
- "@(\\\\)"
6224
- );
6225
- }
6226
- var fixWindowsSlashes = normalizeToPosix;
6227
-
6228
- // src/cli/options/get-options-for-file.js
6229
- var import_dashify2 = __toESM(require_dashify(), 1);
6230
- import { resolveConfig } from "../index.mjs";
6231
- function getOptions(argv, detailedOptions) {
6232
- return Object.fromEntries(
6233
- detailedOptions.filter(({ forwardToApi }) => forwardToApi).map(({ forwardToApi, name }) => [forwardToApi, argv[name]])
6234
- );
6235
- }
6236
- function cliifyOptions(object, apiDetailedOptionMap) {
6237
- return Object.fromEntries(
6238
- Object.entries(object || {}).map(([key, value]) => {
6239
- const apiOption = apiDetailedOptionMap[key];
6240
- const cliKey = apiOption ? apiOption.name : key;
6241
- return [(0, import_dashify2.default)(cliKey), value];
6242
- })
6243
- );
6244
- }
6245
- function createApiDetailedOptionMap(detailedOptions) {
6246
- return Object.fromEntries(
6247
- detailedOptions.filter(
6248
- (option) => option.forwardToApi && option.forwardToApi !== option.name
6249
- ).map((option) => [option.forwardToApi, option])
6250
- );
6251
- }
6252
- function parseArgsToOptions(context, overrideDefaults) {
6253
- const minimistOptions = createMinimistOptions(context.detailedOptions);
6254
- const apiDetailedOptionMap = createApiDetailedOptionMap(
6255
- context.detailedOptions
6256
- );
6257
- return getOptions(
6258
- normalize_cli_options_default(
6259
- minimistParse(context.rawArguments, {
6260
- string: minimistOptions.string,
6261
- boolean: minimistOptions.boolean,
6262
- default: cliifyOptions(overrideDefaults, apiDetailedOptionMap)
6263
- }),
6264
- context.detailedOptions,
6265
- { logger: false }
6266
- ),
6267
- context.detailedOptions
6268
- );
6269
- }
6270
- async function getOptionsOrDie(context, filePath) {
6271
- try {
6272
- if (context.argv.config === false) {
6273
- context.logger.debug(
6274
- "'--no-config' option found, skip loading config file."
6275
- );
6276
- return null;
6277
- }
6278
- context.logger.debug(
6279
- context.argv.config ? `load config file from '${context.argv.config}'` : `resolve config from '${filePath}'`
6280
- );
6281
- const options = await resolveConfig(filePath, {
6282
- editorconfig: context.argv.editorconfig,
6283
- config: context.argv.config
6284
- });
6285
- context.logger.debug("loaded options `" + JSON.stringify(options) + "`");
6286
- return options;
6287
- } catch (error) {
6288
- context.logger.error(
6289
- `Invalid configuration${filePath ? ` for file "${filePath}"` : ""}:
6290
- ` + error.message
6291
- );
6292
- process.exit(2);
6293
- }
6294
- }
6295
- function applyConfigPrecedence(context, options) {
6296
- try {
6297
- switch (context.argv.configPrecedence) {
6298
- case "cli-override":
6299
- return parseArgsToOptions(context, options);
6300
- case "file-override":
6301
- return { ...parseArgsToOptions(context), ...options };
6302
- case "prefer-file":
6303
- return options || parseArgsToOptions(context);
5974
+ } else {
5975
+ yield* sortPaths(result).map((filePath) => ({
5976
+ filePath,
5977
+ ignoreUnknown
5978
+ }));
6304
5979
  }
6305
- } catch (error) {
6306
- context.logger.error(error.toString());
6307
- process.exit(2);
6308
5980
  }
6309
5981
  }
6310
- async function getOptionsForFile(context, filepath) {
6311
- const options = await getOptionsOrDie(context, filepath);
6312
- const hasPlugins = options == null ? void 0 : options.plugins;
6313
- if (hasPlugins) {
6314
- await context.pushContextPlugins(options.plugins);
6315
- }
6316
- const appliedOptions = {
6317
- filepath,
6318
- ...applyConfigPrecedence(
6319
- context,
6320
- options && normalizeOptions(options, context.supportOptions, {
6321
- logger: context.logger
6322
- })
6323
- )
6324
- };
6325
- context.logger.debug(
6326
- `applied config-precedence (${context.argv.configPrecedence}): ${JSON.stringify(appliedOptions)}`
6327
- );
6328
- if (hasPlugins) {
6329
- context.popContextPlugins();
5982
+ var errorMessages = {
5983
+ globError: {
5984
+ file: "Unable to resolve file",
5985
+ dir: "Unable to expand directory",
5986
+ glob: "Unable to expand glob pattern"
5987
+ },
5988
+ emptyResults: {
5989
+ file: "Explicitly specified file was ignored due to negative glob patterns",
5990
+ dir: "No supported files were found in the directory",
5991
+ glob: "No files matching the pattern were found"
6330
5992
  }
6331
- return appliedOptions;
5993
+ };
5994
+ function containsIgnoredPathSegment(absolutePath, cwd2, ignoredDirectories) {
5995
+ return path3.relative(cwd2, absolutePath).split(path3.sep).some((dir) => ignoredDirectories.includes(dir));
6332
5996
  }
6333
- var get_options_for_file_default = getOptionsForFile;
6334
-
6335
- // src/cli/is-tty.js
6336
- function isTTY() {
6337
- return process.stdout.isTTY && !mockable.isCI();
5997
+ function sortPaths(paths) {
5998
+ return paths.sort((a, b) => a.localeCompare(b));
5999
+ }
6000
+ function escapePathForGlob(path10) {
6001
+ return string_replace_all_default(
6002
+ /* isOptionalObject*/
6003
+ false,
6004
+ string_replace_all_default(
6005
+ /* isOptionalObject*/
6006
+ false,
6007
+ fastGlob.escapePath(
6008
+ string_replace_all_default(
6009
+ /* isOptionalObject*/
6010
+ false,
6011
+ path10,
6012
+ "\\",
6013
+ "\0"
6014
+ )
6015
+ // Workaround for fast-glob#262 (part 1)
6016
+ ),
6017
+ "\\!",
6018
+ "@(!)"
6019
+ ),
6020
+ "\0",
6021
+ "@(\\\\)"
6022
+ );
6338
6023
  }
6024
+ var fixWindowsSlashes = normalizeToPosix;
6339
6025
 
6340
6026
  // src/cli/find-cache-file.js
6341
6027
  import fs4 from "fs/promises";
6342
6028
  import os2 from "os";
6343
- import path7 from "path";
6029
+ import path8 from "path";
6344
6030
 
6345
6031
  // node_modules/find-cache-dir/index.js
6346
6032
  var import_common_path_prefix = __toESM(require_common_path_prefix(), 1);
6347
6033
  import process4 from "process";
6348
- import path6 from "path";
6034
+ import path7 from "path";
6349
6035
  import fs3 from "fs";
6350
6036
 
6351
6037
  // node_modules/pkg-dir/index.js
6352
- import path5 from "path";
6038
+ import path6 from "path";
6353
6039
 
6354
6040
  // node_modules/pkg-dir/node_modules/find-up/index.js
6355
- import path4 from "path";
6041
+ import path5 from "path";
6356
6042
  import { fileURLToPath as fileURLToPath2 } from "url";
6357
6043
 
6358
6044
  // node_modules/pkg-dir/node_modules/locate-path/index.js
6359
6045
  import process3 from "process";
6360
- import path3 from "path";
6046
+ import path4 from "path";
6361
6047
  import fs2, { promises as fsPromises } from "fs";
6362
6048
  import { fileURLToPath } from "url";
6363
6049
 
@@ -6440,7 +6126,7 @@ function locatePathSync(paths, {
6440
6126
  const statFunction = allowSymlinks ? fs2.statSync : fs2.lstatSync;
6441
6127
  for (const path_ of paths) {
6442
6128
  try {
6443
- const stat = statFunction(path3.resolve(cwd2, path_), {
6129
+ const stat = statFunction(path4.resolve(cwd2, path_), {
6444
6130
  throwIfNoEntry: false
6445
6131
  });
6446
6132
  if (!stat) {
@@ -6458,8 +6144,8 @@ function locatePathSync(paths, {
6458
6144
  var toPath2 = (urlOrPath) => urlOrPath instanceof URL ? fileURLToPath2(urlOrPath) : urlOrPath;
6459
6145
  var findUpStop = Symbol("findUpStop");
6460
6146
  function findUpMultipleSync(name, options = {}) {
6461
- let directory = path4.resolve(toPath2(options.cwd) || "");
6462
- const { root } = path4.parse(directory);
6147
+ let directory = path5.resolve(toPath2(options.cwd) || "");
6148
+ const { root } = path5.parse(directory);
6463
6149
  const stopAt = options.stopAt || root;
6464
6150
  const limit = options.limit || Number.POSITIVE_INFINITY;
6465
6151
  const paths = [name].flat();
@@ -6480,12 +6166,12 @@ function findUpMultipleSync(name, options = {}) {
6480
6166
  break;
6481
6167
  }
6482
6168
  if (foundPath) {
6483
- matches.push(path4.resolve(directory, foundPath));
6169
+ matches.push(path5.resolve(directory, foundPath));
6484
6170
  }
6485
6171
  if (directory === stopAt || matches.length >= limit) {
6486
6172
  break;
6487
6173
  }
6488
- directory = path4.dirname(directory);
6174
+ directory = path5.dirname(directory);
6489
6175
  }
6490
6176
  return matches;
6491
6177
  }
@@ -6497,7 +6183,7 @@ function findUpSync(name, options = {}) {
6497
6183
  // node_modules/pkg-dir/index.js
6498
6184
  function packageDirectorySync({ cwd: cwd2 } = {}) {
6499
6185
  const filePath = findUpSync("package.json", { cwd: cwd2 });
6500
- return filePath && path5.dirname(filePath);
6186
+ return filePath && path6.dirname(filePath);
6501
6187
  }
6502
6188
 
6503
6189
  // node_modules/find-cache-dir/index.js
@@ -6517,22 +6203,22 @@ function useDirectory(directory, options) {
6517
6203
  return directory;
6518
6204
  }
6519
6205
  function getNodeModuleDirectory(directory) {
6520
- const nodeModules = path6.join(directory, "node_modules");
6521
- if (!isWritable(nodeModules) && (fs3.existsSync(nodeModules) || !isWritable(path6.join(directory)))) {
6206
+ const nodeModules = path7.join(directory, "node_modules");
6207
+ if (!isWritable(nodeModules) && (fs3.existsSync(nodeModules) || !isWritable(path7.join(directory)))) {
6522
6208
  return;
6523
6209
  }
6524
6210
  return nodeModules;
6525
6211
  }
6526
6212
  function findCacheDirectory(options = {}) {
6527
6213
  if (env2.CACHE_DIR && !["true", "false", "1", "0"].includes(env2.CACHE_DIR)) {
6528
- return useDirectory(path6.join(env2.CACHE_DIR, options.name), options);
6214
+ return useDirectory(path7.join(env2.CACHE_DIR, options.name), options);
6529
6215
  }
6530
6216
  let { cwd: directory = cwd(), files } = options;
6531
6217
  if (files) {
6532
6218
  if (!Array.isArray(files)) {
6533
6219
  throw new TypeError(`Expected \`files\` option to be an array, got \`${typeof files}\`.`);
6534
6220
  }
6535
- directory = (0, import_common_path_prefix.default)(files.map((file) => path6.resolve(directory, file)));
6221
+ directory = (0, import_common_path_prefix.default)(files.map((file) => path7.resolve(directory, file)));
6536
6222
  }
6537
6223
  directory = packageDirectorySync({ cwd: directory });
6538
6224
  if (!directory) {
@@ -6542,17 +6228,17 @@ function findCacheDirectory(options = {}) {
6542
6228
  if (!nodeModules) {
6543
6229
  return;
6544
6230
  }
6545
- return useDirectory(path6.join(directory, "node_modules", ".cache", options.name), options);
6231
+ return useDirectory(path7.join(directory, "node_modules", ".cache", options.name), options);
6546
6232
  }
6547
6233
 
6548
6234
  // src/cli/find-cache-file.js
6549
6235
  function findDefaultCacheFile() {
6550
6236
  const cacheDir = findCacheDirectory({ name: "prettier", create: true }) || os2.tmpdir();
6551
- const cacheFilePath = path7.join(cacheDir, ".prettier-cache");
6237
+ const cacheFilePath = path8.join(cacheDir, ".prettier-cache");
6552
6238
  return cacheFilePath;
6553
6239
  }
6554
6240
  async function findCacheFileFromOption(cacheLocation) {
6555
- const cacheFile = path7.resolve(cacheLocation);
6241
+ const cacheFile = path8.resolve(cacheLocation);
6556
6242
  const stat = await statSafe(cacheFile);
6557
6243
  if (stat) {
6558
6244
  if (stat.isDirectory()) {
@@ -6577,8 +6263,8 @@ async function findCacheFile(cacheLocation) {
6577
6263
  var find_cache_file_default = findCacheFile;
6578
6264
 
6579
6265
  // src/cli/format-results-cache.js
6266
+ var import_fast_json_stable_stringify2 = __toESM(require_fast_json_stable_stringify(), 1);
6580
6267
  var import_file_entry_cache = __toESM(require_cache2(), 1);
6581
- var import_fast_json_stable_stringify = __toESM(require_fast_json_stable_stringify(), 1);
6582
6268
  import { version as prettierVersion } from "../index.mjs";
6583
6269
  var optionsHashCache = /* @__PURE__ */ new WeakMap();
6584
6270
  var nodeVersion = process.version;
@@ -6587,7 +6273,7 @@ function getHashOfOptions(options) {
6587
6273
  return optionsHashCache.get(options);
6588
6274
  }
6589
6275
  const hash = createHash(
6590
- `${prettierVersion}_${nodeVersion}_${(0, import_fast_json_stable_stringify.default)(options)}`
6276
+ `${prettierVersion}_${nodeVersion}_${(0, import_fast_json_stable_stringify2.default)(options)}`
6591
6277
  );
6592
6278
  optionsHashCache.set(options, hash);
6593
6279
  return hash;
@@ -6650,6 +6336,118 @@ var FormatResultsCache = class {
6650
6336
  _fileEntryCache = new WeakMap();
6651
6337
  var format_results_cache_default = FormatResultsCache;
6652
6338
 
6339
+ // src/cli/is-tty.js
6340
+ function isTTY() {
6341
+ return process.stdout.isTTY && !mockable.isCI();
6342
+ }
6343
+
6344
+ // src/cli/options/get-options-for-file.js
6345
+ var import_dashify2 = __toESM(require_dashify(), 1);
6346
+ import { resolveConfig } from "../index.mjs";
6347
+ function getOptions(argv, detailedOptions) {
6348
+ return Object.fromEntries(
6349
+ detailedOptions.filter(({ forwardToApi }) => forwardToApi).map(({ forwardToApi, name }) => [forwardToApi, argv[name]])
6350
+ );
6351
+ }
6352
+ function cliifyOptions(object, apiDetailedOptionMap) {
6353
+ return Object.fromEntries(
6354
+ Object.entries(object || {}).map(([key, value]) => {
6355
+ const apiOption = apiDetailedOptionMap[key];
6356
+ const cliKey = apiOption ? apiOption.name : key;
6357
+ return [(0, import_dashify2.default)(cliKey), value];
6358
+ })
6359
+ );
6360
+ }
6361
+ function createApiDetailedOptionMap(detailedOptions) {
6362
+ return Object.fromEntries(
6363
+ detailedOptions.filter(
6364
+ (option) => option.forwardToApi && option.forwardToApi !== option.name
6365
+ ).map((option) => [option.forwardToApi, option])
6366
+ );
6367
+ }
6368
+ function parseArgsToOptions(context, overrideDefaults) {
6369
+ const minimistOptions = createMinimistOptions(context.detailedOptions);
6370
+ const apiDetailedOptionMap = createApiDetailedOptionMap(
6371
+ context.detailedOptions
6372
+ );
6373
+ return getOptions(
6374
+ normalize_cli_options_default(
6375
+ minimistParse(context.rawArguments, {
6376
+ string: minimistOptions.string,
6377
+ boolean: minimistOptions.boolean,
6378
+ default: cliifyOptions(overrideDefaults, apiDetailedOptionMap)
6379
+ }),
6380
+ context.detailedOptions,
6381
+ { logger: false }
6382
+ ),
6383
+ context.detailedOptions
6384
+ );
6385
+ }
6386
+ async function getOptionsOrDie(context, filePath) {
6387
+ try {
6388
+ if (context.argv.config === false) {
6389
+ context.logger.debug(
6390
+ "'--no-config' option found, skip loading config file."
6391
+ );
6392
+ return null;
6393
+ }
6394
+ context.logger.debug(
6395
+ context.argv.config ? `load config file from '${context.argv.config}'` : `resolve config from '${filePath}'`
6396
+ );
6397
+ const options = await resolveConfig(filePath, {
6398
+ editorconfig: context.argv.editorconfig,
6399
+ config: context.argv.config
6400
+ });
6401
+ context.logger.debug("loaded options `" + JSON.stringify(options) + "`");
6402
+ return options;
6403
+ } catch (error) {
6404
+ context.logger.error(
6405
+ `Invalid configuration${filePath ? ` for file "${filePath}"` : ""}:
6406
+ ` + error.message
6407
+ );
6408
+ process.exit(2);
6409
+ }
6410
+ }
6411
+ function applyConfigPrecedence(context, options) {
6412
+ try {
6413
+ switch (context.argv.configPrecedence) {
6414
+ case "cli-override":
6415
+ return parseArgsToOptions(context, options);
6416
+ case "file-override":
6417
+ return { ...parseArgsToOptions(context), ...options };
6418
+ case "prefer-file":
6419
+ return options || parseArgsToOptions(context);
6420
+ }
6421
+ } catch (error) {
6422
+ context.logger.error(error.toString());
6423
+ process.exit(2);
6424
+ }
6425
+ }
6426
+ async function getOptionsForFile(context, filepath) {
6427
+ const options = await getOptionsOrDie(context, filepath);
6428
+ const hasPlugins = options == null ? void 0 : options.plugins;
6429
+ if (hasPlugins) {
6430
+ await context.pushContextPlugins(options.plugins);
6431
+ }
6432
+ const appliedOptions = {
6433
+ filepath,
6434
+ ...applyConfigPrecedence(
6435
+ context,
6436
+ options && normalizeOptions(options, context.supportOptions, {
6437
+ logger: context.logger
6438
+ })
6439
+ )
6440
+ };
6441
+ context.logger.debug(
6442
+ `applied config-precedence (${context.argv.configPrecedence}): ${JSON.stringify(appliedOptions)}`
6443
+ );
6444
+ if (hasPlugins) {
6445
+ context.popContextPlugins();
6446
+ }
6447
+ return appliedOptions;
6448
+ }
6449
+ var get_options_for_file_default = getOptionsForFile;
6450
+
6653
6451
  // src/cli/format.js
6654
6452
  var { getStdin, writeFormattedFile } = mockable;
6655
6453
  function diff(a, b) {
@@ -6714,7 +6512,7 @@ async function listDifferent(context, input, options, filename) {
6714
6512
  }
6715
6513
  return true;
6716
6514
  }
6717
- async function format2(context, input, opt) {
6515
+ async function format3(context, input, opt) {
6718
6516
  if (context.argv.debugPrintDoc) {
6719
6517
  const doc = await prettier.__debug.printToDoc(input, opt);
6720
6518
  return { formatted: await prettier.__debug.formatDoc(doc) + "\n" };
@@ -6847,12 +6645,12 @@ async function formatStdin(context) {
6847
6645
  }
6848
6646
  const options = await get_options_for_file_default(
6849
6647
  context,
6850
- filepath ? path8.resolve(filepath) : void 0
6648
+ filepath ? path9.resolve(filepath) : void 0
6851
6649
  );
6852
6650
  if (await listDifferent(context, input, options, "(stdin)")) {
6853
6651
  return;
6854
6652
  }
6855
- const formatted = await format2(context, input, options);
6653
+ const formatted = await format3(context, input, options);
6856
6654
  const { performanceTestFlag } = context;
6857
6655
  if (performanceTestFlag) {
6858
6656
  context.logger.log(
@@ -6902,7 +6700,7 @@ async function formatFiles(context) {
6902
6700
  ...await get_options_for_file_default(context, filename),
6903
6701
  filepath: filename
6904
6702
  };
6905
- const fileNameToDisplay = normalizeToPosix(path8.relative(cwd2, filename));
6703
+ const fileNameToDisplay = normalizeToPosix(path9.relative(cwd2, filename));
6906
6704
  let printedFilename;
6907
6705
  if (isTTY()) {
6908
6706
  printedFilename = context.logger.log(fileNameToDisplay, {
@@ -6938,7 +6736,7 @@ ${error2.message}`
6938
6736
  if (isCacheExists) {
6939
6737
  result = { formatted: input };
6940
6738
  } else {
6941
- result = await format2(context, input, options);
6739
+ result = await format3(context, input, options);
6942
6740
  }
6943
6741
  output = result.formatted;
6944
6742
  } catch (error2) {
@@ -6992,74 +6790,143 @@ ${error2.message}`
6992
6790
  } else if (!context.argv.check && !context.argv.listDifferent) {
6993
6791
  writeOutput(context, result, options);
6994
6792
  }
6995
- if (shouldSetCache) {
6996
- formatResultsCache == null ? void 0 : formatResultsCache.setFormatResultsCache(filename, options);
6997
- } else {
6998
- formatResultsCache == null ? void 0 : formatResultsCache.removeFormatResultsCache(filename);
6793
+ if (shouldSetCache) {
6794
+ formatResultsCache == null ? void 0 : formatResultsCache.setFormatResultsCache(filename, options);
6795
+ } else {
6796
+ formatResultsCache == null ? void 0 : formatResultsCache.removeFormatResultsCache(filename);
6797
+ }
6798
+ if (isDifferent) {
6799
+ if (context.argv.check) {
6800
+ context.logger.warn(fileNameToDisplay);
6801
+ } else if (context.argv.listDifferent) {
6802
+ context.logger.log(fileNameToDisplay);
6803
+ }
6804
+ numberOfUnformattedFilesFound += 1;
6805
+ }
6806
+ }
6807
+ formatResultsCache == null ? void 0 : formatResultsCache.reconcile();
6808
+ if (context.argv.check) {
6809
+ if (numberOfUnformattedFilesFound === 0) {
6810
+ context.logger.log("All matched files use Prettier code style!");
6811
+ } else {
6812
+ const files = numberOfUnformattedFilesFound === 1 ? "the above file" : `${numberOfUnformattedFilesFound} files`;
6813
+ context.logger.warn(
6814
+ context.argv.write ? `Code style issues fixed in ${files}.` : `Code style issues found in ${files}. Run Prettier to fix.`
6815
+ );
6816
+ }
6817
+ }
6818
+ if ((context.argv.check || context.argv.listDifferent) && numberOfUnformattedFilesFound > 0 && !process.exitCode && !context.argv.write) {
6819
+ process.exitCode = 1;
6820
+ }
6821
+ }
6822
+
6823
+ // src/cli/logger.js
6824
+ import readline from "readline";
6825
+
6826
+ // node_modules/ansi-regex/index.js
6827
+ function ansiRegex({ onlyFirst = false } = {}) {
6828
+ const pattern = [
6829
+ "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
6830
+ "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"
6831
+ ].join("|");
6832
+ return new RegExp(pattern, onlyFirst ? void 0 : "g");
6833
+ }
6834
+
6835
+ // node_modules/strip-ansi/index.js
6836
+ var regex = ansiRegex();
6837
+ function stripAnsi(string) {
6838
+ if (typeof string !== "string") {
6839
+ throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
6840
+ }
6841
+ return string.replace(regex, "");
6842
+ }
6843
+
6844
+ // src/cli/logger.js
6845
+ var import_wcwidth = __toESM(require_wcwidth(), 1);
6846
+ var countLines = (stream, text) => {
6847
+ const columns = stream.columns || 80;
6848
+ let lineCount = 0;
6849
+ for (const line of stripAnsi(text).split("\n")) {
6850
+ lineCount += Math.max(1, Math.ceil((0, import_wcwidth.default)(line) / columns));
6851
+ }
6852
+ return lineCount;
6853
+ };
6854
+ var clear = (stream, text) => () => {
6855
+ const lineCount = countLines(stream, text);
6856
+ for (let line = 0; line < lineCount; line++) {
6857
+ if (line > 0) {
6858
+ readline.moveCursor(stream, 0, -1);
6859
+ }
6860
+ readline.clearLine(stream, 0);
6861
+ readline.cursorTo(stream, 0);
6862
+ }
6863
+ };
6864
+ var emptyLogResult = {
6865
+ clear() {
6866
+ }
6867
+ };
6868
+ function createLogger(logLevel = "log") {
6869
+ return {
6870
+ logLevel,
6871
+ warn: createLogFunc("warn", "yellow"),
6872
+ error: createLogFunc("error", "red"),
6873
+ debug: createLogFunc("debug", "blue"),
6874
+ log: createLogFunc("log")
6875
+ };
6876
+ function createLogFunc(loggerName, color) {
6877
+ if (!shouldLog(loggerName)) {
6878
+ return () => emptyLogResult;
6999
6879
  }
7000
- if (isDifferent) {
7001
- if (context.argv.check) {
7002
- context.logger.warn(fileNameToDisplay);
7003
- } else if (context.argv.listDifferent) {
7004
- context.logger.log(fileNameToDisplay);
6880
+ const stream = process[loggerName === "log" ? "stdout" : "stderr"];
6881
+ const chalkInstance = loggerName === "log" ? source_default : chalkStderr;
6882
+ const prefix = color ? `[${chalkInstance[color](loggerName)}] ` : "";
6883
+ return (message, options) => {
6884
+ options = {
6885
+ newline: true,
6886
+ clearable: false,
6887
+ ...options
6888
+ };
6889
+ message = string_replace_all_default(
6890
+ /* isOptionalObject*/
6891
+ false,
6892
+ message,
6893
+ /^/gm,
6894
+ prefix
6895
+ ) + (options.newline ? "\n" : "");
6896
+ stream.write(message);
6897
+ if (options.clearable) {
6898
+ return {
6899
+ clear: clear(stream, message)
6900
+ };
7005
6901
  }
7006
- numberOfUnformattedFilesFound += 1;
7007
- }
6902
+ };
7008
6903
  }
7009
- formatResultsCache == null ? void 0 : formatResultsCache.reconcile();
7010
- if (context.argv.check) {
7011
- if (numberOfUnformattedFilesFound === 0) {
7012
- context.logger.log("All matched files use Prettier code style!");
7013
- } else {
7014
- const files = numberOfUnformattedFilesFound === 1 ? "the above file" : `${numberOfUnformattedFilesFound} files`;
7015
- context.logger.warn(
7016
- context.argv.write ? `Code style issues fixed in ${files}.` : `Code style issues found in ${files}. Run Prettier to fix.`
7017
- );
6904
+ function shouldLog(loggerName) {
6905
+ switch (logLevel) {
6906
+ case "silent":
6907
+ return false;
6908
+ case "debug":
6909
+ if (loggerName === "debug") {
6910
+ return true;
6911
+ }
6912
+ case "log":
6913
+ if (loggerName === "log") {
6914
+ return true;
6915
+ }
6916
+ case "warn":
6917
+ if (loggerName === "warn") {
6918
+ return true;
6919
+ }
6920
+ case "error":
6921
+ return loggerName === "error";
7018
6922
  }
7019
6923
  }
7020
- if ((context.argv.check || context.argv.listDifferent) && numberOfUnformattedFilesFound > 0 && !process.exitCode && !context.argv.write) {
7021
- process.exitCode = 1;
7022
- }
7023
- }
7024
-
7025
- // src/cli/file-info.js
7026
- var import_fast_json_stable_stringify2 = __toESM(require_fast_json_stable_stringify(), 1);
7027
- import { format as format3, getFileInfo } from "../index.mjs";
7028
- async function logFileInfoOrDie(context) {
7029
- const {
7030
- fileInfo: file,
7031
- ignorePath,
7032
- withNodeModules,
7033
- plugins,
7034
- config
7035
- } = context.argv;
7036
- const fileInfo = await getFileInfo(file, {
7037
- ignorePath,
7038
- withNodeModules,
7039
- plugins,
7040
- resolveConfig: config !== false
7041
- });
7042
- printToScreen(await format3((0, import_fast_json_stable_stringify2.default)(fileInfo), { parser: "json" }));
7043
- }
7044
- var file_info_default = logFileInfoOrDie;
7045
-
7046
- // src/cli/find-config-path.js
7047
- import path9 from "path";
7048
- import { resolveConfigFile } from "../index.mjs";
7049
- async function logResolvedConfigPathOrDie(context) {
7050
- const file = context.argv.findConfigPath;
7051
- const configFile = await resolveConfigFile(file);
7052
- if (configFile) {
7053
- printToScreen(normalizeToPosix(path9.relative(process.cwd(), configFile)));
7054
- } else {
7055
- throw new Error(`Can not find configure file for "${file}".`);
7056
- }
7057
6924
  }
7058
- var find_config_path_default = logResolvedConfigPathOrDie;
6925
+ var logger_default = createLogger;
7059
6926
 
7060
6927
  // src/cli/print-support-info.js
7061
6928
  var import_fast_json_stable_stringify3 = __toESM(require_fast_json_stable_stringify(), 1);
7062
- import { getSupportInfo as getSupportInfo2, format as format4 } from "../index.mjs";
6929
+ import { format as format4, getSupportInfo as getSupportInfo2 } from "../index.mjs";
7063
6930
  var sortByName = (array2) => array2.sort((a, b) => a.name.localeCompare(b.name));
7064
6931
  async function printSupportInfo() {
7065
6932
  const { languages, options } = await getSupportInfo2();
@@ -7073,6 +6940,139 @@ async function printSupportInfo() {
7073
6940
  }
7074
6941
  var print_support_info_default = printSupportInfo;
7075
6942
 
6943
+ // src/cli/constants.evaluate.js
6944
+ var categoryOrder = [
6945
+ "Output",
6946
+ "Format",
6947
+ "Config",
6948
+ "Editor",
6949
+ "Other"
6950
+ ];
6951
+ 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.";
6952
+
6953
+ // src/cli/usage.js
6954
+ var OPTION_USAGE_THRESHOLD = 25;
6955
+ var CHOICE_USAGE_MARGIN = 3;
6956
+ var CHOICE_USAGE_INDENTATION = 2;
6957
+ function indent(str, spaces) {
6958
+ return string_replace_all_default(
6959
+ /* isOptionalObject*/
6960
+ false,
6961
+ str,
6962
+ /^/gm,
6963
+ " ".repeat(spaces)
6964
+ );
6965
+ }
6966
+ function createDefaultValueDisplay(value) {
6967
+ return Array.isArray(value) ? `[${value.map(createDefaultValueDisplay).join(", ")}]` : value;
6968
+ }
6969
+ function getOptionDefaultValue(context, optionName) {
6970
+ var _a;
6971
+ const option = context.detailedOptions.find(({
6972
+ name
6973
+ }) => name === optionName);
6974
+ if ((option == null ? void 0 : option.default) !== void 0) {
6975
+ return option.default;
6976
+ }
6977
+ const optionCamelName = camelCase(optionName);
6978
+ return formatOptionsHiddenDefaults[optionCamelName] ?? ((_a = context.supportOptions.find((option2) => !option2.deprecated && option2.name === optionCamelName)) == null ? void 0 : _a.default);
6979
+ }
6980
+ function createOptionUsageHeader(option) {
6981
+ const name = `--${option.name}`;
6982
+ const alias = option.alias ? `-${option.alias},` : null;
6983
+ const type = createOptionUsageType(option);
6984
+ return [alias, name, type].filter(Boolean).join(" ");
6985
+ }
6986
+ function createOptionUsageRow(header, content, threshold) {
6987
+ const separator = header.length >= threshold ? `
6988
+ ${" ".repeat(threshold)}` : " ".repeat(threshold - header.length);
6989
+ const description = string_replace_all_default(
6990
+ /* isOptionalObject*/
6991
+ false,
6992
+ content,
6993
+ "\n",
6994
+ `
6995
+ ${" ".repeat(threshold)}`
6996
+ );
6997
+ return `${header}${separator}${description}`;
6998
+ }
6999
+ function createOptionUsageType(option) {
7000
+ switch (option.type) {
7001
+ case "boolean":
7002
+ return null;
7003
+ case "choice":
7004
+ return `<${option.choices.filter((choice) => !choice.deprecated).map((choice) => choice.value).join("|")}>`;
7005
+ default:
7006
+ return `<${option.type}>`;
7007
+ }
7008
+ }
7009
+ function createChoiceUsages(choices, margin, indentation) {
7010
+ const activeChoices = choices.filter((choice) => !choice.deprecated);
7011
+ const threshold = Math.max(0, ...activeChoices.map((choice) => choice.value.length)) + margin;
7012
+ return activeChoices.map((choice) => indent(createOptionUsageRow(choice.value, choice.description, threshold), indentation));
7013
+ }
7014
+ function createOptionUsage(context, option, threshold) {
7015
+ const header = createOptionUsageHeader(option);
7016
+ const optionDefaultValue = getOptionDefaultValue(context, option.name);
7017
+ return createOptionUsageRow(header, `${option.description}${optionDefaultValue === void 0 ? "" : `
7018
+ Defaults to ${createDefaultValueDisplay(optionDefaultValue)}.`}`, threshold);
7019
+ }
7020
+ function getOptionsWithOpposites(options) {
7021
+ const optionsWithOpposites = options.map((option) => [option.description ? option : null, option.oppositeDescription ? {
7022
+ ...option,
7023
+ name: `no-${option.name}`,
7024
+ type: "boolean",
7025
+ description: option.oppositeDescription
7026
+ } : null]);
7027
+ return optionsWithOpposites.flat().filter(Boolean);
7028
+ }
7029
+ function createUsage(context) {
7030
+ const sortedOptions = context.detailedOptions.sort((optionA, optionB) => optionA.name.localeCompare(optionB.name));
7031
+ const options = getOptionsWithOpposites(sortedOptions).filter(
7032
+ // remove unnecessary option (e.g. `semi`, `color`, etc.), which is only used for --help <flag>
7033
+ (option) => !(option.type === "boolean" && option.oppositeDescription && !option.name.startsWith("no-"))
7034
+ );
7035
+ const groupedOptions = groupBy(options, (option) => option.category);
7036
+ const firstCategories = categoryOrder.slice(0, -1);
7037
+ const lastCategories = categoryOrder.slice(-1);
7038
+ const restCategories = Object.keys(groupedOptions).filter((category) => !categoryOrder.includes(category));
7039
+ const allCategories = [...firstCategories, ...restCategories, ...lastCategories];
7040
+ const optionsUsage = allCategories.map((category) => {
7041
+ const categoryOptions = groupedOptions[category].map((option) => createOptionUsage(context, option, OPTION_USAGE_THRESHOLD)).join("\n");
7042
+ return `${category} options:
7043
+
7044
+ ${indent(categoryOptions, 2)}`;
7045
+ });
7046
+ return [usageSummary, ...optionsUsage, ""].join("\n\n");
7047
+ }
7048
+ function createPluginDefaults(pluginDefaults) {
7049
+ if (!pluginDefaults || Object.keys(pluginDefaults).length === 0) {
7050
+ return "";
7051
+ }
7052
+ const defaults = Object.entries(pluginDefaults).sort(([pluginNameA], [pluginNameB]) => pluginNameA.localeCompare(pluginNameB)).map(([plugin, value]) => `* ${plugin}: ${createDefaultValueDisplay(value)}`).join("\n");
7053
+ return `
7054
+ Plugin defaults:
7055
+ ${defaults}`;
7056
+ }
7057
+ function createDetailedUsage(context, flag) {
7058
+ const option = getOptionsWithOpposites(context.detailedOptions).find((option2) => option2.name === flag || option2.alias === flag);
7059
+ const header = createOptionUsageHeader(option);
7060
+ const description = `
7061
+
7062
+ ${indent(option.description, 2)}`;
7063
+ const choices = option.type !== "choice" ? "" : `
7064
+
7065
+ Valid options:
7066
+
7067
+ ${createChoiceUsages(option.choices, CHOICE_USAGE_MARGIN, CHOICE_USAGE_INDENTATION).join("\n")}`;
7068
+ const optionDefaultValue = getOptionDefaultValue(context, option.name);
7069
+ const defaults = optionDefaultValue !== void 0 ? `
7070
+
7071
+ Default: ${createDefaultValueDisplay(optionDefaultValue)}` : "";
7072
+ const pluginDefaults = createPluginDefaults(option.pluginDefaults);
7073
+ return `${header}${description}${choices}${defaults}${pluginDefaults}`;
7074
+ }
7075
+
7076
7076
  // src/cli/index.js
7077
7077
  async function run(rawArguments = process.argv.slice(2)) {
7078
7078
  let logger = logger_default();