2021-07-31 20:49:32 +02:00
|
|
|
#!/usr/bin/env bash
|
2021-07-25 16:55:35 +02:00
|
|
|
#
|
|
|
|
# This script assumes a linux environment
|
|
|
|
|
2021-07-31 23:34:25 +02:00
|
|
|
set -e
|
|
|
|
|
2021-07-25 16:55:35 +02:00
|
|
|
DES=dist/build/uBlock0.nodejs
|
|
|
|
|
2021-08-03 13:02:48 +02:00
|
|
|
rm -rf $DES
|
|
|
|
|
2021-07-25 16:55:35 +02:00
|
|
|
mkdir -p $DES/js
|
|
|
|
cp src/js/base64-custom.js $DES/js
|
|
|
|
cp src/js/biditrie.js $DES/js
|
2021-08-03 18:19:25 +02:00
|
|
|
cp src/js/dynamic-net-filtering.js $DES/js
|
2021-07-25 16:55:35 +02:00
|
|
|
cp src/js/filtering-context.js $DES/js
|
|
|
|
cp src/js/globals.js $DES/js
|
2021-08-03 18:19:25 +02:00
|
|
|
cp src/js/hnswitches.js $DES/js
|
2021-07-25 16:55:35 +02:00
|
|
|
cp src/js/hntrie.js $DES/js
|
|
|
|
cp src/js/static-filtering-parser.js $DES/js
|
|
|
|
cp src/js/static-net-filtering.js $DES/js
|
|
|
|
cp src/js/static-filtering-io.js $DES/js
|
2021-07-31 14:59:55 +02:00
|
|
|
cp src/js/text-utils.js $DES/js
|
2021-07-25 16:55:35 +02:00
|
|
|
cp src/js/uri-utils.js $DES/js
|
2021-08-03 18:19:25 +02:00
|
|
|
cp src/js/url-net-filtering.js $DES/js
|
2021-07-25 16:55:35 +02:00
|
|
|
|
|
|
|
mkdir -p $DES/lib
|
|
|
|
cp -R src/lib/punycode.js $DES/lib/
|
|
|
|
cp -R src/lib/regexanalyzer $DES/lib/
|
2021-07-31 13:06:11 +02:00
|
|
|
cp -R src/lib/publicsuffixlist $DES/lib/
|
|
|
|
|
|
|
|
# Convert wasm modules into json arrays
|
|
|
|
mkdir -p $DES/js/wasm
|
|
|
|
cp src/js/wasm/* $DES/js/wasm/
|
|
|
|
node -pe "JSON.stringify(Array.from(fs.readFileSync('src/js/wasm/hntrie.wasm')))" \
|
|
|
|
> $DES/js/wasm/hntrie.wasm.json
|
|
|
|
node -pe "JSON.stringify(Array.from(fs.readFileSync('src/js/wasm/biditrie.wasm')))" \
|
|
|
|
> $DES/js/wasm/biditrie.wasm.json
|
|
|
|
node -pe "JSON.stringify(Array.from(fs.readFileSync('src/lib/publicsuffixlist/wasm/publicsuffixlist.wasm')))" \
|
|
|
|
> $DES/lib/publicsuffixlist/wasm/publicsuffixlist.wasm.json
|
2021-07-25 16:55:35 +02:00
|
|
|
|
2021-07-29 16:06:49 +02:00
|
|
|
git submodule update --depth 1 --init
|
|
|
|
UASSETS=submodules/uAssets
|
2021-07-29 01:40:11 +02:00
|
|
|
|
2021-07-28 16:38:24 +02:00
|
|
|
# https://github.com/uBlockOrigin/uBlock-issues/issues/1664#issuecomment-888332409
|
2021-07-29 01:40:11 +02:00
|
|
|
THIRDPARTY=$UASSETS/thirdparties/publicsuffix.org
|
2021-07-25 16:55:35 +02:00
|
|
|
mkdir -p $DES/data
|
2021-08-01 21:42:46 +02:00
|
|
|
node -pe "JSON.stringify(fs.readFileSync('$THIRDPARTY/list/effective_tld_names.dat', 'utf8'))" \
|
|
|
|
> $DES/data/effective_tld_names.json
|
2021-07-29 01:40:11 +02:00
|
|
|
THIRDPARTY=$UASSETS/thirdparties/easylist-downloads.adblockplus.org
|
2021-07-28 16:38:24 +02:00
|
|
|
node -pe "JSON.stringify(fs.readFileSync('$THIRDPARTY/easylist.txt', 'utf8'))" \
|
|
|
|
> $DES/data/easylist.json
|
|
|
|
node -pe "JSON.stringify(fs.readFileSync('$THIRDPARTY/easyprivacy.txt', 'utf8'))" \
|
|
|
|
> $DES/data/easyprivacy.json
|
2021-07-25 16:55:35 +02:00
|
|
|
|
2021-08-13 12:43:20 +02:00
|
|
|
cp platform/nodejs/.*.json $DES/
|
2021-08-05 20:36:13 +02:00
|
|
|
cp platform/nodejs/*.js $DES/
|
|
|
|
cp platform/nodejs/*.json $DES/
|
|
|
|
cp platform/nodejs/README.md $DES/
|
|
|
|
cp LICENSE.txt $DES/
|
2021-07-29 01:40:11 +02:00
|
|
|
|
2021-08-10 02:02:58 +02:00
|
|
|
cd $DES
|
|
|
|
npm run build
|
2021-08-12 13:57:56 +02:00
|
|
|
tarballname=$(npm pack 2> /dev/null)
|
2021-08-12 14:33:43 +02:00
|
|
|
if [ "$1" ]; then
|
2021-07-29 01:40:11 +02:00
|
|
|
echo "*** uBlock0.nodejs: Creating versioned package..."
|
2021-08-12 14:33:43 +02:00
|
|
|
mv $tarballname ../uBlock0_"$1".nodejs.tgz
|
|
|
|
else
|
|
|
|
echo "*** uBlock0.nodejs: Creating plain package..."
|
|
|
|
mv $tarballname ../uBlock0.nodejs.tgz
|
2021-07-29 01:40:11 +02:00
|
|
|
fi
|
2021-08-12 14:33:43 +02:00
|
|
|
cd -
|
2021-07-29 01:40:11 +02:00
|
|
|
|
|
|
|
echo "*** uBlock0.nodejs: Package done."
|