feat: remove games.txt and replace it with an in-code solution (#407)

* feat: remove games.txt and replace it with an in-code solution

* docs: update changelog

* chore: add todo comment regarding weird game ids to rename

* fix: generate games list md file

* fix: gemerate games list file to alphabetical id order

* fix: update changelog to note removal of some game ids and add geneshift alternative
This commit is contained in:
CosminPerRam 2023-11-19 02:59:31 +02:00 committed by GitHub
parent 2fb9f507e2
commit ce4cddb87f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 2456 additions and 468 deletions

View file

@ -1,14 +1,10 @@
#!/usr/bin/env node
import * as fs from 'node:fs'
import GameResolver from '../lib/GameResolver.js'
import { games } from '../lib/games.js'
import { fileURLToPath } from 'node:url'
import { dirname } from 'node:path'
const gameResolver = new GameResolver()
const generated = gameResolver.printReadme()
const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)
@ -18,6 +14,32 @@ const readme = fs.readFileSync(readmeFilename, { encoding: 'utf8' })
const markerTop = '<!--- BEGIN GENERATED GAMES -->'
const markerBottom = '<!--- END GENERATED GAMES -->'
const sortedGamesIds = Object.keys(games).sort()
const sortedGames = {}
sortedGamesIds.forEach(key => {
sortedGames[key] = games[key]
})
let generated = ''
generated += '| GameDig Type ID | Name | See Also\n'
generated += '|---|---|---\n'
for (const id in sortedGames) {
const game = sortedGames[id]
generated += '| ' + id.padEnd(10, ' ') + ' | ' + game.name
const notes = []
if (game?.extra?.doc_notes) {
notes.push('[Notes](#' + game.extra.doc_notes + ')')
}
if (game.options.protocol === 'valve') {
notes.push('[Valve Protocol](#valve)')
}
if (notes.length) {
generated += ' | ' + notes.join(', ')
}
generated += '\n'
}
let start = readme.indexOf(markerTop)
start += markerTop.length
const end = readme.indexOf(markerBottom)