Skip to content

Commit 2371ecf

Browse files
committed
fix: ci consistency and npm publish configuration
1 parent 23f87e2 commit 2371ecf

4 files changed

Lines changed: 85 additions & 21 deletions

File tree

.github/workflows/publish-cli.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ jobs:
3535
- name: Run E2E tests
3636
run: npm run test:e2e --prefix cli
3737

38+
- name: Prepare snippets for publishing
39+
run: cp -r snippets cli/
40+
3841
- name: Publish to npm
3942
run: npm publish
4043
working-directory: cli

cli/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
"version": "0.1.0",
44
"description": "Run curated WebPerf Snippets headlessly via Playwright. Diagnose Core Web Vitals beyond what Lighthouse exposes.",
55
"type": "module",
6-
"bin": {
7-
"webperf-snippets": "./src/bin.js"
8-
},
6+
"bin": "./src/bin.js",
97
"files": [
108
"src",
119
"snippets",
@@ -36,6 +34,9 @@
3634
],
3735
"author": "Joan Leon | @nucliweb",
3836
"license": "MIT",
37+
"publishConfig": {
38+
"access": "public"
39+
},
3940
"repository": {
4041
"type": "git",
4142
"url": "git+https://github.com/nucliweb/webperf-snippets.git",

pages/CLI.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
---
2+
type: guide
3+
---
4+
15
# CLI
26

37
Run curated WebPerf Snippets headlessly via Playwright. Diagnose Core Web Vitals beyond what Lighthouse exposes and gate CI on real performance budgets.

public/llms-full.txt

Lines changed: 74 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5713,6 +5713,9 @@ Identifies resources that block the browser from rendering the page. These resou
57135713
durationMs: Math.round(r.duration),
57145714
sizeBytes: r.size,
57155715
})),
5716+
issues: blockingResources.length > 0
5717+
? [{ severity: "error", message: `${blockingResources.length} render-blocking resource(s) delay rendering until ${Math.round(lastBlockingEnd)}ms` }]
5718+
: [],
57165719
};
57175720
})();
57185721
```
@@ -5794,10 +5797,14 @@ Analyzes all scripts loaded on the page, separating them into first-party (your
57945797
const firstMetrics = calcMetrics(firstParty);
57955798
const thirdMetrics = calcMetrics(thirdParty);
57965799
const totalScripts = scripts.length;
5797-
const thirdPartyPct = totalScripts > 0 ? ((thirdParty.length / totalScripts) * 100).toFixed(0) : 0;
5800+
const thirdPartyPct =
5801+
totalScripts > 0 ? ((thirdParty.length / totalScripts) * 100).toFixed(0) : 0;
57985802

57995803
// Display results
5800-
console.group("%c📊 Script Analysis: First vs Third Party", "font-weight: bold; font-size: 14px;");
5804+
console.group(
5805+
"%c📊 Script Analysis: First vs Third Party",
5806+
"font-weight: bold; font-size: 14px;",
5807+
);
58015808

58025809
// Overall summary
58035810
console.log("");
@@ -5812,7 +5819,10 @@ Analyzes all scripts loaded on the page, separating them into first-party (your
58125819

58135820
// First Party Section
58145821
console.log("");
5815-
console.group(`%c🏠 First-Party Scripts (${firstParty.length})`, "color: #22c55e; font-weight: bold;");
5822+
console.group(
5823+
`%c🏠 First-Party Scripts (${firstParty.length})`,
5824+
"color: #22c55e; font-weight: bold;",
5825+
);
58165826

58175827
if (firstParty.length === 0) {
58185828
console.log("No first-party scripts found.");
@@ -5836,13 +5846,13 @@ Analyzes all scripts loaded on the page, separating them into first-party (your
58365846

58375847
// Third Party Section
58385848
console.log("");
5839-
console.group(`%c🌐 Third-Party Scripts (${thirdParty.length})`, "color: #ef4444; font-weight: bold;");
5849+
console.group(
5850+
`%c🌐 Third-Party Scripts (${thirdParty.length})`,
5851+
"color: #ef4444; font-weight: bold;",
5852+
);
58405853

58415854
if (thirdParty.length === 0) {
5842-
console.log(
5843-
"%c✅ No third-party scripts found!",
5844-
"color: #22c55e; font-weight: bold;"
5845-
);
5855+
console.log("%c✅ No third-party scripts found!", "color: #22c55e; font-weight: bold;");
58465856
} else {
58475857
console.log(` Total size: ${formatBytes(thirdMetrics.totalSize)}`);
58485858
console.log(` Render-blocking: ${thirdMetrics.blocking}`);
@@ -5863,7 +5873,9 @@ Analyzes all scripts loaded on the page, separating them into first-party (your
58635873
.sort((a, b) => b[1].size - a[1].size)
58645874
.forEach(([host, data]) => {
58655875
const blockingMark = data.blocking > 0 ? " ⚠️" : "";
5866-
console.log(` ${host}: ${data.count} script(s), ${formatBytes(data.size)}${blockingMark}`);
5876+
console.log(
5877+
` ${host}: ${data.count} script(s), ${formatBytes(data.size)}${blockingMark}`,
5878+
);
58675879
});
58685880

58695881
console.log("");
@@ -5887,23 +5899,38 @@ Analyzes all scripts loaded on the page, separating them into first-party (your
58875899

58885900
if (thirdMetrics.blocking > 0) {
58895901
console.log("");
5890-
console.log("%c⚠️ Render-blocking third-party scripts:", "font-weight: bold; color: #ef4444;");
5902+
console.log(
5903+
"%c⚠️ Render-blocking third-party scripts:",
5904+
"font-weight: bold; color: #ef4444;",
5905+
);
58915906
console.log(" • Load with 'async' or 'defer' attribute");
58925907
console.log(" • Consider lazy-loading after user interaction");
5893-
console.log('%c <script src="..." async></script>', "font-family: monospace; color: #22c55e;");
5908+
console.log(
5909+
'%c <script src="..." async></script>',
5910+
"font-family: monospace; color: #22c55e;",
5911+
);
58945912
}
58955913

58965914
if (thirdMetrics.hosts.length > 3) {
58975915
console.log("");
5898-
console.log(`%c⚠️ ${thirdMetrics.hosts.length} different third-party hosts:`, "font-weight: bold; color: #f59e0b;");
5916+
console.log(
5917+
`%c⚠️ ${thirdMetrics.hosts.length} different third-party hosts:`,
5918+
"font-weight: bold; color: #f59e0b;",
5919+
);
58995920
console.log(" • Each host requires DNS lookup + connection");
59005921
console.log(" • Use <link rel='preconnect'> for critical hosts");
5901-
console.log('%c <link rel="preconnect" href="https://web.dev">', "font-family: monospace; color: #22c55e;");
5922+
console.log(
5923+
'%c <link rel="preconnect" href="https://web.dev">',
5924+
"font-family: monospace; color: #22c55e;",
5925+
);
59025926
}
59035927

59045928
if (thirdMetrics.totalSize > 100 * 1024) {
59055929
console.log("");
5906-
console.log(`%c⚠️ Third-party scripts total ${formatBytes(thirdMetrics.totalSize)}:`, "font-weight: bold; color: #f59e0b;");
5930+
console.log(
5931+
`%c⚠️ Third-party scripts total ${formatBytes(thirdMetrics.totalSize)}:`,
5932+
"font-weight: bold; color: #f59e0b;",
5933+
);
59075934
console.log(" • Audit necessity of each script");
59085935
console.log(" • Consider self-hosting critical scripts");
59095936
console.log(" • Look for lighter alternatives");
@@ -5934,11 +5961,39 @@ Analyzes all scripts loaded on the page, separating them into first-party (your
59345961
thirdPartyBlockingCount: thirdMetrics.blocking,
59355962
thirdPartyHostCount: thirdMetrics.hosts.length,
59365963
},
5937-
items: scripts.map(s => ({ shortName: s.shortName, host: s.host, firstParty: s.firstParty, transferBytes: s.transferSize, durationMs: Math.round(s.duration), renderBlocking: s.renderBlocking })),
5964+
items: scripts.map((s) => ({
5965+
shortName: s.shortName,
5966+
host: s.host,
5967+
firstParty: s.firstParty,
5968+
transferBytes: s.transferSize,
5969+
durationMs: Math.round(s.duration),
5970+
renderBlocking: s.renderBlocking,
5971+
})),
59385972
issues: [
5939-
...(thirdMetrics.blocking > 0 ? [{ severity: "error", message: `${thirdMetrics.blocking} render-blocking third-party script(s)` }] : []),
5940-
...(thirdMetrics.hosts.length > 3 ? [{ severity: "warning", message: `${thirdMetrics.hosts.length} different third-party hosts require separate DNS lookups` }] : []),
5941-
...(thirdMetrics.totalSize > 100 * 1024 ? [{ severity: "warning", message: `Third-party scripts total ${Math.round(thirdMetrics.totalSize / 1024)} KB` }] : []),
5973+
...(thirdMetrics.blocking > 0
5974+
? [
5975+
{
5976+
severity: "error",
5977+
message: `${thirdMetrics.blocking} render-blocking third-party script(s)`,
5978+
},
5979+
]
5980+
: []),
5981+
...(thirdMetrics.hosts.length > 3
5982+
? [
5983+
{
5984+
severity: "warning",
5985+
message: `${thirdMetrics.hosts.length} different third-party hosts require separate DNS lookups`,
5986+
},
5987+
]
5988+
: []),
5989+
...(thirdMetrics.totalSize > 100 * 1024
5990+
? [
5991+
{
5992+
severity: "warning",
5993+
message: `Third-party scripts total ${Math.round(thirdMetrics.totalSize / 1024)} KB`,
5994+
},
5995+
]
5996+
: []),
59425997
],
59435998
};
59445999
})();
@@ -6566,6 +6621,7 @@ Analyzes font loading strategy by comparing preloaded fonts, loaded fonts, and f
65666621
usedNotPreloadedCount: usedNotPreloaded.length,
65676622
},
65686623
items: uniqueLoadedFonts.map(f => ({ family: f.family, weight: f.weight, style: f.style, display: f.display })),
6624+
usedFonts: usedFonts.map(f => ({ family: f.family, weight: f.weight, style: f.style, elements: f.elements })),
65696625
issues: [
65706626
...preloadedNotUsed.map(f => ({ severity: "warning", message: `Preloaded but not used above fold: ${f.name}` })),
65716627
...usedNotPreloaded.map(f => ({ severity: "warning", message: `Used above fold but not preloaded: ${f.family} (${f.weight})` })),

0 commit comments

Comments
 (0)