Refactor extensions.ts

This commit is contained in:
Shivam Mathur 2020-07-24 10:28:48 +05:30
parent e0561697dc
commit 0fae072f07
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A
5 changed files with 285 additions and 355 deletions

View File

@ -1,20 +1,6 @@
import * as extensions from '../src/extensions'; import * as extensions from '../src/extensions';
describe('Extension tests', () => { describe('Extension tests', () => {
it('checking getXdebugVersion', async () => {
expect(await extensions.getXdebugVersion('5.3')).toContain('2.2.7');
expect(await extensions.getXdebugVersion('5.4')).toContain('2.4.1');
expect(await extensions.getXdebugVersion('5.5')).toContain('2.5.5');
expect(await extensions.getXdebugVersion('5.6')).toContain('2.5.5');
expect(await extensions.getXdebugVersion('7.0')).toContain('2.7.2');
expect(await extensions.getXdebugVersion('7.2')).toContain('2.9.6');
});
it('checking getUnsupportedLog', async () => {
expect(await extensions.getUnsupportedLog('ext', '5.6', 'linux')).toContain(
'add_log "$cross" "ext" "ext is not supported on PHP 5.6"'
);
});
it('checking addExtensionOnWindows', async () => { it('checking addExtensionOnWindows', async () => {
let win32: string = await extensions.addExtension( let win32: string = await extensions.addExtension(
'Xdebug, pcov, sqlite, :intl, phalcon4, ioncube, oci8, pdo_oci, ast-beta, grpc-1.2.3, inotify-1.2.3alpha2', 'Xdebug, pcov, sqlite, :intl, phalcon4, ioncube, oci8, pdo_oci, ast-beta, grpc-1.2.3, inotify-1.2.3alpha2',

View File

@ -167,4 +167,23 @@ describe('Utils tests', () => {
'Platform fedora is not supported' 'Platform fedora is not supported'
); );
}); });
it('checking getXdebugVersion', async () => {
expect(await utils.getXdebugVersion('5.3')).toContain('2.2.7');
expect(await utils.getXdebugVersion('5.4')).toContain('2.4.1');
expect(await utils.getXdebugVersion('5.5')).toContain('2.5.5');
expect(await utils.getXdebugVersion('5.6')).toContain('2.5.5');
expect(await utils.getXdebugVersion('7.0')).toContain('2.7.2');
expect(await utils.getXdebugVersion('7.2')).toContain('2.9.6');
});
it('checking getUnsupportedLog', async () => {
expect(await utils.getUnsupportedLog('ext', '5.6', 'linux')).toContain(
'add_log "$cross" "ext" "ext is not supported on PHP 5.6"'
);
});
it('checking joins', async () => {
expect(await utils.joins('a', 'b', 'c')).toBe('a b c');
});
}); });

240
dist/index.js vendored
View File

@ -1314,7 +1314,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result; return result;
}; };
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.suppressOutput = exports.getExtensionPrefix = exports.CSVArray = exports.extensionArray = exports.writeScript = exports.readScript = exports.addLog = exports.stepLog = exports.log = exports.color = exports.asyncForEach = exports.getInput = void 0; exports.joins = exports.getUnsupportedLog = exports.getXdebugVersion = exports.suppressOutput = exports.getExtensionPrefix = exports.CSVArray = exports.extensionArray = exports.writeScript = exports.readScript = exports.addLog = exports.stepLog = exports.log = exports.color = exports.asyncForEach = exports.getInput = void 0;
const fs = __importStar(__webpack_require__(747)); const fs = __importStar(__webpack_require__(747));
const path = __importStar(__webpack_require__(622)); const path = __importStar(__webpack_require__(622));
const core = __importStar(__webpack_require__(470)); const core = __importStar(__webpack_require__(470));
@ -1529,6 +1529,49 @@ async function suppressOutput(os_version) {
} }
} }
exports.suppressOutput = suppressOutput; exports.suppressOutput = suppressOutput;
/**
* Function to get Xdebug version compatible with php versions.
*
* @param version
*/
async function getXdebugVersion(version) {
switch (version) {
case '5.3':
return '2.2.7';
case '5.4':
return '2.4.1';
case '5.5':
case '5.6':
return '2.5.5';
case '7.0':
return '2.7.2';
default:
return '2.9.6';
}
}
exports.getXdebugVersion = getXdebugVersion;
/**
* Function to get script to log unsupported extensions.
*
* @param extension
* @param version
* @param os_version
*/
async function getUnsupportedLog(extension, version, os_version) {
return ('\n' +
(await addLog('$cross', extension, [extension, 'is not supported on PHP', version].join(' '), os_version)) +
'\n');
}
exports.getUnsupportedLog = getUnsupportedLog;
/**
* Function to join strings with space
*
* @param str
*/
async function joins(...str) {
return [...str].join(' ');
}
exports.joins = joins;
/***/ }), /***/ }),
@ -3568,36 +3611,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result; return result;
}; };
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.addExtension = exports.addExtensionLinux = exports.addExtensionWindows = exports.addExtensionDarwin = exports.getUnsupportedLog = exports.getXdebugVersion = void 0; exports.addExtension = exports.addExtensionLinux = exports.addExtensionWindows = exports.addExtensionDarwin = void 0;
const path = __importStar(__webpack_require__(622)); const path = __importStar(__webpack_require__(622));
const utils = __importStar(__webpack_require__(163)); const utils = __importStar(__webpack_require__(163));
/**
* Function to get Xdebug version compatible with php versions
*
* @param version
*/
async function getXdebugVersion(version) {
switch (version) {
case '5.3':
return '2.2.7';
case '5.4':
return '2.4.1';
case '5.5':
case '5.6':
return '2.5.5';
case '7.0':
return '2.7.2';
default:
return '2.9.6';
}
}
exports.getXdebugVersion = getXdebugVersion;
async function getUnsupportedLog(extension, version, os_version) {
return ('\n' +
(await utils.addLog('$cross', extension, extension + ' is not supported on PHP ' + version, os_version)) +
'\n');
}
exports.getUnsupportedLog = getUnsupportedLog;
/** /**
* Install and enable extensions for darwin * Install and enable extensions for darwin
* *
@ -3623,42 +3639,23 @@ async function addExtensionDarwin(extension_csv, version, pipe) {
// match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire // match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire
// match 5.3blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0 // match 5.3blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0
case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension): case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension):
command = command = await utils.joins('\nbash', path.join(__dirname, '../src/scripts/ext/blackfire_darwin.sh'), version, extension);
'bash ' +
path.join(__dirname, '../src/scripts/ext/blackfire_darwin.sh') +
' ' +
version +
' ' +
extension;
break; break;
// match pre-release versions. For example - xdebug-beta // match pre-release versions. For example - xdebug-beta
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension): case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
add_script += add_script += await utils.joins('\nadd_unstable_extension', ext_name, ext_version, ext_prefix);
'\nadd_unstable_extension ' +
ext_name +
' ' +
ext_version +
' ' +
ext_prefix;
return; return;
// match semver // match semver
case /.*-\d+\.\d+\.\d+.*/.test(version_extension): case /.*-\d+\.\d+\.\d+.*/.test(version_extension):
add_script += add_script += await utils.joins('\nadd_pecl_extension', ext_name, ext_version, ext_prefix);
'\nadd_pecl_extension ' +
ext_name +
' ' +
ext_version +
' ' +
ext_prefix;
return; return;
// match 5.3xdebug...5.5xdebug
case /5\.[3-5]xdebug/.test(version_extension): case /5\.[3-5]xdebug/.test(version_extension):
command = command =
command_prefix + 'xdebug-' + (await getXdebugVersion(version)); command_prefix + 'xdebug-' + (await utils.getXdebugVersion(version));
break; break;
// match 5.3pcov to 7.0pcov // match 5.3pcov to 7.0pcov
case /(5\.[3-6]|7\.0)pcov/.test(version_extension): case /(5\.[3-6]|7\.0)pcov/.test(version_extension):
add_script += await getUnsupportedLog('pcov', version, 'darwin'); add_script += await utils.getUnsupportedLog('pcov', version, 'darwin');
return; return;
// match 5.6xdebug to 8.0xdebug, 5.6swoole to 8.0swoole // match 5.6xdebug to 8.0xdebug, 5.6swoole to 8.0swoole
// match 5.6grpc to 7.4grpc, 5.6protobuf to 7.4protobuf // match 5.6grpc to 7.4grpc, 5.6protobuf to 7.4protobuf
@ -3674,13 +3671,7 @@ async function addExtensionDarwin(extension_csv, version, pipe) {
break; break;
// match imagick // match imagick
case /^imagick$/.test(extension): case /^imagick$/.test(extension):
command = command = await utils.joins('brew install pkg-config imagemagick' + pipe, '&& ' + command_prefix + 'imagick' + pipe);
'brew install pkg-config imagemagick' +
pipe +
' && ' +
command_prefix +
'imagick' +
pipe;
break; break;
// match sqlite // match sqlite
case /^sqlite$/.test(extension): case /^sqlite$/.test(extension):
@ -3689,38 +3680,21 @@ async function addExtensionDarwin(extension_csv, version, pipe) {
break; break;
// match pdo_oci and oci8 // match pdo_oci and oci8
case /^pdo_oci$|^oci8$/.test(extension): case /^pdo_oci$|^oci8$/.test(extension):
add_script += add_script += await utils.joins('\nbash ', path.join(__dirname, '../src/scripts/ext/oci.sh'), extension, version);
'\nbash ' +
path.join(__dirname, '../src/scripts/ext/oci.sh') +
' ' +
extension +
' ' +
version;
return; return;
// match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube // match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube
case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension): case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension):
add_script += add_script += await utils.joins('\nbash ', path.join(__dirname, '../src/scripts/ext/ioncube.sh'), version);
'\nbash ' +
path.join(__dirname, '../src/scripts/ext/ioncube.sh') +
' ' +
version;
return; return;
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4 // match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
add_script += add_script += await utils.joins('\nbash ', path.join(__dirname, '../src/scripts/ext/phalcon_darwin.sh'), extension, version);
'\nbash ' +
path.join(__dirname, '../src/scripts/ext/phalcon_darwin.sh') +
' ' +
extension +
' ' +
version;
return; return;
default: default:
command = command_prefix + extension; command = command_prefix + extension;
break; break;
} }
add_script += add_script += await utils.joins('\nadd_extension', extension, '"' + command + '"', ext_prefix);
'\nadd_extension ' + extension + ' "' + command + '" ' + ext_prefix;
}); });
return add_script + remove_script; return add_script + remove_script;
} }
@ -3747,31 +3721,24 @@ async function addExtensionWindows(extension_csv, version) {
// match 5.4blackfire...5.6blackfire, 7.0blackfire...7.4blackfire // match 5.4blackfire...5.6blackfire, 7.0blackfire...7.4blackfire
// match 5.4blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0 // match 5.4blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0
case /^(5\.[4-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension): case /^(5\.[4-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension):
add_script += add_script += await utils.joins('\n& ', path.join(__dirname, '../src/scripts/ext/blackfire.ps1'), version, extension);
'\n& ' +
path.join(__dirname, '../src/scripts/ext/blackfire.ps1') +
' ' +
version +
' ' +
extension;
return; return;
// match pre-release versions. For example - xdebug-beta // match pre-release versions. For example - xdebug-beta
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension): case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
add_script += '\nAdd-Extension ' + ext_name + ' ' + ext_version; add_script += await utils.joins('\nAdd-Extension', ext_name, ext_version);
break; break;
// match semver without state // match semver without state
case /.*-\d+\.\d+\.\d+$/.test(version_extension): case /.*-\d+\.\d+\.\d+$/.test(version_extension):
add_script += '\nAdd-Extension ' + ext_name + ' stable ' + ext_version; add_script += await utils.joins('\nAdd-Extension', ext_name, 'stable', ext_version);
return; return;
// match semver with state // match semver with state
case /.*-(\d+\.\d+\.\d)(beta|alpha|devel|snapshot)\d*/.test(version_extension): case /.*-(\d+\.\d+\.\d)(beta|alpha|devel|snapshot)\d*/.test(version_extension):
matches = /.*-(\d+\.\d+\.\d)(beta|alpha|devel|snapshot)\d*/.exec(version_extension); matches = /.*-(\d+\.\d+\.\d)(beta|alpha|devel|snapshot)\d*/.exec(version_extension);
add_script += add_script += await utils.joins('\nAdd-Extension', ext_name, matches[2], matches[1]);
'\nAdd-Extension ' + ext_name + ' ' + matches[2] + ' ' + matches[1];
return; return;
// match 5.3pcov to 7.0pcov // match 5.3pcov to 7.0pcov
case /(5\.[3-6]|7\.0)pcov/.test(version_extension): case /(5\.[3-6]|7\.0)pcov/.test(version_extension):
add_script += await getUnsupportedLog('pcov', version, 'win32'); add_script += await utils.getUnsupportedLog('pcov', version, 'win32');
break; break;
// match 5.3mysql..5.6mysql // match 5.3mysql..5.6mysql
// match 5.3mysqli..5.6mysqli // match 5.3mysqli..5.6mysqli
@ -3789,38 +3756,19 @@ async function addExtensionWindows(extension_csv, version) {
// match sqlite // match sqlite
case /^sqlite$/.test(extension): case /^sqlite$/.test(extension):
extension = 'sqlite3'; extension = 'sqlite3';
add_script += '\nAdd-Extension ' + extension; add_script += await utils.joins('\nAdd-Extension', extension);
break; break;
// match pdo_oci and oci8 // match pdo_oci and oci8
case /^pdo_oci$|^oci8$/.test(extension): case /^pdo_oci$|^oci8$/.test(extension):
add_script += add_script += await utils.joins('\n& ', path.join(__dirname, '../src/scripts/ext/oci.ps1'), extension, version);
'\n& ' +
path.join(__dirname, '../src/scripts/ext/oci.ps1') +
' ' +
extension +
' ' +
version +
'\n';
break; break;
// match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube // match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube
case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension): case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension):
add_script += add_script += await utils.joins('\n& ', path.join(__dirname, '../src/scripts/ext/ioncube.ps1'), version);
'\n& ' +
path.join(__dirname, '../src/scripts/ext/ioncube.ps1') +
' ' +
version +
'\n';
break; break;
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4 // match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
add_script += add_script += await utils.joins('\n& ', path.join(__dirname, '../src/scripts/ext/phalcon.ps1'), extension, version);
'\n& ' +
path.join(__dirname, '../src/scripts/ext/phalcon.ps1') +
' ' +
extension +
' ' +
version +
'\n';
break; break;
default: default:
add_script += '\nAdd-Extension ' + extension; add_script += '\nAdd-Extension ' + extension;
@ -3855,74 +3803,35 @@ async function addExtensionLinux(extension_csv, version, pipe) {
// match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire // match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire
// match 5.3blackfire-{semver}...5.6blackfire-{semver}, 7.0blackfire-{semver}...7.4blackfire-{semver} // match 5.3blackfire-{semver}...5.6blackfire-{semver}, 7.0blackfire-{semver}...7.4blackfire-{semver}
case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension): case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension):
command = command = await utils.joins('\nbash', path.join(__dirname, '../src/scripts/ext/blackfire.sh'), version, extension);
'bash ' +
path.join(__dirname, '../src/scripts/ext/blackfire.sh') +
' ' +
version +
' ' +
extension;
break; break;
// match pre-release versions. For example - xdebug-beta // match pre-release versions. For example - xdebug-beta
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension): case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
add_script += add_script += await utils.joins('\nadd_unstable_extension', ext_name, ext_version, ext_prefix);
'\nadd_unstable_extension ' +
ext_name +
' ' +
ext_version +
' ' +
ext_prefix;
return; return;
// match semver versions // match semver versions
case /.*-\d+\.\d+\.\d+.*/.test(version_extension): case /.*-\d+\.\d+\.\d+.*/.test(version_extension):
add_script += add_script += await utils.joins('\nadd_pecl_extension', ext_name, ext_version, ext_prefix);
'\nadd_pecl_extension ' +
ext_name +
' ' +
ext_version +
' ' +
ext_prefix;
return; return;
// match 5.3pcov to 7.0pcov // match 5.3pcov to 7.0pcov
case /(5\.[3-6]|7\.0)pcov/.test(version_extension): case /(5\.[3-6]|7\.0)pcov/.test(version_extension):
add_script += await getUnsupportedLog('pcov', version, 'linux'); add_script += await utils.getUnsupportedLog('pcov', version, 'linux');
return; return;
// match 5.6gearman..7.4gearman // match 5.6gearman..7.4gearman
case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension): case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension):
command = command = await utils.joins('\nbash', path.join(__dirname, '../src/scripts/ext/gearman.sh'), version, pipe);
'\nbash ' +
path.join(__dirname, '../src/scripts/ext/gearman.sh') +
' ' +
version +
pipe;
break; break;
// match pdo_oci and oci8 // match pdo_oci and oci8
case /^pdo_oci$|^oci8$/.test(extension): case /^pdo_oci$|^oci8$/.test(extension):
add_script += add_script += await utils.joins('\nbash', path.join(__dirname, '../src/scripts/ext/oci.sh'), extension, version);
'\nbash ' +
path.join(__dirname, '../src/scripts/ext/oci.sh') +
' ' +
extension +
' ' +
version;
return; return;
// match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube // match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube
case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension): case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension):
add_script += add_script += await utils.joins('\nbash', path.join(__dirname, '../src/scripts/ext/ioncube.sh'), version);
'\nbash ' +
path.join(__dirname, '../src/scripts/ext/ioncube.sh') +
' ' +
version;
return; return;
// match 7.0phalcon3...7.3phalcon3 or 7.2phalcon4...7.4phalcon4 // match 7.0phalcon3...7.3phalcon3 or 7.2phalcon4...7.4phalcon4
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
add_script += add_script += await utils.joins('\nbash', path.join(__dirname, '../src/scripts/ext/phalcon.sh'), extension, version);
'\nbash ' +
path.join(__dirname, '../src/scripts/ext/phalcon.sh') +
' ' +
extension +
' ' +
version;
return; return;
// match 7.2xdebug3..7.4xdebug3 // match 7.2xdebug3..7.4xdebug3
case /^7\.[2-4]xdebug3$/.test(version_extension): case /^7\.[2-4]xdebug3$/.test(version_extension):
@ -3935,7 +3844,7 @@ async function addExtensionLinux(extension_csv, version, pipe) {
command = command_prefix + version + '-' + extension + pipe; command = command_prefix + version + '-' + extension + pipe;
break; break;
// match pdo extensions // match pdo extensions
case /.*pdo[_-].*/.test(version_extension): case /.*pdo[_st-].*/.test(version_extension):
extension = extension extension = extension
.replace('pdo_', '') .replace('pdo_', '')
.replace('pdo-', '') .replace('pdo-', '')
@ -3955,8 +3864,7 @@ async function addExtensionLinux(extension_csv, version, pipe) {
command = command_prefix + version + '-' + extension + pipe; command = command_prefix + version + '-' + extension + pipe;
break; break;
} }
add_script += add_script += await utils.joins('\nadd_extension', extension, '"' + command + '"', ext_prefix);
'\nadd_extension ' + extension + ' "' + command + '" ' + ext_prefix;
}); });
return add_script + remove_script; return add_script + remove_script;
} }

