Fetch blackfire latest versions

This commit is contained in:
Shivam Mathur
2020-05-07 17:14:15 +05:30
parent 8123132b99
commit 5c2618165a
11 changed files with 42 additions and 96 deletions

View File

@ -38,7 +38,7 @@ export async function addExtensionDarwin(
' ' +
version +
' ' +
(await utils.getBlackfireVersion(ext_version));
extension;
break;
// match pre-release versions. For example - xdebug-beta
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
@ -110,7 +110,7 @@ export async function addExtensionDarwin(
break;
}
add_script +=
'\nadd_extension ' + extension + ' "' + command + '" ' + ext_prefix;
'\nadd_extension ' + ext_name + ' "' + command + '" ' + ext_prefix;
});
return add_script + remove_script;
}
@ -148,7 +148,7 @@ export async function addExtensionWindows(
' ' +
version +
' ' +
(await utils.getBlackfireVersion(ext_version));
extension;
return;
// match pre-release versions. For example - xdebug-beta
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
@ -198,7 +198,7 @@ export async function addExtensionWindows(
'\n';
break;
default:
add_script += '\nAdd-Extension ' + extension;
add_script += '\nAdd-Extension ' + ext_name;
break;
}
});
@ -232,7 +232,7 @@ export async function addExtensionLinux(
remove_script += '\nremove_extension ' + ext_name.slice(1);
return;
// match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire
// match 5.3blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0
// match 5.3blackfire-{semver}...5.6blackfire-{semver}, 7.0blackfire-{semver}...7.4blackfire-{semver}
case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(
version_extension
):
@ -242,7 +242,7 @@ export async function addExtensionLinux(
' ' +
version +
' ' +
(await utils.getBlackfireVersion(ext_version));
extension;
break;
// match pre-release versions. For example - xdebug-beta
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
@ -310,7 +310,7 @@ export async function addExtensionLinux(
break;
}
add_script +=
'\nadd_extension ' + extension + ' "' + command + '" ' + ext_prefix;
'\nadd_extension ' + ext_name + ' "' + command + '" ' + ext_prefix;
});
return add_script + remove_script;
}

View File

@ -3,10 +3,10 @@ Param (
[ValidateNotNull()]
[string]
$version,
[Parameter(Position = 2, Mandatory = $false)]
[Parameter(Position = 1, Mandatory = $true)]
[ValidateNotNull()]
[string]
$extension_version
$extension
)
$tick = ([char]8730)
@ -15,7 +15,11 @@ $ext_dir = $php_dir + '\ext'
$arch='x64'
if ($version -lt '7.0') { $arch='x86' }
$version = $version.replace('.', '')
$extension_version = $extension.split('-')[1]
if ($extension_version -notmatch "\S") {
$ext_data = Invoke-WebRequest https://blackfire.io/docs/up-and-running/update | ForEach-Object { $_.tostring() -split "[`r`n]" | Select-String '<td class="version">' | Select-Object -Index 2 }
$extension_version = [regex]::Matches($ext_data, '<td.*?>(.+)</td>') | ForEach-Object { $_.Captures[0].Groups[1].value }
}
if (Test-Path $ext_dir\blackfire.dll) {
Enable-PhpExtension -Extension blackfire -Path $php_dir
$status="Enabled"

View File

@ -1,5 +1,9 @@
version=${1/./}
extension_version=$2
extension=${2}
extension_version=$(echo "$extension" | cut -d '-' -f 2)
if [ "$extension_version" = "blackfire" ]; then
extension_version=$(curl -sSL https://blackfire.io/docs/up-and-running/update | grep 'class="version"' | sed -e 's/<[^>]*>\| //g' | sed -n '3,3p')
fi
ext_dir=$(php -i | grep "extension_dir => /" | sed -e "s|.*=> s*||")
scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||")
ini_file="$scan_dir/50-blackfire.ini"

View File

@ -1,5 +1,9 @@
version=${1/./}
extension_version=$2
extension=${2}
extension_version=$(echo "$extension" | cut -d '-' -f 2)
if [ "$extension_version" = "blackfire" ]; then
extension_version=$(curl -sSL https://blackfire.io/docs/up-and-running/update | grep 'class="version"' | sed -e "s/ //g" | sed -n '3,3p' | cut -d '>' -f 2 | cut -d '<' -f 1)
fi
ext_dir=$(php -i | grep -Ei "extension_dir => /usr" | sed -e "s|.*=> s*||")
scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||")
ini_file="$scan_dir/50-blackfire.ini"

View File

@ -216,13 +216,8 @@ Function Add-Pecl() {
}
Function Add-Blackfire() {
Param (
[Parameter(Position = 0, Mandatory = $true)]
[ValidateNotNull()]
[ValidateLength(1, [int]::MaxValue)]
[string]
$agent_version
)
$agent_data = Invoke-WebRequest https://blackfire.io/docs/up-and-running/update | ForEach-Object { $_.tostring() -split "[`r`n]" | Select-String '<td class="version">' | Select-Object -Index 0 }
$agent_version = [regex]::Matches($agent_data, '<td.*?>(.+)</td>') | ForEach-Object {$_.Captures[0].Groups[1].value }
$url = "https://packages.blackfire.io/binaries/blackfire-agent/${agent_version}/blackfire-agent-windows_${arch_name}.zip"
Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $php_dir\blackfire.zip >$null 2>&1
Expand-Archive -Path $php_dir\blackfire.zip -DestinationPath $php_dir -Force >$null 2>&1

View File

@ -438,10 +438,7 @@ export async function addTools(
switch (tool) {
case 'blackfire':
case 'blackfire-agent':
script += await getCommand(
os_version,
'blackfire ' + (await utils.getBlackfireAgentVersion())
);
script += await getCommand(os_version, 'blackfire');
break;
case 'blackfire-player':
url = await getPharUrl('https://get.blackfire.io', tool, 'v', version);

View File

@ -255,28 +255,3 @@ export async function suppressOutput(os_version: string): Promise<string> {
);
}
}
/**
* Function to get Blackfire version
*
* @param blackfire_version
*/
export async function getBlackfireVersion(
blackfire_version: null | undefined | string
): Promise<string> {
switch (blackfire_version) {
case null:
case undefined:
case '':
return '1.31.0';
default:
return blackfire_version;
}
}
/**
* Function to get Blackfire Agent version
*/
export async function getBlackfireAgentVersion(): Promise<string> {
return '1.32.0';
}