mirror of
https://github.com/revoltchat/revite.git
synced 2024-12-24 22:52:09 -05:00
Show Git revision in settings.
This commit is contained in:
parent
feaec3f8d9
commit
c52f1f5bca
6 changed files with 34 additions and 2 deletions
|
@ -29,6 +29,7 @@
|
|||
"@fontsource/open-sans": "^4.4.5",
|
||||
"@hcaptcha/react-hcaptcha": "^0.3.6",
|
||||
"@preact/preset-vite": "^2.0.0",
|
||||
"@rollup/plugin-replace": "^2.4.2",
|
||||
"@styled-icons/bootstrap": "^10.34.0",
|
||||
"@styled-icons/feather": "^10.34.0",
|
||||
"@styled-icons/simple-icons": "^10.33.0",
|
||||
|
|
|
@ -104,6 +104,10 @@
|
|||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.revision a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
|
||||
scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
|
||||
|
|
|
@ -20,6 +20,7 @@ import {
|
|||
User
|
||||
} from "@styled-icons/feather";
|
||||
import { Megaphone } from "@styled-icons/bootstrap";
|
||||
import { GIT_REVISION, REPO_URL } from "../../revision";
|
||||
import LineDivider from "../../components/ui/LineDivider";
|
||||
import RequiresOnline from "../../context/revoltjs/RequiresOnline";
|
||||
import ButtonItem from "../../components/navigation/items/ButtonItem";
|
||||
|
@ -142,6 +143,11 @@ export default function Settings() {
|
|||
</ButtonItem>,
|
||||
<div className={styles.version}>
|
||||
<div>
|
||||
<span className={styles.revision}>
|
||||
<a href={`${REPO_URL}/${GIT_REVISION}`} target="_blank">
|
||||
{ GIT_REVISION.substr(0, 7) }
|
||||
</a>
|
||||
</span>
|
||||
<span>Stable {APP_VERSION}</span>
|
||||
<span>API: {client.configuration?.revolt ?? "N/A"}</span>
|
||||
<span>revolt.js: {LIBRARY_VERSION}</span>
|
||||
|
|
2
src/revision.ts
Normal file
2
src/revision.ts
Normal file
|
@ -0,0 +1,2 @@
|
|||
export const GIT_REVISION = '__GIT_REVISION__';
|
||||
export const REPO_URL = 'https://gitlab.insrt.uk/revolt/revite/-/commit';
|
|
@ -1,9 +1,24 @@
|
|||
import { resolve } from 'path'
|
||||
import { readFileSync } from 'fs'
|
||||
import { defineConfig } from 'vite'
|
||||
import preact from '@preact/preset-vite'
|
||||
import { VitePWA } from 'vite-plugin-pwa'
|
||||
import replace from '@rollup/plugin-replace'
|
||||
|
||||
function getGitRevision() {
|
||||
try {
|
||||
const rev = readFileSync('.git/HEAD').toString().trim();
|
||||
if (rev.indexOf(':') === -1) {
|
||||
return rev;
|
||||
} else {
|
||||
return readFileSync('.git/' + rev.substring(5)).toString().trim();
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Failed to get Git revision.');
|
||||
return '?';
|
||||
}
|
||||
}
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
preact(),
|
||||
|
@ -31,6 +46,10 @@ export default defineConfig({
|
|||
]
|
||||
},
|
||||
workbox: { }
|
||||
}),
|
||||
replace({
|
||||
__GIT_REVISION__: getGitRevision(),
|
||||
preventAssignment: true
|
||||
})
|
||||
],
|
||||
build: {
|
||||
|
|
|
@ -1057,7 +1057,7 @@
|
|||
is-module "^1.0.0"
|
||||
resolve "^1.19.0"
|
||||
|
||||
"@rollup/plugin-replace@^2.4.1":
|
||||
"@rollup/plugin-replace@^2.4.1", "@rollup/plugin-replace@^2.4.2":
|
||||
version "2.4.2"
|
||||
resolved "https://registry.yarnpkg.com/@rollup/plugin-replace/-/plugin-replace-2.4.2.tgz#a2d539314fbc77c244858faa523012825068510a"
|
||||
integrity sha512-IGcu+cydlUMZ5En85jxHH4qj2hta/11BHq95iHEyb2sbgiN0eCdzvUcHw5gt9pBL5lTi4JDYJ1acCoMGpTvEZg==
|
||||
|
|
Loading…
Reference in a new issue