Support test configs

This adds support for test configs, to make it easier to test config
changes without affecting the live service.
This commit is contained in:
Guangcong Luo 2024-07-20 22:33:16 +00:00
parent 09c248382a
commit c2ec42310c
4 changed files with 18 additions and 0 deletions

1
.gitignore vendored
View File

@ -10,6 +10,7 @@ npm-debug.log
/play.pokemonshowdown.com/audio/
/play.pokemonshowdown.com/index.php
/play.pokemonshowdown.com/index.html
/play.pokemonshowdown.com/index-test.html
/play.pokemonshowdown.com/preactalpha.html
/play.pokemonshowdown.com/crossprotocol.html
/play.pokemonshowdown.com/data/

9
build-tools/swap-configs Executable file
View File

@ -0,0 +1,9 @@
#!/usr/bin/env bash
cd "$(dirname "$0")"
cd ..
cp config/config.js config/config.js.old
cp config/head-custom.html config/head-custom.html.old
mv -f config/config-test.js config/config.js
mv -f config/head-custom-test.html config/head-custom.html
mv -i config/config.js.old config/config-test.js
mv -i config/head-custom.html.old config/head-custom-test.html

View File

@ -197,11 +197,18 @@ try {
indexContents = indexContents.replace(/<!-- newsid -->/g, newsid);
indexContents = indexContents.replace(/<!-- news -->/g, news);
let indexContents2 = '';
try {
let indexContentsOld = indexContents;
indexContents = indexContents.replace(/<!-- head custom -->/g, '' + fs.readFileSync('config/head-custom.html'));
indexContents2 = indexContentsOld.replace(/<!-- head custom -->/g, '' + fs.readFileSync('config/head-custom-test.html'));
indexContents2 = indexContents2.replace(/src="\/\/play.pokemonshowdown.com\/config\/config.js\?[a-z0-9]*"/, 'src="//play.pokemonshowdown.com/config/config-test.js?3"');
} catch (e) {}
fs.writeFileSync('play.pokemonshowdown.com/index.html', indexContents);
if (indexContents2) {
fs.writeFileSync('play.pokemonshowdown.com/index-test.html', indexContents2);
}
fs.writeFileSync('play.pokemonshowdown.com/preactalpha.html', preactIndexContents);
fs.writeFileSync('play.pokemonshowdown.com/crossprotocol.html', crossprotocolContents);
fs.writeFileSync('play.pokemonshowdown.com/js/replay-embed.js', replayEmbedContents);

View File

@ -0,0 +1 @@
../../config/config-test.js