mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-25 21:13:04 +07:00
Skip prestissimo and composer-prefetcher unless composer:v1 is specified
This commit is contained in:
parent
403191b6b6
commit
09222f42ae
@ -251,9 +251,6 @@ describe('Tools tests', () => {
|
||||
expect(
|
||||
await tools.addComposer(['a', 'b', 'c', 'composer:v2'])
|
||||
).toStrictEqual(['composer:2', 'a', 'b', 'c']);
|
||||
expect(
|
||||
await tools.addComposer(['hirak', 'b', 'c', 'composer:v2'])
|
||||
).toStrictEqual(['composer:1', 'hirak', 'b', 'c']);
|
||||
});
|
||||
|
||||
it('checking getComposerUrl', async () => {
|
||||
@ -629,6 +626,7 @@ describe('Tools tests', () => {
|
||||
});
|
||||
it('checking addTools with composer tool using user/tool as input', async () => {
|
||||
const listOfTools = [
|
||||
'composer:v1',
|
||||
'hirak/prestissimo',
|
||||
'narrowspark/automatic-composer-prefetcher',
|
||||
'robmorgan/phinx'
|
||||
|
4
dist/index.js
vendored
4
dist/index.js
vendored
@ -2023,14 +2023,10 @@ exports.getWpCliUrl = getWpCliUrl;
|
||||
async function addComposer(tools_list) {
|
||||
const regex_any = /^composer($|:.*)/;
|
||||
const regex_valid = /^composer:?($|preview$|snapshot$|v?[1-2]$|v?\d+\.\d+\.\d+[\w-]*$)/;
|
||||
const regex_composer1_tools = /hirak|prestissimo|narrowspark|composer-prefetcher/;
|
||||
const matches = tools_list.filter(tool => regex_valid.test(tool));
|
||||
let composer = 'composer';
|
||||
tools_list = tools_list.filter(tool => !regex_any.test(tool));
|
||||
switch (true) {
|
||||
case regex_composer1_tools.test(tools_list.join(' ')):
|
||||
composer = 'composer:1';
|
||||
break;
|
||||
case matches[0] == undefined:
|
||||
break;
|
||||
default:
|
||||
|
@ -222,12 +222,12 @@ Function Get-ToolVersion() {
|
||||
$version_regex = "[0-9]+((\.{1}[0-9]+)+)(\.{0})(-[a-z0-9]+){0,1}"
|
||||
if($tool -eq 'composer') {
|
||||
if ($param -eq 'snapshot') {
|
||||
$trunk = Select-String -Pattern "const\sBRANCH_ALIAS_VERSION" -Path $bin_dir\composer -Raw | Select-String -Pattern $version_regex | ForEach-Object { $_.matches.Value }
|
||||
$commit = Select-String -Pattern "const\sVERSION" -Path $bin_dir\composer -Raw | Select-String -Pattern "[a-zA-Z0-9]+" -AllMatches | ForEach-Object { $_.matches[2].Value }
|
||||
return "$trunk+$commit"
|
||||
$composer_version = (Select-String -Pattern "const\sBRANCH_ALIAS_VERSION" -Path $bin_dir\composer -Raw | Select-String -Pattern $version_regex | ForEach-Object { $_.matches.Value }) + '+' + (Select-String -Pattern "const\sVERSION" -Path $bin_dir\composer -Raw | Select-String -Pattern "[a-zA-Z0-9]+" -AllMatches | ForEach-Object { $_.matches[2].Value })
|
||||
} else {
|
||||
return Select-String -Pattern "const\sVERSION" -Path $bin_dir\composer -Raw | Select-String -Pattern $version_regex | ForEach-Object { $_.matches.Value }
|
||||
$composer_version = Select-String -Pattern "const\sVERSION" -Path $bin_dir\composer -Raw | Select-String -Pattern $version_regex | ForEach-Object { $_.matches.Value }
|
||||
}
|
||||
Set-Variable -Name 'composer_version' -Value $composer_version -Scope Global
|
||||
return "$composer_version"
|
||||
}
|
||||
return . $tool $param 2> $null | ForEach-Object { $_ -replace "composer $version_regex", '' } | Select-String -Pattern $version_regex | Select-Object -First 1 | ForEach-Object { $_.matches.Value }
|
||||
}
|
||||
@ -310,6 +310,11 @@ Function Add-Composertool() {
|
||||
[string]
|
||||
$prefix
|
||||
)
|
||||
if($tool -match "prestissimo|composer-prefetcher" -and $composer_version.split('.')[0] -ne "1") {
|
||||
Write-Output "::warning:: Skipping $tool, as it does not support Composer $composer_version. Specify composer:v1 in tools to use $tool"
|
||||
Add-Log $cross $tool "Skipped"
|
||||
Return
|
||||
}
|
||||
composer global require $prefix$release 2>&1 | out-null
|
||||
$json = findstr $prefix$tool $env:APPDATA\Composer\composer.json
|
||||
if(Test-Path $composer_bin\composer) {
|
||||
|
@ -306,14 +306,10 @@ export async function getWpCliUrl(version: string): Promise<string> {
|
||||
export async function addComposer(tools_list: string[]): Promise<string[]> {
|
||||
const regex_any = /^composer($|:.*)/;
|
||||
const regex_valid = /^composer:?($|preview$|snapshot$|v?[1-2]$|v?\d+\.\d+\.\d+[\w-]*$)/;
|
||||
const regex_composer1_tools = /hirak|prestissimo|narrowspark|composer-prefetcher/;
|
||||
const matches: string[] = tools_list.filter(tool => regex_valid.test(tool));
|
||||
let composer = 'composer';
|
||||
tools_list = tools_list.filter(tool => !regex_any.test(tool));
|
||||
switch (true) {
|
||||
case regex_composer1_tools.test(tools_list.join(' ')):
|
||||
composer = 'composer:1';
|
||||
break;
|
||||
case matches[0] == undefined:
|
||||
break;
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user