Removed old script and template

This commit is contained in:
Sammy Hori
2024-11-17 21:48:11 +00:00
parent b531c33c6b
commit 445e53bc48
2 changed files with 0 additions and 114 deletions

View File

@@ -1,87 +0,0 @@
const fs = require('fs');
const data = require('../../data.json');
const TPL_FILE = './.github/tpl.md';
const TARGET = './README.md';
const tpl = getTemplate(TPL_FILE);
const categories = {};
data.repositories.sort((a, b) => {
const nameA = a.name.toUpperCase();
const nameB = b.name.toUpperCase();
if (nameA < nameB) {
return -1;
}
if (nameA > nameB) {
return 1;
}
return 0;
}).forEach(repo =>
repo.technologies.forEach(tech => {
if (!categories.hasOwnProperty(tech)) {
categories[tech] = [];
}
categories[tech].push(repo);
}))
const sortedCategories = Object.fromEntries(Object.entries(categories).sort((a, b) => {
const nameA = a[0].toUpperCase();
const nameB = b[0].toUpperCase();
if (nameA < nameB) {
return -1;
}
if (nameA > nameB) {
return 1;
}
return 0;
}));
const toc = Object.keys(sortedCategories)
.map(t => `- [${t}](#${data.technologies[t] || t.toLowerCase()})`)
.join('\n');
const content = Object.keys(sortedCategories)
.map(category => {
const repos = sortedCategories[category].map(repo => `- [${repo.name}](${repo.link}) _(label: ${repo.label || 'n/a'})_ <br> ${repo.description}`).join('\n')
return `## ${category}\n\n${repos}\n`
}).join('\n');
const sponsorList = data.sponsors.map(sponsor => `<td align="center"><a href="${sponsor.link}"><img src="${sponsor.image}" width="60px;" alt=""/><br/><sub><b>${sponsor.name}</b></sub></a></td>`)
const sponsorRows = Math.ceil(sponsorList.length / 6);
let sponsors = '';
for (let i = 1; i <= sponsorRows; i++) {
sponsors += '<tr>';
for(let j = 0; j < 6; j++) {
if (sponsorList.length > i*j) {
sponsors += sponsorList[i*j];
} else if (sponsorRows > 1) {
sponsors += '<td></td>'
}
}
sponsors += '</tr>';
}
sponsors = `<table>${sponsors}</table>`
saveFile(TARGET, render(tpl, { toc, content, sponsors }));
function getTemplate(file) {
return fs.readFileSync(file).toString();
}
function saveFile(file, contents) {
return fs.writeFileSync(file, contents);
}
function render(template, variables) {
Object
.entries(variables)
.forEach(([key, value]) => {
template = template.replace(new RegExp(`<% ${key} %>`, 'g'), value);
});
return template;
}

27
.github/tpl.md vendored
View File

@@ -1,27 +0,0 @@
# Awesome First PR Opportunities [![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/sindresorhus/awesome)
Inspired by [First Timers Only](https://kentcdodds.com/blog/first-timers-only) blog post.
If you are a maintainer of open-source projects, add the label `first-timers-only` (or similar) to your project and list it here so that people can find it.
If you are not a programmer but would like to contribute, check out the [Awesome for non-programmers](https://github.com/szabgab/awesome-for-non-programmers) list.
## Table of Contents:
<% toc %>
<% content %>
## Contribute
Contributions are welcome! See the [contributing guidelines](CONTRIBUTING.md).
## Thanks to GitHub Sponsors
<% sponsors %>
## License
[![CC0](http://i.creativecommons.org/p/zero/1.0/88x31.png)](http://creativecommons.org/publicdomain/zero/1.0/)
To the extent possible under law, the author has waived all copyrights and related or neighboring rights to this work.