yarn-why-duplicate 1.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/bin/yarn-why-duplicate.mjs +31 -0
- package/package.json +26 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { execSync } from 'child_process';
|
|
4
|
+
|
|
5
|
+
const pkgName = process.argv.slice(2)[0];
|
|
6
|
+
|
|
7
|
+
const yarnWhyResult = execSync(`yarn why ${pkgName} --json`, { encoding: 'utf8' })
|
|
8
|
+
.split('\n')
|
|
9
|
+
.filter(Boolean)
|
|
10
|
+
.map((line) => JSON.parse(line));
|
|
11
|
+
|
|
12
|
+
const groupByVersions = new Map();
|
|
13
|
+
|
|
14
|
+
for (const line of yarnWhyResult) {
|
|
15
|
+
for (const [key, child] of Object.entries(line.children)) {
|
|
16
|
+
let values = groupByVersions.get(child.locator);
|
|
17
|
+
if (!values) {
|
|
18
|
+
values = [];
|
|
19
|
+
groupByVersions.set(child.locator, values);
|
|
20
|
+
}
|
|
21
|
+
values.push(line.value);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
for (const [version, values] of groupByVersions.entries()) {
|
|
26
|
+
console.log(version);
|
|
27
|
+
for (const value of values) {
|
|
28
|
+
console.log(`- ${value}`);
|
|
29
|
+
}
|
|
30
|
+
console.log();
|
|
31
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "yarn-why-duplicate",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Simple bin to know why a package is duplicated",
|
|
5
|
+
"main": "bin/yarn-why-duplicate.mjs",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/christophehurpeau/yarn-why-duplicate.git"
|
|
12
|
+
},
|
|
13
|
+
"bin": {
|
|
14
|
+
"yarn-why-duplicate": "./bin/yarn-why-duplicate.mjs"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"yarn",
|
|
18
|
+
"berry"
|
|
19
|
+
],
|
|
20
|
+
"author": "Christophe Hurpeau",
|
|
21
|
+
"license": "ISC",
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/christophehurpeau/yarn-why-duplicate/issues"
|
|
24
|
+
},
|
|
25
|
+
"homepage": "https://github.com/christophehurpeau/yarn-why-duplicate#readme"
|
|
26
|
+
}
|