Skip to content

Commit

Permalink
Use composer for codeception setup
Browse files Browse the repository at this point in the history
  • Loading branch information
shivammathur committed Feb 19, 2021
1 parent 70d858d commit cff0bde
Show file tree
Hide file tree
Showing 4 changed files with 7,710 additions and 248 deletions.
89 changes: 1 addition & 88 deletions __tests__/tools.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,93 +79,6 @@ describe('Tools tests', () => {
).toBe('releases/download/v1.2.3/tool.phar');
});

it('checking getCodeceptionUriBuilder', async () => {
expect(await tools.getCodeceptionUriBuilder('3.2.1', 'php56')).toBe(
'releases/3.2.1/php56/codecept.phar'
);
expect(await tools.getCodeceptionUriBuilder('3.2.1', 'php54')).toBe(
'releases/3.2.1/php54/codecept.phar'
);
expect(await tools.getCodeceptionUriBuilder('3.2.1', '')).toBe(
'releases/3.2.1/codecept.phar'
);
});

it('checking getCodeceptionUri', async () => {
expect(await tools.getCodeceptionUri('latest', '5.6')).toBe(
'php56/codecept.phar'
);
expect(await tools.getCodeceptionUri('latest', '7.0')).toBe(
'php56/codecept.phar'
);
expect(await tools.getCodeceptionUri('latest', '7.1')).toBe(
'php56/codecept.phar'
);
expect(await tools.getCodeceptionUri('latest', '7.2')).toBe(
'codecept.phar'
);
expect(await tools.getCodeceptionUri('latest', '7.3')).toBe(
'codecept.phar'
);
expect(await tools.getCodeceptionUri('latest', '7.4')).toBe(
'codecept.phar'
);
expect(await tools.getCodeceptionUri('4.0.0', '7.4')).toBe(
'releases/4.0.0/codecept.phar'
);
expect(await tools.getCodeceptionUri('4.0.0', '5.6')).toBe(
'releases/4.0.0/php56/codecept.phar'
);
expect(await tools.getCodeceptionUri('4.0.0', '7.1')).toBe(
'releases/4.0.0/php56/codecept.phar'
);
expect(await tools.getCodeceptionUri('3.1.0', '7.4')).toBe(
'releases/3.1.0/codecept.phar'
);
expect(await tools.getCodeceptionUri('3.1.0', '5.6')).toBe(
'releases/3.1.0/php54/codecept.phar'
);
expect(await tools.getCodeceptionUri('2.5.4', '7.4')).toBe(
'releases/2.5.4/codecept.phar'
);
expect(await tools.getCodeceptionUri('2.5.4', '5.6')).toBe(
'releases/2.5.4/php54/codecept.phar'
);
expect(await tools.getCodeceptionUri('2.3.4', '7.4')).toBe(
'releases/2.3.4/codecept.phar'
);
expect(await tools.getCodeceptionUri('2.3.4', '5.4')).toBe(
'releases/2.3.4/php54/codecept.phar'
);
expect(await tools.getCodeceptionUri('2.2.4', '5.6')).toBe(
'releases/2.2.4/codecept.phar'
);
expect(await tools.getCodeceptionUri('2.2.4', '7.4')).toBe(
'releases/2.2.4/codecept.phar'
);
expect(await tools.getCodeceptionUri('2.2.4', '5.4')).toBe(
'releases/2.2.4/php54/codecept.phar'
);
expect(await tools.getCodeceptionUri('2.1.7', '5.6')).toBe(
'releases/2.1.7/codecept.phar'
);
expect(await tools.getCodeceptionUri('2.1.7', '5.4')).toBe(
'releases/2.1.7/php54/codecept.phar'
);
expect(await tools.getCodeceptionUri('2.1.5', '5.4')).toBe(
'releases/2.1.5/codecept.phar'
);
expect(await tools.getCodeceptionUri('2.1.5', '7.4')).toBe(
'releases/2.1.5/codecept.phar'
);
expect(await tools.getCodeceptionUri('1.6.9', '7.4')).toBe(
'releases/1.6.9/codecept.phar'
);
expect(await tools.getCodeceptionUri('1.5.0', '7.4')).toBe(
'releases/1.5.0/codecept.phar'
);
});

