Compare commits
5 Commits
d9163bcff8
...
8f12b643b8
| Author | SHA1 | Date | |
|---|---|---|---|
| 8f12b643b8 | |||
| 3fea4a6c78 | |||
| b821339e69 | |||
| 6b856f9731 | |||
| e664352139 |
15
Dockerfile
15
Dockerfile
@ -17,20 +17,23 @@ RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
|
|||||||
RUN curl -L http://cs.sensiolabs.org/download/php-cs-fixer-v2.phar -o /usr/local/bin/php-cs-fixer && \
|
RUN curl -L http://cs.sensiolabs.org/download/php-cs-fixer-v2.phar -o /usr/local/bin/php-cs-fixer && \
|
||||||
chmod a+x /usr/local/bin/php-cs-fixer
|
chmod a+x /usr/local/bin/php-cs-fixer
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
# add csscomb and prettier
|
# add csscomb and prettier
|
||||||
RUN yarn add prettier csscomb --global && \
|
RUN yarn add prettier csscomb --global && \
|
||||||
ln -s /node_modules/.bin/prettier /usr/local/bin/prettier && \
|
ln -s /app/node_modules/.bin/prettier /usr/local/bin/prettier && \
|
||||||
ln -s /node_modules/.bin/csscomb /usr/local/bin/csscomb
|
ln -s /app/node_modules/.bin/csscomb /usr/local/bin/csscomb
|
||||||
|
|
||||||
COPY ["src/entry.sh", "/entry.sh"]
|
COPY ["src/entry.sh", "/app/entry.sh"]
|
||||||
|
|
||||||
COPY ["src/inc", "/inc"]
|
COPY ["src/inc", "/app/inc"]
|
||||||
|
|
||||||
WORKDIR /code
|
WORKDIR /code
|
||||||
|
|
||||||
CMD ["/entry.sh"]
|
|
||||||
|
|
||||||
ENTRYPOINT ["/entry.sh"]
|
CMD ["/app/entry.sh"]
|
||||||
|
ENTRYPOINT ["/app/entry.sh"]
|
||||||
|
|
||||||
|
|
||||||
ARG VERSION
|
ARG VERSION
|
||||||
ARG COMMIT_SHA
|
ARG COMMIT_SHA
|
||||||
|
|||||||
18
src/entry.sh
18
src/entry.sh
@ -46,6 +46,24 @@ main() {
|
|||||||
process
|
process
|
||||||
return $?
|
return $?
|
||||||
;;
|
;;
|
||||||
|
prettier)
|
||||||
|
__initVariables "$@"
|
||||||
|
source ${INCLUDES_PATH}/formatters/prettier.shinc
|
||||||
|
__prettier
|
||||||
|
return $?
|
||||||
|
;;
|
||||||
|
csscomb)
|
||||||
|
__initVariables "$@"
|
||||||
|
source ${INCLUDES_PATH}/formatters/csscomb.shinc
|
||||||
|
__csscomb
|
||||||
|
return $?
|
||||||
|
;;
|
||||||
|
php-cs-fixer)
|
||||||
|
__initVariables "$@"
|
||||||
|
source ${INCLUDES_PATH}/formatters/php-cs-fixer.shinc
|
||||||
|
__phpFixer
|
||||||
|
return $?
|
||||||
|
;;
|
||||||
help|--help|-h)
|
help|--help|-h)
|
||||||
usage
|
usage
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
14
src/inc/formatters/csscomb.shinc
Normal file
14
src/inc/formatters/csscomb.shinc
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
|
||||||
|
__csscomb() {
|
||||||
|
__msg "Csscomb:"
|
||||||
|
|
||||||
|
if [[ ${DRY_RUN} -eq 0 ]]; then
|
||||||
|
csscomb -v "${CSS_FILES[@]}"
|
||||||
|
else
|
||||||
|
csscomb --lint -v "${CSS_FILES[@]}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
return $?
|
||||||
|
}
|
||||||
58
src/inc/formatters/php-cs-fixer.shinc
Normal file
58
src/inc/formatters/php-cs-fixer.shinc
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
|
||||||
|
__phpFixer() {
|
||||||
|
local failed=0
|
||||||
|
|
||||||
|
__msg "PHP-cs-fixer"
|
||||||
|
|
||||||
|
# Cannot chain php files without specifying a config CS file :(
|
||||||
|
if [[ ${DRY_RUN} -eq 0 ]]; then
|
||||||
|
for file in "${PHP_FILES[@]}"; do
|
||||||
|
php-cs-fixer fix "${file}"
|
||||||
|
[[ $? -ne 0 ]] && failed=1
|
||||||
|
done
|
||||||
|
else
|
||||||
|
local needs_fixing=()
|
||||||
|
local invalid_syntax=()
|
||||||
|
|
||||||
|
for file in "${PHP_FILES[@]}"; do
|
||||||
|
php-cs-fixer fix --dry-run "${file}"
|
||||||
|
case $? in
|
||||||
|
0)
|
||||||
|
#all good
|
||||||
|
;;
|
||||||
|
4)
|
||||||
|
invalid_syntax+=("${file}")
|
||||||
|
;;
|
||||||
|
8)
|
||||||
|
needs_fixing+=("${file}")
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
__err "There was an error with php-cs-fixer configuration"
|
||||||
|
failed=1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ ${#needs_fixing[@]} -gt 0 ]]; then
|
||||||
|
failed=1
|
||||||
|
|
||||||
|
__err "Needs fixing:" 1
|
||||||
|
for file in "${needs_fixing[@]}"; do
|
||||||
|
__msg "${file}" 2
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ${#invalid_syntax[@]} -gt 0 ]]; then
|
||||||
|
failed=1
|
||||||
|
|
||||||
|
__err "Invalid syntax:" 1
|
||||||
|
for file in "${invalid_syntax[@]}"; do
|
||||||
|
__msg "${file}" 2
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
return ${failed}
|
||||||
|
}
|
||||||
15
src/inc/formatters/prettier.shinc
Normal file
15
src/inc/formatters/prettier.shinc
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
|
||||||
|
__prettier() {
|
||||||
|
__msg "Prettier:"
|
||||||
|
|
||||||
|
if [[ ${DRY_RUN} -eq 0 ]]; then
|
||||||
|
prettier --write "${JS_FILES[@]}"
|
||||||
|
else
|
||||||
|
__msg "Listing (: unprettiered :) files:" 1
|
||||||
|
prettier --list-different "${JS_FILES[@]}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
return $?
|
||||||
|
}
|
||||||
@ -1,54 +1,31 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
|
||||||
|
source ${INCLUDES_PATH}/formatters/prettier.shinc
|
||||||
__csscomb() {
|
source ${INCLUDES_PATH}/formatters/csscomb.shinc
|
||||||
if [[ ${DRY_RUN} -eq 0 ]]; then
|
source ${INCLUDES_PATH}/formatters/php-cs-fixer.shinc
|
||||||
csscomb "$@"
|
|
||||||
else
|
|
||||||
csscomb --lint "$@"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
__prettier() {
|
|
||||||
if [[ ${DRY_RUN} -eq 0 ]]; then
|
|
||||||
prettier --write "$@"
|
|
||||||
else
|
|
||||||
prettier --list-different "$@"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
__phpFixer() {
|
|
||||||
# Cannot chain php files without specifying a config CS file :(
|
|
||||||
if [[ ${DRY_RUN} -eq 0 ]]; then
|
|
||||||
for file in "${PHP_FILES[@]}"; do
|
|
||||||
php-cs-fixer fix "${file}"
|
|
||||||
done
|
|
||||||
else
|
|
||||||
for file in "${PHP_FILES[@]}"; do
|
|
||||||
php-cs-fixer fix --dry-run "${file}"
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
process() {
|
process() {
|
||||||
|
local failed=0
|
||||||
|
|
||||||
# Run css comb
|
# Run css comb
|
||||||
if [[ ${#CSS_FILES[@]} -ne 0 ]]; then
|
if [[ ${#CSS_FILES[@]} -ne 0 ]]; then
|
||||||
__csscomb "${CSS_FILES[@]}"
|
__csscomb
|
||||||
|
[[ $? -ne 0 ]] && failed=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Run JS prettier
|
# Run JS prettier
|
||||||
if [[ ${#JS_FILES[@]} -ne 0 ]]; then
|
if [[ ${#JS_FILES[@]} -ne 0 ]]; then
|
||||||
__prettier --write "${JS_FILES[@]}"
|
__prettier
|
||||||
|
[[ $? -ne 0 ]] && failed=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Run PHP cs fixer
|
# Run PHP cs fixer
|
||||||
if [[ ${#PHP_FILES[@]} -ne 0 ]]; then
|
if [[ ${#PHP_FILES[@]} -ne 0 ]]; then
|
||||||
__phpFixer ${PHP_FILES[@]}
|
__phpFixer
|
||||||
|
[[ $? -ne 0 ]] && failed=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
return ${failed}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,25 +25,25 @@ __initVariables() {
|
|||||||
__path_exists "${1}"
|
__path_exists "${1}"
|
||||||
if [[ $? -ne 0 ]]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
__err "Specified path does not exist: ${1}"
|
__err "Specified path does not exist: ${1}"
|
||||||
continue
|
else
|
||||||
|
CSS_FILES+=("${1}")
|
||||||
fi
|
fi
|
||||||
CSS_FILES+=(${1})
|
|
||||||
;;
|
;;
|
||||||
*.js|*.jsx)
|
*.js|*.jsx)
|
||||||
__path_exists "${1}"
|
__path_exists "${1}"
|
||||||
if [[ $? -ne 0 ]]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
__err "Specified path does not exist: ${1}"
|
__err "Specified path does not exist: ${1}"
|
||||||
continue
|
else
|
||||||
|
JS_FILES+=("${1}")
|
||||||
fi
|
fi
|
||||||
JS_FILES+=(${1})
|
|
||||||
;;
|
;;
|
||||||
*.php|*.phtml)
|
*.php|*.phtml)
|
||||||
__path_exists "${1}"
|
__path_exists "${1}"
|
||||||
if [[ $? -ne 0 ]]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
__err "Specified path does not exist: ${1}"
|
__err "Specified path does not exist: ${1}"
|
||||||
continue
|
else
|
||||||
|
PHP_FILES+=("${1}")
|
||||||
fi
|
fi
|
||||||
PHP_FILES+=(${1})
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
shift 1
|
shift 1
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user