Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add scorecard visualizer external link #235

Merged
merged 1 commit into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 target="_blank"><img src="ext-link.svg" class="logo"> OpenSSF Scorecard Monitor Visualizer</a>
</span>
</div>
</div>
</div>
Expand Down