(platform, debug, watch, test)
| 6 | import {readJSON, writeJSON} from './utils.js'; |
| 7 | |
| 8 | async function patchManifest(platform, debug, watch, test) { |
| 9 | const manifest = await readJSON(absolutePath('src/manifest.json')); |
| 10 | const manifestPatch = platform === PLATFORM.CHROMIUM_MV2 || platform === PLATFORM.CHROMIUM_MV2_PLUS ? {} : await readJSON(absolutePath(`src/manifest-${platform.replace('-plus', '')}.json`)); |
| 11 | const manifestExtras = platform === PLATFORM.CHROMIUM_MV2_PLUS ? await readJSON(absolutePath(`src/plus/manifest.json`)) : {}; |
| 12 | const patched = {...manifest, ...manifestPatch, ...manifestExtras}; |
| 13 | if (debug && platform === PLATFORM.CHROMIUM_MV3) { |
| 14 | patched.name = 'Dark Reader MV3'; |
| 15 | } |
| 16 | if (platform === PLATFORM.CHROMIUM_MV3) { |
| 17 | patched.browser_action = undefined; |
| 18 | } |
| 19 | if (debug) { |
| 20 | patched.version = '1'; |
| 21 | patched.description = `Debug build, platform: ${platform}, watch: ${watch ? 'yes' : 'no'}.`; |
| 22 | } |
| 23 | if (debug && !test && platform === PLATFORM.CHROMIUM_MV3) { |
| 24 | patched.permissions.push('tabs'); |
| 25 | } |
| 26 | if (debug && (platform === PLATFORM.CHROMIUM_MV2 || platform === PLATFORM.CHROMIUM_MV3)) { |
| 27 | patched.version_name = 'Debug'; |
| 28 | } |
| 29 | if (debug && platform === PLATFORM.CHROMIUM_MV2_PLUS) { |
| 30 | patched.version_name = 'Debug Plus'; |
| 31 | } |
| 32 | // Needed to test settings export and CSS theme export via a download |
| 33 | if (test || debug) { |
| 34 | patched.permissions.push('downloads'); |
| 35 | } |
| 36 | return patched; |
| 37 | } |
| 38 | |
| 39 | async function manifests({platforms, debug, watch, test}) { |
| 40 | const enabledPlatforms = Object.values(PLATFORM).filter((platform) => platform !== PLATFORM.API && platforms[platform]); |
no test coverage detected