mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 11:51:07 +07:00
Improve extension support
This commit is contained in:
parent
0da52b1327
commit
6a4159ba98
@ -3,12 +3,13 @@ import * as extensions from '../src/extensions';
|
||||
describe('Extension tests', () => {
|
||||
it('checking addExtensionOnWindows', async () => {
|
||||
let win32: string = await extensions.addExtension(
|
||||
'xdebug, pcov, phalcon4, ast-beta',
|
||||
'Xdebug, pcov, sqlite, phalcon4, ast-beta',
|
||||
'7.4',
|
||||
'win32'
|
||||
);
|
||||
expect(win32).toContain('Add-Extension xdebug');
|
||||
expect(win32).toContain('Add-Extension pcov');
|
||||
expect(win32).toContain('Add-Extension sqlite3');
|
||||
expect(win32).toContain('phalcon.ps1 phalcon4');
|
||||
expect(win32).toContain('Add-Extension ast beta');
|
||||
|
||||
@ -27,13 +28,14 @@ describe('Extension tests', () => {
|
||||
|
||||
it('checking addExtensionOnLinux', async () => {
|
||||
let linux: string = await extensions.addExtension(
|
||||
'xdebug, pcov, ast-beta, xdebug-alpha',
|
||||
'Xdebug, pcov, sqlite, ast-beta, xdebug-alpha',
|
||||
'7.4',
|
||||
'linux'
|
||||
);
|
||||
expect(linux).toContain('update_extension xdebug 2.9.0');
|
||||
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 DEBIAN_FRONTEND=noninteractive apt-get install -y php7.4-pcov'
|
||||
'sudo $debconf_fix apt-get install -y php7.4-sqlite3'
|
||||
);
|
||||
expect(linux).toContain('add_unstable_extension ast beta extension');
|
||||
expect(linux).toContain(
|
||||
@ -64,12 +66,13 @@ describe('Extension tests', () => {
|
||||
|
||||
it('checking addExtensionOnDarwin', async () => {
|
||||
let darwin: string = await extensions.addExtension(
|
||||
'xdebug, pcov, ast-beta',
|
||||
'Xdebug, pcov, sqlite3, ast-beta',
|
||||
'7.2',
|
||||
'darwin'
|
||||
);
|
||||
expect(darwin).toContain('sudo pecl install -f xdebug');
|
||||
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');
|
||||
|
||||
darwin = await extensions.addExtension('phalcon3', '7.0', 'darwin');
|
||||
|
67
dist/index.js
vendored
67
dist/index.js
vendored
@ -1177,6 +1177,7 @@ function extensionArray(extension_csv) {
|
||||
.map(function (extension) {
|
||||
return extension
|
||||
.trim()
|
||||
.toLowerCase()
|
||||
.replace('php-', '')
|
||||
.replace('php_', '');
|
||||
})
|
||||
@ -2645,11 +2646,11 @@ function addExtensionDarwin(extension_csv, version, pipe) {
|
||||
let script = '\n';
|
||||
yield utils.asyncForEach(extensions, function (extension) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
extension = extension.toLowerCase();
|
||||
const version_extension = version + extension;
|
||||
const [extension_name, stability] = extension.split('-');
|
||||
const prefix = yield utils.getExtensionPrefix(extension_name);
|
||||
let install_command = '';
|
||||
const ext_prefix = yield utils.getExtensionPrefix(extension_name);
|
||||
const command_prefix = 'sudo pecl install -f ';
|
||||
let command = '';
|
||||
switch (true) {
|
||||
// match pre-release versions
|
||||
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
|
||||
@ -2659,24 +2660,36 @@ function addExtensionDarwin(extension_csv, version, pipe) {
|
||||
' ' +
|
||||
stability +
|
||||
' ' +
|
||||
prefix;
|
||||
ext_prefix;
|
||||
return;
|
||||
// match 5.6xdebug
|
||||
case /5\.6xdebug/.test(version_extension):
|
||||
install_command = 'sudo pecl install -f xdebug-2.5.5' + pipe;
|
||||
command = command_prefix + 'xdebug-2.5.5' + pipe;
|
||||
break;
|
||||
// match 7.0xdebug
|
||||
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;
|
||||
// match 5.6redis
|
||||
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;
|
||||
case /[5-9]\.\dimagick/.test(version_extension):
|
||||
install_command =
|
||||
// match imagick
|
||||
case /imagick/.test(extension):
|
||||
command =
|
||||
'brew install pkg-config imagemagick' +
|
||||
pipe +
|
||||
' && sudo pecl install -f imagick' +
|
||||
' && ' +
|
||||
command_prefix +
|
||||
'imagick' +
|
||||
pipe;
|
||||
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):
|
||||
script +=
|
||||
'sh ' +
|
||||
@ -2687,14 +2700,14 @@ function addExtensionDarwin(extension_csv, version, pipe) {
|
||||
version;
|
||||
return;
|
||||
default:
|
||||
install_command = 'sudo pecl install -f ' + extension + pipe;
|
||||
command = command_prefix + extension + pipe;
|
||||
break;
|
||||
}
|
||||
script +=
|
||||
'\nadd_extension ' +
|
||||
extension +
|
||||
' "' +
|
||||
install_command +
|
||||
command +
|
||||
'" ' +
|
||||
(yield utils.getExtensionPrefix(extension));
|
||||
});
|
||||
@ -2716,7 +2729,6 @@ function addExtensionWindows(extension_csv, version, pipe) {
|
||||
let script = '\n';
|
||||
yield utils.asyncForEach(extensions, function (extension) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
extension = extension.toLowerCase();
|
||||
const [extension_name, stability] = extension.split('-');
|
||||
const version_extension = version + extension;
|
||||
switch (true) {
|
||||
@ -2724,6 +2736,11 @@ function addExtensionWindows(extension_csv, version, pipe) {
|
||||
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
|
||||
script += '\nAdd-Extension ' + extension_name + ' ' + stability;
|
||||
break;
|
||||
// match sqlite
|
||||
case /sqlite/.test(extension):
|
||||
extension = 'sqlite3';
|
||||
script += '\nAdd-Extension ' + extension;
|
||||
break;
|
||||
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
|
||||
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
||||
script +=
|
||||
@ -2758,11 +2775,11 @@ function addExtensionLinux(extension_csv, version, pipe) {
|
||||
let script = '\n';
|
||||
yield utils.asyncForEach(extensions, function (extension) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
extension = extension.toLowerCase();
|
||||
const version_extension = version + extension;
|
||||
const [extension_name, stability] = extension.split('-');
|
||||
const prefix = yield utils.getExtensionPrefix(extension_name);
|
||||
let install_command = '';
|
||||
const ext_prefix = yield utils.getExtensionPrefix(extension_name);
|
||||
const command_prefix = 'sudo $debconf_fix apt-get install -y php';
|
||||
let command = '';
|
||||
switch (true) {
|
||||
// match pre-release versions
|
||||
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
|
||||
@ -2772,11 +2789,11 @@ function addExtensionLinux(extension_csv, version, pipe) {
|
||||
' ' +
|
||||
stability +
|
||||
' ' +
|
||||
prefix;
|
||||
ext_prefix;
|
||||
return;
|
||||
// match 5.6gearman..7.4gearman
|
||||
case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension):
|
||||
install_command =
|
||||
command =
|
||||
'sh ' +
|
||||
path.join(__dirname, '../src/scripts/ext/gearman.sh') +
|
||||
' ' +
|
||||
@ -2796,14 +2813,18 @@ function addExtensionLinux(extension_csv, version, pipe) {
|
||||
// match 7.0xdebug..7.4xdebug
|
||||
case /^7\.[0-4]xdebug$/.test(version_extension):
|
||||
script +=
|
||||
'\nupdate_extension xdebug 2.9.0' +
|
||||
'\nupdate_extension xdebug 2.9.2' +
|
||||
pipe +
|
||||
'\n' +
|
||||
(yield utils.addLog('$tick', 'xdebug', 'Enabled', 'linux'));
|
||||
return;
|
||||
case /sqlite/.test(extension):
|
||||
extension = 'sqlite3';
|
||||
command = command_prefix + version + '-' + extension + pipe;
|
||||
break;
|
||||
default:
|
||||
install_command =
|
||||
'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y php' +
|
||||
command =
|
||||
command_prefix +
|
||||
version +
|
||||
'-' +
|
||||
extension.replace('pdo_', '').replace('pdo-', '') +
|
||||
@ -2811,7 +2832,7 @@ function addExtensionLinux(extension_csv, version, pipe) {
|
||||
break;
|
||||
}
|
||||
script +=
|
||||
'\nadd_extension ' + extension + ' "' + install_command + '" ' + prefix;
|
||||
'\nadd_extension ' + extension + ' "' + command + '" ' + ext_prefix;
|
||||
});
|
||||
});
|
||||
return script;
|
||||
@ -2824,7 +2845,7 @@ exports.addExtensionLinux = addExtensionLinux;
|
||||
* @param extension_csv
|
||||
* @param version
|
||||
* @param os_version
|
||||
* @param log_prefix
|
||||
* @param no_step
|
||||
*/
|
||||
function addExtension(extension_csv, version, os_version, no_step = false) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
|
@ -16,11 +16,11 @@ export async function addExtensionDarwin(
|
||||
const extensions: Array<string> = await utils.extensionArray(extension_csv);
|
||||
let script = '\n';
|
||||
await utils.asyncForEach(extensions, async function(extension: string) {
|
||||
extension = extension.toLowerCase();
|
||||
const version_extension: string = version + extension;
|
||||
const [extension_name, stability]: string[] = extension.split('-');
|
||||
const prefix = await utils.getExtensionPrefix(extension_name);
|
||||
let install_command = '';
|
||||
const ext_prefix = await utils.getExtensionPrefix(extension_name);
|
||||
const command_prefix = 'sudo pecl install -f ';
|
||||
let command = '';
|
||||
switch (true) {
|
||||
// match pre-release versions
|
||||
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
|
||||
@ -30,24 +30,36 @@ export async function addExtensionDarwin(
|
||||
' ' +
|
||||
stability +
|
||||
' ' +
|
||||
prefix;
|
||||
ext_prefix;
|
||||
return;
|
||||
// match 5.6xdebug
|
||||
case /5\.6xdebug/.test(version_extension):
|
||||
install_command = 'sudo pecl install -f xdebug-2.5.5' + pipe;
|
||||
command = command_prefix + 'xdebug-2.5.5' + pipe;
|
||||
break;
|
||||
// match 7.0xdebug
|
||||
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;
|
||||
// match 5.6redis
|
||||
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;
|
||||
case /[5-9]\.\dimagick/.test(version_extension):
|
||||
install_command =
|
||||
// match imagick
|
||||
case /imagick/.test(extension):
|
||||
command =
|
||||
'brew install pkg-config imagemagick' +
|
||||
pipe +
|
||||
' && sudo pecl install -f imagick' +
|
||||
' && ' +
|
||||
command_prefix +
|
||||
'imagick' +
|
||||
pipe;
|
||||
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):
|
||||
script +=
|
||||
'sh ' +
|
||||
@ -58,14 +70,14 @@ export async function addExtensionDarwin(
|
||||
version;
|
||||
return;
|
||||
default:
|
||||
install_command = 'sudo pecl install -f ' + extension + pipe;
|
||||
command = command_prefix + extension + pipe;
|
||||
break;
|
||||
}
|
||||
script +=
|
||||
'\nadd_extension ' +
|
||||
extension +
|
||||
' "' +
|
||||
install_command +
|
||||
command +
|
||||
'" ' +
|
||||
(await utils.getExtensionPrefix(extension));
|
||||
});
|
||||
@ -87,7 +99,6 @@ export async function addExtensionWindows(
|
||||
const extensions: Array<string> = await utils.extensionArray(extension_csv);
|
||||
let script = '\n';
|
||||
await utils.asyncForEach(extensions, async function(extension: string) {
|
||||
extension = extension.toLowerCase();
|
||||
const [extension_name, stability]: string[] = extension.split('-');
|
||||
const version_extension: string = version + extension;
|
||||
switch (true) {
|
||||
@ -95,6 +106,11 @@ export async function addExtensionWindows(
|
||||
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
|
||||
script += '\nAdd-Extension ' + extension_name + ' ' + stability;
|
||||
break;
|
||||
// match sqlite
|
||||
case /sqlite/.test(extension):
|
||||
extension = 'sqlite3';
|
||||
script += '\nAdd-Extension ' + extension;
|
||||
break;
|
||||
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
|
||||
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
||||
script +=
|
||||
@ -129,11 +145,11 @@ export async function addExtensionLinux(
|
||||
const extensions: Array<string> = await utils.extensionArray(extension_csv);
|
||||
let script = '\n';
|
||||
await utils.asyncForEach(extensions, async function(extension: string) {
|
||||
extension = extension.toLowerCase();
|
||||
const version_extension: string = version + extension;
|
||||
const [extension_name, stability]: string[] = extension.split('-');
|
||||
const prefix = await utils.getExtensionPrefix(extension_name);
|
||||
let install_command = '';
|
||||
const ext_prefix = await utils.getExtensionPrefix(extension_name);
|
||||
const command_prefix = 'sudo $debconf_fix apt-get install -y php';
|
||||
let command = '';
|
||||
switch (true) {
|
||||
// match pre-release versions
|
||||
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
|
||||
@ -143,11 +159,11 @@ export async function addExtensionLinux(
|
||||
' ' +
|
||||
stability +
|
||||
' ' +
|
||||
prefix;
|
||||
ext_prefix;
|
||||
return;
|
||||
// match 5.6gearman..7.4gearman
|
||||
case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension):
|
||||
install_command =
|
||||
command =
|
||||
'sh ' +
|
||||
path.join(__dirname, '../src/scripts/ext/gearman.sh') +
|
||||
' ' +
|
||||
@ -167,14 +183,18 @@ export async function addExtensionLinux(
|
||||
// match 7.0xdebug..7.4xdebug
|
||||
case /^7\.[0-4]xdebug$/.test(version_extension):
|
||||
script +=
|
||||
'\nupdate_extension xdebug 2.9.0' +
|
||||
'\nupdate_extension xdebug 2.9.2' +
|
||||
pipe +
|
||||
'\n' +
|
||||
(await utils.addLog('$tick', 'xdebug', 'Enabled', 'linux'));
|
||||
return;
|
||||
case /sqlite/.test(extension):
|
||||
extension = 'sqlite3';
|
||||
command = command_prefix + version + '-' + extension + pipe;
|
||||
break;
|
||||
default:
|
||||
install_command =
|
||||
'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y php' +
|
||||
command =
|
||||
command_prefix +
|
||||
version +
|
||||
'-' +
|
||||
extension.replace('pdo_', '').replace('pdo-', '') +
|
||||
@ -182,7 +202,7 @@ export async function addExtensionLinux(
|
||||
break;
|
||||
}
|
||||
script +=
|
||||
'\nadd_extension ' + extension + ' "' + install_command + '" ' + prefix;
|
||||
'\nadd_extension ' + extension + ' "' + command + '" ' + ext_prefix;
|
||||
});
|
||||
return script;
|
||||
}
|
||||
@ -193,7 +213,7 @@ export async function addExtensionLinux(
|
||||
* @param extension_csv
|
||||
* @param version
|
||||
* @param os_version
|
||||
* @param log_prefix
|
||||
* @param no_step
|
||||
*/
|
||||
export async function addExtension(
|
||||
extension_csv: string,
|
||||
|
@ -196,6 +196,7 @@ export async function extensionArray(
|
||||
.map(function(extension: string) {
|
||||
return extension
|
||||
.trim()
|
||||
.toLowerCase()
|
||||
.replace('php-', '')
|
||||
.replace('php_', '');
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user