-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #143: Fix uploads for polish ad-block lists and cookie lists
- Loading branch information
Showing
5 changed files
with
120 additions
and
70 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
const { lists } = require('adblock-rs') | ||
const fs = require('fs-extra') | ||
const mkdirp = require('mkdirp') | ||
const path = require('path') | ||
|
||
var outPath = path.join('build', 'ad-block-updater'); | ||
|
||
const defaultAdblockComponentId = "cffkpbalmllkdoenhmdmpbkajipdjfam" | ||
const defaultAdblockBase64PublicKey = | ||
"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs0qzJmHSgIiw7IGFCxij" + | ||
"1NnB5hJ5ZQ1LKW9htL4EBOaMJvmqaDs/wfq0nw/goBHWsqqkMBynRTu2Hxxirvdb" + | ||
"cugn1Goys5QKPgAvKwDHJp9jlnADWm5xQvPQ4GE1mK1/I3ka9cEOCzPW6GI+wGLi" + | ||
"VPx9VZrxHHsSBIJRaEB5Tyi5bj0CZ+kcfMnRTsXIBw3C6xJgCVKISQUkd8mawVvG" + | ||
"vqOhBOogCdb9qza5eJ1Cgx8RWKucFfaWWxKLOelCiBMT1Hm1znAoVBHG/blhJJOD" + | ||
"5HcH/heRrB4MvrE1J76WF3fvZ03aHVcnlLtQeiNNOZ7VbBDXdie8Nomf/QswbBGa" + | ||
"VwIDAQAB" | ||
|
||
const generateManifestFile = (name, base64PublicKey, uuid) => { | ||
var manifest = "{\n" + | ||
" \"description\": \"Brave Ad Block Updater extension\",\n" + | ||
" \"key\": \"" + base64PublicKey + "\",\n" + | ||
" \"manifest_version\": 2,\n" + | ||
" \"name\": \"Brave Ad Block Updater (" + name + ")\",\n" + | ||
" \"version\": \"0.0.0\"\n" + | ||
"}\n" | ||
|
||
let filePath = path.join(outPath, uuid , 'manifest.json') | ||
let p = fs.writeFile(filePath, manifest); | ||
return p | ||
} | ||
|
||
const generateManifestFileForDefaultAdblock = | ||
generateManifestFile.bind(null, 'Default', defaultAdblockBase64PublicKey, 'default') // eslint-disable-line | ||
|
||
const generateManifestFilesForAllRegions = () => { | ||
let p = Promise.resolve() | ||
new lists('regions').forEach((region) => { // eslint-disable-line | ||
p = p.then(generateManifestFile.bind(null, region.title, | ||
region.base64_public_key, region.uuid)) | ||
}) | ||
} | ||
|
||
if (!fs.existsSync(outPath)){ | ||
fs.mkdirSync(outPath); | ||
} | ||
|
||
generateManifestFileForDefaultAdblock() | ||
.then(generateManifestFilesForAllRegions) | ||
.then(() => { | ||
console.log('Thank you for updating the data files, don\'t forget to upload them too!') | ||
}) | ||
.catch((e) => { | ||
console.error(`Something went wrong, aborting: ${e}`) | ||
process.exit(1) | ||
}) | ||
|
||
process.on('uncaughtException', (err) => { | ||
console.error('Caught exception:', err) | ||
process.exit(1) | ||
}) | ||
|
||
process.on('unhandledRejection', (err) => { | ||
console.error('Unhandled rejection:', err) | ||
process.exit(1) | ||
}) |
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