From 8554b0452c7f85024251f9f35a2f988c218c8784 Mon Sep 17 00:00:00 2001 From: Daniel N <2color@users.noreply.github.com> Date: Tue, 12 Aug 2025 10:57:38 +0200 Subject: [PATCH] refactor: move sync version script to file --- package.json | 2 +- scripts/sync-version.mjs | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100755 scripts/sync-version.mjs diff --git a/package.json b/package.json index d059949..2754660 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ }, "main": "src/background.js", "scripts": { - "sync-version": "node -e \"const fs=require('fs'); const pkg=require('./package.json'); const m=require('./src/manifest.json'); if(m.version!==pkg.version){m.version=pkg.version; fs.writeFileSync('src/manifest.json', JSON.stringify(m,null,2)+'\\n'); console.log('✓ Updated manifest.json version to '+pkg.version)}else{console.log('✓ Version already in sync: '+pkg.version)}\"", + "sync-version": "node scripts/sync-version.mjs", "build": "npm run sync-version && tsc && cp src/manifest.json dist/ && cp src/popup.html dist/ && cp -r src/icons dist/", "package": "npm run build && web-ext build --source-dir=dist --artifacts-dir=. --filename=ipfs-quicklaunch-{version}.zip --overwrite-dest", "start": "npm run build && web-ext run --source-dir=dist --target=chromium", diff --git a/scripts/sync-version.mjs b/scripts/sync-version.mjs new file mode 100755 index 0000000..09ec92c --- /dev/null +++ b/scripts/sync-version.mjs @@ -0,0 +1,17 @@ +#!/usr/bin/env node + +// Synchronizes the version in src/manifest.json with the version in package.json +import fs from 'fs'; +import { readFileSync } from 'fs'; + +const pkg = JSON.parse(readFileSync('./package.json', 'utf8')); +const manifestPath = './src/manifest.json'; +const manifest = JSON.parse(readFileSync(manifestPath, 'utf8')); + +if (manifest.version !== pkg.version) { + manifest.version = pkg.version; + fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2) + '\n'); + console.log('✓ Updated manifest.json version to ' + pkg.version); +} else { + console.log('✓ manifest.json version already in sync with package.json: ' + pkg.version); +} \ No newline at end of file