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
|
||||
}
|
||||
|
||||
# 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.
|
||||
get_extension_map() {
|
||||
php -d'error_reporting=0' "${src:?}"/scripts/extensions/extension_map.php /tmp/map"$version".orig
|
||||
|
@ -59,25 +59,41 @@ Function Add-ToolsHelper() {
|
||||
[ValidateNotNull()]
|
||||
$tool
|
||||
)
|
||||
$extensions = @();
|
||||
if($tool -eq "codeception") {
|
||||
$extensions += @('json', 'mbstring')
|
||||
Copy-Item $env:codeception_bin\codecept.bat -Destination $env:codeception_bin\codeception.bat
|
||||
} elseif($tool -eq "composer") {
|
||||
Edit-ComposerConfig $bin_dir\$tool
|
||||
} elseif($tool -eq "cs2pr") {
|
||||
(Get-Content $bin_dir/cs2pr).replace('exit(9)', 'exit(0)') | Set-Content $bin_dir/cs2pr
|
||||
} elseif($tool -eq "phan") {
|
||||
Add-Extension fileinfo >$null 2>&1
|
||||
Add-Extension ast >$null 2>&1
|
||||
$extensions += @('fileinfo', 'ast')
|
||||
} elseif($tool -eq "phinx") {
|
||||
$extensions += @('mbstring')
|
||||
} 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") {
|
||||
$extensions+=('ctype', 'hash', 'json', 'fileinfo', 'iconv', 'mbstring', 'simplexml', 'xml')
|
||||
Add-Extension fileinfo >$null 2>&1
|
||||
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
|
||||
} elseif($tool -eq "wp-cli") {
|
||||
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.
|
||||
|
@ -52,7 +52,9 @@ configure_composer() {
|
||||
# Helper function to configure tools.
|
||||
add_tools_helper() {
|
||||
tool=$1
|
||||
extensions=()
|
||||
if [ "$tool" = "codeception" ]; then
|
||||
extensions+=(json mbstring)
|
||||
sudo ln -s "$scoped_dir"/vendor/bin/codecept "$scoped_dir"/vendor/bin/codeception
|
||||
elif [ "$tool" = "composer" ]; then
|
||||
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"
|
||||
elif [ "$tool" = "phan" ]; then
|
||||
add_extension fileinfo extension >/dev/null 2>&1
|
||||
add_extension ast extension >/dev/null 2>&1
|
||||
extensions+=(fileinfo ast)
|
||||
elif [ "$tool" = "phinx" ]; then
|
||||
extensions+=(mbstring)
|
||||
elif [ "$tool" = "phive" ]; then
|
||||
add_extension curl extension >/dev/null 2>&1
|
||||
add_extension mbstring extension >/dev/null 2>&1
|
||||
add_extension xml extension >/dev/null 2>&1
|
||||
extensions+=(curl mbstring xml)
|
||||
elif [[ "$tool" =~ phpc(bf|s) ]]; then
|
||||
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
|
||||
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"/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
|
||||
if [ -e "$tool_path_dir"/phpunit ] && [ -d "$composer_bin" ]; then
|
||||
sudo cp "$tool_path_dir"/phpunit "$composer_bin"
|
||||
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
|
||||
elif [ "$tool" = wp-cli ]; then
|
||||
sudo ln -s "$tool_path" "$tool_path_dir"/"${tool%-*}"
|
||||
fi
|
||||
for extension in "${extensions[@]}"; do
|
||||
add_extension "$extension" extension >/dev/null 2>&1
|
||||
done
|
||||
}
|
||||
|
||||
# Function to setup a remote tool.
|
||||
@ -118,8 +133,7 @@ add_composertool_helper() {
|
||||
prefix=$3
|
||||
scope=$4
|
||||
composer_args=$5
|
||||
enable_extension mbstring extension >/dev/null 2>&1
|
||||
enable_extension openssl extension >/dev/null 2>&1
|
||||
enable_extensions curl mbstring openssl
|
||||
if [ "$scope" = "global" ]; then
|
||||
sudo rm -f "$composer_lock" >/dev/null 2>&1 || true
|
||||
composer global require "$prefix$release" "$composer_args" >/dev/null 2>&1
|
||||
|
Loading…
Reference in New Issue
Block a user