mirror of
				https://github.com/shivammathur/setup-php.git
				synced 2025-10-31 23:36:21 +07:00 
			
		
		
		
	Fetch blackfire latest versions
This commit is contained in:
		| @ -42,10 +42,10 @@ describe('Extension tests', () => { | ||||
|     expect(win32).toContain('Platform fedora is not supported'); | ||||
|  | ||||
|     win32 = await extensions.addExtension('blackfire', '7.3', 'win32'); | ||||
|     expect(win32).toContain('blackfire.ps1 7.3 1.31.0'); | ||||
|     expect(win32).toContain('blackfire.ps1 7.3 blackfire'); | ||||
|  | ||||
|     win32 = await extensions.addExtension('blackfire-1.31.0', '7.3', 'win32'); | ||||
|     expect(win32).toContain('blackfire.ps1 7.3 1.31.0'); | ||||
|     expect(win32).toContain('blackfire.ps1 7.3 blackfire-1.31.0'); | ||||
|   }); | ||||
|  | ||||
|   it('checking addExtensionOnLinux', async () => { | ||||
| @ -92,10 +92,10 @@ describe('Extension tests', () => { | ||||
|     expect(linux).toContain('phalcon.sh phalcon4 7.3'); | ||||
|  | ||||
|     linux = await extensions.addExtension('blackfire', '7.3', 'linux'); | ||||
|     expect(linux).toContain('blackfire.sh 7.3 1.31.0'); | ||||
|     expect(linux).toContain('blackfire.sh 7.3 blackfire'); | ||||
|  | ||||
|     linux = await extensions.addExtension('blackfire-1.31.0', '7.3', 'linux'); | ||||
|     expect(linux).toContain('blackfire.sh 7.3 1.31.0'); | ||||
|     expect(linux).toContain('blackfire.sh 7.3 blackfire-1.31.0'); | ||||
|   }); | ||||
|  | ||||
|   it('checking addExtensionOnDarwin', async () => { | ||||
| @ -156,10 +156,10 @@ describe('Extension tests', () => { | ||||
|     expect(darwin).toContain('sudo pecl install -f imagick'); | ||||
|  | ||||
|     darwin = await extensions.addExtension('blackfire', '7.3', 'darwin'); | ||||
|     expect(darwin).toContain('blackfire_darwin.sh 7.3 1.31.0'); | ||||
|     expect(darwin).toContain('blackfire_darwin.sh 7.3 blackfire'); | ||||
|  | ||||
|     darwin = await extensions.addExtension('blackfire-1.31.0', '7.3', 'darwin'); | ||||
|     expect(darwin).toContain('blackfire_darwin.sh 7.3 1.31.0'); | ||||
|     expect(darwin).toContain('blackfire_darwin.sh 7.3 blackfire-1.31.0'); | ||||
|  | ||||
|     darwin = await extensions.addExtension( | ||||
|       'does_not_exist', | ||||
|  | ||||
| @ -450,7 +450,7 @@ describe('Tools tests', () => { | ||||
|       '7.4', | ||||
|       'win32' | ||||
|     ); | ||||
|     expect(script).toContain('Add-Blackfire 1.32.0'); | ||||
|     expect(script).toContain('Add-Blackfire'); | ||||
|     expect(script).toContain( | ||||
|       'Add-Tool https://get.blackfire.io/blackfire-player-v1.8.1.phar blackfire-player' | ||||
|     ); | ||||
|  | ||||
| @ -161,14 +161,4 @@ describe('Utils tests', () => { | ||||
|       'Platform fedora is not supported' | ||||
|     ); | ||||
|   }); | ||||
|  | ||||
|   it('checking getBlackfireVersion', async () => { | ||||
|     expect(await utils.getBlackfireVersion('')).toEqual('1.31.0'); | ||||
|     expect(await utils.getBlackfireVersion(undefined)).toEqual('1.31.0'); | ||||
|     expect(await utils.getBlackfireVersion(null)).toEqual('1.31.0'); | ||||
|     expect(await utils.getBlackfireVersion('1.32.0')).toEqual('1.32.0'); | ||||
|   }); | ||||
|   it('checking getBlackfireAgentVersion', async () => { | ||||
|     expect(await utils.getBlackfireAgentVersion()).toEqual('1.32.0'); | ||||
|   }); | ||||
| }); | ||||
|  | ||||
							
								
								
									
										39
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										39
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							| @ -1214,29 +1214,6 @@ async function suppressOutput(os_version) { | ||||
|     } | ||||
| } | ||||
| exports.suppressOutput = suppressOutput; | ||||
| /** | ||||
|  * Function to get Blackfire version | ||||
|  * | ||||
|  * @param blackfire_version | ||||
|  */ | ||||
| async function getBlackfireVersion(blackfire_version) { | ||||
|     switch (blackfire_version) { | ||||
|         case null: | ||||
|         case undefined: | ||||
|         case '': | ||||
|             return '1.31.0'; | ||||
|         default: | ||||
|             return blackfire_version; | ||||
|     } | ||||
| } | ||||
| exports.getBlackfireVersion = getBlackfireVersion; | ||||
| /** | ||||
|  * Function to get Blackfire Agent version | ||||
|  */ | ||||
| async function getBlackfireAgentVersion() { | ||||
|     return '1.32.0'; | ||||
| } | ||||
| exports.getBlackfireAgentVersion = getBlackfireAgentVersion; | ||||
|  | ||||
|  | ||||
| /***/ }), | ||||
| @ -1940,7 +1917,7 @@ async function addTools(tools_csv, php_version, os_version) { | ||||
|         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); | ||||
| @ -2620,7 +2597,7 @@ async function addExtensionDarwin(extension_csv, version, pipe) { | ||||
|                         ' ' + | ||||
|                         version + | ||||
|                         ' ' + | ||||
|                         (await utils.getBlackfireVersion(ext_version)); | ||||
|                         extension; | ||||
|                 break; | ||||
|             // match pre-release versions. For example - xdebug-beta | ||||
|             case /.*-(beta|alpha|devel|snapshot)/.test(version_extension): | ||||
| @ -2692,7 +2669,7 @@ async function addExtensionDarwin(extension_csv, version, pipe) { | ||||
|                 break; | ||||
|         } | ||||
|         add_script += | ||||
|             '\nadd_extension ' + extension + ' "' + command + '" ' + ext_prefix; | ||||
|             '\nadd_extension ' + ext_name + ' "' + command + '" ' + ext_prefix; | ||||
|     }); | ||||
|     return add_script + remove_script; | ||||
| } | ||||
| @ -2725,7 +2702,7 @@ async function addExtensionWindows(extension_csv, version) { | ||||
|                         ' ' + | ||||
|                         version + | ||||
|                         ' ' + | ||||
|                         (await utils.getBlackfireVersion(ext_version)); | ||||
|                         extension; | ||||
|                 return; | ||||
|             // match pre-release versions. For example - xdebug-beta | ||||
|             case /.*-(beta|alpha|devel|snapshot)/.test(version_extension): | ||||
| @ -2771,7 +2748,7 @@ async function addExtensionWindows(extension_csv, version) { | ||||
|                         '\n'; | ||||
|                 break; | ||||
|             default: | ||||
|                 add_script += '\nAdd-Extension ' + extension; | ||||
|                 add_script += '\nAdd-Extension ' + ext_name; | ||||
|                 break; | ||||
|         } | ||||
|     }); | ||||
| @ -2801,7 +2778,7 @@ async function addExtensionLinux(extension_csv, version, pipe) { | ||||
|                 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): | ||||
|                 command = | ||||
|                     'bash ' + | ||||
| @ -2809,7 +2786,7 @@ async function addExtensionLinux(extension_csv, version, pipe) { | ||||
|                         ' ' + | ||||
|                         version + | ||||
|                         ' ' + | ||||
|                         (await utils.getBlackfireVersion(ext_version)); | ||||
|                         extension; | ||||
|                 break; | ||||
|             // match pre-release versions. For example - xdebug-beta | ||||
|             case /.*-(beta|alpha|devel|snapshot)/.test(version_extension): | ||||
| @ -2877,7 +2854,7 @@ async function addExtensionLinux(extension_csv, version, pipe) { | ||||
|                 break; | ||||
|         } | ||||
|         add_script += | ||||
|             '\nadd_extension ' + extension + ' "' + command + '" ' + ext_prefix; | ||||
|             '\nadd_extension ' + ext_name + ' "' + command + '" ' + ext_prefix; | ||||
|     }); | ||||
|     return add_script + remove_script; | ||||
| } | ||||
|  | ||||
| @ -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; | ||||
| } | ||||
|  | ||||
| @ -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" | ||||
|  | ||||
| @ -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" | ||||
|  | ||||
| @ -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" | ||||
|  | ||||
| @ -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 | ||||
|  | ||||
| @ -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); | ||||
|  | ||||
							
								
								
									
										25
									
								
								src/utils.ts
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								src/utils.ts
									
									
									
									
									
								
							| @ -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'; | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Shivam Mathur
					Shivam Mathur