-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·110 lines (97 loc) · 3.21 KB
/
install.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
#/bin/bash
function main() {
# Check for git
which git >> /dev/null
if [[ $? != 0 ]]; then
echo "Sorry, you need git for this.";
exit 1;
fi
# Check for composer
which composer >> /dev/null
if [[ $? != 0 ]]; then
echo "Sorry, you need composer for this.";
exit 1;
fi
which phpcs >> /dev/null
if [[ $? != 0 ]]; then
echo "You need phpcs! let me grab it for you."
composer global require squizlabs/php_codesniffer
fi
original_dir=$PWD
phpcs_path=$(which phpcs)
try_install
}
function try_install() {
echo "phpcs found in $phpcs_path";
read -p "Would you like to install to this directory? " -n 1 -r
if [[ "$REPLY" =~ ^[Yy]$ ]]; then
install_func
else
echo "\nAborting!"
fi
}
function install_func() {
echo "\n\n------------ Installing ------------\n";
install_dir="$(dirname $phpcs_path)"
echo "Changing directory to $install_dir"
cd $install_dir
echo "Getting real phpcs install path"
real_install="$(dirname $(readlink phpcs))"
echo "Changing directory to $real_install"
cd $real_install
echo "Going up a directory"
cd "../"
echo "Changing directory to src/Standards"
cd "src/Standards"
local standards="$(ls -1)"
# Slevomat
if [[ $standards = *"SlevomatCodingStandard"* ]]; then
echo "SlevomatCodingStandard: \033[32mCheck\033[0m"
else
echo "SlevomatCodingStandard: \033[31mMissing\033[0m"
git clone git@github.com:slevomat/coding-standard.git
mv coding-standard/SlevomatCodingStandard SlevomatCodingStandard
rm -rf coding-standard
echo "Copied SlevomatCodingStandard from repo."
fi
echo "Installing Slevomat Dependencies..."
composer global require phpstan/phpdoc-parser
# Hostnet
if [[ $standards = *"Hostnet"* ]]; then
echo "Hostnet: \033[32mCheck\033[0m"
else
echo "Hostnet: \033[31mMissing\033[0m"
git clone git@github.com:hostnet/phpcs-tool.git
mv phpcs-tool/src/Hostnet Hostnet
rm -rf phpcs-tool
echo "Copied Hostnet from repo."
fi
# VariableAnalysis
if [[ $standards = *"VariableAnalysis"* ]]; then
echo "VariableAnalysis: \033[32mCheck\033[0m"
else
echo "VariableAnalysis: \033[31mMissing\033[0m"
git clone git@github.com:sirbrillig/phpcs-variable-analysis.git
mv phpcs-variable-analysis/VariableAnalysis VariableAnalysis
rm -rf phpcs-variable-analysis
echo "Copied VariableAnalysis from repo."
fi
# XpBar
if [[ $standards = *"XpBar"* ]]; then
echo "XpBar: \033[32mCheck\033[0m"
else
echo "XpBar: \033[31mMissing\033[0m"
cp -rf $original_dir/XpBar XpBar
echo "Copied XpBar from repo."
fi
# Set Standard
phpcs --config-set default_standard XpBar
echo "\033[32m
mmmm m m mmm mmm mmmmmm mmmm mmmm
#\" \" # # m\" \" m\" \" # #\" \" #\" \"
\"#mmm # # # # #mmmmm \"#mmm \"#mmm
\"# # # # # # \"# \"#
\"mmm#\" \"mmmm\" \"mmm\" \"mmm\" #mmmmm \"mmm#\" \"mmm#\"
\033[0m"
}
main