1declare version
2declare composerStrictValidation
3declare composerGlobal
4
5setComposerRootVersion() {
6 set +e # Disable exit on error
7
8 if [[ -v version ]]; then
9 echo -e "\e[32mSetting COMPOSER_ROOT_VERSION to $version\e[0m"
10 export COMPOSER_ROOT_VERSION=$version
11 fi
12
13 set -e
14}
15
16setComposerEnvVariables() {
17 echo -e "\e[32mSetting some required environment variables for Composer...\e[0m"
18 export COMPOSER_MIRROR_PATH_REPOS=1
19 export COMPOSER_CACHE_DIR=/dev/null
20 export COMPOSER_HTACCESS_PROTECT=0
21}
22
23checkComposerValidate() {
24 setComposerRootVersion
25
26 if [ "1" == "${composerGlobal-}" ]; then
27 global="global";
28 else
29 global="";
30 fi
31
32 command="composer ${global} validate --strict --quiet --no-interaction --no-check-all --no-check-lock"
33 if ! $command; then
34 if [ "1" == "${composerStrictValidation-}" ]; then
35 echo
36 echo -e "\e[31mERROR: composer files validation failed\e[0m"
37 echo
38 echo -e '\e[31mThe validation of the composer.json failed.\e[0m'
39 echo -e '\e[31mMake sure that the file composer.json is valid.\e[0m'
40 echo
41 echo -e '\e[31mTo address the issue efficiently, follow one of these steps:\e[0m'
42 echo -e '\e[31m 1. File an issue in the project'\''s issue tracker with detailed information, and apply any available remote patches as a temporary solution '\('with fetchpatch'\)'.\e[0m'
43 echo -e '\e[31m 2. If an immediate fix is needed or if reporting upstream isn'\''t suitable, develop a temporary local patch.\e[0m'
44 echo
45 exit 1
46 else
47 echo
48 echo -e "\e[33mWARNING: composer files validation failed\e[0m"
49 echo
50 echo -e '\e[33mThe validation of the composer.json failed.\e[0m'
51 echo -e '\e[33mMake sure that the file composer.json is valid.\e[0m'
52 echo
53 echo -e '\e[33mTo address the issue efficiently, follow one of these steps:\e[0m'
54 echo -e '\e[33m 1. File an issue in the project'\''s issue tracker with detailed information, and apply any available remote patches as a temporary solution with '\('with fetchpatch'\)'.\e[0m'
55 echo -e '\e[33m 2. If an immediate fix is needed or if reporting upstream isn'\''t suitable, develop a temporary local patch.\e[0m'
56 echo
57 echo -e '\e[33mThis check is not blocking, but it is recommended to fix the issue.\e[0m'
58 echo
59 fi
60 fi
61
62 command="composer ${global} validate --strict --no-ansi --no-interaction --quiet --no-check-all --check-lock"
63 if ! $command; then
64 if [ "1" == "${composerStrictValidation-}" ]; then
65 echo
66 echo -e "\e[31mERROR: composer files validation failed\e[0m"
67 echo
68 echo -e '\e[31mThe validation of the composer.json and composer.lock failed.\e[0m'
69 echo -e '\e[31mMake sure that the file composer.lock is consistent with composer.json.\e[0m'
70 echo
71 echo -e '\e[31mThis often indicates an issue with the upstream project, which can typically be resolved by reporting the issue to the relevant project maintainers.\e[0m'
72 echo
73 echo -e '\e[31mTo address the issue efficiently, follow one of these steps:\e[0m'
74 echo -e '\e[31m 1. File an issue in the project'\''s issue tracker with detailed information '\('run '\''composer update --lock --no-install'\'' to fix the issue'\)', and apply any available remote patches as a temporary solution with '\('with fetchpatch'\)'.\e[0m'
75 echo -e '\e[31m 2. If an immediate fix is needed or if reporting upstream isn'\''t suitable, develop a temporary local patch.\e[0m'
76 echo
77 exit 1
78 else
79 echo
80 echo -e "\e[33mWARNING: composer files validation failed\e[0m"
81 echo
82 echo -e '\e[33mThe validation of the composer.json and composer.lock failed.\e[0m'
83 echo -e '\e[33mMake sure that the file composer.lock is consistent with composer.json.\e[0m'
84 echo
85 echo -e '\e[33mThis often indicates an issue with the upstream project, which can typically be resolved by reporting the issue to the relevant project maintainers.\e[0m'
86 echo
87 echo -e '\e[33mTo address the issue efficiently, follow one of these steps:\e[0m'
88 echo -e '\e[33m 1. File an issue in the project'\''s issue tracker with detailed information '\('run '\''composer update --lock --no-install'\'' to fix the issue'\)', and apply any available remote patches as a temporary solution with '\('with fetchpatch'\)'.\e[0m'
89 echo -e '\e[33m 2. If an immediate fix is needed or if reporting upstream isn'\''t suitable, develop a temporary local patch.\e[0m'
90 echo
91 echo -e '\e[33mThis check is not blocking, but it is recommended to fix the issue.\e[0m'
92 echo
93 fi
94 fi
95}