Skip to content

Commit 27027c0

Browse files
committed
ENSITECH-74
1 parent 83beb78 commit 27027c0

File tree

375 files changed

+972
-167303
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

375 files changed

+972
-167303
lines changed

.eslintrc.js

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
# - 'composer update' if changed composer.json
4+
5+
ESC_SEQ="\x1b["
6+
COL_RESET=$ESC_SEQ"39;49;00m"
7+
COL_RED=$ESC_SEQ"0;31m"
8+
COL_GREEN=$ESC_SEQ"0;32m"
9+
COL_YELLOW=$ESC_SEQ"0;33m"
10+
11+
changed_files="$(git diff-tree -r --name-only --no-commit-id HEAD@{1} HEAD)"
12+
13+
check_run() {
14+
echo "$changed_files" | grep -q "$1" && echo " * changes detected in $1" && echo " * running $2" && eval "$2"
15+
}
16+
17+
check_run composer.json "composer update"
18+
exit 0
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
# - 'composer update' if changed composer.json
4+
5+
ESC_SEQ="\x1b["
6+
COL_RESET=$ESC_SEQ"39;49;00m"
7+
COL_RED=$ESC_SEQ"0;31m"
8+
COL_GREEN=$ESC_SEQ"0;32m"
9+
COL_YELLOW=$ESC_SEQ"0;33m"
10+
11+
changed_files="$(git diff-tree -r --name-only --no-commit-id HEAD@{1} HEAD)"
12+
13+
check_run() {
14+
echo "$changed_files" | grep -q "$1" && echo " * changes detected in $1" && echo " * running $2" && eval "$2"
15+
}
16+
17+
check_run composer.json "composer update"
18+
exit 0

.git_hooks/pre-commit/01-lint-php.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/bash
2+
3+
# Lint all added php-files via 'php -l'
4+
5+
ROOT_DIR="$(pwd)/"
6+
LIST=$(git diff-index --cached --name-only --diff-filter=ACMR HEAD)
7+
ERRORS_BUFFER=""
8+
ESC_SEQ="\x1b["
9+
COL_RESET=$ESC_SEQ"39;49;00m"
10+
COL_RED=$ESC_SEQ"0;31m"
11+
COL_GREEN=$ESC_SEQ"0;32m"
12+
COL_YELLOW=$ESC_SEQ"0;33m"
13+
COL_BLUE=$ESC_SEQ"0;34m"
14+
COL_MAGENTA=$ESC_SEQ"0;35m"
15+
COL_CYAN=$ESC_SEQ"0;36m"
16+
17+
echo
18+
printf "$COL_YELLOW%s$COL_RESET\n" "Running pre-commit hook: \"php-linter\""
19+
20+
for file in $LIST
21+
do
22+
EXTENSION=$(echo "$file" | grep -E ".php$|.module$|.inc$|.install$")
23+
if [ "$EXTENSION" != "" ]; then
24+
ERRORS=$(php -l $ROOT_DIR$file 2>&1 | grep "Parse error")
25+
if [ "$ERRORS" != "" ]; then
26+
if [ "$ERRORS_BUFFER" != "" ]; then
27+
ERRORS_BUFFER="$ERRORS_BUFFER\n$ERRORS"
28+
else
29+
ERRORS_BUFFER="$ERRORS"
30+
fi
31+
echo "Syntax errors found in file: $file "
32+
fi
33+
fi
34+
done
35+
if [ "$ERRORS_BUFFER" != "" ]; then
36+
echo
37+
echo "These errors were found in try-to-commit files: "
38+
echo -e $ERRORS_BUFFER
39+
echo
40+
printf "$COL_RED%s$COL_RESET\r\n\r\n" "Can't commit, fix errors first."
41+
exit 1
42+
else
43+
echo "Okay"
44+
exit 0
45+
fi
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/bin/bash
2+
3+
# Check code style via '.php-cs-fixer.php'
4+
5+
EXECUTABLE_NAME=php-cs-fixer
6+
EXECUTABLE_COMMAND=fix
7+
CONFIG_FILE=.php-cs-fixer.php
8+
CONFIG_FILE_PARAMETER='--config'
9+
ROOT=`pwd`
10+
ESC_SEQ="\x1b["
11+
COL_RESET=$ESC_SEQ"39;49;00m"
12+
COL_RED=$ESC_SEQ"0;31m"
13+
COL_GREEN=$ESC_SEQ"0;32m"
14+
COL_YELLOW=$ESC_SEQ"0;33m"
15+
COL_BLUE=$ESC_SEQ"0;34m"
16+
COL_MAGENTA=$ESC_SEQ"0;35m"
17+
COL_CYAN=$ESC_SEQ"0;36m"
18+
19+
echo ""
20+
printf "$COL_YELLOW%s$COL_RESET\n" "Running pre-commit hook: \"php-cs-fixer\""
21+
22+
# possible locations
23+
locations=(
24+
$ROOT/bin/$EXECUTABLE_NAME
25+
$ROOT/vendor/bin/$EXECUTABLE_NAME
26+
)
27+
28+
for location in ${locations[*]}
29+
do
30+
if [[ -x $location ]]; then
31+
EXECUTABLE=$location
32+
break
33+
fi
34+
done
35+
36+
if [[ ! -x $EXECUTABLE ]]; then
37+
echo "executable $EXECUTABLE_NAME not found, exiting..."
38+
echo "if you're sure this is incorrect, make sure they're executable (chmod +x)"
39+
exit
40+
fi
41+
42+
echo "using \"$EXECUTABLE_NAME\" located at $EXECUTABLE"
43+
$EXECUTABLE --version
44+
45+
if [[ -f $ROOT/$CONFIG_FILE ]]; then
46+
CONFIG=$ROOT/$CONFIG_FILE
47+
echo "config file located at $CONFIG loaded"
48+
fi
49+
50+
FILES=`git status --porcelain | grep -e '^[AM]\(.*\).php$' | cut -c 3- | sed -e "s/_ide_helper.php$//" | sed -e "s/_ide_helper_models.php$//" | sed -e "s/.phpstorm.meta.php$//" | tr '\n' ' ' | sed 's/ *$//g'`
51+
if [ -z "$FILES" ]; then
52+
echo "No php files found to fix."
53+
else
54+
echo "Fixing files ${FILES} in project";
55+
if [[ -f $CONFIG ]]; then
56+
$EXECUTABLE $EXECUTABLE_COMMAND $CONFIG_FILE_PARAMETER=$CONFIG ${FILES};
57+
else
58+
$EXECUTABLE $EXECUTABLE_COMMAND ${FILES};
59+
fi
60+
git add ${FILES}
61+
fi
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
# Validate composer.json before commit
4+
5+
ESC_SEQ="\x1b["
6+
COL_RESET=$ESC_SEQ"39;49;00m"
7+
COL_RED=$ESC_SEQ"0;31m"
8+
COL_GREEN=$ESC_SEQ"0;32m"
9+
COL_YELLOW=$ESC_SEQ"0;33m"
10+
11+
echo
12+
printf "$COL_YELLOW%s$COL_RESET\n" "Running pre-push hook: \"composer-validate\""
13+
14+
VALID=$(composer validate --strict --no-check-publish --no-check-all | grep "is valid")
15+
16+
if [ "$VALID" != "" ]; then
17+
echo "Okay"
18+
exit 0
19+
else
20+
printf "$COL_RED%s$COL_RESET\r\n" "Composer validate check failed."
21+
exit 1
22+
fi

