laxy-verify 1.2.0 → 1.2.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/trend.d.ts CHANGED
@@ -1,50 +1,50 @@
1
- export interface TrendSnapshot {
2
- grade: string;
3
- lighthouse: {
4
- performance: number;
5
- accessibility: number;
6
- seo: number;
7
- bestPractices: number;
8
- } | null;
9
- e2e?: {
10
- passed: number;
11
- total: number;
12
- } | null;
13
- timestamp: string;
14
- }
15
- export interface TrendDelta {
16
- grade: {
17
- current: string;
18
- base: string;
19
- changed: boolean;
20
- };
21
- performance: {
22
- current: number | null;
23
- base: number | null;
24
- delta: number | null;
25
- };
26
- accessibility: {
27
- current: number | null;
28
- base: number | null;
29
- delta: number | null;
30
- };
31
- seo: {
32
- current: number | null;
33
- base: number | null;
34
- delta: number | null;
35
- };
36
- bestPractices: {
37
- current: number | null;
38
- base: number | null;
39
- delta: number | null;
40
- };
41
- e2e: {
42
- current: string | null;
43
- base: string | null;
44
- };
45
- }
46
- export declare function gradeIndex(grade: string): number;
47
- export declare function loadBaseSnapshot(baseResultPath: string): TrendSnapshot | null;
48
- export declare function computeTrendDelta(current: TrendSnapshot, base: TrendSnapshot): TrendDelta;
49
- export declare function renderTrendSection(delta: TrendDelta): string;
50
- export declare function getBaseResultPath(projectDir: string): string;
1
+ export interface TrendSnapshot {
2
+ grade: string;
3
+ lighthouse: {
4
+ performance: number;
5
+ accessibility: number;
6
+ seo: number;
7
+ bestPractices: number;
8
+ } | null;
9
+ e2e?: {
10
+ passed: number;
11
+ total: number;
12
+ } | null;
13
+ timestamp: string;
14
+ }
15
+ export interface TrendDelta {
16
+ grade: {
17
+ current: string;
18
+ base: string;
19
+ changed: boolean;
20
+ };
21
+ performance: {
22
+ current: number | null;
23
+ base: number | null;
24
+ delta: number | null;
25
+ };
26
+ accessibility: {
27
+ current: number | null;
28
+ base: number | null;
29
+ delta: number | null;
30
+ };
31
+ seo: {
32
+ current: number | null;
33
+ base: number | null;
34
+ delta: number | null;
35
+ };
36
+ bestPractices: {
37
+ current: number | null;
38
+ base: number | null;
39
+ delta: number | null;
40
+ };
41
+ e2e: {
42
+ current: string | null;
43
+ base: string | null;
44
+ };
45
+ }
46
+ export declare function gradeIndex(grade: string): number;
47
+ export declare function loadBaseSnapshot(baseResultPath: string): TrendSnapshot | null;
48
+ export declare function computeTrendDelta(current: TrendSnapshot, base: TrendSnapshot): TrendDelta;
49
+ export declare function renderTrendSection(delta: TrendDelta): string;
50
+ export declare function getBaseResultPath(projectDir: string): string;
package/dist/trend.js CHANGED
@@ -1,148 +1,148 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.gradeIndex = gradeIndex;
37
- exports.loadBaseSnapshot = loadBaseSnapshot;
38
- exports.computeTrendDelta = computeTrendDelta;
39
- exports.renderTrendSection = renderTrendSection;
40
- exports.getBaseResultPath = getBaseResultPath;
41
- const fs = __importStar(require("node:fs"));
42
- const path = __importStar(require("node:path"));
43
- const GRADE_ORDER = ["Unverified", "Bronze", "Silver", "Gold", "Platinum"];
44
- function gradeIndex(grade) {
45
- const idx = GRADE_ORDER.indexOf(grade);
46
- return idx === -1 ? 0 : idx;
47
- }
48
- function formatDelta(delta) {
49
- if (delta === null)
50
- return "";
51
- if (delta > 0)
52
- return ` (+${delta})`;
53
- if (delta < 0)
54
- return ` (${delta})`;
55
- return "";
56
- }
57
- function gradeTrend(current, base) {
58
- const ci = gradeIndex(current);
59
- const bi = gradeIndex(base);
60
- if (ci > bi)
61
- return ` ↑ (was ${base})`;
62
- if (ci < bi)
63
- return ` ↓ (was ${base})`;
64
- return "";
65
- }
66
- function loadBaseSnapshot(baseResultPath) {
67
- if (!fs.existsSync(baseResultPath))
68
- return null;
69
- try {
70
- const raw = JSON.parse(fs.readFileSync(baseResultPath, "utf-8"));
71
- return {
72
- grade: raw.grade ?? "Unverified",
73
- lighthouse: raw.lighthouse ?? null,
74
- e2e: raw.e2e ? { passed: raw.e2e.passed, total: raw.e2e.total } : null,
75
- timestamp: raw.timestamp ?? "",
76
- };
77
- }
78
- catch {
79
- return null;
80
- }
81
- }
82
- function computeTrendDelta(current, base) {
83
- const lhCurrent = current.lighthouse;
84
- const lhBase = base.lighthouse;
85
- function lhDelta(key) {
86
- if (!lhCurrent || !lhBase)
87
- return null;
88
- return lhCurrent[key] - lhBase[key];
89
- }
90
- return {
91
- grade: {
92
- current: current.grade,
93
- base: base.grade,
94
- changed: current.grade !== base.grade,
95
- },
96
- performance: {
97
- current: lhCurrent?.performance ?? null,
98
- base: lhBase?.performance ?? null,
99
- delta: lhDelta("performance"),
100
- },
101
- accessibility: {
102
- current: lhCurrent?.accessibility ?? null,
103
- base: lhBase?.accessibility ?? null,
104
- delta: lhDelta("accessibility"),
105
- },
106
- seo: {
107
- current: lhCurrent?.seo ?? null,
108
- base: lhBase?.seo ?? null,
109
- delta: lhDelta("seo"),
110
- },
111
- bestPractices: {
112
- current: lhCurrent?.bestPractices ?? null,
113
- base: lhBase?.bestPractices ?? null,
114
- delta: lhDelta("bestPractices"),
115
- },
116
- e2e: {
117
- current: current.e2e ? `${current.e2e.passed}/${current.e2e.total}` : null,
118
- base: base.e2e ? `${base.e2e.passed}/${base.e2e.total}` : null,
119
- },
120
- };
121
- }
122
- function renderTrendSection(delta) {
123
- const lines = ["## vs Base Branch", ""];
124
- lines.push("| Check | This PR | Base |");
125
- lines.push("|---|---|---|");
126
- const gradeTrendStr = gradeTrend(delta.grade.current, delta.grade.base);
127
- lines.push(`| Grade | **${delta.grade.current}**${gradeTrendStr} | ${delta.grade.base} |`);
128
- if (delta.performance.current !== null) {
129
- lines.push(`| Performance | ${delta.performance.current}${formatDelta(delta.performance.delta)} | ${delta.performance.base ?? "—"} |`);
130
- }
131
- if (delta.accessibility.current !== null) {
132
- lines.push(`| Accessibility | ${delta.accessibility.current}${formatDelta(delta.accessibility.delta)} | ${delta.accessibility.base ?? "—"} |`);
133
- }
134
- if (delta.seo.current !== null) {
135
- lines.push(`| SEO | ${delta.seo.current}${formatDelta(delta.seo.delta)} | ${delta.seo.base ?? "—"} |`);
136
- }
137
- if (delta.bestPractices.current !== null) {
138
- lines.push(`| Best Practices | ${delta.bestPractices.current}${formatDelta(delta.bestPractices.delta)} | ${delta.bestPractices.base ?? "—"} |`);
139
- }
140
- if (delta.e2e.current !== null) {
141
- lines.push(`| E2E | ${delta.e2e.current} | ${delta.e2e.base ?? "—"} |`);
142
- }
143
- lines.push("");
144
- return lines.join("\n");
145
- }
146
- function getBaseResultPath(projectDir) {
147
- return path.join(projectDir, ".laxy-result-base.json");
148
- }
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.gradeIndex = gradeIndex;
37
+ exports.loadBaseSnapshot = loadBaseSnapshot;
38
+ exports.computeTrendDelta = computeTrendDelta;
39
+ exports.renderTrendSection = renderTrendSection;
40
+ exports.getBaseResultPath = getBaseResultPath;
41
+ const fs = __importStar(require("node:fs"));
42
+ const path = __importStar(require("node:path"));
43
+ const GRADE_ORDER = ["Unverified", "Bronze", "Silver", "Gold", "Platinum"];
44
+ function gradeIndex(grade) {
45
+ const idx = GRADE_ORDER.indexOf(grade);
46
+ return idx === -1 ? 0 : idx;
47
+ }
48
+ function formatDelta(delta) {
49
+ if (delta === null)
50
+ return "";
51
+ if (delta > 0)
52
+ return ` (+${delta})`;
53
+ if (delta < 0)
54
+ return ` (${delta})`;
55
+ return "";
56
+ }
57
+ function gradeTrend(current, base) {
58
+ const ci = gradeIndex(current);
59
+ const bi = gradeIndex(base);
60
+ if (ci > bi)
61
+ return ` ↑ (was ${base})`;
62
+ if (ci < bi)
63
+ return ` ↓ (was ${base})`;
64
+ return "";
65
+ }
66
+ function loadBaseSnapshot(baseResultPath) {
67
+ if (!fs.existsSync(baseResultPath))
68
+ return null;
69
+ try {
70
+ const raw = JSON.parse(fs.readFileSync(baseResultPath, "utf-8"));
71
+ return {
72
+ grade: raw.grade ?? "Unverified",
73
+ lighthouse: raw.lighthouse ?? null,
74
+ e2e: raw.e2e ? { passed: raw.e2e.passed, total: raw.e2e.total } : null,
75
+ timestamp: raw.timestamp ?? "",
76
+ };
77
+ }
78
+ catch {
79
+ return null;
80
+ }
81
+ }
82
+ function computeTrendDelta(current, base) {
83
+ const lhCurrent = current.lighthouse;
84
+ const lhBase = base.lighthouse;
85
+ function lhDelta(key) {
86
+ if (!lhCurrent || !lhBase)
87
+ return null;
88
+ return lhCurrent[key] - lhBase[key];
89
+ }
90
+ return {
91
+ grade: {
92
+ current: current.grade,
93
+ base: base.grade,
94
+ changed: current.grade !== base.grade,
95
+ },
96
+ performance: {
97
+ current: lhCurrent?.performance ?? null,
98
+ base: lhBase?.performance ?? null,
99
+ delta: lhDelta("performance"),
100
+ },
101
+ accessibility: {
102
+ current: lhCurrent?.accessibility ?? null,
103
+ base: lhBase?.accessibility ?? null,
104
+ delta: lhDelta("accessibility"),
105
+ },
106
+ seo: {
107
+ current: lhCurrent?.seo ?? null,
108
+ base: lhBase?.seo ?? null,
109
+ delta: lhDelta("seo"),
110
+ },
111
+ bestPractices: {
112
+ current: lhCurrent?.bestPractices ?? null,
113
+ base: lhBase?.bestPractices ?? null,
114
+ delta: lhDelta("bestPractices"),
115
+ },
116
+ e2e: {
117
+ current: current.e2e ? `${current.e2e.passed}/${current.e2e.total}` : null,
118
+ base: base.e2e ? `${base.e2e.passed}/${base.e2e.total}` : null,
119
+ },
120
+ };
121
+ }
122
+ function renderTrendSection(delta) {
123
+ const lines = ["## vs Base Branch", ""];
124
+ lines.push("| Check | This PR | Base |");
125
+ lines.push("|---|---|---|");
126
+ const gradeTrendStr = gradeTrend(delta.grade.current, delta.grade.base);
127
+ lines.push(`| Grade | **${delta.grade.current}**${gradeTrendStr} | ${delta.grade.base} |`);
128
+ if (delta.performance.current !== null) {
129
+ lines.push(`| Performance | ${delta.performance.current}${formatDelta(delta.performance.delta)} | ${delta.performance.base ?? "—"} |`);
130
+ }
131
+ if (delta.accessibility.current !== null) {
132
+ lines.push(`| Accessibility | ${delta.accessibility.current}${formatDelta(delta.accessibility.delta)} | ${delta.accessibility.base ?? "—"} |`);
133
+ }
134
+ if (delta.seo.current !== null) {
135
+ lines.push(`| SEO | ${delta.seo.current}${formatDelta(delta.seo.delta)} | ${delta.seo.base ?? "—"} |`);
136
+ }
137
+ if (delta.bestPractices.current !== null) {
138
+ lines.push(`| Best Practices | ${delta.bestPractices.current}${formatDelta(delta.bestPractices.delta)} | ${delta.bestPractices.base ?? "—"} |`);
139
+ }
140
+ if (delta.e2e.current !== null) {
141
+ lines.push(`| E2E | ${delta.e2e.current} | ${delta.e2e.base ?? "—"} |`);
142
+ }
143
+ lines.push("");
144
+ return lines.join("\n");
145
+ }
146
+ function getBaseResultPath(projectDir) {
147
+ return path.join(projectDir, ".laxy-result-base.json");
148
+ }
@@ -1,3 +1,3 @@
1
- export * from "./types.js";
2
- export * from "./tier-policy.js";
3
- export * from "./report.js";
1
+ export * from "./types.js";
2
+ export * from "./tier-policy.js";
3
+ export * from "./report.js";
@@ -1,19 +1,19 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./types.js"), exports);
18
- __exportStar(require("./tier-policy.js"), exports);
19
- __exportStar(require("./report.js"), exports);
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./types.js"), exports);
18
+ __exportStar(require("./tier-policy.js"), exports);
19
+ __exportStar(require("./report.js"), exports);
@@ -1,14 +1,14 @@
1
- import type { LighthouseThresholds, TierVerificationView, VerificationEvidence, VerificationFinding, VerificationGrade, VerificationInput, VerificationReport, VerificationTier } from "./types.js";
2
- export declare const DEFAULT_LH_THRESHOLDS: LighthouseThresholds;
3
- export declare function getLighthousePass(lighthouseScores?: VerificationInput["lighthouseScores"], thresholds?: LighthouseThresholds): boolean;
4
- export declare function getVerificationGrade(input: VerificationInput, thresholds?: LighthouseThresholds): VerificationGrade;
5
- export declare function buildVerificationEvidence(input: VerificationInput, thresholds?: LighthouseThresholds): VerificationEvidence;
6
- export declare function getImprovementRecommendations(input: VerificationInput, thresholds?: LighthouseThresholds): VerificationFinding[];
7
- export declare function buildVerificationReport(input: VerificationInput, options?: {
8
- tier?: VerificationTier;
9
- thresholds?: LighthouseThresholds;
10
- }): VerificationReport;
11
- export declare function buildTierVerificationView(input: VerificationInput, options?: {
12
- tier?: VerificationTier;
13
- thresholds?: LighthouseThresholds;
14
- }): TierVerificationView;
1
+ import type { LighthouseThresholds, TierVerificationView, VerificationEvidence, VerificationFinding, VerificationGrade, VerificationInput, VerificationReport, VerificationTier } from "./types.js";
2
+ export declare const DEFAULT_LH_THRESHOLDS: LighthouseThresholds;
3
+ export declare function getLighthousePass(lighthouseScores?: VerificationInput["lighthouseScores"], thresholds?: LighthouseThresholds): boolean;
4
+ export declare function getVerificationGrade(input: VerificationInput, thresholds?: LighthouseThresholds): VerificationGrade;
5
+ export declare function buildVerificationEvidence(input: VerificationInput, thresholds?: LighthouseThresholds): VerificationEvidence;
6
+ export declare function getImprovementRecommendations(input: VerificationInput, thresholds?: LighthouseThresholds): VerificationFinding[];
7
+ export declare function buildVerificationReport(input: VerificationInput, options?: {
8
+ tier?: VerificationTier;
9
+ thresholds?: LighthouseThresholds;
10
+ }): VerificationReport;
11
+ export declare function buildTierVerificationView(input: VerificationInput, options?: {
12
+ tier?: VerificationTier;
13
+ thresholds?: LighthouseThresholds;
14
+ }): TierVerificationView;