it('checking addPhive', async () => {
let script: string = await tools.addPhive('1.2.3', '7.4', 'linux');
expect(script).toContain(
Expand Down Expand Up @@ -581,7 +494,6 @@ describe('Tools tests', () => {
const listOfTools = [
'blackfire',
'blackfire-player:1.8.1',
'codeception',
'cs2pr',
'deployer',
'does_not_exist',
Expand Down Expand Up @@ -635,6 +547,7 @@ describe('Tools tests', () => {
it('checking addTools with composer tool using user/tool as input', async () => {
const listOfTools = [
'composer:v1',
'codeception/codeception',
'hirak/prestissimo',
'narrowspark/automatic-composer-prefetcher',
'robmorgan/phinx'
Expand Down
80 changes: 3 additions & 77 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1786,7 +1786,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.addTools = exports.addPackage = exports.addDevTools = exports.addArchive = exports.getCleanedToolsList = exports.getComposerUrl = exports.addComposer = exports.getWpCliUrl = exports.getSymfonyUri = exports.getDeployerUrl = exports.getBlackfirePlayerUrl = exports.getPharUrl = exports.addPhive = exports.getCodeceptionUri = exports.getCodeceptionUriBuilder = exports.getUri = exports.parseTool = exports.getToolVersion = void 0;
exports.addTools = exports.addPackage = exports.addDevTools = exports.addArchive = exports.getCleanedToolsList = exports.getComposerUrl = exports.addComposer = exports.getWpCliUrl = exports.getSymfonyUri = exports.getDeployerUrl = exports.getBlackfirePlayerUrl = exports.getPharUrl = exports.addPhive = exports.getUri = exports.parseTool = exports.getToolVersion = void 0;
const utils = __importStar(__webpack_require__(163));
/**
* Function to get tool version
Expand Down Expand Up @@ -1855,77 +1855,6 @@ async function getUri(tool, extension, version, prefix, version_prefix, verb) {
}
}
exports.getUri = getUri;
/**
* Helper function to get the codeception url
*
* @param version
* @param suffix
*/
async function getCodeceptionUriBuilder(version, suffix) {
return ['releases', version, suffix, 'codecept.phar']
.filter(Boolean)
.join('/');
}
exports.getCodeceptionUriBuilder = getCodeceptionUriBuilder;
/**
* Function to get the codeception url
*
* @param version
* @param php_version
*/
async function getCodeceptionUri(version, php_version) {
const codecept = await getCodeceptionUriBuilder(version, '');
const codecept54 = await getCodeceptionUriBuilder(version, 'php54');
const codecept56 = await getCodeceptionUriBuilder(version, 'php56');
// Refer to https://codeception.com/builds
switch (true) {
case /latest/.test(version):
switch (true) {
case /5\.6|7\.[0|1]/.test(php_version):
return 'php56/codecept.phar';
case /7\.[2-4]/.test(php_version):
default:
return 'codecept.phar';
}
case /(^[4-9]|\d{2,})\..*/.test(version):
switch (true) {
case /5\.6|7\.[0|1]/.test(php_version):
return codecept56;
case /7\.[2-4]/.test(php_version):
default:
return codecept;
}
case /(^2\.[4-5]\.\d+|^3\.[0-1]\.\d+).*/.test(version):
switch (true) {
case /5\.6/.test(php_version):
return codecept54;
case /7\.[0-4]/.test(php_version):
default:
return codecept;
}
case /^2\.3\.\d+.*/.test(version):
switch (true) {
case /5\.[4-6]/.test(php_version):
return codecept54;
case /^7\.[0-4]$/.test(php_version):
default:
return codecept;
}
case /(^2\.(1\.([6-9]|\d{2,}))|^2\.2\.\d+).*/.test(version):
switch (true) {
case /5\.[4-5]/.test(php_version):
return codecept54;
case /5.6|7\.[0-4]/.test(php_version):
default:
return codecept;
}
case /(^2\.(1\.[0-5]|0\.\d+)|^1\.[6-8]\.\d+).*/.test(version):
return codecept;
default:
return codecept;
}
}
exports.getCodeceptionUri = getCodeceptionUri;
/**
* Helper function to get script to setup phive
*
Expand Down Expand Up @@ -2102,7 +2031,7 @@ async function getCleanedToolsList(tools_csv) {
.map(function (extension) {
return extension
.trim()
.replace(/-agent|behat\/|hirak\/|icanhazstring\/|laravel\/|narrowspark\/automatic-|overtrue\/|phpspec\/|robmorgan\/|symfony\//, '');
.replace(/-agent|behat\/|codeception\/|hirak\/|icanhazstring\/|laravel\/|narrowspark\/automatic-|overtrue\/|phpspec\/|robmorgan\/|symfony\//, '');
})
.filter(Boolean);
return [...new Set(tools_list)];
Expand Down Expand Up @@ -2185,10 +2114,7 @@ async function addTools(tools_csv, php_version, os_version) {
script += await addArchive(tool, url, os_version, '"-V"');
break;
case 'codeception':
url =
'https://codeception.com/' +
(await getCodeceptionUri(version, php_version));
script += await addArchive(tool, url, os_version, '"-V"');
script += await addPackage(tool, release, 'codeception/', os_version);
break;
case 'composer':
url = await getComposerUrl(version);
Expand Down
Loading

0 comments on commit cff0bde

Please sign in to comment.