npmaargh 1.0.0 → 1.0.2
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/README.md +16 -0
- package/index.js +28 -6
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -14,6 +14,15 @@ The report can be used to report blockers upstream or write more targeted
|
|
|
14
14
|
|
|
15
15
|
## Usage
|
|
16
16
|
|
|
17
|
+
You can either install and run:
|
|
18
|
+
|
|
19
|
+
```shell
|
|
20
|
+
npm install --global npmaargh
|
|
21
|
+
npmaargh [flags...] [target]
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Or use `npx`:
|
|
25
|
+
|
|
17
26
|
```shell
|
|
18
27
|
npx npmaargh [flags...] [target]
|
|
19
28
|
```
|
|
@@ -59,3 +68,10 @@ Let's unpack that report:
|
|
|
59
68
|
tracker of `hello` is included to make it easy to report the blocker.
|
|
60
69
|
- `world@0.1.0` is a transitive dependency of `hello@3.2.1`.
|
|
61
70
|
- `# Need 1.1.1` indicates we need to bump it, because of a known vulnerability.
|
|
71
|
+
|
|
72
|
+
## License
|
|
73
|
+
|
|
74
|
+
This software is available under the `AGPL-3.0-or-later` license, see [LICENSE]
|
|
75
|
+
for the full license text.
|
|
76
|
+
|
|
77
|
+
[LICENSE]: ./LICENSE
|
package/index.js
CHANGED
|
@@ -64,12 +64,30 @@ Flags:
|
|
|
64
64
|
|
|
65
65
|
/* -------------------------------------------------------------------------- */
|
|
66
66
|
|
|
67
|
+
let subject = path.basename(wd);
|
|
68
|
+
try {
|
|
69
|
+
const manifestPath = path.resolve(wd, "package.json");
|
|
70
|
+
const manifestRaw = await readFile(manifestPath);
|
|
71
|
+
const manifest = JSON.parse(manifestRaw);
|
|
72
|
+
subject = manifest.name || subject;
|
|
73
|
+
} catch { }
|
|
74
|
+
|
|
75
|
+
let version = "";
|
|
76
|
+
try {
|
|
77
|
+
const { stdout } = await exec("git rev-parse --short HEAD", { cwd: wd });
|
|
78
|
+
version = `@${stdout.trim()}`;
|
|
79
|
+
} catch { }
|
|
80
|
+
|
|
81
|
+
/* -------------------------------------------------------------------------- */
|
|
82
|
+
|
|
67
83
|
const npmListCache = new Map();
|
|
68
84
|
async function npmList(subject) {
|
|
69
85
|
if (!npmListCache.has(subject)) {
|
|
70
86
|
async function fetch() {
|
|
71
87
|
const { stdout } = await exec(`npm list ${subject} --json`, { cwd: wd });
|
|
72
|
-
|
|
88
|
+
const list = JSON.parse(stdout);
|
|
89
|
+
list.version = version.substring(1) || list.version || "1.0.0";
|
|
90
|
+
return list;
|
|
73
91
|
}
|
|
74
92
|
|
|
75
93
|
npmListCache.set(subject, fetch());
|
|
@@ -115,7 +133,7 @@ function prerelease(version) {
|
|
|
115
133
|
/* -------------------------------------------------------------------------- */
|
|
116
134
|
|
|
117
135
|
console.info("=== npm audit assistant ===");
|
|
118
|
-
console.info(`I'm here to help audit '${
|
|
136
|
+
console.info(`I'm here to help audit '${subject}${version}'.`);
|
|
119
137
|
console.info("");
|
|
120
138
|
|
|
121
139
|
console.info("=== setup ===");
|
|
@@ -131,7 +149,8 @@ try {
|
|
|
131
149
|
try {
|
|
132
150
|
await exec("npm install --ignore-scripts", { cwd: wd });
|
|
133
151
|
} catch (error) {
|
|
134
|
-
|
|
152
|
+
stdout.write(`\rFailed to (re)install dependencies:\n`);
|
|
153
|
+
console.info(error);
|
|
135
154
|
exit(1);
|
|
136
155
|
}
|
|
137
156
|
}
|
|
@@ -145,7 +164,7 @@ stdout.write("Obtaining audit report...");
|
|
|
145
164
|
let npmAuditReport;
|
|
146
165
|
try {
|
|
147
166
|
await exec("npm audit --json", { cwd: wd });
|
|
148
|
-
|
|
167
|
+
stdout.write("\rNothing to audit. \n");
|
|
149
168
|
exit(0);
|
|
150
169
|
} catch (error) {
|
|
151
170
|
npmAuditReport = JSON.parse(error.stdout);
|
|
@@ -153,7 +172,8 @@ try {
|
|
|
153
172
|
|
|
154
173
|
const reportVersion = npmAuditReport.auditReportVersion;
|
|
155
174
|
if (reportVersion !== 2) {
|
|
156
|
-
|
|
175
|
+
stdout.write(`\rUnknown audit report version: ${reportVersion}\n`);
|
|
176
|
+
exit(1);
|
|
157
177
|
}
|
|
158
178
|
|
|
159
179
|
stdout.write("\rObtained audit report. \n");
|
|
@@ -189,7 +209,7 @@ stdout.write("\rAnalyzed audit report. \n");
|
|
|
189
209
|
|
|
190
210
|
/* -------------------------------------------------------------------------- */
|
|
191
211
|
|
|
192
|
-
const SELF = `<${
|
|
212
|
+
const SELF = `<${subject}>`;
|
|
193
213
|
|
|
194
214
|
class Nothing {
|
|
195
215
|
toString() {
|
|
@@ -482,6 +502,8 @@ function pruneNoops(result) {
|
|
|
482
502
|
}
|
|
483
503
|
|
|
484
504
|
function print(result, gutter, level) {
|
|
505
|
+
result.name = result.name.replace(SELF, subject);
|
|
506
|
+
|
|
485
507
|
if (!level) {
|
|
486
508
|
function depth(obj, lvl) {
|
|
487
509
|
const length = obj.name.length + obj.version.length + lvl;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "npmaargh",
|
|
3
3
|
"description": "The npm audit assistant",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.2",
|
|
5
5
|
"license": "AGPL-3.0-or-later",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -31,6 +31,10 @@
|
|
|
31
31
|
],
|
|
32
32
|
"type": "module",
|
|
33
33
|
"bin": "./index.js",
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": ">=24",
|
|
36
|
+
"npm": ">=11"
|
|
37
|
+
},
|
|
34
38
|
"dependencies": {
|
|
35
39
|
"semver": "^7.3.8"
|
|
36
40
|
}
|