json-sort-cli 3.1.2 → 3.1.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.
Files changed (3) hide show
  1. package/CHANGELOG.md +2 -2
  2. package/cli.js +39 -39
  3. package/package.json +7 -7
package/CHANGELOG.md CHANGED
@@ -3,13 +3,13 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- ## [3.1.1](https://github.com/codsen/codsen/compare/json-sort-cli@3.1.0...json-sort-cli@3.1.1) (2023-04-18)
6
+ ## 3.1.1 (2023-04-18)
7
7
 
8
8
  ### Bug Fixes
9
9
 
10
10
  - fix `-c` flag to correctly recognise different EOLs as per `-l` ([5af3ba1](https://github.com/codsen/codsen/commit/5af3ba16962c2dd001005780a3843ecf675389f4)), closes [#73](https://github.com/codsen/codsen/issues/73)
11
11
 
12
- # [3.1.0](https://github.com/codsen/codsen/compare/json-sort-cli@3.0.12...json-sort-cli@3.1.0) (2023-04-16)
12
+ ## 3.1.0 (2023-04-16)
13
13
 
14
14
  ### Features
15
15
 
package/cli.js CHANGED
@@ -138,7 +138,7 @@ const cli = meow(
138
138
  shortFlag: "l",
139
139
  },
140
140
  },
141
- }
141
+ },
142
142
  );
143
143
  updateNotifier({ pkg }).notify();
144
144
 
@@ -203,7 +203,7 @@ function readSortAndWriteOverFile(oneOfPaths) {
203
203
  ? "\t".repeat(indentationCount)
204
204
  : indentationCount,
205
205
  EOL: eolChar,
206
- }
206
+ },
207
207
  );
208
208
  } else {
209
209
  result = parsedJson;
@@ -212,7 +212,7 @@ function readSortAndWriteOverFile(oneOfPaths) {
212
212
  return Promise.resolve(
213
213
  !cli.flags.pack && path.basename(oneOfPaths) === "package.json"
214
214
  ? format(result)
215
- : result
215
+ : result,
216
216
  ).then((obj) => {
217
217
  if (cli.flags.ci) {
218
218
  // if it's CI mode, we only gather a list of files that differ from
@@ -240,7 +240,7 @@ function readSortAndWriteOverFile(oneOfPaths) {
240
240
  return current;
241
241
  }),
242
242
  null,
243
- cli.flags.tabs ? "\t".repeat(indentationCount) : indentationCount
243
+ cli.flags.tabs ? "\t".repeat(indentationCount) : indentationCount,
244
244
  );
245
245
 
246
246
  if (eolChar === "\r\n") {
@@ -257,7 +257,7 @@ function readSortAndWriteOverFile(oneOfPaths) {
257
257
  stringified
258
258
  .replaceAll(
259
259
  /\r\n/g,
260
- resolveEolSetting(filesContent, cli.flags.lineEnding)
260
+ resolveEolSetting(filesContent, cli.flags.lineEnding),
261
261
  )
262
262
  .trimEnd() !== filesContent.trimEnd()
263
263
  );
@@ -288,14 +288,14 @@ function readSortAndWriteOverFile(oneOfPaths) {
288
288
  ? "\t".repeat(indentationCount)
289
289
  : indentationCount,
290
290
  EOL: resolveEolSetting(filesContent, cli.flags.lineEnding),
291
- }
291
+ },
292
292
  )
293
293
  .then(() => {
294
294
  if (!cli.flags.silent) {
295
295
  log(
296
296
  `${chalk.grey(
297
- prefix
298
- )}${oneOfPaths} - ${`\u001b[${32}m${"OK"}\u001b[${39}m`}`
297
+ prefix,
298
+ )}${oneOfPaths} - ${`\u001b[${32}m${"OK"}\u001b[${39}m`}`,
299
299
  );
300
300
  }
301
301
  return true;
@@ -304,7 +304,7 @@ function readSortAndWriteOverFile(oneOfPaths) {
304
304
  })
305
305
  .catch((err) => {
306
306
  console.log(
307
- `${oneOfPaths} - ${`\u001b[${31}m${"BAD"}\u001b[${39}m`} - ${err}`
307
+ `${oneOfPaths} - ${`\u001b[${31}m${"BAD"}\u001b[${39}m`} - ${err}`,
308
308
  );
309
309
  });
310
310
  }
@@ -337,8 +337,8 @@ globby(input, { dot: true })
337
337
  if (paths.length === 0 && !cli.flags.silent) {
338
338
  log(
339
339
  `${chalk.grey(prefix)}${chalk.red(
340
- "The inputs don't lead to any json files! Exiting."
341
- )}`
340
+ "The inputs don't lead to any json files! Exiting.",
341
+ )}`,
342
342
  );
343
343
  process.exit(0);
344
344
  }
@@ -360,33 +360,33 @@ globby(input, { dot: true })
360
360
  expandDirectories: {
361
361
  files: [".*", "*.json"],
362
362
  },
363
- }
363
+ },
364
364
  )
365
- : [singleDirOrFilePath]
366
- )
365
+ : [singleDirOrFilePath],
366
+ ),
367
367
  ),
