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