Skip to content

Commit

Permalink
💚 [prebuild] download releasenotes from live server
Browse files Browse the repository at this point in the history
  • Loading branch information
jxn-30 committed Feb 5, 2024
1 parent 1f0d837 commit 5319704
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package-lock.json
/static/db_access.php
/static/.configs.json
/static/missions/
/static/releasenotes/
/static/.check_request.php
/static/beta.php
/static/lssm-v4.local.user.js
Expand Down
27 changes: 27 additions & 0 deletions prebuild/downloadReleasenotes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { dirname } from 'node:path';
import { mkdir, writeFile } from 'node:fs/promises';

import config from '../src/config';

export default async (): Promise<void> => {
const supportedLanguages = Object.keys(config.games);
const items = supportedLanguages.map(lang => {
return {
from: `https://v4.lss-manager.de/releasenotes/${lang}.json`,
to: `static/releasenotes/${lang}.json`,
};
});

await Promise.all(
items.map(async item => {
console.log(`Downloading ${item.from} to ${item.to}...`);

// ensure target directory exists
await mkdir(dirname(item.to), { recursive: true });

// download file and write it to disk
const response = await fetch(item.from);
await writeFile(item.to, Buffer.from(await response.arrayBuffer()));
})
);
};
4 changes: 3 additions & 1 deletion prebuild/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import buildAPI from './api';
import collectFAIconNames from './collectFAIconNames';
import copyStatic from './copyStatic';
import downloadMissions from './downloadMissions';
import downloadReleasenotes from './downloadReleasenotes';
import { emptyFolder } from './emptyDir';
import getLibraries from './getLibraries';
import setVersion from './setVersion';
Expand All @@ -23,7 +24,8 @@ const timeWrap = async (name: string, fn: () => Promise<unknown> | unknown) => {
await timeWrap('setVersion', setVersion);
await timeWrap('update latest browser versions', updateBrowserVersions);
await timeWrap('emptyDir', () => emptyFolder('./dist'));
await timeWrap('downloadMissions', downloadMissions);
await timeWrap('download missions', downloadMissions);
await timeWrap('download releasenotes', downloadReleasenotes);
await timeWrap('copyStatic', copyStatic);
await timeWrap('build API', buildAPI);
await timeWrap('Collect Third-Party Libraries', getLibraries);
Expand Down

0 comments on commit 5319704

Please sign in to comment.