mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 20:01:06 +07:00
Improve tools support
This commit is contained in:
parent
8e1cde2d0a
commit
6a70f864ec
@ -72,7 +72,7 @@ Setup PHP with required extensions, php.ini configuration, code-coverage support
|
|||||||
|
|
||||||
The latest version of the following tools can be setup globally using the `tools` input
|
The latest version of the following tools can be setup globally using the `tools` input
|
||||||
|
|
||||||
`composer`, `codeception`, `deployer`, `pecl`, `phpcbf`, `phpcpd`, `php-cs-fixer`, `phpcs`, `phpmd`, `phpstan`, `phpunit`, `prestissimo`
|
`composer`, `codeception`, `deployer`, `pecl`, `phinx`, `phpcbf`, `phpcpd`, `php-cs-fixer`, `phpcs`, `phpmd`, `phpstan`, `phpunit`, `prestissimo`, `psalm`
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
uses: shivammathur/setup-php@v1
|
uses: shivammathur/setup-php@v1
|
||||||
|
@ -21,40 +21,57 @@ describe('Tools tests', () => {
|
|||||||
|
|
||||||
it('checking addTools', async () => {
|
it('checking addTools', async () => {
|
||||||
let script: string = await tools.addTools(
|
let script: string = await tools.addTools(
|
||||||
'php-cs-fixer, phpstan, phpunit, pecl',
|
'php-cs-fixer, phpstan, phpunit, pecl, phinx',
|
||||||
'linux'
|
'linux'
|
||||||
);
|
);
|
||||||
expect(script).toContain('add_tool https://getcomposer.org/composer.phar');
|
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'add_tool https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/latest/download/php-cs-fixer.phar'
|
'add_tool https://github.com/composer/composer/releases/latest/download/composer.phar composer'
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'add_tool https://github.com/phpstan/phpstan/releases/latest/download/phpstan.phar'
|
'add_tool https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/latest/download/php-cs-fixer.phar php-cs-fixer'
|
||||||
|
);
|
||||||
|
expect(script).toContain(
|
||||||
|
'add_tool https://github.com/phpstan/phpstan/releases/latest/download/phpstan.phar phpstan'
|
||||||
|
);
|
||||||
|
expect(script).toContain(
|
||||||
|
'add_tool https://phar.phpunit.de/phpunit.phar phpunit'
|
||||||
);
|
);
|
||||||
expect(script).toContain('add_tool https://phar.phpunit.de/phpunit.phar');
|
|
||||||
expect(script).toContain('add_pecl');
|
expect(script).toContain('add_pecl');
|
||||||
|
expect(script).toContain('composer global require robmorgan/phinx');
|
||||||
|
|
||||||
script = await tools.addTools('phpcs, phpcbf, phpcpd, phpmd', 'darwin');
|
script = await tools.addTools(
|
||||||
expect(script).toContain('add_tool https://getcomposer.org/composer.phar');
|
'phpcs, phpcbf, phpcpd, phpmd, psalm',
|
||||||
expect(script).toContain(
|
'darwin'
|
||||||
'add_tool https://github.com/squizlabs/PHP_CodeSniffer/releases/latest/download/phpcs.phar'
|
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'add_tool https://github.com/squizlabs/PHP_CodeSniffer/releases/latest/download/phpcbf.phar'
|
'add_tool https://github.com/composer/composer/releases/latest/download/composer.phar composer'
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'add_tool https://github.com/sebastianbergmann/phpcpd/releases/latest/download/phpcpd.phar'
|
'add_tool https://github.com/squizlabs/PHP_CodeSniffer/releases/latest/download/phpcs.phar phpcs'
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'add_tool https://github.com/phpmd/phpmd/releases/latest/download/phpmd.phar'
|
'add_tool https://github.com/squizlabs/PHP_CodeSniffer/releases/latest/download/phpcbf.phar phpcbf'
|
||||||
|
);
|
||||||
|
expect(script).toContain(
|
||||||
|
'add_tool https://github.com/sebastianbergmann/phpcpd/releases/latest/download/phpcpd.phar phpcpd'
|
||||||
|
);
|
||||||
|
expect(script).toContain(
|
||||||
|
'add_tool https://github.com/phpmd/phpmd/releases/latest/download/phpmd.phar phpmd'
|
||||||
|
);
|
||||||
|
expect(script).toContain(
|
||||||
|
'https://github.com/vimeo/psalm/releases/latest/download/psalm.phar psalm'
|
||||||
);
|
);
|
||||||
|
|
||||||
script = await tools.addTools(
|
script = await tools.addTools(
|
||||||
'codeception, deployer, prestissimo, phpmd, does_not_exit',
|
'codeception, deployer, prestissimo, phpmd, does_not_exit',
|
||||||
'win32'
|
'win32'
|
||||||
);
|
);
|
||||||
expect(script).toContain('Add-Tool https://getcomposer.org/composer.phar');
|
expect(script).toContain(
|
||||||
expect(script).toContain('Add-Tool https://deployer.org/deployer.phar');
|
'Add-Tool https://github.com/composer/composer/releases/latest/download/composer.phar composer'
|
||||||
|
);
|
||||||
|
expect(script).toContain(
|
||||||
|
'Add-Tool https://deployer.org/deployer.phar deployer'
|
||||||
|
);
|
||||||
expect(script).toContain('composer global require hirak/prestissimo');
|
expect(script).toContain('composer global require hirak/prestissimo');
|
||||||
expect(script).toContain('Tool does_not_exit is not supported');
|
expect(script).toContain('Tool does_not_exit is not supported');
|
||||||
});
|
});
|
||||||
|
16
dist/index.js
vendored
16
dist/index.js
vendored
@ -1591,7 +1591,7 @@ exports.getPECLCommand = getPECLCommand;
|
|||||||
*/
|
*/
|
||||||
function addTools(tools_csv, os_version) {
|
function addTools(tools_csv, os_version) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let script = yield utils.stepLog('Setup Tools', os_version);
|
let script = '\n' + (yield utils.stepLog('Setup Tools', os_version));
|
||||||
let tools = yield utils.CSVArray(tools_csv);
|
let tools = yield utils.CSVArray(tools_csv);
|
||||||
tools = tools.filter(tool => tool !== 'composer');
|
tools = tools.filter(tool => tool !== 'composer');
|
||||||
tools.unshift('composer');
|
tools.unshift('composer');
|
||||||
@ -1641,10 +1641,22 @@ function addTools(tools_csv, os_version) {
|
|||||||
' ' +
|
' ' +
|
||||||
'phpmd';
|
'phpmd';
|
||||||
break;
|
break;
|
||||||
|
case 'psalm':
|
||||||
|
script +=
|
||||||
|
(yield getToolCommand(os_version)) +
|
||||||
|
'https://github.com/vimeo/psalm/releases/latest/download/psalm.phar' +
|
||||||
|
' ' +
|
||||||
|
'psalm';
|
||||||
|
break;
|
||||||
|
case 'phinx':
|
||||||
|
script +=
|
||||||
|
'composer global require robmorgan/phinx' +
|
||||||
|
(yield utils.suppressOutput(os_version));
|
||||||
|
break;
|
||||||
case 'composer':
|
case 'composer':
|
||||||
script +=
|
script +=
|
||||||
(yield getToolCommand(os_version)) +
|
(yield getToolCommand(os_version)) +
|
||||||
'https://getcomposer.org/composer.phar' +
|
'https://github.com/composer/composer/releases/latest/download/composer.phar' +
|
||||||
' ' +
|
' ' +
|
||||||
'composer';
|
'composer';
|
||||||
break;
|
break;
|
||||||
|
@ -51,11 +51,15 @@ remove_extension() {
|
|||||||
add_tool() {
|
add_tool() {
|
||||||
url=$1
|
url=$1
|
||||||
tool=$2
|
tool=$2
|
||||||
|
if [ "$tool" = "composer" ]; then
|
||||||
|
brew install composer >/dev/null 2>&1
|
||||||
|
else
|
||||||
if [ ! -e /usr/local/bin/"$tool" ]; then
|
if [ ! -e /usr/local/bin/"$tool" ]; then
|
||||||
rm -rf /usr/local/bin/"${tool:?}"
|
rm -rf /usr/local/bin/"${tool:?}"
|
||||||
fi
|
fi
|
||||||
sudo curl -o /usr/local/bin/"$tool" -L "$url" >/dev/null 2>&1
|
sudo curl -o /usr/local/bin/"$tool" -L "$url" >/dev/null 2>&1
|
||||||
sudo chmod a+x /usr/local/bin/"$tool"
|
sudo chmod a+x /usr/local/bin/"$tool"
|
||||||
|
fi
|
||||||
add_log "$tick" "$tool" "Added"
|
add_log "$tick" "$tool" "Added"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +89,11 @@ Function Add-Tool() {
|
|||||||
[string]
|
[string]
|
||||||
$tool
|
$tool
|
||||||
)
|
)
|
||||||
if (Test-Path $php_dir\$tool) {
|
if($tool -eq "composer") {
|
||||||
|
Install-Composer -Scope System -Path $php_dir -PhpPath $php_dir
|
||||||
|
} else {
|
||||||
|
if (Test-Path $php_dir\$tool)
|
||||||
|
{
|
||||||
Remove-Item $php_dir\$tool
|
Remove-Item $php_dir\$tool
|
||||||
}
|
}
|
||||||
Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $php_dir\$tool > $null 2>&1
|
Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $php_dir\$tool > $null 2>&1
|
||||||
@ -100,6 +104,7 @@ Function Add-Tool() {
|
|||||||
$bat_content += "php %BIN_TARGET% %*"
|
$bat_content += "php %BIN_TARGET% %*"
|
||||||
Set-Content -Path $php_dir\$tool.bat -Value $bat_content
|
Set-Content -Path $php_dir\$tool.bat -Value $bat_content
|
||||||
Add-Content -Path $PsHome\profile.ps1 -Value "New-Alias $tool $php_dir\$tool.bat"
|
Add-Content -Path $PsHome\profile.ps1 -Value "New-Alias $tool $php_dir\$tool.bat"
|
||||||
|
}
|
||||||
Add-Log $tick $tool "Added"
|
Add-Log $tick $tool "Added"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
16
src/tools.ts
16
src/tools.ts
@ -42,7 +42,7 @@ export async function addTools(
|
|||||||
tools_csv: string,
|
tools_csv: string,
|
||||||
os_version: string
|
os_version: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
let script = await utils.stepLog('Setup Tools', os_version);
|
let script = '\n' + (await utils.stepLog('Setup Tools', os_version));
|
||||||
let tools: Array<string> = await utils.CSVArray(tools_csv);
|
let tools: Array<string> = await utils.CSVArray(tools_csv);
|
||||||
tools = tools.filter(tool => tool !== 'composer');
|
tools = tools.filter(tool => tool !== 'composer');
|
||||||
tools.unshift('composer');
|
tools.unshift('composer');
|
||||||
@ -91,10 +91,22 @@ export async function addTools(
|
|||||||
' ' +
|
' ' +
|
||||||
'phpmd';
|
'phpmd';
|
||||||
break;
|
break;
|
||||||
|
case 'psalm':
|
||||||
|
script +=
|
||||||
|
(await getToolCommand(os_version)) +
|
||||||
|
'https://github.com/vimeo/psalm/releases/latest/download/psalm.phar' +
|
||||||
|
' ' +
|
||||||
|
'psalm';
|
||||||
|
break;
|
||||||
|
case 'phinx':
|
||||||
|
script +=
|
||||||
|
'composer global require robmorgan/phinx' +
|
||||||
|
(await utils.suppressOutput(os_version));
|
||||||
|
break;
|
||||||
case 'composer':
|
case 'composer':
|
||||||
script +=
|
script +=
|
||||||
(await getToolCommand(os_version)) +
|
(await getToolCommand(os_version)) +
|
||||||
'https://getcomposer.org/composer.phar' +
|
'https://github.com/composer/composer/releases/latest/download/composer.phar' +
|
||||||
' ' +
|
' ' +
|
||||||
'composer';
|
'composer';
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user