diff --git a/dist/index.js b/dist/index.js index 8ac13c4e..99b81b43 100644 --- a/dist/index.js +++ b/dist/index.js @@ -2259,7 +2259,7 @@ async function getCleanedToolsList(tools_csv) { .map(function (extension) { return extension .trim() - .replace(/hirak\/|laravel\/|narrowspark\/automatic-|overtrue\/|robmorgan\/|symfony\//, ''); + .replace(/-agent|hirak\/|laravel\/|narrowspark\/automatic-|overtrue\/|robmorgan\/|symfony\//, ''); }) .filter(Boolean); return [...new Set(tools_list)]; @@ -2345,8 +2345,9 @@ async function addTools(tools_csv, php_version, os_version) { let url = ''; switch (tool) { case 'blackfire': - case 'blackfire-agent': - script += await getCommand(os_version, 'blackfire'); + case 'grpc_php_plugin': + case 'protoc': + script += await addCustomTool(tool, version, os_version); break; case 'blackfire-player': url = await getPharUrl('https://get.blackfire.io', tool, 'v', version); @@ -2392,10 +2393,6 @@ async function addTools(tools_csv, php_version, os_version) { case 'flex': script += await addPackage(tool, release, 'symfony/', os_version); break; - case 'grpc_php_plugin': - case 'protoc': - script += await addCustomTool(tool, version, os_version); - break; case 'infection': url = github + 'infection/infection/' + uri; script += await addArchive(tool, version, url, os_version); diff --git a/src/scripts/darwin.sh b/src/scripts/darwin.sh index 998e76c9..e27c4d59 100644 --- a/src/scripts/darwin.sh +++ b/src/scripts/darwin.sh @@ -202,21 +202,6 @@ add_composertool() { ) || add_log "$cross" "$tool" "Could not setup $tool" } -add_blackfire() { - sudo mkdir -p usr/local/var/run - brew tap --shallow blackfireio/homebrew-blackfire >/dev/null 2>&1 - brew install blackfire-agent >/dev/null 2>&1 - if [[ -n $BLACKFIRE_SERVER_ID ]] && [[ -n $BLACKFIRE_SERVER_TOKEN ]]; then - blackfire-agent --register --server-id="$BLACKFIRE_SERVER_ID" --server-token="$BLACKFIRE_SERVER_TOKEN" >/dev/null 2>&1 - brew services start blackfire-agent >/dev/null 2>&1 - fi - if [[ -n $BLACKFIRE_CLIENT_ID ]] && [[ -n $BLACKFIRE_CLIENT_TOKEN ]]; then - blackfire config --client-id="$BLACKFIRE_CLIENT_ID" --client-token="$BLACKFIRE_CLIENT_TOKEN" >/dev/null 2>&1 - fi - add_log "$tick" "blackfire" "Added" - add_log "$tick" "blackfire-agent" "Added" -} - # Function to configure PECL configure_pecl() { for tool in pear pecl; do diff --git a/src/scripts/linux.sh b/src/scripts/linux.sh index d02d15cf..adcf9f23 100644 --- a/src/scripts/linux.sh +++ b/src/scripts/linux.sh @@ -305,24 +305,6 @@ add_devtools() { configure_pecl >/dev/null 2>&1 } -# Function to add blackfire and blackfire-agent. -add_blackfire() { - sudo mkdir -p /var/run/blackfire - sudo curl "${curl_opts[@]}" https://packages.blackfire.io/gpg.key | sudo apt-key add - >/dev/null 2>&1 - echo "deb http://packages.blackfire.io/debian any main" | sudo tee /etc/apt/sources.list.d/blackfire.list >/dev/null 2>&1 - sudo "$debconf_fix" apt-get update >/dev/null 2>&1 - $apt_install blackfire-agent >/dev/null 2>&1 - if [[ -n $BLACKFIRE_SERVER_ID ]] && [[ -n $BLACKFIRE_SERVER_TOKEN ]]; then - sudo blackfire-agent --register --server-id="$BLACKFIRE_SERVER_ID" --server-token="$BLACKFIRE_SERVER_TOKEN" >/dev/null 2>&1 - sudo /etc/init.d/blackfire-agent restart >/dev/null 2>&1 - fi - if [[ -n $BLACKFIRE_CLIENT_ID ]] && [[ -n $BLACKFIRE_CLIENT_TOKEN ]]; then - blackfire config --client-id="$BLACKFIRE_CLIENT_ID" --client-token="$BLACKFIRE_CLIENT_TOKEN" >/dev/null 2>&1 - fi - add_log "$tick" "blackfire" "Added" - add_log "$tick" "blackfire-agent" "Added" -} - # Function to setup the nightly build from master branch. setup_master() { curl "${curl_opts[@]}" "$github"/php-builder/releases/latest/download/install.sh | bash -s "$runner" diff --git a/src/scripts/tools/blackfire.ps1 b/src/scripts/tools/blackfire.ps1 new file mode 100644 index 00000000..5dca721d --- /dev/null +++ b/src/scripts/tools/blackfire.ps1 @@ -0,0 +1,17 @@ +# Function to add blackfire and blackfire-agent. +Function Add-Blackfire() { + $agent_version = (Invoke-RestMethod https://blackfire.io/api/v1/releases).agent + $url = "https://packages.blackfire.io/binaries/blackfire-agent/${agent_version}/blackfire-agent-windows_${arch_name}.zip" + Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $bin_dir\blackfire.zip >$null 2>&1 + Expand-Archive -Path $bin_dir\blackfire.zip -DestinationPath $bin_dir -Force >$null 2>&1 + Add-ToProfile $current_profile 'blackfire' "New-Alias blackfire $bin_dir\blackfire.exe" + Add-ToProfile $current_profile 'blackfire-agent' "New-Alias blackfire-agent $bin_dir\blackfire-agent.exe" + if ((Test-Path env:BLACKFIRE_SERVER_ID) -and (Test-Path env:BLACKFIRE_SERVER_TOKEN)) { + blackfire-agent --register --server-id=$env:BLACKFIRE_SERVER_ID --server-token=$env:BLACKFIRE_SERVER_TOKEN >$null 2>&1 + } + if ((Test-Path env:BLACKFIRE_CLIENT_ID) -and (Test-Path env:BLACKFIRE_CLIENT_TOKEN)) { + blackfire config --client-id=$env:BLACKFIRE_CLIENT_ID --client-token=$env:BLACKFIRE_CLIENT_TOKEN --ca-cert=$php_dir\ssl\cacert.pem >$null 2>&1 + } + Add-Log $tick "blackfire" "Added" + Add-Log $tick "blackfire-agent" "Added" +} diff --git a/src/scripts/tools/blackfire.sh b/src/scripts/tools/blackfire.sh new file mode 100644 index 00000000..a41b8717 --- /dev/null +++ b/src/scripts/tools/blackfire.sh @@ -0,0 +1,34 @@ +add_blackfire_linux() { + sudo mkdir -p /var/run/blackfire + sudo curl "${curl_opts[@]:?}" https://packages.blackfire.io/gpg.key | sudo apt-key add - + echo "deb http://packages.blackfire.io/debian any main" | sudo tee /etc/apt/sources.list.d/blackfire.list + sudo "${debconf_fix:?}" apt-get update + ${apt_install:?} blackfire-agent +} + +add_blackfire_darwin() { + sudo mkdir -p /usr/local/var/run + brew tap --shallow blackfireio/homebrew-blackfire + brew install blackfire-agent +} + +blackfire_config() { + if [[ -n $BLACKFIRE_SERVER_ID ]] && [[ -n $BLACKFIRE_SERVER_TOKEN ]]; then + sudo blackfire-agent --register --server-id="$BLACKFIRE_SERVER_ID" --server-token="$BLACKFIRE_SERVER_TOKEN" + [ "$os" = "Linux" ] && sudo /etc/init.d/blackfire-agent restart + [ "$os" = "Darwin" ] && brew services start blackfire-agent + fi + if [[ -n $BLACKFIRE_CLIENT_ID ]] && [[ -n $BLACKFIRE_CLIENT_TOKEN ]]; then + blackfire config --client-id="$BLACKFIRE_CLIENT_ID" --client-token="$BLACKFIRE_CLIENT_TOKEN" + fi +} + +# Function to add blackfire and blackfire-agent. +add_blackfire() { + os="$(uname -s)" + [ "$os" = "Linux" ] && add_blackfire_linux >/dev/null 2>&1 + [ "$os" = "Darwin" ] && add_blackfire_darwin >/dev/null 2>&1 + blackfire_config >/dev/null 2>&1 + add_log "${tick:?}" "blackfire" "Added" + add_log "${tick:?}" "blackfire-agent" "Added" +} diff --git a/src/scripts/win32.ps1 b/src/scripts/win32.ps1 index a097ac1b..9731dcbc 100644 --- a/src/scripts/win32.ps1 +++ b/src/scripts/win32.ps1 @@ -265,24 +265,6 @@ Function Add-Pecl() { Add-Log $tick "PECL" "Use extensions input to setup PECL extensions on windows" } -# Function to add blackfire and blackfire-agent. -Function Add-Blackfire() { - $agent_version = (Invoke-RestMethod https://blackfire.io/api/v1/releases).agent - $url = "https://packages.blackfire.io/binaries/blackfire-agent/${agent_version}/blackfire-agent-windows_${arch_name}.zip" - Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $bin_dir\blackfire.zip >$null 2>&1 - Expand-Archive -Path $bin_dir\blackfire.zip -DestinationPath $bin_dir -Force >$null 2>&1 - Add-ToProfile $current_profile 'blackfire' "New-Alias blackfire $bin_dir\blackfire.exe" - Add-ToProfile $current_profile 'blackfire-agent' "New-Alias blackfire-agent $bin_dir\blackfire-agent.exe" - if ((Test-Path env:BLACKFIRE_SERVER_ID) -and (Test-Path env:BLACKFIRE_SERVER_TOKEN)) { - blackfire-agent --register --server-id=$env:BLACKFIRE_SERVER_ID --server-token=$env:BLACKFIRE_SERVER_TOKEN >$null 2>&1 - } - if ((Test-Path env:BLACKFIRE_CLIENT_ID) -and (Test-Path env:BLACKFIRE_CLIENT_TOKEN)) { - blackfire config --client-id=$env:BLACKFIRE_CLIENT_ID --client-token=$env:BLACKFIRE_CLIENT_TOKEN --ca-cert=$php_dir\ssl\cacert.pem >$null 2>&1 - } - Add-Log $tick "blackfire" "Added" - Add-Log $tick "blackfire-agent" "Added" -} - # Variables $tick = ([char]8730) $cross = ([char]10007) diff --git a/src/tools.ts b/src/tools.ts index ffb3f599..50677a05 100644 --- a/src/tools.ts +++ b/src/tools.ts @@ -364,7 +364,7 @@ export async function getCleanedToolsList( return extension .trim() .replace( - /hirak\/|laravel\/|narrowspark\/automatic-|overtrue\/|robmorgan\/|symfony\//, + /-agent|hirak\/|laravel\/|narrowspark\/automatic-|overtrue\/|robmorgan\/|symfony\//, '' ); }) @@ -494,8 +494,9 @@ export async function addTools( let url = ''; switch (tool) { case 'blackfire': - case 'blackfire-agent': - script += await getCommand(os_version, 'blackfire'); + case 'grpc_php_plugin': + case 'protoc': + script += await addCustomTool(tool, version, os_version); break; case 'blackfire-player': url = await getPharUrl('https://get.blackfire.io', tool, 'v', version); @@ -546,10 +547,6 @@ export async function addTools( case 'flex': script += await addPackage(tool, release, 'symfony/', os_version); break; - case 'grpc_php_plugin': - case 'protoc': - script += await addCustomTool(tool, version, os_version); - break; case 'infection': url = github + 'infection/infection/' + uri; script += await addArchive(tool, version, url, os_version);