mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 20:01:06 +07:00
Add support for removing extensions
This commit is contained in:
parent
f5863fd356
commit
8123132b99
@ -3,13 +3,14 @@ import * as extensions from '../src/extensions';
|
||||
describe('Extension tests', () => {
|
||||
it('checking addExtensionOnWindows', async () => {
|
||||
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',
|
||||
'win32'
|
||||
);
|
||||
expect(win32).toContain('Add-Extension xdebug');
|
||||
expect(win32).toContain('Add-Extension pcov');
|
||||
expect(win32).toContain('Add-Extension sqlite3');
|
||||
expect(win32).toContain('Remove-Extension intl');
|
||||
expect(win32).toContain('phalcon.ps1 phalcon4');
|
||||
expect(win32).toContain('Add-Extension ast beta');
|
||||
expect(win32).toContain('Add-Extension grpc stable 1.2.3');
|
||||
@ -49,7 +50,7 @@ describe('Extension tests', () => {
|
||||
|
||||
it('checking addExtensionOnLinux', async () => {
|
||||
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',
|
||||
'linux'
|
||||
);
|
||||
@ -58,6 +59,7 @@ describe('Extension tests', () => {
|
||||
expect(linux).toContain(
|
||||
'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-uopz');
|
||||
expect(linux).toContain('add_unstable_extension ast beta extension');
|
||||
@ -98,13 +100,14 @@ describe('Extension tests', () => {
|
||||
|
||||
it('checking addExtensionOnDarwin', async () => {
|
||||
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',
|
||||
'darwin'
|
||||
);
|
||||
expect(darwin).toContain('sudo pecl install -f xdebug');
|
||||
expect(darwin).toContain('sudo pecl install -f pcov');
|
||||
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_pecl_extension grpc 1.2.3 extension');
|
||||
|
||||
|
148
dist/index.js
vendored
148
dist/index.js
vendored
@ -354,13 +354,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
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 os = __webpack_require__(87);
|
||||
const events = __webpack_require__(614);
|
||||
const child = __webpack_require__(129);
|
||||
const path = __webpack_require__(622);
|
||||
const io = __webpack_require__(1);
|
||||
const ioUtil = __webpack_require__(672);
|
||||
const os = __importStar(__webpack_require__(87));
|
||||
const events = __importStar(__webpack_require__(614));
|
||||
const child = __importStar(__webpack_require__(129));
|
||||
const path = __importStar(__webpack_require__(622));
|
||||
const io = __importStar(__webpack_require__(1));
|
||||
const ioUtil = __importStar(__webpack_require__(672));
|
||||
/* eslint-disable @typescript-eslint/unbound-method */
|
||||
const IS_WINDOWS = process.platform === 'win32';
|
||||
/*
|
||||
@ -804,6 +811,12 @@ class ToolRunner extends events.EventEmitter {
|
||||
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;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 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) {
|
||||
return (s || '')
|
||||
return toCommandValue(s)
|
||||
.replace(/%/g, '%25')
|
||||
.replace(/\r/g, '%0D')
|
||||
.replace(/\n/g, '%0A');
|
||||
}
|
||||
function escapeProperty(s) {
|
||||
return (s || '')
|
||||
return toCommandValue(s)
|
||||
.replace(/%/g, '%25')
|
||||
.replace(/\r/g, '%0D')
|
||||
.replace(/\n/g, '%0A')
|
||||
@ -1365,11 +1392,13 @@ var ExitCode;
|
||||
/**
|
||||
* Sets env variable for this action and future actions in the job
|
||||
* @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) {
|
||||
process.env[name] = val;
|
||||
command_1.issueCommand('set-env', { name }, val);
|
||||
const convertedVal = command_1.toCommandValue(val);
|
||||
process.env[name] = convertedVal;
|
||||
command_1.issueCommand('set-env', { name }, convertedVal);
|
||||
}
|
||||
exports.exportVariable = exportVariable;
|
||||
/**
|
||||
@ -1408,12 +1437,22 @@ exports.getInput = getInput;
|
||||
* Sets the value of an output.
|
||||
*
|
||||
* @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) {
|
||||
command_1.issueCommand('set-output', { name }, value);
|
||||
}
|
||||
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
|
||||
//-----------------------------------------------------------------------
|
||||
@ -1447,18 +1486,18 @@ function debug(message) {
|
||||
exports.debug = debug;
|
||||
/**
|
||||
* 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) {
|
||||
command_1.issue('error', message);
|
||||
command_1.issue('error', message instanceof Error ? message.toString() : message);
|
||||
}
|
||||
exports.error = error;
|
||||
/**
|
||||
* 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) {
|
||||
command_1.issue('warning', message);
|
||||
command_1.issue('warning', message instanceof Error ? message.toString() : message);
|
||||
}
|
||||
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.
|
||||
*
|
||||
* @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) {
|
||||
command_1.issueCommand('save-state', { name }, value);
|
||||
}
|
||||
@ -2558,7 +2598,8 @@ const utils = __importStar(__webpack_require__(163));
|
||||
*/
|
||||
async function addExtensionDarwin(extension_csv, version, pipe) {
|
||||
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) {
|
||||
const version_extension = version + extension;
|
||||
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 ';
|
||||
let command = '';
|
||||
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-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):
|
||||
@ -2579,7 +2624,7 @@ async function addExtensionDarwin(extension_csv, version, pipe) {
|
||||
break;
|
||||
// match pre-release versions. For example - xdebug-beta
|
||||
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
|
||||
script +=
|
||||
add_script +=
|
||||
'\nadd_unstable_extension ' +
|
||||
ext_name +
|
||||
' ' +
|
||||
@ -2589,7 +2634,7 @@ async function addExtensionDarwin(extension_csv, version, pipe) {
|
||||
return;
|
||||
// match semver
|
||||
case /.*-\d+\.\d+\.\d+.*/.test(version_extension):
|
||||
script +=
|
||||
add_script +=
|
||||
'\nadd_pecl_extension ' +
|
||||
ext_name +
|
||||
' ' +
|
||||
@ -2634,7 +2679,7 @@ async function addExtensionDarwin(extension_csv, version, pipe) {
|
||||
break;
|
||||
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
|
||||
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
||||
script +=
|
||||
add_script +=
|
||||
'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;
|
||||
break;
|
||||
}
|
||||
script +=
|
||||
add_script +=
|
||||
'\nadd_extension ' + extension + ' "' + command + '" ' + ext_prefix;
|
||||
});
|
||||
return script;
|
||||
return add_script + remove_script;
|
||||
}
|
||||
exports.addExtensionDarwin = addExtensionDarwin;
|
||||
/**
|
||||
@ -2660,16 +2705,21 @@ exports.addExtensionDarwin = addExtensionDarwin;
|
||||
*/
|
||||
async function addExtensionWindows(extension_csv, version) {
|
||||
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) {
|
||||
const [ext_name, ext_version] = extension.split('-');
|
||||
const version_extension = version + extension;
|
||||
let matches;
|
||||
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-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):
|
||||
script +=
|
||||
add_script +=
|
||||
'\n& ' +
|
||||
path.join(__dirname, '../src/scripts/ext/blackfire.ps1') +
|
||||
' ' +
|
||||
@ -2679,39 +2729,39 @@ async function addExtensionWindows(extension_csv, version) {
|
||||
return;
|
||||
// match pre-release versions. For example - xdebug-beta
|
||||
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
|
||||
script += '\nAdd-Extension ' + ext_name + ' ' + ext_version;
|
||||
add_script += '\nAdd-Extension ' + ext_name + ' ' + ext_version;
|
||||
break;
|
||||
// match semver without state
|
||||
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;
|
||||
// match semver with state
|
||||
case /.*-(\d+\.\d+\.\d)(beta|alpha|devel|snapshot)\d*/.test(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];
|
||||
return;
|
||||
// match 5.3mysql..5.6mysql
|
||||
// match 5.3mysqli..5.6mysqli
|
||||
// match 5.3mysqlnd..5.6mysqlnd
|
||||
case /^5\.\d(mysql|mysqli|mysqlnd)$/.test(version_extension):
|
||||
script +=
|
||||
add_script +=
|
||||
'\nAdd-Extension mysql\nAdd-Extension mysqli\nAdd-Extension mysqlnd';
|
||||
break;
|
||||
// match 7.0mysql..8.0mysql
|
||||
// match 7.0mysqli..8.0mysqli
|
||||
// match 7.0mysqlnd..8.0mysqlnd
|
||||
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;
|
||||
// match sqlite
|
||||
case /^sqlite$/.test(extension):
|
||||
extension = 'sqlite3';
|
||||
script += '\nAdd-Extension ' + extension;
|
||||
add_script += '\nAdd-Extension ' + extension;
|
||||
break;
|
||||
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
|
||||
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
||||
script +=
|
||||
add_script +=
|
||||
'\n& ' +
|
||||
path.join(__dirname, '../src/scripts/ext/phalcon.ps1') +
|
||||
' ' +
|
||||
@ -2721,11 +2771,11 @@ async function addExtensionWindows(extension_csv, version) {
|
||||
'\n';
|
||||
break;
|
||||
default:
|
||||
script += '\nAdd-Extension ' + extension;
|
||||
add_script += '\nAdd-Extension ' + extension;
|
||||
break;
|
||||
}
|
||||
});
|
||||
return script;
|
||||
return add_script + remove_script;
|
||||
}
|
||||
exports.addExtensionWindows = addExtensionWindows;
|
||||
/**
|
||||
@ -2737,7 +2787,8 @@ exports.addExtensionWindows = addExtensionWindows;
|
||||
*/
|
||||
async function addExtensionLinux(extension_csv, version, pipe) {
|
||||
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) {
|
||||
const version_extension = version + extension;
|
||||
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';
|
||||
let command = '';
|
||||
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-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):
|
||||
@ -2758,7 +2813,7 @@ async function addExtensionLinux(extension_csv, version, pipe) {
|
||||
break;
|
||||
// match pre-release versions. For example - xdebug-beta
|
||||
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
|
||||
script +=
|
||||
add_script +=
|
||||
'\nadd_unstable_extension ' +
|
||||
ext_name +
|
||||
' ' +
|
||||
@ -2768,7 +2823,7 @@ async function addExtensionLinux(extension_csv, version, pipe) {
|
||||
return;
|
||||
// match semver versions
|
||||
case /.*-\d+\.\d+\.\d+.*/.test(version_extension):
|
||||
script +=
|
||||
add_script +=
|
||||
'\nadd_pecl_extension ' +
|
||||
ext_name +
|
||||
' ' +
|
||||
@ -2787,7 +2842,7 @@ async function addExtensionLinux(extension_csv, version, pipe) {
|
||||
break;
|
||||
// match 7.0phalcon3...7.3phalcon3 or 7.2phalcon4...7.4phalcon4
|
||||
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
||||
script +=
|
||||
add_script +=
|
||||
'\nsh ' +
|
||||
path.join(__dirname, '../src/scripts/ext/phalcon.sh') +
|
||||
' ' +
|
||||
@ -2797,7 +2852,7 @@ async function addExtensionLinux(extension_csv, version, pipe) {
|
||||
return;
|
||||
// match 7.1xdebug..7.4xdebug
|
||||
case /^7\.[1-4]xdebug$/.test(version_extension):
|
||||
script +=
|
||||
add_script +=
|
||||
'\nupdate_extension xdebug 2.9.3' +
|
||||
pipe +
|
||||
'\n' +
|
||||
@ -2806,7 +2861,7 @@ async function addExtensionLinux(extension_csv, version, pipe) {
|
||||
// match pdo extensions
|
||||
case /.*pdo[_-].*/.test(version_extension):
|
||||
extension = extension.replace('pdo_', '').replace('pdo-', '');
|
||||
script += '\nadd_pdo_extension ' + extension;
|
||||
add_script += '\nadd_pdo_extension ' + extension;
|
||||
return;
|
||||
// match ast and uopz
|
||||
case /^(ast|uopz)$/.test(extension):
|
||||
@ -2821,10 +2876,10 @@ async function addExtensionLinux(extension_csv, version, pipe) {
|
||||
command = command_prefix + version + '-' + extension + pipe;
|
||||
break;
|
||||
}
|
||||
script +=
|
||||
add_script +=
|
||||
'\nadd_extension ' + extension + ' "' + command + '" ' + ext_prefix;
|
||||
});
|
||||
return script;
|
||||
return add_script + remove_script;
|
||||
}
|
||||
exports.addExtensionLinux = addExtensionLinux;
|
||||
/**
|
||||
@ -2877,8 +2932,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
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 tr = __webpack_require__(9);
|
||||
const tr = __importStar(__webpack_require__(9));
|
||||
/**
|
||||
* Exec a command.
|
||||
* Output will be streamed to the live console.
|
||||
|
1061
package-lock.json
generated
1061
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -14,7 +14,8 @@ export async function addExtensionDarwin(
|
||||
pipe: string
|
||||
): Promise<string> {
|
||||
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) {
|
||||
const version_extension: string = version + extension;
|
||||
const [ext_name, ext_version]: string[] = extension.split('-');
|
||||
@ -22,6 +23,10 @@ export async function addExtensionDarwin(
|
||||
const command_prefix = 'sudo pecl install -f ';
|
||||
let command = '';
|
||||
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-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(
|
||||
@ -37,7 +42,7 @@ export async function addExtensionDarwin(
|
||||
break;
|
||||
// match pre-release versions. For example - xdebug-beta
|
||||
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
|
||||
script +=
|
||||
add_script +=
|
||||
'\nadd_unstable_extension ' +
|
||||
ext_name +
|
||||
' ' +
|
||||
@ -47,7 +52,7 @@ export async function addExtensionDarwin(
|
||||
return;
|
||||
// match semver
|
||||
case /.*-\d+\.\d+\.\d+.*/.test(version_extension):
|
||||
script +=
|
||||
add_script +=
|
||||
'\nadd_pecl_extension ' +
|
||||
ext_name +
|
||||
' ' +
|
||||
@ -92,7 +97,7 @@ export async function addExtensionDarwin(
|
||||
break;
|
||||
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
|
||||
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
||||
script +=
|
||||
add_script +=
|
||||
'sh ' +
|
||||
path.join(__dirname, '../src/scripts/ext/phalcon_darwin.sh') +
|
||||
' ' +
|
||||
@ -104,10 +109,10 @@ export async function addExtensionDarwin(
|
||||
command = command_prefix + extension + pipe;
|
||||
break;
|
||||
}
|
||||
script +=
|
||||
add_script +=
|
||||
'\nadd_extension ' + extension + ' "' + command + '" ' + ext_prefix;
|
||||
});
|
||||
return script;
|
||||
return add_script + remove_script;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -121,18 +126,23 @@ export async function addExtensionWindows(
|
||||
version: string
|
||||
): Promise<string> {
|
||||
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) {
|
||||
const [ext_name, ext_version]: string[] = extension.split('-');
|
||||
const version_extension: string = version + extension;
|
||||
let matches: RegExpExecArray;
|
||||
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-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
|
||||
):
|
||||
script +=
|
||||
add_script +=
|
||||
'\n& ' +
|
||||
path.join(__dirname, '../src/scripts/ext/blackfire.ps1') +
|
||||
' ' +
|
||||
@ -142,11 +152,11 @@ export async function addExtensionWindows(
|
||||
return;
|
||||
// match pre-release versions. For example - xdebug-beta
|
||||
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
|
||||
script += '\nAdd-Extension ' + ext_name + ' ' + ext_version;
|
||||
add_script += '\nAdd-Extension ' + ext_name + ' ' + ext_version;
|
||||
break;
|
||||
// match semver without state
|
||||
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;
|
||||
// match semver with state
|
||||
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(
|
||||
version_extension
|
||||
) as RegExpExecArray;
|
||||
script +=
|
||||
add_script +=
|
||||
'\nAdd-Extension ' + ext_name + ' ' + matches[2] + ' ' + matches[1];
|
||||
return;
|
||||
// match 5.3mysql..5.6mysql
|
||||
// match 5.3mysqli..5.6mysqli
|
||||
// match 5.3mysqlnd..5.6mysqlnd
|
||||
case /^5\.\d(mysql|mysqli|mysqlnd)$/.test(version_extension):
|
||||
script +=
|
||||
add_script +=
|
||||
'\nAdd-Extension mysql\nAdd-Extension mysqli\nAdd-Extension mysqlnd';
|
||||
break;
|
||||
// match 7.0mysql..8.0mysql
|
||||
// match 7.0mysqli..8.0mysqli
|
||||
// match 7.0mysqlnd..8.0mysqlnd
|
||||
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;
|
||||
// match sqlite
|
||||
case /^sqlite$/.test(extension):
|
||||
extension = 'sqlite3';
|
||||
script += '\nAdd-Extension ' + extension;
|
||||
add_script += '\nAdd-Extension ' + extension;
|
||||
break;
|
||||
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
|
||||
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
||||
script +=
|
||||
add_script +=
|
||||
'\n& ' +
|
||||
path.join(__dirname, '../src/scripts/ext/phalcon.ps1') +
|
||||
' ' +
|
||||
@ -188,11 +198,11 @@ export async function addExtensionWindows(
|
||||
'\n';
|
||||
break;
|
||||
default:
|
||||
script += '\nAdd-Extension ' + extension;
|
||||
add_script += '\nAdd-Extension ' + extension;
|
||||
break;
|
||||
}
|
||||
});
|
||||
return script;
|
||||
return add_script + remove_script;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -208,7 +218,8 @@ export async function addExtensionLinux(
|
||||
pipe: string
|
||||
): Promise<string> {
|
||||
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) {
|
||||
const version_extension: string = version + extension;
|
||||
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';
|
||||
let command = '';
|
||||
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-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(
|
||||
@ -231,7 +246,7 @@ export async function addExtensionLinux(
|
||||
break;
|
||||
// match pre-release versions. For example - xdebug-beta
|
||||
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
|
||||
script +=
|
||||
add_script +=
|
||||
'\nadd_unstable_extension ' +
|
||||
ext_name +
|
||||
' ' +
|
||||
@ -241,7 +256,7 @@ export async function addExtensionLinux(
|
||||
return;
|
||||
// match semver versions
|
||||
case /.*-\d+\.\d+\.\d+.*/.test(version_extension):
|
||||
script +=
|
||||
add_script +=
|
||||
'\nadd_pecl_extension ' +
|
||||
ext_name +
|
||||
' ' +
|
||||
@ -260,7 +275,7 @@ export async function addExtensionLinux(
|
||||
break;
|
||||
// match 7.0phalcon3...7.3phalcon3 or 7.2phalcon4...7.4phalcon4
|
||||
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
||||
script +=
|
||||
add_script +=
|
||||
'\nsh ' +
|
||||
path.join(__dirname, '../src/scripts/ext/phalcon.sh') +
|
||||
' ' +
|
||||
@ -270,7 +285,7 @@ export async function addExtensionLinux(
|
||||
return;
|
||||
// match 7.1xdebug..7.4xdebug
|
||||
case /^7\.[1-4]xdebug$/.test(version_extension):
|
||||
script +=
|
||||
add_script +=
|
||||
'\nupdate_extension xdebug 2.9.3' +
|
||||
pipe +
|
||||
'\n' +
|
||||
@ -279,7 +294,7 @@ export async function addExtensionLinux(
|
||||
// match pdo extensions
|
||||
case /.*pdo[_-].*/.test(version_extension):
|
||||
extension = extension.replace('pdo_', '').replace('pdo-', '');
|
||||
script += '\nadd_pdo_extension ' + extension;
|
||||
add_script += '\nadd_pdo_extension ' + extension;
|
||||
return;
|
||||
// match ast and uopz
|
||||
case /^(ast|uopz)$/.test(extension):
|
||||
@ -294,10 +309,10 @@ export async function addExtensionLinux(
|
||||
command = command_prefix + version + '-' + extension + pipe;
|
||||
break;
|
||||
}
|
||||
script +=
|
||||
add_script +=
|
||||
'\nadd_extension ' + extension + ' "' + command + '" ' + ext_prefix;
|
||||
});
|
||||
return script;
|
||||
return add_script + remove_script;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,9 +19,15 @@ add_log() {
|
||||
# Function to remove extensions
|
||||
remove_extension() {
|
||||
extension=$1
|
||||
sudo sed -i '' "/$extension/d" "$ini_file"
|
||||
sudo rm -rf "$scan_dir"/*"$extension"* >/dev/null 2>&1
|
||||
sudo rm -rf "$ext_dir"/"$extension".so >/dev/null 2>&1
|
||||
if check_extension "$extension"; then
|
||||
sudo sed -i '' "/$extension/d" "$ini_file"
|
||||
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
|
||||
@ -59,7 +65,7 @@ add_pecl_extension() {
|
||||
if [ "$ext_version" = "$pecl_version" ]; then
|
||||
add_log "$tick" "$extension" "Enabled"
|
||||
else
|
||||
remove_extension "$extension"
|
||||
remove_extension "$extension" >/dev/null 2>&1
|
||||
(
|
||||
sudo pecl install -f "$extension-$pecl_version" >/dev/null 2>&1 &&
|
||||
check_extension "$extension" &&
|
||||
|
@ -93,10 +93,16 @@ delete_extension() {
|
||||
# Function to disable and delete extensions
|
||||
remove_extension() {
|
||||
extension=$1
|
||||
if [[ ! "$version" =~ $old_versions ]] && [ -e /etc/php/"$version"/mods-available/"$extension".ini ]; then
|
||||
sudo phpdismod -v "$version" "$extension"
|
||||
if check_extension "$extension"; then
|
||||
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
|
||||
delete_extension "$extension"
|
||||
}
|
||||
|
||||
# Function to enable existing extension
|
||||
|
@ -120,10 +120,17 @@ Function Remove-Extension() {
|
||||
$extension
|
||||
)
|
||||
if(php -m | findstr -i $extension) {
|
||||
Disable-PhpExtension $extension $php_dir
|
||||
}
|
||||
if (Test-Path $ext_dir\php_$extension.dll) {
|
||||
Remove-Item $ext_dir\php_$extension.dll
|
||||
try {
|
||||
Disable-PhpExtension $extension $php_dir
|
||||
if (Test-Path $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)"
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user