svelte-5-doctor 0.2.0 → 0.3.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/dist/cli.js +18 -3
- package/package.json +3 -3
package/dist/cli.js
CHANGED
|
@@ -26,6 +26,8 @@ program
|
|
|
26
26
|
.option("--diff", "alias for --scope changed (deprecated)", false)
|
|
27
27
|
.option("--scope <scope>", "scope: full | changed | files", "full")
|
|
28
28
|
.option("--base <branch>", "diff base for changed scope", "main")
|
|
29
|
+
.option("--blocking <level>", "fail CI on: error | warning | none (also score <75)", "none")
|
|
30
|
+
.option("--fail-on-score <n>", "fail if score < n (default 75 for --blocking error)", "75")
|
|
29
31
|
.option("--no-color", "disable color")
|
|
30
32
|
.action(async (directory, opts) => {
|
|
31
33
|
const dir = resolve(process.cwd(), directory);
|
|
@@ -48,8 +50,13 @@ program
|
|
|
48
50
|
else {
|
|
49
51
|
console.log(out);
|
|
50
52
|
}
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
+
const blockingJson = opts.blocking ?? "none";
|
|
54
|
+
const failOnScoreJson = Number.parseInt(opts.failOnScore ?? "75", 10);
|
|
55
|
+
const hasErrorsJson = report.diagnostics.some((d) => d.severity === "error");
|
|
56
|
+
const hasWarningsJson = report.diagnostics.some((d) => d.severity === "warn");
|
|
57
|
+
const scoreBlockedJson = report.score < failOnScoreJson && blockingJson !== "none";
|
|
58
|
+
const shouldFailJson = (blockingJson === "error" && hasErrorsJson) || (blockingJson === "warning" && (hasErrorsJson || hasWarningsJson)) || scoreBlockedJson;
|
|
59
|
+
process.exit(shouldFailJson ? 1 : 0);
|
|
53
60
|
}
|
|
54
61
|
// human output — mirrors react-doctor score header
|
|
55
62
|
const labelColor = report.label === "Great" ? pc.green : report.label === "Needs work" ? pc.yellow : pc.red;
|
|
@@ -91,8 +98,16 @@ program
|
|
|
91
98
|
console.log(pc.dim(` Run ${pc.bold("npx svelte-5-doctor --json --json-out report.json")} for machine-readable output.`));
|
|
92
99
|
console.log(pc.dim(` Run ${pc.bold("npx svelte-5-doctor rules list")} to see all rules.`));
|
|
93
100
|
console.log("");
|
|
101
|
+
// Score CI gate — ported from react-doctor blocking + SCORE_BANDS (75/50) — svelte-5-doctor 0.3.0 perfection
|
|
102
|
+
const blocking = opts.blocking ?? "none";
|
|
103
|
+
const failOnScore = Number.parseInt(opts.failOnScore ?? "75", 10);
|
|
94
104
|
const hasErrors = report.diagnostics.some((d) => d.severity === "error");
|
|
95
|
-
|
|
105
|
+
const hasWarnings = report.diagnostics.some((d) => d.severity === "warn");
|
|
106
|
+
const scoreBlocked = report.score < failOnScore && blocking !== "none";
|
|
107
|
+
if (scoreBlocked)
|
|
108
|
+
console.log(pc.yellow(` Score ${report.score} < ${failOnScore} — failing due to --blocking ${blocking}`));
|
|
109
|
+
const shouldFail = (blocking === "error" && hasErrors) || (blocking === "warning" && (hasErrors || hasWarnings)) || scoreBlocked;
|
|
110
|
+
process.exit(shouldFail ? 1 : 0);
|
|
96
111
|
});
|
|
97
112
|
program
|
|
98
113
|
.command("rules")
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelte-5-doctor",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Svelte 5 Doctor — 0-100 health check for Svelte 5. Ported from React Doctor (millionco/react-doctor). Renamed from svelte-doctor (taken on npm by pimatis/svelte-doctor).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
"commander": "^14.0.3",
|
|
21
21
|
"picocolors": "^1.1.1",
|
|
22
22
|
"tinyglobby": "^0.2.12",
|
|
23
|
-
"svelte-5-doctor-core": "0.
|
|
23
|
+
"svelte-5-doctor-core": "0.3.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"svelte": "^5.
|
|
26
|
+
"svelte": "^5.56.10",
|
|
27
27
|
"tsx": "^4.22.4",
|
|
28
28
|
"typescript": "^5.9.2",
|
|
29
29
|
"vitest": "^3.2.4"
|