-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix built extension manifest for Chromium compatibility (#10)
- Loading branch information
Showing
4 changed files
with
26 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'github-to-linear': patch | ||
--- | ||
|
||
Fix built extension manifest for Chromium browsers. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,26 @@ | ||
import fs from 'node:fs/promises'; | ||
import pkg from '../package.json' assert { type: 'json' }; | ||
import manifest from '../extension/manifest.json' assert { type: 'json' }; | ||
|
||
console.log('Copying source files to dist...'); | ||
await fs.cp('extension', 'dist', { recursive: true }); | ||
|
||
console.log('Updating version number in manifest.json...'); | ||
let manifest = await fs.readFile('dist/manifest.json', 'utf-8'); | ||
manifest = manifest.replace( | ||
'"version": "0.0.0"', | ||
`"version": "${pkg.version}"` | ||
manifest.version = pkg.version; | ||
|
||
if (process.argv.includes('--chromium')) { | ||
console.log('Updating manifest.json for Chromium compatibility...'); | ||
manifest.manifest_version = 3; | ||
const swSource = manifest.background.scripts[0]; | ||
manifest.background.service_worker = swSource; | ||
delete manifest.background.scripts; | ||
delete manifest.options_ui.chrome_style; | ||
} | ||
|
||
await fs.writeFile( | ||
'dist/manifest.json', | ||
JSON.stringify(manifest, null, 2), | ||
'utf-8' | ||
); | ||
await fs.writeFile('dist/manifest.json', manifest, 'utf-8'); | ||
|
||
console.log('Done!'); |