uBlock/tools/make-nodejs.sh
Raymond Hill 087da6407d
Add support for nodejs flavors
The main nodejs flavor is "npm", which is to be used to
lint/test and the publication of an official npm
package -- and by design it has dependencies on mocha,
eslint, etc.

A new flavor "dig" has been created with minimal
dependencies and which purpose is to easily allow to
write specialized code to investigate local code changes
in uBO -- and it's not meant for publication.

Consequently, "make nodejs" has been replaced with
"make npm", and a new "dig" target has been added to the
makefile, to be used for instrumenting local code changes
for investigation purpose.
2021-08-15 10:43:36 -04:00

41 lines
1.4 KiB
Bash
Executable file

#!/usr/bin/env bash
#
# This script assumes a linux environment
set -e
DES=$1
mkdir -p $DES/js
cp src/js/base64-custom.js $DES/js
cp src/js/biditrie.js $DES/js
cp src/js/dynamic-net-filtering.js $DES/js
cp src/js/filtering-context.js $DES/js
cp src/js/globals.js $DES/js
cp src/js/hnswitches.js $DES/js
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
cp src/js/text-utils.js $DES/js
cp src/js/uri-utils.js $DES/js
cp src/js/url-net-filtering.js $DES/js
mkdir -p $DES/lib
cp -R src/lib/punycode.js $DES/lib/
cp -R src/lib/regexanalyzer $DES/lib/
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
cp platform/nodejs/*.js $DES/
cp platform/nodejs/README.md $DES/
cp LICENSE.txt $DES/