-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake.sh
More file actions
executable file
·94 lines (75 loc) · 1.93 KB
/
Copy pathmake.sh
File metadata and controls
executable file
·94 lines (75 loc) · 1.93 KB
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
#!/bin/bash
set -euo pipefail
cd "${0%/*}" || exit
function build {
local target=$1
mkdir -p "$target"
cp --update LICENSE "$target/"
pushd src &>/dev/null
cp --update plugin.info.txt style.css "../$target/"
if [ "$target" == "debug" ]; then
find . -type f -iname '*.php' -exec cp --parents --update {} "../$target" \;
else
for file in $(find . -type f -iname '*.php'); do
if [ ! -f "../$target/$file" ] || [ "$file" -nt "../$target/$file" ]; then
mkdir -p "../$target/$(dirname "$file")"
php --strip "$file" > "../$target/$file"
fi
done
fi
popd &>/dev/null
# lint and minify javascript
local compilation_level=SIMPLE
if [ "$target" == "debug" ]; then
compilation_level=BUNDLE
fi
if [ ! -f "$target/script.js" ] || [ "src/script.js" -nt "$target/script.js" ]; then
echo "Compiling script.js"
google-closure-compiler --js src/script.js --js_output_file "$target/script.js" \
--externs "/usr/local/lib/node_modules/google-closure-compiler/contrib/externs/jquery-3.3.js" \
--externs "build/dokuwiki-externs.js" \
--compilation_level $compilation_level \
--language_in STABLE \
--language_out STABLE \
--warning_level VERBOSE
fi
# precompress javascript to support static asset serving
gzip --force --keep --verbose "$target/script.js"
# get release date
local date;
date=$(grep -E "^date\s+" "$target/plugin.info.txt" | grep -Eo "[^ \t]+$")
# pack everything together
pushd "$target" &>/dev/null
zip -9 -X --latest-time --filesync --recurse-paths "../dokuwiki_selectionsearch_$target-$date.zip" ./*
popd &>/dev/null
}
function check {
find src -type f -iname '*.php' -exec php --syntax-check {} \;
}
function clean {
rm -rf release
rm -rf debug
}
case "$1" in
clean)
clean
;;
check)
check
;;
debug)
check
build debug
;;
release)
check
build release
;;
all)
build debug
build release
;;
*)
echo $"Usage: $0 all|check|clean|debug|release"
exit 1
esac