Skip to content

Commit

Permalink
Support test configs
Browse files Browse the repository at this point in the history
This adds support for test configs, to make it easier to test config
changes without affecting the live service.
  • Loading branch information
Zarel committed Jul 20, 2024
1 parent 09c2483 commit c2ec423
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
9 changes: 9 additions & 0 deletions build-tools/swap-configs
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions build-tools/update
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions play.pokemonshowdown.com/config/config-test.js

0 comments on commit c2ec423

Please sign in to comment.