Skip to content

Commit

Permalink
feat: add scorecard visualizer external link
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreDemailly committed Sep 13, 2023
1 parent 65144fa commit e085566
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 2 deletions.
12 changes: 10 additions & 2 deletions esbuild.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,15 @@ await esbuild.build({
});

await Promise.all([
...["github-mark.png", "github-black.png", "npm-icon.svg", "nodejs.png", "snyk.png", "sonatype.png", "avatar-default.png"]
.map((name) => fs.copyFile(path.join(kImagesDir, name), path.join(kOutDir, name))),
...[
"github-mark.png",
"github-black.png",
"npm-icon.svg",
"nodejs.png",
"snyk.png",
"sonatype.png",
"avatar-default.png",
"ext-link.svg"
].map((name) => fs.copyFile(path.join(kImagesDir, name), path.join(kOutDir, name))),
fs.copyFile(path.join(kPublicDir, "favicon.ico"), path.join(kOutDir, "favicon.ico"))
]);
12 changes: 12 additions & 0 deletions public/css/components/package-info.css
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,18 @@ section#package-info ul li.clickable:hover {
font-size: 18px;
}

#pan-scorecard .score-header .visualizer a {
color: #cfd8dc;
margin-top: 6px;
}

#pan-scorecard .score-header .visualizer .logo {
vertical-align: sub;
width: 21px;
/* https://codepen.io/sosuke/pen/Pjoqqp */
filter: invert(99%) sepia(36%) saturate(748%) hue-rotate(170deg) brightness(93%) contrast(84%);
}

#pan-scorecard .check {
display: flex;
height: 26px;
Expand Down
1 change: 1 addition & 0 deletions public/img/ext-link.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions public/js/components/package.info.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { UnpkgCodeFetcher } from "./unpkgCodeFetcher.js";

const kSocketDevLink = 'https://socket.dev/npm/package/';
const kSnykAdvisorLink = 'https://snyk.io/advisor/npm-package/';
const kScorecardVisualizer = (repo) => `https://kooltheba.github.io/openssf-scorecard-api-visualizer/#/projects/github.com/${repo}`;

export class PackageInfo {
static DOMElementName = "package-info";
Expand Down Expand Up @@ -751,6 +752,7 @@ export class PackageInfo {

document.getElementById('ossf-score').innerText = score;
document.getElementById('head-score').innerText = score;
document.querySelector(".score-header .visualizer a").setAttribute('href', kScorecardVisualizer(repoName));

const checksNodes = checksContainerElement.childNodes;
checksNodes.forEach((check, checkKey) => {
Expand Down
3 changes: 3 additions & 0 deletions views/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,9 @@ <h1><i class="icon-cog"></i>General</h1>
<span class="score-value">
<span id="head-score"></span>/10
</span>
<span class="visualizer">
<a><img src="ext-link.svg" class="logo"> OpenSSF Scorecard Monitor Visualizer</a>
</span>
</div>
</div>
</div>
Expand Down

0 comments on commit e085566

Please sign in to comment.