mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 20:01:06 +07:00
commit
ffc5b0249d
@ -20,7 +20,8 @@ describe('Config tests', () => {
|
|||||||
it('checking addINIValuesOnLinux', async () => {
|
it('checking addINIValuesOnLinux', async () => {
|
||||||
let linux: string = await config.addINIValues(
|
let linux: string = await config.addINIValues(
|
||||||
'post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata',
|
'post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata',
|
||||||
'linux'
|
'linux',
|
||||||
|
true
|
||||||
);
|
);
|
||||||
expect(linux).toContain(
|
expect(linux).toContain(
|
||||||
'echo "post_max_size=256M\nshort_open_tag=On\ndate.timezone=Asia/Kolkata" >> $ini_file'
|
'echo "post_max_size=256M\nshort_open_tag=On\ndate.timezone=Asia/Kolkata" >> $ini_file'
|
||||||
|
@ -17,10 +17,10 @@ describe('Config tests', () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
win32 = await coverage.addCoverage('pcov', '7.0', 'win32');
|
win32 = await coverage.addCoverage('pcov', '7.0', 'win32');
|
||||||
expect(win32).toContain('PCOV requires PHP 7.1 or newer');
|
expect(win32).toContain('PHP 7.1 or newer is required');
|
||||||
|
|
||||||
win32 = await coverage.addCoverage('pcov', '5.6', 'win32');
|
win32 = await coverage.addCoverage('pcov', '5.6', 'win32');
|
||||||
expect(win32).toContain('PCOV requires PHP 7.1 or newer');
|
expect(win32).toContain('PHP 7.1 or newer is required');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('checking addCoverage with PCOV on linux', async () => {
|
it('checking addCoverage with PCOV on linux', async () => {
|
||||||
|
@ -19,9 +19,14 @@ describe('Extension tests', () => {
|
|||||||
);
|
);
|
||||||
expect(win32).toContain('Install-PhpExtension pcov');
|
expect(win32).toContain('Install-PhpExtension pcov');
|
||||||
|
|
||||||
win32 = await extensions.addExtension('does_not_exist', '7.2', 'win32');
|
win32 = await extensions.addExtension(
|
||||||
|
'does_not_exist',
|
||||||
|
'7.2',
|
||||||
|
'win32',
|
||||||
|
true
|
||||||
|
);
|
||||||
expect(win32).toContain(
|
expect(win32).toContain(
|
||||||
'Add-Extension does_not_exist "Install-PhpExtension does_not_exist" extension "Add Extension"'
|
'Add-Extension does_not_exist "Install-PhpExtension does_not_exist" extension'
|
||||||
);
|
);
|
||||||
|
|
||||||
win32 = await extensions.addExtension('xdebug', '7.2', 'fedora');
|
win32 = await extensions.addExtension('xdebug', '7.2', 'fedora');
|
||||||
@ -84,7 +89,12 @@ describe('Extension tests', () => {
|
|||||||
darwin = await extensions.addExtension('xdebug', '7.2', 'darwin');
|
darwin = await extensions.addExtension('xdebug', '7.2', 'darwin');
|
||||||
expect(darwin).toContain('sudo pecl install xdebug');
|
expect(darwin).toContain('sudo pecl install xdebug');
|
||||||
|
|
||||||
darwin = await extensions.addExtension('does_not_exist', '7.2', 'darwin');
|
darwin = await extensions.addExtension(
|
||||||
|
'does_not_exist',
|
||||||
|
'7.2',
|
||||||
|
'darwin',
|
||||||
|
false
|
||||||
|
);
|
||||||
expect(darwin).toContain('add_extension does_not_exist');
|
expect(darwin).toContain('add_extension does_not_exist');
|
||||||
|
|
||||||
darwin = await extensions.addExtension('xdebug', '7.2', 'fedora');
|
darwin = await extensions.addExtension('xdebug', '7.2', 'fedora');
|
||||||
|
@ -61,6 +61,11 @@ describe('Utils tests', () => {
|
|||||||
expect(await utils.readScript('fedora.sh', '7.3', 'fedora')).toContain(
|
expect(await utils.readScript('fedora.sh', '7.3', 'fedora')).toContain(
|
||||||
'Platform fedora is not supported'
|
'Platform fedora is not supported'
|
||||||
);
|
);
|
||||||
|
await cleanup('./config.yaml');
|
||||||
|
await cleanup('./pcov.sh');
|
||||||
|
await cleanup('./phalcon.sh');
|
||||||
|
await cleanup('./php_pcov.dll');
|
||||||
|
await cleanup('./xdebug_darwin.sh');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('checking writeScripts', async () => {
|
it('checking writeScripts', async () => {
|
||||||
@ -101,53 +106,48 @@ describe('Utils tests', () => {
|
|||||||
let message: string = 'Test message';
|
let message: string = 'Test message';
|
||||||
|
|
||||||
let warning_log: string = await utils.log(message, 'win32', 'warning');
|
let warning_log: string = await utils.log(message, 'win32', 'warning');
|
||||||
expect(warning_log).toEqual(
|
expect(warning_log).toEqual('printf "\\033[33;1m' + message + ' \\033[0m"');
|
||||||
"Write-Host '" + message + "' -ForegroundColor yellow"
|
|
||||||
);
|
|
||||||
warning_log = await utils.log(message, 'linux', 'warning');
|
warning_log = await utils.log(message, 'linux', 'warning');
|
||||||
expect(warning_log).toEqual('echo "\\033[33;1m' + message + '\\033[0m"');
|
expect(warning_log).toEqual('echo "\\033[33;1m' + message + '\\033[0m"');
|
||||||
warning_log = await utils.log(message, 'darwin', 'warning');
|
warning_log = await utils.log(message, 'darwin', 'warning');
|
||||||
expect(warning_log).toEqual('echo "\\033[33;1m' + message + '\\033[0m"');
|
expect(warning_log).toEqual('echo "\\033[33;1m' + message + '\\033[0m"');
|
||||||
|
|
||||||
let error_log: string = await utils.log(message, 'win32', 'error');
|
let error_log: string = await utils.log(message, 'win32', 'error');
|
||||||
expect(error_log).toEqual(
|
expect(error_log).toEqual('printf "\\033[31;1m' + message + ' \\033[0m"');
|
||||||
"Write-Host '" + message + "' -ForegroundColor red"
|
|
||||||
);
|
|
||||||
error_log = await utils.log(message, 'linux', 'error');
|
error_log = await utils.log(message, 'linux', 'error');
|
||||||
expect(error_log).toEqual('echo "\\033[31;1m' + message + '\\033[0m"');
|
expect(error_log).toEqual('echo "\\033[31;1m' + message + '\\033[0m"');
|
||||||
error_log = await utils.log(message, 'darwin', 'error');
|
error_log = await utils.log(message, 'darwin', 'error');
|
||||||
expect(error_log).toEqual('echo "\\033[31;1m' + message + '\\033[0m"');
|
expect(error_log).toEqual('echo "\\033[31;1m' + message + '\\033[0m"');
|
||||||
|
|
||||||
let success_log: string = await utils.log(message, 'win32', 'success');
|
let success_log: string = await utils.log(message, 'win32', 'success');
|
||||||
expect(success_log).toEqual(
|
expect(success_log).toEqual('printf "\\033[32;1m' + message + ' \\033[0m"');
|
||||||
"Write-Host '" + message + "' -ForegroundColor green"
|
|
||||||
);
|
|
||||||
success_log = await utils.log(message, 'linux', 'success');
|
success_log = await utils.log(message, 'linux', 'success');
|
||||||
expect(success_log).toEqual('echo "\\033[32;1m' + message + '\\033[0m"');
|
expect(success_log).toEqual('echo "\\033[32;1m' + message + '\\033[0m"');
|
||||||
success_log = await utils.log(message, 'darwin', 'success');
|
success_log = await utils.log(message, 'darwin', 'success');
|
||||||
expect(success_log).toEqual('echo "\\033[32;1m' + message + '\\033[0m"');
|
expect(success_log).toEqual('echo "\\033[32;1m' + message + '\\033[0m"');
|
||||||
|
|
||||||
success_log = await utils.log(message, 'win32', 'success', 'Test win');
|
let step_log: string = await utils.stepLog(message, 'win32');
|
||||||
expect(success_log).toEqual(
|
expect(step_log).toEqual('Step-Log "Test message"');
|
||||||
"Write-Host 'Test win: " + message + "' -ForegroundColor green"
|
step_log = await utils.stepLog(message, 'linux');
|
||||||
);
|
expect(step_log).toEqual('step_log "Test message"');
|
||||||
});
|
step_log = await utils.stepLog(message, 'darwin');
|
||||||
|
expect(step_log).toEqual('step_log "Test message"');
|
||||||
|
step_log = await utils.stepLog(message, 'fedora');
|
||||||
|
expect(step_log).toContain('Platform fedora is not supported');
|
||||||
|
|
||||||
it('checking log with prefix', async () => {
|
let add_log: string = await utils.addLog(
|
||||||
let message: string = 'Test message';
|
'tick',
|
||||||
let prefix_log: string = await utils.log(
|
'xdebug',
|
||||||
message,
|
'enabled',
|
||||||
'linux',
|
'win32'
|
||||||
'success',
|
|
||||||
'Test Prefix'
|
|
||||||
);
|
|
||||||
expect(prefix_log).toEqual(
|
|
||||||
'echo "\\033[32;1mTest Prefix: ' + message + '\\033[0m"'
|
|
||||||
);
|
|
||||||
prefix_log = await utils.log(message, 'darwin', 'success', 'Test');
|
|
||||||
expect(prefix_log).toEqual(
|
|
||||||
'echo "\\033[32;1mTest: ' + message + '\\033[0m"'
|
|
||||||
);
|
);
|
||||||
|
expect(add_log).toEqual('Add-Log "tick" "xdebug" "enabled"');
|
||||||
|
add_log = await utils.addLog('tick', 'xdebug', 'enabled', 'linux');
|
||||||
|
expect(add_log).toEqual('add_log "tick" "xdebug" "enabled"');
|
||||||
|
add_log = await utils.addLog('tick', 'xdebug', 'enabled', 'darwin');
|
||||||
|
expect(add_log).toEqual('add_log "tick" "xdebug" "enabled"');
|
||||||
|
add_log = await utils.addLog('tick', 'xdebug', 'enabled', 'fedora');
|
||||||
|
expect(add_log).toContain('Platform fedora is not supported');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('checking getExtensionPrefix', async () => {
|
it('checking getExtensionPrefix', async () => {
|
||||||
@ -158,4 +158,13 @@ describe('Utils tests', () => {
|
|||||||
expect(await utils.getExtensionPrefix('xdebug')).toEqual('zend_extension');
|
expect(await utils.getExtensionPrefix('xdebug')).toEqual('zend_extension');
|
||||||
expect(await utils.getExtensionPrefix('opcache')).toEqual('zend_extension');
|
expect(await utils.getExtensionPrefix('opcache')).toEqual('zend_extension');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('checking suppressOutput', async () => {
|
||||||
|
expect(await utils.suppressOutput('win32')).toEqual(' >$null 2>&1');
|
||||||
|
expect(await utils.suppressOutput('linux')).toEqual(' >/dev/null 2>&1');
|
||||||
|
expect(await utils.suppressOutput('darwin')).toEqual(' >/dev/null 2>&1');
|
||||||
|
expect(await utils.suppressOutput('fedora')).toContain(
|
||||||
|
'Platform fedora is not supported'
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -23,16 +23,29 @@ const utils = __importStar(require("./utils"));
|
|||||||
* @param ini_values_csv
|
* @param ini_values_csv
|
||||||
* @param os_version
|
* @param os_version
|
||||||
*/
|
*/
|
||||||
function addINIValues(ini_values_csv, os_version) {
|
function addINIValues(ini_values_csv, os_version, no_step = false) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
let script = '\n';
|
||||||
|
switch (no_step) {
|
||||||
|
case true:
|
||||||
|
script +=
|
||||||
|
(yield utils.stepLog('Add php.ini values', os_version)) +
|
||||||
|
(yield utils.suppressOutput(os_version)) +
|
||||||
|
'\n';
|
||||||
|
break;
|
||||||
|
case false:
|
||||||
|
default:
|
||||||
|
script += (yield utils.stepLog('Add php.ini values', os_version)) + '\n';
|
||||||
|
break;
|
||||||
|
}
|
||||||
switch (os_version) {
|
switch (os_version) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return yield addINIValuesWindows(ini_values_csv);
|
return script + (yield addINIValuesWindows(ini_values_csv));
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
case 'linux':
|
case 'linux':
|
||||||
return yield addINIValuesUnix(ini_values_csv);
|
return script + (yield addINIValuesUnix(ini_values_csv));
|
||||||
default:
|
default:
|
||||||
return yield utils.log('Platform ' + os_version + ' is not supported', os_version, 'error', 'Add Config');
|
return yield utils.log('Platform ' + os_version + ' is not supported', os_version, 'error');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -45,7 +58,14 @@ exports.addINIValues = addINIValues;
|
|||||||
function addINIValuesUnix(ini_values_csv) {
|
function addINIValuesUnix(ini_values_csv) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let ini_values = yield utils.INIArray(ini_values_csv);
|
let ini_values = yield utils.INIArray(ini_values_csv);
|
||||||
return '\necho "' + ini_values.join('\n') + '" >> $ini_file\n';
|
let script = '\n';
|
||||||
|
yield utils.asyncForEach(ini_values, function (line) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
script +=
|
||||||
|
(yield utils.addLog('$tick', line, 'Added to php.ini', 'linux')) + '\n';
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return 'echo "' + ini_values.join('\n') + '" >> $ini_file' + script;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.addINIValuesUnix = addINIValuesUnix;
|
exports.addINIValuesUnix = addINIValuesUnix;
|
||||||
@ -57,7 +77,17 @@ exports.addINIValuesUnix = addINIValuesUnix;
|
|||||||
function addINIValuesWindows(ini_values_csv) {
|
function addINIValuesWindows(ini_values_csv) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let ini_values = yield utils.INIArray(ini_values_csv);
|
let ini_values = yield utils.INIArray(ini_values_csv);
|
||||||
return ('Add-Content C:\\tools\\php\\php.ini "' + ini_values.join('\n') + '"\n');
|
let script = '\n';
|
||||||
|
yield utils.asyncForEach(ini_values, function (line) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
script +=
|
||||||
|
(yield utils.addLog('$tick', line, 'Added to php.ini', 'win32')) + '\n';
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return ('Add-Content C:\\tools\\php\\php.ini "' +
|
||||||
|
ini_values.join('\n') +
|
||||||
|
'"' +
|
||||||
|
script);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.addINIValuesWindows = addINIValuesWindows;
|
exports.addINIValuesWindows = addINIValuesWindows;
|
||||||
|
@ -29,13 +29,14 @@ const config = __importStar(require("./config"));
|
|||||||
function addCoverage(coverage_driver, version, os_version) {
|
function addCoverage(coverage_driver, version, os_version) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
coverage_driver.toLowerCase();
|
coverage_driver.toLowerCase();
|
||||||
|
let script = '\n' + (yield utils.stepLog('Setup Coverage', os_version));
|
||||||
switch (coverage_driver) {
|
switch (coverage_driver) {
|
||||||
case 'pcov':
|
case 'pcov':
|
||||||
return addCoveragePCOV(version, os_version);
|
return script + (yield addCoveragePCOV(version, os_version));
|
||||||
case 'xdebug':
|
case 'xdebug':
|
||||||
return addCoverageXdebug(version, os_version);
|
return script + (yield addCoverageXdebug(version, os_version));
|
||||||
case 'none':
|
case 'none':
|
||||||
return disableCoverage(version, os_version);
|
return script + (yield disableCoverage(version, os_version));
|
||||||
default:
|
default:
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
@ -50,10 +51,10 @@ exports.addCoverage = addCoverage;
|
|||||||
*/
|
*/
|
||||||
function addCoverageXdebug(version, os_version) {
|
function addCoverageXdebug(version, os_version) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let script = '\n';
|
return ((yield extensions.addExtension('xdebug', version, os_version, true)) +
|
||||||
script += yield extensions.addExtension('xdebug', version, os_version, 'Set Coverage Driver');
|
(yield utils.suppressOutput(os_version)) +
|
||||||
script += yield utils.log('Xdebug enabled as coverage driver', os_version, 'success', 'Set Coverage Driver');
|
'\n' +
|
||||||
return script;
|
(yield utils.addLog('$tick', 'xdebug', 'Xdebug enabled as coverage driver', os_version)));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.addCoverageXdebug = addCoverageXdebug;
|
exports.addCoverageXdebug = addCoverageXdebug;
|
||||||
@ -68,8 +69,12 @@ function addCoveragePCOV(version, os_version) {
|
|||||||
let script = '\n';
|
let script = '\n';
|
||||||
switch (version) {
|
switch (version) {
|
||||||
default:
|
default:
|
||||||
script += yield extensions.addExtension('pcov', version, os_version, 'Set Coverage Driver');
|
script +=
|
||||||
script += yield config.addINIValues('pcov.enabled=1', os_version);
|
(yield extensions.addExtension('pcov', version, os_version, true)) +
|
||||||
|
(yield utils.suppressOutput(os_version)) +
|
||||||
|
'\n';
|
||||||
|
script +=
|
||||||
|
(yield config.addINIValues('pcov.enabled=1', os_version, true)) + '\n';
|
||||||
// add command to disable xdebug and enable pcov
|
// add command to disable xdebug and enable pcov
|
||||||
switch (os_version) {
|
switch (os_version) {
|
||||||
case 'linux':
|
case 'linux':
|
||||||
@ -90,12 +95,12 @@ function addCoveragePCOV(version, os_version) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// success
|
// success
|
||||||
script += yield utils.log('PCOV enabled as coverage driver', os_version, 'success', 'Set Coverage Driver');
|
script += yield utils.addLog('$tick', 'coverage: pcov', 'PCOV enabled as coverage driver', os_version);
|
||||||
// version is not supported
|
// version is not supported
|
||||||
break;
|
break;
|
||||||
case '5.6':
|
case '5.6':
|
||||||
case '7.0':
|
case '7.0':
|
||||||
script += yield utils.log('PCOV requires PHP 7.1 or newer', os_version, 'warning', 'Set Coverage Driver');
|
script += yield utils.addLog('$cross', 'pcov', 'PHP 7.1 or newer is required', os_version);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return script;
|
return script;
|
||||||
@ -139,7 +144,7 @@ function disableCoverage(version, os_version) {
|
|||||||
'if(php -m | findstr -i pcov) { Disable-PhpExtension pcov C:\\tools\\php }\n';
|
'if(php -m | findstr -i pcov) { Disable-PhpExtension pcov C:\\tools\\php }\n';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
script += yield utils.log('Disabled Xdebug and PCOV', os_version, 'success', 'Set Coverage Driver');
|
script += yield utils.addLog('$tick', 'none', 'Disabled Xdebug and PCOV', os_version);
|
||||||
return script;
|
return script;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -25,17 +25,29 @@ const utils = __importStar(require("./utils"));
|
|||||||
* @param os_version
|
* @param os_version
|
||||||
* @param log_prefix
|
* @param log_prefix
|
||||||
*/
|
*/
|
||||||
function addExtension(extension_csv, version, os_version, log_prefix = 'Add Extension') {
|
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* () {
|
||||||
|
let script = '\n';
|
||||||
|
switch (no_step) {
|
||||||
|
case true:
|
||||||
|
script +=
|
||||||
|
(yield utils.stepLog('Setup Extensions', os_version)) +
|
||||||
|
(yield utils.suppressOutput(os_version));
|
||||||
|
break;
|
||||||
|
case false:
|
||||||
|
default:
|
||||||
|
script += yield utils.stepLog('Setup Extensions', os_version);
|
||||||
|
break;
|
||||||
|
}
|
||||||
switch (os_version) {
|
switch (os_version) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return yield addExtensionWindows(extension_csv, version, log_prefix);
|
return script + (yield addExtensionWindows(extension_csv, version));
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
return yield addExtensionDarwin(extension_csv, version, log_prefix);
|
return script + (yield addExtensionDarwin(extension_csv, version));
|
||||||
case 'linux':
|
case 'linux':
|
||||||
return yield addExtensionLinux(extension_csv, version, log_prefix);
|
return script + (yield addExtensionLinux(extension_csv, version));
|
||||||
default:
|
default:
|
||||||
return yield utils.log('Platform ' + os_version + ' is not supported', os_version, 'error', log_prefix);
|
return yield utils.log('Platform ' + os_version + ' is not supported', os_version, 'error');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -46,7 +58,7 @@ exports.addExtension = addExtension;
|
|||||||
* @param extension_csv
|
* @param extension_csv
|
||||||
* @param version
|
* @param version
|
||||||
*/
|
*/
|
||||||
function addExtensionDarwin(extension_csv, version, log_prefix) {
|
function addExtensionDarwin(extension_csv, version) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let extensions = yield utils.extensionArray(extension_csv);
|
let extensions = yield utils.extensionArray(extension_csv);
|
||||||
let script = '\n';
|
let script = '\n';
|
||||||
@ -72,15 +84,12 @@ function addExtensionDarwin(extension_csv, version, log_prefix) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
script +=
|
script +=
|
||||||
'add_extension ' +
|
'\nadd_extension ' +
|
||||||
extension +
|
extension +
|
||||||
' "' +
|
' "' +
|
||||||
install_command +
|
install_command +
|
||||||
'" ' +
|
'" ' +
|
||||||
(yield utils.getExtensionPrefix(extension)) +
|
(yield utils.getExtensionPrefix(extension));
|
||||||
' "' +
|
|
||||||
log_prefix +
|
|
||||||
'"\n';
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return script;
|
return script;
|
||||||
@ -93,7 +102,7 @@ exports.addExtensionDarwin = addExtensionDarwin;
|
|||||||
* @param extension_csv
|
* @param extension_csv
|
||||||
* @param version
|
* @param version
|
||||||
*/
|
*/
|
||||||
function addExtensionWindows(extension_csv, version, log_prefix) {
|
function addExtensionWindows(extension_csv, version) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let extensions = yield utils.extensionArray(extension_csv);
|
let extensions = yield utils.extensionArray(extension_csv);
|
||||||
let script = '\n';
|
let script = '\n';
|
||||||
@ -117,15 +126,12 @@ function addExtensionWindows(extension_csv, version, log_prefix) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
script +=
|
script +=
|
||||||
'Add-Extension ' +
|
'\nAdd-Extension ' +
|
||||||
extension +
|
extension +
|
||||||
' "' +
|
' "' +
|
||||||
install_command +
|
install_command +
|
||||||
'" ' +
|
'" ' +
|
||||||
(yield utils.getExtensionPrefix(extension)) +
|
(yield utils.getExtensionPrefix(extension));
|
||||||
' "' +
|
|
||||||
log_prefix +
|
|
||||||
'"\n';
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return script;
|
return script;
|
||||||
@ -138,7 +144,7 @@ exports.addExtensionWindows = addExtensionWindows;
|
|||||||
* @param extension_csv
|
* @param extension_csv
|
||||||
* @param version
|
* @param version
|
||||||
*/
|
*/
|
||||||
function addExtensionLinux(extension_csv, version, log_prefix) {
|
function addExtensionLinux(extension_csv, version) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let extensions = yield utils.extensionArray(extension_csv);
|
let extensions = yield utils.extensionArray(extension_csv);
|
||||||
let script = '\n';
|
let script = '\n';
|
||||||
@ -174,15 +180,12 @@ function addExtensionLinux(extension_csv, version, log_prefix) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
script +=
|
script +=
|
||||||
'add_extension ' +
|
'\nadd_extension ' +
|
||||||
extension +
|
extension +
|
||||||
' "' +
|
' "' +
|
||||||
install_command +
|
install_command +
|
||||||
'" ' +
|
'" ' +
|
||||||
(yield utils.getExtensionPrefix(extension)) +
|
(yield utils.getExtensionPrefix(extension));
|
||||||
' "' +
|
|
||||||
log_prefix +
|
|
||||||
'"\n';
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return script;
|
return script;
|
||||||
|
@ -22,46 +22,56 @@ const utils = __importStar(require("./utils"));
|
|||||||
const extensions = __importStar(require("./extensions"));
|
const extensions = __importStar(require("./extensions"));
|
||||||
const config = __importStar(require("./config"));
|
const config = __importStar(require("./config"));
|
||||||
const coverage = __importStar(require("./coverage"));
|
const coverage = __importStar(require("./coverage"));
|
||||||
|
/**
|
||||||
|
* Build the script
|
||||||
|
*
|
||||||
|
* @param filename
|
||||||
|
* @param version
|
||||||
|
* @param os_version
|
||||||
|
*/
|
||||||
|
function build(filename, version, os_version) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
// taking inputs
|
||||||
|
let extension_csv = yield utils.getInput('extension-csv', false);
|
||||||
|
let ini_values_csv = yield utils.getInput('ini-values-csv', false);
|
||||||
|
let coverage_driver = yield utils.getInput('coverage', false);
|
||||||
|
let script = yield utils.readScript(filename, version, os_version);
|
||||||
|
if (extension_csv) {
|
||||||
|
script += yield extensions.addExtension(extension_csv, version, os_version);
|
||||||
|
}
|
||||||
|
if (ini_values_csv) {
|
||||||
|
script += yield config.addINIValues(ini_values_csv, os_version);
|
||||||
|
}
|
||||||
|
if (coverage_driver) {
|
||||||
|
script += yield coverage.addCoverage(coverage_driver, version, os_version);
|
||||||
|
}
|
||||||
|
yield utils.writeScript(filename, version, script);
|
||||||
|
});
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Run the script
|
* Run the script
|
||||||
*/
|
*/
|
||||||
function run() {
|
function run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
// taking inputs
|
|
||||||
let version = yield utils.getInput('php-version', true);
|
|
||||||
let extension_csv = yield utils.getInput('extension-csv', false);
|
|
||||||
let ini_values_csv = yield utils.getInput('ini-values-csv', false);
|
|
||||||
let coverage_driver = yield utils.getInput('coverage', false);
|
|
||||||
let os_version = process.platform;
|
let os_version = process.platform;
|
||||||
|
let version = yield utils.getInput('php-version', true);
|
||||||
// check the os version and run the respective script
|
// check the os version and run the respective script
|
||||||
if (os_version == 'darwin') {
|
if (os_version == 'darwin') {
|
||||||
let darwin = yield utils.readScript('darwin.sh', version, os_version);
|
yield build('darwin.sh', version, os_version);
|
||||||
darwin += yield extensions.addExtension(extension_csv, version, os_version);
|
|
||||||
darwin += yield config.addINIValues(ini_values_csv, os_version);
|
|
||||||
darwin += yield coverage.addCoverage(coverage_driver, version, os_version);
|
|
||||||
yield utils.writeScript('darwin.sh', version, darwin);
|
|
||||||
yield exec_1.exec('sh ./' + version + 'darwin.sh ' + version);
|
yield exec_1.exec('sh ./' + version + 'darwin.sh ' + version);
|
||||||
}
|
}
|
||||||
else if (os_version == 'win32') {
|
else if (os_version == 'win32') {
|
||||||
let windows = yield utils.readScript('win32.ps1', version, os_version);
|
yield build('win32.ps1', version, os_version);
|
||||||
windows += yield extensions.addExtension(extension_csv, version, os_version);
|
|
||||||
windows += yield config.addINIValues(ini_values_csv, os_version);
|
|
||||||
windows += yield coverage.addCoverage(coverage_driver, version, os_version);
|
|
||||||
yield utils.writeScript('win32.ps1', version, windows);
|
|
||||||
yield exec_1.exec('powershell .\\' + version + 'win32.ps1 -version ' + version);
|
yield exec_1.exec('powershell .\\' + version + 'win32.ps1 -version ' + version);
|
||||||
}
|
}
|
||||||
else if (os_version == 'linux') {
|
else if (os_version == 'linux') {
|
||||||
let linux = yield utils.readScript('linux.sh', version, os_version);
|
yield build('linux.sh', version, os_version);
|
||||||
linux += yield extensions.addExtension(extension_csv, version, os_version);
|
|
||||||
linux += yield config.addINIValues(ini_values_csv, os_version);
|
|
||||||
linux += yield coverage.addCoverage(coverage_driver, version, os_version);
|
|
||||||
yield utils.writeScript('linux.sh', version, linux);
|
|
||||||
yield exec_1.exec('./' + version + 'linux.sh ' + version);
|
yield exec_1.exec('./' + version + 'linux.sh ' + version);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (error) {
|
||||||
core.setFailed(err.message);
|
core.setFailed(error.message);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
110
lib/utils.js
110
lib/utils.js
@ -58,14 +58,14 @@ exports.asyncForEach = asyncForEach;
|
|||||||
*
|
*
|
||||||
* @param files
|
* @param files
|
||||||
*/
|
*/
|
||||||
function readFiles74(files) {
|
function moveFiles(files) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
yield asyncForEach(files, function (filename) {
|
yield asyncForEach(files, function (filename) {
|
||||||
fs.createReadStream(path.join(__dirname, '../src/' + filename)).pipe(fs.createWriteStream(filename.split('/')[1], { mode: 0o755 }));
|
fs.createReadStream(path.join(__dirname, '../src/' + filename)).pipe(fs.createWriteStream(filename.split('/')[1], { mode: 0o755 }));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.readFiles74 = readFiles74;
|
exports.moveFiles = moveFiles;
|
||||||
/**
|
/**
|
||||||
* Read the scripts
|
* Read the scripts
|
||||||
*
|
*
|
||||||
@ -79,7 +79,7 @@ function readScript(filename, version, os_version) {
|
|||||||
case 'darwin':
|
case 'darwin':
|
||||||
switch (version) {
|
switch (version) {
|
||||||
case '7.4':
|
case '7.4':
|
||||||
yield readFiles74([
|
yield moveFiles([
|
||||||
'configs/config.yaml',
|
'configs/config.yaml',
|
||||||
'scripts/xdebug_darwin.sh',
|
'scripts/xdebug_darwin.sh',
|
||||||
'scripts/pcov.sh'
|
'scripts/pcov.sh'
|
||||||
@ -89,18 +89,17 @@ function readScript(filename, version, os_version) {
|
|||||||
break;
|
break;
|
||||||
case 'linux':
|
case 'linux':
|
||||||
let files = ['scripts/phalcon.sh'];
|
let files = ['scripts/phalcon.sh'];
|
||||||
yield readFiles74(['scripts/phalcon.sh']);
|
|
||||||
switch (version) {
|
switch (version) {
|
||||||
case '7.4':
|
case '7.4':
|
||||||
files.concat(['scripts/xdebug.sh', 'scripts/pcov.sh']);
|
files = files.concat(['scripts/xdebug.sh', 'scripts/pcov.sh']);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
yield readFiles74(files);
|
yield moveFiles(files);
|
||||||
break;
|
break;
|
||||||
case 'win32':
|
case 'win32':
|
||||||
switch (version) {
|
switch (version) {
|
||||||
case '7.4':
|
case '7.4':
|
||||||
yield readFiles74(['ext/php_pcov.dll']);
|
yield moveFiles(['ext/php_pcov.dll']);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -166,42 +165,68 @@ function INIArray(ini_values_csv) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.INIArray = INIArray;
|
exports.INIArray = INIArray;
|
||||||
function log(message, os_version, log_type, prefix = '') {
|
/**
|
||||||
|
* Function to log a step
|
||||||
|
*
|
||||||
|
* @param message
|
||||||
|
* @param os_version
|
||||||
|
*/
|
||||||
|
function stepLog(message, os_version) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const unix_color = {
|
switch (os_version) {
|
||||||
|
case 'win32':
|
||||||
|
return 'Step-Log "' + message + '"';
|
||||||
|
case 'linux':
|
||||||
|
case 'darwin':
|
||||||
|
return 'step_log "' + message + '"';
|
||||||
|
default:
|
||||||
|
return yield log('Platform ' + os_version + ' is not supported', os_version, 'error');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
exports.stepLog = stepLog;
|
||||||
|
/**
|
||||||
|
* Function to log a result
|
||||||
|
* @param mark
|
||||||
|
* @param subject
|
||||||
|
* @param message
|
||||||
|
*/
|
||||||
|
function addLog(mark, subject, message, os_version) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
switch (os_version) {
|
||||||
|
case 'win32':
|
||||||
|
return 'Add-Log "' + mark + '" "' + subject + '" "' + message + '"';
|
||||||
|
case 'linux':
|
||||||
|
case 'darwin':
|
||||||
|
return 'add_log "' + mark + '" "' + subject + '" "' + message + '"';
|
||||||
|
default:
|
||||||
|
return yield log('Platform ' + os_version + ' is not supported', os_version, 'error');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
exports.addLog = addLog;
|
||||||
|
/**
|
||||||
|
* Log to console
|
||||||
|
*
|
||||||
|
* @param message
|
||||||
|
* @param os_version
|
||||||
|
* @param log_type
|
||||||
|
* @param prefix
|
||||||
|
*/
|
||||||
|
function log(message, os_version, log_type) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const color = {
|
||||||
error: '31',
|
error: '31',
|
||||||
success: '32',
|
success: '32',
|
||||||
warning: '33'
|
warning: '33'
|
||||||
};
|
};
|
||||||
switch (prefix) {
|
|
||||||
case '':
|
|
||||||
prefix = '';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
prefix = prefix + ': ';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
switch (os_version) {
|
switch (os_version) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
const color = {
|
return ('printf "\\033[' + color[log_type] + ';1m' + message + ' \\033[0m"');
|
||||||
error: 'red',
|
|
||||||
success: 'green',
|
|
||||||
warning: 'yellow'
|
|
||||||
};
|
|
||||||
return ("Write-Host '" +
|
|
||||||
prefix +
|
|
||||||
message +
|
|
||||||
"' -ForegroundColor " +
|
|
||||||
color[log_type]);
|
|
||||||
case 'linux':
|
case 'linux':
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
default:
|
default:
|
||||||
return ('echo "\\033[' +
|
return 'echo "\\033[' + color[log_type] + ';1m' + message + '\\033[0m"';
|
||||||
unix_color[log_type] +
|
|
||||||
';1m' +
|
|
||||||
prefix +
|
|
||||||
message +
|
|
||||||
'\\033[0m"');
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -225,3 +250,22 @@ function getExtensionPrefix(extension) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.getExtensionPrefix = getExtensionPrefix;
|
exports.getExtensionPrefix = getExtensionPrefix;
|
||||||
|
/**
|
||||||
|
* Function to get the suffix to suppress console output
|
||||||
|
*
|
||||||
|
* @param os_version
|
||||||
|
*/
|
||||||
|
function suppressOutput(os_version) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
switch (os_version) {
|
||||||
|
case 'win32':
|
||||||
|
return ' >$null 2>&1';
|
||||||
|
case 'linux':
|
||||||
|
case 'darwin':
|
||||||
|
return ' >/dev/null 2>&1';
|
||||||
|
default:
|
||||||
|
return yield log('Platform ' + os_version + ' is not supported', os_version, 'error');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
exports.suppressOutput = suppressOutput;
|
||||||
|
20
package-lock.json
generated
20
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "setup-php",
|
"name": "setup-php",
|
||||||
"version": "1.4.2",
|
"version": "1.4.3",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -525,9 +525,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@types/jest": {
|
"@types/jest": {
|
||||||
"version": "24.0.18",
|
"version": "24.0.19",
|
||||||
"resolved": "https://registry.npmjs.org/@types/jest/-/jest-24.0.18.tgz",
|
"resolved": "https://registry.npmjs.org/@types/jest/-/jest-24.0.19.tgz",
|
||||||
"integrity": "sha512-jcDDXdjTcrQzdN06+TSVsPPqxvsZA/5QkYfIZlq1JMw7FdP5AZylbOc+6B/cuDurctRe+MziUMtQ3xQdrbjqyQ==",
|
"integrity": "sha512-YYiqfSjocv7lk5H/T+v5MjATYjaTMsUkbDnjGqSMoO88jWdtJXJV4ST/7DKZcoMHMBvB2SeSfyOzZfkxXHR5xg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@types/jest-diff": "*"
|
"@types/jest-diff": "*"
|
||||||
@ -540,9 +540,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@types/node": {
|
"@types/node": {
|
||||||
"version": "12.7.12",
|
"version": "12.11.1",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.7.12.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.11.1.tgz",
|
||||||
"integrity": "sha512-KPYGmfD0/b1eXurQ59fXD1GBzhSQfz6/lKBxkaHX9dKTzjXbK68Zt7yGUxUsCS1jeTy/8aL+d9JEr+S54mpkWQ==",
|
"integrity": "sha512-TJtwsqZ39pqcljJpajeoofYRfeZ7/I/OMUQ5pR4q5wOKf2ocrUvBAZUMhWsOvKx3dVc/aaV5GluBivt0sWqA5A==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@types/normalize-package-data": {
|
"@types/normalize-package-data": {
|
||||||
@ -5021,9 +5021,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"uglify-js": {
|
"uglify-js": {
|
||||||
"version": "3.6.1",
|
"version": "3.6.2",
|
||||||
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.6.1.tgz",
|
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.6.2.tgz",
|
||||||
"integrity": "sha512-+dSJLJpXBb6oMHP+Yvw8hUgElz4gLTh82XuX68QiJVTXaE5ibl6buzhNkQdYhBlIhozWOC9ge16wyRmjG4TwVQ==",
|
"integrity": "sha512-+gh/xFte41GPrgSMJ/oJVq15zYmqr74pY9VoM69UzMzq9NFk4YDylclb1/bhEzZSaUQjbW5RvniHeq1cdtRYjw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "setup-php",
|
"name": "setup-php",
|
||||||
"version": "1.4.2",
|
"version": "1.4.3",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "Setup php action",
|
"description": "Setup php action",
|
||||||
"main": "lib/setup-php.js",
|
"main": "lib/setup-php.js",
|
||||||
|
@ -6,19 +6,35 @@ import * as utils from './utils';
|
|||||||
* @param ini_values_csv
|
* @param ini_values_csv
|
||||||
* @param os_version
|
* @param os_version
|
||||||
*/
|
*/
|
||||||
export async function addINIValues(ini_values_csv: string, os_version: string) {
|
export async function addINIValues(
|
||||||
|
ini_values_csv: string,
|
||||||
|
os_version: string,
|
||||||
|
no_step = false
|
||||||
|
): Promise<string> {
|
||||||
|
let script: string = '\n';
|
||||||
|
switch (no_step) {
|
||||||
|
case true:
|
||||||
|
script +=
|
||||||
|
(await utils.stepLog('Add php.ini values', os_version)) +
|
||||||
|
(await utils.suppressOutput(os_version)) +
|
||||||
|
'\n';
|
||||||
|
break;
|
||||||
|
case false:
|
||||||
|
default:
|
||||||
|
script += (await utils.stepLog('Add php.ini values', os_version)) + '\n';
|
||||||
|
break;
|
||||||
|
}
|
||||||
switch (os_version) {
|
switch (os_version) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return await addINIValuesWindows(ini_values_csv);
|
return script + (await addINIValuesWindows(ini_values_csv));
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
case 'linux':
|
case 'linux':
|
||||||
return await addINIValuesUnix(ini_values_csv);
|
return script + (await addINIValuesUnix(ini_values_csv));
|
||||||
default:
|
default:
|
||||||
return await utils.log(
|
return await utils.log(
|
||||||
'Platform ' + os_version + ' is not supported',
|
'Platform ' + os_version + ' is not supported',
|
||||||
os_version,
|
os_version,
|
||||||
'error',
|
'error'
|
||||||
'Add Config'
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -32,7 +48,12 @@ export async function addINIValuesUnix(
|
|||||||
ini_values_csv: string
|
ini_values_csv: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
let ini_values: Array<string> = await utils.INIArray(ini_values_csv);
|
let ini_values: Array<string> = await utils.INIArray(ini_values_csv);
|
||||||
return '\necho "' + ini_values.join('\n') + '" >> $ini_file\n';
|
let script: string = '\n';
|
||||||
|
await utils.asyncForEach(ini_values, async function(line: string) {
|
||||||
|
script +=
|
||||||
|
(await utils.addLog('$tick', line, 'Added to php.ini', 'linux')) + '\n';
|
||||||
|
});
|
||||||
|
return 'echo "' + ini_values.join('\n') + '" >> $ini_file' + script;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -44,7 +65,15 @@ export async function addINIValuesWindows(
|
|||||||
ini_values_csv: string
|
ini_values_csv: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
let ini_values: Array<string> = await utils.INIArray(ini_values_csv);
|
let ini_values: Array<string> = await utils.INIArray(ini_values_csv);
|
||||||
|
let script: string = '\n';
|
||||||
|
await utils.asyncForEach(ini_values, async function(line: string) {
|
||||||
|
script +=
|
||||||
|
(await utils.addLog('$tick', line, 'Added to php.ini', 'win32')) + '\n';
|
||||||
|
});
|
||||||
return (
|
return (
|
||||||
'Add-Content C:\\tools\\php\\php.ini "' + ini_values.join('\n') + '"\n'
|
'Add-Content C:\\tools\\php\\php.ini "' +
|
||||||
|
ini_values.join('\n') +
|
||||||
|
'"' +
|
||||||
|
script
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -15,13 +15,15 @@ export async function addCoverage(
|
|||||||
os_version: string
|
os_version: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
coverage_driver.toLowerCase();
|
coverage_driver.toLowerCase();
|
||||||
|
let script: string =
|
||||||
|
'\n' + (await utils.stepLog('Setup Coverage', os_version));
|
||||||
switch (coverage_driver) {
|
switch (coverage_driver) {
|
||||||
case 'pcov':
|
case 'pcov':
|
||||||
return addCoveragePCOV(version, os_version);
|
return script + (await addCoveragePCOV(version, os_version));
|
||||||
case 'xdebug':
|
case 'xdebug':
|
||||||
return addCoverageXdebug(version, os_version);
|
return script + (await addCoverageXdebug(version, os_version));
|
||||||
case 'none':
|
case 'none':
|
||||||
return disableCoverage(version, os_version);
|
return script + (await disableCoverage(version, os_version));
|
||||||
default:
|
default:
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
@ -34,21 +36,17 @@ export async function addCoverage(
|
|||||||
* @param os_version
|
* @param os_version
|
||||||
*/
|
*/
|
||||||
export async function addCoverageXdebug(version: string, os_version: string) {
|
export async function addCoverageXdebug(version: string, os_version: string) {
|
||||||
let script: string = '\n';
|
return (
|
||||||
script += await extensions.addExtension(
|
(await extensions.addExtension('xdebug', version, os_version, true)) +
|
||||||
|
(await utils.suppressOutput(os_version)) +
|
||||||
|
'\n' +
|
||||||
|
(await utils.addLog(
|
||||||
|
'$tick',
|
||||||
'xdebug',
|
'xdebug',
|
||||||
version,
|
|
||||||
os_version,
|
|
||||||
'Set Coverage Driver'
|
|
||||||
);
|
|
||||||
script += await utils.log(
|
|
||||||
'Xdebug enabled as coverage driver',
|
'Xdebug enabled as coverage driver',
|
||||||
os_version,
|
os_version
|
||||||
'success',
|
))
|
||||||
'Set Coverage Driver'
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return script;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -61,13 +59,12 @@ export async function addCoveragePCOV(version: string, os_version: string) {
|
|||||||
let script: string = '\n';
|
let script: string = '\n';
|
||||||
switch (version) {
|
switch (version) {
|
||||||
default:
|
default:
|
||||||
script += await extensions.addExtension(
|
script +=
|
||||||
'pcov',
|
(await extensions.addExtension('pcov', version, os_version, true)) +
|
||||||
version,
|
(await utils.suppressOutput(os_version)) +
|
||||||
os_version,
|
'\n';
|
||||||
'Set Coverage Driver'
|
script +=
|
||||||
);
|
(await config.addINIValues('pcov.enabled=1', os_version, true)) + '\n';
|
||||||
script += await config.addINIValues('pcov.enabled=1', os_version);
|
|
||||||
|
|
||||||
// add command to disable xdebug and enable pcov
|
// add command to disable xdebug and enable pcov
|
||||||
switch (os_version) {
|
switch (os_version) {
|
||||||
@ -90,21 +87,21 @@ export async function addCoveragePCOV(version: string, os_version: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// success
|
// success
|
||||||
script += await utils.log(
|
script += await utils.addLog(
|
||||||
|
'$tick',
|
||||||
|
'coverage: pcov',
|
||||||
'PCOV enabled as coverage driver',
|
'PCOV enabled as coverage driver',
|
||||||
os_version,
|
os_version
|
||||||
'success',
|
|
||||||
'Set Coverage Driver'
|
|
||||||
);
|
);
|
||||||
// version is not supported
|
// version is not supported
|
||||||
break;
|
break;
|
||||||
case '5.6':
|
case '5.6':
|
||||||
case '7.0':
|
case '7.0':
|
||||||
script += await utils.log(
|
script += await utils.addLog(
|
||||||
'PCOV requires PHP 7.1 or newer',
|
'$cross',
|
||||||
os_version,
|
'pcov',
|
||||||
'warning',
|
'PHP 7.1 or newer is required',
|
||||||
'Set Coverage Driver'
|
os_version
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -148,11 +145,11 @@ export async function disableCoverage(version: string, os_version: string) {
|
|||||||
'if(php -m | findstr -i pcov) { Disable-PhpExtension pcov C:\\tools\\php }\n';
|
'if(php -m | findstr -i pcov) { Disable-PhpExtension pcov C:\\tools\\php }\n';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
script += await utils.log(
|
script += await utils.addLog(
|
||||||
|
'$tick',
|
||||||
|
'none',
|
||||||
'Disabled Xdebug and PCOV',
|
'Disabled Xdebug and PCOV',
|
||||||
os_version,
|
os_version
|
||||||
'success',
|
|
||||||
'Set Coverage Driver'
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return script;
|
return script;
|
||||||
|
@ -12,21 +12,33 @@ export async function addExtension(
|
|||||||
extension_csv: string,
|
extension_csv: string,
|
||||||
version: string,
|
version: string,
|
||||||
os_version: string,
|
os_version: string,
|
||||||
log_prefix = 'Add Extension'
|
no_step = false
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
|
let script: string = '\n';
|
||||||
|
switch (no_step) {
|
||||||
|
case true:
|
||||||
|
script +=
|
||||||
|
(await utils.stepLog('Setup Extensions', os_version)) +
|
||||||
|
(await utils.suppressOutput(os_version));
|
||||||
|
break;
|
||||||
|
case false:
|
||||||
|
default:
|
||||||
|
script += await utils.stepLog('Setup Extensions', os_version);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
switch (os_version) {
|
switch (os_version) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return await addExtensionWindows(extension_csv, version, log_prefix);
|
return script + (await addExtensionWindows(extension_csv, version));
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
return await addExtensionDarwin(extension_csv, version, log_prefix);
|
return script + (await addExtensionDarwin(extension_csv, version));
|
||||||
case 'linux':
|
case 'linux':
|
||||||
return await addExtensionLinux(extension_csv, version, log_prefix);
|
return script + (await addExtensionLinux(extension_csv, version));
|
||||||
default:
|
default:
|
||||||
return await utils.log(
|
return await utils.log(
|
||||||
'Platform ' + os_version + ' is not supported',
|
'Platform ' + os_version + ' is not supported',
|
||||||
os_version,
|
os_version,
|
||||||
'error',
|
'error'
|
||||||
log_prefix
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -39,8 +51,7 @@ export async function addExtension(
|
|||||||
*/
|
*/
|
||||||
export async function addExtensionDarwin(
|
export async function addExtensionDarwin(
|
||||||
extension_csv: string,
|
extension_csv: string,
|
||||||
version: string,
|
version: string
|
||||||
log_prefix: string
|
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
let extensions: Array<string> = await utils.extensionArray(extension_csv);
|
let extensions: Array<string> = await utils.extensionArray(extension_csv);
|
||||||
let script: string = '\n';
|
let script: string = '\n';
|
||||||
@ -65,15 +76,12 @@ export async function addExtensionDarwin(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
script +=
|
script +=
|
||||||
'add_extension ' +
|
'\nadd_extension ' +
|
||||||
extension +
|
extension +
|
||||||
' "' +
|
' "' +
|
||||||
install_command +
|
install_command +
|
||||||
'" ' +
|
'" ' +
|
||||||
(await utils.getExtensionPrefix(extension)) +
|
(await utils.getExtensionPrefix(extension));
|
||||||
' "' +
|
|
||||||
log_prefix +
|
|
||||||
'"\n';
|
|
||||||
});
|
});
|
||||||
return script;
|
return script;
|
||||||
}
|
}
|
||||||
@ -86,8 +94,7 @@ export async function addExtensionDarwin(
|
|||||||
*/
|
*/
|
||||||
export async function addExtensionWindows(
|
export async function addExtensionWindows(
|
||||||
extension_csv: string,
|
extension_csv: string,
|
||||||
version: string,
|
version: string
|
||||||
log_prefix: string
|
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
let extensions: Array<string> = await utils.extensionArray(extension_csv);
|
let extensions: Array<string> = await utils.extensionArray(extension_csv);
|
||||||
let script: string = '\n';
|
let script: string = '\n';
|
||||||
@ -112,15 +119,12 @@ export async function addExtensionWindows(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
script +=
|
script +=
|
||||||
'Add-Extension ' +
|
'\nAdd-Extension ' +
|
||||||
extension +
|
extension +
|
||||||
' "' +
|
' "' +
|
||||||
install_command +
|
install_command +
|
||||||
'" ' +
|
'" ' +
|
||||||
(await utils.getExtensionPrefix(extension)) +
|
(await utils.getExtensionPrefix(extension));
|
||||||
' "' +
|
|
||||||
log_prefix +
|
|
||||||
'"\n';
|
|
||||||
});
|
});
|
||||||
return script;
|
return script;
|
||||||
}
|
}
|
||||||
@ -133,8 +137,7 @@ export async function addExtensionWindows(
|
|||||||
*/
|
*/
|
||||||
export async function addExtensionLinux(
|
export async function addExtensionLinux(
|
||||||
extension_csv: string,
|
extension_csv: string,
|
||||||
version: string,
|
version: string
|
||||||
log_prefix: string
|
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
let extensions: Array<string> = await utils.extensionArray(extension_csv);
|
let extensions: Array<string> = await utils.extensionArray(extension_csv);
|
||||||
let script: string = '\n';
|
let script: string = '\n';
|
||||||
@ -170,15 +173,12 @@ export async function addExtensionLinux(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
script +=
|
script +=
|
||||||
'add_extension ' +
|
'\nadd_extension ' +
|
||||||
extension +
|
extension +
|
||||||
' "' +
|
' "' +
|
||||||
install_command +
|
install_command +
|
||||||
'" ' +
|
'" ' +
|
||||||
(await utils.getExtensionPrefix(extension)) +
|
(await utils.getExtensionPrefix(extension));
|
||||||
' "' +
|
|
||||||
log_prefix +
|
|
||||||
'"\n';
|
|
||||||
});
|
});
|
||||||
return script;
|
return script;
|
||||||
}
|
}
|
||||||
|
@ -6,75 +6,51 @@ import * as config from './config';
|
|||||||
import * as coverage from './coverage';
|
import * as coverage from './coverage';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run the script
|
* Build the script
|
||||||
|
*
|
||||||
|
* @param filename
|
||||||
|
* @param version
|
||||||
|
* @param os_version
|
||||||
*/
|
*/
|
||||||
async function run() {
|
async function build(filename: string, version: string, os_version: string) {
|
||||||
try {
|
|
||||||
// taking inputs
|
// taking inputs
|
||||||
let version: string = await utils.getInput('php-version', true);
|
|
||||||
let extension_csv: string = await utils.getInput('extension-csv', false);
|
let extension_csv: string = await utils.getInput('extension-csv', false);
|
||||||
let ini_values_csv: string = await utils.getInput('ini-values-csv', false);
|
let ini_values_csv: string = await utils.getInput('ini-values-csv', false);
|
||||||
let coverage_driver: string = await utils.getInput('coverage', false);
|
let coverage_driver: string = await utils.getInput('coverage', false);
|
||||||
|
|
||||||
|
let script: string = await utils.readScript(filename, version, os_version);
|
||||||
|
if (extension_csv) {
|
||||||
|
script += await extensions.addExtension(extension_csv, version, os_version);
|
||||||
|
}
|
||||||
|
if (ini_values_csv) {
|
||||||
|
script += await config.addINIValues(ini_values_csv, os_version);
|
||||||
|
}
|
||||||
|
if (coverage_driver) {
|
||||||
|
script += await coverage.addCoverage(coverage_driver, version, os_version);
|
||||||
|
}
|
||||||
|
await utils.writeScript(filename, version, script);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run the script
|
||||||
|
*/
|
||||||
|
async function run() {
|
||||||
|
try {
|
||||||
let os_version: string = process.platform;
|
let os_version: string = process.platform;
|
||||||
|
let version: string = await utils.getInput('php-version', true);
|
||||||
// check the os version and run the respective script
|
// check the os version and run the respective script
|
||||||
if (os_version == 'darwin') {
|
if (os_version == 'darwin') {
|
||||||
let darwin: string = await utils.readScript(
|
await build('darwin.sh', version, os_version);
|
||||||
'darwin.sh',
|
|
||||||
version,
|
|
||||||
os_version
|
|
||||||
);
|
|
||||||
|
|
||||||
darwin += await extensions.addExtension(
|
|
||||||
extension_csv,
|
|
||||||
version,
|
|
||||||
os_version
|
|
||||||
);
|
|
||||||
darwin += await config.addINIValues(ini_values_csv, os_version);
|
|
||||||
darwin += await coverage.addCoverage(
|
|
||||||
coverage_driver,
|
|
||||||
version,
|
|
||||||
os_version
|
|
||||||
);
|
|
||||||
await utils.writeScript('darwin.sh', version, darwin);
|
|
||||||
await exec('sh ./' + version + 'darwin.sh ' + version);
|
await exec('sh ./' + version + 'darwin.sh ' + version);
|
||||||
} else if (os_version == 'win32') {
|
} else if (os_version == 'win32') {
|
||||||
let windows: string = await utils.readScript(
|
await build('win32.ps1', version, os_version);
|
||||||
'win32.ps1',
|
|
||||||
version,
|
|
||||||
os_version
|
|
||||||
);
|
|
||||||
windows += await extensions.addExtension(
|
|
||||||
extension_csv,
|
|
||||||
version,
|
|
||||||
os_version
|
|
||||||
);
|
|
||||||
windows += await config.addINIValues(ini_values_csv, os_version);
|
|
||||||
windows += await coverage.addCoverage(
|
|
||||||
coverage_driver,
|
|
||||||
version,
|
|
||||||
os_version
|
|
||||||
);
|
|
||||||
await utils.writeScript('win32.ps1', version, windows);
|
|
||||||
await exec('powershell .\\' + version + 'win32.ps1 -version ' + version);
|
await exec('powershell .\\' + version + 'win32.ps1 -version ' + version);
|
||||||
} else if (os_version == 'linux') {
|
} else if (os_version == 'linux') {
|
||||||
let linux: string = await utils.readScript(
|
await build('linux.sh', version, os_version);
|
||||||
'linux.sh',
|
|
||||||
version,
|
|
||||||
os_version
|
|
||||||
);
|
|
||||||
linux += await extensions.addExtension(
|
|
||||||
extension_csv,
|
|
||||||
version,
|
|
||||||
os_version
|
|
||||||
);
|
|
||||||
linux += await config.addINIValues(ini_values_csv, os_version);
|
|
||||||
linux += await coverage.addCoverage(coverage_driver, version, os_version);
|
|
||||||
await utils.writeScript('linux.sh', version, linux);
|
|
||||||
await exec('./' + version + 'linux.sh ' + version);
|
await exec('./' + version + 'linux.sh ' + version);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (error) {
|
||||||
core.setFailed(err.message);
|
core.setFailed(error.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,28 @@
|
|||||||
|
tick="✓"
|
||||||
|
cross="✗"
|
||||||
|
|
||||||
|
step_log() {
|
||||||
|
message=$1
|
||||||
|
printf "\n\033[90;1m==> \033[0m\033[37;1m%s\033[0m\n" "$message"
|
||||||
|
}
|
||||||
|
|
||||||
|
add_log() {
|
||||||
|
mark=$1
|
||||||
|
subject=$2
|
||||||
|
message=$3
|
||||||
|
if [ "$mark" = "$tick" ]; then
|
||||||
|
printf "\033[32;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
|
||||||
|
else
|
||||||
|
printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
|
||||||
|
fi
|
||||||
|
}
|
||||||
version='7.4.0RC3'
|
version='7.4.0RC3'
|
||||||
brew install pkg-config autoconf bison re2c openssl@1.1 krb5 enchant libffi freetype intltool icu4c libiconv t1lib gd libzip gmp tidyp libxml2 libxslt postgresql curl >/dev/null 2>&1
|
step_log "Setup dependencies"
|
||||||
|
for package in pkg-config autoconf bison re2c openssl@1.1 krb5 enchant libffi freetype intltool icu4c libiconv t1lib gd libzip gmp tidyp libxml2 libxslt postgresql curl;
|
||||||
|
do
|
||||||
|
brew install "$package" >/dev/null 2>&1
|
||||||
|
add_log "$tick" "$package" "Installed"
|
||||||
|
done
|
||||||
brew link icu4c gettext --force >/dev/null 2>&1
|
brew link icu4c gettext --force >/dev/null 2>&1
|
||||||
|
|
||||||
for package in gettext gmp krb5 icu4c bison openssl@1.1 libxml2 libffi libxslt libiconv pkgconfig enchant krb5 readline libedit freetype;
|
for package in gettext gmp krb5 icu4c bison openssl@1.1 libxml2 libffi libxslt libiconv pkgconfig enchant krb5 readline libedit freetype;
|
||||||
@ -36,6 +59,8 @@ echo 'export EXTRA_LIBS="/usr/local/opt/readline/lib/libhistory.dylib
|
|||||||
/usr/local/opt/icu4c/lib/libicuuc.dylib"'
|
/usr/local/opt/icu4c/lib/libicuuc.dylib"'
|
||||||
} >> ~/.bash_profile
|
} >> ~/.bash_profile
|
||||||
config_file=$(pwd)/config.yaml
|
config_file=$(pwd)/config.yaml
|
||||||
|
|
||||||
|
step_log "Setup PHPBrew"
|
||||||
curl -L -O https://github.com/phpbrew/phpbrew/raw/master/phpbrew >/dev/null 2>&1
|
curl -L -O https://github.com/phpbrew/phpbrew/raw/master/phpbrew >/dev/null 2>&1
|
||||||
chmod +x ./phpbrew
|
chmod +x ./phpbrew
|
||||||
sudo mv phpbrew /usr/local/bin/phpbrew
|
sudo mv phpbrew /usr/local/bin/phpbrew
|
||||||
@ -47,37 +72,43 @@ sudo chmod -R 777 /opt/phpbrew
|
|||||||
export PHPBREW_ROOT=/opt/phpbrew
|
export PHPBREW_ROOT=/opt/phpbrew
|
||||||
export PHPBREW_HOME=/opt/phpbrew
|
export PHPBREW_HOME=/opt/phpbrew
|
||||||
echo "[[ -e ~/.phpbrew/bashrc ]] && source ~/.phpbrew/bashrc" >> ~/.bashrc
|
echo "[[ -e ~/.phpbrew/bashrc ]] && source ~/.phpbrew/bashrc" >> ~/.bashrc
|
||||||
|
add_log "$tick" "PHPBrew" "Installed"
|
||||||
|
|
||||||
source ~/.bash_profile >/dev/null 2>&1
|
source ~/.bash_profile >/dev/null 2>&1
|
||||||
source ~/.bashrc >/dev/null 2>&1
|
source ~/.bashrc >/dev/null 2>&1
|
||||||
|
|
||||||
|
step_log "Setup PHP and Composer"
|
||||||
phpbrew install -j 6 $version +dev >/dev/null 2>&1
|
phpbrew install -j 6 $version +dev >/dev/null 2>&1
|
||||||
phpbrew switch $version
|
phpbrew switch $version
|
||||||
sudo ln -sf /opt/phpbrew/php/php-$version/bin/* /usr/local/bin/
|
sudo ln -sf /opt/phpbrew/php/php-$version/bin/* /usr/local/bin/
|
||||||
sudo ln -sf /opt/phpbrew/php/php-$version/etc/php.ini /etc/php.ini
|
sudo ln -sf /opt/phpbrew/php/php-$version/etc/php.ini /etc/php.ini
|
||||||
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
||||||
ext_dir=$(php -i | grep "extension_dir => /opt" | sed -e "s|.*=> s*||")
|
ext_dir=$(php -i | grep "extension_dir => /opt" | sed -e "s|.*=> s*||")
|
||||||
pecl config-set php_ini "$ini_file"
|
pecl config-set php_ini "$ini_file" >/dev/null 2>&1
|
||||||
sudo chmod 777 "$ini_file"
|
sudo chmod 777 "$ini_file"
|
||||||
brew install composer
|
brew install composer >/dev/null 2>&1
|
||||||
|
|
||||||
add_extension()
|
add_log "$tick" "PHP" "Installed PHP$version"
|
||||||
{
|
add_log "$tick" "Composer" "Installed"
|
||||||
|
|
||||||
|
add_extension() {
|
||||||
extension=$1
|
extension=$1
|
||||||
install_command=$2
|
install_command=$2
|
||||||
prefix=$3
|
prefix=$3
|
||||||
log_prefix=$4
|
|
||||||
if ! php -m | grep -i -q "$extension" && [ -e "$ext_dir/$extension.so" ]; then
|
if ! php -m | grep -i -q "$extension" && [ -e "$ext_dir/$extension.so" ]; then
|
||||||
echo "$prefix=$extension" >> "$ini_file" && echo "\033[32;1m$log_prefix: Enabled $extension\033[0m";
|
echo "$prefix=$extension" >>"$ini_file" && add_log "$tick" "$extension" "Enabled"
|
||||||
elif php -m | grep -i -q "$extension"; then
|
elif php -m | grep -i -q "$extension"; then
|
||||||
echo "\033[33;1m$log_prefix: $extension was already enabled\033[0m";
|
add_log "$tick" "$extension" "Enabled"
|
||||||
elif ! php -m | grep -i -q "$extension"; then
|
elif ! php -m | grep -i -q "$extension"; then
|
||||||
exists=$(curl -sL https://pecl.php.net/json.php?package="$extension" -w "%{http_code}" -o /dev/null)
|
exists=$(curl -sL https://pecl.php.net/json.php?package="$extension" -w "%{http_code}" -o /dev/null)
|
||||||
if [ "$exists" = "200" ]; then
|
if [ "$exists" = "200" ]; then
|
||||||
|
(
|
||||||
eval "$install_command" && \
|
eval "$install_command" && \
|
||||||
echo "\033[32;1m$log_prefix: Installed and enabled $extension\033[0m" || \
|
add_log "$tick" "$extension" "Installed and enabled"
|
||||||
echo "\033[31;1m$log_prefix: Could not install $extension on PHP$version\033[0m";
|
) || add_log "$cross" "$extension" "Could not install $extension on PHP$version"
|
||||||
else
|
else
|
||||||
if ! php -m | grep -i -q "$extension"; then
|
if ! php -m | grep -i -q "$extension"; then
|
||||||
echo "\033[31;1m$log_prefix: Could not find $extension for PHP$version on PECL\033[0m";
|
add_log "$cross" "$extension" "Could not find $extension for PHP$version on PECL"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -1,37 +1,57 @@
|
|||||||
|
tick="✓"
|
||||||
|
cross="✗"
|
||||||
|
|
||||||
|
step_log() {
|
||||||
|
message=$1
|
||||||
|
printf "\n\033[90;1m==> \033[0m\033[37;1m%s\033[0m\n" "$message"
|
||||||
|
}
|
||||||
|
|
||||||
|
add_log() {
|
||||||
|
mark=$1
|
||||||
|
subject=$2
|
||||||
|
message=$3
|
||||||
|
if [ "$mark" = "$tick" ]; then
|
||||||
|
printf "\033[32;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
|
||||||
|
else
|
||||||
|
printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
version=$1
|
version=$1
|
||||||
export HOMEBREW_NO_INSTALL_CLEANUP=TRUE
|
export HOMEBREW_NO_INSTALL_CLEANUP=TRUE
|
||||||
if [ "$1" = "5.6" ] || [ "$1" = "7.0" ]; then
|
if [ "$1" = "5.6" ] || [ "$1" = "7.0" ]; then
|
||||||
brew tap exolnet/homebrew-deprecated >/dev/null 2>&1
|
brew tap exolnet/homebrew-deprecated >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
|
step_log "Setup PHP and Composer"
|
||||||
brew install php@"$1" composer >/dev/null 2>&1
|
brew install php@"$1" composer >/dev/null 2>&1
|
||||||
brew link --force --overwrite php@"$1" >/dev/null 2>&1
|
brew link --force --overwrite php@"$1" >/dev/null 2>&1
|
||||||
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
ini_file=$(php -d "date.timezone=UTC" --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
||||||
|
echo "date.timezone=UTC" >> "$ini_file"
|
||||||
ext_dir=$(php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||")
|
ext_dir=$(php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||")
|
||||||
sudo chmod 777 "$ini_file"
|
sudo chmod 777 "$ini_file"
|
||||||
mkdir -p "$(pecl config-get ext_dir)"
|
mkdir -p "$(pecl config-get ext_dir)"
|
||||||
composer global require hirak/prestissimo >/dev/null 2>&1
|
composer global require hirak/prestissimo >/dev/null 2>&1
|
||||||
php -v
|
add_log "$tick" "PHP" "Installed PHP$version"
|
||||||
composer -V
|
add_log "$tick" "Composer" "Installed"
|
||||||
|
|
||||||
add_extension()
|
add_extension() {
|
||||||
{
|
|
||||||
extension=$1
|
extension=$1
|
||||||
install_command=$2
|
install_command=$2
|
||||||
prefix=$3
|
prefix=$3
|
||||||
log_prefix=$4
|
|
||||||
if ! php -m | grep -i -q "$extension" && [ -e "$ext_dir/$extension.so" ]; then
|
if ! php -m | grep -i -q "$extension" && [ -e "$ext_dir/$extension.so" ]; then
|
||||||
echo "$prefix=$extension" >> "$ini_file" && echo "\033[32;1m$log_prefix: Enabled $extension\033[0m";
|
echo "$prefix=$extension" >>"$ini_file" && add_log $tick "$extension" "Enabled"
|
||||||
elif php -m | grep -i -q "$extension"; then
|
elif php -m | grep -i -q "$extension"; then
|
||||||
echo "\033[33;1m$log_prefix: $extension was already enabled\033[0m";
|
add_log "$tick" "$extension" "Enabled"
|
||||||
elif ! php -m | grep -i -q "$extension"; then
|
elif ! php -m | grep -i -q "$extension"; then
|
||||||
exists=$(curl -sL https://pecl.php.net/json.php?package="$extension" -w "%{http_code}" -o /dev/null)
|
exists=$(curl -sL https://pecl.php.net/json.php?package="$extension" -w "%{http_code}" -o /dev/null)
|
||||||
if [ "$exists" = "200" ]; then
|
if [ "$exists" = "200" ]; then
|
||||||
|
(
|
||||||
eval "$install_command" && \
|
eval "$install_command" && \
|
||||||
echo "\033[32;1m$log_prefix: Installed and enabled $extension\033[0m" || \
|
add_log "$tick" "$extension" "Installed and enabled"
|
||||||
echo "\033[31;1m$log_prefix: Could not install $extension on PHP$version\033[0m";
|
) || add_log "$cross" "$extension" "Could not install $extension on PHP$version"
|
||||||
else
|
else
|
||||||
if ! php -m | grep -i -q "$extension"; then
|
if ! php -m | grep -i -q "$extension"; then
|
||||||
echo "\033[31;1m$log_prefix: Could not find $extension for PHP$version on PECL\033[0m";
|
add_log "$cross" "$extension" "Could not find $extension for PHP$version on PECL"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -1,5 +1,25 @@
|
|||||||
|
tick="✓"
|
||||||
|
cross="✗"
|
||||||
|
|
||||||
|
step_log() {
|
||||||
|
message=$1
|
||||||
|
printf "\n\033[90;1m==> \033[0m\033[37;1m%s\033[0m\n" "$message"
|
||||||
|
}
|
||||||
|
|
||||||
|
add_log() {
|
||||||
|
mark=$1
|
||||||
|
subject=$2
|
||||||
|
message=$3
|
||||||
|
if [ "$mark" = "$tick" ]; then
|
||||||
|
printf "\033[32;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
|
||||||
|
else
|
||||||
|
printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
|
||||||
|
fi
|
||||||
|
}
|
||||||
existing_version=$(php-config --version | cut -c 1-3)
|
existing_version=$(php-config --version | cut -c 1-3)
|
||||||
version=$1
|
version=$1
|
||||||
|
status="Switched to PHP$version"
|
||||||
|
step_log "Setup PHP and Composer"
|
||||||
if [ "$existing_version" != "$1" ]; then
|
if [ "$existing_version" != "$1" ]; then
|
||||||
if [ ! -e "/usr/bin/php$1" ]; then
|
if [ ! -e "/usr/bin/php$1" ]; then
|
||||||
sudo DEBIAN_FRONTEND=noninteractive add-apt-repository ppa:ondrej/php -y >/dev/null 2>&1
|
sudo DEBIAN_FRONTEND=noninteractive add-apt-repository ppa:ondrej/php -y >/dev/null 2>&1
|
||||||
@ -9,14 +29,23 @@ if [ "$existing_version" != "$1" ]; then
|
|||||||
else
|
else
|
||||||
sudo DEBIAN_FRONTEND=noninteractive apt install -y php"$1" php"$1"-dev curl php"$1"-curl >/dev/null 2>&1
|
sudo DEBIAN_FRONTEND=noninteractive apt install -y php"$1" php"$1"-dev curl php"$1"-curl >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
|
status="Installed PHP$version"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
for tool in php phar phar.phar php-cgi php-config phpize; do
|
for tool in php phar phar.phar php-cgi php-config phpize; do
|
||||||
if [ -e "/usr/bin/$tool$1" ]; then
|
if [ -e "/usr/bin/$tool$1" ]; then
|
||||||
sudo update-alternatives --set $tool /usr/bin/"$tool$1" &
|
sudo update-alternatives --set $tool /usr/bin/"$tool$1" >/dev/null 2>&1 &
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
||||||
|
ext_dir=$(php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||")
|
||||||
|
sudo chmod 777 "$ini_file"
|
||||||
|
sudo mkdir -p /run/php
|
||||||
|
add_log "$tick" "PHP" "$status"
|
||||||
|
|
||||||
if [ ! -e "/usr/bin/composer" ]; then
|
if [ ! -e "/usr/bin/composer" ]; then
|
||||||
curl -s -L https://getcomposer.org/installer > composer-setup.php
|
curl -s -L https://getcomposer.org/installer > composer-setup.php
|
||||||
if [ "$(curl -s https://composer.github.io/installer.sig)" != "$(php -r "echo hash_file('sha384', 'composer-setup.php');")" ]; then
|
if [ "$(curl -s https://composer.github.io/installer.sig)" != "$(php -r "echo hash_file('sha384', 'composer-setup.php');")" ]; then
|
||||||
@ -27,28 +56,22 @@ if [ ! -e "/usr/bin/composer" ]; then
|
|||||||
fi
|
fi
|
||||||
rm composer-setup.php
|
rm composer-setup.php
|
||||||
fi
|
fi
|
||||||
|
|
||||||
composer global require hirak/prestissimo >/dev/null 2>&1
|
composer global require hirak/prestissimo >/dev/null 2>&1
|
||||||
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
add_log "$tick" "Composer" "Installed"
|
||||||
ext_dir=$(php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||")
|
|
||||||
sudo chmod 777 "$ini_file"
|
|
||||||
sudo mkdir -p /run/php
|
|
||||||
php -v
|
|
||||||
composer -V
|
|
||||||
|
|
||||||
add_extension()
|
add_extension()
|
||||||
{
|
{
|
||||||
extension=$1
|
extension=$1
|
||||||
install_command=$2
|
install_command=$2
|
||||||
prefix=$3
|
prefix=$3
|
||||||
log_prefix=$4
|
|
||||||
if ! php -m | grep -i -q "$extension" && [ -e "$ext_dir/$extension.so" ]; then
|
if ! php -m | grep -i -q "$extension" && [ -e "$ext_dir/$extension.so" ]; then
|
||||||
echo "$prefix=$extension" >> "$ini_file" && echo "\033[32;1m$log_prefix: Enabled $extension\033[0m";
|
echo "$prefix=$extension" >> "$ini_file" && add_log "$tick" "$extension" "Enabled"
|
||||||
elif php -m | grep -i -q "$extension"; then
|
elif php -m | grep -i -q "$extension"; then
|
||||||
echo "\033[33;1m$log_prefix: $extension was already enabled\033[0m";
|
add_log "$tick" "$extension" "Enabled"
|
||||||
elif ! php -m | grep -i -q "$extension"; then
|
elif ! php -m | grep -i -q "$extension"; then
|
||||||
|
(
|
||||||
eval "$install_command" && \
|
eval "$install_command" && \
|
||||||
echo "\033[32;1m$log_prefix: Installed and enabled $extension\033[0m" || \
|
add_log "$tick" "$extension" "Installed and enabled"
|
||||||
echo "\033[31;1m$log_prefix: Could not find php$version-$extension on APT repository\033[0m";
|
) || add_log "$cross" "$extension" "Could not find php$version-$extension"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
@ -2,58 +2,69 @@ param (
|
|||||||
[Parameter(Mandatory=$true)][string]$version = "7.3"
|
[Parameter(Mandatory=$true)][string]$version = "7.3"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
$tick = ([char]8730)
|
||||||
|
$cross = ([char]10007)
|
||||||
|
|
||||||
|
Function Step-Log($message) {
|
||||||
|
printf "\n\033[90;1m==> \033[0m\033[37;1m%s \033[0m" $message
|
||||||
|
}
|
||||||
|
|
||||||
|
Function Add-Log($mark, $subject, $message) {
|
||||||
|
$code = if($mark -eq $cross) {"31"} else {"32"}
|
||||||
|
printf "\033[%s;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m" $code $mark $subject $message
|
||||||
|
}
|
||||||
|
|
||||||
if($version -eq '7.4') {
|
if($version -eq '7.4') {
|
||||||
$version = '7.4RC'
|
$version = '7.4RC'
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Host "Installing PhpManager" -ForegroundColor Blue
|
Step-Log "Setup PhpManager"
|
||||||
Install-Module -Name PhpManager -Force -Scope CurrentUser
|
Install-Module -Name PhpManager -Force -Scope CurrentUser
|
||||||
|
printf "\n"
|
||||||
|
Add-Log $tick "PhpManager" "Installed"
|
||||||
|
|
||||||
$installed = $($(php -v)[0] -join '')[4..6] -join ''
|
$installed = $($(php -v)[0] -join '')[4..6] -join ''
|
||||||
|
Step-Log "Setup PHP and Composer"
|
||||||
|
$status = "Switched to PHP$version"
|
||||||
if($installed -ne $version) {
|
if($installed -ne $version) {
|
||||||
if($version -lt '7.0') {
|
if($version -lt '7.0') {
|
||||||
Write-Host "Installing VcRedist"
|
|
||||||
Install-Module -Name VcRedist -Force
|
Install-Module -Name VcRedist -Force
|
||||||
}
|
}
|
||||||
Write-Host "Installing PHP" -ForegroundColor Blue
|
|
||||||
Uninstall-Php C:\tools\php
|
Uninstall-Php C:\tools\php
|
||||||
Install-Php -Version $version -Architecture x86 -ThreadSafe $true -InstallVC -Path C:\tools\php$version -TimeZone UTC -InitialPhpIni Production -Force
|
Install-Php -Version $version -Architecture x86 -ThreadSafe $true -InstallVC -Path C:\tools\php$version -TimeZone UTC -InitialPhpIni Production -Force >$null 2>&1
|
||||||
Write-Host "Switch PHP" -ForegroundColor Blue
|
|
||||||
(Get-PhpSwitcher).targets
|
(Get-PhpSwitcher).targets
|
||||||
Initialize-PhpSwitcher -Alias C:\tools\php -Scope CurrentUser -Force
|
Initialize-PhpSwitcher -Alias C:\tools\php -Scope CurrentUser -Force
|
||||||
Add-PhpToSwitcher -Name $version -Path C:\tools\php$version -Force
|
Add-PhpToSwitcher -Name $version -Path C:\tools\php$version -Force
|
||||||
Switch-Php $version -Force
|
Switch-Php $version -Force
|
||||||
|
$status = "Installed PHP$version"
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Host "Housekeeping in PHP.ini, enabling openssl" -ForegroundColor Blue
|
|
||||||
$ext_dir = "C:\tools\php\ext"
|
$ext_dir = "C:\tools\php\ext"
|
||||||
Add-Content C:\tools\php\php.ini "date.timezone = 'UTC'"
|
Add-Content C:\tools\php\php.ini "date.timezone = 'UTC'"
|
||||||
Set-PhpIniKey extension_dir $ext_dir
|
Set-PhpIniKey extension_dir $ext_dir
|
||||||
|
|
||||||
if($version -lt '7.4') {
|
if($version -lt '7.4') {
|
||||||
Enable-PhpExtension openssl
|
Enable-PhpExtension openssl
|
||||||
} else {
|
} else {
|
||||||
Add-Content C:\tools\php\php.ini "extension=php_openssl.dll"
|
Add-Content C:\tools\php\php.ini "extension=php_openssl.dll"
|
||||||
Copy-Item "php_pcov.dll" -Destination $ext_dir"\php_pcov.dll"
|
Copy-Item "php_pcov.dll" -Destination $ext_dir"\php_pcov.dll"
|
||||||
}
|
}
|
||||||
|
Add-Log $tick "PHP" $status
|
||||||
|
|
||||||
Write-Host "Installing Composer" -ForegroundColor Blue
|
|
||||||
Install-Composer -Scope System -Path C:\tools\php
|
Install-Composer -Scope System -Path C:\tools\php
|
||||||
php -v
|
Add-Log $tick "Composer" "Installed"
|
||||||
composer -V
|
|
||||||
|
|
||||||
Function Add-Extension($extension, $install_command, $prefix, $log_prefix)
|
Function Add-Extension($extension, $install_command, $prefix)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$exist = Test-Path -Path C:\tools\php\ext\php_$extension.dll
|
$exist = Test-Path -Path C:\tools\php\ext\php_$extension.dll
|
||||||
if(!(php -m | findstr -i ${extension}) -and $exist) {
|
if(!(php -m | findstr -i ${extension}) -and $exist) {
|
||||||
Add-Content C:\tools\php\php.ini "$prefix=php_$extension.dll"
|
Add-Content C:\tools\php\php.ini "$prefix=php_$extension.dll"
|
||||||
Write-Host "$log_prefix`: Enabled $extension" -ForegroundColor green
|
Add-Log $tick $extension "Enabled"
|
||||||
} elseif(php -m | findstr -i $extension) {
|
} elseif(php -m | findstr -i $extension) {
|
||||||
Write-Host "$log_prefix`: $extension was already enabled" -ForegroundColor yellow
|
Add-Log $tick $extension "Enabled"
|
||||||
}
|
}
|
||||||
} catch [Exception] {
|
} catch [Exception] {
|
||||||
Write-Host "$log_prefix`: $extension could not be enabled" -ForegroundColor red
|
Add-Log $cross $extension "Could not enable"
|
||||||
}
|
}
|
||||||
|
|
||||||
$status = 404
|
$status = 404
|
||||||
@ -67,14 +78,14 @@ Function Add-Extension($extension, $install_command, $prefix, $log_prefix)
|
|||||||
if(!(php -m | findstr -i $extension)) {
|
if(!(php -m | findstr -i $extension)) {
|
||||||
try {
|
try {
|
||||||
Invoke-Expression $install_command
|
Invoke-Expression $install_command
|
||||||
Write-Host "$log_prefix`: Installed and enabled $extension" -ForegroundColor green
|
Add-Log $tick $extension "Installed and enabled"
|
||||||
} catch [Exception] {
|
} catch [Exception] {
|
||||||
Write-Host "$log_prefix`: Could not install $extension on PHP $version" -ForegroundColor red
|
Add-Log $cross $extension "Could not install on PHP$version"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(!(php -m | findstr -i $extension)) {
|
if(!(php -m | findstr -i $extension)) {
|
||||||
Write-Host "$log_prefix`: Could not find $extension for PHP$version on PECL" -ForegroundColor red
|
Add-Log $cross $extension "Could not find $extension for PHP$version on PECL"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
126
src/utils.ts
126
src/utils.ts
@ -43,7 +43,7 @@ export async function asyncForEach(
|
|||||||
*
|
*
|
||||||
* @param files
|
* @param files
|
||||||
*/
|
*/
|
||||||
export async function readFiles74(files: Array<string>) {
|
export async function moveFiles(files: Array<string>) {
|
||||||
await asyncForEach(files, function(filename: string) {
|
await asyncForEach(files, function(filename: string) {
|
||||||
fs.createReadStream(path.join(__dirname, '../src/' + filename)).pipe(
|
fs.createReadStream(path.join(__dirname, '../src/' + filename)).pipe(
|
||||||
fs.createWriteStream(filename.split('/')[1], {mode: 0o755})
|
fs.createWriteStream(filename.split('/')[1], {mode: 0o755})
|
||||||
@ -67,7 +67,7 @@ export async function readScript(
|
|||||||
case 'darwin':
|
case 'darwin':
|
||||||
switch (version) {
|
switch (version) {
|
||||||
case '7.4':
|
case '7.4':
|
||||||
await readFiles74([
|
await moveFiles([
|
||||||
'configs/config.yaml',
|
'configs/config.yaml',
|
||||||
'scripts/xdebug_darwin.sh',
|
'scripts/xdebug_darwin.sh',
|
||||||
'scripts/pcov.sh'
|
'scripts/pcov.sh'
|
||||||
@ -80,18 +80,17 @@ export async function readScript(
|
|||||||
break;
|
break;
|
||||||
case 'linux':
|
case 'linux':
|
||||||
let files: Array<string> = ['scripts/phalcon.sh'];
|
let files: Array<string> = ['scripts/phalcon.sh'];
|
||||||
await readFiles74(['scripts/phalcon.sh']);
|
|
||||||
switch (version) {
|
switch (version) {
|
||||||
case '7.4':
|
case '7.4':
|
||||||
files.concat(['scripts/xdebug.sh', 'scripts/pcov.sh']);
|
files = files.concat(['scripts/xdebug.sh', 'scripts/pcov.sh']);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
await readFiles74(files);
|
await moveFiles(files);
|
||||||
break;
|
break;
|
||||||
case 'win32':
|
case 'win32':
|
||||||
switch (version) {
|
switch (version) {
|
||||||
case '7.4':
|
case '7.4':
|
||||||
await readFiles74(['ext/php_pcov.dll']);
|
await moveFiles(['ext/php_pcov.dll']);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -164,51 +163,87 @@ export async function INIArray(ini_values_csv: string): Promise<Array<string>> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to log a step
|
||||||
|
*
|
||||||
|
* @param message
|
||||||
|
* @param os_version
|
||||||
|
*/
|
||||||
|
export async function stepLog(
|
||||||
|
message: string,
|
||||||
|
os_version: string
|
||||||
|
): Promise<string> {
|
||||||
|
switch (os_version) {
|
||||||
|
case 'win32':
|
||||||
|
return 'Step-Log "' + message + '"';
|
||||||
|
case 'linux':
|
||||||
|
case 'darwin':
|
||||||
|
return 'step_log "' + message + '"';
|
||||||
|
default:
|
||||||
|
return await log(
|
||||||
|
'Platform ' + os_version + ' is not supported',
|
||||||
|
os_version,
|
||||||
|
'error'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to log a result
|
||||||
|
* @param mark
|
||||||
|
* @param subject
|
||||||
|
* @param message
|
||||||
|
*/
|
||||||
|
export async function addLog(
|
||||||
|
mark: string,
|
||||||
|
subject: string,
|
||||||
|
message: string,
|
||||||
|
os_version: string
|
||||||
|
): Promise<string> {
|
||||||
|
switch (os_version) {
|
||||||
|
case 'win32':
|
||||||
|
return 'Add-Log "' + mark + '" "' + subject + '" "' + message + '"';
|
||||||
|
case 'linux':
|
||||||
|
case 'darwin':
|
||||||
|
return 'add_log "' + mark + '" "' + subject + '" "' + message + '"';
|
||||||
|
default:
|
||||||
|
return await log(
|
||||||
|
'Platform ' + os_version + ' is not supported',
|
||||||
|
os_version,
|
||||||
|
'error'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log to console
|
||||||
|
*
|
||||||
|
* @param message
|
||||||
|
* @param os_version
|
||||||
|
* @param log_type
|
||||||
|
* @param prefix
|
||||||
|
*/
|
||||||
export async function log(
|
export async function log(
|
||||||
message: string,
|
message: string,
|
||||||
os_version: string,
|
os_version: string,
|
||||||
log_type: string,
|
log_type: string
|
||||||
prefix = ''
|
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const unix_color: any = {
|
const color: any = {
|
||||||
error: '31',
|
error: '31',
|
||||||
success: '32',
|
success: '32',
|
||||||
warning: '33'
|
warning: '33'
|
||||||
};
|
};
|
||||||
switch (prefix) {
|
|
||||||
case '':
|
|
||||||
prefix = '';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
prefix = prefix + ': ';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
switch (os_version) {
|
switch (os_version) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
const color: any = {
|
|
||||||
error: 'red',
|
|
||||||
success: 'green',
|
|
||||||
warning: 'yellow'
|
|
||||||
};
|
|
||||||
return (
|
return (
|
||||||
"Write-Host '" +
|
'printf "\\033[' + color[log_type] + ';1m' + message + ' \\033[0m"'
|
||||||
prefix +
|
|
||||||
message +
|
|
||||||
"' -ForegroundColor " +
|
|
||||||
color[log_type]
|
|
||||||
);
|
);
|
||||||
|
|
||||||
case 'linux':
|
case 'linux':
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
default:
|
default:
|
||||||
return (
|
return 'echo "\\033[' + color[log_type] + ';1m' + message + '\\033[0m"';
|
||||||
'echo "\\033[' +
|
|
||||||
unix_color[log_type] +
|
|
||||||
';1m' +
|
|
||||||
prefix +
|
|
||||||
message +
|
|
||||||
'\\033[0m"'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,3 +263,24 @@ export async function getExtensionPrefix(extension: string): Promise<string> {
|
|||||||
return 'extension';
|
return 'extension';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to get the suffix to suppress console output
|
||||||
|
*
|
||||||
|
* @param os_version
|
||||||
|
*/
|
||||||
|
export async function suppressOutput(os_version: string): Promise<string> {
|
||||||
|
switch (os_version) {
|
||||||
|
case 'win32':
|
||||||
|
return ' >$null 2>&1';
|
||||||
|
case 'linux':
|
||||||
|
case 'darwin':
|
||||||
|
return ' >/dev/null 2>&1';
|
||||||
|
default:
|
||||||
|
return await log(
|
||||||
|
'Platform ' + os_version + ' is not supported',
|
||||||
|
os_version,
|
||||||
|
'error'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user