1# shellcheck shell=bash
2
3declare -g version
4declare -g -i composerStrictValidation="${composerStrictValidation:-0}"
5
6setComposerRootVersion() {
7 if [[ -n $version ]]; then
8 echo -e "\e[32mSetting COMPOSER_ROOT_VERSION to $version\e[0m"
9 export COMPOSER_ROOT_VERSION="$version"
10 fi
11}
12
13setComposerEnvVariables() {
14 echo -e "\e[32mSetting some required environment variables for Composer...\e[0m"
15 export COMPOSER_MIRROR_PATH_REPOS=1
16 export COMPOSER_HTACCESS_PROTECT=0
17 export COMPOSER_FUND=0
18}
19
20checkComposerValidate() {
21 command="composer validate --strict --quiet --no-interaction --no-check-all --no-check-lock"
22 if ! $command; then
23 echo
24 echo -e "\e[31mERROR: composer files validation failed\e[0m"
25 echo
26 echo -e '\e[31mThe validation of the composer.json failed.\e[0m'
27 echo -e '\e[31mMake sure that the file composer.json is valid.\e[0m'
28 echo
29 echo -e '\e[31mTo address the issue efficiently, follow one of these steps:\e[0m'
30 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'
31 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'
32 echo
33
34 if [[ "${composerStrictValidation}" == "1" ]]; then
35 echo
36 echo -e '\e[33mThis check is blocking, set the attribute composerStrictValidation to false to make it not blocking.\e[0m'
37 echo
38 exit 1
39 else
40 echo
41 echo -e '\e[33mThis check is not blocking, but it is recommended to fix the issue.\e[0m'
42 echo
43 fi
44 fi
45
46 command="composer validate --strict --no-ansi --no-interaction --quiet --no-check-all --check-lock"
47 if ! $command; then
48 echo
49 echo -e "\e[31mERROR: composer files validation failed\e[0m"
50 echo
51 echo -e '\e[31mThe validation of the composer.json and composer.lock failed.\e[0m'
52 echo -e '\e[31mMake sure that the file composer.lock is consistent with composer.json.\e[0m'
53 echo
54 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'
55 echo
56 echo -e '\e[31mTo address the issue efficiently, follow one of these steps:\e[0m'
57 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'
58 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'
59 echo
60
61 if [[ "${composerStrictValidation}" == "1" ]]; then
62 echo
63 echo -e '\e[33mThis check is blocking, set the attribute composerStrictValidation to false to make it not blocking.\e[0m'
64 echo
65 exit 1
66 else
67 echo
68 echo -e '\e[33mThis check is not blocking, but it is recommended to fix the issue.\e[0m'
69 echo
70 fi
71 fi
72}