Move the version number into Vite config.

This commit is contained in:
Bauke 2022-03-20 21:52:53 +01:00
parent 163f838ffc
commit 0aa26aa809
Signed by: Bauke
GPG Key ID: C1C0F29952BCF558
3 changed files with 16 additions and 3 deletions

View File

@ -2,7 +2,6 @@
"manifest_version": 3, "manifest_version": 3,
"name": "Queue", "name": "Queue",
"description": "A WebExtension for queueing links.", "description": "A WebExtension for queueing links.",
"version": "0.2.2",
"permissions": [ "permissions": [
"contextMenus", "contextMenus",
"storage", "storage",

View File

@ -2,7 +2,6 @@
"manifest_version": 2, "manifest_version": 2,
"name": "Queue", "name": "Queue",
"description": "A WebExtension for queueing links.", "description": "A WebExtension for queueing links.",
"version": "0.2.2",
"permissions": [ "permissions": [
"contextMenus", "contextMenus",
"storage", "storage",

View File

@ -1,4 +1,5 @@
import fs from 'node:fs'; import fs from 'node:fs';
import fsp from 'node:fs/promises';
import path from 'node:path'; import path from 'node:path';
import process from 'node:process'; import process from 'node:process';
import url from 'node:url'; 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 currentDir = path.dirname(url.fileURLToPath(import.meta.url));
const sourceDir = path.join(currentDir, 'source'); const sourceDir = path.join(currentDir, 'source');
const queueVersion = '0.2.2';
const targetBrowser = process.env.VITE_BROWSER ?? 'firefox'; const targetBrowser = process.env.VITE_BROWSER ?? 'firefox';
process.env.VITE_BROWSER = targetBrowser; process.env.VITE_BROWSER = targetBrowser;
@ -52,7 +55,19 @@ export default defineConfig({
webExtension({ webExtension({
assets: 'assets', assets: 'assets',
browser: targetBrowser, 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<string, unknown>;
manifest.version = queueVersion;
return manifest;
},
webExtConfig, webExtConfig,
}), }),
], ],