.git_hooks/pre-push/02-phpstan.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
# Run composer phpstan
4+
5+
ESC_SEQ="\x1b["
6+
COL_RESET=$ESC_SEQ"39;49;00m"
7+
COL_RED=$ESC_SEQ"0;31m"
8+
COL_GREEN=$ESC_SEQ"0;32m"
9+
COL_YELLOW=$ESC_SEQ"0;33m"
10+
11+
echo
12+
printf "$COL_YELLOW%s$COL_RESET\n" "Running pre-push hook: \"phpstan\""
13+
14+
if composer phpstan; then
15+
echo "Okay"
16+
exit 0
17+
else
18+
printf "$COL_RED%s$COL_RESET\r\n" "phpstan analysis failed."
19+
exit 1
20+
fi

.git_hooks/pre-push/03-test-code.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
# Run composer test
4+
5+
ESC_SEQ="\x1b["
6+
COL_RESET=$ESC_SEQ"39;49;00m"
7+
COL_RED=$ESC_SEQ"0;31m"
8+
COL_GREEN=$ESC_SEQ"0;32m"
9+
COL_YELLOW=$ESC_SEQ"0;33m"
10+
11+
echo
12+
printf "$COL_YELLOW%s$COL_RESET\n" "Running pre-push hook: \"test-code\""
13+
14+
if composer test; then
15+
echo "Okay"
16+
exit 0
17+
else
18+
printf "$COL_RED%s$COL_RESET\r\n" "Tests failed."
19+
exit 1
20+
fi
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
# Validate composer.json before commit
4+
5+
ESC_SEQ="\x1b["
6+
COL_RESET=$ESC_SEQ"39;49;00m"
7+
COL_RED=$ESC_SEQ"0;31m"
8+
COL_GREEN=$ESC_SEQ"0;32m"
9+
COL_YELLOW=$ESC_SEQ"0;33m"
10+
11+
echo
12+
printf "$COL_YELLOW%s$COL_RESET\n" "Running pre-push hook: \"composer-validate\""
13+
14+
VALID=$(composer validate --strict --no-check-publish --no-check-all | grep "is valid")
15+
16+
if [ "$VALID" != "" ]; then
17+
echo "Okay"
18+
exit 0
19+
else
20+
printf "$COL_RED%s$COL_RESET\r\n" "Composer validate check failed."
21+
exit 1
22+
fi
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
# - 'composer update' if changed composer.json
4+
5+
ESC_SEQ="\x1b["
6+
COL_RESET=$ESC_SEQ"39;49;00m"
7+
COL_RED=$ESC_SEQ"0;31m"
8+
COL_GREEN=$ESC_SEQ"0;32m"
9+
COL_YELLOW=$ESC_SEQ"0;33m"
10+
11+
changed_files="$(git diff-tree -r --name-only --no-commit-id HEAD@{1} HEAD)"
12+
13+
check_run() {
14+
echo "$changed_files" | grep -q "$1" && echo " * changes detected in $1" && echo " * running $2" && eval "$2"
15+
}
16+
17+
check_run composer.json "composer update"
18+
exit 0

0 commit comments

Comments
 (0)