improved /version route to include git info
This commit is contained in:
parent
6f7f65fa36
commit
bc9d395e77
@ -1,7 +1,7 @@
|
|||||||
<%~ E.includeFile("../partials/head.eta.html", {"title": "Settings"}) %> <%~ E.includeFile("../partials/controls.eta.html", {"active": "SETT"}) %>
|
<%~ E.includeFile("../partials/head.eta.html", {"title": "Settings"}) %> <%~ E.includeFile("../partials/controls.eta.html", {"active": "SETT"}) %>
|
||||||
|
|
||||||
<h1>Manage your AssetFlow instance</h1>
|
<h1>Manage your AssetFlow instance</h1>
|
||||||
<div class="alert alert-success" role="alert">A new version is available. <a href="#" class="alert-link">Click here to update</a></div>
|
<div class="alert alert-success" role="alert" id="updateNotifier">A new version is available. <a href="https://git.project-name-here.de/Project-Name-Here/assetflow/releases" class="alert-link">Click here to update</a></div>
|
||||||
<div class="container text-center">
|
<div class="container text-center">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<a class="card col m-2" href="/manage/categories">
|
<a class="card col m-2" href="/manage/categories">
|
||||||
@ -30,5 +30,16 @@
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<script>
|
||||||
|
$(document).ready(function () {
|
||||||
|
$.getJSON("/api/v1/version", function (data) {
|
||||||
|
if (data.updateAvailable) {
|
||||||
|
$("#updateNotifier").show();
|
||||||
|
// $("#updateNotifier").find(".alert-link").attr("href", data.url);
|
||||||
|
}else {
|
||||||
|
$("#updateNotifier").hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
<%~ E.includeFile("../partials/controlsFoot.eta.html") %> <%~ E.includeFile("../partials/foot.eta.html") %>
|
<%~ E.includeFile("../partials/controlsFoot.eta.html") %> <%~ E.includeFile("../partials/foot.eta.html") %>
|
||||||
|
@ -67,9 +67,16 @@ Sentry.init({
|
|||||||
environment: config.global.debug ? 'development' : 'production'
|
environment: config.global.debug ? 'development' : 'production'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.locals.versionRevLong = require('child_process')
|
||||||
|
.execSync('git rev-parse HEAD')
|
||||||
|
.toString().trim()
|
||||||
app.locals.versionRev = require('child_process')
|
app.locals.versionRev = require('child_process')
|
||||||
.execSync('git rev-parse --short HEAD')
|
.execSync('git rev-parse --short HEAD')
|
||||||
.toString().trim()
|
.toString().trim()
|
||||||
|
app.locals.versionRevLatest = require('child_process')
|
||||||
|
.execSync('git ls-remote --refs -q')
|
||||||
|
.toString().trim().split("\t")[0]
|
||||||
|
log.core.info(`Running revision ${app.locals.versionRevLong} (${app.locals.versionRevLatest} latest)`);
|
||||||
|
|
||||||
// RequestHandler creates a separate execution context using domains, so that every
|
// RequestHandler creates a separate execution context using domains, so that every
|
||||||
// transaction/span/breadcrumb is attached to its own Hub instance
|
// transaction/span/breadcrumb is attached to its own Hub instance
|
||||||
|
@ -2,7 +2,12 @@ import express, { Request, Response } from 'express';
|
|||||||
|
|
||||||
function get(req: Request, res: Response) {
|
function get(req: Request, res: Response) {
|
||||||
const revision = req.app.locals.versionRev;
|
const revision = req.app.locals.versionRev;
|
||||||
res.status(200).send({ version: '1.0.0', commit: revision });
|
let updateAvailable = false;
|
||||||
|
if(req.app.locals.versionRevLong !== req.app.locals.versionRevLatest) {
|
||||||
|
updateAvailable = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
res.status(200).send({ version: '1.0.0', commit: revision, updateAvailable: updateAvailable });
|
||||||
};
|
};
|
||||||
|
|
||||||
export default { get };
|
export default { get };
|
||||||
|
Loading…
Reference in New Issue
Block a user