View File

@ -1,44 +1,6 @@
import * as path from 'path'; import * as path from 'path';
import * as utils from './utils'; import * as utils from './utils';
/**
* Function to get Xdebug version compatible with php versions
*
* @param version
*/
export async function getXdebugVersion(version: string): Promise<string> {
switch (version) {
case '5.3':
return '2.2.7';
case '5.4':
return '2.4.1';
case '5.5':
case '5.6':
return '2.5.5';
case '7.0':
return '2.7.2';
default:
return '2.9.6';
}
}
export async function getUnsupportedLog(
extension: string,
version: string,
os_version: string
): Promise<string> {
return (
'\n' +
(await utils.addLog(
'$cross',
extension,
extension + ' is not supported on PHP ' + version,
os_version
)) +
'\n'
);
}
/** /**
* Install and enable extensions for darwin * Install and enable extensions for darwin
* *
@ -70,42 +32,38 @@ export async function addExtensionDarwin(
case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test( case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(
version_extension version_extension
): ):
command = command = await utils.joins(
'bash ' + '\nbash',
path.join(__dirname, '../src/scripts/ext/blackfire_darwin.sh') + path.join(__dirname, '../src/scripts/ext/blackfire_darwin.sh'),
' ' + version,
version + extension
' ' + );
extension;
break; break;
// match pre-release versions. For example - xdebug-beta // match pre-release versions. For example - xdebug-beta
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension): case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
add_script += add_script += await utils.joins(
'\nadd_unstable_extension ' + '\nadd_unstable_extension',
ext_name + ext_name,
' ' + ext_version,
ext_version + ext_prefix
' ' + );
ext_prefix;
return; return;
// match semver // match semver
case /.*-\d+\.\d+\.\d+.*/.test(version_extension): case /.*-\d+\.\d+\.\d+.*/.test(version_extension):
add_script += add_script += await utils.joins(
'\nadd_pecl_extension ' + '\nadd_pecl_extension',
ext_name + ext_name,
' ' + ext_version,
ext_version + ext_prefix
' ' + );
ext_prefix;
return; return;
// match 5.3xdebug...5.5xdebug
case /5\.[3-5]xdebug/.test(version_extension): case /5\.[3-5]xdebug/.test(version_extension):
command = command =
command_prefix + 'xdebug-' + (await getXdebugVersion(version)); command_prefix + 'xdebug-' + (await utils.getXdebugVersion(version));
break; break;
// match 5.3pcov to 7.0pcov // match 5.3pcov to 7.0pcov
case /(5\.[3-6]|7\.0)pcov/.test(version_extension): case /(5\.[3-6]|7\.0)pcov/.test(version_extension):
add_script += await getUnsupportedLog('pcov', version, 'darwin'); add_script += await utils.getUnsupportedLog('pcov', version, 'darwin');
return; return;
// match 5.6xdebug to 8.0xdebug, 5.6swoole to 8.0swoole // match 5.6xdebug to 8.0xdebug, 5.6swoole to 8.0swoole
// match 5.6grpc to 7.4grpc, 5.6protobuf to 7.4protobuf // match 5.6grpc to 7.4grpc, 5.6protobuf to 7.4protobuf
@ -121,13 +79,10 @@ export async function addExtensionDarwin(
break; break;
// match imagick // match imagick
case /^imagick$/.test(extension): case /^imagick$/.test(extension):
command = command = await utils.joins(
'brew install pkg-config imagemagick' + 'brew install pkg-config imagemagick' + pipe,
pipe + '&& ' + command_prefix + 'imagick' + pipe
' && ' + );
command_prefix +
'imagick' +
pipe;
break; break;
// match sqlite // match sqlite
case /^sqlite$/.test(extension): case /^sqlite$/.test(extension):
@ -136,38 +91,40 @@ export async function addExtensionDarwin(
break; break;
// match pdo_oci and oci8 // match pdo_oci and oci8
case /^pdo_oci$|^oci8$/.test(extension): case /^pdo_oci$|^oci8$/.test(extension):
add_script += add_script += await utils.joins(
'\nbash ' + '\nbash ',
path.join(__dirname, '../src/scripts/ext/oci.sh') + path.join(__dirname, '../src/scripts/ext/oci.sh'),
' ' + extension,
extension + version
' ' + );
version;
return; return;
// match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube // match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube
case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension): case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension):
add_script += add_script += await utils.joins(
'\nbash ' + '\nbash ',
path.join(__dirname, '../src/scripts/ext/ioncube.sh') + path.join(__dirname, '../src/scripts/ext/ioncube.sh'),
' ' + version
version; );
return; return;
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4 // match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
add_script += add_script += await utils.joins(
'\nbash ' + '\nbash ',
path.join(__dirname, '../src/scripts/ext/phalcon_darwin.sh') + path.join(__dirname, '../src/scripts/ext/phalcon_darwin.sh'),
' ' + extension,
extension + version
' ' + );
version;
return; return;
default: default:
command = command_prefix + extension; command = command_prefix + extension;
break; break;
} }
add_script += add_script += await utils.joins(
'\nadd_extension ' + extension + ' "' + command + '" ' + ext_prefix; '\nadd_extension',
extension,
'"' + command + '"',
ext_prefix
);
}); });
return add_script + remove_script; return add_script + remove_script;
} }
@ -199,21 +156,29 @@ export async function addExtensionWindows(
case /^(5\.[4-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test( case /^(5\.[4-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(
version_extension version_extension
): ):
add_script += add_script += await utils.joins(
'\n& ' + '\n& ',
path.join(__dirname, '../src/scripts/ext/blackfire.ps1') + path.join(__dirname, '../src/scripts/ext/blackfire.ps1'),
' ' + version,
version + extension
' ' + );
extension;
return; return;
// match pre-release versions. For example - xdebug-beta // match pre-release versions. For example - xdebug-beta
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension): case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
add_script += '\nAdd-Extension ' + ext_name + ' ' + ext_version; add_script += await utils.joins(
'\nAdd-Extension',
ext_name,
ext_version
);
break; break;
// match semver without state // match semver without state
case /.*-\d+\.\d+\.\d+$/.test(version_extension): case /.*-\d+\.\d+\.\d+$/.test(version_extension):
add_script += '\nAdd-Extension ' + ext_name + ' stable ' + ext_version; add_script += await utils.joins(
'\nAdd-Extension',
ext_name,
'stable',
ext_version
);
return; return;
// match semver with state // match semver with state
case /.*-(\d+\.\d+\.\d)(beta|alpha|devel|snapshot)\d*/.test( case /.*-(\d+\.\d+\.\d)(beta|alpha|devel|snapshot)\d*/.test(
@ -222,12 +187,16 @@ export async function addExtensionWindows(
matches = /.*-(\d+\.\d+\.\d)(beta|alpha|devel|snapshot)\d*/.exec( matches = /.*-(\d+\.\d+\.\d)(beta|alpha|devel|snapshot)\d*/.exec(
version_extension version_extension
) as RegExpExecArray; ) as RegExpExecArray;
add_script += add_script += await utils.joins(
'\nAdd-Extension ' + ext_name + ' ' + matches[2] + ' ' + matches[1]; '\nAdd-Extension',
ext_name,
matches[2],
matches[1]
);
return; return;
// match 5.3pcov to 7.0pcov // match 5.3pcov to 7.0pcov
case /(5\.[3-6]|7\.0)pcov/.test(version_extension): case /(5\.[3-6]|7\.0)pcov/.test(version_extension):
add_script += await getUnsupportedLog('pcov', version, 'win32'); add_script += await utils.getUnsupportedLog('pcov', version, 'win32');
break; break;
// match 5.3mysql..5.6mysql // match 5.3mysql..5.6mysql
// match 5.3mysqli..5.6mysqli // match 5.3mysqli..5.6mysqli
@ -245,38 +214,33 @@ export async function addExtensionWindows(
// match sqlite // match sqlite
case /^sqlite$/.test(extension): case /^sqlite$/.test(extension):
extension = 'sqlite3'; extension = 'sqlite3';
add_script += '\nAdd-Extension ' + extension; add_script += await utils.joins('\nAdd-Extension', extension);
break; break;
// match pdo_oci and oci8 // match pdo_oci and oci8
case /^pdo_oci$|^oci8$/.test(extension): case /^pdo_oci$|^oci8$/.test(extension):
add_script += add_script += await utils.joins(
'\n& ' + '\n& ',
path.join(__dirname, '../src/scripts/ext/oci.ps1') + path.join(__dirname, '../src/scripts/ext/oci.ps1'),
' ' + extension,
extension + version
' ' + );
version +
'\n';
break; break;
// match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube // match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube
case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension): case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension):
add_script += add_script += await utils.joins(
'\n& ' + '\n& ',
path.join(__dirname, '../src/scripts/ext/ioncube.ps1') + path.join(__dirname, '../src/scripts/ext/ioncube.ps1'),
' ' + version
version + );
'\n';
break; break;
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4 // match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
add_script += add_script += await utils.joins(
'\n& ' + '\n& ',
path.join(__dirname, '../src/scripts/ext/phalcon.ps1') + path.join(__dirname, '../src/scripts/ext/phalcon.ps1'),
' ' + extension,
extension + version
' ' + );
version +
'\n';
break; break;
default: default:
add_script += '\nAdd-Extension ' + extension; add_script += '\nAdd-Extension ' + extension;
@ -317,74 +281,69 @@ export async function addExtensionLinux(
case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test( case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(
version_extension version_extension
): ):
command = command = await utils.joins(
'bash ' + '\nbash',
path.join(__dirname, '../src/scripts/ext/blackfire.sh') + path.join(__dirname, '../src/scripts/ext/blackfire.sh'),
' ' + version,
version + extension
' ' + );
extension;
break; break;
// match pre-release versions. For example - xdebug-beta // match pre-release versions. For example - xdebug-beta
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension): case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
add_script += add_script += await utils.joins(
'\nadd_unstable_extension ' + '\nadd_unstable_extension',
ext_name + ext_name,
' ' + ext_version,
ext_version + ext_prefix
' ' + );
ext_prefix;
return; return;
// match semver versions // match semver versions
case /.*-\d+\.\d+\.\d+.*/.test(version_extension): case /.*-\d+\.\d+\.\d+.*/.test(version_extension):
add_script += add_script += await utils.joins(
'\nadd_pecl_extension ' + '\nadd_pecl_extension',
ext_name + ext_name,
' ' + ext_version,
ext_version + ext_prefix
' ' + );
ext_prefix;
return; return;
// match 5.3pcov to 7.0pcov // match 5.3pcov to 7.0pcov
case /(5\.[3-6]|7\.0)pcov/.test(version_extension): case /(5\.[3-6]|7\.0)pcov/.test(version_extension):
add_script += await getUnsupportedLog('pcov', version, 'linux'); add_script += await utils.getUnsupportedLog('pcov', version, 'linux');
return; return;
// match 5.6gearman..7.4gearman // match 5.6gearman..7.4gearman
case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension): case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension):
command = command = await utils.joins(
'\nbash ' + '\nbash',
path.join(__dirname, '../src/scripts/ext/gearman.sh') + path.join(__dirname, '../src/scripts/ext/gearman.sh'),
' ' + version,
version + pipe
pipe; );
break; break;
// match pdo_oci and oci8 // match pdo_oci and oci8
case /^pdo_oci$|^oci8$/.test(extension): case /^pdo_oci$|^oci8$/.test(extension):
add_script += add_script += await utils.joins(
'\nbash ' + '\nbash',
path.join(__dirname, '../src/scripts/ext/oci.sh') + path.join(__dirname, '../src/scripts/ext/oci.sh'),
' ' + extension,
extension + version
' ' + );
version;
return; return;
// match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube // match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube
case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension): case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension):
add_script += add_script += await utils.joins(
'\nbash ' + '\nbash',
path.join(__dirname, '../src/scripts/ext/ioncube.sh') + path.join(__dirname, '../src/scripts/ext/ioncube.sh'),
' ' + version
version; );
return; return;
// match 7.0phalcon3...7.3phalcon3 or 7.2phalcon4...7.4phalcon4 // match 7.0phalcon3...7.3phalcon3 or 7.2phalcon4...7.4phalcon4
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
add_script += add_script += await utils.joins(
'\nbash ' + '\nbash',
path.join(__dirname, '../src/scripts/ext/phalcon.sh') + path.join(__dirname, '../src/scripts/ext/phalcon.sh'),
' ' + extension,
extension + version
' ' + );
version;
return; return;
// match 7.2xdebug3..7.4xdebug3 // match 7.2xdebug3..7.4xdebug3
case /^7\.[2-4]xdebug3$/.test(version_extension): case /^7\.[2-4]xdebug3$/.test(version_extension):
@ -397,7 +356,7 @@ export async function addExtensionLinux(
command = command_prefix + version + '-' + extension + pipe; command = command_prefix + version + '-' + extension + pipe;
break; break;
// match pdo extensions // match pdo extensions
case /.*pdo[_-].*/.test(version_extension): case /.*pdo[_st-].*/.test(version_extension):
extension = extension extension = extension
.replace('pdo_', '') .replace('pdo_', '')
.replace('pdo-', '') .replace('pdo-', '')
@ -417,8 +376,12 @@ export async function addExtensionLinux(
command = command_prefix + version + '-' + extension + pipe; command = command_prefix + version + '-' + extension + pipe;
break; break;
} }
add_script += add_script += await utils.joins(
'\nadd_extension ' + extension + ' "' + command + '" ' + ext_prefix; '\nadd_extension',
extension,
'"' + command + '"',
ext_prefix
);
}); });
return add_script + remove_script; return add_script + remove_script;
} }

View File

@ -259,3 +259,57 @@ export async function suppressOutput(os_version: string): Promise<string> {
); );
} }
} }
/**
* Function to get Xdebug version compatible with php versions.
*
* @param version
*/
export async function getXdebugVersion(version: string): Promise<string> {
switch (version) {
case '5.3':
return '2.2.7';
case '5.4':
return '2.4.1';
case '5.5':
case '5.6':
return '2.5.5';
case '7.0':
return '2.7.2';
default:
return '2.9.6';
}
}
/**
* Function to get script to log unsupported extensions.
*
* @param extension
* @param version
* @param os_version
*/
export async function getUnsupportedLog(
extension: string,
version: string,
os_version: string
): Promise<string> {
return (
'\n' +
(await addLog(
'$cross',
extension,
[extension, 'is not supported on PHP', version].join(' '),
os_version
)) +
'\n'
);
}
/**
* Function to join strings with space
*
* @param str
*/
export async function joins(...str: string[]): Promise<string> {
return [...str].join(' ');
}