diff --git a/browser-targets.json b/browser-targets.json new file mode 100644 index 00000000..32b5df5a --- /dev/null +++ b/browser-targets.json @@ -0,0 +1,13 @@ +{ + "firefox": { + "minimumVersion": "91.1.0", + "manifestVersionPath": [ + "applications", + "gecko", + "strict_min_version" + ] + }, + "chrome": { + "minimumVersion": "114" + } +} diff --git a/scripts/build.sh b/scripts/build.sh index 7f43e24c..3d7b6d4c 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -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/ diff --git a/scripts/generate_manifest.js b/scripts/generate_manifest.js new file mode 100644 index 00000000..31b422b6 --- /dev/null +++ b/scripts/generate_manifest.js @@ -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 diff --git a/src/manifest.json b/src/manifest.json index c1089c0f..9b0136d9 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -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" } -} \ No newline at end of file +}