diff --git a/.gitignore b/.gitignore index b6d109a..371f884 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ node_modules/ test-results/ var/ .npmrc +src/version.txt \ No newline at end of file diff --git a/Makefile b/Makefile index 1a17a00..fd8d2ae 100644 --- a/Makefile +++ b/Makefile @@ -3,10 +3,13 @@ all: format build restart-server: docker-compose restart -build: +write-version: + @echo $(shell date +'%Y%m%d-%H.%M.%S') > ./src/version.txt + +build: write-version tools/npm run-script build:dev -build-min: +build-min: write-version tools/npm run-script build format: diff --git a/src/Dashboard.ts b/src/Dashboard.ts index 8b66ef1..5fb3686 100644 --- a/src/Dashboard.ts +++ b/src/Dashboard.ts @@ -7,9 +7,11 @@ import { Command } from './Common'; import TaskQueueRenderer from './TaskQueueRenderer'; export default class Dashboard { + private readonly version: string; private scheduler: Scheduler; - constructor(scheduler: Scheduler) { + constructor(version: string, scheduler: Scheduler) { + this.version = version; this.scheduler = scheduler; } @@ -19,7 +21,7 @@ export default class Dashboard { await sleepShort(); - markPage('Dashboard'); + markPage('Dashboard', this.version); new TaskQueueRenderer().render(this.scheduler.taskState()); if (p.pathname === '/build.php') { diff --git a/src/Scheduler.ts b/src/Scheduler.ts index d9740cd..51d54fd 100644 --- a/src/Scheduler.ts +++ b/src/Scheduler.ts @@ -9,17 +9,19 @@ import { Args, Command } from './Common'; import TaskQueueRenderer from './TaskQueueRenderer'; export default class Scheduler { + private readonly version: string; private taskQueue: TaskQueue; private actionQueue: ActionQueue; - constructor() { + constructor(version: string) { + this.version = version; this.taskQueue = new TaskQueue(); this.actionQueue = new ActionQueue(); } async run() { await sleepShort(); - markPage('Executor'); + markPage('Executor', this.version); new TaskQueueRenderer().render(this.taskQueue.state()); while (true) { await sleepLong(); diff --git a/src/index.ts b/src/index.js similarity index 64% rename from src/index.ts rename to src/index.js index 5885e82..ce74ab3 100644 --- a/src/index.ts +++ b/src/index.js @@ -1,15 +1,16 @@ import ModeDetector from './ModeDetector'; import Scheduler from './Scheduler'; import Dashboard from './Dashboard'; +import TxtVersion from '!!raw-loader!./version.txt'; const md = new ModeDetector(); if (md.isAuto()) { md.setAuto(); console.log('AUTO MANAGEMENT ON'); - const scheduler = new Scheduler(); + const scheduler = new Scheduler(TxtVersion); scheduler.run(); } else { console.log('NORMAL MODE'); - const dashboard = new Dashboard(new Scheduler()); + const dashboard = new Dashboard(TxtVersion, new Scheduler()); dashboard.run(); } diff --git a/src/utils.ts b/src/utils.ts index 7036d17..d481014 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -14,7 +14,7 @@ export async function sleepLong() { return await sleep(ms); } -export function markPage(text: string) { +export function markPage(text: string, version: string) { jQuery('body').append( '
' + text + + ' ' + + version + '
' ); } diff --git a/webpack.config.js b/webpack.config.js index 3cf0582..c74f9c4 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -2,7 +2,7 @@ const path = require('path'); module.exports = (env = {}) => ({ mode: env.production ? 'production' : 'development', - entry: path.resolve(__dirname, 'src/index.ts'), + entry: path.resolve(__dirname, 'src/index.js'), output: { filename: env.production ? 'travian.min.js' : 'travian.js', path: path.resolve(__dirname, 'dist'),