diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..62276b0 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,20 @@ +# Configuration for known file extensions +[*.{css,js,json,less,md,py,rst,sass,scss,xml,yaml,yml}] +charset = utf-8 +end_of_line = lf +indent_size = 4 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true + +[.eslintrc,*.{json,yml,yaml,rst,md}] +indent_size = 2 + +# Do not configure editor for libs and autogenerated content +[*/static/{lib,src/lib}/**,*/static/description/index.html,*/readme/../README.rst] +charset = unset +end_of_line = unset +indent_size = unset +indent_style = unset +insert_final_newline = false +trim_trailing_whitespace = false diff --git a/script/code_generator/install_and_test_code_generator.sh b/script/code_generator/install_and_test_code_generator.sh index b43919b..57267d8 100755 --- a/script/code_generator/install_and_test_code_generator.sh +++ b/script/code_generator/install_and_test_code_generator.sh @@ -49,7 +49,17 @@ cd "$3" || exit 1 git checkout -- "*.po*" cd - || exit 1 -./script/maintenance/black.sh "$3" +#./script/maintenance/format.sh "$3" +# Itéré pour chaque module et formater +IFS=',' +# Diviser la chaîne en un tableau +read -ra elements <<<"$4" +# Itérer sur les éléments +for element in "${elements[@]}"; do + echo "Format ${3}/${element}" + ./script/maintenance/format.sh "${3}/${element}" +done + echo "TEST ${2}" ./script/code_generator/check_git_change_code_generator.sh "$3" retVal=$? diff --git a/script/code_generator/search_class_model.py b/script/code_generator/search_class_model.py index 266bf28..795046a 100755 --- a/script/code_generator/search_class_model.py +++ b/script/code_generator/search_class_model.py @@ -212,8 +212,8 @@ def main(): with open(hooks_file_path, "w") as source: source.write(new_file_content) - # Call black - os.system(f"./script/maintenance/black.sh {hooks_file_path}") + # Call format all file + os.system(f"./script/maintenance/format.sh {hooks_file_path}") return 0 diff --git a/script/maintenance/black.sh b/script/maintenance/black.sh index 2bc6f89..630f61a 100755 --- a/script/maintenance/black.sh +++ b/script/maintenance/black.sh @@ -2,7 +2,7 @@ # This will format all python file # argument 1: directory or file to format source ./.venv/bin/activate -black -l 79 --preview -t py37 $@ +black -l 79 --preview -t py37 "$@" retVal=$? if [[ $retVal -ne 0 ]]; then echo "Error black format" diff --git a/script/maintenance/format.sh b/script/maintenance/format.sh new file mode 100755 index 0000000..7b2bf7e --- /dev/null +++ b/script/maintenance/format.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +cmd1="./script/maintenance/format_python.sh \"$*\"" +cmd2="find \"$*\" -type f -not -path \"*/not_supported_files/*\" -name '*.xml' -print0 | parallel -0 ./script/maintenance/prettier_xml.sh {}" +cmd3="find \"$*\" -type f -not -path \"*/not_supported_files/*\" -name '*.js' -print0 | parallel -0 ./script/maintenance/prettier.sh {}" +cmd4="find \"$*\" -type f -not -path \"*/not_supported_files/*\" -name '*.css' -print0 | parallel -0 ./script/maintenance/prettier.sh {}" +cmd5="find \"$*\" -type f -not -path \"*/not_supported_files/*\" -name '*.scss' -print0 | parallel -0 ./script/maintenance/prettier.sh {}" +cmd6="find \"$*\" -type f -not -path \"*/not_supported_files/*\" -name '*.html' -print0 | parallel -0 ./script/maintenance/prettier.sh {}" +parallel ::: "$cmd1" "$cmd2" "$cmd3" "$cmd4" "$cmd5" "$cmd6" diff --git a/script/maintenance/format_python.sh b/script/maintenance/format_python.sh index 75a67f1..f17ec1e 100755 --- a/script/maintenance/format_python.sh +++ b/script/maintenance/format_python.sh @@ -1,3 +1,5 @@ #!/usr/bin/env bash -.venv/bin/isort --profile black -l 79 "$@" +source ./.venv/bin/activate +isort --profile black -l 79 "$@" +#./.venv/bin/isort --profile black -l 79 "$@" ./script/maintenance/black.sh "$@"