@pob/pretty-pkg 6.3.0 → 7.0.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 +10 -0
- package/bin/pretty-pkg.js +32 -8
- package/lib/index.js +1 -1
- package/package.json +9 -8
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
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
|
+
## [7.0.0](https://github.com/christophehurpeau/pob/compare/@pob/pretty-pkg@6.3.0...@pob/pretty-pkg@7.0.0) (2023-12-29)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **@pob/pretty-pkg:** read workspaces ([11313e7](https://github.com/christophehurpeau/pob/commit/11313e737d701b180b0460e8fcb822436944d9d1))
|
|
12
|
+
|
|
13
|
+
Version bump for dependency: sort-pkg
|
|
14
|
+
|
|
15
|
+
|
|
6
16
|
## [6.3.0](https://github.com/christophehurpeau/pob/compare/@pob/pretty-pkg@6.2.0...@pob/pretty-pkg@6.3.0) (2023-12-10)
|
|
7
17
|
|
|
8
18
|
|
package/bin/pretty-pkg.js
CHANGED
|
@@ -1,13 +1,37 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { glob } from 'glob';
|
|
6
|
+
import { overrideSync, writeSync } from '../lib/index.js';
|
|
4
7
|
|
|
5
|
-
const
|
|
8
|
+
const packageJsonPathnames = process.argv.slice(2);
|
|
6
9
|
|
|
7
|
-
if (
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
if (packageJsonPathnames.length > 0) {
|
|
11
|
+
packageJsonPathnames.forEach((packageJsonPathname) => {
|
|
12
|
+
overrideSync(packageJsonPathname);
|
|
13
|
+
});
|
|
14
|
+
} else {
|
|
15
|
+
const pkg = JSON.parse(fs.readFileSync('package.json'));
|
|
16
|
+
writeSync(pkg, 'package.json');
|
|
17
|
+
|
|
18
|
+
if (pkg.workspaces && pkg.workspaces.length > 0) {
|
|
19
|
+
const patterns = pkg.workspaces;
|
|
20
|
+
|
|
21
|
+
const getGlobPattern = (pattern) =>
|
|
22
|
+
pattern.endsWith('/') ? pattern : `${pattern}/`;
|
|
10
23
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
24
|
+
for (const pattern of patterns) {
|
|
25
|
+
const matches = await glob(getGlobPattern(pattern), {
|
|
26
|
+
ignore: ['**/node_modules/**'],
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
for (const match of matches) {
|
|
30
|
+
const packageJsonPathname = path.join(match, 'package.json');
|
|
31
|
+
if (fs.existsSync(packageJsonPathname)) {
|
|
32
|
+
overrideSync(packageJsonPathname);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
package/lib/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import fs from 'node:fs';
|
|
|
2
2
|
import sortPkg from '@pob/sort-pkg';
|
|
3
3
|
import prettier from 'prettier';
|
|
4
4
|
|
|
5
|
-
export default function prettyPkg(pkg, prettierOptions
|
|
5
|
+
export default function prettyPkg(pkg, prettierOptions) {
|
|
6
6
|
if (typeof pkg === 'string') {
|
|
7
7
|
pkg = JSON.parse(pkg);
|
|
8
8
|
if (typeof pkg !== 'object') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pob/pretty-pkg",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "prettier and sort package.json",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "Christophe Hurpeau <christophe@hurpeau.com> (https://christophe.hurpeau.com)",
|
|
@@ -15,17 +15,17 @@
|
|
|
15
15
|
"engines": {
|
|
16
16
|
"node": ">=18.12.0"
|
|
17
17
|
},
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
},
|
|
18
|
+
"sideEffects": false,
|
|
19
|
+
"bin": "./bin/pretty-pkg.js",
|
|
21
20
|
"main": "./lib/index.js",
|
|
22
21
|
"exports": {
|
|
23
22
|
".": "./lib/index.js",
|
|
24
23
|
"./bin/pretty-pkg.js": "./bin/pretty-pkg.js",
|
|
25
24
|
"./package.json": "./package.json"
|
|
26
25
|
},
|
|
27
|
-
"
|
|
28
|
-
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
29
|
"files": [
|
|
30
30
|
"lib",
|
|
31
31
|
"bin"
|
|
@@ -34,10 +34,11 @@
|
|
|
34
34
|
"lint": "yarn run lint:eslint",
|
|
35
35
|
"lint:eslint": "yarn ../.. run eslint --report-unused-disable-directives --resolve-plugins-relative-to . --quiet @pob/pretty-pkg"
|
|
36
36
|
},
|
|
37
|
-
"prettier": "@pob/root/prettier-config",
|
|
38
37
|
"pob": {},
|
|
38
|
+
"prettier": "@pob/root/prettier-config",
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@pob/sort-pkg": "
|
|
40
|
+
"@pob/sort-pkg": "7.0.0",
|
|
41
|
+
"glob": "^10.0.0",
|
|
41
42
|
"prettier": "^2.6.2"
|
|
42
43
|
}
|
|
43
44
|
}
|