2019-09-20 09:41:20 +07:00
|
|
|
"use strict";
|
|
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
|
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
|
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
|
|
});
|
|
|
|
};
|
|
|
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
|
if (mod && mod.__esModule) return mod;
|
|
|
|
var result = {};
|
|
|
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
|
|
result["default"] = mod;
|
|
|
|
return result;
|
|
|
|
};
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
const fs = __importStar(require("fs"));
|
|
|
|
const path = __importStar(require("path"));
|
|
|
|
const core = __importStar(require("@actions/core"));
|
2019-10-12 00:39:05 +07:00
|
|
|
/**
|
|
|
|
* Function to get inputs from both with and env annotations.
|
|
|
|
*
|
|
|
|
* @param name
|
|
|
|
* @param mandatory
|
|
|
|
*/
|
2019-09-20 09:41:20 +07:00
|
|
|
function getInput(name, mandatory) {
|
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
|
|
let input = process.env[name];
|
2019-09-26 04:03:39 +07:00
|
|
|
switch (input) {
|
|
|
|
case '':
|
|
|
|
case undefined:
|
|
|
|
return core.getInput(name, { required: mandatory });
|
|
|
|
default:
|
|
|
|
return input;
|
2019-09-20 09:41:20 +07:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
exports.getInput = getInput;
|
|
|
|
/**
|
|
|
|
* Async foreach loop
|
|
|
|
*
|
|
|
|
* @author https://github.com/Atinux
|
|
|
|
* @param array
|
|
|
|
* @param callback
|
|
|
|
*/
|
|
|
|
function asyncForEach(array, callback) {
|
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
|
|
for (let index = 0; index < array.length; index++) {
|
|
|
|
yield callback(array[index], index, array);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
exports.asyncForEach = asyncForEach;
|
|
|
|
/**
|
|
|
|
* Read the scripts
|
|
|
|
*
|
|
|
|
* @param filename
|
|
|
|
* @param version
|
|
|
|
* @param os_version
|
|
|
|
*/
|
|
|
|
function readScript(filename, version, os_version) {
|
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
2019-09-26 04:03:39 +07:00
|
|
|
switch (os_version) {
|
|
|
|
case 'darwin':
|
|
|
|
switch (version) {
|
|
|
|
case '7.4':
|
2019-09-28 21:39:05 +07:00
|
|
|
return fs.readFileSync(path.join(__dirname, '../src/scripts/7.4.sh'), 'utf8');
|
2019-09-26 04:03:39 +07:00
|
|
|
}
|
2019-10-27 07:12:49 +07:00
|
|
|
return fs.readFileSync(path.join(__dirname, '../src/scripts/' + filename), 'utf8');
|
2019-09-26 04:03:39 +07:00
|
|
|
case 'linux':
|
2019-09-28 21:39:05 +07:00
|
|
|
case 'win32':
|
2019-10-27 07:12:49 +07:00
|
|
|
return fs.readFileSync(path.join(__dirname, '../src/scripts/' + filename), 'utf8');
|
2019-09-26 04:03:39 +07:00
|
|
|
default:
|
|
|
|
return yield log('Platform ' + os_version + ' is not supported', os_version, 'error');
|
2019-09-20 09:41:20 +07:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
exports.readScript = readScript;
|
|
|
|
/**
|
|
|
|
* Write final script which runs
|
|
|
|
*
|
|
|
|
* @param filename
|
|
|
|
* @param version
|
|
|
|
* @param script
|
|
|
|
*/
|
2019-10-27 07:12:49 +07:00
|
|
|
function writeScript(filename, script) {
|
2019-09-20 09:41:20 +07:00
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
2019-10-27 07:12:49 +07:00
|
|
|
let runner_dir = yield getInput('RUNNER_TOOL_CACHE', false);
|
|
|
|
let script_path = path.join(runner_dir, filename);
|
|
|
|
fs.writeFileSync(script_path, script, { mode: 0o755 });
|
|
|
|
return script_path;
|
2019-09-20 09:41:20 +07:00
|
|
|
});
|
|
|
|
}
|
|
|
|
exports.writeScript = writeScript;
|
|
|
|
/**
|
|
|
|
* Function to break extension csv into an array
|
2019-10-12 00:39:05 +07:00
|
|
|
*
|
2019-09-20 09:41:20 +07:00
|
|
|
* @param extension_csv
|
|
|
|
*/
|
|
|
|
function extensionArray(extension_csv) {
|
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
2019-09-28 21:39:05 +07:00
|
|
|
switch (extension_csv) {
|
|
|
|
case '':
|
|
|
|
case ' ':
|
|
|
|
return [];
|
|
|
|
default:
|
|
|
|
return extension_csv.split(',').map(function (extension) {
|
|
|
|
return extension
|
|
|
|
.trim()
|
|
|
|
.replace('php-', '')
|
2019-10-19 20:59:29 +07:00
|
|
|
.replace('php_', '')
|
|
|
|
.replace('pdo_', '')
|
|
|
|
.replace('pdo-', '');
|
2019-09-28 21:39:05 +07:00
|
|
|
});
|
|
|
|
}
|
2019-09-20 09:41:20 +07:00
|
|
|
});
|
|
|
|
}
|
|
|
|
exports.extensionArray = extensionArray;
|
|
|
|
/**
|
|
|
|
* Function to break ini values csv into an array
|
|
|
|
*
|
|
|
|
* @param ini_values_csv
|
|
|
|
* @constructor
|
|
|
|
*/
|
|
|
|
function INIArray(ini_values_csv) {
|
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
2019-09-28 21:39:05 +07:00
|
|
|
switch (ini_values_csv) {
|
|
|
|
case '':
|
|
|
|
case ' ':
|
|
|
|
return [];
|
|
|
|
default:
|
|
|
|
return ini_values_csv.split(',').map(function (ini_value) {
|
|
|
|
return ini_value.trim();
|
|
|
|
});
|
|
|
|
}
|
2019-09-20 09:41:20 +07:00
|
|
|
});
|
|
|
|
}
|
|
|
|
exports.INIArray = INIArray;
|
2019-10-17 03:11:13 +07:00
|
|
|
/**
|
|
|
|
* Function to log a step
|
|
|
|
*
|
|
|
|
* @param message
|
|
|
|
* @param os_version
|
|
|
|
*/
|
|
|
|
function stepLog(message, os_version) {
|
2019-09-26 04:03:39 +07:00
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
2019-10-17 03:11:13 +07:00
|
|
|
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 = {
|
2019-09-28 04:36:41 +07:00
|
|
|
error: '31',
|
|
|
|
success: '32',
|
|
|
|
warning: '33'
|
|
|
|
};
|
2019-09-26 04:03:39 +07:00
|
|
|
switch (os_version) {
|
|
|
|
case 'win32':
|
2019-10-17 03:11:13 +07:00
|
|
|
return ('printf "\\033[' + color[log_type] + ';1m' + message + ' \\033[0m"');
|
2019-09-26 04:03:39 +07:00
|
|
|
case 'linux':
|
|
|
|
case 'darwin':
|
|
|
|
default:
|
2019-10-17 03:11:13 +07:00
|
|
|
return 'echo "\\033[' + color[log_type] + ';1m' + message + '\\033[0m"';
|
2019-09-26 04:03:39 +07:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
exports.log = log;
|
2019-10-12 00:39:05 +07:00
|
|
|
/**
|
|
|
|
* Function to get prefix required to load an extension.
|
|
|
|
*
|
|
|
|
* @param extension
|
|
|
|
*/
|
2019-09-28 10:19:11 +07:00
|
|
|
function getExtensionPrefix(extension) {
|
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
2019-10-04 15:00:16 +07:00
|
|
|
let zend = ['xdebug', 'opcache', 'ioncube', 'eaccelerator'];
|
2019-09-28 10:19:11 +07:00
|
|
|
switch (zend.indexOf(extension)) {
|
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
return 'zend_extension';
|
|
|
|
case -1:
|
|
|
|
default:
|
|
|
|
return 'extension';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
exports.getExtensionPrefix = getExtensionPrefix;
|
2019-10-17 03:11:13 +07:00
|
|
|
/**
|
|
|
|
* 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;
|