-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathmake.sh
executable file
·204 lines (159 loc) · 4.88 KB
/
make.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
200
201
202
203
204
#!/bin/bash -x
#
#
#
set -o errexit
set -o errtrace
set -o nounset
set -o pipefail
BIN_SELF=$(readlink -f "$0")
APP_ROOT=$(dirname "$BIN_SELF")
f=$(readlink -f "$0")
d=$(dirname "$f")
cd "$d"
action="${1:-}"
case "$action" in
#
# Clean up the junk
clean)
rm -frv ./node_modules
rm -frv ./webroot/lib
rm -fv ./webroot/css/app.css*
rm -fv ./webroot/js/app.js webroot/js/app.js.gz
rm -fv ./webroot/js/vendor.js webroot/js/vendor.js.gz
;;
#
# Build the App CSS
css)
./node_modules/.bin/sass \
--no-quiet \
--style=compressed \
--verbose \
scss/_.scss \
webroot/css/app.css
#_gzip ./webroot/css/app.css
gzip --force --keep ./webroot/css/app.css
;;
#
# Install
install)
# jquery
mkdir -p webroot/vendor/jquery/
cp node_modules/jquery/dist/jquery.min.js webroot/vendor/jquery/
cp node_modules/jquery/dist/jquery.min.map webroot/vendor/jquery/
# jquery-ui
mkdir -p webroot/vendor/jquery-ui/
cp node_modules/jquery-ui/dist/jquery-ui.min.js webroot/vendor/jquery-ui/
cp node_modules/jquery-ui/dist/themes/base/jquery-ui.min.css webroot/vendor/jquery-ui/
# bootstrap
mkdir -p webroot/vendor/bootstrap/
cp node_modules/bootstrap/dist/css/bootstrap.min.css webroot/vendor/bootstrap/
cp node_modules/bootstrap/dist/css/bootstrap.min.css.map webroot/vendor/bootstrap/
cp node_modules/bootstrap/dist/js/bootstrap.bundle.min.js webroot/vendor/bootstrap/
cp node_modules/bootstrap/dist/js/bootstrap.bundle.min.js.map webroot/vendor/bootstrap/
# font awesome
mkdir -p webroot/vendor/fontawesome/css webroot/vendor/fontawesome/webfonts
cp node_modules/@fortawesome/fontawesome-free/css/all.min.css webroot/vendor/fontawesome/css/
cp node_modules/@fortawesome/fontawesome-free/webfonts/* webroot/vendor/fontawesome/webfonts/
# htmx
mkdir -p webroot/vendor/htmx
cp node_modules/htmx.org/dist/htmx.min.js webroot/vendor/htmx/
;;
#
# Build the JS STuff
js)
rm -fr \
./webroot/js/app.js \
./webroot/js/app.js.gz \
./webroot/js/vendor.js \
./webroot/js/vendor.js.gz
#cat ./webroot/lib/lodash/lodash.js \
# ./webroot/lib/jquery/dist/jquery.js \
# ./webroot/lib/jquery-ui/dist/jquery-ui.js \
# > ./webroot/js/vendor.js
cat ./webroot/lib/lodash/lodash.js \
./webroot/lib/jquery/dist/jquery.js \
./webroot/lib/jquery-ui/ui/core.js \
./webroot/lib/jquery-ui/ui/widget.js \
./webroot/lib/jquery-ui/ui/position.js \
./webroot/lib/jquery-ui/ui/autocomplete.js \
./webroot/lib/jquery-ui/ui/menu.js \
> ./webroot/js/vendor.js
#
# App CSS
cat ./webroot/js/base.js \
./webroot/js/weed.js \
./webroot/js/weed-printer.js \
./webroot/js/weed-bulkmenu.js \
./webroot/js/weed-keyboard.js \
./webroot/js/weed-scanner.js \
> ./webroot/js/app.js
#
# Pack them
./node_modules/.bin/uglifyjs ./webroot/js/vendor.js > ./webroot/js/vendor.js.tmp
mv ./webroot/js/vendor.js.tmp ./webroot/js/vendor.js
gzip --force --keep ./webroot/js/vendor.js
./node_modules/.bin/uglifyjs ./webroot/js/app.js > ./webroot/js/app.js.tmp
mv ./webroot/js/app.js.tmp ./webroot/js/app.js
gzip --force --keep ./webroot/js/app.js
;;
#
# Lint all the files
lint)
jslint="./node_modules/.bin/jslint --maxerr=10 --terse"
jslint="./node_modules/.bin/jshint --show-non-errors"
#./node_modules/.bin/jscpd
find_opts="! -path '*/node_modules/*' ! -path '*/vendor/*' ! -path '*webroot/lib*' -type f "
find_opts="! -path './.git/*' ! -path './lib/php-google-cloud-print/*' ! -path './node_modules/*' ! -path './vendor/*' ! -path './webroot/lib/*'"
# Lint PHP
# find ./ $find_opts -name '*.php' -exec php -l {} \; >/dev/null
# Lint JS
#find \
# ./jsx/ \
# ./webroot/js \
# -name '*.js' \
# -exec $jslint {} \;
# Lint Less
# find ./webroot/css -name '*.less' -exec ./node_modules/.bin/lessc --lint {} \;
# Lint CSS
# find ./webroot/css $find_opts -name '*.css' -exec ./node_modules/.bin/csslint --format=compact --quiet {} \;
#
# Find Non Unix EOL Files
#find ./ $find_opts -exec file {} \; \
# | grep CRLF \
# > CRLF.out
#
# Find File that have leading whitespace that is four or more spaces
find ./ \
! -path './.git/*' \
! -path './lib/php-google-cloud-print/*' \
! -path './node_modules/*' \
! -path './vendor/*' \
! -path './webroot/lib/*' \
| xargs ack --nopager '^\t+ +'
# | grep -v ':0' \
# | awk 'BEGIN { FS = ":" }; { print $2 " " $1 }' \
# | xargs -l ack --count --nobreak --nofollow --nopager --sort-files --recurse '^\t+ +' \
# | sort -n \
# | tail -n 20
;;
#
# Help, the default target
help|*)
set +x
echo
echo "You must supply a make command"
echo
grep -ozP "^#\n#.*\n[a-zA-Z_-]+\)" $0 \
| awk '/[a-zA-Z_-]+\)/ { printf " \033[0;49;31m%-15s\033[0m%s\n", $$1, gensub(/^# /, "", "", x) }; { x=$$0 }' \
| sort
echo
esac
# https://github.com/kucherenko/jscpd
#
# #
# # Make all the things for live
# live: css-full js-full
# #git clone https://github.com/yasirsiddiqui/php-google-cloud-print.git ./lib/php-google-cloud-print
# ./composer.phar self-update
# ./composer.phar update