diff --git a/__tests__/extensions.test.ts b/__tests__/extensions.test.ts index cf3ddbf7..02e44365 100644 --- a/__tests__/extensions.test.ts +++ b/__tests__/extensions.test.ts @@ -27,10 +27,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 73'); + expect(win32).toContain('blackfire.ps1 73'); win32 = await extensions.addExtension('blackfire-1.31.0', '7.3', 'win32'); - expect(win32).toContain('blackfire.ps1 7.3 73 1.31.0'); + expect(win32).toContain('blackfire.ps1 73 1.31.0'); }); it('checking addExtensionOnLinux', async () => { diff --git a/dist/index.js b/dist/index.js index 62837264..749c1d37 100644 --- a/dist/index.js +++ b/dist/index.js @@ -2692,6 +2692,18 @@ function addExtensionDarwin(extension_csv, version, pipe) { const prefix = yield utils.getExtensionPrefix(ext_name); let install_command = ''; switch (true) { + case /^blackfire(-\d+\.\d+\.\d+)?$/.test(extension): + script += + '\nsh ' + + path.join(__dirname, '../src/scripts/ext/blackfire_darwin.sh') + + ' ' + + version + + ' ' + + (yield utils.getMinorVersion(version)).replace('.', ''); + if (ext_version) { + script += ' ' + ext_version; + } + return; // match pre-release versions case /.*-(beta|alpha|devel|snapshot)/.test(version_extension): script += @@ -2733,18 +2745,6 @@ function addExtensionDarwin(extension_csv, version, pipe) { ' ' + version; return; - case /^blackfire(-\d+\.\d+\.\d+)?$/.test(extension): - script += - '\nsh ' + - path.join(__dirname, '../src/scripts/ext/blackfire_darwin.sh') + - ' ' + - version + - ' ' + - (yield utils.getMinorVersion(version)).replace('.', ''); - if (ext_version) { - script += ' ' + ext_version; - } - return; default: install_command = 'sudo pecl install -f ' + extension + pipe; break; @@ -2783,11 +2783,9 @@ function addExtensionWindows(extension_csv, version, pipe) { // match blackfire...blackfire-1.31.0 case /^blackfire(-\d+\.\d+\.\d+)?$/.test(extension): script += - '\nsh ' + + '\n& ' + path.join(__dirname, '../src/scripts/ext/blackfire.ps1') + ' ' + - version + - ' ' + (yield utils.getMinorVersion(version)).replace('.', ''); if (ext_version) { script += ' ' + ext_version; diff --git a/src/extensions.ts b/src/extensions.ts index 632b541d..c423053f 100644 --- a/src/extensions.ts +++ b/src/extensions.ts @@ -22,6 +22,19 @@ export async function addExtensionDarwin( const prefix = await utils.getExtensionPrefix(ext_name); let install_command = ''; switch (true) { + case /^blackfire(-\d+\.\d+\.\d+)?$/.test(extension): + script += + '\nsh ' + + path.join(__dirname, '../src/scripts/ext/blackfire_darwin.sh') + + ' ' + + version + + ' ' + + (await utils.getMinorVersion(version)).replace('.', ''); + + if (ext_version) { + script += ' ' + ext_version; + } + return; // match pre-release versions case /.*-(beta|alpha|devel|snapshot)/.test(version_extension): script += @@ -63,19 +76,6 @@ export async function addExtensionDarwin( ' ' + version; return; - case /^blackfire(-\d+\.\d+\.\d+)?$/.test(extension): - script += - '\nsh ' + - path.join(__dirname, '../src/scripts/ext/blackfire_darwin.sh') + - ' ' + - version + - ' ' + - (await utils.getMinorVersion(version)).replace('.', ''); - - if (ext_version) { - script += ' ' + ext_version; - } - return; default: install_command = 'sudo pecl install -f ' + extension + pipe; break; @@ -114,11 +114,9 @@ export async function addExtensionWindows( // match blackfire...blackfire-1.31.0 case /^blackfire(-\d+\.\d+\.\d+)?$/.test(extension): script += - '\nsh ' + + '\n& ' + path.join(__dirname, '../src/scripts/ext/blackfire.ps1') + ' ' + - version + - ' ' + (await utils.getMinorVersion(version)).replace('.', ''); if (ext_version) { diff --git a/src/scripts/ext/blackfire.ps1 b/src/scripts/ext/blackfire.ps1 new file mode 100644 index 00000000..f7955b49 --- /dev/null +++ b/src/scripts/ext/blackfire.ps1 @@ -0,0 +1,27 @@ +Param ( + [Parameter(Position = 0, Mandatory = $true)] + [ValidateNotNull()] + [string] + $phpversion, + [Parameter(Position = 1, Mandatory = $true)] + [ValidateNotNull()] + [ValidateLength(1, [int]::MaxValue)] + [string] + $version = '1.31.0' +) + +Function Install-Blackfire() { + $installed = Get-Php -Path $php_dir + $nts = if (!$installed.ThreadSafe) { "_nts" } else { "" } + Invoke-WebRequest -UseBasicParsing -Uri "https://packages.blackfire.io/binaries/blackfire-php/${version}/blackfire-php-windows_x64-php-${phpversion}${nts}.dll" -OutFile $ENV:RUNNER_TOOL_CACHE\blackfire.dll > $null 2>&1 + Copy-Item -Path "$ENV:RUNNER_TOOL_CACHE\blackfire.dll" -Destination "$ext_dir\blackfire.dll" + Enable-PhpExtension -Extension blackfire -Path $php_dir + printf "\033[%s;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "32" $tick "Blackfire" "Installed and enabled" +} + +$tick = ([char]8730) +$php_dir = 'C:\tools\php' +$ext_dir = $php_dir + '\ext' + +Install-Blackfire +