This repository was archived by the owner on Jan 14, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
199 lines (173 loc) · 5.34 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
#!/bin/bash
R='\033[0;31m'
G='\033[0;32m'
B='\033[0;96m'
PLUGIN='winamaz-woocommerce' # slug
PREFIX='WinamazWoocommerce' # StudlyCaps
if [ -d "${PLUGIN}" ]; then
rm -rf "${PLUGIN}"
fi
rm -f *.zip
# Activate plugin
echo -e "${G}Activating plugin..."
wp plugin activate "${PLUGIN}"
sleep 3
clear
# Unit testing
bash test.sh
sleep 3
clear
# Cloning plugin parts
echo -e "${G}Cloning plugin parts..."
mkdir "${PLUGIN}"
mkdir "${PLUGIN}/core"
cp "${PLUGIN}.php" "${PLUGIN}/${PLUGIN}.php"
cp "index.php" "${PLUGIN}/index.php"
cp "uninstall.php" "${PLUGIN}/uninstall.php"
cp "license.txt" "${PLUGIN}/license.txt"
cp "vanilleplugin.json" "${PLUGIN}/composer.json" # Used by packager
cp "core/changelog.txt" "${PLUGIN}/core/changelog.txt"
cp "core/Framework.php" "${PLUGIN}/core/Framework.php"
cp -r "core/assets" "${PLUGIN}/core/assets"
cp -r "core/storage" "${PLUGIN}/core/storage"
cp -r "core/system" "${PLUGIN}/core/system"
cp -r "core/view" "${PLUGIN}/core/view"
cp -r "languages" "${PLUGIN}/languages"
sleep 2
clear
# Composer update (Production)
echo -e "${G}Composer update (Production)..."
cd "${PLUGIN}"
composer clearcache
composer validate
composer update --no-dev -o
sleep 2
clear
# Packager init
echo -e "${G}VanillePlugin Packager init..."
if ! vanilleplugin --version vanilleplugin &> /dev/null
then
echo -e "${B}Installing global VanillePlugin Packager..."
composer global require --dev jakiboy/vanilleplugin-packager
fi
# Packaging
vanilleplugin -reg "\!${PREFIX}"
sleep 2
clear
# Test Packaging
vanilleplugin -test "\!${PREFIX}"
sleep 2
clear
# Removing development vendors
echo -e "${R}Removing development vendors..."
# Dynamic
find . -name "*.sh" -type f -delete
find . -name "*.md" -type f -delete
find . -name "phpunit.*" -type f -delete
find . -name ".gitignore" -type f -delete
find . -name ".editorconfig" -type f -delete
find . -name ".gitattributes" -type f -delete
find . -name ".codeclimate.yml" -type f -delete
find . -name ".travis.yml" -type f -delete
find . -name "composer.json" -type f -delete
find . -name "composer.lock" -type f -delete
find . -name "CHANGELOG" -type f -delete
find . -name "README" -type f -delete
find . -name "README.rst" -type f -delete
find . -name "LICENSE.txt" -type f -delete
find . -name "LICENSE" -type f -delete
find . -name "LICENCE" -type f -delete
find . -name "installed.json" -type f -delete
find . -name "_config.yml" -type f -delete
find . -name ".php_cs.dist" -type f -delete
find . -name ".php-cs-fixer.dist.php" -type f -delete
find "./core/vendor/" -type d -name ".github" -exec rm -rf {} +
find "./core/vendor/" -type d -name "bin" -exec rm -rf {} +
find "./core/vendor/" -type d -name "dist" -exec rm -rf {} +
find "./core/vendor/" -type d -name "tests" -exec rm -rf {} +
find "./core/vendor/" -type d -name "docs" -exec rm -rf {} +
find "./core/vendor/" -type d -name "examples" -exec rm -rf {} +
find "./core/vendor/" -type d -name "example" -exec rm -rf {} +
find "./core/vendor/" -type d -name "demo" -exec rm -rf {} +
# Custom
rm "core/vendor/jakiboy/vanilleplugin/logo.png"
sleep 2
clear
echo -e "${G}Restricting vendor directory..."
echo "deny from all" > "core/vendor/.htaccess"
sleep 2
clear
# Installing globals
if ! uglifyjs -v uglifyjs &> /dev/null
then
echo -e "${B}Installing global uglify-js package..."
npm install uglify-js -g
fi
if ! uglifycss --version uglifycss &> /dev/null
then
echo -e "${B}Installing global uglify-css package..."
npm install uglifycss -g
fi
# Minify CSS files
echo -e "${G}Minify CSS files..."
uglifycss "core/assets/front/css/style.css" --output "core/assets/front/css/style.css"
sleep 2
clear
# Minify JS files
echo -e "${G}Minify JS files..."
uglifyjs "core/assets/front/js/main.js" -c -m --output "core/assets/front/js/main.js"
sleep 2
clear
# Compile language files
echo -e "${G}Compile language files [FR]..."
msgfmt -o "languages/${PLUGIN}-fr_FR.mo" "languages/${PLUGIN}-fr_FR.po"
sleep 2
clear
# Remove plugin cache, temp & logs
echo -e "${R}Remove plugin cache, temp & logs..."
rm -rf "core/storage/cache"
rm -rf "core/storage/temp"
rm -rf "core/storage/logs"
sleep 2
clear
# Creating plugin storage directories
echo -e "${G}Creating plugin storage directories..."
mkdir "core/storage/cache"
mkdir "core/storage/temp"
mkdir "core/storage/logs"
sleep 2
clear
# Update plugin config & disable debug mode
echo -e "${G}Update plugin config & disable debug mode..."
rm "core/storage/config/global.json.example"
DEBUGON='"debug": true'
DEBUGOFF='"debug": false'
cp "core/storage/config/global.json" "core/storage/config/global.tmp"
sed "s/${DEBUGON}/${DEBUGOFF}/g" "core/storage/config/global.tmp" > "core/storage/config/global.json"
rm "core/storage/config/global.tmp"
sleep 2
clear
if ! json --version json &> /dev/null
then
echo -e "${B}Installing global Json Parser..."
npm install -g json
fi
echo -e "${G}Parsing version from global.json..."
VERSION=`cat core/storage/config/global.json`
VERSION=`echo ${VERSION} | json version`
sleep 2
clear
cd ..
# Generating language archive
echo -e "${G}Generating language [FR] archive [${VERSION}]..."
zip "${PLUGIN}-${VERSION}-fr_FR.zip" -r -j "languages/${PLUGIN}-fr_FR.mo" "languages/${PLUGIN}-fr_FR.po"
sleep 2
clear
# Generating plugin production archive
echo -e "${G}Generating plugin production archive [${VERSION}]..."
zip "${PLUGIN}-${VERSION}.zip" -r "${PLUGIN}"
rm -rf "${PLUGIN}"
sleep 2
clear
# Pushing plugin production files
echo "Done :D"