@mnci/cli 4.40.1 → 4.40.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/dist/cli.js +19 -2
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -283,7 +283,17 @@ function classifyNpmAudit(report) {
|
|
|
283
283
|
});
|
|
284
284
|
return { blocking, total: all.length, notes };
|
|
285
285
|
}
|
|
286
|
-
function
|
|
286
|
+
function planIsEmpty(stdout) {
|
|
287
|
+
try {
|
|
288
|
+
const start = stdout.search(/^\{/m);
|
|
289
|
+
const plan = JSON.parse(start === -1 ? stdout : stdout.slice(start));
|
|
290
|
+
const lists = [plan.add, plan.change, plan.remove];
|
|
291
|
+
return lists.every((list) => Array.isArray(list) && list.length === 0);
|
|
292
|
+
} catch {
|
|
293
|
+
return false;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
function auditNpm(result, dryRun, log) {
|
|
287
297
|
let report;
|
|
288
298
|
try {
|
|
289
299
|
report = JSON.parse(result.stdout);
|
|
@@ -299,6 +309,13 @@ function auditNpm(result, log) {
|
|
|
299
309
|
log(`npm audit - ${total} advisory(ies), none actionable at moderate or above.`);
|
|
300
310
|
return 0;
|
|
301
311
|
}
|
|
312
|
+
if (planIsEmpty(dryRun().stdout)) {
|
|
313
|
+
for (const advisory of blocking) {
|
|
314
|
+
log(` note [${advisory.severity}] ${advisory.name} - npm reports a fix, but npm audit fix has nothing to apply`);
|
|
315
|
+
}
|
|
316
|
+
log(`npm audit - ${total} advisory(ies); ${blocking.length} reported as fixable, but no patched release is reachable, so there is nothing to do here.`);
|
|
317
|
+
return 0;
|
|
318
|
+
}
|
|
302
319
|
for (const advisory of blocking) {
|
|
303
320
|
log(` BLOCKING [${advisory.severity}] ${advisory.name} - fix available`);
|
|
304
321
|
}
|
|
@@ -325,7 +342,7 @@ function runAudit(workspaceRoot, dependencies = {}) {
|
|
|
325
342
|
}
|
|
326
343
|
};
|
|
327
344
|
log(groupStart(host, "npm audit"));
|
|
328
|
-
const npm = auditNpm(processes.capture("npm", ["audit", "--json"]), log);
|
|
345
|
+
const npm = auditNpm(processes.capture("npm", ["audit", "--json"]), () => processes.capture("npm", ["audit", "fix", "--dry-run", "--json"]), log);
|
|
329
346
|
closeGroup();
|
|
330
347
|
if (npm !== 0) {
|
|
331
348
|
return npm;
|