json-sort-cli 3.0.11 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/cli.js +14 -6
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
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.0](https://github.com/codsen/codsen/compare/json-sort-cli@3.0.12...json-sort-cli@3.1.0) (2023-04-16)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- `-l` or `--lineEnding` flag to override the default - the EOL format found in file (or LF) ([1788a77](https://github.com/codsen/codsen/commit/1788a7701629713a1b9ad9b992ad01aa7d456068))
|
|
11
|
+
|
|
6
12
|
## 3.0.7 (2023-01-06)
|
|
7
13
|
|
|
8
14
|
### Bug Fixes
|
package/cli.js
CHANGED
|
@@ -12,7 +12,7 @@ import pReduce from "p-reduce";
|
|
|
12
12
|
import pFilter from "p-filter";
|
|
13
13
|
import { globby } from "globby";
|
|
14
14
|
import { createRequire } from "module";
|
|
15
|
-
import { isPlainObject } from "codsen-utils";
|
|
15
|
+
import { isPlainObject, resolveEolSetting } from "codsen-utils";
|
|
16
16
|
import updateNotifier from "update-notifier";
|
|
17
17
|
import { traverse } from "ast-monkey-traverse";
|
|
18
18
|
import sortPackageJson, { sortOrder } from "sort-package-json";
|
|
@@ -66,7 +66,7 @@ const cli = meow(
|
|
|
66
66
|
Options
|
|
67
67
|
-n, --nodemodules Don't ignore any node_modules folders
|
|
68
68
|
-t, --tabs Use tabs for JSON file indentation
|
|
69
|
-
-i, --indentationCount How many spaces
|
|
69
|
+
-i, --indentationCount How many spaces/tabs to use (default: 2 for spaces or 1 for tabs)
|
|
70
70
|
-s, --silent Does not show the result per-file, only totals in the end
|
|
71
71
|
-h, --help Shows this help
|
|
72
72
|
-v, --version Shows the current version
|
|
@@ -74,6 +74,8 @@ const cli = meow(
|
|
|
74
74
|
-d, --dry Only list all the files about to be processed
|
|
75
75
|
-p, --pack Exclude all package.json files
|
|
76
76
|
-c, --ci Only exits with non-zero code if files COULD BE sorted
|
|
77
|
+
-l, --lineEnding Set to "cr", "crlf" or "lf" to override the default
|
|
78
|
+
(which is either EOL format used in the file, or Mac LF)
|
|
77
79
|
|
|
78
80
|
Example
|
|
79
81
|
Call anywhere using glob patterns. If you put them as string, this library
|
|
@@ -131,6 +133,10 @@ const cli = meow(
|
|
|
131
133
|
type: "number",
|
|
132
134
|
alias: "i",
|
|
133
135
|
},
|
|
136
|
+
lineEnding: {
|
|
137
|
+
type: "string",
|
|
138
|
+
alias: "l",
|
|
139
|
+
},
|
|
134
140
|
},
|
|
135
141
|
}
|
|
136
142
|
);
|
|
@@ -194,6 +200,7 @@ function readSortAndWriteOverFile(oneOfPaths) {
|
|
|
194
200
|
spaces: cli.flags.tabs
|
|
195
201
|
? "\t".repeat(indentationCount)
|
|
196
202
|
: indentationCount,
|
|
203
|
+
EOL: resolveEolSetting(filesContent, cli.flags.lineEnding),
|
|
197
204
|
}
|
|
198
205
|
);
|
|
199
206
|
} else {
|
|
@@ -258,6 +265,7 @@ function readSortAndWriteOverFile(oneOfPaths) {
|
|
|
258
265
|
spaces: cli.flags.tabs
|
|
259
266
|
? "\t".repeat(indentationCount)
|
|
260
267
|
: indentationCount,
|
|
268
|
+
EOL: resolveEolSetting(filesContent, cli.flags.lineEnding),
|
|
261
269
|
}
|
|
262
270
|
)
|
|
263
271
|
.then(() => {
|
|
@@ -265,7 +273,7 @@ function readSortAndWriteOverFile(oneOfPaths) {
|
|
|
265
273
|
log(
|
|
266
274
|
`${chalk.grey(
|
|
267
275
|
prefix
|
|
268
|
-
)}${oneOfPaths} - ${`\u001b[${32}m${
|
|
276
|
+
)}${oneOfPaths} - ${`\u001b[${32}m${"OK"}\u001b[${39}m`}`
|
|
269
277
|
);
|
|
270
278
|
}
|
|
271
279
|
return true;
|
|
@@ -274,7 +282,7 @@ function readSortAndWriteOverFile(oneOfPaths) {
|
|
|
274
282
|
})
|
|
275
283
|
.catch((err) => {
|
|
276
284
|
console.log(
|
|
277
|
-
`${oneOfPaths} - ${`\u001b[${31}m${
|
|
285
|
+
`${oneOfPaths} - ${`\u001b[${31}m${"BAD"}\u001b[${39}m`} - ${err}`
|
|
278
286
|
);
|
|
279
287
|
});
|
|
280
288
|
}
|
|
@@ -318,8 +326,8 @@ globby(input, { dot: true })
|
|
|
318
326
|
.then((paths) =>
|
|
319
327
|
pReduce(
|
|
320
328
|
paths,
|
|
321
|
-
(
|
|
322
|
-
|
|
329
|
+
(concatTotal, singleDirOrFilePath) =>
|
|
330
|
+
concatTotal.concat(
|
|
323
331
|
isDirectory(singleDirOrFilePath).then((bool) =>
|
|
324
332
|
bool
|
|
325
333
|
? globby(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "json-sort-cli",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "Command line app to deep sort JSON files, retains package.json special key order",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"app",
|
|
@@ -67,11 +67,11 @@
|
|
|
67
67
|
}
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"ast-monkey-traverse": "^4.0.
|
|
70
|
+
"ast-monkey-traverse": "^4.0.9",
|
|
71
71
|
"chalk": "^5.2.0",
|
|
72
|
-
"codsen-utils": "^1.
|
|
72
|
+
"codsen-utils": "^1.4.0",
|
|
73
73
|
"fs-extra": "^11.1.1",
|
|
74
|
-
"globby": "^13.1.
|
|
74
|
+
"globby": "^13.1.4",
|
|
75
75
|
"is-d": "^1.0.0",
|
|
76
76
|
"meow": "^11.0.0",
|
|
77
77
|
"p-filter": "^3.0.0",
|