Skip to content

Commit f7ab698

Browse files
AlexeiBerezaAlexei Berezhetskii
andauthored
#104352 add date, range and input filters (#1)
* #104352 add date, range and input filters * #104352 improvements and renaming * #104352 remove package json and lock files --------- Co-authored-by: Alexei Berezhetskii <berezhetskii@greensight.ru>
1 parent 287528f commit f7ab698

Some content is hidden

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

58 files changed

+11349
-1
lines changed

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_size = 4
6+
indent_style = space
7+
end_of_line = lf
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[*.{yml,yaml}]
15+
indent_size = 2
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
ESC_SEQ="\x1b["
4+
COL_RESET=$ESC_SEQ"39;49;00m"
5+
COL_RED=$ESC_SEQ"0;31m"
6+
COL_GREEN=$ESC_SEQ"0;32m"
7+
COL_YELLOW=$ESC_SEQ"0;33m"
8+
9+
changed_files="$(git diff-tree -r --name-only --no-commit-id HEAD@{1} HEAD)"
10+
11+
check_run() {
12+
echo "$changed_files" | grep --quiet "$1" && echo " * changes detected in $1" && echo " * running $2" && eval "$2"
13+
}
14+
15+
check_run composer.lock "composer install"
16+
check_run package-lock.json "npm install"
17+
exit 0
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
ESC_SEQ="\x1b["
4+
COL_RESET=$ESC_SEQ"39;49;00m"
5+
COL_RED=$ESC_SEQ"0;31m"
6+
COL_GREEN=$ESC_SEQ"0;32m"
7+
COL_YELLOW=$ESC_SEQ"0;33m"
8+
9+
changed_files="$(git diff-tree -r --name-only --no-commit-id HEAD@{1} HEAD)"
10+
11+
check_run() {
12+
echo "$changed_files" | grep --quiet "$1" && echo " * changes detected in $1" && echo " * running $2" && eval "$2"
13+
}
14+
15+
check_run composer.lock "composer install"
16+
check_run package-lock.json "npm install"
17+
exit 0

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

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
3+
ROOT_DIR="$(pwd)/"
4+
LIST=$(git diff-index --cached --name-only --diff-filter=ACMR HEAD)
5+
ERRORS_BUFFER=""
6+
ESC_SEQ="\x1b["
7+
COL_RESET=$ESC_SEQ"39;49;00m"
8+
COL_RED=$ESC_SEQ"0;31m"
9+
COL_GREEN=$ESC_SEQ"0;32m"
10+
COL_YELLOW=$ESC_SEQ"0;33m"
11+
COL_BLUE=$ESC_SEQ"0;34m"
12+
COL_MAGENTA=$ESC_SEQ"0;35m"
13+
COL_CYAN=$ESC_SEQ"0;36m"
14+
15+
echo
16+
printf "$COL_YELLOW%s$COL_RESET\n" "Running pre-commit hook: \"php-linter\""
17+
18+
for file in $LIST
19+
do
20+
EXTENSION=$(echo "$file" | grep -E ".php$|.module$|.inc$|.install$")
21+
if [ "$EXTENSION" != "" ]; then
22+
ERRORS=$(php -l $ROOT_DIR$file 2>&1 | grep "Parse error")
23+
if [ "$ERRORS" != "" ]; then
24+
if [ "$ERRORS_BUFFER" != "" ]; then
25+
ERRORS_BUFFER="$ERRORS_BUFFER\n$ERRORS"
26+
else
27+
ERRORS_BUFFER="$ERRORS"
28+
fi
29+
echo "Syntax errors found in file: $file "
30+
fi
31+
fi
32+
done
33+
if [ "$ERRORS_BUFFER" != "" ]; then
34+
echo
35+
echo "These errors were found in try-to-commit files: "
36+
echo -e $ERRORS_BUFFER
37+
echo
38+
printf "$COL_RED%s$COL_RESET\r\n\r\n" "Can't commit, fix errors first."
39+
exit 1
40+
else
41+
echo "Okay"
42+
exit 0
43+
fi
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/bash
2+
3+
EXECUTABLE_NAME=php-cs-fixer
4+
EXECUTABLE_COMMAND=fix
5+
CONFIG_FILE=.php-cs-fixer.php
6+
CONFIG_FILE_PARAMETER='--config'
7+
ROOT=`pwd`
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-cs-fixer\""
19+
20+
# possible locations
21+
locations=(
22+
$ROOT/bin/$EXECUTABLE_NAME
23+
$ROOT/vendor/bin/$EXECUTABLE_NAME
24+
)
25+
26+
for location in ${locations[*]}
27+
do
28+
if [[ -x $location ]]; then
29+
EXECUTABLE=$location
30+
break
31+
fi
32+
done
33+
34+
if [[ ! -x $EXECUTABLE ]]; then
35+
echo "executable $EXECUTABLE_NAME not found, exiting..."
36+
echo "if you're sure this is incorrect, make sure they're executable (chmod +x)"
37+
exit
38+
fi
39+
40+
echo "using \"$EXECUTABLE_NAME\" located at $EXECUTABLE"
41+
$EXECUTABLE --version
42+
43+
if [[ -f $ROOT/$CONFIG_FILE ]]; then
44+
CONFIG=$ROOT/$CONFIG_FILE
45+
echo "config file located at $CONFIG loaded"
46+
fi
47+
48+
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'`
49+
if [ -z "$FILES" ]; then
50+
echo "No php files found to fix."
51+
else
52+
echo "Fixing files ${FILES} in project";
53+
if [[ -f $CONFIG ]]; then
54+
$EXECUTABLE $EXECUTABLE_COMMAND $CONFIG_FILE_PARAMETER=$CONFIG ${FILES};
55+
else
56+
$EXECUTABLE $EXECUTABLE_COMMAND ${FILES};
57+
fi
58+
git add ${FILES}
59+
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
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: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
ESC_SEQ="\x1b["
4+
COL_RESET=$ESC_SEQ"39;49;00m"
5+
COL_RED=$ESC_SEQ"0;31m"
6+
COL_GREEN=$ESC_SEQ"0;32m"
7+
COL_YELLOW=$ESC_SEQ"0;33m"
8+
9+
echo
10+
printf "$COL_YELLOW%s$COL_RESET\n" "Running pre-push hook: \"var-dump-checker\""
11+
12+
./vendor/bin/var-dump-check --laravel --exclude bootstrap --exclude node_modules --exclude vendor .
13+
14+
# If the grep command has no hits - echo a warning and exit with non-zero status.
15+
if [ $? == 1 ]; then
16+
printf "$COL_RED%s$COL_RESET\r\n\r\n" "Some var_dump usage found. Please fix your code"
17+
exit 1
18+
fi
19+
20+
echo "Okay"
21+
exit 0

