mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 20:01:06 +07:00
Fix composer version for prestissimo & composer-prefetcher to v1
This commit is contained in:
parent
2c29e8b9a1
commit
87e62cbb7f
@ -228,6 +228,9 @@ describe('Tools tests', () => {
|
|||||||
expect(
|
expect(
|
||||||
await tools.addComposer(['a', 'b', 'c', 'composer:v2'])
|
await tools.addComposer(['a', 'b', 'c', 'composer:v2'])
|
||||||
).toStrictEqual(['composer:2', 'a', 'b', 'c']);
|
).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 () => {
|
it('checking getComposerUrl', async () => {
|
||||||
@ -277,7 +280,7 @@ describe('Tools tests', () => {
|
|||||||
|
|
||||||
it('checking getCleanedToolsList', async () => {
|
it('checking getCleanedToolsList', async () => {
|
||||||
const tools_list: string[] = await tools.getCleanedToolsList(
|
const tools_list: string[] = await tools.getCleanedToolsList(
|
||||||
'tool, composer:1.2.3, behat/behat, icanhazstring/composer-unused, laravel/vapor-cli, robmorgan/phinx, hirak/prestissimo, narrowspark/automatic-composer-prefetcher, phpspec/phpspec, symfony/flex'
|
'tool, composer:1.2.3, behat/behat, icanhazstring/composer-unused, laravel/vapor-cli, robmorgan/phinx, phpspec/phpspec, symfony/flex'
|
||||||
);
|
);
|
||||||
expect(tools_list).toStrictEqual([
|
expect(tools_list).toStrictEqual([
|
||||||
'composer',
|
'composer',
|
||||||
@ -286,8 +289,6 @@ describe('Tools tests', () => {
|
|||||||
'composer-unused',
|
'composer-unused',
|
||||||
'vapor-cli',
|
'vapor-cli',
|
||||||
'phinx',
|
'phinx',
|
||||||
'prestissimo',
|
|
||||||
'composer-prefetcher',
|
|
||||||
'phpspec',
|
'phpspec',
|
||||||
'flex'
|
'flex'
|
||||||
]);
|
]);
|
||||||
@ -433,7 +434,6 @@ describe('Tools tests', () => {
|
|||||||
'blackfire',
|
'blackfire',
|
||||||
'blackfire-player',
|
'blackfire-player',
|
||||||
'composer-normalize',
|
'composer-normalize',
|
||||||
'composer-prefetcher:1.2.3',
|
|
||||||
'composer-require-checker',
|
'composer-require-checker',
|
||||||
'composer-unused',
|
'composer-unused',
|
||||||
'cs2pr:1.2.3',
|
'cs2pr:1.2.3',
|
||||||
@ -522,9 +522,6 @@ describe('Tools tests', () => {
|
|||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'add_composertool composer-unused composer-unused icanhazstring/'
|
'add_composertool composer-unused composer-unused icanhazstring/'
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
|
||||||
'add_composertool composer-prefetcher composer-prefetcher:1.2.3 narrowspark/automatic-'
|
|
||||||
);
|
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'add_tool https://github.com/symfony/cli/releases/latest/download/symfony_darwin_amd64 symfony version'
|
'add_tool https://github.com/symfony/cli/releases/latest/download/symfony_darwin_amd64 symfony version'
|
||||||
);
|
);
|
||||||
@ -551,7 +548,6 @@ describe('Tools tests', () => {
|
|||||||
'php-config',
|
'php-config',
|
||||||
'phpize',
|
'phpize',
|
||||||
'phpmd',
|
'phpmd',
|
||||||
'prestissimo',
|
|
||||||
'symfony',
|
'symfony',
|
||||||
'wp-cli'
|
'wp-cli'
|
||||||
];
|
];
|
||||||
@ -576,7 +572,6 @@ describe('Tools tests', () => {
|
|||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'Add-Tool https://deployer.org/deployer.phar deployer "-V"'
|
'Add-Tool https://deployer.org/deployer.phar deployer "-V"'
|
||||||
);
|
);
|
||||||
expect(script).toContain('Add-Composertool prestissimo prestissimo hirak/');
|
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'Add-Tool https://github.com/phpmd/phpmd/releases/latest/download/phpmd.phar phpmd "--version"'
|
'Add-Tool https://github.com/phpmd/phpmd/releases/latest/download/phpmd.phar phpmd "--version"'
|
||||||
);
|
);
|
||||||
@ -608,7 +603,7 @@ describe('Tools tests', () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'Add-Tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-stable.phar,https://getcomposer.org/composer-stable.phar composer'
|
'Add-Tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-1.phar,https://getcomposer.org/composer-1.phar composer'
|
||||||
);
|
);
|
||||||
expect(script).toContain('Add-Composertool prestissimo prestissimo hirak/');
|
expect(script).toContain('Add-Composertool prestissimo prestissimo hirak/');
|
||||||
expect(script).toContain('Add-Composertool phinx phinx robmorgan/');
|
expect(script).toContain('Add-Composertool phinx phinx robmorgan/');
|
||||||
|
8
dist/index.js
vendored
8
dist/index.js
vendored
@ -2006,11 +2006,15 @@ exports.getWpCliUrl = getWpCliUrl;
|
|||||||
async function addComposer(tools_list) {
|
async function addComposer(tools_list) {
|
||||||
const regex_any = /^composer($|:.*)/;
|
const regex_any = /^composer($|:.*)/;
|
||||||
const regex_valid = /^composer:?($|preview$|snapshot$|v?[1-2]$)/;
|
const regex_valid = /^composer:?($|preview$|snapshot$|v?[1-2]$)/;
|
||||||
|
const regex_composer1_tools = /hirak|prestissimo|narrowspark|composer-prefetcher/;
|
||||||
const matches = tools_list.filter(tool => regex_valid.test(tool));
|
const matches = tools_list.filter(tool => regex_valid.test(tool));
|
||||||
let composer = 'composer';
|
let composer = 'composer';
|
||||||
tools_list = tools_list.filter(tool => !regex_any.test(tool));
|
tools_list = tools_list.filter(tool => !regex_any.test(tool));
|
||||||
switch (matches[0]) {
|
switch (true) {
|
||||||
case undefined:
|
case regex_composer1_tools.test(tools_list.join(' ')):
|
||||||
|
composer = 'composer:1';
|
||||||
|
break;
|
||||||
|
case matches[0] == undefined:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
composer = matches[matches.length - 1].replace(/v([1-2])/, '$1');
|
composer = matches[matches.length - 1].replace(/v([1-2])/, '$1');
|
||||||
|
@ -281,11 +281,15 @@ export async function getWpCliUrl(version: string): Promise<string> {
|
|||||||
export async function addComposer(tools_list: string[]): Promise<string[]> {
|
export async function addComposer(tools_list: string[]): Promise<string[]> {
|
||||||
const regex_any = /^composer($|:.*)/;
|
const regex_any = /^composer($|:.*)/;
|
||||||
const regex_valid = /^composer:?($|preview$|snapshot$|v?[1-2]$)/;
|
const regex_valid = /^composer:?($|preview$|snapshot$|v?[1-2]$)/;
|
||||||
|
const regex_composer1_tools = /hirak|prestissimo|narrowspark|composer-prefetcher/;
|
||||||
const matches: string[] = tools_list.filter(tool => regex_valid.test(tool));
|
const matches: string[] = tools_list.filter(tool => regex_valid.test(tool));
|
||||||
let composer = 'composer';
|
let composer = 'composer';
|
||||||
tools_list = tools_list.filter(tool => !regex_any.test(tool));
|
tools_list = tools_list.filter(tool => !regex_any.test(tool));
|
||||||
switch (matches[0]) {
|
switch (true) {
|
||||||
case undefined:
|
case regex_composer1_tools.test(tools_list.join(' ')):
|
||||||
|
composer = 'composer:1';
|
||||||
|
break;
|
||||||
|
case matches[0] == undefined:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
composer = matches[matches.length - 1].replace(/v([1-2])/, '$1');
|
composer = matches[matches.length - 1].replace(/v([1-2])/, '$1');
|
||||||
|
Loading…
Reference in New Issue
Block a user