prettier 4.0.2 → 4.0.4
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -1
- data/README.md +12 -1
- data/node_modules/prettier/LICENSE +227 -408
- data/node_modules/prettier/README.md +3 -3
- data/node_modules/prettier/bin/prettier.cjs +3 -2
- data/node_modules/prettier/doc.d.ts +10 -7
- data/node_modules/prettier/doc.js +17 -29
- data/node_modules/prettier/doc.mjs +12 -24
- data/node_modules/prettier/index.cjs +22 -29
- data/node_modules/prettier/index.d.ts +76 -68
- data/node_modules/prettier/index.mjs +16274 -13541
- data/node_modules/prettier/internal/cli.mjs +388 -79
- data/node_modules/prettier/package.json +7 -3
- data/node_modules/prettier/plugins/acorn.js +12 -12
- data/node_modules/prettier/plugins/acorn.mjs +12 -12
- data/node_modules/prettier/plugins/angular.js +1 -2
- data/node_modules/prettier/plugins/angular.mjs +1 -2
- data/node_modules/prettier/plugins/babel.js +11 -11
- data/node_modules/prettier/plugins/babel.mjs +11 -11
- data/node_modules/prettier/plugins/estree.d.ts +1 -0
- data/node_modules/prettier/plugins/estree.js +26 -26
- data/node_modules/prettier/plugins/estree.mjs +26 -26
- data/node_modules/prettier/plugins/flow.js +17 -17
- data/node_modules/prettier/plugins/flow.mjs +17 -17
- data/node_modules/prettier/plugins/glimmer.js +22 -22
- data/node_modules/prettier/plugins/glimmer.mjs +22 -22
- data/node_modules/prettier/plugins/graphql.js +9 -9
- data/node_modules/prettier/plugins/graphql.mjs +9 -9
- data/node_modules/prettier/plugins/html.js +17 -17
- data/node_modules/prettier/plugins/html.mjs +17 -17
- data/node_modules/prettier/plugins/markdown.js +46 -46
- data/node_modules/prettier/plugins/markdown.mjs +46 -46
- data/node_modules/prettier/plugins/meriyah.js +5 -5
- data/node_modules/prettier/plugins/meriyah.mjs +5 -5
- data/node_modules/prettier/plugins/postcss.js +28 -28
- data/node_modules/prettier/plugins/postcss.mjs +28 -28
- data/node_modules/prettier/plugins/typescript.js +20 -22
- data/node_modules/prettier/plugins/typescript.mjs +20 -22
- data/node_modules/prettier/plugins/yaml.js +38 -38
- data/node_modules/prettier/plugins/yaml.mjs +39 -39
- data/node_modules/prettier/standalone.d.ts +2 -2
- data/node_modules/prettier/standalone.js +31 -31
- data/node_modules/prettier/standalone.mjs +31 -31
- data/package.json +4 -4
- data/src/plugin.js +13 -5
- data/src/server.rb +8 -3
- metadata +2 -3
- data/node_modules/prettier/internal/internal.mjs +0 -6531
@@ -1197,6 +1197,260 @@ var require_common_path_prefix = __commonJS({
|
|
1197
1197
|
}
|
1198
1198
|
});
|
1199
1199
|
|
1200
|
+
// node_modules/json-buffer/index.js
|
1201
|
+
var require_json_buffer = __commonJS({
|
1202
|
+
"node_modules/json-buffer/index.js"(exports) {
|
1203
|
+
exports.stringify = function stringify4(o) {
|
1204
|
+
if ("undefined" == typeof o)
|
1205
|
+
return o;
|
1206
|
+
if (o && Buffer.isBuffer(o))
|
1207
|
+
return JSON.stringify(":base64:" + o.toString("base64"));
|
1208
|
+
if (o && o.toJSON)
|
1209
|
+
o = o.toJSON();
|
1210
|
+
if (o && "object" === typeof o) {
|
1211
|
+
var s = "";
|
1212
|
+
var array2 = Array.isArray(o);
|
1213
|
+
s = array2 ? "[" : "{";
|
1214
|
+
var first = true;
|
1215
|
+
for (var k in o) {
|
1216
|
+
var ignore = "function" == typeof o[k] || !array2 && "undefined" === typeof o[k];
|
1217
|
+
if (Object.hasOwnProperty.call(o, k) && !ignore) {
|
1218
|
+
if (!first)
|
1219
|
+
s += ",";
|
1220
|
+
first = false;
|
1221
|
+
if (array2) {
|
1222
|
+
if (o[k] == void 0)
|
1223
|
+
s += "null";
|
1224
|
+
else
|
1225
|
+
s += stringify4(o[k]);
|
1226
|
+
} else if (o[k] !== void 0) {
|
1227
|
+
s += stringify4(k) + ":" + stringify4(o[k]);
|
1228
|
+
}
|
1229
|
+
}
|
1230
|
+
}
|
1231
|
+
s += array2 ? "]" : "}";
|
1232
|
+
return s;
|
1233
|
+
} else if ("string" === typeof o) {
|
1234
|
+
return JSON.stringify(/^:/.test(o) ? ":" + o : o);
|
1235
|
+
} else if ("undefined" === typeof o) {
|
1236
|
+
return "null";
|
1237
|
+
} else
|
1238
|
+
return JSON.stringify(o);
|
1239
|
+
};
|
1240
|
+
exports.parse = function(s) {
|
1241
|
+
return JSON.parse(s, function(key, value) {
|
1242
|
+
if ("string" === typeof value) {
|
1243
|
+
if (/^:base64:/.test(value))
|
1244
|
+
return Buffer.from(value.substring(8), "base64");
|
1245
|
+
else
|
1246
|
+
return /^:/.test(value) ? value.substring(1) : value;
|
1247
|
+
}
|
1248
|
+
return value;
|
1249
|
+
});
|
1250
|
+
};
|
1251
|
+
}
|
1252
|
+
});
|
1253
|
+
|
1254
|
+
// node_modules/keyv/src/index.js
|
1255
|
+
var require_src = __commonJS({
|
1256
|
+
"node_modules/keyv/src/index.js"(exports, module) {
|
1257
|
+
"use strict";
|
1258
|
+
var EventEmitter = __require("events");
|
1259
|
+
var JSONB = require_json_buffer();
|
1260
|
+
var loadStore = (options) => {
|
1261
|
+
const adapters = {
|
1262
|
+
redis: "@keyv/redis",
|
1263
|
+
rediss: "@keyv/redis",
|
1264
|
+
mongodb: "@keyv/mongo",
|
1265
|
+
mongo: "@keyv/mongo",
|
1266
|
+
sqlite: "@keyv/sqlite",
|
1267
|
+
postgresql: "@keyv/postgres",
|
1268
|
+
postgres: "@keyv/postgres",
|
1269
|
+
mysql: "@keyv/mysql",
|
1270
|
+
etcd: "@keyv/etcd",
|
1271
|
+
offline: "@keyv/offline",
|
1272
|
+
tiered: "@keyv/tiered"
|
1273
|
+
};
|
1274
|
+
if (options.adapter || options.uri) {
|
1275
|
+
const adapter = options.adapter || /^[^:+]*/.exec(options.uri)[0];
|
1276
|
+
return new (__require(adapters[adapter]))(options);
|
1277
|
+
}
|
1278
|
+
return /* @__PURE__ */ new Map();
|
1279
|
+
};
|
1280
|
+
var iterableAdapters = [
|
1281
|
+
"sqlite",
|
1282
|
+
"postgres",
|
1283
|
+
"mysql",
|
1284
|
+
"mongo",
|
1285
|
+
"redis",
|
1286
|
+
"tiered"
|
1287
|
+
];
|
1288
|
+
var Keyv = class extends EventEmitter {
|
1289
|
+
constructor(uri, { emitErrors = true, ...options } = {}) {
|
1290
|
+
super();
|
1291
|
+
this.opts = {
|
1292
|
+
namespace: "keyv",
|
1293
|
+
serialize: JSONB.stringify,
|
1294
|
+
deserialize: JSONB.parse,
|
1295
|
+
...typeof uri === "string" ? { uri } : uri,
|
1296
|
+
...options
|
1297
|
+
};
|
1298
|
+
if (!this.opts.store) {
|
1299
|
+
const adapterOptions = { ...this.opts };
|
1300
|
+
this.opts.store = loadStore(adapterOptions);
|
1301
|
+
}
|
1302
|
+
if (this.opts.compression) {
|
1303
|
+
const compression = this.opts.compression;
|
1304
|
+
this.opts.serialize = compression.serialize.bind(compression);
|
1305
|
+
this.opts.deserialize = compression.deserialize.bind(compression);
|
1306
|
+
}
|
1307
|
+
if (typeof this.opts.store.on === "function" && emitErrors) {
|
1308
|
+
this.opts.store.on("error", (error) => this.emit("error", error));
|
1309
|
+
}
|
1310
|
+
this.opts.store.namespace = this.opts.namespace;
|
1311
|
+
const generateIterator = (iterator) => async function* () {
|
1312
|
+
for await (const [key, raw] of typeof iterator === "function" ? iterator(this.opts.store.namespace) : iterator) {
|
1313
|
+
const data = await this.opts.deserialize(raw);
|
1314
|
+
if (this.opts.store.namespace && !key.includes(this.opts.store.namespace)) {
|
1315
|
+
continue;
|
1316
|
+
}
|
1317
|
+
if (typeof data.expires === "number" && Date.now() > data.expires) {
|
1318
|
+
this.delete(key);
|
1319
|
+
continue;
|
1320
|
+
}
|
1321
|
+
yield [this._getKeyUnprefix(key), data.value];
|
1322
|
+
}
|
1323
|
+
};
|
1324
|
+
if (typeof this.opts.store[Symbol.iterator] === "function" && this.opts.store instanceof Map) {
|
1325
|
+
this.iterator = generateIterator(this.opts.store);
|
1326
|
+
} else if (typeof this.opts.store.iterator === "function" && this.opts.store.opts && this._checkIterableAdaptar()) {
|
1327
|
+
this.iterator = generateIterator(this.opts.store.iterator.bind(this.opts.store));
|
1328
|
+
}
|
1329
|
+
}
|
1330
|
+
_checkIterableAdaptar() {
|
1331
|
+
return iterableAdapters.includes(this.opts.store.opts.dialect) || iterableAdapters.findIndex((element) => this.opts.store.opts.url.includes(element)) >= 0;
|
1332
|
+
}
|
1333
|
+
_getKeyPrefix(key) {
|
1334
|
+
return `${this.opts.namespace}:${key}`;
|
1335
|
+
}
|
1336
|
+
_getKeyPrefixArray(keys) {
|
1337
|
+
return keys.map((key) => `${this.opts.namespace}:${key}`);
|
1338
|
+
}
|
1339
|
+
_getKeyUnprefix(key) {
|
1340
|
+
return key.split(":").splice(1).join(":");
|
1341
|
+
}
|
1342
|
+
get(key, options) {
|
1343
|
+
const { store } = this.opts;
|
1344
|
+
const isArray = Array.isArray(key);
|
1345
|
+
const keyPrefixed = isArray ? this._getKeyPrefixArray(key) : this._getKeyPrefix(key);
|
1346
|
+
if (isArray && store.getMany === void 0) {
|
1347
|
+
const promises = [];
|
1348
|
+
for (const key2 of keyPrefixed) {
|
1349
|
+
promises.push(
|
1350
|
+
Promise.resolve().then(() => store.get(key2)).then((data) => typeof data === "string" ? this.opts.deserialize(data) : this.opts.compression ? this.opts.deserialize(data) : data).then((data) => {
|
1351
|
+
if (data === void 0 || data === null) {
|
1352
|
+
return void 0;
|
1353
|
+
}
|
1354
|
+
if (typeof data.expires === "number" && Date.now() > data.expires) {
|
1355
|
+
return this.delete(key2).then(() => void 0);
|
1356
|
+
}
|
1357
|
+
return options && options.raw ? data : data.value;
|
1358
|
+
})
|
1359
|
+
);
|
1360
|
+
}
|
1361
|
+
return Promise.allSettled(promises).then((values) => {
|
1362
|
+
const data = [];
|
1363
|
+
for (const value of values) {
|
1364
|
+
data.push(value.value);
|
1365
|
+
}
|
1366
|
+
return data;
|
1367
|
+
});
|
1368
|
+
}
|
1369
|
+
return Promise.resolve().then(() => isArray ? store.getMany(keyPrefixed) : store.get(keyPrefixed)).then((data) => typeof data === "string" ? this.opts.deserialize(data) : this.opts.compression ? this.opts.deserialize(data) : data).then((data) => {
|
1370
|
+
if (data === void 0 || data === null) {
|
1371
|
+
return void 0;
|
1372
|
+
}
|
1373
|
+
if (isArray) {
|
1374
|
+
return data.map((row, index) => {
|
1375
|
+
if (typeof row === "string") {
|
1376
|
+
row = this.opts.deserialize(row);
|
1377
|
+
}
|
1378
|
+
if (row === void 0 || row === null) {
|
1379
|
+
return void 0;
|
1380
|
+
}
|
1381
|
+
if (typeof row.expires === "number" && Date.now() > row.expires) {
|
1382
|
+
this.delete(key[index]).then(() => void 0);
|
1383
|
+
return void 0;
|
1384
|
+
}
|
1385
|
+
return options && options.raw ? row : row.value;
|
1386
|
+
});
|
1387
|
+
}
|
1388
|
+
if (typeof data.expires === "number" && Date.now() > data.expires) {
|
1389
|
+
return this.delete(key).then(() => void 0);
|
1390
|
+
}
|
1391
|
+
return options && options.raw ? data : data.value;
|
1392
|
+
});
|
1393
|
+
}
|
1394
|
+
set(key, value, ttl) {
|
1395
|
+
const keyPrefixed = this._getKeyPrefix(key);
|
1396
|
+
if (typeof ttl === "undefined") {
|
1397
|
+
ttl = this.opts.ttl;
|
1398
|
+
}
|
1399
|
+
if (ttl === 0) {
|
1400
|
+
ttl = void 0;
|
1401
|
+
}
|
1402
|
+
const { store } = this.opts;
|
1403
|
+
return Promise.resolve().then(() => {
|
1404
|
+
const expires = typeof ttl === "number" ? Date.now() + ttl : null;
|
1405
|
+
if (typeof value === "symbol") {
|
1406
|
+
this.emit("error", "symbol cannot be serialized");
|
1407
|
+
}
|
1408
|
+
value = { value, expires };
|
1409
|
+
return this.opts.serialize(value);
|
1410
|
+
}).then((value2) => store.set(keyPrefixed, value2, ttl)).then(() => true);
|
1411
|
+
}
|
1412
|
+
delete(key) {
|
1413
|
+
const { store } = this.opts;
|
1414
|
+
if (Array.isArray(key)) {
|
1415
|
+
const keyPrefixed2 = this._getKeyPrefixArray(key);
|
1416
|
+
if (store.deleteMany === void 0) {
|
1417
|
+
const promises = [];
|
1418
|
+
for (const key2 of keyPrefixed2) {
|
1419
|
+
promises.push(store.delete(key2));
|
1420
|
+
}
|
1421
|
+
return Promise.allSettled(promises).then((values) => values.every((x) => x.value === true));
|
1422
|
+
}
|
1423
|
+
return Promise.resolve().then(() => store.deleteMany(keyPrefixed2));
|
1424
|
+
}
|
1425
|
+
const keyPrefixed = this._getKeyPrefix(key);
|
1426
|
+
return Promise.resolve().then(() => store.delete(keyPrefixed));
|
1427
|
+
}
|
1428
|
+
clear() {
|
1429
|
+
const { store } = this.opts;
|
1430
|
+
return Promise.resolve().then(() => store.clear());
|
1431
|
+
}
|
1432
|
+
has(key) {
|
1433
|
+
const keyPrefixed = this._getKeyPrefix(key);
|
1434
|
+
const { store } = this.opts;
|
1435
|
+
return Promise.resolve().then(async () => {
|
1436
|
+
if (typeof store.has === "function") {
|
1437
|
+
return store.has(keyPrefixed);
|
1438
|
+
}
|
1439
|
+
const value = await store.get(keyPrefixed);
|
1440
|
+
return value !== void 0;
|
1441
|
+
});
|
1442
|
+
}
|
1443
|
+
disconnect() {
|
1444
|
+
const { store } = this.opts;
|
1445
|
+
if (typeof store.disconnect === "function") {
|
1446
|
+
return store.disconnect();
|
1447
|
+
}
|
1448
|
+
}
|
1449
|
+
};
|
1450
|
+
module.exports = Keyv;
|
1451
|
+
}
|
1452
|
+
});
|
1453
|
+
|
1200
1454
|
// node_modules/flatted/cjs/index.js
|
1201
1455
|
var require_cjs = __commonJS({
|
1202
1456
|
"node_modules/flatted/cjs/index.js"(exports) {
|
@@ -4008,6 +4262,7 @@ var require_cache = __commonJS({
|
|
4008
4262
|
"node_modules/flat-cache/src/cache.js"(exports, module) {
|
4009
4263
|
var path10 = __require("path");
|
4010
4264
|
var fs6 = __require("fs");
|
4265
|
+
var Keyv = require_src();
|
4011
4266
|
var utils = require_utils();
|
4012
4267
|
var del = require_del();
|
4013
4268
|
var writeJSON = utils.writeJSON;
|
@@ -4023,13 +4278,28 @@ var require_cache = __commonJS({
|
|
4023
4278
|
*/
|
4024
4279
|
load: function(docId, cacheDir) {
|
4025
4280
|
var me = this;
|
4026
|
-
me.
|
4027
|
-
me.
|
4281
|
+
me.keyv = new Keyv();
|
4282
|
+
me.__visited = {};
|
4283
|
+
me.__persisted = {};
|
4028
4284
|
me._pathToFile = cacheDir ? path10.resolve(cacheDir, docId) : path10.resolve(__dirname, "../.cache/", docId);
|
4029
4285
|
if (fs6.existsSync(me._pathToFile)) {
|
4030
4286
|
me._persisted = utils.tryParse(me._pathToFile, {});
|
4031
4287
|
}
|
4032
4288
|
},
|
4289
|
+
get _persisted() {
|
4290
|
+
return this.__persisted;
|
4291
|
+
},
|
4292
|
+
set _persisted(value) {
|
4293
|
+
this.__persisted = value;
|
4294
|
+
this.keyv.set("persisted", value);
|
4295
|
+
},
|
4296
|
+
get _visited() {
|
4297
|
+
return this.__visited;
|
4298
|
+
},
|
4299
|
+
set _visited(value) {
|
4300
|
+
this.__visited = value;
|
4301
|
+
this.keyv.set("visited", value);
|
4302
|
+
},
|
4033
4303
|
/**
|
4034
4304
|
* Load the cache from the provided file
|
4035
4305
|
* @method loadFile
|
@@ -4777,7 +5047,7 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
4777
5047
|
return 1;
|
4778
5048
|
}
|
4779
5049
|
if ("CI" in env) {
|
4780
|
-
if ("GITHUB_ACTIONS" in env) {
|
5050
|
+
if ("GITHUB_ACTIONS" in env || "GITEA_ACTIONS" in env) {
|
4781
5051
|
return 3;
|
4782
5052
|
}
|
4783
5053
|
if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
|
@@ -5006,7 +5276,7 @@ var chalk = createChalk();
|
|
5006
5276
|
var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
|
5007
5277
|
var source_default = chalk;
|
5008
5278
|
|
5009
|
-
// node_modules/
|
5279
|
+
// node_modules/ansi-regex/index.js
|
5010
5280
|
function ansiRegex({ onlyFirst = false } = {}) {
|
5011
5281
|
const pattern = [
|
5012
5282
|
"[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
|
@@ -5134,7 +5404,8 @@ var {
|
|
5134
5404
|
getSupportInfoWithoutPlugins,
|
5135
5405
|
normalizeOptionSettings,
|
5136
5406
|
vnopts,
|
5137
|
-
fastGlob
|
5407
|
+
fastGlob,
|
5408
|
+
mockable
|
5138
5409
|
} = sharedWithCli;
|
5139
5410
|
|
5140
5411
|
// src/cli/cli-options.evaluate.js
|
@@ -5404,12 +5675,30 @@ var preserveCamelCase = (string, toLowerCase, toUpperCase, preserveConsecutiveUp
|
|
5404
5675
|
};
|
5405
5676
|
var preserveConsecutiveUppercase = (input, toLowerCase) => {
|
5406
5677
|
LEADING_CAPITAL.lastIndex = 0;
|
5407
|
-
return
|
5678
|
+
return string_replace_all_default(
|
5679
|
+
/* isOptionalObject*/
|
5680
|
+
false,
|
5681
|
+
input,
|
5682
|
+
LEADING_CAPITAL,
|
5683
|
+
(match) => toLowerCase(match)
|
5684
|
+
);
|
5408
5685
|
};
|
5409
5686
|
var postProcess = (input, toUpperCase) => {
|
5410
5687
|
SEPARATORS_AND_IDENTIFIER.lastIndex = 0;
|
5411
5688
|
NUMBERS_AND_IDENTIFIER.lastIndex = 0;
|
5412
|
-
return
|
5689
|
+
return string_replace_all_default(
|
5690
|
+
/* isOptionalObject*/
|
5691
|
+
false,
|
5692
|
+
string_replace_all_default(
|
5693
|
+
/* isOptionalObject*/
|
5694
|
+
false,
|
5695
|
+
input,
|
5696
|
+
NUMBERS_AND_IDENTIFIER,
|
5697
|
+
(match, pattern, offset) => ["_", "-"].includes(input.charAt(offset + match.length)) ? match : toUpperCase(match)
|
5698
|
+
),
|
5699
|
+
SEPARATORS_AND_IDENTIFIER,
|
5700
|
+
(_, identifier) => toUpperCase(identifier)
|
5701
|
+
);
|
5413
5702
|
};
|
5414
5703
|
function camelCase(input, options) {
|
5415
5704
|
if (!(typeof input === "string" || Array.isArray(input))) {
|
@@ -5905,25 +6194,33 @@ import fs5 from "fs/promises";
|
|
5905
6194
|
import path8 from "path";
|
5906
6195
|
var import_diff = __toESM(require_create(), 1);
|
5907
6196
|
import * as prettier from "../index.mjs";
|
5908
|
-
import mockable2 from "./internal.mjs";
|
5909
6197
|
|
5910
6198
|
// src/cli/expand-patterns.js
|
5911
6199
|
import path2 from "path";
|
5912
6200
|
async function* expandPatterns(context) {
|
5913
6201
|
const seen = /* @__PURE__ */ new Set();
|
5914
6202
|
let noResults = true;
|
5915
|
-
for await (const
|
6203
|
+
for await (const {
|
6204
|
+
filePath,
|
6205
|
+
ignoreUnknown,
|
6206
|
+
error
|
6207
|
+
} of expandPatternsInternal(context)) {
|
5916
6208
|
noResults = false;
|
5917
|
-
if (
|
5918
|
-
yield
|
6209
|
+
if (error) {
|
6210
|
+
yield {
|
6211
|
+
error
|
6212
|
+
};
|
5919
6213
|
continue;
|
5920
6214
|
}
|
5921
|
-
const
|
5922
|
-
if (seen.has(
|
6215
|
+
const filename = path2.resolve(filePath);
|
6216
|
+
if (seen.has(filename)) {
|
5923
6217
|
continue;
|
5924
6218
|
}
|
5925
|
-
seen.add(
|
5926
|
-
yield
|
6219
|
+
seen.add(filename);
|
6220
|
+
yield {
|
6221
|
+
filename,
|
6222
|
+
ignoreUnknown
|
6223
|
+
};
|
5927
6224
|
}
|
5928
6225
|
if (noResults && context.argv.errorOnUnmatchedPattern !== false) {
|
5929
6226
|
yield {
|
@@ -5941,7 +6238,6 @@ async function* expandPatternsInternal(context) {
|
|
5941
6238
|
ignore: silentlyIgnoredDirs.map((dir) => "**/" + dir),
|
5942
6239
|
followSymbolicLinks: false
|
5943
6240
|
};
|
5944
|
-
let supportedFilesGlob;
|
5945
6241
|
const cwd2 = process.cwd();
|
5946
6242
|
const entries = [];
|
5947
6243
|
for (const pattern of context.filePatterns) {
|
@@ -5952,9 +6248,13 @@ async function* expandPatternsInternal(context) {
|
|
5952
6248
|
const stat = await lstatSafe(absolutePath);
|
5953
6249
|
if (stat) {
|
5954
6250
|
if (stat.isSymbolicLink()) {
|
5955
|
-
|
5956
|
-
|
5957
|
-
|
6251
|
+
if (context.argv.errorOnUnmatchedPattern !== false) {
|
6252
|
+
yield {
|
6253
|
+
error: `Explicitly specified pattern "${pattern}" is a symbolic link.`
|
6254
|
+
};
|
6255
|
+
} else {
|
6256
|
+
context.logger.debug(`Skipping pattern "${pattern}", as it is a symbolic link.`);
|
6257
|
+
}
|
5958
6258
|
} else if (stat.isFile()) {
|
5959
6259
|
entries.push({
|
5960
6260
|
type: "file",
|
@@ -5963,10 +6263,12 @@ async function* expandPatternsInternal(context) {
|
|
5963
6263
|
});
|
5964
6264
|
} else if (stat.isDirectory()) {
|
5965
6265
|
const relativePath = path2.relative(cwd2, absolutePath) || ".";
|
6266
|
+
const prefix = escapePathForGlob(fixWindowsSlashes(relativePath));
|
5966
6267
|
entries.push({
|
5967
6268
|
type: "dir",
|
5968
|
-
glob:
|
5969
|
-
input: pattern
|
6269
|
+
glob: `${prefix}/**/*`,
|
6270
|
+
input: pattern,
|
6271
|
+
ignoreUnknown: true
|
5970
6272
|
});
|
5971
6273
|
}
|
5972
6274
|
} else if (pattern[0] === "!") {
|
@@ -5982,7 +6284,8 @@ async function* expandPatternsInternal(context) {
|
|
5982
6284
|
for (const {
|
5983
6285
|
type,
|
5984
6286
|
glob,
|
5985
|
-
input
|
6287
|
+
input,
|
6288
|
+
ignoreUnknown
|
5986
6289
|
} of entries) {
|
5987
6290
|
let result;
|
5988
6291
|
try {
|
@@ -6003,17 +6306,12 @@ ${message}`
|
|
6003
6306
|
};
|
6004
6307
|
}
|
6005
6308
|
} else {
|
6006
|
-
yield* sortPaths(result)
|
6309
|
+
yield* sortPaths(result).map((filePath) => ({
|
6310
|
+
filePath,
|
6311
|
+
ignoreUnknown
|
6312
|
+
}));
|
6007
6313
|
}
|
6008
6314
|
}
|
6009
|
-
function getSupportedFilesGlob() {
|
6010
|
-
if (!supportedFilesGlob) {
|
6011
|
-
const extensions = context.languages.flatMap((lang) => lang.extensions || []);
|
6012
|
-
const filenames = context.languages.flatMap((lang) => lang.filenames || []);
|
6013
|
-
supportedFilesGlob = `**/{${[...extensions.map((ext) => "*" + (ext[0] === "." ? ext : "." + ext)), ...filenames]}}`;
|
6014
|
-
}
|
6015
|
-
return supportedFilesGlob;
|
6016
|
-
}
|
6017
6315
|
}
|
6018
6316
|
var errorMessages = {
|
6019
6317
|
globError: {
|
@@ -6120,7 +6418,7 @@ async function getOptionsOrDie(context, filePath) {
|
|
6120
6418
|
return options;
|
6121
6419
|
} catch (error) {
|
6122
6420
|
context.logger.error(
|
6123
|
-
`Invalid configuration for file "${filePath}":
|
6421
|
+
`Invalid configuration${filePath ? ` for file "${filePath}"` : ""}:
|
6124
6422
|
` + error.message
|
6125
6423
|
);
|
6126
6424
|
process.exit(2);
|
@@ -6167,7 +6465,6 @@ async function getOptionsForFile(context, filepath) {
|
|
6167
6465
|
var get_options_for_file_default = getOptionsForFile;
|
6168
6466
|
|
6169
6467
|
// src/cli/is-tty.js
|
6170
|
-
import mockable from "./internal.mjs";
|
6171
6468
|
function isTTY() {
|
6172
6469
|
return process.stdout.isTTY && !mockable.isCI();
|
6173
6470
|
}
|
@@ -6349,9 +6646,6 @@ function useDirectory(directory, options) {
|
|
6349
6646
|
if (options.create) {
|
6350
6647
|
fs3.mkdirSync(directory, { recursive: true });
|
6351
6648
|
}
|
6352
|
-
if (options.thunk) {
|
6353
|
-
return (...arguments_) => path6.join(directory, ...arguments_);
|
6354
|
-
}
|
6355
6649
|
return directory;
|
6356
6650
|
}
|
6357
6651
|
function getNodeModuleDirectory(directory) {
|
@@ -6365,9 +6659,12 @@ function findCacheDirectory(options = {}) {
|
|
6365
6659
|
if (env2.CACHE_DIR && !["true", "false", "1", "0"].includes(env2.CACHE_DIR)) {
|
6366
6660
|
return useDirectory(path6.join(env2.CACHE_DIR, options.name), options);
|
6367
6661
|
}
|
6368
|
-
let { cwd: directory = cwd() } = options;
|
6369
|
-
if (
|
6370
|
-
|
6662
|
+
let { cwd: directory = cwd(), files } = options;
|
6663
|
+
if (files) {
|
6664
|
+
if (!Array.isArray(files)) {
|
6665
|
+
throw new TypeError(`Expected \`files\` option to be an array, got \`${typeof files}\`.`);
|
6666
|
+
}
|
6667
|
+
directory = (0, import_common_path_prefix.default)(files.map((file) => path6.resolve(directory, file)));
|
6371
6668
|
}
|
6372
6669
|
directory = packageDirectorySync({ cwd: directory });
|
6373
6670
|
if (!directory) {
|
@@ -6486,24 +6783,25 @@ _fileEntryCache = new WeakMap();
|
|
6486
6783
|
var format_results_cache_default = FormatResultsCache;
|
6487
6784
|
|
6488
6785
|
// src/cli/format.js
|
6489
|
-
var { getStdin, writeFormattedFile } =
|
6786
|
+
var { getStdin, writeFormattedFile } = mockable;
|
6490
6787
|
function diff(a, b) {
|
6491
6788
|
return (0, import_diff.createTwoFilesPatch)("", "", a, b, "", "", { context: 2 });
|
6492
6789
|
}
|
6493
6790
|
var DebugError = class extends Error {
|
6494
6791
|
name = "DebugError";
|
6495
6792
|
};
|
6496
|
-
function handleError(context, filename, error, printedFilename) {
|
6793
|
+
function handleError(context, filename, error, printedFilename, ignoreUnknown) {
|
6794
|
+
ignoreUnknown || (ignoreUnknown = context.argv.ignoreUnknown);
|
6497
6795
|
const errorIsUndefinedParseError = error instanceof errors.UndefinedParserError;
|
6498
6796
|
if (printedFilename) {
|
6499
|
-
if ((context.argv.write ||
|
6797
|
+
if ((context.argv.write || ignoreUnknown) && errorIsUndefinedParseError) {
|
6500
6798
|
printedFilename.clear();
|
6501
6799
|
} else {
|
6502
6800
|
process.stdout.write("\n");
|
6503
6801
|
}
|
6504
6802
|
}
|
6505
6803
|
if (errorIsUndefinedParseError) {
|
6506
|
-
if (
|
6804
|
+
if (ignoreUnknown) {
|
6507
6805
|
return;
|
6508
6806
|
}
|
6509
6807
|
if (!context.argv.check && !context.argv.listDifferent) {
|
@@ -6646,7 +6944,11 @@ async function format2(context, input, opt) {
|
|
6646
6944
|
ms: averageMs
|
6647
6945
|
};
|
6648
6946
|
context.logger.debug(
|
6649
|
-
`'${performanceTestFlag.name}' measurements for formatWithCursor: ${JSON.stringify(
|
6947
|
+
`'${performanceTestFlag.name}' measurements for formatWithCursor: ${JSON.stringify(
|
6948
|
+
results,
|
6949
|
+
null,
|
6950
|
+
2
|
6951
|
+
)}`
|
6650
6952
|
);
|
6651
6953
|
}
|
6652
6954
|
return prettier.formatWithCursor(input, opt);
|
@@ -6677,7 +6979,7 @@ async function formatStdin(context) {
|
|
6677
6979
|
}
|
6678
6980
|
const options = await get_options_for_file_default(
|
6679
6981
|
context,
|
6680
|
-
filepath ? path8.resolve(
|
6982
|
+
filepath ? path8.resolve(filepath) : void 0
|
6681
6983
|
);
|
6682
6984
|
if (await listDifferent(context, input, options, "(stdin)")) {
|
6683
6985
|
return;
|
@@ -6710,27 +7012,20 @@ async function formatFiles(context) {
|
|
6710
7012
|
cacheFilePath,
|
6711
7013
|
context.argv.cacheStrategy || "content"
|
6712
7014
|
);
|
6713
|
-
} else {
|
6714
|
-
|
6715
|
-
|
6716
|
-
|
6717
|
-
);
|
6718
|
-
process.exit(2);
|
6719
|
-
}
|
6720
|
-
if (!context.argv.cacheLocation) {
|
6721
|
-
const stat = await statSafe(cacheFilePath);
|
6722
|
-
if (stat) {
|
6723
|
-
await fs5.unlink(cacheFilePath);
|
6724
|
-
}
|
7015
|
+
} else if (!context.argv.cacheLocation) {
|
7016
|
+
const stat = await statSafe(cacheFilePath);
|
7017
|
+
if (stat) {
|
7018
|
+
await fs5.unlink(cacheFilePath);
|
6725
7019
|
}
|
6726
7020
|
}
|
6727
|
-
for await (const
|
6728
|
-
|
6729
|
-
|
7021
|
+
for await (const { error, filename, ignoreUnknown } of expandPatterns(
|
7022
|
+
context
|
7023
|
+
)) {
|
7024
|
+
if (error) {
|
7025
|
+
context.logger.error(error);
|
6730
7026
|
process.exitCode = 2;
|
6731
7027
|
continue;
|
6732
7028
|
}
|
6733
|
-
const filename = pathOrError;
|
6734
7029
|
const isFileIgnored = isIgnored(filename);
|
6735
7030
|
if (isFileIgnored && (context.argv.debugCheck || context.argv.write || context.argv.check || context.argv.listDifferent)) {
|
6736
7031
|
continue;
|
@@ -6750,11 +7045,11 @@ async function formatFiles(context) {
|
|
6750
7045
|
let input;
|
6751
7046
|
try {
|
6752
7047
|
input = await fs5.readFile(filename, "utf8");
|
6753
|
-
} catch (
|
7048
|
+
} catch (error2) {
|
6754
7049
|
context.logger.log("");
|
6755
7050
|
context.logger.error(
|
6756
7051
|
`Unable to read file "${fileNameToDisplay}":
|
6757
|
-
${
|
7052
|
+
${error2.message}`
|
6758
7053
|
);
|
6759
7054
|
process.exitCode = 2;
|
6760
7055
|
continue;
|
@@ -6778,8 +7073,14 @@ ${error.message}`
|
|
6778
7073
|
result = await format2(context, input, options);
|
6779
7074
|
}
|
6780
7075
|
output = result.formatted;
|
6781
|
-
} catch (
|
6782
|
-
handleError(
|
7076
|
+
} catch (error2) {
|
7077
|
+
handleError(
|
7078
|
+
context,
|
7079
|
+
fileNameToDisplay,
|
7080
|
+
error2,
|
7081
|
+
printedFilename,
|
7082
|
+
ignoreUnknown
|
7083
|
+
);
|
6783
7084
|
continue;
|
6784
7085
|
}
|
6785
7086
|
const isDifferent = output !== input;
|
@@ -6799,15 +7100,15 @@ ${error.message}`
|
|
6799
7100
|
try {
|
6800
7101
|
await writeFormattedFile(filename, output);
|
6801
7102
|
shouldSetCache = true;
|
6802
|
-
} catch (
|
7103
|
+
} catch (error2) {
|
6803
7104
|
context.logger.error(
|
6804
7105
|
`Unable to write file "${fileNameToDisplay}":
|
6805
|
-
${
|
7106
|
+
${error2.message}`
|
6806
7107
|
);
|
6807
7108
|
process.exitCode = 2;
|
6808
7109
|
}
|
6809
7110
|
} else if (!context.argv.check && !context.argv.listDifferent) {
|
6810
|
-
const message = `${source_default.grey(fileNameToDisplay)} ${Date.now() - start}ms`;
|
7111
|
+
const message = `${source_default.grey(fileNameToDisplay)} ${Date.now() - start}ms (unchanged)`;
|
6811
7112
|
if (isCacheExists) {
|
6812
7113
|
context.logger.log(`${message} (cached)`);
|
6813
7114
|
} else {
|
@@ -6905,7 +7206,7 @@ async function printSupportInfo() {
|
|
6905
7206
|
var print_support_info_default = printSupportInfo;
|
6906
7207
|
|
6907
7208
|
// src/cli/index.js
|
6908
|
-
async function run(rawArguments) {
|
7209
|
+
async function run(rawArguments = process.argv.slice(2)) {
|
6909
7210
|
let logger = logger_default();
|
6910
7211
|
try {
|
6911
7212
|
const { logLevel } = parseArgvWithoutPlugins(
|
@@ -6941,6 +7242,9 @@ async function main(context) {
|
|
6941
7242
|
if (context.argv.fileInfo && context.filePatterns.length > 0) {
|
6942
7243
|
throw new Error("Cannot use --file-info with multiple files");
|
6943
7244
|
}
|
7245
|
+
if (!context.argv.cache && context.argv.cacheStrategy) {
|
7246
|
+
throw new Error("`--cache-strategy` cannot be used without `--cache`.");
|
7247
|
+
}
|
6944
7248
|
if (context.argv.version) {
|
6945
7249
|
printToScreen(prettier2.version);
|
6946
7250
|
return;
|
@@ -6954,24 +7258,29 @@ async function main(context) {
|
|
6954
7258
|
if (context.argv.supportInfo) {
|
6955
7259
|
return print_support_info_default();
|
6956
7260
|
}
|
6957
|
-
const hasFilePatterns = context.filePatterns.length > 0;
|
6958
|
-
const useStdin = !hasFilePatterns && (!process.stdin.isTTY || context.argv.filePath);
|
6959
7261
|
if (context.argv.findConfigPath) {
|
6960
7262
|
await find_config_path_default(context);
|
6961
|
-
|
7263
|
+
return;
|
7264
|
+
}
|
7265
|
+
if (context.argv.fileInfo) {
|
6962
7266
|
await file_info_default(context);
|
6963
|
-
|
7267
|
+
return;
|
7268
|
+
}
|
7269
|
+
const hasFilePatterns = context.filePatterns.length > 0;
|
7270
|
+
const useStdin = !hasFilePatterns && (!process.stdin.isTTY || context.argv.filepath);
|
7271
|
+
if (useStdin) {
|
6964
7272
|
if (context.argv.cache) {
|
6965
|
-
|
6966
|
-
process.exit(2);
|
7273
|
+
throw new Error("`--cache` cannot be used when formatting stdin.");
|
6967
7274
|
}
|
6968
7275
|
await formatStdin(context);
|
6969
|
-
|
7276
|
+
return;
|
7277
|
+
}
|
7278
|
+
if (hasFilePatterns) {
|
6970
7279
|
await formatFiles(context);
|
6971
|
-
|
6972
|
-
process.exitCode = 1;
|
6973
|
-
printToScreen(createUsage(context));
|
7280
|
+
return;
|
6974
7281
|
}
|
7282
|
+
process.exitCode = 1;
|
7283
|
+
printToScreen(createUsage(context));
|
6975
7284
|
}
|
6976
7285
|
export {
|
6977
7286
|
run
|