VBV-143: "git revision hash" und Build-Datum anzeigen

This commit is contained in:
Daniel Egger 2022-09-09 11:39:36 +02:00
parent 3ff2b23cf7
commit ac268907bf
3 changed files with 26 additions and 14 deletions

View File

@ -3,7 +3,7 @@
"version": "0.0.0", "version": "0.0.0",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
"build": "vue-tsc --noEmit && vite build && cp ./dist/index.html ../server/vbv_lernwelt/templates/vue/index.html && cp -r ./dist/static/vue ../server/vbv_lernwelt/static/", "build": "vue-tsc --noEmit && vite build && node versionize && cp ./dist/index.html ../server/vbv_lernwelt/templates/vue/index.html && cp -r ./dist/static/vue ../server/vbv_lernwelt/static/",
"build:tailwind": "tailwindcss -i tailwind.css -o ../server/vbv_lernwelt/static/css/tailwind.css --minify", "build:tailwind": "tailwindcss -i tailwind.css -o ../server/vbv_lernwelt/static/css/tailwind.css --minify",
"test": "vitest run", "test": "vitest run",
"coverage": "vitest run --coverage", "coverage": "vitest run --coverage",
@ -44,6 +44,7 @@
"postcss": "^8.4.14", "postcss": "^8.4.14",
"postcss-import": "^14.1.0", "postcss-import": "^14.1.0",
"prettier": "^2.7.1", "prettier": "^2.7.1",
"replace-in-file": "^6.3.5",
"sass": "^1.54.6", "sass": "^1.54.6",
"sass-loader": "^12.6.0", "sass-loader": "^12.6.0",
"start-server-and-test": "^1.14.0", "start-server-and-test": "^1.14.0",

View File

@ -1,21 +1,15 @@
<script setup lang="ts"> <script setup lang="ts">
import * as log from 'loglevel'; import * as log from 'loglevel'
log.debug('Footer created');
log.debug('Footer created')
</script> </script>
<template> <template>
<footer <footer class="px-8 py-4 bg-gray-200 border-t border-gray-500 flex">
class=" <div>@2022 VBV</div>
px-8 <div class="flex-grow"></div>
py-4 <div>VBV_VERSION_BUILD_NUMBER_VBV</div>
bg-gray-200
border-t border-gray-500
">
@2022 VBV
</footer> </footer>
</template> </template>
<style scoped> <style scoped></style>
</style>

17
client/versionize.js Normal file
View File

@ -0,0 +1,17 @@
const replace = require("replace-in-file");
const gitHash = require('child_process')
.execSync("git rev-parse --short HEAD")
.toString().trim()
const options = {
files: "dist/static/vue/*.js",
from: /VBV_VERSION_BUILD_NUMBER_VBV/g,
to: new Date().toISOString().replace("T", " ").substring(0, 19) + ' ' + gitHash,
};
replace(options, (error, results) => {
if (error) {
return console.error("Versionize Error occurred:", error);
}
console.log(`Versionized ${results.filter((f) => f.hasChanged).length} files`);
});