svelte-vitals 0.7.0 → 0.8.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/bin.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  knownRuleIds,
7
7
  readPackageVersion,
8
8
  run
9
- } from "./chunk-DVIKLRTP.js";
9
+ } from "./chunk-L6IHVJKF.js";
10
10
 
11
11
  // src/bin.ts
12
12
  import mri from "mri";
@@ -85,6 +85,7 @@ Options:
85
85
  --json Alias for --reporter=json
86
86
  --fail-on <severity> Fail (exit 1) when any finding reaches this severity: critical | warning | info
87
87
  --fail-on-warning Alias for --fail-on=warning
88
+ --min-health <0-100> Fail (exit 1) when the combined Health score is below this value
88
89
  --rules <ids> Comma-separated rule ids to enable (all others disabled)
89
90
  --ignore <ids> Comma-separated rule ids to disable
90
91
  -h, --help Show this help
@@ -99,7 +100,7 @@ async function main() {
99
100
  const argv = mri(process.argv.slice(2), {
100
101
  alias: { h: "help", v: "version" },
101
102
  boolean: ["by-route", "json", "fail-on-warning"],
102
- string: ["meta-components", "treat-dynamic-as", "route", "fail-on", "reporter", "rules", "ignore"]
103
+ string: ["meta-components", "treat-dynamic-as", "route", "fail-on", "reporter", "rules", "ignore", "min-health"]
103
104
  });
104
105
  if (argv.help) {
105
106
  console.log(HELP);
@@ -113,7 +114,17 @@ async function main() {
113
114
  for (const w of warnings) console.error(w);
114
115
  for (const e of errors) console.error(e);
115
116
  if (!options) process.exit(2);
116
- const code = await run(options);
117
+ const minHealthRaw = argv["min-health"];
118
+ let minHealth;
119
+ if (minHealthRaw !== void 0) {
120
+ const n = Number(minHealthRaw);
121
+ if (!Number.isFinite(n) || n < 0 || n > 100) {
122
+ console.error(`svelte-vitals: invalid --min-health '${minHealthRaw}'; expected a number 0-100.`);
123
+ process.exit(2);
124
+ }
125
+ minHealth = n;
126
+ }
127
+ const code = await run({ ...options, minHealth });
117
128
  process.exit(code);
118
129
  }
119
130
  void main();
@@ -9,6 +9,7 @@ import {
9
9
  formatGithubReport,
10
10
  summarize,
11
11
  hasFailureAtOrAbove,
12
+ computeHealth,
12
13
  defineConfig,
13
14
  selectRules,
14
15
  applyRuleSeverities
@@ -641,6 +642,10 @@ async function analyzeProject(opts = {}) {
641
642
  async function run(opts = {}) {
642
643
  const log = opts.log ?? ((line) => console.log(line));
643
644
  const errorLog = opts.errorLog ?? ((line) => console.error(line));
645
+ if (opts.minHealth != null && (!Number.isFinite(opts.minHealth) || opts.minHealth < 0 || opts.minHealth > 100)) {
646
+ errorLog(`svelte-vitals: invalid minHealth '${opts.minHealth}'; expected a number 0-100.`);
647
+ return 2;
648
+ }
644
649
  let analysis;
645
650
  try {
646
651
  analysis = await analyzeProject({
@@ -686,7 +691,9 @@ async function run(opts = {}) {
686
691
  log(formatConsoleReport(results, config, { byRoute: opts.byRoute ?? false }));
687
692
  }
688
693
  const summary = summarize(results, config);
689
- return hasFailureAtOrAbove(summary, config.failOn) ? 1 : 0;
694
+ const failBySeverity = hasFailureAtOrAbove(summary, config.failOn);
695
+ const failByHealth = opts.minHealth != null && computeHealth(results, config).health < opts.minHealth;
696
+ return failBySeverity || failByHealth ? 1 : 0;
690
697
  } catch (err) {
691
698
  errorLog(`svelte-vitals: ${err instanceof Error ? err.message : String(err)}`);
692
699
  return 2;
package/dist/index.d.ts CHANGED
@@ -37,6 +37,8 @@ interface RunOptions {
37
37
  rules?: Record<string, RuleSetting>;
38
38
  /** Override process.env for reporter auto-detection (mainly useful in tests). */
39
39
  env?: NodeJS.ProcessEnv;
40
+ /** Fail (exit 1) when the combined Health score is below this value (0–100). */
41
+ minHealth?: number;
40
42
  }
41
43
  declare function routeMatcher(glob: string | undefined): (route: string) => boolean;
42
44
  interface AnalyzeOptions {
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  knownRuleIds,
7
7
  routeMatcher,
8
8
  run
9
- } from "./chunk-DVIKLRTP.js";
9
+ } from "./chunk-L6IHVJKF.js";
10
10
  export {
11
11
  ProjectError,
12
12
  analyzeProject,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-vitals",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "A SvelteKit SEO checker — not a runtime Web Vitals reporter. Static analysis of your routes' head metadata.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -42,7 +42,7 @@
42
42
  "mri": "^1.2.0",
43
43
  "svelte": "^5.56.3",
44
44
  "tinyglobby": "^0.2.17",
45
- "@svelte-vitals/core": "0.8.0"
45
+ "@svelte-vitals/core": "0.9.0"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@types/node": "^24.7.0"