Use vite-plugin-version-mark to read project version

Change-Id: I0d46dc57df025538379a2f0786d3e972c56dd248
This commit is contained in:
Manuel Stahl 2024-04-18 20:25:14 +02:00 committed by Manuel Stahl
parent 2e2085cdfe
commit f4ea63c8f4
4 changed files with 22 additions and 15 deletions

View file

@ -119,22 +119,14 @@
<div class="loader">Loading...</div> <div class="loader">Loading...</div>
</div> </div>
</div> </div>
<!-- <script type="module" src="/src/index.jsx"></script>
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
<footer <footer
style="position: relative; z-index: 2; height: 2em; margin-top: -2em; line-height: 2em; background-color: #eee; border: 0.5px solid #ddd"> style="position: relative; z-index: 2; height: 2em; margin-top: -2em; line-height: 2em; background-color: #eee; border: 0.5px solid #ddd">
<a id="copyright" href="https://github.com/Awesome-Technologies/synapse-admin" <a id="copyright" href="https://github.com/Awesome-Technologies/synapse-admin"
style="margin-left: 1em; color: #888; font-family: Roboto, Helvetica, Arial, sans-serif; font-weight: 100; font-size: 0.8em; text-decoration: none;"> style="margin-left: 1em; color: #888; font-family: Roboto, Helvetica, Arial, sans-serif; font-weight: 100; font-size: 0.8em; text-decoration: none;">
Synapse-Admin <b>(%REACT_APP_VERSION%)</b> by Awesome Technologies Innovationslabor GmbH Synapse-Admin <b><span id="version"></span></b> by Awesome Technologies Innovationslabor GmbH
</a> </a>
</footer> </footer>
</body> </body>
<script>document.getElementById("version").textContent = __SYNAPSE_ADMIN_VERSION__</script>
</html> </html>

View file

@ -26,7 +26,8 @@
"jest-fetch-mock": "^3.0.3", "jest-fetch-mock": "^3.0.3",
"prettier": "^3.2.5", "prettier": "^3.2.5",
"react-test-renderer": "^18.2.0", "react-test-renderer": "^18.2.0",
"vite": "^5.0.0" "vite": "^5.0.0",
"vite-plugin-version-mark": "^0.0.13"
}, },
"dependencies": { "dependencies": {
"@haleos/ra-language-german": "^1.0.0", "@haleos/ra-language-german": "^1.0.0",
@ -43,8 +44,8 @@
"react-dom": "^18.0.0" "react-dom": "^18.0.0"
}, },
"scripts": { "scripts": {
"start": "REACT_APP_VERSION=$(git describe --tags) vite serve", "start": "vite serve",
"build": "REACT_APP_VERSION=$(git describe --tags) vite build", "build": "vite build",
"fix:other": "yarn prettier --write", "fix:other": "yarn prettier --write",
"fix:code": "yarn test:lint --fix", "fix:code": "yarn test:lint --fix",
"fix": "yarn fix:code && yarn fix:other", "fix": "yarn fix:code && yarn fix:other",

View file

@ -1,6 +1,15 @@
import { defineConfig } from "vite"; import { defineConfig } from "vite";
import react from "@vitejs/plugin-react"; import react from "@vitejs/plugin-react";
import { vitePluginVersionMark } from "vite-plugin-version-mark";
export default defineConfig({ export default defineConfig({
plugins: [react()], plugins: [
react(),
vitePluginVersionMark({
command: "git describe --tags",
ifMeta: true,
ifLog: true,
ifGlobal: true,
}),
],
}); });

View file

@ -6411,6 +6411,11 @@ v8-to-istanbul@^9.0.1:
"@types/istanbul-lib-coverage" "^2.0.1" "@types/istanbul-lib-coverage" "^2.0.1"
convert-source-map "^2.0.0" convert-source-map "^2.0.0"
vite-plugin-version-mark@^0.0.13:
version "0.0.13"
resolved "https://registry.yarnpkg.com/vite-plugin-version-mark/-/vite-plugin-version-mark-0.0.13.tgz#dbdbbcba37eb0a9f7f4d2a3c65d05f5645cd65a6"
integrity sha512-myri8xZYEo2mqVJCAZYR+OIFUCdw9AWbl/a4RFucKtcQa4sMXsoxUcXUtBI9jyC2EZGBDHYE0FL22YLYxNZb0Q==
vite@^5.0.0: vite@^5.0.0:
version "5.2.9" version "5.2.9"
resolved "https://registry.yarnpkg.com/vite/-/vite-5.2.9.tgz#cd9a356c6ff5f7456c09c5ce74068ffa8df743d9" resolved "https://registry.yarnpkg.com/vite/-/vite-5.2.9.tgz#cd9a356c6ff5f7456c09c5ce74068ffa8df743d9"