-
Notifications
You must be signed in to change notification settings - Fork 14
/
package.sh
executable file
·76 lines (53 loc) · 1.51 KB
/
package.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
#!/bin/sh
SRC_DIR="plugin"
MAIN_FILE="webpay-rest.php"
README_FILE="readme.txt"
COMPOSER_FILE="composer.json"
COMPOSER_LOCK_FILE="composer.lock"
package_plugin() {
echo "Packaging plugin."
check_tag
cd $SRC_DIR
composer install --no-dev > /dev/null 2>&1
npm install --no-audit --no-fund --no-optional > /dev/null 2>&1
npm run build > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "Command npm run build finished with error" 1>&2
exit 1
fi
rm -rf node_modules/
set_plugin_tag
create_zip
cd ..
restore_files
echo "\\nPlugin created, the detail is:"
echo "- Version: $TAG"
echo "- File name: $PLUGIN_FILE"
}
check_tag() {
if [ "$TAG" = "" ]
then
echo "No Tag found. Using default Tag 1.0.0"
TAG='1.0.0'
fi
echo "Tag: $TAG"
}
set_plugin_tag() {
echo "Setting tag ${TAG#"v"} in readme and main file."
sed -i.bkp "s/Version: VERSION_REPLACE_HERE/Version: ${TAG#"v"}/g" $MAIN_FILE
sed -i.bkp "s/VERSION_REPLACE_HERE/${TAG#"v"}/g" $README_FILE
}
create_zip() {
echo "Creating zip file."
EXCLUSIONS="webpack.config.js *.lock *.json *.bkp"
PLUGIN_FILE="transbank-webpay-plus-rest.zip"
zip -FSr ../$PLUGIN_FILE . -x $EXCLUSIONS > /dev/null
}
restore_files() {
echo "Restoring readme and main file."
cp "$SRC_DIR/$MAIN_FILE.bkp" "$SRC_DIR/$MAIN_FILE"
rm "$SRC_DIR/$MAIN_FILE.bkp"
cp "$SRC_DIR/$README_FILE.bkp" "$SRC_DIR/$README_FILE"
rm "$SRC_DIR/$README_FILE.bkp"
}
package_plugin