-
Notifications
You must be signed in to change notification settings - Fork 13
/
build.sh
executable file
·100 lines (88 loc) · 2.61 KB
/
build.sh
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/bash
copyDevFunction() {
echo "Copying files to ./dev/"
rm -rf ./dev/*
cp -rf css ./dev/
cp -rf js ./dev/
cp -rf img ./dev/
cp background.js ./dev/
cp manifest.json ./dev/
cp options.html ./dev/
cp popup.html ./dev/
rm ./dev/img/icon_full.png # raw file
rm ./dev/img/LICENSE
rm ./dev/img/flags/Hello.txt
rm ./dev/img/flags/LICENSE.txt
}
prepareChromeFunction() {
echo "Preparing manifest.json for Chrome"
}
packageChromeFunction() {
prepareChromeFunction
echo "Creating archive for Chrome"
cd ./dev/
zip -qr chrome.zip ./*
cd ..
cp ./dev/chrome.zip ./build/
echo "Archive created in ./build/"
}
prepareFirefoxFunction() {
#echo "Preparing manifest.json for Firefox"
echo "Firefox is currently not supported. It uses a different manifest.json file. Use an older version of the extension for Firefox."
exit 1
#sed -i -e '14d;16d;17d' ./dev/manifest.json
cd ./dev/
zip -qr firefox.zip ./*
cd ..
echo "Package for Firefox in ./dev/ created."
}
packageFirefoxFunction() {
prepareFirefoxFunction
echo "Creating archive for Firefox"
cp ./dev/firefox.zip ./build/
}
prepareOperaFunction() {
echo "Preparing manifest.json for Opera"
echo "Right now it is the same as Chrome, going for it..."
prepareChromeFunction
}
packageOperaFunction() {
prepareOperaFunction
cp -rf ./dev/* ./build/
echo "Use Opera and select the ./build/ directory and create a signed package."
}
if [ -z "$1" ] || ([ "$1" != "dev" ] && [ "$1" != "package" ]); then
echo ""
echo "Usage: $0 [dev chrome|firefox|opera] [package chrome|firefox|opera]"
echo -e "\tdev [chrome|firefox|opera] - Copies extension files into ./dev/ folder to load it from any browser in development mode. Archive file is for Firefox."
echo -e "\tpackage [chrome|firefox|opera] - creates production ready archives to upload them on the specific extension store."
exit 1
fi
echo "Running $1 command..."
if [ "$1" == "dev" ]; then
mkdir -p ./dev/
copyDevFunction
if [ "$2" == "chrome" ]; then
prepareChromeFunction
elif [ "$2" == "opera" ]; then
prepareOperaFunction
else
prepareFirefoxFunction
fi
echo "Done, now load extension in browser."
fi
if [ "$1" == "package" ]; then
mkdir -p ./build/
rm -rf ./build/*
echo "Building package for $2"
copyDevFunction
if [ "$2" == "chrome" ]; then
packageChromeFunction
elif [ "$2" == "opera" ]; then
packageOperaFunction
else
packageFirefoxFunction
fi
echo "Done, now publish package."
fi
exit 0