Skip to content

Commit 39f2685

Browse files
authored
Merge pull request #1 from greensight/dev
Search and aggregation queries.
2 parents d1dff88 + 8717282 commit 39f2685

File tree

83 files changed

+13636
-1
lines changed

Some content is hidden

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

83 files changed

+13636
-1
lines changed
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
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

.github/CONTRIBUTING.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Contributing
2+
3+
Contributions are **welcome** and will be fully **credited**.
4+
5+
Please read and understand the contribution guide before creating an issue or pull request.
6+
7+
## Etiquette
8+
9+
This project is open source, and as such, the maintainers give their free time to build and maintain the source code
10+
held within. They make the code freely available in the hope that it will be of use to other developers. It would be
11+
extremely unfair for them to suffer abuse or anger for their hard work.
12+
13+
Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the
14+
world that developers are civilized and selfless people.
15+
16+
It's the duty of the maintainer to ensure that all submissions to the project are of sufficient
17+
quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used.
18+
19+
## Viability
20+
21+
When requesting or submitting new features, first consider whether it might be useful to others. Open
22+
source projects are used by many developers, who may have entirely different needs to your own. Think about
23+
whether or not your feature is likely to be used by other users of the project.
24+
25+
## Procedure
26+
27+
Before filing an issue:
28+
29+
- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident.
30+
- Check to make sure your feature suggestion isn't already present within the project.
31+
- Check the pull requests tab to ensure that the bug doesn't have a fix in progress.
32+
- Check the pull requests tab to ensure that the feature isn't already in progress.
33+
34+
Before submitting a pull request:
35+
36+
- Check the codebase to ensure that your feature doesn't already exist.
37+
- Check the pull requests to ensure that another person hasn't already submitted the feature or fix.
38+
39+
## Requirements
40+
41+
If the project maintainer has any additional requirements, you will find them listed here.
42+
43+
- **Add tests!** - Your patch won't be accepted if it doesn't have tests.
44+
45+
- **Use hooks!** - You can make use of .git hooks if you install them using `npm i`
46+
47+
- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.
48+
49+
- **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option.
50+
51+
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
52+
53+
- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting.
54+
55+
**Happy coding**!

.github/SECURITY.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Security Policy
2+
3+
If you discover any security related issues, please email mail@greensight.ru instead of using the issue tracker.

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.idea
2+
/vendor
3+
/node_modules
4+
/build
5+
6+
*.cache
7+
phpunit.xml
8+
.huskyrc

.huskyrc.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"hooks": {
3+
"post-checkout": ".git_hooks/post-checkout/install-dependecies.sh",
4+
"post-merge": ".git_hooks/post-merge/install-dependecies.sh",
5+
"pre-commit": ".git_hooks/pre-commit/lint-php.sh && .git_hooks/pre-commit/php-cs-fixer.sh",
6+
"pre-push": ".git_hooks/pre-push/composer-validate.sh && .git_hooks/pre-push/var-dump-checker.sh && composer test"
7+
}
8+
}

0 commit comments

Comments
 (0)