json-sort-cli 2.0.5 → 2.0.11
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/LICENSE +1 -1
- package/README.md +2 -4
- package/cli.js +5 -5
- package/package.json +22 -47
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2010-
|
|
3
|
+
Copyright (c) 2010-2022 Roy Revelt and other contributors
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
6
|
a copy of this software and associated documentation files (the
|
package/README.md
CHANGED
|
@@ -26,8 +26,6 @@
|
|
|
26
26
|
|
|
27
27
|
## Install
|
|
28
28
|
|
|
29
|
-
This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required:
|
|
30
|
-
|
|
31
29
|
```bash
|
|
32
30
|
npm i -g json-sort-cli
|
|
33
31
|
```
|
|
@@ -41,7 +39,7 @@ sortjson
|
|
|
41
39
|
|
|
42
40
|
## Documentation
|
|
43
41
|
|
|
44
|
-
Please [visit codsen.com](https://codsen.com/os/json-sort-cli/) for a full description of the API
|
|
42
|
+
Please [visit codsen.com](https://codsen.com/os/json-sort-cli/) for a full description of the API.
|
|
45
43
|
|
|
46
44
|
## Contributing
|
|
47
45
|
|
|
@@ -51,6 +49,6 @@ To report bugs or request features or assistance, [raise an issue](https://githu
|
|
|
51
49
|
|
|
52
50
|
MIT License
|
|
53
51
|
|
|
54
|
-
Copyright (c) 2010-
|
|
52
|
+
Copyright (c) 2010-2022 Roy Revelt and other contributors
|
|
55
53
|
|
|
56
54
|
<img src="https://codsen.com/images/png-codsen-ok.png" width="98" alt="ok" align="center"> <img src="https://codsen.com/images/png-codsen-1.png" width="148" alt="codsen" align="center"> <img src="https://codsen.com/images/png-codsen-star-small.png" width="32" alt="star" align="center">
|
package/cli.js
CHANGED
|
@@ -25,14 +25,14 @@ function format(obj) {
|
|
|
25
25
|
if (typeof obj !== "object") {
|
|
26
26
|
return obj;
|
|
27
27
|
}
|
|
28
|
-
|
|
28
|
+
let sortOrder = sortPackageJson.sortOrder
|
|
29
29
|
// 1. delete tap and lect fields
|
|
30
30
|
.filter((field) => !["lect", "tap"].includes(field));
|
|
31
31
|
|
|
32
32
|
// 2. then, insert both after resolutions, first tap then lect
|
|
33
33
|
// console.log(sortOrder);
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
let idxOfResolutions = sortOrder.indexOf("resolutions");
|
|
36
36
|
// console.log(idxOfResolutions);
|
|
37
37
|
// => 63
|
|
38
38
|
|
|
@@ -202,9 +202,9 @@ function readSortAndWriteOverFile(oneOfPaths) {
|
|
|
202
202
|
// In this function, readSortAndWriteOverFile(), path came in,
|
|
203
203
|
// we read it, now we return true if result differs after processing
|
|
204
204
|
|
|
205
|
-
|
|
205
|
+
let stringified = JSON.stringify(
|
|
206
206
|
traverse(obj, (key, val) => {
|
|
207
|
-
|
|
207
|
+
let current = val !== undefined ? val : key;
|
|
208
208
|
if (isObj(current)) {
|
|
209
209
|
return sortObject(current);
|
|
210
210
|
}
|
|
@@ -229,7 +229,7 @@ function readSortAndWriteOverFile(oneOfPaths) {
|
|
|
229
229
|
.writeJson(
|
|
230
230
|
oneOfPaths,
|
|
231
231
|
traverse(obj, (key, val) => {
|
|
232
|
-
|
|
232
|
+
let current = val !== undefined ? val : key;
|
|
233
233
|
if (isObj(current)) {
|
|
234
234
|
return sortObject(current);
|
|
235
235
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "json-sort-cli",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.11",
|
|
4
4
|
"description": "Command line app to deep sort JSON files, retains package.json special key order",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"app",
|
|
@@ -32,73 +32,48 @@
|
|
|
32
32
|
"sortjson": "cli.js"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"tap": "tap",
|
|
45
|
-
"test": "npm run lint && npm run unittest && npm run format",
|
|
46
|
-
"unittest": "tap --no-only --output-file=testStats.md --reporter=terse && npm run clean_cov"
|
|
35
|
+
"build": "echo 'no build needed'",
|
|
36
|
+
"dev": "echo 'no build needed'",
|
|
37
|
+
"lect": "node '../../ops/lect/lect.js'",
|
|
38
|
+
"letspublish": "yarn publish || :",
|
|
39
|
+
"lint": "eslint . --fix",
|
|
40
|
+
"prepare": "echo 'ready'",
|
|
41
|
+
"prettier:format": "prettier --write '**/*.{js,md}' --no-error-on-unmatched-pattern",
|
|
42
|
+
"test": "c8 yarn run unit && yarn run lint",
|
|
43
|
+
"unit": "uvu test"
|
|
47
44
|
},
|
|
48
|
-
"
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
|
47
|
+
},
|
|
48
|
+
"c8": {
|
|
49
49
|
"check-coverage": false,
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
|
|
53
|
-
],
|
|
54
|
-
"node-arg": [
|
|
55
|
-
"--no-warnings",
|
|
56
|
-
"--experimental-loader",
|
|
57
|
-
"@istanbuljs/esm-loader-hook"
|
|
58
|
-
],
|
|
59
|
-
"timeout": 0
|
|
50
|
+
"exclude": [
|
|
51
|
+
"**/test/**/*.*"
|
|
52
|
+
]
|
|
60
53
|
},
|
|
61
54
|
"lect": {
|
|
62
55
|
"licence": {
|
|
63
56
|
"extras": [
|
|
64
57
|
""
|
|
65
58
|
]
|
|
66
|
-
},
|
|
67
|
-
"various": {
|
|
68
|
-
"devDependencies": [
|
|
69
|
-
"@types/lodash.isplainobject",
|
|
70
|
-
"p-map"
|
|
71
|
-
]
|
|
72
59
|
}
|
|
73
60
|
},
|
|
74
61
|
"dependencies": {
|
|
75
|
-
"ast-monkey-traverse": "^3.0.
|
|
76
|
-
"chalk": "^
|
|
62
|
+
"ast-monkey-traverse": "^3.0.11",
|
|
63
|
+
"chalk": "^5.0.0",
|
|
77
64
|
"fs-extra": "^10.0.0",
|
|
78
65
|
"globby": "^12.0.2",
|
|
79
66
|
"is-d": "^1.0.0",
|
|
80
67
|
"lodash.isplainobject": "^4.0.6",
|
|
81
|
-
"meow": "^10.1.
|
|
68
|
+
"meow": "^10.1.2",
|
|
82
69
|
"p-filter": "^3.0.0",
|
|
83
70
|
"p-reduce": "^3.0.0",
|
|
84
|
-
"sort-package-json": "^1.
|
|
71
|
+
"sort-package-json": "^1.53.1",
|
|
85
72
|
"sorted-object": "^2.0.1",
|
|
86
73
|
"update-notifier": "^5.1.0"
|
|
87
74
|
},
|
|
88
75
|
"devDependencies": {
|
|
89
|
-
"@istanbuljs/esm-loader-hook": "^0.1.2",
|
|
90
76
|
"@types/lodash.isplainobject": "^4.0.6",
|
|
91
|
-
"
|
|
92
|
-
"cross-env": "^7.0.3",
|
|
93
|
-
"eslint": "^8.2.0",
|
|
94
|
-
"execa": "^5.1.1",
|
|
95
|
-
"lect": "^0.18.5",
|
|
96
|
-
"p-map": "^5.3.0",
|
|
97
|
-
"tap": "^15.0.10",
|
|
98
|
-
"tempy": "^2.0.0",
|
|
99
|
-
"tslib": "^2.3.1"
|
|
100
|
-
},
|
|
101
|
-
"engines": {
|
|
102
|
-
"node": ">=12"
|
|
77
|
+
"p-map": "^5.3.0"
|
|
103
78
|
}
|
|
104
79
|
}
|