Add build version

This commit is contained in:
Anton Vakhrushev 2020-03-29 17:53:16 +03:00
parent 4eaff4e6b9
commit c980abfc63
7 changed files with 21 additions and 10 deletions

1
.gitignore vendored
View File

@ -6,3 +6,4 @@ node_modules/
test-results/
var/
.npmrc
src/version.txt

View File

@ -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:

View File

@ -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') {

View File

@ -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();

View File

@ -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();
}

View File

@ -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(
'<div style="' +
'position: absolute; ' +
@ -25,6 +25,8 @@ export function markPage(text: string) {
'padding: 8px 6px; ' +
'color: black">' +
text +
' ' +
version +
'</div>'
);
}

View File

@ -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'),