mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-04 23:39:22 +00:00
[NAK_CVR_Mods] Experiment
This commit is contained in:
parent
364de89b30
commit
0564de3ebf
2 changed files with 89 additions and 0 deletions
55
.github/scripts/update-modlist.js
vendored
Normal file
55
.github/scripts/update-modlist.js
vendored
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
const ROOT = '.';
|
||||||
|
const EXPERIMENTAL = '.Experimental';
|
||||||
|
const README_PATH = 'README.md';
|
||||||
|
const MARKER_START = '<!-- BEGIN MOD LIST -->';
|
||||||
|
const MARKER_END = '<!-- END MOD LIST -->';
|
||||||
|
|
||||||
|
function getModFolders(baseDir) {
|
||||||
|
const entries = fs.readdirSync(baseDir, { withFileTypes: true });
|
||||||
|
return entries
|
||||||
|
.filter(entry => entry.isDirectory())
|
||||||
|
.map(entry => path.join(baseDir, entry.name))
|
||||||
|
.filter(dir => fs.existsSync(path.join(dir, 'README.md')));
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatTable(mods, baseDir) {
|
||||||
|
if (mods.length === 0) return '';
|
||||||
|
|
||||||
|
let rows = mods.map(modPath => {
|
||||||
|
const modName = path.basename(modPath);
|
||||||
|
const readmeLink = path.join(modPath, 'README.md');
|
||||||
|
const zipLink = path.join(modPath, `${modName}.zip`);
|
||||||
|
return `| [${modName}](${readmeLink}) | [Download](${zipLink}) |`;
|
||||||
|
});
|
||||||
|
|
||||||
|
return [
|
||||||
|
`### ${baseDir === EXPERIMENTAL ? 'Experimental Mods' : 'Released Mods'}`,
|
||||||
|
'',
|
||||||
|
'| Name | Download |',
|
||||||
|
'|------|----------|',
|
||||||
|
...rows,
|
||||||
|
''
|
||||||
|
].join('\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateReadme(modListSection) {
|
||||||
|
const readme = fs.readFileSync(README_PATH, 'utf8');
|
||||||
|
const before = readme.split(MARKER_START)[0];
|
||||||
|
const after = readme.split(MARKER_END)[1];
|
||||||
|
|
||||||
|
const newReadme = `${before}${MARKER_START}\n\n${modListSection}\n${MARKER_END}${after}`;
|
||||||
|
fs.writeFileSync(README_PATH, newReadme);
|
||||||
|
}
|
||||||
|
|
||||||
|
const mainMods = getModFolders(ROOT).filter(dir => !dir.startsWith(EXPERIMENTAL));
|
||||||
|
const experimentalMods = getModFolders(EXPERIMENTAL);
|
||||||
|
|
||||||
|
const tableContent = [
|
||||||
|
formatTable(mainMods, ROOT),
|
||||||
|
formatTable(experimentalMods, EXPERIMENTAL)
|
||||||
|
].join('\n');
|
||||||
|
|
||||||
|
updateReadme(tableContent);
|
34
.github/workflows/update-modlist.yml
vendored
Normal file
34
.github/workflows/update-modlist.yml
vendored
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
name: Update Mod List in README
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
paths:
|
||||||
|
- '**/README.md'
|
||||||
|
- '.github/workflows/update-modlist.yml'
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
update-readme:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Set up Node.js
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: '20'
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm install gray-matter
|
||||||
|
|
||||||
|
- name: Generate mod list
|
||||||
|
run: node .github/scripts/update-modlist.js
|
||||||
|
|
||||||
|
- name: Commit changes
|
||||||
|
run: |
|
||||||
|
git config user.name "github-actions[bot]"
|
||||||
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
|
git add README.md
|
||||||
|
git commit -m "[NAK_CVR_Mods] Update mod list in README" || echo "No changes to commit"
|
||||||
|
git push
|
Loading…
Add table
Add a link
Reference in a new issue