Skip to content

Commit

Permalink
auto-reload on new release
Browse files Browse the repository at this point in the history
  • Loading branch information
L3P3 committed Jan 6, 2024
1 parent 1fd2225 commit ae98b68
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
10 changes: 8 additions & 2 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import cssnano from 'cssnano';
const GCC_COMMAND = './node_modules/.bin/google-closure-compiler --';
const TMP_FILE = '/tmp/app.js';

const prod = !!process.env.CI;
const {version} = JSON.parse(
await readFile('./package.json', 'utf-8')
);
Expand Down Expand Up @@ -56,7 +57,12 @@ async function build_css() {
}

async function build_js() {
await env_set(version, false, '/api/minicraft/', '/static/minicraft/worlds/');
await env_set(
prod ? version : 'dev',
false,
prod ? '/api/minicraft/' : '//l3p3.de/api/minicraft/',
prod ? '/static/minicraft/worlds/' : '//l3p3.de/static/minicraft/worlds/'
);

console.log('js pass 1...');
console.log((await exec(
Expand Down Expand Up @@ -120,7 +126,7 @@ if(
await exec('mkdir -p ./dist');
await exec('rm ./dist/*');

console.log(`build ${version}...`);
console.log(`build ${version} (${prod ? 'production' : 'dev'})...`);

try {
await Promise.all([
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "minicraft",
"version": "0.9.4",
"version": "0.9.5",
"description": "voxel-based 3d game, written in javascript",
"homepage": "https://l3p3.de/minicraft",
"repository": {
Expand Down
1 change: 1 addition & 0 deletions src/externs.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ var TYPE_WORLD_API;
rank: number,
},
worlds: !Array<TYPE_WORLD_LISTING_REMOTE>,
version_latest: string,
}}
*/
var TYPE_RESPONSE_INITIAL;
7 changes: 7 additions & 0 deletions src/game/c_menu_start.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ export default function MenuStart({
const json = await response.json();
if (!initial) return /** @type {!Array<TYPE_WORLD_LISTING_REMOTE>} */ (json);
const json_initial = /** @type {TYPE_RESPONSE_INITIAL} */ (json);
if (
VERSION !== 'dev' &&
json_initial.version_latest !== VERSION
) {
location.reload();
return null;
}
defer();
actions.account_set(json_initial.account);
return json_initial.worlds;
Expand Down

0 comments on commit ae98b68

Please sign in to comment.