mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 20:01:06 +07:00
Improve tools support when extensions are disabled/missing
This commit is contained in:
parent
99a4a141f4
commit
6f6e534936
@ -47,6 +47,17 @@ enable_extension() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Function to enable array of extensions
|
||||||
|
enable_extensions() {
|
||||||
|
local extensions=("$@")
|
||||||
|
to_wait=()
|
||||||
|
for ext in "${extensions[@]}"; do
|
||||||
|
enable_extension "$ext" extension >/dev/null 2>&1 &
|
||||||
|
to_wait+=($!)
|
||||||
|
done
|
||||||
|
wait "${to_wait[@]}"
|
||||||
|
}
|
||||||
|
|
||||||
# Function to get a map of extensions and their dependent shared extensions.
|
# Function to get a map of extensions and their dependent shared extensions.
|
||||||
get_extension_map() {
|
get_extension_map() {
|
||||||
php -d'error_reporting=0' "${src:?}"/scripts/extensions/extension_map.php /tmp/map"$version".orig
|
php -d'error_reporting=0' "${src:?}"/scripts/extensions/extension_map.php /tmp/map"$version".orig
|
||||||
|
@ -59,25 +59,41 @@ Function Add-ToolsHelper() {
|
|||||||
[ValidateNotNull()]
|
[ValidateNotNull()]
|
||||||
$tool
|
$tool
|
||||||
)
|
)
|
||||||
|
$extensions = @();
|
||||||
if($tool -eq "codeception") {
|
if($tool -eq "codeception") {
|
||||||
|
$extensions += @('json', 'mbstring')
|
||||||
Copy-Item $env:codeception_bin\codecept.bat -Destination $env:codeception_bin\codeception.bat
|
Copy-Item $env:codeception_bin\codecept.bat -Destination $env:codeception_bin\codeception.bat
|
||||||
} elseif($tool -eq "composer") {
|
} elseif($tool -eq "composer") {
|
||||||
Edit-ComposerConfig $bin_dir\$tool
|
Edit-ComposerConfig $bin_dir\$tool
|
||||||
} elseif($tool -eq "cs2pr") {
|
} elseif($tool -eq "cs2pr") {
|
||||||
(Get-Content $bin_dir/cs2pr).replace('exit(9)', 'exit(0)') | Set-Content $bin_dir/cs2pr
|
(Get-Content $bin_dir/cs2pr).replace('exit(9)', 'exit(0)') | Set-Content $bin_dir/cs2pr
|
||||||
} elseif($tool -eq "phan") {
|
} elseif($tool -eq "phan") {
|
||||||
Add-Extension fileinfo >$null 2>&1
|
$extensions += @('fileinfo', 'ast')
|
||||||
Add-Extension ast >$null 2>&1
|
} elseif($tool -eq "phinx") {
|
||||||
|
$extensions += @('mbstring')
|
||||||
} elseif($tool -eq "phive") {
|
} elseif($tool -eq "phive") {
|
||||||
Add-Extension xml >$null 2>&1
|
$extensions += @('curl', 'mbstring', 'xml')
|
||||||
|
} elseif($tool -match "phpc(df|s)") {
|
||||||
|
$extensions += @('tokenizer', 'xmlwriter', 'simplexml')
|
||||||
|
} elseif($tool -match "php-cs-fixer") {
|
||||||
|
$extensions += @('json', 'tokenizer')
|
||||||
} elseif($tool -eq "phpDocumentor") {
|
} elseif($tool -eq "phpDocumentor") {
|
||||||
|
$extensions+=('ctype', 'hash', 'json', 'fileinfo', 'iconv', 'mbstring', 'simplexml', 'xml')
|
||||||
Add-Extension fileinfo >$null 2>&1
|
Add-Extension fileinfo >$null 2>&1
|
||||||
Copy-Item $bin_dir\phpDocumentor.bat -Destination $bin_dir\phpdoc.bat
|
Copy-Item $bin_dir\phpDocumentor.bat -Destination $bin_dir\phpdoc.bat
|
||||||
} elseif($tool -match "vapor-cli") {
|
} elseif($tool -eq "phpunit") {
|
||||||
|
$extensions += @('dom', 'json', 'libxml', 'mbstring', 'xml', 'xmlwriter')
|
||||||
|
} elseif($tool -eq "phpunit-bridge") {
|
||||||
|
$extensions += @('dom', 'pdo', 'tokenizer', 'xmlwriter')
|
||||||
|
} elseif($tool -eq "vapor-cli") {
|
||||||
|
$extensions += @('fileinfo', 'json', 'mbstring', 'zip', 'simplexml')
|
||||||
Copy-Item $env:vapor_cli_bin\vapor.bat -Destination $env:vapor_cli_bin\vapor-cli.bat
|
Copy-Item $env:vapor_cli_bin\vapor.bat -Destination $env:vapor_cli_bin\vapor-cli.bat
|
||||||
} elseif($tool -eq "wp-cli") {
|
} elseif($tool -eq "wp-cli") {
|
||||||
Copy-Item $bin_dir\wp-cli.bat -Destination $bin_dir\wp.bat
|
Copy-Item $bin_dir\wp-cli.bat -Destination $bin_dir\wp.bat
|
||||||
}
|
}
|
||||||
|
foreach($extension in $extensions) {
|
||||||
|
Add-Extension $extension >$null 2>&1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to add tools.
|
# Function to add tools.
|
||||||
|
@ -52,7 +52,9 @@ configure_composer() {
|
|||||||
# Helper function to configure tools.
|
# Helper function to configure tools.
|
||||||
add_tools_helper() {
|
add_tools_helper() {
|
||||||
tool=$1
|
tool=$1
|
||||||
|
extensions=()
|
||||||
if [ "$tool" = "codeception" ]; then
|
if [ "$tool" = "codeception" ]; then
|
||||||
|
extensions+=(json mbstring)
|
||||||
sudo ln -s "$scoped_dir"/vendor/bin/codecept "$scoped_dir"/vendor/bin/codeception
|
sudo ln -s "$scoped_dir"/vendor/bin/codecept "$scoped_dir"/vendor/bin/codeception
|
||||||
elif [ "$tool" = "composer" ]; then
|
elif [ "$tool" = "composer" ]; then
|
||||||
configure_composer "$tool_path"
|
configure_composer "$tool_path"
|
||||||
@ -60,25 +62,38 @@ add_tools_helper() {
|
|||||||
sudo sed -i 's/\r$//; s/exit(9)/exit(0)/' "$tool_path" 2>/dev/null ||
|
sudo sed -i 's/\r$//; s/exit(9)/exit(0)/' "$tool_path" 2>/dev/null ||
|
||||||
sudo sed -i '' 's/\r$//; s/exit(9)/exit(0)/' "$tool_path"
|
sudo sed -i '' 's/\r$//; s/exit(9)/exit(0)/' "$tool_path"
|
||||||
elif [ "$tool" = "phan" ]; then
|
elif [ "$tool" = "phan" ]; then
|
||||||
add_extension fileinfo extension >/dev/null 2>&1
|
extensions+=(fileinfo ast)
|
||||||
add_extension ast extension >/dev/null 2>&1
|
elif [ "$tool" = "phinx" ]; then
|
||||||
|
extensions+=(mbstring)
|
||||||
elif [ "$tool" = "phive" ]; then
|
elif [ "$tool" = "phive" ]; then
|
||||||
add_extension curl extension >/dev/null 2>&1
|
extensions+=(curl mbstring xml)
|
||||||
add_extension mbstring extension >/dev/null 2>&1
|
elif [[ "$tool" =~ phpc(bf|s) ]]; then
|
||||||
add_extension xml extension >/dev/null 2>&1
|
extensions+=(tokenizer simplexml xmlwriter)
|
||||||
|
elif [[ "$tool" =~ phpc(bf|s) ]]; then
|
||||||
|
extensions+=(tokenizer xmlwriter simplexml)
|
||||||
|
elif [ "$tool" = "php-cs-fixer" ]; then
|
||||||
|
extensions+=(json tokenizer)
|
||||||
elif [ "$tool" = "phpDocumentor" ]; then
|
elif [ "$tool" = "phpDocumentor" ]; then
|
||||||
add_extension fileinfo extension >/dev/null 2>&1
|
extensions+=(ctype hash json fileinfo iconv mbstring simplexml xml)
|
||||||
sudo ln -s "$tool_path" "$tool_path_dir"/phpdocumentor 2>/dev/null || true
|
sudo ln -s "$tool_path" "$tool_path_dir"/phpdocumentor 2>/dev/null || true
|
||||||
sudo ln -s "$tool_path" "$tool_path_dir"/phpdoc
|
sudo ln -s "$tool_path" "$tool_path_dir"/phpdoc
|
||||||
|
elif [ "$tool" = "phpunit" ]; then
|
||||||
|
extensions+=(dom json libxml mbstring xml xmlwriter)
|
||||||
|
elif [ "$tool" = "phpunit-bridge" ]; then
|
||||||
|
extensions+=(dom pdo tokenizer xmlwriter xmlreader)
|
||||||
elif [[ "$tool" =~ phpunit(-polyfills)?$ ]]; then
|
elif [[ "$tool" =~ phpunit(-polyfills)?$ ]]; then
|
||||||
if [ -e "$tool_path_dir"/phpunit ] && [ -d "$composer_bin" ]; then
|
if [ -e "$tool_path_dir"/phpunit ] && [ -d "$composer_bin" ]; then
|
||||||
sudo cp "$tool_path_dir"/phpunit "$composer_bin"
|
sudo cp "$tool_path_dir"/phpunit "$composer_bin"
|
||||||
fi
|
fi
|
||||||
elif [[ "$tool" =~ vapor-cli ]]; then
|
elif [ "$tool" = "vapor-cli" ]; then
|
||||||
|
extensions+=(fileinfo json mbstring zip simplexml)
|
||||||
sudo ln -s "$scoped_dir"/vendor/bin/vapor "$scoped_dir"/vendor/bin/vapor-cli
|
sudo ln -s "$scoped_dir"/vendor/bin/vapor "$scoped_dir"/vendor/bin/vapor-cli
|
||||||
elif [ "$tool" = wp-cli ]; then
|
elif [ "$tool" = wp-cli ]; then
|
||||||
sudo ln -s "$tool_path" "$tool_path_dir"/"${tool%-*}"
|
sudo ln -s "$tool_path" "$tool_path_dir"/"${tool%-*}"
|
||||||
fi
|
fi
|
||||||
|
for extension in "${extensions[@]}"; do
|
||||||
|
add_extension "$extension" extension >/dev/null 2>&1
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to setup a remote tool.
|
# Function to setup a remote tool.
|
||||||
@ -118,8 +133,7 @@ add_composertool_helper() {
|
|||||||
prefix=$3
|
prefix=$3
|
||||||
scope=$4
|
scope=$4
|
||||||
composer_args=$5
|
composer_args=$5
|
||||||
enable_extension mbstring extension >/dev/null 2>&1
|
enable_extensions curl mbstring openssl
|
||||||
enable_extension openssl extension >/dev/null 2>&1
|
|
||||||
if [ "$scope" = "global" ]; then
|
if [ "$scope" = "global" ]; then
|
||||||
sudo rm -f "$composer_lock" >/dev/null 2>&1 || true
|
sudo rm -f "$composer_lock" >/dev/null 2>&1 || true
|
||||||
composer global require "$prefix$release" "$composer_args" >/dev/null 2>&1
|
composer global require "$prefix$release" "$composer_args" >/dev/null 2>&1
|
||||||
|
Loading…
Reference in New Issue
Block a user