aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2022-09-04 23:08:45 -0300
committerSebastian <sebasjm@gmail.com>2022-09-04 23:08:45 -0300
commitd439c3e1bc743f2aa47de4457953dba6ecb0e20f (patch)
treeb1ab28141a99ad7fc23c0aab4620d22abd6d975d
parent36376bdeb673476734b38413303a12d64017b455 (diff)
adding version and commit into the setting section
-rwxr-xr-xpackages/taler-wallet-webextension/build-fast-with-linaria.mjs34
-rw-r--r--packages/taler-wallet-webextension/src/custom.d.ts2
-rw-r--r--packages/taler-wallet-webextension/src/wallet/Settings.tsx16
3 files changed, 47 insertions, 5 deletions
diff --git a/packages/taler-wallet-webextension/build-fast-with-linaria.mjs b/packages/taler-wallet-webextension/build-fast-with-linaria.mjs
index dc6f7b2b6..25e5e78db 100755
--- a/packages/taler-wallet-webextension/build-fast-with-linaria.mjs
+++ b/packages/taler-wallet-webextension/build-fast-with-linaria.mjs
@@ -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({
diff --git a/packages/taler-wallet-webextension/src/custom.d.ts b/packages/taler-wallet-webextension/src/custom.d.ts
index 7f4a10cfc..1bcd2a8d0 100644
--- a/packages/taler-wallet-webextension/src/custom.d.ts
+++ b/packages/taler-wallet-webextension/src/custom.d.ts
@@ -29,3 +29,5 @@ declare module "*.svg" {
const content: any;
export default content;
}
+declare const __VERSION__: string;
+declare const __GIT_HASH__: string;
diff --git a/packages/taler-wallet-webextension/src/wallet/Settings.tsx b/packages/taler-wallet-webextension/src/wallet/Settings.tsx
index 90e8518ae..1b75ee6c9 100644
--- a/packages/taler-wallet-webextension/src/wallet/Settings.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/Settings.tsx
@@ -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>
);