Add support for unstable versions

This commit is contained in:
Shivam Mathur 2020-02-16 00:25:50 +05:30
parent 40944de129
commit 3a473c9a22
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A
6 changed files with 53 additions and 31 deletions

View File

@ -3,7 +3,7 @@ import * as extensions from '../src/extensions';
describe('Extension tests', () => {
it('checking addExtensionOnWindows', async () => {
let win32: string = await extensions.addExtension(
'xdebug, pcov, phalcon4, ast-beta, grpc-1.2.3',
'xdebug, pcov, phalcon4, ast-beta, grpc-1.2.3, inotify-1.2.3alpha2',
'7.4',
'win32'
);
@ -12,6 +12,7 @@ describe('Extension tests', () => {
expect(win32).toContain('phalcon.ps1 phalcon4');
expect(win32).toContain('Add-Extension ast beta');
expect(win32).toContain('Add-Extension grpc stable 1.2.3');
expect(win32).toContain('Add-Extension inotify alpha 1.2.3');
win32 = await extensions.addExtension(
'phalcon3, does_not_exist',

34
dist/index.js vendored
View File

@ -2679,17 +2679,17 @@ function addExtensionDarwin(extension_csv, version, pipe) {
return __awaiter(this, void 0, void 0, function* () {
extension = extension.toLowerCase();
const version_extension = version + extension;
const [extension_name, stability] = extension.split('-');
const prefix = yield utils.getExtensionPrefix(extension_name);
const [ext_name, ext_version] = extension.split('-');
const prefix = yield utils.getExtensionPrefix(ext_name);
let install_command = '';
switch (true) {
// match pre-release versions
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
script +=
'\nadd_unstable_extension ' +
extension_name +
ext_name +
' ' +
stability +
ext_version +
' ' +
prefix;
return;
@ -2755,16 +2755,22 @@ function addExtensionWindows(extension_csv, version, pipe) {
yield utils.asyncForEach(extensions, function (extension) {
return __awaiter(this, void 0, void 0, function* () {
extension = extension.toLowerCase();
const [extension_name, stability] = extension.split('-');
const [ext_name, ext_version] = extension.split('-');
const version_extension = version + extension;
let matches;
switch (true) {
// match pre-release versions
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
script += '\nAdd-Extension ' + extension_name + ' ' + stability;
script += '\nAdd-Extension ' + ext_name + ' ' + ext_version;
break;
// match exact versions
case /.*-\d+\.\d+\.\d+/.test(version_extension):
script += '\nAdd-Extension ' + extension_name + ' stable ' + stability;
case /.*-\d+\.\d+\.\d+$/.test(version_extension):
script += '\nAdd-Extension ' + ext_name + ' stable ' + ext_version;
return;
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 +=
'\nAdd-Extension ' + ext_name + ' ' + matches[2] + ' ' + matches[1];
return;
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
@ -2802,23 +2808,23 @@ function addExtensionLinux(extension_csv, version, pipe) {
return __awaiter(this, void 0, void 0, function* () {
extension = extension.toLowerCase();
const version_extension = version + extension;
const [extension_name, stability] = extension.split('-');
const prefix = yield utils.getExtensionPrefix(extension_name);
const [ext_name, ext_version] = extension.split('-');
const prefix = yield utils.getExtensionPrefix(ext_name);
let install_command = '';
switch (true) {
// match pre-release versions
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
script +=
'\nadd_unstable_extension ' +
extension_name +
ext_name +
' ' +
stability +
ext_version +
' ' +
prefix;
return;
// match exact versions
case /.*-\d+\.\d+\.\d+/.test(version_extension):
script += '\nadd_pecl_extension ' + extension_name + ' ' + stability;
case /.*-\d+\.\d+\.\d+.*/.test(version_extension):
script += '\nadd_pecl_extension ' + ext_name + ' ' + ext_version;
return;
// match 5.6gearman..7.4gearman
case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension):

View File

@ -18,17 +18,17 @@ export async function addExtensionDarwin(
await utils.asyncForEach(extensions, async function(extension: string) {
extension = extension.toLowerCase();
const version_extension: string = version + extension;
const [extension_name, stability]: string[] = extension.split('-');
const prefix = await utils.getExtensionPrefix(extension_name);
const [ext_name, ext_version]: string[] = extension.split('-');
const prefix = await utils.getExtensionPrefix(ext_name);
let install_command = '';
switch (true) {
// match pre-release versions
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
script +=
'\nadd_unstable_extension ' +
extension_name +
ext_name +
' ' +
stability +
ext_version +
' ' +
prefix;
return;
@ -94,16 +94,26 @@ export async function addExtensionWindows(
let script = '\n';
await utils.asyncForEach(extensions, async function(extension: string) {
extension = extension.toLowerCase();
const [extension_name, stability]: string[] = extension.split('-');
const [ext_name, ext_version]: string[] = extension.split('-');
const version_extension: string = version + extension;
let matches: RegExpExecArray;
switch (true) {
// match pre-release versions
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
script += '\nAdd-Extension ' + extension_name + ' ' + stability;
script += '\nAdd-Extension ' + ext_name + ' ' + ext_version;
break;
// match exact versions
case /.*-\d+\.\d+\.\d+/.test(version_extension):
script += '\nAdd-Extension ' + extension_name + ' stable ' + stability;
case /.*-\d+\.\d+\.\d+$/.test(version_extension):
script += '\nAdd-Extension ' + ext_name + ' stable ' + ext_version;
return;
case /.*-(\d+\.\d+\.\d)+(beta|alpha|devel|snapshot)\d*/.test(
version_extension
):
matches = /.*-(\d+\.\d+\.\d)+(beta|alpha|devel|snapshot)\d*/.exec(
version_extension
) as RegExpExecArray;
script +=
'\nAdd-Extension ' + ext_name + ' ' + matches[2] + ' ' + matches[1];
return;
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
@ -141,23 +151,23 @@ export async function addExtensionLinux(
await utils.asyncForEach(extensions, async function(extension: string) {
extension = extension.toLowerCase();
const version_extension: string = version + extension;
const [extension_name, stability]: string[] = extension.split('-');
const prefix = await utils.getExtensionPrefix(extension_name);
const [ext_name, ext_version]: string[] = extension.split('-');
const prefix = await utils.getExtensionPrefix(ext_name);
let install_command = '';
switch (true) {
// match pre-release versions
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
script +=
'\nadd_unstable_extension ' +
extension_name +
ext_name +
' ' +
stability +
ext_version +
' ' +
prefix;
return;
// match exact versions
case /.*-\d+\.\d+\.\d+/.test(version_extension):
script += '\nadd_pecl_extension ' + extension_name + ' ' + stability;
case /.*-\d+\.\d+\.\d+.*/.test(version_extension):
script += '\nadd_pecl_extension ' + ext_name + ' ' + ext_version;
return;
// match 5.6gearman..7.4gearman
case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension):

View File

@ -187,6 +187,7 @@ version=$1
nodot_version=${1/./}
old_versions="5.[3-5]"
existing_version=$(php-config --version | cut -c 1-3)
[[ -z "${update}" ]] && update='false' || update="${update}"
# Setup PHP
step_log "Setup PHP"

View File

@ -98,6 +98,7 @@ remove_extension() {
add_pecl_extension() {
extension=$1
pecl_version=$2
delete_extension "$extension"
(sudo pecl install -f "$extension-$pecl_version" >/dev/null 2>&1 &&
add_log "$tick" "$extension" "Installed and enabled") ||
add_log "$cross" "$extension" "Could not install $extension-$pecl_version on PHP $semver"
@ -251,6 +252,7 @@ old_versions="5.[4-5]"
debconf_fix="DEBIAN_FRONTEND=noninteractive"
apt_install="sudo $debconf_fix apt-fast install -y"
existing_version=$(php-config --version | cut -c 1-3)
[[ -z "${update}" ]] && update='false' || update="${update}"
# Setup PHP
step_log "Setup PHP"

View File

@ -56,9 +56,11 @@ Function Add-Extension {
}
else {
if($extension_version -ne '') {
$extension = "$extension -Version $extension_version"
Install-PhpExtension -Extension $extension -Version $extension_version -MinimumStability $mininum_stability -Path $php_dir
} else {
Install-PhpExtension -Extension $extension -MinimumStability $mininum_stability -Path $php_dir
}
Install-PhpExtension -Extension $extension -MinimumStability $mininum_stability -Path $php_dir
Add-Log $tick $extension "Installed and enabled"
}
}