mirror of
https://github.com/IvarK/AntimatterDimensionsSourceCode.git
synced 2024-11-21 11:31:46 +00:00
Implement commit watcher without GitHub API dependency
This commit is contained in:
parent
2d918dbb19
commit
2b86d687f0
17
build/post-build.js
Normal file
17
build/post-build.js
Normal file
@ -0,0 +1,17 @@
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const proc = require("child_process");
|
||||
|
||||
function executeCommand(command) {
|
||||
return proc.execSync(command).toString().trim();
|
||||
}
|
||||
|
||||
const commit = {
|
||||
sha: executeCommand("git rev-parse HEAD"),
|
||||
message: executeCommand("git log -1 --pretty=%B"),
|
||||
author: executeCommand("git log -1 --pretty=format:%an")
|
||||
};
|
||||
|
||||
const json = JSON.stringify(commit);
|
||||
|
||||
fs.writeFileSync(path.resolve(__dirname, "../dist/commit.json"), json);
|
@ -1,4 +1,3 @@
|
||||
import { isLocalEnvironment } from "./core/devtools.js";
|
||||
import { playFabLogin } from "./core/playfab.js";
|
||||
import { DC } from "./core/constants.js";
|
||||
|
||||
@ -245,36 +244,6 @@ export function gainedInfinities() {
|
||||
return infGain;
|
||||
}
|
||||
|
||||
// TODO: remove before release
|
||||
if (!isLocalEnvironment()) {
|
||||
let commit;
|
||||
setInterval(() => {
|
||||
const url = "https://api.github.com/repos/IvarK/IToughtAboutCurseWordsButThatWouldBeMeanToOmsi/commits/master";
|
||||
const headers = new Headers();
|
||||
// Yes, this is my GitHub API key for reading private repo details
|
||||
headers.append("Authorization", `Basic ${btoa("WaitingIdly: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")}`);
|
||||
|
||||
fetch(url, { method: "GET", headers })
|
||||
.then(response => response.json())
|
||||
.then(json => {
|
||||
if (commit === undefined) {
|
||||
commit = json.sha;
|
||||
return;
|
||||
}
|
||||
if (commit === json.sha) return;
|
||||
// GH Pages need some time to get rebuilt, so show message after 60 seconds
|
||||
setTimeout(() => {
|
||||
Modal.message.show(
|
||||
"Refresh the page (game will be saved), we've got new stuff: " +
|
||||
`"${json.commit.message}" by ${json.author.login}`,
|
||||
updateRefresh,
|
||||
true
|
||||
);
|
||||
}, 60000);
|
||||
});
|
||||
}, 60000);
|
||||
}
|
||||
|
||||
export function updateRefresh() {
|
||||
GameStorage.save(true);
|
||||
location.reload(true);
|
||||
|
@ -2,7 +2,7 @@
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"serve": "vue-cli-service serve",
|
||||
"build": "vue-cli-service build",
|
||||
"build": "vue-cli-service build && node build/post-build.js",
|
||||
"lint": "vue-cli-service lint"
|
||||
},
|
||||
"dependencies": {
|
||||
|
32
src/commit-watcher.js
Normal file
32
src/commit-watcher.js
Normal file
@ -0,0 +1,32 @@
|
||||
// TODO: remove before release
|
||||
export function watchLatestCommit() {
|
||||
if (isLocalEnvironment()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const url = "commit.json";
|
||||
let current;
|
||||
|
||||
function watch() {
|
||||
fetch(url, { method: "GET" })
|
||||
.then(response => response.json())
|
||||
.then(json => {
|
||||
if (json === undefined) {
|
||||
return;
|
||||
}
|
||||
current = current ?? json.sha;
|
||||
if (current === json.sha) {
|
||||
return;
|
||||
}
|
||||
|
||||
Modal.message.show(
|
||||
"Refresh the page (game will be saved), we've got new stuff: " +
|
||||
`"${json.message}" by ${json.author}`,
|
||||
updateRefresh,
|
||||
true
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
setInterval(watch, 60000);
|
||||
}
|
51
src/main.js
51
src/main.js
@ -1,47 +1,6 @@
|
||||
function mergeIntoGlobal(object) {
|
||||
for (const key in object) {
|
||||
const value = object[key];
|
||||
const existingValue = window[key];
|
||||
if (existingValue !== undefined) {
|
||||
throw `Property ${key} already exists in global context`;
|
||||
}
|
||||
import "./merge-globals";
|
||||
import { init } from "../javascripts/game";
|
||||
import { watchLatestCommit } from "@/commit-watcher";
|
||||
|
||||
window[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
import * as Utils from "../javascripts/core/utils.js";
|
||||
mergeIntoGlobal(Utils);
|
||||
|
||||
import "../javascripts/components";
|
||||
|
||||
import * as GameDB from "../javascripts/core/secret-formula";
|
||||
mergeIntoGlobal(GameDB);
|
||||
|
||||
// Start of bullshit
|
||||
|
||||
// Hevi, why
|
||||
import * as AutomatorBlockEditor from "../javascripts/components/reality/automator/automator-block-editor.js";
|
||||
mergeIntoGlobal(AutomatorBlockEditor);
|
||||
|
||||
// Hevi, whyy
|
||||
import * as AutomatorBlocks from "../javascripts/components/reality/automator/automator-blocks.js";
|
||||
mergeIntoGlobal(AutomatorBlocks);
|
||||
|
||||
// Garnet, nooo
|
||||
import * as AutomatorTextEditor from "../javascripts/components/reality/automator/automator-text-editor.js";
|
||||
mergeIntoGlobal(AutomatorTextEditor);
|
||||
|
||||
// Spec, reeee
|
||||
import * as PerksTab from "../javascripts/components/reality/perks-tab.js";
|
||||
mergeIntoGlobal(PerksTab);
|
||||
|
||||
// End of bullshit
|
||||
|
||||
import * as core from "../javascripts/core/globals.js";
|
||||
mergeIntoGlobal(core);
|
||||
|
||||
import * as game from "../javascripts/game.js";
|
||||
mergeIntoGlobal(game);
|
||||
|
||||
game.init();
|
||||
init();
|
||||
watchLatestCommit();
|
||||
|
45
src/merge-globals.js
Normal file
45
src/merge-globals.js
Normal file
@ -0,0 +1,45 @@
|
||||
function mergeIntoGlobal(object) {
|
||||
for (const key in object) {
|
||||
const value = object[key];
|
||||
const existingValue = window[key];
|
||||
if (existingValue !== undefined) {
|
||||
throw `Property ${key} already exists in global context`;
|
||||
}
|
||||
|
||||
window[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
import * as Utils from "../javascripts/core/utils";
|
||||
mergeIntoGlobal(Utils);
|
||||
|
||||
import "../javascripts/components";
|
||||
|
||||
import * as GameDB from "../javascripts/core/secret-formula";
|
||||
mergeIntoGlobal(GameDB);
|
||||
|
||||
// Start of bullshit
|
||||
|
||||
// Hevi, why
|
||||
import * as AutomatorBlockEditor from "../javascripts/components/reality/automator/automator-block-editor";
|
||||
mergeIntoGlobal(AutomatorBlockEditor);
|
||||
|
||||
// Hevi, whyy
|
||||
import * as AutomatorBlocks from "../javascripts/components/reality/automator/automator-blocks";
|
||||
mergeIntoGlobal(AutomatorBlocks);
|
||||
|
||||
// Garnet, nooo
|
||||
import * as AutomatorTextEditor from "../javascripts/components/reality/automator/automator-text-editor";
|
||||
mergeIntoGlobal(AutomatorTextEditor);
|
||||
|
||||
// Spec, reeee
|
||||
import * as PerksTab from "../javascripts/components/reality/perks-tab";
|
||||
mergeIntoGlobal(PerksTab);
|
||||
|
||||
// End of bullshit
|
||||
|
||||
import * as core from "../javascripts/core/globals";
|
||||
mergeIntoGlobal(core);
|
||||
|
||||
import * as game from "../javascripts/game";
|
||||
mergeIntoGlobal(game);
|
Loading…
Reference in New Issue
Block a user