Skip to content

Commit

Permalink
feat: add script for testing update process (ghostery#1879)
Browse files Browse the repository at this point in the history
  • Loading branch information
smalluban authored Sep 13, 2024
1 parent 4248856 commit 273acfd
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions extension-manifest-v3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"download-wtm-stats": "node scripts/download-wtm-stats.js",
"build": "node scripts/build.js",
"start": "npm run build -- --watch",
"start:update": "./scripts/update.sh",
"licenses": "license-report --config=../.license-report-config.json > dist/licenses.html",
"lint": "eslint src/",
"test": "node --test && npm run lint",
Expand Down
1 change: 1 addition & 0 deletions extension-manifest-v3/scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ if (argv.watch) {
case 'firefox':
settings = {
target: 'firefox-desktop',
devtools: true,
firefoxBinary:
'/Applications/Firefox Nightly.app/Contents/MacOS/firefox-bin',
};
Expand Down
37 changes: 37 additions & 0 deletions extension-manifest-v3/scripts/update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# The script will download the latest tag, unzip it, and run the extension.
# Then it will wait for the user to press enter, rebuild the extension from
# the current branch, and finally kill the browser.
#
# Usage:
# ./scripts/update.sh [target=chromium] [tag=latest]
#
# Supported targets: chromium, firefox
#

target="${1:-chromium}"
tag=${2:-$(git describe --tags `git rev-list --tags --max-count=1`)}
version=${tag:1}

webExtTarget=$target
if [ $webExtTarget == "firefox" ]; then
webExtTarget="firefox-desktop"
fi

# Rebuild from latest tag
echo "Downloading and unzipping the latest tag: $tag"
rm -rf ./dist ./dist.zip
curl -L -o dist.zip "https://github.com/ghostery/ghostery-extension/releases/download/$tag/ghostery-$target-$version.zip"
unzip dist.zip -d ./dist
rm dist.zip

../node_modules/.bin/web-ext run --target=$webExtTarget --no-reload --devtools >/dev/null &
pid=$!

read -p "Booting up the target browser. Press enter to rebuild from source.."

# Rebuild from source
echo "Rebuilding from source: $currentBranch"
npm run build $target

read -p "Rebuilding done. Press enter to kill the browser..."
kill -2 $pid

0 comments on commit 273acfd

Please sign in to comment.