.gitattributes

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Path-based git attributes
2+
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html
3+
4+
# Ignore all test and documentation with "export-ignore".
5+
/.github export-ignore
6+
/.gitattributes export-ignore
7+
/.gitignore export-ignore
8+
/phpunit.xml.dist export-ignore
9+
/art export-ignore
10+
/docs export-ignore
11+
/tests export-ignore
12+
/.editorconfig export-ignore
13+
/.php_cs.dist.php export-ignore
14+
/psalm.xml export-ignore
15+
/psalm.xml.dist export-ignore
16+
/testbench.yaml export-ignore
17+
/UPGRADING.md export-ignore
18+
/phpstan.neon.dist export-ignore
19+
/phpstan-baseline.neon export-ignore

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.idea
2+
build
3+
coverage
4+
docs
5+
phpstan.neon
6+
testbench.yaml
7+
vendor
8+
node_modules
9+
10+
*.cache
11+
phpunit.xml
12+
.huskyrc

.php-cs-fixer.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
$finder = Symfony\Component\Finder\Finder::create()
4+
->in([
5+
__DIR__ . '/src',
6+
__DIR__ . '/tests',
7+
])
8+
->name('*.php')
9+
->notName('*.blade.php')
10+
->ignoreDotFiles(true)
11+
->ignoreVCS(true);
12+
13+
return (new PhpCsFixer\Config())
14+
->setRules([
15+
'@PSR2' => true,
16+
'@PSR12' => true,
17+
'array_syntax' => ['syntax' => 'short'],
18+
'ordered_imports' => ['sort_algorithm' => 'alpha'],
19+
'no_unused_imports' => true,
20+
'trailing_comma_in_multiline' => true,
21+
'phpdoc_scalar' => true,
22+
'unary_operator_spaces' => true,
23+
'blank_line_before_statement' => [
24+
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'],
25+
],
26+
'phpdoc_single_line_var_spacing' => true,
27+
'phpdoc_var_without_name' => true,
28+
'class_attributes_separation' => [
29+
'elements' => [
30+
'method' => 'one',
31+
],
32+
],
33+
'method_argument_space' => [
34+
'on_multiline' => 'ensure_fully_multiline',
35+
'keep_multiple_spaces_after_comma' => true,
36+
],
37+
'single_trait_insert_per_statement' => true,
38+
'no_whitespace_in_blank_line' => true,
39+
'method_chaining_indentation' => true,
40+
41+
])
42+
->setFinder($finder);

0 commit comments

Comments
 (0)