improve lila version info

pull/6515/head
Niklas Fiekas 2020-04-30 17:18:20 +02:00
parent 52602543a8
commit 3139bf8f80
4 changed files with 44 additions and 19 deletions

View File

@ -40,7 +40,7 @@ jobs:
- uses: actions/setup-java@v1
with:
java-version: 13.0.2
- run: TZ=UTC git log -1 --date=iso-strict-local --pretty='format:app.version = """%h / %ad / %s"""%n' | tee conf/version.conf
- run: TZ=UTC git log -1 --date=iso-strict-local --pretty='format:app.version.commit = "%h"%napp.version.date = "%ad"%napp.version.message = """%s"""%n' | tee conf/version.conf
- run: ./lila -Depoll=true "test;stage"
- run: cp LICENSE COPYING.md README.md target/universal/stage && git log -n 1 --pretty=oneline > target/universal/stage/commit.txt
- run: cd target/universal/stage && tar -cvpJf ../../../lila-3.0.tar.xz . && cd -

View File

@ -85,7 +85,10 @@ final class Env(
val isStage = config.get[Boolean]("app.stage")
val explorerEndpoint = config.get[String]("explorer.endpoint")
val tablebaseEndpoint = config.get[String]("explorer.tablebase.endpoint")
val appVersion = config.getOptional[String]("app.version")
val appVersionDate = config.getOptional[String]("app.version.date")
val appVersionCommit = config.getOptional[String]("app.version.commit")
val appVersionMessage = config.getOptional[String]("app.version.message")
def net = common.netConfig

View File

@ -31,7 +31,12 @@ object help {
title = title,
active = "source",
moreCss = frag(cssTag("source")),
contentCls = "page"
contentCls = "page",
moreJs = embedJsUnsafe(
"""$('#asset-version-date').text(lichess.info.date);
$('#asset-version-commit').attr('href', 'https://github.com/ornicar/lila/commit/' + lichess.info.commit).find('pre').text(lichess.info.commit);
$('#asset-version-message').text(lichess.info.message);"""
)
)(
frag(
st.section(cls := "box box-pad body")(
@ -39,16 +44,30 @@ object help {
raw(~doc.getHtml("doc.content", resolver))
),
br,
env.appVersion map { appVersion =>
st.section(cls := "box box-pad")(
h1("lila version"),
pre(appVersion),
pre(
"Boot ",
momentFromNow(lila.common.Uptime.startedAt)
st.section(cls := "box")(
h1("lila version"),
table(cls := "slist slist-pad")(
env.appVersionDate zip env.appVersionCommit zip env.appVersionMessage map {
case ((date, commit), message) =>
tr(
td("Server"),
td(date),
td(a(href := s"https://github.com/ornicar/lila/commit/$commit")(pre(commit))),
td(message)
)
},
tr(
td("Assets"),
td(id := "asset-version-date"),
td(a(id := "asset-version-commit")(pre)),
td(id := "asset-version-message")
),
tr(
td("Boot"),
td(momentFromNow(lila.common.Uptime.startedAt))
)
)
},
),
br,
st.section(cls := "box")(freeJs())
)

View File

@ -9,7 +9,7 @@ const terser = require('gulp-terser');
const size = require('gulp-size');
const tsify = require('tsify');
const concat = require('gulp-concat');
const exec = require('child_process').exec;
const execSync = require('child_process').execSync;
const fs = require('fs');
const path = require('path');
@ -127,15 +127,18 @@ function makeBundle(filename) {
};
}
const gitSha = (cb) => exec("git rev-parse -q --short HEAD", function (err, stdout) {
if (err) throw err;
const gitSha = (cb) => {
const info = JSON.stringify({
date: new Date(new Date().toUTCString()).toISOString().split('.')[0] + '+00:00',
commit: execSync('git rev-parse -q --short HEAD', {encoding: 'utf-8'}).trim(),
message: execSync('git log -1 --pretty=%s', {encoding: 'utf-8'}).trim(),
});
if (!fs.existsSync('./dist')) fs.mkdirSync('./dist');
var date = new Date().toISOString().split('.')[0];
fs.writeFileSync('./dist/consolemsg.js',
'window.lichess=window.lichess||{};console.info("Lichess is open source! https://github.com/ornicar/lila");' +
`lichess.info = "Assets built ${date} from sha ${stdout.trim()}";`);
fs.writeFileSync(
'./dist/consolemsg.js',
`window.lichess=window.lichess||{};console.info("Lichess is open source! https://github.com/ornicar/lila");lichess.info=${info};`);
cb();
});
};
const standalonesJs = () => gulp.src([
'util.js', 'trans.js', 'tv.js', 'puzzle.js', 'user.js', 'coordinate.js', 'captcha.js', 'embed-analyse.js'