2020-07-03 06:55:48 +09:00
|
|
|
const fs = require('fs');
|
|
|
|
const path = require('path');
|
|
|
|
|
|
|
|
const JSON_FILE_PATH = path.join(__dirname, '../site/.vuepress/data/gameVersions.json');
|
|
|
|
const INJECTION_TAG = '<!-- injectionpoint -->';
|
|
|
|
|
2020-07-03 10:42:57 +09:00
|
|
|
const locales = require(path.join(__dirname, '../site/.vuepress/i18n/locales.json'));
|
2020-07-03 08:21:52 +09:00
|
|
|
|
2020-07-03 06:55:48 +09:00
|
|
|
// Load the current json configuration
|
|
|
|
const codeJson = JSON.parse(fs.readFileSync(JSON_FILE_PATH));
|
|
|
|
|
|
|
|
codeJson.forEach((gameVersion) => {
|
|
|
|
gameVersion.codes = [];
|
|
|
|
});
|
|
|
|
|
|
|
|
// Save the codeJSON with the cleared codes
|
|
|
|
fs.writeFileSync(JSON_FILE_PATH, JSON.stringify(codeJson));
|
|
|
|
|
2020-07-03 08:21:52 +09:00
|
|
|
Object.keys(locales).forEach((locale) => {
|
|
|
|
// Clear the code reference
|
2021-11-05 10:29:56 +09:00
|
|
|
const filePath = path.join(__dirname, `../site/${locale.trim()}/code-reference/index.md`);
|
2020-07-03 06:55:48 +09:00
|
|
|
|
2021-11-05 10:29:56 +09:00
|
|
|
// Get the current reference
|
|
|
|
const reference = fs.readFileSync(filePath).toString();
|
2020-07-03 06:55:48 +09:00
|
|
|
|
2021-11-05 10:29:56 +09:00
|
|
|
if (!reference.includes(INJECTION_TAG)) {
|
|
|
|
throw new Error(`No injection tag found in ${locale.trim()}/code-reference/index.md`);
|
|
|
|
}
|
2020-07-03 06:55:48 +09:00
|
|
|
|
2021-11-05 10:29:56 +09:00
|
|
|
// Clear everything after the injection tag
|
|
|
|
let fileContent = reference.split(INJECTION_TAG)[0] + INJECTION_TAG;
|
2020-07-03 06:55:48 +09:00
|
|
|
|
2021-11-05 10:29:56 +09:00
|
|
|
// Save the reference file
|
|
|
|
fs.writeFileSync(filePath, fileContent);
|
2020-07-03 08:21:52 +09:00
|
|
|
});
|