-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.sh
executable file
·82 lines (71 loc) · 2.33 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
# Check if argument is set
if [ -z "$1" ]
then
echo "BUILD ERROR: No argument supplied"
exit 1
fi
# Check if argument is "production" or "dev"
if [ $1 != "production" ] && [ $1 != "dev" ]
then
echo "BUILD ERROR: Argument must be 'production' or 'dev'"
exit 1
fi
# Update composer packages
echo "Updating composer packages (should also be made manually as often as possible)..."
rm -rf vendor
composer update -o --no-progress --no-dev > /dev/null 2>&1
# Check if argument is "production" and version number is set
if [ $1 == "production" ] && [ -z "$2" ]
then
echo "BUILD ERROR: No version number supplied"
exit 1
fi
# Create build folder, overwrite if exists
rm -rf build
mkdir build
# Copy all files in this folder to build folder, except for build folder
cp -r assets build
cp -r includes build
cp -r vendor build
cp -r mobile-bankid-integration.php build
cp -r index.php build
cp -r readme.txt build
cp -r LICENSE.md build
# If argument is "production", minimize js/css and update version number
if [ $1 == "production" ]
then
echo "Building production version $2..."
gsed -i 's/Version: .*/Version: '$2'/g' build/mobile-bankid-integration.php
gsed -i "s/define( 'MOBILE_BANKID_INTEGRATION_VERSION', '.*' );/define( 'MOBILE_BANKID_INTEGRATION_VERSION', '$2' );/g" build/mobile-bankid-integration.php
#Minimize CSS
cp -r build/assets/css/setup.css build/assets/css/setup.full.css
cleancss -o build/assets/css/setup.css build/assets/css/setup.css
cp -r build/assets/css/login.css build/assets/css/login.full.css
cleancss -o build/assets/css/login.css build/assets/css/login.css
#Minimize JS
cp -r build/assets/js/setup.js build/assets/js/setup.full.js
uglifyjs build/assets/js/setup.js -o build/assets/js/setup.js
cp -r build/assets/js/login.js build/assets/js/login.full.js
uglifyjs build/assets/js/login.js -o build/assets/js/login.js
fi
# If argument is "dev", change plugin name
if [ $1 == "dev" ]
then
echo "Building development version..."
gsed -i 's/Plugin Name: Mobile BankID Integration/Plugin Name: Mobile BankID Integration DEV/g' build/mobile-bankid-integration.php
fi
# Zip contents of build folder
cd build
if [ $1 == "production" ]
then
zip -r ../build-$2.zip . > /dev/null 2>&1
fi
if [ $1 == "dev" ]
then
zip -r ../build-dev.zip . > /dev/null 2>&1
fi
cd ..
# Remove build folder
rm -rf build
# Done
echo "Done!"