aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-webextension/pack.sh
blob: f83948a4dc3e87bac57d90590edf842a16e29f96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env bash
# This file is in the public domain.

ENV=$1
set -eu

if [[ ! -e package.json ]]; then
  echo "Please run this from the root of the repo.">&2
  exit 1
fi

[[ "$ENV" == "prod" || "$ENV" == "dev" ]] || { echo "first argument must be prod or dev"; exit 1; }

vers_manifest=$(jq -r '.version' manifest-common.json)


# Create version form Manifest v2
zipfile="taler-wallet-webextension-${vers_manifest}.zip"

TEMP_DIR=$(mktemp -d)
jq -s 'add | .name = "GNU Taler Wallet" ' manifest-common.json manifest-v2.json > $TEMP_DIR/manifest.json
cp -r static $TEMP_DIR
cp -r dist/prod $TEMP_DIR/dist

find $TEMP_DIR/dist \( -name "test.*" -o -name "*.test.*" -o -name "stories.*" -o -name "*.dev.*" \) -delete
[[ "$ENV" == "prod" ]] && find $TEMP_DIR/dist \( -name "*.map" \) -delete
find $TEMP_DIR/dist -type d -empty -delete

(cd $TEMP_DIR && zip -q -r "$zipfile" dist static manifest.json)

mkdir -p extension/v2
mv "$TEMP_DIR/$zipfile" ./extension/v2/
rm -rf $TEMP_DIR
# also provide unpacked version
rm -rf extension/v2/unpacked
mkdir -p extension/v2/unpacked
(cd extension/v2/unpacked && unzip -q ../$zipfile)
echo "Packed webextension: extension/v2/$zipfile"
cp -rf src extension/v2/unpacked

# Create version form Manifest v3
zipfile="taler-wallet-webextension-${vers_manifest}.zip"

TEMP_DIR=$(mktemp -d)
jq -s 'add | .name = "GNU Taler Wallet" ' manifest-common.json manifest-v3.json > $TEMP_DIR/manifest.json
cp -r static $TEMP_DIR
cp -r dist/prod $TEMP_DIR/dist
cp -r service_worker.js $TEMP_DIR

find $TEMP_DIR/dist \( -name "test.*" -o -name "*.test.*" -o -name "stories.*" -o -name "*.dev.*" \) -delete
[[ "$ENV" == "prod" ]] && find $TEMP_DIR/dist \( -name "*.map" \) -delete
find $TEMP_DIR/dist -type d -empty -delete

(cd $TEMP_DIR && zip -q -r "$zipfile" dist static manifest.json service_worker.js)
mkdir -p extension/v3
mv "$TEMP_DIR/$zipfile" ./extension/v3/
rm -rf $TEMP_DIR
# also provide unpacked version
rm -rf extension/v3/unpacked
mkdir -p extension/v3/unpacked
(cd extension/v3/unpacked && unzip -q ../$zipfile)
echo "Packed webextension: extension/v3/$zipfile"