Skip to content

Commit 79ae47e

Browse files
committed
fix(doctor): group reconcile recommendations
1 parent 02f92ca commit 79ae47e

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

scripts/doctor.mjs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,26 @@ function main() {
3232
console.log(`[doctor] Found ${issues.length} custom public issue${issues.length === 1 ? "" : "s"}:`);
3333
for (const issue of issues) {
3434
console.log(`- [${issue.severity}] ${issue.path}: ${issue.message}`);
35-
console.log(` Fix: npm run reconcile -- --${issue.fix}`);
35+
}
36+
37+
printRecommendedFixes(issues);
38+
}
39+
40+
function printRecommendedFixes(issues) {
41+
const fixes = [...new Set(issues.map((issue) => issue.fix))];
42+
const fixCounts = fixes.map((fix) => ({
43+
fix,
44+
count: issues.filter((issue) => issue.fix === fix).length
45+
}));
46+
47+
console.log("");
48+
console.log("[doctor] Recommended fix:");
49+
console.log(` npm run reconcile -- ${fixes.map((fix) => `--${fix}`).join(" ")}`);
50+
51+
console.log("");
52+
console.log("[doctor] Fix groups:");
53+
for (const { fix, count } of fixCounts) {
54+
console.log(`- --${fix}: ${count} issue${count === 1 ? "" : "s"}`);
3655
}
3756
}
3857

scripts/maintenance.test.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ function run(cwd, args) {
7878
(issue) => issue.code === "html-head-assets-stale" && issue.path === "custom/public/en/index.html"
7979
)
8080
);
81+
const doctorText = run(fixture, ["scripts/doctor.mjs"]);
82+
assert.match(doctorText, /Recommended fix:/);
83+
assert.match(doctorText, /npm run reconcile -- --head-assets/);
84+
assert.match(doctorText, /--head-assets: 1 issue/);
8185

8286
run(fixture, ["scripts/reconcile.mjs", "--head-assets"]);
8387
const fixedHtml = fs.readFileSync(indexPath, "utf8");

0 commit comments

Comments
 (0)