From efed6b32c5f4680f3175305985c4371517131927 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Wed, 2 Aug 2023 07:40:28 -0300 Subject: [PATCH] fix #7717 --- packages/taler-util/src/wallet-types.ts | 3 +++ packages/taler-wallet-core/.gitignore | 1 + packages/taler-wallet-core/package.json | 4 ++-- packages/taler-wallet-core/src/wallet.ts | 15 +++++---------- packages/taler-wallet-core/tsconfig.json | 7 ++++++- pnpm-lock.yaml | 2 +- 6 files changed, 18 insertions(+), 14 deletions(-) diff --git a/packages/taler-util/src/wallet-types.ts b/packages/taler-util/src/wallet-types.ts index 93653240b..5151b8aae 100644 --- a/packages/taler-util/src/wallet-types.ts +++ b/packages/taler-util/src/wallet-types.ts @@ -994,6 +994,9 @@ export interface ExchangeDetailedResponse { } export interface WalletCoreVersion { + /** + * @deprecated + */ hash: string | undefined; version: string; exchange: string; diff --git a/packages/taler-wallet-core/.gitignore b/packages/taler-wallet-core/.gitignore index cb5a51ac5..13d7285e1 100644 --- a/packages/taler-wallet-core/.gitignore +++ b/packages/taler-wallet-core/.gitignore @@ -1,2 +1,3 @@ /lib /coverage +/src/version.json diff --git a/packages/taler-wallet-core/package.json b/packages/taler-wallet-core/package.json index bf4efe814..90ef6a453 100644 --- a/packages/taler-wallet-core/package.json +++ b/packages/taler-wallet-core/package.json @@ -12,7 +12,7 @@ "author": "Florian Dold", "license": "GPL-3.0", "scripts": { - "compile": "tsc --build", + "compile": "jq '{version}' package.json > src/version.json && tsc --build", "pretty": "prettier --write src", "test": "tsc && ava", "coverage": "tsc && c8 --src src --all ava", @@ -85,4 +85,4 @@ "lib/**/*test.*" ] } -} \ No newline at end of file +} diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts index 628a55e92..1f5c6ee3b 100644 --- a/packages/taler-wallet-core/src/wallet.ts +++ b/packages/taler-wallet-core/src/wallet.ts @@ -310,6 +310,7 @@ import { WalletCoreApiClient, WalletCoreResponseType, } from "./wallet-api-types.js"; +import versionInfo from "./version.json" assert { type: 'json' }; const logger = new Logger("wallet.ts"); @@ -1016,12 +1017,6 @@ export async function getClientFromWalletState( return client; } -declare const __VERSION__: string; -declare const __GIT_HASH__: string; - -const VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "dev"; -const GIT_HASH = typeof __GIT_HASH__ !== "undefined" ? __GIT_HASH__ : undefined; - /** * Implementation of the "wallet-core" API. */ @@ -1590,15 +1585,15 @@ async function dispatchRequestInternal( } export function getVersion(ws: InternalWalletState): WalletCoreVersion { - const version: WalletCoreVersion = { - hash: GIT_HASH, - version: VERSION, + const result: WalletCoreVersion = { + hash: undefined, + version: versionInfo.version, exchange: WALLET_EXCHANGE_PROTOCOL_VERSION, merchant: WALLET_MERCHANT_PROTOCOL_VERSION, bank: WALLET_BANK_INTEGRATION_PROTOCOL_VERSION, devMode: false, }; - return version; + return result; } /** diff --git a/packages/taler-wallet-core/tsconfig.json b/packages/taler-wallet-core/tsconfig.json index 5b74121a2..8de28b3d8 100644 --- a/packages/taler-wallet-core/tsconfig.json +++ b/packages/taler-wallet-core/tsconfig.json @@ -7,8 +7,10 @@ "target": "ES2017", "module": "ESNext", "moduleResolution": "Node16", + "resolveJsonModule": true, "sourceMap": true, "lib": ["es6"], + "resolvePackageJsonImports": true, "types": ["node"], "noImplicitReturns": true, "noFallthroughCasesInSwitch": true, @@ -31,5 +33,8 @@ "path": "../taler-util/" } ], - "include": ["src/**/*"] + "include": [ + "src/**/*", + "src/*.json" + ] } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d9d1a2fa3..f7fd2f134 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,4 +1,4 @@ -lockfileVersion: '6.0' +lockfileVersion: '6.1' settings: autoInstallPeers: true