From 0aa26aa809ea626dbbd3000ae19fc969ce54b9ac Mon Sep 17 00:00:00 2001 From: Bauke Date: Sun, 20 Mar 2022 21:52:53 +0100 Subject: [PATCH] Move the version number into Vite config. --- source/chromium-manifest.json | 1 - source/firefox-manifest.json | 1 - vite.config.ts | 17 ++++++++++++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/source/chromium-manifest.json b/source/chromium-manifest.json index 1b95a87..daa51f3 100644 --- a/source/chromium-manifest.json +++ b/source/chromium-manifest.json @@ -2,7 +2,6 @@ "manifest_version": 3, "name": "Queue", "description": "A WebExtension for queueing links.", - "version": "0.2.2", "permissions": [ "contextMenus", "storage", diff --git a/source/firefox-manifest.json b/source/firefox-manifest.json index 2980cab..0b45ad0 100644 --- a/source/firefox-manifest.json +++ b/source/firefox-manifest.json @@ -2,7 +2,6 @@ "manifest_version": 2, "name": "Queue", "description": "A WebExtension for queueing links.", - "version": "0.2.2", "permissions": [ "contextMenus", "storage", diff --git a/vite.config.ts b/vite.config.ts index 5539abb..f434a64 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,4 +1,5 @@ import fs from 'node:fs'; +import fsp from 'node:fs/promises'; import path from 'node:path'; import process from 'node:process'; import url from 'node:url'; @@ -12,6 +13,8 @@ import webExtension from 'vite-plugin-web-extension'; const currentDir = path.dirname(url.fileURLToPath(import.meta.url)); const sourceDir = path.join(currentDir, 'source'); +const queueVersion = '0.2.2'; + const targetBrowser = process.env.VITE_BROWSER ?? 'firefox'; process.env.VITE_BROWSER = targetBrowser; @@ -52,7 +55,19 @@ export default defineConfig({ webExtension({ assets: 'assets', browser: targetBrowser, - manifest: path.join(sourceDir, `${targetBrowser}-manifest.json`), + async manifest() { + const manifest = JSON.parse( + await fsp.readFile( + path.join(sourceDir, `${targetBrowser}-manifest.json`), + // eslint-disable-next-line unicorn/prefer-json-parse-buffer + 'utf-8', + ), + ) as Record; + + manifest.version = queueVersion; + + return manifest; + }, webExtConfig, }), ],