Skip to content
Draft
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
160 changes: 160 additions & 0 deletions bin/readme
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
#!/usr/bin/env node

import { readFileSync, writeFileSync } from "node:fs";

const token = process.env.GH_TOKEN;
const org = "umts";
const stacks = {
rails: "rails-CC0000?logo=ruby-on-rails",
sinatra: "sinatra-000000?logo=ruby-sinatra",
react: "react-61DAFB?logo=react&logoColor=black",
};

async function fetchRepos() {
const query = `
query($org: String!, $cursor: String) {
organization(login: $org) {
repositories(first: 100, after: $cursor, isArchived: false) {
pageInfo {
hasNextPage
endCursor
}
nodes {
name
visibility
homepageUrl
defaultBranchRef {
name
}
repositoryTopics(first: 100) {
nodes {
topic { name }
}
}
repositoryCustomPropertyValues(first: 100) {
nodes {
propertyName
value
}
}
}
}
}
}
`;
const repos = [];
let cursor = null;
while (true) {
const res = await fetch("https://api.github.com/graphql", {
method: "POST",
headers: {
Authorization: `Bearer ${token}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ query, variables: { org, cursor } }),
});
const json = await res.json();
if (json.errors || !json.data) {
console.error(JSON.stringify(json, null, 2));
process.exit(1);
}
const { nodes, pageInfo } = json.data.organization.repositories;
repos.push(...nodes);
if (!pageInfo.hasNextPage) break;
cursor = pageInfo.endCursor;
}
return repos
.filter((r) =>
r.repositoryCustomPropertyValues.nodes.some(
(p) => p.propertyName === "dashboard" && p.value.includes("true"),
),
)
.sort((r1, r2) => {
const s1 = repoStackOrder(r1);
const s2 = repoStackOrder(r2);
return s1 !== s2 ? s1 - s2 : r1.name.localeCompare(r2.name);
});
}

function repoStackOrder(repo) {
const topics = repo.repositoryTopics.nodes.map((n) => n.topic.name);
const stackKeys = Object.keys(stacks);
const idx = stackKeys.findIndex((k) => topics.includes(k));
return idx === -1 ? stackKeys.length : idx;
}

function renderDashboard(repos) {
const apps = repos.filter((r) => r.homepageUrl);
const appRows = apps
.map(
(repo) => `<tr>
${renderRepoCell(repo)}
${renderSiteCell(repo)}
${renderStackCell(repo)}
</tr>`,
)
.join("\n");

const others = repos.filter((r) => !r.homepageUrl);
const otherRows = others
.map(
(repo) => `<tr>
${renderRepoCell(repo)}
<td></td>
${renderStackCell(repo)}
</tr>`,
)
.join("\n");

return `<table>
<tbody>
<tr>
<th align="left" colspan="3">Applications</th>
</tr>
${appRows}
</tbody>
<tbody>
<tr>
<th align="left" colspan="3">Libraries, Tools & Infrastructure</th>
</tr>
${otherRows}
</tbody>
</table>`
.trim()
.replace(/\s+/g, " ");
}

function renderRepoCell(repo) {
const checksBadge = !repo.defaultBranchRef
? ""
: repo.visibility === "PRIVATE"
? `<img align="right" src="https://img.shields.io/badge/private-999" />`
: `<img align="right" src="https://img.shields.io/github/check-runs/${org}/${repo.name}/${repo.defaultBranchRef.name}?label=" />`;
return `<td>
<a href="https://github.com/${org}/${repo.name}">
<strong>${repo.name}</strong>
</a>
${checksBadge}
</td>`;
}

function renderStackCell(repo) {
const topics = repo.repositoryTopics.nodes.map((n) => n.topic.name);
const match = Object.keys(stacks).find((k) => topics.includes(k));
if (!match) return `<td></td>`;
return `<td align="center">
<img src="https://img.shields.io/badge/${stacks[match]}" />
</td>`;
}

function renderSiteCell(repo) {
return `<td>
<a href="${repo.homepageUrl}">${repo.homepageUrl}</a>
<img align="right" src="https://img.shields.io/website?url=${encodeURIComponent(`${repo.homepageUrl}/up`)}&label=" />
</td>`;
}

const repos = await fetchRepos();
const dashboard = renderDashboard(repos);
const template = readFileSync("profile/README.template.md", "utf-8");
writeFileSync("profile/README.md", template.replace("{{dashboard}}", dashboard));
11 changes: 11 additions & 0 deletions profile/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# UMass Transportation Services

<div align="center"> <table> <tbody> <tr> <th align="left" colspan="3">Applications</th> </tr> <tr> <td> <a href="https://github.com/umts/incidents"> <strong>incidents</strong> </a> <img align="right" src="https://img.shields.io/github/check-runs/umts/incidents/main?label=" /> </td> <td> <a href="https://incidents.pvta.com">https://incidents.pvta.com</a> <img align="right" src="https://img.shields.io/website?url=https%3A%2F%2Fincidents.pvta.com%2Fup&label=" /> </td> <td align="center"> <img src="https://img.shields.io/badge/rails-CC0000?logo=ruby-on-rails" /> </td> </tr> <tr> <td> <a href="https://github.com/umts/jobapps"> <strong>jobapps</strong> </a> <img align="right" src="https://img.shields.io/github/check-runs/umts/jobapps/main?label=" /> </td> <td> <a href="https://transit-jobapps.admin.umass.edu">https://transit-jobapps.admin.umass.edu</a> <img align="right" src="https://img.shields.io/website?url=https%3A%2F%2Ftransit-jobapps.admin.umass.edu%2Fup&label=" /> </td> <td align="center"> <img src="https://img.shields.io/badge/rails-CC0000?logo=ruby-on-rails" /> </td> </tr> <tr> <td> <a href="https://github.com/umts/round-three"> <strong>round-three</strong> </a> <img align="right" src="https://img.shields.io/badge/private-999" /> </td> <td> <a href="https://umasstransit.org">https://umasstransit.org</a> <img align="right" src="https://img.shields.io/website?url=https%3A%2F%2Fumasstransit.org%2Fup&label=" /> </td> <td align="center"> <img src="https://img.shields.io/badge/rails-CC0000?logo=ruby-on-rails" /> </td> </tr> <tr> <td> <a href="https://github.com/umts/screaming-dinosaur"> <strong>screaming-dinosaur</strong> </a> <img align="right" src="https://img.shields.io/github/check-runs/umts/screaming-dinosaur/main?label=" /> </td> <td> <a href="https://umts-oncall.admin.umass.edu">https://umts-oncall.admin.umass.edu</a> <img align="right" src="https://img.shields.io/website?url=https%3A%2F%2Fumts-oncall.admin.umass.edu%2Fup&label=" /> </td> <td align="center"> <img src="https://img.shields.io/badge/rails-CC0000?logo=ruby-on-rails" /> </td> </tr> <tr> <td> <a href="https://github.com/umts/stop-project"> <strong>stop-project</strong> </a> <img align="right" src="https://img.shields.io/github/check-runs/umts/stop-project/main?label=" /> </td> <td> <a href="https://stop-project.admin.umass.edu">https://stop-project.admin.umass.edu</a> <img align="right" src="https://img.shields.io/website?url=https%3A%2F%2Fstop-project.admin.umass.edu%2Fup&label=" /> </td> <td align="center"> <img src="https://img.shields.io/badge/rails-CC0000?logo=ruby-on-rails" /> </td> </tr> <tr> <td> <a href="https://github.com/umts/umaps-rails"> <strong>umaps-rails</strong> </a> <img align="right" src="https://img.shields.io/badge/private-999" /> </td> <td> <a href="https://hub.parking.umass.edu">https://hub.parking.umass.edu</a> <img align="right" src="https://img.shields.io/website?url=https%3A%2F%2Fhub.parking.umass.edu%2Fup&label=" /> </td> <td align="center"> <img src="https://img.shields.io/badge/rails-CC0000?logo=ruby-on-rails" /> </td> </tr> <tr> <td> <a href="https://github.com/umts/umasstransit.rodeo"> <strong>umasstransit.rodeo</strong> </a> <img align="right" src="https://img.shields.io/github/check-runs/umts/umasstransit.rodeo/main?label=" /> </td> <td> <a href="https://umasstransit.rodeo">https://umasstransit.rodeo</a> <img align="right" src="https://img.shields.io/website?url=https%3A%2F%2Fumasstransit.rodeo%2Fup&label=" /> </td> <td align="center"> <img src="https://img.shields.io/badge/rails-CC0000?logo=ruby-on-rails" /> </td> </tr> <tr> <td> <a href="https://github.com/umts/dev-training-web"> <strong>dev-training-web</strong> </a> <img align="right" src="https://img.shields.io/github/check-runs/umts/dev-training-web/main?label=" /> </td> <td> <a href="https://umts-dt.admin.umass.edu">https://umts-dt.admin.umass.edu</a> <img align="right" src="https://img.shields.io/website?url=https%3A%2F%2Fumts-dt.admin.umass.edu%2Fup&label=" /> </td> <td align="center"> <img src="https://img.shields.io/badge/sinatra-000000?logo=ruby-sinatra" /> </td> </tr> <tr> <td> <a href="https://github.com/umts/fleetfocus-api"> <strong>fleetfocus-api</strong> </a> <img align="right" src="https://img.shields.io/github/check-runs/umts/fleetfocus-api/main?label=" /> </td> <td> <a href="https://transit-fuel-api.admin.umass.edu">https://transit-fuel-api.admin.umass.edu</a> <img align="right" src="https://img.shields.io/website?url=https%3A%2F%2Ftransit-fuel-api.admin.umass.edu%2Fup&label=" /> </td> <td align="center"> <img src="https://img.shields.io/badge/sinatra-000000?logo=ruby-sinatra" /> </td> </tr> <tr> <td> <a href="https://github.com/umts/gtfs_cache"> <strong>gtfs_cache</strong> </a> <img align="right" src="https://img.shields.io/github/check-runs/umts/gtfs_cache/main?label=" /> </td> <td> <a href="https://gtfs-cache.admin.umass.edu">https://gtfs-cache.admin.umass.edu</a> <img align="right" src="https://img.shields.io/website?url=https%3A%2F%2Fgtfs-cache.admin.umass.edu%2Fup&label=" /> </td> <td align="center"> <img src="https://img.shields.io/badge/sinatra-000000?logo=ruby-sinatra" /> </td> </tr> <tr> <td> <a href="https://github.com/umts/strap"> <strong>strap</strong> </a> <img align="right" src="https://img.shields.io/github/check-runs/umts/strap/main?label=" /> </td> <td> <a href="https://strap.umasstransit.it">https://strap.umasstransit.it</a> <img align="right" src="https://img.shields.io/website?url=https%3A%2F%2Fstrap.umasstransit.it%2Fup&label=" /> </td> <td align="center"> <img src="https://img.shields.io/badge/sinatra-000000?logo=ruby-sinatra" /> </td> </tr> <tr> <td> <a href="https://github.com/umts/departure-board"> <strong>departure-board</strong> </a> <img align="right" src="https://img.shields.io/github/check-runs/umts/departure-board/main?label=" /> </td> <td> <a href="https://pvta-departures.admin.umass.edu">https://pvta-departures.admin.umass.edu</a> <img align="right" src="https://img.shields.io/website?url=https%3A%2F%2Fpvta-departures.admin.umass.edu%2Fup&label=" /> </td> <td align="center"> <img src="https://img.shields.io/badge/react-61DAFB?logo=react&logoColor=black" /> </td> </tr> <tr> <td> <a href="https://github.com/umts/public-message-board"> <strong>public-message-board</strong> </a> <img align="right" src="https://img.shields.io/github/check-runs/umts/public-message-board/main?label=" /> </td> <td> <a href="https://pvta-public-messages.admin.umass.edu">https://pvta-public-messages.admin.umass.edu</a> <img align="right" src="https://img.shields.io/website?url=https%3A%2F%2Fpvta-public-messages.admin.umass.edu%2Fup&label=" /> </td> <td align="center"> <img src="https://img.shields.io/badge/react-61DAFB?logo=react&logoColor=black" /> </td> </tr> <tr> <td> <a href="https://github.com/umts/BusInfoBoard"> <strong>BusInfoBoard</strong> </a> <img align="right" src="https://img.shields.io/github/check-runs/umts/BusInfoBoard/master?label=" /> </td> <td> <a href="https://umts.github.io/BusInfoBoard">https://umts.github.io/BusInfoBoard</a> <img align="right" src="https://img.shields.io/website?url=https%3A%2F%2Fumts.github.io%2FBusInfoBoard%2Fup&label=" /> </td> <td></td> </tr> </tbody> <tbody> <tr> <th align="left" colspan="3">Libraries, Tools & Infrastructure</th> </tr> <tr> <td> <a href="https://github.com/umts/gtfs-react-hooks"> <strong>gtfs-react-hooks</strong> </a> <img align="right" src="https://img.shields.io/github/check-runs/umts/gtfs-react-hooks/main?label=" /> </td> <td></td> <td align="center"> <img src="https://img.shields.io/badge/react-61DAFB?logo=react&logoColor=black" /> </td> </tr> <tr> <td> <a href="https://github.com/umts/eam-mileage-import"> <strong>eam-mileage-import</strong> </a> <img align="right" src="https://img.shields.io/github/check-runs/umts/eam-mileage-import/main?label=" /> </td> <td></td> <td></td> </tr> <tr> <td> <a href="https://github.com/umts/homebrew-umts-dev"> <strong>homebrew-umts-dev</strong> </a> <img align="right" src="https://img.shields.io/github/check-runs/umts/homebrew-umts-dev/main?label=" /> </td> <td></td> <td></td> </tr> <tr> <td> <a href="https://github.com/umts/pmp"> <strong>pmp</strong> </a> <img align="right" src="https://img.shields.io/github/check-runs/umts/pmp/main?label=" /> </td> <td></td> <td></td> </tr> <tr> <td> <a href="https://github.com/umts/renovate-config"> <strong>renovate-config</strong> </a> <img align="right" src="https://img.shields.io/github/check-runs/umts/renovate-config/main?label=" /> </td> <td></td> <td></td> </tr> <tr> <td> <a href="https://github.com/umts/umts-ansible"> <strong>umts-ansible</strong> </a> <img align="right" src="https://img.shields.io/github/check-runs/umts/umts-ansible/main?label=" /> </td> <td></td> <td></td> </tr> </tbody> </table> </div>

## Resources
- [Azure](https://portal.azure.com/)
- [Confluence](https://umass-amherst.atlassian.net/wiki/spaces/AFIT/overview)
- [GenAI Platform](https://genai.umass.edu)
- [Jenkins](https://jenkins.umass.edu)
- [ServiceNow](https://umass.service-now.com)
- [Sharepoint](https://umass.sharepoint.com/sites/TransportationIT)
11 changes: 11 additions & 0 deletions profile/README.template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# UMass Transportation Services

{{dashboard}}

## Resources
- [Azure](https://portal.azure.com/)
- [Confluence](https://umass-amherst.atlassian.net/wiki/spaces/AFIT/overview)
- [GenAI Platform](https://genai.umass.edu)
- [Jenkins](https://jenkins.umass.edu)
- [ServiceNow](https://umass.service-now.com)
- [Sharepoint](https://umass.sharepoint.com/sites/TransportationIT)