Add support for removing extensions

This commit is contained in:
Shivam Mathur 2020-05-07 03:27:00 +05:30
parent f5863fd356
commit 8123132b99
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A
7 changed files with 782 additions and 542 deletions

View File

@ -3,13 +3,14 @@ import * as extensions from '../src/extensions';
describe('Extension tests', () => { describe('Extension tests', () => {
it('checking addExtensionOnWindows', async () => { it('checking addExtensionOnWindows', async () => {
let win32: string = await extensions.addExtension( let win32: string = await extensions.addExtension(
'Xdebug, pcov, sqlite, phalcon4, ast-beta, grpc-1.2.3, inotify-1.2.3alpha2', 'Xdebug, pcov, sqlite, :intl, phalcon4, ast-beta, grpc-1.2.3, inotify-1.2.3alpha2',
'7.4', '7.4',
'win32' 'win32'
); );
expect(win32).toContain('Add-Extension xdebug'); expect(win32).toContain('Add-Extension xdebug');
expect(win32).toContain('Add-Extension pcov'); expect(win32).toContain('Add-Extension pcov');
expect(win32).toContain('Add-Extension sqlite3'); expect(win32).toContain('Add-Extension sqlite3');
expect(win32).toContain('Remove-Extension intl');
expect(win32).toContain('phalcon.ps1 phalcon4'); expect(win32).toContain('phalcon.ps1 phalcon4');
expect(win32).toContain('Add-Extension ast beta'); expect(win32).toContain('Add-Extension ast beta');
expect(win32).toContain('Add-Extension grpc stable 1.2.3'); expect(win32).toContain('Add-Extension grpc stable 1.2.3');
@ -49,7 +50,7 @@ describe('Extension tests', () => {
it('checking addExtensionOnLinux', async () => { it('checking addExtensionOnLinux', async () => {
let linux: string = await extensions.addExtension( let linux: string = await extensions.addExtension(
'Xdebug, pcov, sqlite, ast, uopz, ast-beta, pdo_mysql, pdo-odbc, xdebug-alpha, grpc-1.2.3', 'Xdebug, pcov, sqlite, :intl, ast, uopz, ast-beta, pdo_mysql, pdo-odbc, xdebug-alpha, grpc-1.2.3',
'7.4', '7.4',
'linux' 'linux'
); );
@ -58,6 +59,7 @@ describe('Extension tests', () => {
expect(linux).toContain( expect(linux).toContain(
'sudo $debconf_fix apt-get install -y php7.4-sqlite3' 'sudo $debconf_fix apt-get install -y php7.4-sqlite3'
); );
expect(linux).toContain('remove_extension intl');
expect(linux).toContain('sudo $debconf_fix apt-get install -y php-ast'); expect(linux).toContain('sudo $debconf_fix apt-get install -y php-ast');
expect(linux).toContain('sudo $debconf_fix apt-get install -y php-uopz'); expect(linux).toContain('sudo $debconf_fix apt-get install -y php-uopz');
expect(linux).toContain('add_unstable_extension ast beta extension'); expect(linux).toContain('add_unstable_extension ast beta extension');
@ -98,13 +100,14 @@ describe('Extension tests', () => {
it('checking addExtensionOnDarwin', async () => { it('checking addExtensionOnDarwin', async () => {
let darwin: string = await extensions.addExtension( let darwin: string = await extensions.addExtension(
'Xdebug, pcov, sqlite, ast-beta, grpc-1.2.3', 'Xdebug, pcov, sqlite, :intl, ast-beta, grpc-1.2.3',
'7.2', '7.2',
'darwin' 'darwin'
); );
expect(darwin).toContain('sudo pecl install -f xdebug'); expect(darwin).toContain('sudo pecl install -f xdebug');
expect(darwin).toContain('sudo pecl install -f pcov'); expect(darwin).toContain('sudo pecl install -f pcov');
expect(darwin).toContain('sudo pecl install -f sqlite3'); expect(darwin).toContain('sudo pecl install -f sqlite3');
expect(darwin).toContain('remove_extension intl');
expect(darwin).toContain('add_unstable_extension ast beta extension'); expect(darwin).toContain('add_unstable_extension ast beta extension');
expect(darwin).toContain('add_pecl_extension grpc 1.2.3 extension'); expect(darwin).toContain('add_pecl_extension grpc 1.2.3 extension');

148
dist/index.js vendored
View File

@ -354,13 +354,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
step((generator = generator.apply(thisArg, _arguments || [])).next()); 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 }); Object.defineProperty(exports, "__esModule", { value: true });
const os = __webpack_require__(87); const os = __importStar(__webpack_require__(87));
const events = __webpack_require__(614); const events = __importStar(__webpack_require__(614));
const child = __webpack_require__(129); const child = __importStar(__webpack_require__(129));
const path = __webpack_require__(622); const path = __importStar(__webpack_require__(622));
const io = __webpack_require__(1); const io = __importStar(__webpack_require__(1));
const ioUtil = __webpack_require__(672); const ioUtil = __importStar(__webpack_require__(672));
/* eslint-disable @typescript-eslint/unbound-method */ /* eslint-disable @typescript-eslint/unbound-method */
const IS_WINDOWS = process.platform === 'win32'; const IS_WINDOWS = process.platform === 'win32';
/* /*
@ -804,6 +811,12 @@ class ToolRunner extends events.EventEmitter {
resolve(exitCode); resolve(exitCode);
} }
}); });
if (this.options.input) {
if (!cp.stdin) {
throw new Error('child process missing stdin');
}
cp.stdin.end(this.options.input);
}
}); });
}); });
} }
@ -1302,14 +1315,28 @@ class Command {
return cmdStr; return cmdStr;
} }
} }
/**
* Sanitizes an input into a string so it can be passed into issueCommand safely
* @param input input to sanitize into a string
*/
function toCommandValue(input) {
if (input === null || input === undefined) {
return '';
}
else if (typeof input === 'string' || input instanceof String) {
return input;
}
return JSON.stringify(input);
}
exports.toCommandValue = toCommandValue;
function escapeData(s) { function escapeData(s) {
return (s || '') return toCommandValue(s)
.replace(/%/g, '%25') .replace(/%/g, '%25')
.replace(/\r/g, '%0D') .replace(/\r/g, '%0D')
.replace(/\n/g, '%0A'); .replace(/\n/g, '%0A');
} }
function escapeProperty(s) { function escapeProperty(s) {
return (s || '') return toCommandValue(s)
.replace(/%/g, '%25') .replace(/%/g, '%25')
.replace(/\r/g, '%0D') .replace(/\r/g, '%0D')
.replace(/\n/g, '%0A') .replace(/\n/g, '%0A')
@ -1365,11 +1392,13 @@ var ExitCode;
/** /**
* Sets env variable for this action and future actions in the job * Sets env variable for this action and future actions in the job
* @param name the name of the variable to set * @param name the name of the variable to set
* @param val the value of the variable * @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify
*/ */
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function exportVariable(name, val) { function exportVariable(name, val) {
process.env[name] = val; const convertedVal = command_1.toCommandValue(val);
command_1.issueCommand('set-env', { name }, val); process.env[name] = convertedVal;
command_1.issueCommand('set-env', { name }, convertedVal);
} }
exports.exportVariable = exportVariable; exports.exportVariable = exportVariable;
/** /**
@ -1408,12 +1437,22 @@ exports.getInput = getInput;
* Sets the value of an output. * Sets the value of an output.
* *
* @param name name of the output to set * @param name name of the output to set
* @param value value to store * @param value value to store. Non-string values will be converted to a string via JSON.stringify
*/ */
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function setOutput(name, value) { function setOutput(name, value) {
command_1.issueCommand('set-output', { name }, value); command_1.issueCommand('set-output', { name }, value);
} }
exports.setOutput = setOutput; exports.setOutput = setOutput;
/**
* Enables or disables the echoing of commands into stdout for the rest of the step.
* Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set.
*
*/
function setCommandEcho(enabled) {
command_1.issue('echo', enabled ? 'on' : 'off');
}
exports.setCommandEcho = setCommandEcho;
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// Results // Results
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@ -1447,18 +1486,18 @@ function debug(message) {
exports.debug = debug; exports.debug = debug;
/** /**
* Adds an error issue * Adds an error issue
* @param message error issue message * @param message error issue message. Errors will be converted to string via toString()
*/ */
function error(message) { function error(message) {
command_1.issue('error', message); command_1.issue('error', message instanceof Error ? message.toString() : message);
} }
exports.error = error; exports.error = error;
/** /**
* Adds an warning issue * Adds an warning issue
* @param message warning issue message * @param message warning issue message. Errors will be converted to string via toString()
*/ */
function warning(message) { function warning(message) {
command_1.issue('warning', message); command_1.issue('warning', message instanceof Error ? message.toString() : message);
} }
exports.warning = warning; exports.warning = warning;
/** /**
@ -1516,8 +1555,9 @@ exports.group = group;
* Saves state for current action, the state can only be retrieved by this action's post job execution. * Saves state for current action, the state can only be retrieved by this action's post job execution.
* *
* @param name name of the state to store * @param name name of the state to store
* @param value value to store * @param value value to store. Non-string values will be converted to a string via JSON.stringify
*/ */
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function saveState(name, value) { function saveState(name, value) {
command_1.issueCommand('save-state', { name }, value); command_1.issueCommand('save-state', { name }, value);
} }
@ -2558,7 +2598,8 @@ const utils = __importStar(__webpack_require__(163));
*/ */
async function addExtensionDarwin(extension_csv, version, pipe) { async function addExtensionDarwin(extension_csv, version, pipe) {
const extensions = await utils.extensionArray(extension_csv); const extensions = await utils.extensionArray(extension_csv);
let script = '\n'; let add_script = '\n';
let remove_script = '\n';
await utils.asyncForEach(extensions, async function (extension) { await utils.asyncForEach(extensions, async function (extension) {
const version_extension = version + extension; const version_extension = version + extension;
const [ext_name, ext_version] = extension.split('-'); const [ext_name, ext_version] = extension.split('-');
@ -2566,6 +2607,10 @@ async function addExtensionDarwin(extension_csv, version, pipe) {
const command_prefix = 'sudo pecl install -f '; const command_prefix = 'sudo pecl install -f ';
let command = ''; let command = '';
switch (true) { switch (true) {
// match :extension
case /^:/.test(ext_name):
remove_script += '\nremove_extension ' + ext_name.slice(1);
return;
// match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire // match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire
// match 5.3blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0 // match 5.3blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0
case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension): case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension):
@ -2579,7 +2624,7 @@ async function addExtensionDarwin(extension_csv, version, pipe) {
break; break;
// match pre-release versions. For example - xdebug-beta // match pre-release versions. For example - xdebug-beta
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension): case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
script += add_script +=
'\nadd_unstable_extension ' + '\nadd_unstable_extension ' +
ext_name + ext_name +
' ' + ' ' +
@ -2589,7 +2634,7 @@ async function addExtensionDarwin(extension_csv, version, pipe) {
return; return;
// match semver // match semver
case /.*-\d+\.\d+\.\d+.*/.test(version_extension): case /.*-\d+\.\d+\.\d+.*/.test(version_extension):
script += add_script +=
'\nadd_pecl_extension ' + '\nadd_pecl_extension ' +
ext_name + ext_name +
' ' + ' ' +
@ -2634,7 +2679,7 @@ async function addExtensionDarwin(extension_csv, version, pipe) {
break; break;
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4 // match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
script += add_script +=
'sh ' + 'sh ' +
path.join(__dirname, '../src/scripts/ext/phalcon_darwin.sh') + path.join(__dirname, '../src/scripts/ext/phalcon_darwin.sh') +
' ' + ' ' +
@ -2646,10 +2691,10 @@ async function addExtensionDarwin(extension_csv, version, pipe) {
command = command_prefix + extension + pipe; command = command_prefix + extension + pipe;
break; break;
} }
script += add_script +=
'\nadd_extension ' + extension + ' "' + command + '" ' + ext_prefix; '\nadd_extension ' + extension + ' "' + command + '" ' + ext_prefix;
}); });
return script; return add_script + remove_script;
} }
exports.addExtensionDarwin = addExtensionDarwin; exports.addExtensionDarwin = addExtensionDarwin;
/** /**
@ -2660,16 +2705,21 @@ exports.addExtensionDarwin = addExtensionDarwin;
*/ */
async function addExtensionWindows(extension_csv, version) { async function addExtensionWindows(extension_csv, version) {
const extensions = await utils.extensionArray(extension_csv); const extensions = await utils.extensionArray(extension_csv);
let script = '\n'; let add_script = '\n';
let remove_script = '\n';
await utils.asyncForEach(extensions, async function (extension) { await utils.asyncForEach(extensions, async function (extension) {
const [ext_name, ext_version] = extension.split('-'); const [ext_name, ext_version] = extension.split('-');
const version_extension = version + extension; const version_extension = version + extension;
let matches; let matches;
switch (true) { switch (true) {
// Match :extension
case /^:/.test(ext_name):
remove_script += '\nRemove-Extension ' + ext_name.slice(1);
return;
// match 5.4blackfire...5.6blackfire, 7.0blackfire...7.4blackfire // match 5.4blackfire...5.6blackfire, 7.0blackfire...7.4blackfire
// match 5.4blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0 // match 5.4blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0
case /^(5\.[4-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension): case /^(5\.[4-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension):
script += add_script +=
'\n& ' + '\n& ' +
path.join(__dirname, '../src/scripts/ext/blackfire.ps1') + path.join(__dirname, '../src/scripts/ext/blackfire.ps1') +
' ' + ' ' +
@ -2679,39 +2729,39 @@ async function addExtensionWindows(extension_csv, version) {
return; return;
// match pre-release versions. For example - xdebug-beta // match pre-release versions. For example - xdebug-beta
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension): case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
script += '\nAdd-Extension ' + ext_name + ' ' + ext_version; add_script += '\nAdd-Extension ' + ext_name + ' ' + ext_version;
break; break;
// match semver without state // match semver without state
case /.*-\d+\.\d+\.\d+$/.test(version_extension): case /.*-\d+\.\d+\.\d+$/.test(version_extension):
script += '\nAdd-Extension ' + ext_name + ' stable ' + ext_version; add_script += '\nAdd-Extension ' + ext_name + ' stable ' + ext_version;
return; return;
// match semver with state // match semver with state
case /.*-(\d+\.\d+\.\d)(beta|alpha|devel|snapshot)\d*/.test(version_extension): case /.*-(\d+\.\d+\.\d)(beta|alpha|devel|snapshot)\d*/.test(version_extension):
matches = /.*-(\d+\.\d+\.\d)(beta|alpha|devel|snapshot)\d*/.exec(version_extension); matches = /.*-(\d+\.\d+\.\d)(beta|alpha|devel|snapshot)\d*/.exec(version_extension);
script += add_script +=
'\nAdd-Extension ' + ext_name + ' ' + matches[2] + ' ' + matches[1]; '\nAdd-Extension ' + ext_name + ' ' + matches[2] + ' ' + matches[1];
return; return;
// match 5.3mysql..5.6mysql // match 5.3mysql..5.6mysql
// match 5.3mysqli..5.6mysqli // match 5.3mysqli..5.6mysqli
// match 5.3mysqlnd..5.6mysqlnd // match 5.3mysqlnd..5.6mysqlnd
case /^5\.\d(mysql|mysqli|mysqlnd)$/.test(version_extension): case /^5\.\d(mysql|mysqli|mysqlnd)$/.test(version_extension):
script += add_script +=
'\nAdd-Extension mysql\nAdd-Extension mysqli\nAdd-Extension mysqlnd'; '\nAdd-Extension mysql\nAdd-Extension mysqli\nAdd-Extension mysqlnd';
break; break;
// match 7.0mysql..8.0mysql // match 7.0mysql..8.0mysql
// match 7.0mysqli..8.0mysqli // match 7.0mysqli..8.0mysqli
// match 7.0mysqlnd..8.0mysqlnd // match 7.0mysqlnd..8.0mysqlnd
case /[7-8]\.\d(mysql|mysqli|mysqlnd)$/.test(version_extension): case /[7-8]\.\d(mysql|mysqli|mysqlnd)$/.test(version_extension):
script += '\nAdd-Extension mysqli\nAdd-Extension mysqlnd'; add_script += '\nAdd-Extension mysqli\nAdd-Extension mysqlnd';
break; break;
// match sqlite // match sqlite
case /^sqlite$/.test(extension): case /^sqlite$/.test(extension):
extension = 'sqlite3'; extension = 'sqlite3';
script += '\nAdd-Extension ' + extension; add_script += '\nAdd-Extension ' + extension;
break; break;
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4 // match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
script += add_script +=
'\n& ' + '\n& ' +
path.join(__dirname, '../src/scripts/ext/phalcon.ps1') + path.join(__dirname, '../src/scripts/ext/phalcon.ps1') +
' ' + ' ' +
@ -2721,11 +2771,11 @@ async function addExtensionWindows(extension_csv, version) {
'\n'; '\n';
break; break;
default: default:
script += '\nAdd-Extension ' + extension; add_script += '\nAdd-Extension ' + extension;
break; break;
} }
}); });
return script; return add_script + remove_script;
} }
exports.addExtensionWindows = addExtensionWindows; exports.addExtensionWindows = addExtensionWindows;
/** /**
@ -2737,7 +2787,8 @@ exports.addExtensionWindows = addExtensionWindows;
*/ */
async function addExtensionLinux(extension_csv, version, pipe) { async function addExtensionLinux(extension_csv, version, pipe) {
const extensions = await utils.extensionArray(extension_csv); const extensions = await utils.extensionArray(extension_csv);
let script = '\n'; let add_script = '\n';
let remove_script = '\n';
await utils.asyncForEach(extensions, async function (extension) { await utils.asyncForEach(extensions, async function (extension) {
const version_extension = version + extension; const version_extension = version + extension;
const [ext_name, ext_version] = extension.split('-'); const [ext_name, ext_version] = extension.split('-');
@ -2745,6 +2796,10 @@ async function addExtensionLinux(extension_csv, version, pipe) {
const command_prefix = 'sudo $debconf_fix apt-get install -y php'; const command_prefix = 'sudo $debconf_fix apt-get install -y php';
let command = ''; let command = '';
switch (true) { switch (true) {
// Match :extension
case /^:/.test(ext_name):
remove_script += '\nremove_extension ' + ext_name.slice(1);
return;
// match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire // match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire
// match 5.3blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0 // match 5.3blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0
case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension): case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension):
@ -2758,7 +2813,7 @@ async function addExtensionLinux(extension_csv, version, pipe) {
break; break;
// match pre-release versions. For example - xdebug-beta // match pre-release versions. For example - xdebug-beta
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension): case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
script += add_script +=
'\nadd_unstable_extension ' + '\nadd_unstable_extension ' +
ext_name + ext_name +
' ' + ' ' +
@ -2768,7 +2823,7 @@ async function addExtensionLinux(extension_csv, version, pipe) {
return; return;
// match semver versions // match semver versions
case /.*-\d+\.\d+\.\d+.*/.test(version_extension): case /.*-\d+\.\d+\.\d+.*/.test(version_extension):
script += add_script +=
'\nadd_pecl_extension ' + '\nadd_pecl_extension ' +
ext_name + ext_name +
' ' + ' ' +
@ -2787,7 +2842,7 @@ async function addExtensionLinux(extension_csv, version, pipe) {
break; break;
// match 7.0phalcon3...7.3phalcon3 or 7.2phalcon4...7.4phalcon4 // match 7.0phalcon3...7.3phalcon3 or 7.2phalcon4...7.4phalcon4
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
script += add_script +=
'\nsh ' + '\nsh ' +
path.join(__dirname, '../src/scripts/ext/phalcon.sh') + path.join(__dirname, '../src/scripts/ext/phalcon.sh') +
' ' + ' ' +
@ -2797,7 +2852,7 @@ async function addExtensionLinux(extension_csv, version, pipe) {
return; return;
// match 7.1xdebug..7.4xdebug // match 7.1xdebug..7.4xdebug
case /^7\.[1-4]xdebug$/.test(version_extension): case /^7\.[1-4]xdebug$/.test(version_extension):
script += add_script +=
'\nupdate_extension xdebug 2.9.3' + '\nupdate_extension xdebug 2.9.3' +
pipe + pipe +
'\n' + '\n' +
@ -2806,7 +2861,7 @@ async function addExtensionLinux(extension_csv, version, pipe) {
// match pdo extensions // match pdo extensions
case /.*pdo[_-].*/.test(version_extension): case /.*pdo[_-].*/.test(version_extension):
extension = extension.replace('pdo_', '').replace('pdo-', ''); extension = extension.replace('pdo_', '').replace('pdo-', '');
script += '\nadd_pdo_extension ' + extension; add_script += '\nadd_pdo_extension ' + extension;
return; return;
// match ast and uopz // match ast and uopz
case /^(ast|uopz)$/.test(extension): case /^(ast|uopz)$/.test(extension):
@ -2821,10 +2876,10 @@ async function addExtensionLinux(extension_csv, version, pipe) {
command = command_prefix + version + '-' + extension + pipe; command = command_prefix + version + '-' + extension + pipe;
break; break;
} }
script += add_script +=
'\nadd_extension ' + extension + ' "' + command + '" ' + ext_prefix; '\nadd_extension ' + extension + ' "' + command + '" ' + ext_prefix;
}); });
return script; return add_script + remove_script;
} }
exports.addExtensionLinux = addExtensionLinux; exports.addExtensionLinux = addExtensionLinux;
/** /**
@ -2877,8 +2932,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
step((generator = generator.apply(thisArg, _arguments || [])).next()); 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 }); Object.defineProperty(exports, "__esModule", { value: true });
const tr = __webpack_require__(9); const tr = __importStar(__webpack_require__(9));
/** /**
* Exec a command. * Exec a command.
* Output will be streamed to the live console. * Output will be streamed to the live console.

1061
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -14,7 +14,8 @@ export async function addExtensionDarwin(
pipe: string pipe: string
): Promise<string> { ): Promise<string> {
const extensions: Array<string> = await utils.extensionArray(extension_csv); const extensions: Array<string> = await utils.extensionArray(extension_csv);
let script = '\n'; let add_script = '\n';
let remove_script = '\n';
await utils.asyncForEach(extensions, async function(extension: string) { await utils.asyncForEach(extensions, async function(extension: string) {
const version_extension: string = version + extension; const version_extension: string = version + extension;
const [ext_name, ext_version]: string[] = extension.split('-'); const [ext_name, ext_version]: string[] = extension.split('-');
@ -22,6 +23,10 @@ export async function addExtensionDarwin(
const command_prefix = 'sudo pecl install -f '; const command_prefix = 'sudo pecl install -f ';
let command = ''; let command = '';
switch (true) { switch (true) {
// match :extension
case /^:/.test(ext_name):
remove_script += '\nremove_extension ' + ext_name.slice(1);
return;
// match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire // match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire
// match 5.3blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0 // match 5.3blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0
case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test( case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(
@ -37,7 +42,7 @@ export async function addExtensionDarwin(
break; break;
// match pre-release versions. For example - xdebug-beta // match pre-release versions. For example - xdebug-beta
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension): case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
script += add_script +=
'\nadd_unstable_extension ' + '\nadd_unstable_extension ' +
ext_name + ext_name +
' ' + ' ' +
@ -47,7 +52,7 @@ export async function addExtensionDarwin(
return; return;
// match semver // match semver
case /.*-\d+\.\d+\.\d+.*/.test(version_extension): case /.*-\d+\.\d+\.\d+.*/.test(version_extension):
script += add_script +=
'\nadd_pecl_extension ' + '\nadd_pecl_extension ' +
ext_name + ext_name +
' ' + ' ' +
@ -92,7 +97,7 @@ export async function addExtensionDarwin(
break; break;
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4 // match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
script += add_script +=
'sh ' + 'sh ' +
path.join(__dirname, '../src/scripts/ext/phalcon_darwin.sh') + path.join(__dirname, '../src/scripts/ext/phalcon_darwin.sh') +
' ' + ' ' +
@ -104,10 +109,10 @@ export async function addExtensionDarwin(
command = command_prefix + extension + pipe; command = command_prefix + extension + pipe;
break; break;
} }
script += add_script +=
'\nadd_extension ' + extension + ' "' + command + '" ' + ext_prefix; '\nadd_extension ' + extension + ' "' + command + '" ' + ext_prefix;
}); });
return script; return add_script + remove_script;
} }
/** /**
@ -121,18 +126,23 @@ export async function addExtensionWindows(
version: string version: string
): Promise<string> { ): Promise<string> {
const extensions: Array<string> = await utils.extensionArray(extension_csv); const extensions: Array<string> = await utils.extensionArray(extension_csv);
let script = '\n'; let add_script = '\n';
let remove_script = '\n';
await utils.asyncForEach(extensions, async function(extension: string) { await utils.asyncForEach(extensions, async function(extension: string) {
const [ext_name, ext_version]: string[] = extension.split('-'); const [ext_name, ext_version]: string[] = extension.split('-');
const version_extension: string = version + extension; const version_extension: string = version + extension;
let matches: RegExpExecArray; let matches: RegExpExecArray;
switch (true) { switch (true) {
// Match :extension
case /^:/.test(ext_name):
remove_script += '\nRemove-Extension ' + ext_name.slice(1);
return;
// match 5.4blackfire...5.6blackfire, 7.0blackfire...7.4blackfire // match 5.4blackfire...5.6blackfire, 7.0blackfire...7.4blackfire
// match 5.4blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0 // match 5.4blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0
case /^(5\.[4-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test( case /^(5\.[4-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(
version_extension version_extension
): ):
script += add_script +=
'\n& ' + '\n& ' +
path.join(__dirname, '../src/scripts/ext/blackfire.ps1') + path.join(__dirname, '../src/scripts/ext/blackfire.ps1') +
' ' + ' ' +
@ -142,11 +152,11 @@ export async function addExtensionWindows(
return; return;
// match pre-release versions. For example - xdebug-beta // match pre-release versions. For example - xdebug-beta
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension): case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
script += '\nAdd-Extension ' + ext_name + ' ' + ext_version; add_script += '\nAdd-Extension ' + ext_name + ' ' + ext_version;
break; break;
// match semver without state // match semver without state
case /.*-\d+\.\d+\.\d+$/.test(version_extension): case /.*-\d+\.\d+\.\d+$/.test(version_extension):
script += '\nAdd-Extension ' + ext_name + ' stable ' + ext_version; add_script += '\nAdd-Extension ' + ext_name + ' stable ' + ext_version;
return; return;
// match semver with state // match semver with state
case /.*-(\d+\.\d+\.\d)(beta|alpha|devel|snapshot)\d*/.test( case /.*-(\d+\.\d+\.\d)(beta|alpha|devel|snapshot)\d*/.test(
@ -155,30 +165,30 @@ export async function addExtensionWindows(
matches = /.*-(\d+\.\d+\.\d)(beta|alpha|devel|snapshot)\d*/.exec( matches = /.*-(\d+\.\d+\.\d)(beta|alpha|devel|snapshot)\d*/.exec(
version_extension version_extension
) as RegExpExecArray; ) as RegExpExecArray;
script += add_script +=
'\nAdd-Extension ' + ext_name + ' ' + matches[2] + ' ' + matches[1]; '\nAdd-Extension ' + ext_name + ' ' + matches[2] + ' ' + matches[1];
return; return;
// match 5.3mysql..5.6mysql // match 5.3mysql..5.6mysql
// match 5.3mysqli..5.6mysqli // match 5.3mysqli..5.6mysqli
// match 5.3mysqlnd..5.6mysqlnd // match 5.3mysqlnd..5.6mysqlnd
case /^5\.\d(mysql|mysqli|mysqlnd)$/.test(version_extension): case /^5\.\d(mysql|mysqli|mysqlnd)$/.test(version_extension):
script += add_script +=
'\nAdd-Extension mysql\nAdd-Extension mysqli\nAdd-Extension mysqlnd'; '\nAdd-Extension mysql\nAdd-Extension mysqli\nAdd-Extension mysqlnd';
break; break;
// match 7.0mysql..8.0mysql // match 7.0mysql..8.0mysql
// match 7.0mysqli..8.0mysqli // match 7.0mysqli..8.0mysqli
// match 7.0mysqlnd..8.0mysqlnd // match 7.0mysqlnd..8.0mysqlnd
case /[7-8]\.\d(mysql|mysqli|mysqlnd)$/.test(version_extension): case /[7-8]\.\d(mysql|mysqli|mysqlnd)$/.test(version_extension):
script += '\nAdd-Extension mysqli\nAdd-Extension mysqlnd'; add_script += '\nAdd-Extension mysqli\nAdd-Extension mysqlnd';
break; break;
// match sqlite // match sqlite
case /^sqlite$/.test(extension): case /^sqlite$/.test(extension):
extension = 'sqlite3'; extension = 'sqlite3';
script += '\nAdd-Extension ' + extension; add_script += '\nAdd-Extension ' + extension;
break; break;
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4 // match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
script += add_script +=
'\n& ' + '\n& ' +
path.join(__dirname, '../src/scripts/ext/phalcon.ps1') + path.join(__dirname, '../src/scripts/ext/phalcon.ps1') +
' ' + ' ' +
@ -188,11 +198,11 @@ export async function addExtensionWindows(
'\n'; '\n';
break; break;
default: default:
script += '\nAdd-Extension ' + extension; add_script += '\nAdd-Extension ' + extension;
break; break;
} }
}); });
return script; return add_script + remove_script;
} }
/** /**
@ -208,7 +218,8 @@ export async function addExtensionLinux(
pipe: string pipe: string
): Promise<string> { ): Promise<string> {
const extensions: Array<string> = await utils.extensionArray(extension_csv); const extensions: Array<string> = await utils.extensionArray(extension_csv);
let script = '\n'; let add_script = '\n';
let remove_script = '\n';
await utils.asyncForEach(extensions, async function(extension: string) { await utils.asyncForEach(extensions, async function(extension: string) {
const version_extension: string = version + extension; const version_extension: string = version + extension;
const [ext_name, ext_version]: string[] = extension.split('-'); const [ext_name, ext_version]: string[] = extension.split('-');
@ -216,6 +227,10 @@ export async function addExtensionLinux(
const command_prefix = 'sudo $debconf_fix apt-get install -y php'; const command_prefix = 'sudo $debconf_fix apt-get install -y php';
let command = ''; let command = '';
switch (true) { switch (true) {
// Match :extension
case /^:/.test(ext_name):
remove_script += '\nremove_extension ' + ext_name.slice(1);
return;
// match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire // match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire
// match 5.3blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0 // match 5.3blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0
case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test( case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(
@ -231,7 +246,7 @@ export async function addExtensionLinux(
break; break;
// match pre-release versions. For example - xdebug-beta // match pre-release versions. For example - xdebug-beta
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension): case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
script += add_script +=
'\nadd_unstable_extension ' + '\nadd_unstable_extension ' +
ext_name + ext_name +
' ' + ' ' +
@ -241,7 +256,7 @@ export async function addExtensionLinux(
return; return;
// match semver versions // match semver versions
case /.*-\d+\.\d+\.\d+.*/.test(version_extension): case /.*-\d+\.\d+\.\d+.*/.test(version_extension):
script += add_script +=
'\nadd_pecl_extension ' + '\nadd_pecl_extension ' +
ext_name + ext_name +
' ' + ' ' +
@ -260,7 +275,7 @@ export async function addExtensionLinux(
break; break;
// match 7.0phalcon3...7.3phalcon3 or 7.2phalcon4...7.4phalcon4 // match 7.0phalcon3...7.3phalcon3 or 7.2phalcon4...7.4phalcon4
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
script += add_script +=
'\nsh ' + '\nsh ' +
path.join(__dirname, '../src/scripts/ext/phalcon.sh') + path.join(__dirname, '../src/scripts/ext/phalcon.sh') +
' ' + ' ' +
@ -270,7 +285,7 @@ export async function addExtensionLinux(
return; return;
// match 7.1xdebug..7.4xdebug // match 7.1xdebug..7.4xdebug
case /^7\.[1-4]xdebug$/.test(version_extension): case /^7\.[1-4]xdebug$/.test(version_extension):
script += add_script +=
'\nupdate_extension xdebug 2.9.3' + '\nupdate_extension xdebug 2.9.3' +
pipe + pipe +
'\n' + '\n' +
@ -279,7 +294,7 @@ export async function addExtensionLinux(
// match pdo extensions // match pdo extensions
case /.*pdo[_-].*/.test(version_extension): case /.*pdo[_-].*/.test(version_extension):
extension = extension.replace('pdo_', '').replace('pdo-', ''); extension = extension.replace('pdo_', '').replace('pdo-', '');
script += '\nadd_pdo_extension ' + extension; add_script += '\nadd_pdo_extension ' + extension;
return; return;
// match ast and uopz // match ast and uopz
case /^(ast|uopz)$/.test(extension): case /^(ast|uopz)$/.test(extension):
@ -294,10 +309,10 @@ export async function addExtensionLinux(
command = command_prefix + version + '-' + extension + pipe; command = command_prefix + version + '-' + extension + pipe;
break; break;
} }
script += add_script +=
'\nadd_extension ' + extension + ' "' + command + '" ' + ext_prefix; '\nadd_extension ' + extension + ' "' + command + '" ' + ext_prefix;
}); });
return script; return add_script + remove_script;
} }
/** /**

View File

@ -19,9 +19,15 @@ add_log() {
# Function to remove extensions # Function to remove extensions
remove_extension() { remove_extension() {
extension=$1 extension=$1
sudo sed -i '' "/$extension/d" "$ini_file" if check_extension "$extension"; then
sudo rm -rf "$scan_dir"/*"$extension"* >/dev/null 2>&1 sudo sed -i '' "/$extension/d" "$ini_file"
sudo rm -rf "$ext_dir"/"$extension".so >/dev/null 2>&1 sudo rm -rf "$scan_dir"/*"$extension"* >/dev/null 2>&1
sudo rm -rf "$ext_dir"/"$extension".so >/dev/null 2>&1
(! check_extension "$extension" && add_log "$tick" ":$extension" "Removed") ||
add_log "$cross" ":$extension" "Could not remove $extension on PHP $semver"
else
add_log "$tick" ":$extension" "Could not find $extension on PHP $semver"
fi
} }
# Function to test if extension is loaded # Function to test if extension is loaded
@ -59,7 +65,7 @@ add_pecl_extension() {
if [ "$ext_version" = "$pecl_version" ]; then if [ "$ext_version" = "$pecl_version" ]; then
add_log "$tick" "$extension" "Enabled" add_log "$tick" "$extension" "Enabled"
else else
remove_extension "$extension" remove_extension "$extension" >/dev/null 2>&1
( (
sudo pecl install -f "$extension-$pecl_version" >/dev/null 2>&1 && sudo pecl install -f "$extension-$pecl_version" >/dev/null 2>&1 &&
check_extension "$extension" && check_extension "$extension" &&

View File

@ -93,10 +93,16 @@ delete_extension() {
# Function to disable and delete extensions # Function to disable and delete extensions
remove_extension() { remove_extension() {
extension=$1 extension=$1
if [[ ! "$version" =~ $old_versions ]] && [ -e /etc/php/"$version"/mods-available/"$extension".ini ]; then if check_extension "$extension"; then
sudo phpdismod -v "$version" "$extension" if [[ ! "$version" =~ $old_versions ]] && [ -e /etc/php/"$version"/mods-available/"$extension".ini ]; then
sudo phpdismod -v "$version" "$extension" >/dev/null 2>&1
fi
delete_extension "$extension"
(! check_extension "$extension" && add_log "$tick" ":$extension" "Removed") ||
add_log "$cross" ":$extension" "Could not remove $extension on PHP $semver"
else
add_log "$tick" ":$extension" "Could not find $extension on PHP $semver"
fi fi
delete_extension "$extension"
} }
# Function to enable existing extension # Function to enable existing extension

View File

@ -120,10 +120,17 @@ Function Remove-Extension() {
$extension $extension
) )
if(php -m | findstr -i $extension) { if(php -m | findstr -i $extension) {
Disable-PhpExtension $extension $php_dir try {
} Disable-PhpExtension $extension $php_dir
if (Test-Path $ext_dir\php_$extension.dll) { if (Test-Path $ext_dir\php_$extension.dll) {
Remove-Item $ext_dir\php_$extension.dll Remove-Item $ext_dir\php_$extension.dll
}
Add-Log $tick ":$extension" "Removed"
} catch {
Add-Log $cross ":$extension" "Could not remove $extension on PHP $($installed.FullVersion)"
}
} else {
Add-Log $tick ":$extension" "Could not find $extension on PHP $($installed.FullVersion)"
} }
} }