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 - uses: actions/setup-java@v1
with: with:
java-version: 13.0.2 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: ./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: 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 - - 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 isStage = config.get[Boolean]("app.stage")
val explorerEndpoint = config.get[String]("explorer.endpoint") val explorerEndpoint = config.get[String]("explorer.endpoint")
val tablebaseEndpoint = config.get[String]("explorer.tablebase.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 def net = common.netConfig

View File

@ -31,7 +31,12 @@ object help {
title = title, title = title,
active = "source", active = "source",
moreCss = frag(cssTag("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( frag(
st.section(cls := "box box-pad body")( st.section(cls := "box box-pad body")(
@ -39,16 +44,30 @@ object help {
raw(~doc.getHtml("doc.content", resolver)) raw(~doc.getHtml("doc.content", resolver))
), ),
br, br,
env.appVersion map { appVersion => st.section(cls := "box")(
st.section(cls := "box box-pad")( h1("lila version"),
h1("lila version"), table(cls := "slist slist-pad")(
pre(appVersion), env.appVersionDate zip env.appVersionCommit zip env.appVersionMessage map {
pre( case ((date, commit), message) =>
"Boot ", tr(
momentFromNow(lila.common.Uptime.startedAt) 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, br,
st.section(cls := "box")(freeJs()) st.section(cls := "box")(freeJs())
) )

View File

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