2019-10-27 05:42:49 +05:30
|
|
|
import * as path from 'path';
|
2019-09-20 08:11:20 +05:30
|
|
|
import * as utils from './utils';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Install and enable extensions for darwin
|
|
|
|
*
|
|
|
|
* @param extension_csv
|
2019-09-26 02:33:39 +05:30
|
|
|
* @param version
|
2019-12-26 18:31:18 +05:30
|
|
|
* @param pipe
|
2019-09-20 08:11:20 +05:30
|
|
|
*/
|
|
|
|
export async function addExtensionDarwin(
|
2019-09-26 02:33:39 +05:30
|
|
|
extension_csv: string,
|
2019-12-26 18:31:18 +05:30
|
|
|
version: string,
|
|
|
|
pipe: string
|
2019-09-20 08:11:20 +05:30
|
|
|
): Promise<string> {
|
2019-11-24 02:04:12 +05:30
|
|
|
const extensions: Array<string> = await utils.extensionArray(extension_csv);
|
|
|
|
let script = '\n';
|
2019-09-20 08:11:20 +05:30
|
|
|
await utils.asyncForEach(extensions, async function(extension: string) {
|
2019-09-26 02:33:39 +05:30
|
|
|
extension = extension.toLowerCase();
|
2019-12-26 18:31:18 +05:30
|
|
|
const version_extension: string = version + extension;
|
2019-09-20 08:11:20 +05:30
|
|
|
// add script to enable extension is already installed along with php
|
2019-11-24 02:04:12 +05:30
|
|
|
let install_command = '';
|
2019-12-23 23:19:38 +05:30
|
|
|
switch (true) {
|
2019-12-26 18:31:18 +05:30
|
|
|
case /5\.6xdebug/.test(version_extension):
|
|
|
|
install_command = 'sudo pecl install xdebug-2.5.5' + pipe;
|
2019-09-26 02:33:39 +05:30
|
|
|
break;
|
2019-12-26 18:31:18 +05:30
|
|
|
case /5\.6redis/.test(version_extension):
|
|
|
|
install_command = 'sudo pecl install redis-2.2.8' + pipe;
|
|
|
|
break;
|
|
|
|
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
|
|
|
install_command =
|
|
|
|
'sh ' +
|
|
|
|
path.join(__dirname, '../src/scripts/ext/phalcon_darwin.sh') +
|
|
|
|
' ' +
|
|
|
|
extension +
|
2019-12-31 05:46:33 +05:30
|
|
|
' ' +
|
|
|
|
version +
|
2019-12-26 18:31:18 +05:30
|
|
|
pipe;
|
2019-12-02 20:43:45 +05:30
|
|
|
break;
|
2019-09-26 02:33:39 +05:30
|
|
|
default:
|
2019-12-26 18:31:18 +05:30
|
|
|
install_command = 'sudo pecl install ' + extension + pipe;
|
2019-09-26 02:33:39 +05:30
|
|
|
break;
|
2019-09-20 08:11:20 +05:30
|
|
|
}
|
2019-10-11 04:41:25 +05:30
|
|
|
script +=
|
2019-10-17 01:41:13 +05:30
|
|
|
'\nadd_extension ' +
|
2019-10-11 04:41:25 +05:30
|
|
|
extension +
|
|
|
|
' "' +
|
|
|
|
install_command +
|
|
|
|
'" ' +
|
2019-10-17 01:41:13 +05:30
|
|
|
(await utils.getExtensionPrefix(extension));
|
2019-09-20 08:11:20 +05:30
|
|
|
});
|
|
|
|
return script;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Install and enable extensions for windows
|
|
|
|
*
|
|
|
|
* @param extension_csv
|
|
|
|
* @param version
|
2019-12-26 18:31:18 +05:30
|
|
|
* @param pipe
|
2019-09-20 08:11:20 +05:30
|
|
|
*/
|
|
|
|
export async function addExtensionWindows(
|
|
|
|
extension_csv: string,
|
2019-12-26 18:31:18 +05:30
|
|
|
version: string,
|
|
|
|
pipe: string
|
2019-09-20 08:11:20 +05:30
|
|
|
): Promise<string> {
|
2019-11-24 02:04:12 +05:30
|
|
|
const extensions: Array<string> = await utils.extensionArray(extension_csv);
|
|
|
|
let script = '\n';
|
2019-09-20 08:11:20 +05:30
|
|
|
await utils.asyncForEach(extensions, async function(extension: string) {
|
|
|
|
// add script to enable extension is already installed along with php
|
2019-12-26 18:31:18 +05:30
|
|
|
const version_extension: string = version + extension;
|
2019-12-23 23:19:38 +05:30
|
|
|
switch (true) {
|
|
|
|
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
|
2019-12-26 18:31:18 +05:30
|
|
|
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
|
|
|
script +=
|
|
|
|
'\n& ' +
|
|
|
|
path.join(__dirname, '../src/scripts/ext/phalcon.ps1') +
|
|
|
|
' ' +
|
|
|
|
extension +
|
|
|
|
' ' +
|
|
|
|
version +
|
|
|
|
'\n';
|
2019-12-02 20:43:45 +05:30
|
|
|
break;
|
|
|
|
default:
|
|
|
|
script += '\nAdd-Extension ' + extension;
|
|
|
|
break;
|
|
|
|
}
|
2019-09-20 08:11:20 +05:30
|
|
|
});
|
|
|
|
return script;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Install and enable extensions for linux
|
|
|
|
*
|
|
|
|
* @param extension_csv
|
|
|
|
* @param version
|
2019-12-26 18:31:18 +05:30
|
|
|
* @param pipe
|
2019-09-20 08:11:20 +05:30
|
|
|
*/
|
|
|
|
export async function addExtensionLinux(
|
|
|
|
extension_csv: string,
|
2019-12-26 18:31:18 +05:30
|
|
|
version: string,
|
|
|
|
pipe: string
|
2019-09-20 08:11:20 +05:30
|
|
|
): Promise<string> {
|
2019-11-24 02:04:12 +05:30
|
|
|
const extensions: Array<string> = await utils.extensionArray(extension_csv);
|
|
|
|
let script = '\n';
|
2019-09-20 08:11:20 +05:30
|
|
|
await utils.asyncForEach(extensions, async function(extension: string) {
|
2019-09-26 02:33:39 +05:30
|
|
|
extension = extension.toLowerCase();
|
2019-09-20 08:11:20 +05:30
|
|
|
// add script to enable extension is already installed along with php
|
2019-12-26 18:31:18 +05:30
|
|
|
const version_extension: string = version + extension;
|
2019-11-24 02:04:12 +05:30
|
|
|
let install_command = '';
|
2019-12-23 23:19:38 +05:30
|
|
|
switch (true) {
|
|
|
|
// match 5.6gearman..7.4gearman
|
2019-12-26 18:31:18 +05:30
|
|
|
case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension):
|
2019-10-27 05:42:49 +05:30
|
|
|
install_command =
|
|
|
|
'sh ' +
|
2019-12-26 18:31:18 +05:30
|
|
|
path.join(__dirname, '../src/scripts/ext/gearman.sh') +
|
2019-12-23 23:19:38 +05:30
|
|
|
' ' +
|
2019-10-27 05:42:49 +05:30
|
|
|
version +
|
2019-12-26 18:31:18 +05:30
|
|
|
pipe;
|
2019-10-13 09:48:29 +05:30
|
|
|
break;
|
2019-12-23 23:19:38 +05:30
|
|
|
// match 7.0phalcon3..7.3phalcon3 and 7.2phalcon4...7.4phalcon4
|
2019-12-26 18:31:18 +05:30
|
|
|
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
2019-10-27 05:42:49 +05:30
|
|
|
install_command =
|
|
|
|
'sh ' +
|
2019-12-26 18:31:18 +05:30
|
|
|
path.join(__dirname, '../src/scripts/ext/phalcon.sh') +
|
2019-12-23 23:19:38 +05:30
|
|
|
' ' +
|
|
|
|
extension +
|
2019-12-14 08:15:39 +05:30
|
|
|
' ' +
|
|
|
|
version +
|
2019-12-26 18:31:18 +05:30
|
|
|
pipe;
|
2019-12-14 08:15:39 +05:30
|
|
|
break;
|
2019-09-28 20:09:05 +05:30
|
|
|
default:
|
|
|
|
install_command =
|
2019-11-07 11:11:35 +05:30
|
|
|
'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y php' +
|
2019-09-28 20:09:05 +05:30
|
|
|
version +
|
|
|
|
'-' +
|
2019-11-13 06:29:58 +05:30
|
|
|
extension.replace('pdo_', '').replace('pdo-', '') +
|
2019-12-26 18:31:18 +05:30
|
|
|
pipe +
|
|
|
|
' || sudo pecl install ' +
|
2019-11-07 11:11:35 +05:30
|
|
|
extension +
|
2019-12-26 18:31:18 +05:30
|
|
|
pipe;
|
2019-09-28 20:09:05 +05:30
|
|
|
break;
|
|
|
|
}
|
2019-09-20 08:11:20 +05:30
|
|
|
script +=
|
2019-10-17 01:41:13 +05:30
|
|
|
'\nadd_extension ' +
|
2019-09-20 08:11:20 +05:30
|
|
|
extension +
|
2019-10-11 04:41:25 +05:30
|
|
|
' "' +
|
2019-09-28 20:09:05 +05:30
|
|
|
install_command +
|
2019-10-11 04:41:25 +05:30
|
|
|
'" ' +
|
2019-10-17 01:41:13 +05:30
|
|
|
(await utils.getExtensionPrefix(extension));
|
2019-09-20 08:11:20 +05:30
|
|
|
});
|
|
|
|
return script;
|
|
|
|
}
|
2019-11-24 02:04:12 +05:30
|
|
|
|
|
|
|
/**
|
|
|
|
* Install and enable extensions
|
|
|
|
*
|
|
|
|
* @param extension_csv
|
|
|
|
* @param version
|
|
|
|
* @param os_version
|
|
|
|
* @param log_prefix
|
|
|
|
*/
|
|
|
|
export async function addExtension(
|
|
|
|
extension_csv: string,
|
|
|
|
version: string,
|
|
|
|
os_version: string,
|
|
|
|
no_step = false
|
|
|
|
): Promise<string> {
|
2019-12-26 18:31:18 +05:30
|
|
|
const pipe: string = await utils.suppressOutput(os_version);
|
2019-11-24 02:04:12 +05:30
|
|
|
let script = '\n';
|
|
|
|
switch (no_step) {
|
|
|
|
case true:
|
2019-12-26 18:31:18 +05:30
|
|
|
script += (await utils.stepLog('Setup Extensions', os_version)) + pipe;
|
2019-11-24 02:04:12 +05:30
|
|
|
break;
|
|
|
|
case false:
|
|
|
|
default:
|
|
|
|
script += await utils.stepLog('Setup Extensions', os_version);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (os_version) {
|
|
|
|
case 'win32':
|
2019-12-26 18:31:18 +05:30
|
|
|
return script + (await addExtensionWindows(extension_csv, version, pipe));
|
2019-11-24 02:04:12 +05:30
|
|
|
case 'darwin':
|
2019-12-26 18:31:18 +05:30
|
|
|
return script + (await addExtensionDarwin(extension_csv, version, pipe));
|
2019-11-24 02:04:12 +05:30
|
|
|
case 'linux':
|
2019-12-26 18:31:18 +05:30
|
|
|
return script + (await addExtensionLinux(extension_csv, version, pipe));
|
2019-11-24 02:04:12 +05:30
|
|
|
default:
|
|
|
|
return await utils.log(
|
|
|
|
'Platform ' + os_version + ' is not supported',
|
|
|
|
os_version,
|
|
|
|
'error'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|