Improve extension support

This commit is contained in:
Shivam Mathur 2020-03-12 04:47:52 +05:30
parent a5e5d07fcb
commit 2937ad6e7a
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A
4 changed files with 155 additions and 102 deletions

View File

@ -3,12 +3,13 @@ import * as extensions from '../src/extensions';
describe('Extension tests', () => { describe('Extension tests', () => {
it('checking addExtensionOnWindows', async () => { it('checking addExtensionOnWindows', async () => {
let win32: string = await extensions.addExtension( let win32: string = await extensions.addExtension(
'xdebug, pcov, phalcon4, ast-beta, grpc-1.2.3, inotify-1.2.3alpha2', 'Xdebug, pcov, sqlite, phalcon4, ast-beta, grpc-1.2.3, inotify-1.2.3alpha2',
'7.4', '7.4',
'win32' 'win32'
); );
expect(win32).toContain('Add-Extension xdebug'); expect(win32).toContain('Add-Extension xdebug');
expect(win32).toContain('Add-Extension pcov'); expect(win32).toContain('Add-Extension pcov');
expect(win32).toContain('Add-Extension sqlite3');
expect(win32).toContain('phalcon.ps1 phalcon4'); expect(win32).toContain('phalcon.ps1 phalcon4');
expect(win32).toContain('Add-Extension ast beta'); expect(win32).toContain('Add-Extension ast beta');
expect(win32).toContain('Add-Extension grpc stable 1.2.3'); expect(win32).toContain('Add-Extension grpc stable 1.2.3');
@ -35,12 +36,15 @@ describe('Extension tests', () => {
it('checking addExtensionOnLinux', async () => { it('checking addExtensionOnLinux', async () => {
let linux: string = await extensions.addExtension( let linux: string = await extensions.addExtension(
'xdebug, pcov, ast-beta, pdo_mysql, pdo-odbc, xdebug-alpha, grpc-1.2.3', 'Xdebug, pcov, sqlite, ast-beta, pdo_mysql, pdo-odbc, xdebug-alpha, grpc-1.2.3',
'7.4', '7.4',
'linux' 'linux'
); );
expect(linux).toContain('update_extension xdebug 2.9.1'); expect(linux).toContain('update_extension xdebug 2.9.2');
expect(linux).toContain('sudo $debconf_fix apt-get install -y php7.4-pcov'); expect(linux).toContain('sudo $debconf_fix apt-get install -y php7.4-pcov');
expect(linux).toContain(
'sudo $debconf_fix apt-get install -y php7.4-sqlite3'
);
expect(linux).toContain('add_unstable_extension ast beta extension'); expect(linux).toContain('add_unstable_extension ast beta extension');
expect(linux).toContain('add_pdo_extension mysql'); expect(linux).toContain('add_pdo_extension mysql');
expect(linux).toContain('add_pdo_extension odbc'); expect(linux).toContain('add_pdo_extension odbc');
@ -79,12 +83,13 @@ describe('Extension tests', () => {
it('checking addExtensionOnDarwin', async () => { it('checking addExtensionOnDarwin', async () => {
let darwin: string = await extensions.addExtension( let darwin: string = await extensions.addExtension(
'xdebug, pcov, ast-beta, grpc-1.2.3', 'Xdebug, pcov, sqlite, ast-beta, grpc-1.2.3',
'7.2', '7.2',
'darwin' 'darwin'
); );
expect(darwin).toContain('sudo pecl install -f xdebug'); expect(darwin).toContain('sudo pecl install -f xdebug');
expect(darwin).toContain('sudo pecl install -f pcov'); expect(darwin).toContain('sudo pecl install -f pcov');
expect(darwin).toContain('sudo pecl install -f sqlite3');
expect(darwin).toContain('add_unstable_extension ast beta extension'); expect(darwin).toContain('add_unstable_extension ast beta extension');
expect(darwin).toContain('add_pecl_extension grpc 1.2.3 extension'); expect(darwin).toContain('add_pecl_extension grpc 1.2.3 extension');

122
dist/index.js vendored
View File

@ -1178,6 +1178,7 @@ function extensionArray(extension_csv) {
.map(function (extension) { .map(function (extension) {
return extension return extension
.trim() .trim()
.toLowerCase()
.replace('php-', '') .replace('php-', '')
.replace('php_', ''); .replace('php_', '');
}) })
@ -2702,16 +2703,16 @@ function addExtensionDarwin(extension_csv, version, pipe) {
let script = '\n'; let script = '\n';
yield utils.asyncForEach(extensions, function (extension) { yield utils.asyncForEach(extensions, function (extension) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
extension = extension.toLowerCase();
const version_extension = version + extension; const version_extension = version + extension;
const [ext_name, ext_version] = extension.split('-'); const [ext_name, ext_version] = extension.split('-');
const prefix = yield utils.getExtensionPrefix(ext_name); const ext_prefix = yield utils.getExtensionPrefix(ext_name);
let install_command = ''; const command_prefix = 'sudo pecl install -f ';
let command = '';
switch (true) { switch (true) {
// 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):
install_command = command =
'bash ' + 'bash ' +
path.join(__dirname, '../src/scripts/ext/blackfire_darwin.sh') + path.join(__dirname, '../src/scripts/ext/blackfire_darwin.sh') +
' ' + ' ' +
@ -2719,7 +2720,7 @@ function addExtensionDarwin(extension_csv, version, pipe) {
' ' + ' ' +
(yield utils.getBlackfireVersion(ext_version)); (yield utils.getBlackfireVersion(ext_version));
break; break;
// match pre-release versions // match pre-release versions. For example - xdebug-beta
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension): case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
script += script +=
'\nadd_unstable_extension ' + '\nadd_unstable_extension ' +
@ -2727,35 +2728,54 @@ function addExtensionDarwin(extension_csv, version, pipe) {
' ' + ' ' +
ext_version + ext_version +
' ' + ' ' +
prefix; ext_prefix;
return; return;
// match exact versions // match semver
case /.*-\d+\.\d+\.\d+.*/.test(version_extension): case /.*-\d+\.\d+\.\d+.*/.test(version_extension):
script += script +=
'\nadd_pecl_extension ' + ext_name + ' ' + ext_version + ' ' + prefix; '\nadd_pecl_extension ' +
ext_name +
' ' +
ext_version +
' ' +
ext_prefix;
return; return;
// match 5.3xdebug
case /5\.3xdebug/.test(version_extension): case /5\.3xdebug/.test(version_extension):
install_command = 'sudo pecl install -f xdebug-2.2.7' + pipe; command = command_prefix + 'xdebug-2.2.7' + pipe;
break; break;
// match 5.4xdebug
case /5\.4xdebug/.test(version_extension): case /5\.4xdebug/.test(version_extension):
install_command = 'sudo pecl install -f xdebug-2.4.1' + pipe; command = command_prefix + 'xdebug-2.4.1' + pipe;
break; break;
// match 5.5xdebug and 5.6xdebug
case /5\.[5-6]xdebug/.test(version_extension): case /5\.[5-6]xdebug/.test(version_extension):
install_command = 'sudo pecl install -f xdebug-2.5.5' + pipe; command = command_prefix + 'xdebug-2.5.5' + pipe;
break; break;
// match 7.0redis
case /7\.0xdebug/.test(version_extension): case /7\.0xdebug/.test(version_extension):
install_command = 'sudo pecl install -f xdebug-2.9.0' + pipe; command = command_prefix + 'xdebug-2.9.0' + pipe;
break; break;
// match 5.6redis
case /5\.6redis/.test(version_extension): case /5\.6redis/.test(version_extension):
install_command = 'sudo pecl install -f redis-2.2.8' + pipe; command = command_prefix + 'redis-2.2.8' + pipe;
break; break;
case /[5-9]\.\dimagick/.test(version_extension): // match imagick
install_command = case /imagick/.test(extension):
command =
'brew install pkg-config imagemagick' + 'brew install pkg-config imagemagick' +
pipe + pipe +
' && sudo pecl install -f imagick' + ' && ' +
command_prefix +
'imagick' +
pipe; pipe;
break; break;
// match sqlite
case /sqlite/.test(extension):
extension = 'sqlite3';
command = command_prefix + extension + pipe;
break;
// 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):
script += script +=
'sh ' + 'sh ' +
@ -2766,16 +2786,11 @@ function addExtensionDarwin(extension_csv, version, pipe) {
version; version;
return; return;
default: default:
install_command = 'sudo pecl install -f ' + extension + pipe; command = command_prefix + extension + pipe;
break; break;
} }
script += script +=
'\nadd_extension ' + '\nadd_extension ' + extension + ' "' + command + '" ' + ext_prefix;
extension +
' "' +
install_command +
'" ' +
(yield utils.getExtensionPrefix(extension));
}); });
}); });
return script; return script;
@ -2795,7 +2810,6 @@ function addExtensionWindows(extension_csv, version, pipe) {
let script = '\n'; let script = '\n';
yield utils.asyncForEach(extensions, function (extension) { yield utils.asyncForEach(extensions, function (extension) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
extension = extension.toLowerCase();
const [ext_name, ext_version] = extension.split('-'); const [ext_name, ext_version] = extension.split('-');
const version_extension = version + extension; const version_extension = version + extension;
let matches; let matches;
@ -2811,19 +2825,25 @@ function addExtensionWindows(extension_csv, version, pipe) {
' ' + ' ' +
(yield utils.getBlackfireVersion(ext_version)); (yield utils.getBlackfireVersion(ext_version));
return; return;
// match pre-release versions // match pre-release versions. For example - xdebug-beta
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension): case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
script += '\nAdd-Extension ' + ext_name + ' ' + ext_version; script += '\nAdd-Extension ' + ext_name + ' ' + ext_version;
break; break;
// match exact versions // match semver without state
case /.*-\d+\.\d+\.\d+$/.test(version_extension): case /.*-\d+\.\d+\.\d+$/.test(version_extension):
script += '\nAdd-Extension ' + ext_name + ' stable ' + ext_version; script += '\nAdd-Extension ' + ext_name + ' stable ' + ext_version;
return; return;
case /.*-(\d+\.\d+\.\d)+(beta|alpha|devel|snapshot)\d*/.test(version_extension): // match semver with state
matches = /.*-(\d+\.\d+\.\d)+(beta|alpha|devel|snapshot)\d*/.exec(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);
script += script +=
'\nAdd-Extension ' + ext_name + ' ' + matches[2] + ' ' + matches[1]; '\nAdd-Extension ' + ext_name + ' ' + matches[2] + ' ' + matches[1];
return; return;
// match sqlite
case /sqlite/.test(extension):
extension = 'sqlite3';
script += '\nAdd-Extension ' + extension;
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):
script += script +=
@ -2858,16 +2878,16 @@ function addExtensionLinux(extension_csv, version, pipe) {
let script = '\n'; let script = '\n';
yield utils.asyncForEach(extensions, function (extension) { yield utils.asyncForEach(extensions, function (extension) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
extension = extension.toLowerCase();
const version_extension = version + extension; const version_extension = version + extension;
const [ext_name, ext_version] = extension.split('-'); const [ext_name, ext_version] = extension.split('-');
const prefix = yield utils.getExtensionPrefix(ext_name); const ext_prefix = yield utils.getExtensionPrefix(ext_name);
let install_command = ''; const command_prefix = 'sudo $debconf_fix apt-get install -y php';
let command = '';
switch (true) { switch (true) {
// 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):
install_command = command =
'bash ' + 'bash ' +
path.join(__dirname, '../src/scripts/ext/blackfire.sh') + path.join(__dirname, '../src/scripts/ext/blackfire.sh') +
' ' + ' ' +
@ -2875,7 +2895,7 @@ function addExtensionLinux(extension_csv, version, pipe) {
' ' + ' ' +
(yield utils.getBlackfireVersion(ext_version)); (yield utils.getBlackfireVersion(ext_version));
break; break;
// match pre-release versions // match pre-release versions. For example - xdebug-beta
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension): case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
script += script +=
'\nadd_unstable_extension ' + '\nadd_unstable_extension ' +
@ -2883,16 +2903,21 @@ function addExtensionLinux(extension_csv, version, pipe) {
' ' + ' ' +
ext_version + ext_version +
' ' + ' ' +
prefix; ext_prefix;
return; return;
// match exact versions // match semver versions
case /.*-\d+\.\d+\.\d+.*/.test(version_extension): case /.*-\d+\.\d+\.\d+.*/.test(version_extension):
script += script +=
'\nadd_pecl_extension ' + ext_name + ' ' + ext_version + ' ' + prefix; '\nadd_pecl_extension ' +
ext_name +
' ' +
ext_version +
' ' +
ext_prefix;
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):
install_command = command =
'sh ' + 'sh ' +
path.join(__dirname, '../src/scripts/ext/gearman.sh') + path.join(__dirname, '../src/scripts/ext/gearman.sh') +
' ' + ' ' +
@ -2912,28 +2937,27 @@ function addExtensionLinux(extension_csv, version, pipe) {
// match 7.0xdebug..7.4xdebug // match 7.0xdebug..7.4xdebug
case /^7\.[0-4]xdebug$/.test(version_extension): case /^7\.[0-4]xdebug$/.test(version_extension):
script += script +=
'\nupdate_extension xdebug 2.9.1' + '\nupdate_extension xdebug 2.9.2' +
pipe + pipe +
'\n' + '\n' +
(yield utils.addLog('$tick', 'xdebug', 'Enabled', 'linux')); (yield utils.addLog('$tick', 'xdebug', 'Enabled', 'linux'));
return; return;
// match pdo extensions // match pdo extensions
case /.*pdo[_-].*/.test(version_extension): case /.*pdo[_-].*/.test(version_extension):
script += extension = extension.replace('pdo_', '').replace('pdo-', '');
'\nadd_pdo_extension ' + script += '\nadd_pdo_extension ' + extension;
extension.replace('pdo_', '').replace('pdo-', '');
return; return;
// match sqlite
case /sqlite/.test(extension):
extension = 'sqlite3';
command = command_prefix + version + '-' + extension + pipe;
break;
default: default:
install_command = command = command_prefix + version + '-' + extension + pipe;
'sudo $debconf_fix apt-get install -y php' +
version +
'-' +
extension +
pipe;
break; break;
} }
script += script +=
'\nadd_extension ' + extension + ' "' + install_command + '" ' + prefix; '\nadd_extension ' + extension + ' "' + command + '" ' + ext_prefix;
}); });
}); });
return script; return script;
@ -2946,7 +2970,7 @@ exports.addExtensionLinux = addExtensionLinux;
* @param extension_csv * @param extension_csv
* @param version * @param version
* @param os_version * @param os_version
* @param log_prefix * @param no_step
*/ */
function addExtension(extension_csv, version, os_version, no_step = false) { function addExtension(extension_csv, version, os_version, no_step = false) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {

View File

@ -16,18 +16,18 @@ export async function addExtensionDarwin(
const extensions: Array<string> = await utils.extensionArray(extension_csv); const extensions: Array<string> = await utils.extensionArray(extension_csv);
let script = '\n'; let script = '\n';
await utils.asyncForEach(extensions, async function(extension: string) { await utils.asyncForEach(extensions, async function(extension: string) {
extension = extension.toLowerCase();
const version_extension: string = version + extension; const version_extension: string = version + extension;
const [ext_name, ext_version]: string[] = extension.split('-'); const [ext_name, ext_version]: string[] = extension.split('-');
const prefix = await utils.getExtensionPrefix(ext_name); const ext_prefix = await utils.getExtensionPrefix(ext_name);
let install_command = ''; const command_prefix = 'sudo pecl install -f ';
let command = '';
switch (true) { switch (true) {
// 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( case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(
version_extension version_extension
): ):
install_command = command =
'bash ' + 'bash ' +
path.join(__dirname, '../src/scripts/ext/blackfire_darwin.sh') + path.join(__dirname, '../src/scripts/ext/blackfire_darwin.sh') +
' ' + ' ' +
@ -35,7 +35,7 @@ export async function addExtensionDarwin(
' ' + ' ' +
(await utils.getBlackfireVersion(ext_version)); (await utils.getBlackfireVersion(ext_version));
break; break;
// match pre-release versions // match pre-release versions. For example - xdebug-beta
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension): case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
script += script +=
'\nadd_unstable_extension ' + '\nadd_unstable_extension ' +
@ -43,35 +43,54 @@ export async function addExtensionDarwin(
' ' + ' ' +
ext_version + ext_version +
' ' + ' ' +
prefix; ext_prefix;
return; return;
// match exact versions // match semver
case /.*-\d+\.\d+\.\d+.*/.test(version_extension): case /.*-\d+\.\d+\.\d+.*/.test(version_extension):
script += script +=
'\nadd_pecl_extension ' + ext_name + ' ' + ext_version + ' ' + prefix; '\nadd_pecl_extension ' +
ext_name +
' ' +
ext_version +
' ' +
ext_prefix;
return; return;
// match 5.3xdebug
case /5\.3xdebug/.test(version_extension): case /5\.3xdebug/.test(version_extension):
install_command = 'sudo pecl install -f xdebug-2.2.7' + pipe; command = command_prefix + 'xdebug-2.2.7' + pipe;
break; break;
// match 5.4xdebug
case /5\.4xdebug/.test(version_extension): case /5\.4xdebug/.test(version_extension):
install_command = 'sudo pecl install -f xdebug-2.4.1' + pipe; command = command_prefix + 'xdebug-2.4.1' + pipe;
break; break;
// match 5.5xdebug and 5.6xdebug
case /5\.[5-6]xdebug/.test(version_extension): case /5\.[5-6]xdebug/.test(version_extension):
install_command = 'sudo pecl install -f xdebug-2.5.5' + pipe; command = command_prefix + 'xdebug-2.5.5' + pipe;
break; break;
// match 7.0redis
case /7\.0xdebug/.test(version_extension): case /7\.0xdebug/.test(version_extension):
install_command = 'sudo pecl install -f xdebug-2.9.0' + pipe; command = command_prefix + 'xdebug-2.9.0' + pipe;
break; break;
// match 5.6redis
case /5\.6redis/.test(version_extension): case /5\.6redis/.test(version_extension):
install_command = 'sudo pecl install -f redis-2.2.8' + pipe; command = command_prefix + 'redis-2.2.8' + pipe;
break; break;
case /[5-9]\.\dimagick/.test(version_extension): // match imagick
install_command = case /imagick/.test(extension):
command =
'brew install pkg-config imagemagick' + 'brew install pkg-config imagemagick' +
pipe + pipe +
' && sudo pecl install -f imagick' + ' && ' +
command_prefix +
'imagick' +
pipe; pipe;
break; break;
// match sqlite
case /sqlite/.test(extension):
extension = 'sqlite3';
command = command_prefix + extension + pipe;
break;
// 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):
script += script +=
'sh ' + 'sh ' +
@ -82,16 +101,11 @@ export async function addExtensionDarwin(
version; version;
return; return;
default: default:
install_command = 'sudo pecl install -f ' + extension + pipe; command = command_prefix + extension + pipe;
break; break;
} }
script += script +=
'\nadd_extension ' + '\nadd_extension ' + extension + ' "' + command + '" ' + ext_prefix;
extension +
' "' +
install_command +
'" ' +
(await utils.getExtensionPrefix(extension));
}); });
return script; return script;
} }
@ -111,7 +125,6 @@ export async function addExtensionWindows(
const extensions: Array<string> = await utils.extensionArray(extension_csv); const extensions: Array<string> = await utils.extensionArray(extension_csv);
let script = '\n'; let script = '\n';
await utils.asyncForEach(extensions, async function(extension: string) { await utils.asyncForEach(extensions, async function(extension: string) {
extension = extension.toLowerCase();
const [ext_name, ext_version]: string[] = extension.split('-'); const [ext_name, ext_version]: string[] = extension.split('-');
const version_extension: string = version + extension; const version_extension: string = version + extension;
let matches: RegExpExecArray; let matches: RegExpExecArray;
@ -129,23 +142,29 @@ export async function addExtensionWindows(
' ' + ' ' +
(await utils.getBlackfireVersion(ext_version)); (await utils.getBlackfireVersion(ext_version));
return; return;
// match pre-release versions // match pre-release versions. For example - xdebug-beta
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension): case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
script += '\nAdd-Extension ' + ext_name + ' ' + ext_version; script += '\nAdd-Extension ' + ext_name + ' ' + ext_version;
break; break;
// match exact versions // match semver without state
case /.*-\d+\.\d+\.\d+$/.test(version_extension): case /.*-\d+\.\d+\.\d+$/.test(version_extension):
script += '\nAdd-Extension ' + ext_name + ' stable ' + ext_version; script += '\nAdd-Extension ' + ext_name + ' stable ' + ext_version;
return; return;
case /.*-(\d+\.\d+\.\d)+(beta|alpha|devel|snapshot)\d*/.test( // match semver with state
case /.*-(\d+\.\d+\.\d)(beta|alpha|devel|snapshot)\d*/.test(
version_extension version_extension
): ):
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;
script += script +=
'\nAdd-Extension ' + ext_name + ' ' + matches[2] + ' ' + matches[1]; '\nAdd-Extension ' + ext_name + ' ' + matches[2] + ' ' + matches[1];
return; return;
// match sqlite
case /sqlite/.test(extension):
extension = 'sqlite3';
script += '\nAdd-Extension ' + extension;
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):
script += script +=
@ -180,18 +199,18 @@ export async function addExtensionLinux(
const extensions: Array<string> = await utils.extensionArray(extension_csv); const extensions: Array<string> = await utils.extensionArray(extension_csv);
let script = '\n'; let script = '\n';
await utils.asyncForEach(extensions, async function(extension: string) { await utils.asyncForEach(extensions, async function(extension: string) {
extension = extension.toLowerCase();
const version_extension: string = version + extension; const version_extension: string = version + extension;
const [ext_name, ext_version]: string[] = extension.split('-'); const [ext_name, ext_version]: string[] = extension.split('-');
const prefix = await utils.getExtensionPrefix(ext_name); const ext_prefix = await utils.getExtensionPrefix(ext_name);
let install_command = ''; const command_prefix = 'sudo $debconf_fix apt-get install -y php';
let command = '';
switch (true) { switch (true) {
// 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( case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(
version_extension version_extension
): ):
install_command = command =
'bash ' + 'bash ' +
path.join(__dirname, '../src/scripts/ext/blackfire.sh') + path.join(__dirname, '../src/scripts/ext/blackfire.sh') +
' ' + ' ' +
@ -199,7 +218,7 @@ export async function addExtensionLinux(
' ' + ' ' +
(await utils.getBlackfireVersion(ext_version)); (await utils.getBlackfireVersion(ext_version));
break; break;
// match pre-release versions // match pre-release versions. For example - xdebug-beta
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension): case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
script += script +=
'\nadd_unstable_extension ' + '\nadd_unstable_extension ' +
@ -207,16 +226,21 @@ export async function addExtensionLinux(
' ' + ' ' +
ext_version + ext_version +
' ' + ' ' +
prefix; ext_prefix;
return; return;
// match exact versions // match semver versions
case /.*-\d+\.\d+\.\d+.*/.test(version_extension): case /.*-\d+\.\d+\.\d+.*/.test(version_extension):
script += script +=
'\nadd_pecl_extension ' + ext_name + ' ' + ext_version + ' ' + prefix; '\nadd_pecl_extension ' +
ext_name +
' ' +
ext_version +
' ' +
ext_prefix;
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):
install_command = command =
'sh ' + 'sh ' +
path.join(__dirname, '../src/scripts/ext/gearman.sh') + path.join(__dirname, '../src/scripts/ext/gearman.sh') +
' ' + ' ' +
@ -236,28 +260,27 @@ export async function addExtensionLinux(
// match 7.0xdebug..7.4xdebug // match 7.0xdebug..7.4xdebug
case /^7\.[0-4]xdebug$/.test(version_extension): case /^7\.[0-4]xdebug$/.test(version_extension):
script += script +=
'\nupdate_extension xdebug 2.9.1' + '\nupdate_extension xdebug 2.9.2' +
pipe + pipe +
'\n' + '\n' +
(await utils.addLog('$tick', 'xdebug', 'Enabled', 'linux')); (await utils.addLog('$tick', 'xdebug', 'Enabled', 'linux'));
return; return;
// match pdo extensions // match pdo extensions
case /.*pdo[_-].*/.test(version_extension): case /.*pdo[_-].*/.test(version_extension):
script += extension = extension.replace('pdo_', '').replace('pdo-', '');
'\nadd_pdo_extension ' + script += '\nadd_pdo_extension ' + extension;
extension.replace('pdo_', '').replace('pdo-', '');
return; return;
// match sqlite
case /sqlite/.test(extension):
extension = 'sqlite3';
command = command_prefix + version + '-' + extension + pipe;
break;
default: default:
install_command = command = command_prefix + version + '-' + extension + pipe;
'sudo $debconf_fix apt-get install -y php' +
version +
'-' +
extension +
pipe;
break; break;
} }
script += script +=
'\nadd_extension ' + extension + ' "' + install_command + '" ' + prefix; '\nadd_extension ' + extension + ' "' + command + '" ' + ext_prefix;
}); });
return script; return script;
} }
@ -268,7 +291,7 @@ export async function addExtensionLinux(
* @param extension_csv * @param extension_csv
* @param version * @param version
* @param os_version * @param os_version
* @param log_prefix * @param no_step
*/ */
export async function addExtension( export async function addExtension(
extension_csv: string, extension_csv: string,

View File

@ -196,6 +196,7 @@ export async function extensionArray(
.map(function(extension: string) { .map(function(extension: string) {
return extension return extension
.trim() .trim()
.toLowerCase()
.replace('php-', '') .replace('php-', '')
.replace('php_', ''); .replace('php_', '');
}) })