Using jsonnet to generate Chrome/Firefox manifest json

This commit is contained in:
Folyd 2020-01-16 20:30:14 +08:00
parent 0af55cd2f3
commit faee2d5ebd
3 changed files with 50 additions and 40 deletions

3
.gitignore vendored
View file

@ -6,4 +6,5 @@
web-ext-artifacts
node_modules
target
docs/public
docs/public
manifest.json

View file

@ -1,39 +0,0 @@
{
"manifest_version": 2,
"name": "Rust Search Extension",
"description": "A handy browser extension to search crates and official docs in the address bar (omnibox)",
"version": "0.6",
"icons": {
"16": "icon.png",
"48": "icon.png",
"128": "icon.png"
},
"browser_action": {
"default_icon": {
"16": "icon.png",
"48": "icon.png",
"128": "icon.png"
},
"default_popup": "popup.html",
"default_title": "A handy browser extension to search crates and official docs in the address bar (omnibox)"
},
"content_security_policy": "script-src-elem 'self' https://rust-search-extension.now.sh/crates/crates-index.js; script-src 'self'; object-src 'self'",
"omnibox": {
"keyword": "rs"
},
"background": {
"scripts": [
"settings.js",
"search.js",
"search-index.js",
"deminifier.js",
"crate-search.js",
"crates-index.js",
"omnibox.js",
"main.js"
]
},
"permissions": [
"tabs"
]
}

48
manifest.jsonnet Normal file
View file

@ -0,0 +1,48 @@
// jsonnet manifest.jsonnet --ext-str browser=chrome|firefox -o extension/manifest.json
local manifest = {
manifest_version: 2,
name: "Rust Search Extension",
description: "A handy browser extension to search crates and official docs in the address bar (omnibox)",
version: "0.6",
icons: {
"16": "icon.png",
"48": "icon.png",
"128": "icon.png"
},
browser_action: {
"default_icon": {
"16": "icon.png",
"48": "icon.png",
"128": "icon.png"
},
default_popup: "popup.html",
default_title: "A handy browser extension to search crates and official docs in the address bar (omnibox)"
},
content_security_policy: "script-src 'self'; object-src 'self';",
omnibox: {
"keyword": "rs"
},
background: {
scripts: [
"settings.js",
"search.js",
"search-index.js",
"deminifier.js",
"crate-search.js",
"crates-index.js",
"omnibox.js",
"main.js"
]
},
permissions: [
"tabs"
],
appendContentSecurityPolicy(policy)::self + {
content_security_policy +: policy,
}
};
if std.extVar("browser") == "chrome" then
manifest.appendContentSecurityPolicy(" script-src-elem 'self' https://rust-search-extension.now.sh/crates/crates-index.js;")
else manifest