-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplugin-build.sh
114 lines (96 loc) · 3.19 KB
/
plugin-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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/bin/bash
# Prompt user for branch name
read -p "Enter the branch name: " GIT_BRANCH
# Define the build directory
BUILD_DIR="godam-build"
# Define the build commands
NPM_INSTALL="npm install"
BUILD_COMMAND="npm run build:prod"
BUILD_COMPOSER="composer install --optimize-autoloader --no-dev"
CLONE_REPO="git clone [email protected]:rtCamp/godam.git $BUILD_DIR"
CHECKOUT_BRANCH="git checkout $GIT_BRANCH"
# Define unwanted files and folders to remove after build
UNWANTED_ITEMS=(
"node_modules" # Remove node_modules
"assets/src/blocks" # Remove source code files
"assets/src/css" # Remove source code files
"assets/src/js" # Remove source code files
"assets/src/libs/jquery-ui-1.14.1.draggable" # Remove source code files
"pages/analytics" # Remove source code files
"pages/godam" # Remove source code files
"pages/help" # Remove source code files
"pages/media-library" # Remove source code files
"pages/video-editor" # Remove source code files
"pages/style.css" # Remove source code files
"tests" # Remove test files
".browserslistrc" # Remove log files
".eslintignore"
".eslintrc"
".gitignore"
".jscsrc"
".jshintignore"
".lintstagedrc.js"
".npmrc"
".nvmrc"
".stylelintignore"
".stylelintrc.json"
"babel.config.js"
"deploy.sh"
"Gulpfile.js"
"package-lock.json"
"package.json"
"phpcs.xml"
"postcss.config.js"
"tailwind.config.js"
"webpack.config.js"
".github"
".git"
"plugin-build.sh"
)
# Ensure the script runs from the project root
PROJECT_ROOT=$(pwd)
PLUGIN_BUILD_PATH="$PROJECT_ROOT/$BUILD_DIR"
# Clone the repo from github
echo "Cloning the repository..."
$CLONE_REPO
# Navigate to the build directory
cd "$PLUGIN_BUILD_PATH" || exit
# Checkout the specified branch
echo "Checking out the $GIT_BRANCH branch..."
$CHECKOUT_BRANCH
# Run the composer build command
echo "Running composer build process inside $PLUGIN_BUILD_PATH..."
$BUILD_COMPOSER
# Run npm install
echo "Installing dependencies inside $PLUGIN_BUILD_PATH..."
$NPM_INSTALL
# Check if npm install was successful
if [ $? -eq 0 ]; then
echo "Dependencies installed successfully."
else
echo "npm install failed. Exiting..."
exit 1
fi
# Run the build command
echo "Running build process inside $PLUGIN_BUILD_PATH..."
$BUILD_COMMAND
# Check if the build command was successful
if [ $? -eq 0 ]; then
echo "Build completed successfully."
# Remove unwanted files and folders
for item in "${UNWANTED_ITEMS[@]}"; do
echo "Removing $item..."
rm -rf $item
done
# Generate a .zip file
echo "Creating a .zip file..."
zip -r "$BUILD_DIR.zip" ./*
# Move the .zip file to the project root
mv "$BUILD_DIR.zip" "$PROJECT_ROOT"
# Remove the build directory
rm -rf "$PLUGIN_BUILD_PATH"
echo "Cleanup completed in $PLUGIN_BUILD_PATH."
else
echo "Build failed. Skipping cleanup."
exit 1
fi