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

Produce code.json. #25

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
21 changes: 19 additions & 2 deletions site/_data/repos.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,23 @@ async function reposForOrg(org) {
isArchived
isFork
isEmpty
licenseInfo {
spdxId
}
repositoryTopics(first: 100) {
nodes {
topic {
name
}
}
}
languages(first: 100) {
nodes {
name
}
}
createdAt
pushedAt
}
pageInfo {
endCursor
Expand Down Expand Up @@ -252,8 +269,8 @@ const manualOverrides = {
"Bonnie is a software tool that allows electronic clinical quality measure (eCQM) developers to test and verify the behavior of their eCQM logic.",
},
"projectcypress/cypress": {
category: "tools"
}
category: "tools",
},
}

module.exports = async () => {
Expand Down
54 changes: 54 additions & 0 deletions site/codejson.11ty.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
class CodeJson {
data() {
return {
permalink: "code.json",
}
}

render({ repos }) {
return JSON.stringify({
version: "2.0.0",
measurementType: {},
agency: "HHS",
releases: repos.repos.map((repo) => ({
name: repo.name,
organization: "CMS",
description: repo.description || "",
permissions: {
usageType: "openSource",
licenses:
repo.licenseInfo?.spdxId && repo.licenseInfo.spdxId != "NOASSERTION"
? [{ name: repo.licenseInfo.spdxId }]
: null,
},
tags: (repo.category ? [repo.category] : []).concat(
repo.repositoryTopics.nodes.map((node) => node.topic.name)
),
contact: { email: "[email protected]" },
vcs: "git",
repositoryURL: `https://github.com/${repo.owner.login}/${repo.name}.git`,
homepageURL:
repo.homepageUrl && repo.homepageUrl != ""
? repo.homepageUrl
: undefined,
langauges: repo.languages.nodes.map((x) => x.name),
// supposedly a required field; most others seem to just be reporting 0 here
// ideally we would be making a calculation from lines of code
laborHours: 0.0,
relatedCode:
repo.otherRepos &&
repo.otherRepos.map((other) => ({
name: other,
URL: `https://github.com/${other}`,
isGovernmentRepo: true,
})),
date: {
created: repo.createdAt,
lastModified: repo.pushedAt,
},
})),
})
}
}

module.exports = CodeJson