-
Notifications
You must be signed in to change notification settings - Fork 57
/
suggested-tools.sh
executable file
·66 lines (57 loc) · 1.51 KB
/
suggested-tools.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
#!/bin/bash
# PHP_VERSION=number bin/suggested-tools.sh <install|remove> <composer_require_modes>
#
# Help:
# $ bin/suggested-tools.sh
# $ bin/suggested-tools.sh install
# $ bin/suggested-tools.sh install --update-no-dev
# $ bin/suggested-tools.sh remove
#
# Usage for PHP5:
# $ PHP_VERSION="5" bin/suggested-tools.sh
COMMAND="$0"
SELECTED_MODE="$1"
COMPOSER_REQUIRE_MODES="$2"
PHP_VERSION=${PHP_VERSION:-"7"}
run () {
TOOLS=$(get_tools)
if [ -z "$SELECTED_MODE" ]; then
show_help "install"
show_help "remove"
echo "Available tools: $TOOLS"
exit 1
fi
show_help $SELECTED_MODE
if [[ $SELECTED_MODE = "install" ]]; then
install "$TOOLS"
else
remove "$TOOLS"
fi
}
show_help() {
MODE=$1
echo "$ PHP_VERSION=$PHP_VERSION $COMMAND $MODE $COMPOSER_REQUIRE_MODES"
echo
}
get_tools () {
TOOLS="php-parallel-lint/php-parallel-lint php-parallel-lint/php-console-highlighter friendsofphp/php-cs-fixer"
if [[ ${PHP_VERSION:0:1} != "5" ]]; then
TOOLS="${TOOLS} vimeo/psalm phpstan/phpstan nette/neon qossmic/deptrac-shim enlightn/security-checker"
fi
echo $TOOLS
}
install () {
TOOLS=$1
echo "> Installing suggested tools"
echo "$ composer require $TOOLS $COMPOSER_REQUIRE_MODES"
echo
composer require $TOOLS $COMPOSER_REQUIRE_MODES
}
remove () {
TOOLS=${1/:>=2/""}
echo "> Removing suggested tools"
echo "$ composer require $TOOLS $COMPOSER_REQUIRE_MODES"
echo
composer remove $TOOLS
}
run