gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-wallet-core] branch master updated: wallet-core: expose build ver


From: gnunet
Subject: [taler-wallet-core] branch master updated: wallet-core: expose build version info via request
Date: Tue, 23 Jan 2024 22:29:24 +0100

This is an automated email from the git hooks/post-receive script.

dold pushed a commit to branch master
in repository wallet-core.

The following commit(s) were added to refs/heads/master by this push:
     new 937d9204e wallet-core: expose build version info via request
937d9204e is described below

commit 937d9204e6c66bdc13e7b770a125d008bdfc6587
Author: Florian Dold <florian@dold.me>
AuthorDate: Tue Jan 23 22:29:21 2024 +0100

    wallet-core: expose build version info via request
---
 packages/taler-harness/build.mjs           | 11 +++--
 packages/taler-util/src/wallet-types.ts    |  3 ++
 packages/taler-wallet-cli/build-node.mjs   |  7 +++-
 packages/taler-wallet-cli/build-qtart.mjs  |  7 +++-
 packages/taler-wallet-core/src/versions.ts | 16 ++++++++
 packages/taler-wallet-core/src/wallet.ts   |  2 +
 packages/taler-wallet-embedded/build.mjs   | 65 ++++++++++++++++--------------
 7 files changed, 75 insertions(+), 36 deletions(-)

diff --git a/packages/taler-harness/build.mjs b/packages/taler-harness/build.mjs
index 3fb411342..ef2a2b111 100755
--- a/packages/taler-harness/build.mjs
+++ b/packages/taler-harness/build.mjs
@@ -16,8 +16,8 @@
  */
 
 import esbuild from "esbuild";
-import path from "path";
 import fs from "fs";
+import path from "path";
 
 const BASE = process.cwd();
 
@@ -43,7 +43,10 @@ function git_hash() {
   if (rev.indexOf("/") === -1) {
     return rev;
   } else {
-    return fs.readFileSync(path.join(GIT_ROOT, ".git", rev)).toString().trim();
+    return fs
+      .readFileSync(path.join(GIT_ROOT, ".git", rev))
+      .toString()
+      .trim();
   }
 }
 
@@ -61,7 +64,9 @@ export const buildConfig = {
   define: {
     __VERSION__: `"${_package.version}"`,
     __GIT_HASH__: `"${GIT_HASH}"`,
-    ["import.meta.url"]: "import_meta_url",
+    "walletCoreBuildInfo.implementationSemver": `"${_package.version}"`,
+    "walletCoreBuildInfo.implementationGitHash": `"${GIT_HASH}"`,
+    "import.meta.url": "import_meta_url",
   },
 };
 
