release manifest v2 for firefox

This commit is contained in:
EnixCoda 2024-04-27 22:40:55 +08:00
parent e31f5de690
commit 755ab1e3db
2 changed files with 34 additions and 1 deletions

View file

@ -31,7 +31,13 @@ upload-for-analytics:
yarn sentry-cli releases finalize "$(FULL_VERSION)"
compress:
cd dist && zip -r Gitako-$(FULL_VERSION).zip * -x *.map -x *.DS_Store
cd dist && zip -r Gitako-$(FULL_VERSION).zip * -x *.map -x *.DS_Store -x*.zip
patch-firefox-manifest:
node scripts/patch-manifest-for-firefox.js
compress-firefox:
cd dist && zip -r Gitako-$(FULL_VERSION)-firefox.zip * -x *.map -x *.DS_Store -x*.zip
compress-source:
git archive -o dist/Gitako-$(FULL_VERSION)-source.zip HEAD
@ -48,5 +54,17 @@ release:
$(MAKE) test
$(MAKE) upload-for-analytics
$(MAKE) compress
$(MAKE) patch-firefox-manifest
$(MAKE) compress-firefox
$(MAKE) compress-source
$(MAKE) copy-build-safari
release-dry-run:
$(MAKE) clean
$(MAKE) build
$(MAKE) test
$(MAKE) compress
$(MAKE) patch-firefox-manifest
$(MAKE) compress-firefox
$(MAKE) compress-source
$(MAKE) copy-build-safari

View file

@ -0,0 +1,15 @@
const path = require('path')
const fs = require('fs')
const manifestPath = path.join(__dirname, '..', 'dist', 'manifest.json')
const manifest = require(manifestPath)
manifest.manifest_version = 2
const serviceWorker = manifest.background?.['service_worker']
if (serviceWorker) {
console.log('Patching background')
manifest.background.scripts = [serviceWorker]
Reflect.deleteProperty(manifest.background, 'service_worker')
fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2))
} else {
console.log('Service worker field not found, skipped patching')
}