Skip to content
Merged
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
51 changes: 50 additions & 1 deletion public/common/scorecard.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,56 @@
// Import Third-party Dependencies
import { getJSON } from "@nodesecure/vis-network";

/**
* @typedef {Object} ScorecardCheckDocumentation
* @property {string} short
* @property {string} url
*/

/**
* @typedef {Object} ScorecardCheck
* @property {string} name
* @property {number} score
* @property {string} reason
* @property {string[] | null} details
* @property {ScorecardCheckDocumentation} documentation
*/

/**
* @typedef {Object} ScorecardRepo
* @property {string} name
* @property {string} commit
*/

/**
* @typedef {Object} ScorecardTool
* @property {string} version
* @property {string} commit
*/

/**
* @typedef {Object} ScorecardData
* @property {string} date
* @property {ScorecardRepo} repo
* @property {ScorecardTool} scorecard
* @property {number} score
* @property {ScorecardCheck[]} checks
*/

/**
* @param {!string} repoName
* @param {string} platform
* @returns {Promise<ScorecardData | null>}
*/
export async function fetchScorecardData(repoName, platform = "github.com") {
try {
const { data } = (await getJSON(`/scorecard/${repoName}?platform=${platform}`));
/** @type any responseRaw */
const responseRaw = (await getJSON(`/scorecard/${repoName}?platform=${platform}`));

/** @type {{ data: ScorecardData }} */
const response = responseRaw;

const data = response.data;
if (!data) {
return null;
}
Expand All @@ -20,6 +64,11 @@ export async function fetchScorecardData(repoName, platform = "github.com") {
}
}

/**
* @param {string} repoName
* @param {string} platform
* @returns {string}
*/
export function getScorecardLink(
repoName,
platform
Expand Down
Loading