diff --git a/packages/taler-util/src/wallet-types.ts 
b/packages/taler-util/src/wallet-types.ts
index b1fbd3d43..c2730812f 100644
--- a/packages/taler-util/src/wallet-types.ts
+++ b/packages/taler-util/src/wallet-types.ts
@@ -1092,6 +1092,9 @@ export interface ExchangeDetailedResponse {
 }
 
 export interface WalletCoreVersion {
+  implementationSemver: string;
+  implementationGitHash: string;
+
   /**
    * Wallet-core protocol version supported by this implementation
    * of the API ("server" version).
diff --git a/packages/taler-wallet-cli/build-node.mjs 
b/packages/taler-wallet-cli/build-node.mjs
index 76426bc41..047fc4527 100755
--- a/packages/taler-wallet-cli/build-node.mjs
+++ b/packages/taler-wallet-cli/build-node.mjs
@@ -43,7 +43,10 @@ function git_hash() {
   if (rev.indexOf("/") === -1) {
     return rev;
   } else {
-    return fs.readFileSync(path.join(GIT_ROOT, ".git", rev)).toString().trim();
+    return fs
+      .readFileSync(path.join(GIT_ROOT, ".git", rev))
+      .toString()
+      .trim();
   }
 }
 
@@ -60,6 +63,8 @@ export const buildConfig = {
   define: {
     __VERSION__: `"${_package.version}"`,
     __GIT_HASH__: `"${GIT_HASH}"`,
+    "walletCoreBuildInfo.implementationSemver": `"${_package.version}"`,
+    "walletCoreBuildInfo.implementationGitHash": `"${GIT_HASH}"`,
     ["import.meta.url"]: "import_meta_url",
   },
 };
diff --git a/packages/taler-wallet-cli/build-qtart.mjs 
b/packages/taler-wallet-cli/build-qtart.mjs
index 7042bf49e..04b2e718f 100755
--- a/packages/taler-wallet-cli/build-qtart.mjs
+++ b/packages/taler-wallet-cli/build-qtart.mjs
@@ -43,7 +43,10 @@ function git_hash() {
   if (rev.indexOf("/") === -1) {
     return rev;
   } else {
-    return fs.readFileSync(path.join(GIT_ROOT, ".git", rev)).toString().trim();
+    return fs
+      .readFileSync(path.join(GIT_ROOT, ".git", rev))
+      .toString()
+      .trim();
   }
 }
 
@@ -63,6 +66,8 @@ export const buildConfig = {
   define: {
     __VERSION__: `"${_package.version}"`,
     __GIT_HASH__: `"${GIT_HASH}"`,
+    "walletCoreBuildInfo.implementationSemver": `"${_package.version}"`,
+    "walletCoreBuildInfo.implementationGitHash": `"${GIT_HASH}"`,
   },
 };
 
diff --git a/packages/taler-wallet-core/src/versions.ts 
b/packages/taler-wallet-core/src/versions.ts
index 023cbb1ff..bf8a9f7c8 100644
--- a/packages/taler-wallet-core/src/versions.ts
+++ b/packages/taler-wallet-core/src/versions.ts
@@ -68,3 +68,19 @@ export const WALLET_CORE_API_IMPLEMENTATION_VERSION = 
"3:0:2";
  * If any interfaces have been removed or changed since the last public
  *     release, then set age to 0.
  */
+
+// Provided either by bundler or in the next lines.
+declare global {
+  const walletCoreBuildInfo: {
+    implementationSemver: string;
+    implementationGitHash: string;
+  };
+}
+
+// Provide walletCoreBuildInfo if the bundler does not override it.
+if (!("walletCoreBuildInfo" in globalThis)) {
+  (globalThis as any).walletCoreBuildInfo = {
+    implementationSemver: "unknown",
+    implementationGitHash: "unknown",
+  } satisfies typeof walletCoreBuildInfo;
+}
diff --git a/packages/taler-wallet-core/src/wallet.ts 
b/packages/taler-wallet-core/src/wallet.ts
index 831f72259..72e9750bc 100644
--- a/packages/taler-wallet-core/src/wallet.ts
+++ b/packages/taler-wallet-core/src/wallet.ts
@@ -1556,6 +1556,8 @@ async function dispatchRequestInternal<Op extends 
WalletApiOperation>(
 
 export function getVersion(ws: InternalWalletState): WalletCoreVersion {
   const result: WalletCoreVersion = {
+    implementationSemver: walletCoreBuildInfo.implementationSemver,
+    implementationGitHash: walletCoreBuildInfo.implementationGitHash,
     hash: undefined,
     version: WALLET_CORE_API_IMPLEMENTATION_VERSION,
     exchange: WALLET_EXCHANGE_PROTOCOL_VERSION,
diff --git a/packages/taler-wallet-embedded/build.mjs 
b/packages/taler-wallet-embedded/build.mjs
index 233660af1..f2bf7b986 100755
--- a/packages/taler-wallet-embedded/build.mjs
+++ b/packages/taler-wallet-embedded/build.mjs
@@ -15,31 +15,38 @@
  GNU Taler; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
  */
 
-import esbuild from 'esbuild'
-import path from "path"
-import fs from "fs"
+import esbuild from "esbuild";
+import path from "path";
+import fs from "fs";
 
-const BASE = process.cwd()
+const BASE = process.cwd();
 
-let GIT_ROOT = BASE
-while (!fs.existsSync(path.join(GIT_ROOT, '.git')) && GIT_ROOT !== '/') {
-  GIT_ROOT = path.join(GIT_ROOT, '../')
+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")
+if (GIT_ROOT === "/") {
+  console.log("not found");
   process.exit(1);
 }
-const GIT_HASH = GIT_ROOT === '/' ? undefined : git_hash()
+const GIT_HASH = GIT_ROOT === "/" ? undefined : git_hash();
 
-
-let _package = JSON.parse(fs.readFileSync(path.join(BASE, 'package.json')));
+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) {
+  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();
+    return fs
+      .readFileSync(path.join(GIT_ROOT, ".git", rev))
+      .toString()
+      .trim();
   }
 }
 
@@ -48,26 +55,22 @@ export const buildConfig = {
   outfile: "dist/taler-wallet-core-qjs.mjs",
   bundle: true,
   minify: false,
-  target: [
-    'es2020'
-  ],
+  target: ["es2020"],
   external: ["os", "std", "better-sqlite3"],
-  format: 'esm',
-  platform: 'neutral',
+  format: "esm",
+  platform: "neutral",
   mainFields: ["module", "main"],
   conditions: ["qtart"],
   sourcemap: true,
   define: {
-    '__VERSION__': `"${_package.version}"`,
-    '__GIT_HASH__': `"${GIT_HASH}"`,
+    __VERSION__: `"${_package.version}"`,
+    __GIT_HASH__: `"${GIT_HASH}"`,
+    "walletCoreBuildInfo.implementationSemver": `"${_package.version}"`,
+    "walletCoreBuildInfo.implementationGitHash": `"${GIT_HASH}"`,
   },
-}
-
-esbuild
-  .build(buildConfig)
-  .catch((e) => {
-    console.log(e)
-    process.exit(1)
-  });
-
+};
 
+esbuild.build(buildConfig).catch((e) => {
+  console.log(e);
+  process.exit(1);
+});

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]