368
- []
368
+ [],
369
369
  // then reduce again, now actually concatenating them all together
370
370
  ).then((received) =>
371
- pReduce(received, (total, single) => total.concat(single), [])
372
- )
371
+ pReduce(received, (total, single) => total.concat(single), []),
372
+ ),
373
373
  )
374
374
  .then((paths) =>
375
375
  paths.filter(
376
376
  (oneOfPaths) =>
377
377
  !oneOfPaths.includes("package-lock.json") &&
378
- !oneOfPaths.includes("yarn.lock")
379
- )
378
+ !oneOfPaths.includes("yarn.lock"),
379
+ ),
380
380
  )
381
381
  .then((paths) =>
382
382
  !cli.flags.nodemodules
383
383
  ? paths.filter((oneOfPaths) => !oneOfPaths.includes("node_modules"))
384
- : paths
384
+ : paths,
385
385
  )
386
386
  .then((paths) =>
387
387
  cli.flags.pack
388
388
  ? paths.filter((oneOfPaths) => !oneOfPaths.includes("package.json"))
389
- : paths
389
+ : paths,
390
390
  )
391
391
  .then((paths) =>
392
392
  paths.filter((singlePath) => {
@@ -395,40 +395,40 @@ globby(input, { dot: true })
395
395
  (typeof path.basename(singlePath) === "string" &&
396
396
  path.basename(singlePath).startsWith(".") &&
397
397
  !nonJsonFormats.some((badExtension) =>
398
- path.extname(singlePath).includes(badExtension)
398
+ path.extname(singlePath).includes(badExtension),
399
399
  ) &&
400
400
  !badFiles.some((badFile) =>
401
- path.basename(singlePath).includes(badFile)
401
+ path.basename(singlePath).includes(badFile),
402
402
  ))
403
403
  );
404
- })
404
+ }),
405
405
  )
406
406
  // eslint-disable-next-line consistent-return
