Use git commit hash instead of version for dev

This way people can go straight to the commit that has caused the dev
page to be built and it is clear what version the site is based on.
This commit is contained in:
Wolvan 2022-01-30 19:24:54 +01:00
parent ee4e83bebc
commit 59a2733df6
4 changed files with 15 additions and 4 deletions

View file

@ -69,7 +69,7 @@
<ul>
{{ FOOTER_LINKS }}
</ul>
<div class="copyright"><a href="https://github.com/Wolvan/poll.horse/releases/tag/v{{ SYSTEM_VERSION }}">v{{ SYSTEM_VERSION }}</a> {{ FOOTER_COPYRIGHT }}</div>
<div class="copyright">{{ GIT_URL }} {{ FOOTER_COPYRIGHT }}</div>
</footer>
</body>
</html>

View file

@ -69,7 +69,7 @@
<ul>
{{ FOOTER_LINKS }}
</ul>
<div class="copyright"><a href="https://github.com/Wolvan/poll.horse/releases/tag/v{{ SYSTEM_VERSION }}">v{{ SYSTEM_VERSION }}</a> {{ FOOTER_COPYRIGHT }}</div>
<div class="copyright">{{ GIT_URL }} {{ FOOTER_COPYRIGHT }}</div>
</footer>
</body>
</html>

View file

@ -57,7 +57,7 @@
<ul>
{{ FOOTER_LINKS }}
</ul>
<div class="copyright"><a href="https://github.com/Wolvan/poll.horse/releases/tag/v{{ SYSTEM_VERSION }}">v{{ SYSTEM_VERSION }}</a> {{ FOOTER_COPYRIGHT }}</div>
<div class="copyright">{{ GIT_URL }} {{ FOOTER_COPYRIGHT }}</div>
</footer>
</body>
</html>

View file

@ -69,7 +69,18 @@ const defaultReplacements = {
} catch (error) {
return "0.0.0";
}
})()
})(),
"GIT_URL": ((): string => {
try {
if (process.env.HEROKU_SLUG_COMMIT) {
return `<a href="https://github.com/Wolvan/poll.horse/commit/${ process.env.HEROKU_SLUG_COMMIT }">git~${ process.env.HEROKU_SLUG_COMMIT.substring(0, 8) }</a>`;
}
const packageJson = JSON.parse(fs.readFileSync(resolve(__dirname, "../package.json"), "utf8"));
return `<a href="https://github.com/Wolvan/poll.horse/releases/tag/v${ packageJson.version }">v${ packageJson.version }</a>`;
} catch (error) {
return "v0.0.0";
}
})(),
};
class Defaults2RenderTransform extends MinificationTransform {
constructor(replacements = {}) {