-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbundle.sh
57 lines (47 loc) · 2.04 KB
/
bundle.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
#!/usr/bin/env bash
#
# bundle.sh
# scripts
#
# Created by Fatih Balsoy on 4/14/23
# Copyright © 2023 Fatih Balsoy. All rights reserved.
#
SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
#?# Plugin Name and Version #?#
PLUGIN_BUNDLE_LINE=$(cat $SCRIPTPATH/src/wp-material-design.php | grep "\$fb_mdp_plugin_bundle =")
IFS='"'; set $PLUGIN_BUNDLE_LINE; php_var=$1; PLUGIN_BUNDLE=$2
PLUGIN_VERSION_LINE=$(cat $SCRIPTPATH/src/wp-material-design.php | grep "\$fb_mdp_plugin_version =")
IFS='"'; set $PLUGIN_VERSION_LINE; php_var=$1; PLUGIN_VERSION=$2
PLUGIN_ZIP_NAME="$PLUGIN_BUNDLE-$PLUGIN_VERSION"
echo "$PLUGIN_ZIP_NAME"
#?# Setup Build Directory #?#
echo "Setting up build directory..."
rm -rf $SCRIPTPATH/build/
mkdir -p $SCRIPTPATH/build/
mkdir -p $SCRIPTPATH/logs/
#?# Copy Files #?#
echo "Copying files..."
cp $SCRIPTPATH/README.md build/
cp $SCRIPTPATH/LICENSE build/
bash $SCRIPTPATH/copy_files.sh
#?# Compiling Sass and Typescript Files #?#
echo "Compiling Sass Files..."
sass $SCRIPTPATH/src/:$SCRIPTPATH/build/ --no-source-map --style compressed
echo "Compiling Typescript Files..."
tsc --declaration false
echo "Compressing Javascript Files..."
# Find all JavaScript files recursively and loop over them
find $SCRIPTPATH/build/ -type f -name "*.js" -print0 | while IFS= read -r -d '' file; do
# Compress each file
uglifyjs --compress --mangle --mangle-props -o $file -- $file
done
#?# Zip Files #?#
echo "Archiving..."
mkdir -p $SCRIPTPATH/build/_bundle/$PLUGIN_BUNDLE
rsync -avz --prune-empty-dirs $SCRIPTPATH/build/. $SCRIPTPATH/build/_bundle/$PLUGIN_BUNDLE >> $SCRIPTPATH/logs/out.log 2>> $SCRIPTPATH/logs/err.log
cd $SCRIPTPATH/build/_bundle
zip -r ./$PLUGIN_ZIP_NAME.zip $PLUGIN_BUNDLE >> $SCRIPTPATH/logs/out.log 2>> $SCRIPTPATH/logs/err.log
cd - >> $SCRIPTPATH/logs/out.log 2>> $SCRIPTPATH/logs/err.log
#?# Unzip files to verify match #?#
unzip $SCRIPTPATH/build/_bundle/$PLUGIN_ZIP_NAME.zip -d $SCRIPTPATH/build/_bundle/$PLUGIN_ZIP_NAME/ >> $SCRIPTPATH/logs/out.log 2>> $SCRIPTPATH/logs/err.log
echo "Done."