Remove unnecessary parameter version from addArchive

This commit is contained in:
Shivam Mathur 2020-09-07 02:14:46 +05:30
parent f7fb800623
commit 03b97e24e9
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A
3 changed files with 30 additions and 37 deletions

View File

@ -324,21 +324,18 @@ describe('Tools tests', () => {
it('checking addArchive', async () => { it('checking addArchive', async () => {
let script: string = await tools.addArchive( let script: string = await tools.addArchive(
'tool', 'tool',
'1.2.3',
'https://tool.com/tool.phar', 'https://tool.com/tool.phar',
'linux' 'linux'
); );
expect(script).toContain('add_tool https://tool.com/tool.phar tool'); expect(script).toContain('add_tool https://tool.com/tool.phar tool');
script = await tools.addArchive( script = await tools.addArchive(
'tool', 'tool',
'1.2.3',
'https://tool.com/tool.phar', 'https://tool.com/tool.phar',
'darwin' 'darwin'
); );
expect(script).toContain('add_tool https://tool.com/tool.phar tool'); expect(script).toContain('add_tool https://tool.com/tool.phar tool');
script = await tools.addArchive( script = await tools.addArchive(
'tool', 'tool',
'1.2.3',
'https://tool.com/tool.phar', 'https://tool.com/tool.phar',
'win32' 'win32'
); );
@ -346,7 +343,6 @@ describe('Tools tests', () => {
script = await tools.addArchive( script = await tools.addArchive(
'tool', 'tool',
'1.2.3',
'https://tool.com/tool.phar', 'https://tool.com/tool.phar',
'fedora' 'fedora'
); );

39
dist/index.js vendored
View File

@ -973,7 +973,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
@ -1029,7 +1029,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
@ -1604,7 +1604,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
@ -1910,11 +1910,10 @@ exports.getCleanedToolsList = getCleanedToolsList;
* Helper function to get script to setup a tool using a phar url * Helper function to get script to setup a tool using a phar url
* *
* @param tool * @param tool
* @param version
* @param url * @param url
* @param os_version * @param os_version
*/ */
async function addArchive(tool, version, url, os_version) { async function addArchive(tool, url, os_version) {
return (await getCommand(os_version, 'tool')) + url + ' ' + tool; return (await getCommand(os_version, 'tool')) + url + ' ' + tool;
} }
exports.addArchive = addArchive; exports.addArchive = addArchive;
@ -1974,51 +1973,51 @@ async function addTools(tools_csv, php_version, os_version) {
case 'cs2pr': case 'cs2pr':
uri = await getUri(tool, '', version, 'releases', '', 'download'); uri = await getUri(tool, '', version, 'releases', '', 'download');
url = github + 'staabm/annotate-pull-request-from-checkstyle/' + uri; url = github + 'staabm/annotate-pull-request-from-checkstyle/' + uri;
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'php-cs-fixer': case 'php-cs-fixer':
uri = await getUri(tool, '.phar', version, 'releases', 'v', 'download'); uri = await getUri(tool, '.phar', version, 'releases', 'v', 'download');
url = github + 'FriendsOfPHP/PHP-CS-Fixer/' + uri; url = github + 'FriendsOfPHP/PHP-CS-Fixer/' + uri;
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'phpcs': case 'phpcs':
case 'phpcbf': case 'phpcbf':
url = github + 'squizlabs/PHP_CodeSniffer/' + uri; url = github + 'squizlabs/PHP_CodeSniffer/' + uri;
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'phive': case 'phive':
script += await addPhive(version, os_version); script += await addPhive(version, os_version);
break; break;
case 'phpstan': case 'phpstan':
url = github + 'phpstan/phpstan/' + uri; url = github + 'phpstan/phpstan/' + uri;
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'phpmd': case 'phpmd':
url = github + 'phpmd/phpmd/' + uri; url = github + 'phpmd/phpmd/' + uri;
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'psalm': case 'psalm':
url = github + 'vimeo/psalm/' + uri; url = github + 'vimeo/psalm/' + uri;
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'composer': case 'composer':
url = await getComposerUrl(version); url = await getComposerUrl(version);
script += await addArchive('composer', version, url, os_version); script += await addArchive('composer', url, os_version);
break; break;
case 'codeception': case 'codeception':
url = url =
'https://codeception.com/' + 'https://codeception.com/' +
(await getCodeceptionUri(version, php_version)); (await getCodeceptionUri(version, php_version));
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'phpcpd': case 'phpcpd':
case 'phpunit': case 'phpunit':
url = await getPharUrl('https://phar.phpunit.de', tool, '', version); url = await getPharUrl('https://phar.phpunit.de', tool, '', version);
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'deployer': case 'deployer':
url = await getDeployerUrl(version); url = await getDeployerUrl(version);
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'phinx': case 'phinx':
script += await addPackage(tool, release, 'robmorgan/', os_version); script += await addPackage(tool, release, 'robmorgan/', os_version);
@ -2040,7 +2039,7 @@ async function addTools(tools_csv, php_version, os_version) {
case 'symfony-cli': case 'symfony-cli':
uri = await getSymfonyUri(version, os_version); uri = await getSymfonyUri(version, os_version);
url = github + 'symfony/cli/' + uri; url = github + 'symfony/cli/' + uri;
script += await addArchive('symfony', version, url, os_version); script += await addArchive('symfony', url, os_version);
break; break;
default: default:
script += await utils.addLog('$cross', tool, 'Tool ' + tool + ' is not supported', os_version); script += await utils.addLog('$cross', tool, 'Tool ' + tool + ' is not supported', os_version);
@ -2088,7 +2087,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
@ -2227,7 +2226,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
@ -2323,7 +2322,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
@ -2646,7 +2645,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };

View File

@ -345,13 +345,11 @@ export async function getCleanedToolsList(
* Helper function to get script to setup a tool using a phar url * Helper function to get script to setup a tool using a phar url
* *
* @param tool * @param tool
* @param version
* @param url * @param url
* @param os_version * @param os_version
*/ */
export async function addArchive( export async function addArchive(
tool: string, tool: string,
version: string,
url: string, url: string,
os_version: string os_version: string
): Promise<string> { ): Promise<string> {
@ -444,51 +442,51 @@ export async function addTools(
case 'cs2pr': case 'cs2pr':
uri = await getUri(tool, '', version, 'releases', '', 'download'); uri = await getUri(tool, '', version, 'releases', '', 'download');
url = github + 'staabm/annotate-pull-request-from-checkstyle/' + uri; url = github + 'staabm/annotate-pull-request-from-checkstyle/' + uri;
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'php-cs-fixer': case 'php-cs-fixer':
uri = await getUri(tool, '.phar', version, 'releases', 'v', 'download'); uri = await getUri(tool, '.phar', version, 'releases', 'v', 'download');
url = github + 'FriendsOfPHP/PHP-CS-Fixer/' + uri; url = github + 'FriendsOfPHP/PHP-CS-Fixer/' + uri;
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'phpcs': case 'phpcs':
case 'phpcbf': case 'phpcbf':
url = github + 'squizlabs/PHP_CodeSniffer/' + uri; url = github + 'squizlabs/PHP_CodeSniffer/' + uri;
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'phive': case 'phive':
script += await addPhive(version, os_version); script += await addPhive(version, os_version);
break; break;
case 'phpstan': case 'phpstan':
url = github + 'phpstan/phpstan/' + uri; url = github + 'phpstan/phpstan/' + uri;
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'phpmd': case 'phpmd':
url = github + 'phpmd/phpmd/' + uri; url = github + 'phpmd/phpmd/' + uri;
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'psalm': case 'psalm':
url = github + 'vimeo/psalm/' + uri; url = github + 'vimeo/psalm/' + uri;
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'composer': case 'composer':
url = await getComposerUrl(version); url = await getComposerUrl(version);
script += await addArchive('composer', version, url, os_version); script += await addArchive('composer', url, os_version);
break; break;
case 'codeception': case 'codeception':
url = url =
'https://codeception.com/' + 'https://codeception.com/' +
(await getCodeceptionUri(version, php_version)); (await getCodeceptionUri(version, php_version));
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'phpcpd': case 'phpcpd':
case 'phpunit': case 'phpunit':
url = await getPharUrl('https://phar.phpunit.de', tool, '', version); url = await getPharUrl('https://phar.phpunit.de', tool, '', version);
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'deployer': case 'deployer':
url = await getDeployerUrl(version); url = await getDeployerUrl(version);
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'phinx': case 'phinx':
script += await addPackage(tool, release, 'robmorgan/', os_version); script += await addPackage(tool, release, 'robmorgan/', os_version);
@ -515,7 +513,7 @@ export async function addTools(
case 'symfony-cli': case 'symfony-cli':
uri = await getSymfonyUri(version, os_version); uri = await getSymfonyUri(version, os_version);
url = github + 'symfony/cli/' + uri; url = github + 'symfony/cli/' + uri;
script += await addArchive('symfony', version, url, os_version); script += await addArchive('symfony', url, os_version);
break; break;
default: default:
script += await utils.addLog( script += await utils.addLog(