Generate manifest to share min version

This commit is contained in:
Oliver Blanthorn 2026-07-11 14:51:12 +02:00
parent a696038929
commit 8d18f541bc
No known key found for this signature in database
GPG key ID: 2BB8C36BB504BFF3
4 changed files with 46 additions and 4 deletions

13
browser-targets.json Normal file
View file

@ -0,0 +1,13 @@
{
"firefox": {
"minimumVersion": "91.1.0",
"manifestVersionPath": [
"applications",
"gecko",
"strict_min_version"
]
},
"chrome": {
"minimumVersion": "114"
}
}

View file

@ -85,7 +85,7 @@ rmdir buildtemp
# Copy extra static files across
cp src/manifest.json build/
node scripts/generate_manifest.js firefox src/manifest.json build/manifest.json
cp -r src/static build
cp -r generated/static build
cp issue_template.md build/

View file

@ -0,0 +1,30 @@
#!/usr/bin/env node
const fs = require("fs")
const targets = require("../browser-targets.json")
function generateManifest(template, targetName) {
const target = targets[targetName]
if (!target || !target.manifestVersionPath) {
throw new Error(`No manifest settings for ${targetName}`)
}
const manifest = JSON.parse(JSON.stringify(template))
const path = target.manifestVersionPath.slice()
const property = path.pop()
const parent = path.reduce((value, name) => {
if (!value[name]) value[name] = {}
return value[name]
}, manifest)
parent[property] = target.minimumVersion
return manifest
}
if (require.main === module) {
const [targetName, source, destination] = process.argv.slice(2)
const template = JSON.parse(fs.readFileSync(source, "utf8"))
const manifest = generateManifest(template, targetName)
fs.writeFileSync(destination, JSON.stringify(manifest, null, 4) + "\n")
}
module.exports = generateManifest

View file

@ -139,8 +139,7 @@
],
"applications": {
"gecko": {
"id": "tridactyl.vim.betas@cmcaine.co.uk",
"strict_min_version": "91.1.0"
"id": "tridactyl.vim.betas@cmcaine.co.uk"
}
},
"options_ui": {
@ -161,4 +160,4 @@
"omnibox": {
"keyword": "tri"
}
}
}