-
Notifications
You must be signed in to change notification settings - Fork 154
/
lint-theme.sh
executable file
·52 lines (43 loc) · 1.38 KB
/
lint-theme.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
#!/bin/sh
# Simple script to check for common errors in themes
do_lint() {
echo "== Linting $1 =="
if [ ! -d $1 ] ; then
echo " * Does not exist!"
return 1
fi
cd $1
if [ ! -f theme.json ] ; then
echo " * Missing theme.json, skipping further checks!"
cd ..
return 1
fi
if [ ! -f screen.png ] ; then
echo " * Missing screen.png, skipping further checks!"
cd ..
return 1
fi
JVERSION=`php -r "echo json_decode(file_get_contents('theme.json'), true)['version'];"`
echo " * Version from theme.json: $JVERSION"
echo " * Supported phpMyAdmin versions: `php -r "echo implode(', ', json_decode(file_get_contents('theme.json'), true)['supports']);"`"
echo " * Metadata:"
php -r "\$data = json_decode(file_get_contents('theme.json'), true); foreach (\$data as \$item => \$value) { echo ' - ' . \$item . ': '; if (is_array(\$value)) { echo implode(', ', \$value); } else { echo \$value; }; echo \"\\n\"; }"
cd ..
}
if [ -z "$1" ] ; then
echo "Usage: lint-theme.sh [--all|THEMEDIR]"
exit 1
fi
if [ "x$1" = "x--all" ] ; then
EXIT_CODE=0
for dir in `find . -mindepth 1 -maxdepth 1 -type d -not -name archived -not -name '.*'` ; do
do_lint $dir
if [ $? -ne 0 ] ; then
EXIT_CODE=1
fi
done
exit $EXIT_CODE
else
do_lint $1
exit $?
fi