svelte-vitals 0.21.0 → 0.22.1

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
@@ -7,7 +7,7 @@ import {
7
7
  readCoreVersion,
8
8
  readPackageVersion,
9
9
  run
10
- } from "./chunk-B3RVLTZY.js";
10
+ } from "./chunk-KSJZLF5U.js";
11
11
 
12
12
  // src/bin.ts
13
13
  import mri3 from "mri";
@@ -843,15 +843,17 @@ import mri2 from "mri";
843
843
 
844
844
  // src/ci/workflow.ts
845
845
  var WORKFLOW_PATH = ".github/workflows/svelte-vitals.yml";
846
+ var CHECKOUT_SHA = "9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0";
847
+ var CHECKOUT_VERSION = "v7.0.0";
846
848
  function planWorkflowWrite(existing, force) {
847
849
  if (existing === void 0) return { status: "created" };
848
850
  if (!force) return { status: "exists" };
849
851
  return { status: "updated" };
850
852
  }
851
853
  function buildWorkflowYaml(opts) {
852
- const v = opts.version;
854
+ const { actionSha, actionVersion } = opts;
853
855
  return [
854
- `# Generated by \`svelte-vitals ci install\` (svelte-vitals ${v}).`,
856
+ "# Generated by `svelte-vitals ci install`.",
855
857
  "# Re-run with --force to regenerate.",
856
858
  "name: svelte-vitals",
857
859
  "",
@@ -866,63 +868,30 @@ function buildWorkflowYaml(opts) {
866
868
  " svelte-vitals:",
867
869
  " runs-on: ubuntu-latest",
868
870
  " steps:",
869
- " - uses: actions/checkout@v4",
871
+ ` - uses: actions/checkout@${CHECKOUT_SHA} # ${CHECKOUT_VERSION}`,
870
872
  " with:",
871
873
  " fetch-depth: 0",
872
- " - uses: actions/setup-node@v4",
874
+ ` - uses: oekazuma/svelte-vitals/packages/action@${actionSha} # @svelte-vitals/action@${actionVersion}`,
873
875
  " with:",
874
- " node-version: 24",
875
- " - name: Scan (inline annotations + gate)",
876
- " id: scan",
877
- " continue-on-error: true",
878
- " run: >",
879
- ` npx -y svelte-vitals@${v} .`,
880
- " --diff origin/${{ github.base_ref }}",
881
- " --baseline origin/${{ github.base_ref }}",
882
- " --reporter github",
883
- " - name: Markdown summary",
884
- " run: >",
885
- ` npx -y svelte-vitals@${v} .`,
886
- " --diff origin/${{ github.base_ref }}",
887
- " --baseline origin/${{ github.base_ref }}",
888
- " --reporter md > svelte-vitals-report.md || true",
889
- " - name: Job summary",
890
- ' run: cat svelte-vitals-report.md >> "$GITHUB_STEP_SUMMARY"',
891
- " - name: PR comment (sticky)",
892
- " if: github.event.pull_request.head.repo.full_name == github.repository",
893
- " continue-on-error: true",
894
- " uses: actions/github-script@v7",
895
- " with:",
896
- " script: |",
897
- " const fs = require('fs');",
898
- " const marker = '<!-- svelte-vitals-report -->';",
899
- " const body = marker + '\\n' + fs.readFileSync('svelte-vitals-report.md', 'utf8');",
900
- " const { data: comments } = await github.rest.issues.listComments({",
901
- " ...context.repo, issue_number: context.issue.number, per_page: 100",
902
- " });",
903
- " const mine = comments.find(c => c.body && c.body.startsWith(marker));",
904
- " if (mine) {",
905
- " await github.rest.issues.updateComment({ ...context.repo, comment_id: mine.id, body });",
906
- " } else {",
907
- " await github.rest.issues.createComment({ ...context.repo, issue_number: context.issue.number, body });",
908
- " }",
909
- " - name: Gate",
910
- " if: steps.scan.outcome == 'failure'",
911
- " run: |",
912
- ' echo "svelte-vitals found blocking issues (see annotations above)."',
913
- " exit 1",
876
+ " diff: origin/${{ github.base_ref }}",
877
+ " baseline: origin/${{ github.base_ref }}",
914
878
  ""
915
879
  ].join("\n");
916
880
  }
917
881
 
882
+ // src/ci/action-pin.generated.ts
883
+ var ACTION_SHA = "f16e414797a2ee42c3b1fb6a14dc6fdb9dca4132";
884
+ var ACTION_VERSION = "0.2.1";
885
+
918
886
  // src/ci/cli.ts
919
887
  var CI_HELP = `svelte-vitals ci \u2014 scaffold CI integration
920
888
 
921
889
  Usage:
922
890
  svelte-vitals ci install [options]
923
891
 
924
- Adds a GitHub Actions workflow (${WORKFLOW_PATH}) that scans pull requests, posts inline
925
- annotations + a job summary, and maintains a sticky PR comment with the findings.
892
+ Adds a GitHub Actions workflow (${WORKFLOW_PATH}) that calls the \`@svelte-vitals/action\`
893
+ GitHub Action on pull requests: inline annotations, a job summary, and a sticky PR
894
+ comment with the findings.
926
895
 
927
896
  Options:
928
897
  --force Overwrite an existing workflow file
@@ -958,9 +927,8 @@ async function runCiCli(args, io = realIO()) {
958
927
  if (plan.status === "exists") {
959
928
  io.log(`= already installed (${WORKFLOW_PATH}) \u2014 use --force to regenerate.`);
960
929
  } else {
961
- const version = readPackageVersion();
962
930
  try {
963
- io.writeFile(path, buildWorkflowYaml({ version }));
931
+ io.writeFile(path, buildWorkflowYaml({ actionSha: ACTION_SHA, actionVersion: ACTION_VERSION }));
964
932
  io.log(`\u2713 ${plan.status} ${WORKFLOW_PATH}`);
965
933
  } catch (err) {
966
934
  io.errorLog(
@@ -994,6 +994,38 @@ async function analyzeProject(opts = {}) {
994
994
  );
995
995
  return { results, config, version: readPackageVersion(), warnings };
996
996
  }
997
+ async function applyScope(results, opts) {
998
+ const errorLog = opts.errorLog ?? ((line) => console.error(line));
999
+ let scoped = results;
1000
+ if (opts.staged || opts.diffBase !== void 0) {
1001
+ const changed = opts.staged ? getChangedFiles(opts.cwd, { staged: true }) : getChangedFiles(opts.cwd, { base: opts.diffBase });
1002
+ if (changed === void 0) {
1003
+ errorLog(
1004
+ "svelte-vitals: could not determine changed files (not a git repo, git unavailable, or bad ref); analyzing all."
1005
+ );
1006
+ } else {
1007
+ scoped = filterToChangedFiles(scoped, changed);
1008
+ }
1009
+ }
1010
+ if (opts.baseline !== void 0) {
1011
+ const checkout = checkoutBaseline(opts.cwd, opts.baseline);
1012
+ if (checkout === void 0) {
1013
+ errorLog(
1014
+ `svelte-vitals: could not analyze baseline '${opts.baseline}' (not a git repo, git unavailable, or bad ref); reporting all findings.`
1015
+ );
1016
+ } else {
1017
+ try {
1018
+ const base = await analyzeProject({ ...opts.analyzeOpts, cwd: checkout.analyzeCwd });
1019
+ scoped = filterToNewFindings(scoped, base.results);
1020
+ } catch {
1021
+ errorLog(`svelte-vitals: baseline analysis of '${opts.baseline}' failed; reporting all findings.`);
1022
+ } finally {
1023
+ checkout.cleanup();
1024
+ }
1025
+ }
1026
+ }
1027
+ return scoped;
1028
+ }
997
1029
  async function run(opts = {}) {
998
1030
  const log = opts.log ?? ((line) => console.log(line));
999
1031
  const errorLog = opts.errorLog ?? ((line) => console.error(line));
@@ -1086,43 +1118,22 @@ async function run(opts = {}) {
1086
1118
  for (const w of analysis.warnings) errorLog(`svelte-vitals: ${w}`);
1087
1119
  try {
1088
1120
  const { config, version } = analysis;
1089
- let results = analysis.results;
1090
- if (opts.staged || opts.diffBase !== void 0) {
1091
- const changed = opts.staged ? getChangedFiles(cwd, { staged: true }) : getChangedFiles(cwd, { base: opts.diffBase });
1092
- if (changed === void 0) {
1093
- errorLog(
1094
- "svelte-vitals: could not determine changed files (not a git repo, git unavailable, or bad ref); analyzing all."
1095
- );
1096
- } else {
1097
- results = filterToChangedFiles(results, changed);
1098
- }
1099
- }
1100
- if (opts.baseline !== void 0) {
1101
- const checkout = checkoutBaseline(cwd, opts.baseline);
1102
- if (checkout === void 0) {
1103
- errorLog(
1104
- `svelte-vitals: could not analyze baseline '${opts.baseline}' (not a git repo, git unavailable, or bad ref); reporting all findings.`
1105
- );
1106
- } else {
1107
- try {
1108
- const base = await analyzeProject({
1109
- cwd: checkout.analyzeCwd,
1110
- metaComponents: opts.metaComponents,
1111
- treatDynamicAs: opts.treatDynamicAs,
1112
- route: opts.route,
1113
- failOn: opts.failOn,
1114
- rules: opts.rules,
1115
- weights: opts.weights,
1116
- categories: opts.categories
1117
- });
1118
- results = filterToNewFindings(results, base.results);
1119
- } catch {
1120
- errorLog(`svelte-vitals: baseline analysis of '${opts.baseline}' failed; reporting all findings.`);
1121
- } finally {
1122
- checkout.cleanup();
1123
- }
1121
+ const results = await applyScope(analysis.results, {
1122
+ cwd,
1123
+ staged: opts.staged,
1124
+ diffBase: opts.diffBase,
1125
+ baseline: opts.baseline,
1126
+ errorLog,
1127
+ analyzeOpts: {
1128
+ metaComponents: opts.metaComponents,
1129
+ treatDynamicAs: opts.treatDynamicAs,
1130
+ route: opts.route,
1131
+ failOn: opts.failOn,
1132
+ rules: opts.rules,
1133
+ weights: opts.weights,
1134
+ categories: opts.categories
1124
1135
  }
1125
- }
1136
+ });
1126
1137
  if (opts.score) {
1127
1138
  log(String(computeHealth(results, config).health));
1128
1139
  } else {
@@ -1192,6 +1203,7 @@ export {
1192
1203
  spinnerEnabled,
1193
1204
  routeMatcher,
1194
1205
  analyzeProject,
1206
+ applyScope,
1195
1207
  run,
1196
1208
  defineConfig2 as defineConfig
1197
1209
  };
package/dist/index.d.ts CHANGED
@@ -137,10 +137,25 @@ interface AnalyzeResult {
137
137
  * 2026-07-05-config-file-design.md §3).
138
138
  */
139
139
  declare function analyzeProject(opts?: AnalyzeOptions): Promise<AnalyzeResult>;
140
+ interface ApplyScopeOptions {
141
+ cwd: string;
142
+ staged?: boolean;
143
+ diffBase?: string;
144
+ baseline?: string;
145
+ errorLog?: (line: string) => void;
146
+ analyzeOpts?: AnalyzeOptions;
147
+ }
148
+ /**
149
+ * Narrow `results` to what a PR gate cares about: `--staged`/`--diff` restrict to
150
+ * changed files, `--baseline` drops findings that already existed at that ref. Shared
151
+ * by `run()` and `@svelte-vitals/action` (issue #154) so the git-diff/baseline
152
+ * orchestration lives in exactly one place.
153
+ */
154
+ declare function applyScope(results: Result[], opts: ApplyScopeOptions): Promise<Result[]>;
140
155
  /**
141
156
  * Run static-mode analysis once and return the process exit code (design §6):
142
157
  * 0 = no failing findings, 1 = critical finding present, 2 = execution error.
143
158
  */
144
159
  declare function run(opts?: RunOptions): Promise<number>;
145
160
 
146
- export { type AnalyzeOptions, type AnalyzeResult, type LoadedConfigFile, ProjectError, type RunOptions, analyzeProject, buildRulesConfig, findUnknownRuleIds, knownRuleIds, loadConfigFile, routeMatcher, run, spinnerEnabled };
161
+ export { type AnalyzeOptions, type AnalyzeResult, type ApplyScopeOptions, type LoadedConfigFile, ProjectError, type RunOptions, analyzeProject, applyScope, buildRulesConfig, findUnknownRuleIds, knownRuleIds, loadConfigFile, routeMatcher, run, spinnerEnabled };
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  ProjectError,
3
3
  analyzeProject,
4
+ applyScope,
4
5
  buildRulesConfig,
5
6
  defineConfig,
6
7
  findUnknownRuleIds,
@@ -9,10 +10,11 @@ import {
9
10
  routeMatcher,
10
11
  run,
11
12
  spinnerEnabled
12
- } from "./chunk-B3RVLTZY.js";
13
+ } from "./chunk-KSJZLF5U.js";
13
14
  export {
14
15
  ProjectError,
15
16
  analyzeProject,
17
+ applyScope,
16
18
  buildRulesConfig,
17
19
  defineConfig,
18
20
  findUnknownRuleIds,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-vitals",
3
- "version": "0.21.0",
3
+ "version": "0.22.1",
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",
@@ -45,14 +45,14 @@
45
45
  "smol-toml": "^1.7.0",
46
46
  "svelte": "^5.56.4",
47
47
  "tinyglobby": "^0.2.17",
48
- "@svelte-vitals/core": "0.22.0"
48
+ "@svelte-vitals/core": "0.22.1"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@types/node": "^24.13.2"
52
52
  },
53
53
  "scripts": {
54
- "build": "tsup",
55
- "typecheck": "tsc --noEmit",
56
- "test": "vitest run"
54
+ "build": "node scripts/gen-action-pin.mjs && tsup",
55
+ "typecheck": "node scripts/gen-action-pin.mjs && tsc --noEmit",
56
+ "test": "node scripts/gen-action-pin.mjs && vitest run"
57
57
  }
58
58
  }