adding version and commit into the setting section
This commit is contained in:
parent
36376bdeb6
commit
d439c3e1bc
@ -40,9 +40,10 @@ function getFilesInDirectory(startPath, regex) {
|
||||
return result
|
||||
}
|
||||
|
||||
const allTestFiles = getFilesInDirectory(path.join(process.cwd(), 'src'), /.test.ts$/)
|
||||
const BASE = process.cwd()
|
||||
const allTestFiles = getFilesInDirectory(path.join(BASE, 'src'), /.test.ts$/)
|
||||
|
||||
const preact = path.join(process.cwd(), "node_modules", "preact", "compat", "dist", "compat.module.js");
|
||||
const preact = path.join(BASE, "node_modules", "preact", "compat", "dist", "compat.module.js");
|
||||
const preactCompatPlugin = {
|
||||
name: "preact-compat",
|
||||
setup(build) {
|
||||
@ -61,6 +62,28 @@ const entryPoints = [
|
||||
'src/browserWorkerEntry.ts'
|
||||
]
|
||||
|
||||
let GIT_ROOT = BASE
|
||||
while (!fs.existsSync(path.join(GIT_ROOT, '.git')) && GIT_ROOT !== '/') {
|
||||
GIT_ROOT = path.join(GIT_ROOT, '../')
|
||||
}
|
||||
if (GIT_ROOT === '/') {
|
||||
console.log("not found")
|
||||
process.exit(1);
|
||||
}
|
||||
const GIT_HASH = GIT_ROOT === '/' ? undefined : git_hash()
|
||||
|
||||
|
||||
let _package = JSON.parse(fs.readFileSync(path.join(BASE, 'package.json')));
|
||||
|
||||
function git_hash() {
|
||||
const rev = fs.readFileSync(path.join(GIT_ROOT, '.git', 'HEAD')).toString().trim().split(/.*[: ]/).slice(-1)[0];
|
||||
if (rev.indexOf('/') === -1) {
|
||||
return rev;
|
||||
} else {
|
||||
return fs.readFileSync(path.join(GIT_ROOT, '.git', rev)).toString().trim();
|
||||
}
|
||||
}
|
||||
|
||||
export const buildConfig = {
|
||||
entryPoints: [...entryPoints, ...allTestFiles],
|
||||
bundle: true,
|
||||
@ -79,9 +102,10 @@ export const buildConfig = {
|
||||
sourcemap: true,
|
||||
jsxFactory: 'h',
|
||||
jsxFragment: 'Fragment',
|
||||
// define: {
|
||||
// 'process.env.NODE_ENV': '"development"',
|
||||
// },
|
||||
define: {
|
||||
'__VERSION__': `"${_package.version}"`,
|
||||
'__GIT_HASH__': `"${GIT_HASH}"`,
|
||||
},
|
||||
plugins: [
|
||||
preactCompatPlugin,
|
||||
linaria.default({
|
||||
|
@ -29,3 +29,5 @@ declare module "*.svg" {
|
||||
const content: any;
|
||||
export default content;
|
||||
}
|
||||
declare const __VERSION__: string;
|
||||
declare const __GIT_HASH__: string;
|
||||
|
@ -19,6 +19,7 @@ import { Fragment, h, VNode } from "preact";
|
||||
import { Checkbox } from "../components/Checkbox.js";
|
||||
import { ErrorTalerOperation } from "../components/ErrorTalerOperation.js";
|
||||
import { JustInDevMode } from "../components/JustInDevMode.js";
|
||||
import { Part } from "../components/Part.js";
|
||||
import { SelectList } from "../components/SelectList.js";
|
||||
import {
|
||||
DestructiveText,
|
||||
@ -69,6 +70,8 @@ export interface ViewProps {
|
||||
toggleDeveloperMode: () => Promise<void>;
|
||||
knownExchanges: Array<ExchangeListItem>;
|
||||
}
|
||||
const VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "dev";
|
||||
const GIT_HASH = typeof __GIT_HASH__ !== "undefined" ? __GIT_HASH__ : undefined;
|
||||
|
||||
export function SettingsView({
|
||||
knownExchanges,
|
||||
@ -210,6 +213,19 @@ export function SettingsView({
|
||||
/>
|
||||
</Input>
|
||||
</JustInDevMode>
|
||||
<SubTitle>
|
||||
<i18n.Translate>Version</i18n.Translate>
|
||||
</SubTitle>
|
||||
<Part
|
||||
title={<i18n.Translate>Release</i18n.Translate>}
|
||||
text={<span>{VERSION}</span>}
|
||||
/>
|
||||
{GIT_HASH && (
|
||||
<Part
|
||||
title={<i18n.Translate>Hash</i18n.Translate>}
|
||||
text={<span>{GIT_HASH}</span>}
|
||||
/>
|
||||
)}
|
||||
</section>
|
||||
</Fragment>
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user