From 7ba90cb0cbbd8007deb3e3667c146d0dc4620b0b Mon Sep 17 00:00:00 2001 From: Percs <83934299+Percslol@users.noreply.github.com> Date: Fri, 19 Apr 2024 09:25:04 -0500 Subject: [PATCH] report the proper bare-mux version --- package.json | 3 ++- rollup.config.js | 10 ++++++++++ src/Switcher.ts | 5 +++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 0993baa..8890ba2 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,8 @@ "esbuild": "^0.19.11", "esbuild-plugin-d.ts": "^1.2.2", "rollup": "^4.9.6", - "rollup-plugin-typescript2": "^0.36.0" + "rollup-plugin-typescript2": "^0.36.0", + "@rollup/plugin-replace": "^5.0.5" }, "dependencies": { "@types/uuid": "^9.0.8", diff --git a/rollup.config.js b/rollup.config.js index bab9c85..e24457d 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,7 +1,12 @@ import inject from '@rollup/plugin-inject'; +import replace from '@rollup/plugin-replace'; import { fileURLToPath } from 'node:url'; +import { readFile } from 'node:fs/promises'; import typescript from 'rollup-plugin-typescript2'; +const pkg = JSON.parse(await readFile('package.json')); +process.env.BARE_MUX_VERSION = pkg.version; + /** * @typedef {import('rollup').OutputOptions} OutputOptions * @typedef {import('rollup').RollupOptions} RollupOptions @@ -22,6 +27,11 @@ const commonPlugins = () => [ ) ) ), + replace({ + 'process.env.BARE_MUX_VERSION': JSON.stringify( + process.env.BARE_MUX_VERSION + ), + }), ]; /** diff --git a/src/Switcher.ts b/src/Switcher.ts index 608254d..cc3de59 100644 --- a/src/Switcher.ts +++ b/src/Switcher.ts @@ -1,8 +1,9 @@ import { BareTransport } from "./BareTypes"; import RemoteTransport from "./RemoteClient"; -self.BCC_VERSION = "3.0.7"; -console.debug("BCC_VERSION: " + self.BCC_VERSION); +//@ts-expect-error not installing node types for this one thing +self.BCC_VERSION = process.env.BARE_MUX_VERSION; +console.debug("BARE_MUX_VERSION: " + self.BCC_VERSION); declare global { interface ServiceWorkerGlobalScope {