diff options
author | Florian Dold <florian@dold.me> | 2024-01-23 22:29:21 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2024-01-23 22:29:21 +0100 |
commit | 937d9204e6c66bdc13e7b770a125d008bdfc6587 (patch) | |
tree | f41be3147e18011122e315a1fe4f198facd2f9e8 /packages/taler-wallet-embedded | |
parent | 7e7306ec4585c5fd7a2ceb727177e7d249ae6031 (diff) | |
download | wallet-core-937d9204e6c66bdc13e7b770a125d008bdfc6587.tar.xz |
wallet-core: expose build version info via request
Diffstat (limited to 'packages/taler-wallet-embedded')
-rwxr-xr-x | packages/taler-wallet-embedded/build.mjs | 65 |
1 files changed, 34 insertions, 31 deletions
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); +}); |