You've already forked AstralRinth
forked from didirus/AstralRinth
Add generator plugin
This commit is contained in:
24
src/package/plugins/generator/outputs/gameVersions.ts
Normal file
24
src/package/plugins/generator/outputs/gameVersions.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { fetch } from 'undici';
|
||||
import { promises as fs } from 'fs';
|
||||
import cliProgress from 'cli-progress';
|
||||
|
||||
export async function gameVersions(API_URL: string) {
|
||||
const progressBar = new cliProgress.SingleBar({
|
||||
format: 'Generating game versions | {bar} | {percentage}%',
|
||||
barCompleteChar: '\u2588',
|
||||
barIncompleteChar: '\u2591',
|
||||
hideCursor: true,
|
||||
});
|
||||
|
||||
progressBar.start(2, 0);
|
||||
|
||||
const gameVersions = await (await fetch(API_URL + 'tag/game_version')).json();
|
||||
|
||||
progressBar.increment();
|
||||
|
||||
// Write JSON file
|
||||
await fs.writeFile('./generated/gameVersions.json', JSON.stringify(gameVersions));
|
||||
progressBar.increment();
|
||||
|
||||
progressBar.stop();
|
||||
}
|
||||
Reference in New Issue
Block a user