From 59a2733df66357a3f6438234fb1fd9557f28fbcc Mon Sep 17 00:00:00 2001 From: Wolvan Date: Sun, 30 Jan 2022 19:24:54 +0100 Subject: [PATCH] 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. --- frontend/html/index.html | 2 +- frontend/html/poll.html | 2 +- frontend/html/result.html | 2 +- src/frontend.ts | 13 ++++++++++++- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/frontend/html/index.html b/frontend/html/index.html index 2b9a233..8936efe 100644 --- a/frontend/html/index.html +++ b/frontend/html/index.html @@ -69,7 +69,7 @@ - + \ No newline at end of file diff --git a/frontend/html/poll.html b/frontend/html/poll.html index d3ff2ae..3daa7cb 100644 --- a/frontend/html/poll.html +++ b/frontend/html/poll.html @@ -69,7 +69,7 @@ - + \ No newline at end of file diff --git a/frontend/html/result.html b/frontend/html/result.html index 328ae42..2c17b18 100644 --- a/frontend/html/result.html +++ b/frontend/html/result.html @@ -57,7 +57,7 @@ - + \ No newline at end of file diff --git a/src/frontend.ts b/src/frontend.ts index d008c5e..0cd07df 100644 --- a/src/frontend.ts +++ b/src/frontend.ts @@ -69,7 +69,18 @@ const defaultReplacements = { } catch (error) { return "0.0.0"; } - })() + })(), + "GIT_URL": ((): string => { + try { + if (process.env.HEROKU_SLUG_COMMIT) { + return `git~${ process.env.HEROKU_SLUG_COMMIT.substring(0, 8) }`; + } + const packageJson = JSON.parse(fs.readFileSync(resolve(__dirname, "../package.json"), "utf8")); + return `v${ packageJson.version }`; + } catch (error) { + return "v0.0.0"; + } + })(), }; class Defaults2RenderTransform extends MinificationTransform { constructor(replacements = {}) {