407
407
  .then((paths) => {
408
408
  if (cli.flags.dry && !cli.flags.silent) {
409
409
  log(
410
410
  `${chalk.grey(prefix)}${chalk.yellow(
411
- "We'd try to sort the following files:"
412
- )}\n${paths.join("\n")}`
411
+ "We'd try to sort the following files:",
412
+ )}\n${paths.join("\n")}`,
413
413
  );
414
414
  } else {
415
415
  if (cli.flags.ci) {
416
416
  // CI setting
417
417
  return pFilter(paths, (currentPath) =>
418
- readSortAndWriteOverFile(currentPath)
418
+ readSortAndWriteOverFile(currentPath),
419
419
  ).then((received2) => {
420
420
  if (received2.length && !cli.flags.silent) {
421
421
  log(
422
422
  `${chalk.grey(prefix)}${chalk.red(
423
- "Unsorted files:"
424
- )}\n${received2.join("\n")}`
423
+ "Unsorted files:",
424
+ )}\n${received2.join("\n")}`,
425
425
  );
426
426
  process.exit(9);
427
427
  } else if (!cli.flags.silent) {
428
428
  log(
429
429
  `${chalk.grey(prefix)}${chalk.white(
430
- "All files were already sorted:"
431
- )}\n${paths.join("\n")}`
430
+ "All files were already sorted:",
431
+ )}\n${paths.join("\n")}`,
432
432
  );
433
433
  process.exit(0);
434
434
  }
@@ -448,36 +448,36 @@ globby(input, { dot: true })
448
448
  : {
449
449
  good: counter.good,
450
450
  bad: counter.bad.concat([currentPath]),
451
- }
451
+ },
452
452
  )
453
453
  .catch((err) => {
454
454
  if (!cli.flags.silent) {
455
455
  log(
456
456
  `${chalk.grey(prefix)}${chalk.red(
457
- "Could not write out the sorted file:"
458
- )} ${err}`
457
+ "Could not write out the sorted file:",
458
+ )} ${err}`,
459
459
  );
460
460
  }
461
461
  }),
462
- { good: [], bad: [] }
462
+ { good: [], bad: [] },
463
463
  ).then((counter) => {
464
464
  if (!cli.flags.silent) {
465
465
  log(
466
466
  `\n${chalk.grey(prefix)}${chalk.green(
467
467
  `${counter.bad && counter.bad.length === 0 ? "All " : ""}${
468
468
  counter.good.length
469
- } files sorted`
469
+ } files sorted`,
470
470
  )}${
471
471
  counter.bad && counter.bad.length
472
472
  ? `\n${chalk.grey(prefix)}${chalk.red(
473
473
  `${counter.bad.length} file${
474
474
  counter.bad.length === 1 ? "" : "s"
475
- } could not be sorted`
475
+ } could not be sorted`,
476
476
  )} ${`\u001b[${90}m - ${counter.bad.join(
477
- " - "
477
+ " - ",
478
478
  )}\u001b[${39}m`}`
479
479
  : ""
480
- }`
480
+ }`,
481
481
  );
482
482
  }
483
483
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "json-sort-cli",
3
- "version": "3.1.2",
3
+ "version": "3.1.4",
4
4
  "description": "Command line app to deep sort JSON files, retains package.json special key order",
5
5
  "keywords": [
6
6
  "app",
@@ -45,7 +45,7 @@
45
45
  "perf": "exit 0",
46
46
  "prep": "echo 'ready'",
47
47
  "prettier": "prettier",
48
- "prettier:format": "npm run prettier -- --write '**/*.{js,md}' --no-error-on-unmatched-pattern --loglevel 'silent'",
48
+ "prettier:format": "npm run prettier -- --write '**/*.{js,md}' --no-error-on-unmatched-pattern --log-level 'silent'",
49
49
  "pretest": "exit 0",
50
50
  "test": "c8 npm run unit && npm run lint",
51
51
  "unit": "uvu test"
@@ -67,16 +67,16 @@
67
67
  }
68
68
  },
69
69
  "dependencies": {
70
- "ast-monkey-traverse": "^4.0.10",
71
- "chalk": "^5.2.0",
72
- "codsen-utils": "^1.5.0",
70
+ "ast-monkey-traverse": "^4.0.12",
71
+ "chalk": "^5.3.0",
72
+ "codsen-utils": "^1.6.1",
73
73
  "fs-extra": "^11.1.1",
74
- "globby": "^13.1.4",
74
+ "globby": "^13.2.2",
75
75
  "is-d": "^1.0.0",
76
76
  "meow": "^12.0.1",
77
77
  "p-filter": "^3.0.0",
78
78
  "p-reduce": "^3.0.0",
79
- "sort-package-json": "^2.4.1",
79
+ "sort-package-json": "^2.5.1",
80
80
  "update-notifier": "^6.0.2"
81
81
  },
82
82
  "devDependencies": {