mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 20:01:06 +07:00
Dry custom tools and extension code
This commit is contained in:
parent
f8b8d766d5
commit
188598ef9d
@ -13,8 +13,8 @@ describe('Extension tests', () => {
|
||||
expect(win32).toContain('Remove-Extension intl');
|
||||
expect(win32).toContain('Add-Phalcon phalcon4');
|
||||
expect(win32).toContain('Add-Ioncube');
|
||||
expect(win32).toContain('Add-OCI oci8');
|
||||
expect(win32).toContain('Add-OCI pdo_oci');
|
||||
expect(win32).toContain('Add-Oci oci8');
|
||||
expect(win32).toContain('Add-Oci pdo_oci');
|
||||
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');
|
||||
|
@ -17,15 +17,6 @@ httpm.HttpClient.prototype.get = jest.fn().mockImplementation(() => {
|
||||
});
|
||||
|
||||
describe('Tools tests', () => {
|
||||
it('checking getCommand', async () => {
|
||||
expect(await tools.getCommand('linux', 'tool')).toBe('add_tool ');
|
||||
expect(await tools.getCommand('darwin', 'tool')).toBe('add_tool ');
|
||||
expect(await tools.getCommand('win32', 'tool')).toBe('Add-Tool ');
|
||||
expect(await tools.getCommand('fedora', 'tool')).toContain(
|
||||
'Platform fedora is not supported'
|
||||
);
|
||||
});
|
||||
|
||||
it('checking parseToolVersion', async () => {
|
||||
expect(await tools.getToolVersion('latest')).toBe('latest');
|
||||
expect(await tools.getToolVersion('1.2.3')).toBe('1.2.3');
|
||||
@ -402,17 +393,6 @@ describe('Tools tests', () => {
|
||||
expect(script).toContain('Platform fedora is not supported');
|
||||
});
|
||||
|
||||
it('checking addCustomTool', async () => {
|
||||
let script: string = await tools.addCustomTool('tool', '1.2.3', 'linux');
|
||||
expect(script).toContain('tool.sh\nadd_tool 1.2.3');
|
||||
|
||||
script = await tools.addCustomTool('tool', '1.2.3', 'darwin');
|
||||
expect(script).toContain('tool.sh\nadd_tool 1.2.3');
|
||||
|
||||
script = await tools.addCustomTool('tool', '1.2.3', 'win32');
|
||||
expect(script).toContain('tool.ps1\nAdd-Tool 1.2.3');
|
||||
});
|
||||
|
||||
it('checking addTools on linux', async () => {
|
||||
const script: string = await tools.addTools(
|
||||
'blackfire, blackfire-player, cs2pr, flex, grpc_php_plugin, php-cs-fixer, phplint, phpstan, phpunit, pecl, phinx, phinx:1.2.3, phive, php-config, phpize, protoc, symfony, wp-cli',
|
||||
|
@ -174,6 +174,15 @@ describe('Utils tests', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('checking getCommand', async () => {
|
||||
expect(await utils.getCommand('linux', 'tool')).toBe('add_tool ');
|
||||
expect(await utils.getCommand('darwin', 'tool')).toBe('add_tool ');
|
||||
expect(await utils.getCommand('win32', 'tool')).toBe('Add-Tool ');
|
||||
expect(await utils.getCommand('fedora', 'tool')).toContain(
|
||||
'Platform fedora is not supported'
|
||||
);
|
||||
});
|
||||
|
||||
it('checking joins', async () => {
|
||||
expect(await utils.joins('a', 'b', 'c')).toBe('a b c');
|
||||
});
|
||||
@ -186,4 +195,17 @@ describe('Utils tests', () => {
|
||||
'Platform fedora is not supported'
|
||||
);
|
||||
});
|
||||
|
||||
it('checking customPackage', async () => {
|
||||
const script_path: string = path.join('ext', 'pkg.sh');
|
||||
expect(await utils.customPackage('pkg', 'ext', '1.2.3', 'linux')).toContain(
|
||||
script_path + '\nadd_pkg 1.2.3'
|
||||
);
|
||||
expect(
|
||||
await utils.customPackage('pdo_pkg', 'ext', '1.2.3', 'linux')
|
||||
).toContain(script_path + '\nadd_pkg 1.2.3');
|
||||
expect(
|
||||
await utils.customPackage('pkg8', 'ext', '1.2.3', 'linux')
|
||||
).toContain(script_path + '\nadd_pkg 1.2.3');
|
||||
});
|
||||
});
|
||||
|
153
dist/index.js
vendored
153
dist/index.js
vendored
@ -1314,7 +1314,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.scriptExtension = exports.joins = exports.getUnsupportedLog = exports.suppressOutput = exports.getExtensionPrefix = exports.CSVArray = exports.extensionArray = exports.writeScript = exports.readScript = exports.addLog = exports.stepLog = exports.log = exports.color = exports.asyncForEach = exports.getInput = void 0;
|
||||
exports.customPackage = exports.scriptExtension = exports.joins = exports.getCommand = exports.getUnsupportedLog = exports.suppressOutput = exports.getExtensionPrefix = exports.CSVArray = exports.extensionArray = exports.writeScript = exports.readScript = exports.addLog = exports.stepLog = exports.log = exports.color = exports.asyncForEach = exports.getInput = void 0;
|
||||
const fs = __importStar(__webpack_require__(747));
|
||||
const path = __importStar(__webpack_require__(622));
|
||||
const core = __importStar(__webpack_require__(470));
|
||||
@ -1542,6 +1542,24 @@ async function getUnsupportedLog(extension, version, os_version) {
|
||||
'\n');
|
||||
}
|
||||
exports.getUnsupportedLog = getUnsupportedLog;
|
||||
/**
|
||||
* Function to get command to setup tools
|
||||
*
|
||||
* @param os_version
|
||||
* @param suffix
|
||||
*/
|
||||
async function getCommand(os_version, suffix) {
|
||||
switch (os_version) {
|
||||
case 'linux':
|
||||
case 'darwin':
|
||||
return 'add_' + suffix + ' ';
|
||||
case 'win32':
|
||||
return 'Add-' + suffix.charAt(0).toUpperCase() + suffix.slice(1) + ' ';
|
||||
default:
|
||||
return await log('Platform ' + os_version + ' is not supported', os_version, 'error');
|
||||
}
|
||||
}
|
||||
exports.getCommand = getCommand;
|
||||
/**
|
||||
* Function to join strings with space
|
||||
*
|
||||
@ -1568,6 +1586,22 @@ async function scriptExtension(os_version) {
|
||||
}
|
||||
}
|
||||
exports.scriptExtension = scriptExtension;
|
||||
/**
|
||||
* Function to get script to add tools with custom support.
|
||||
*
|
||||
* @param pkg
|
||||
* @param type
|
||||
* @param version
|
||||
* @param os_version
|
||||
*/
|
||||
async function customPackage(pkg, type, version, os_version) {
|
||||
const pkg_name = pkg.replace(/\d+|pdo[_-]/, '');
|
||||
const script_extension = await scriptExtension(os_version);
|
||||
const script = path.join(__dirname, '../src/scripts/' + type + '/' + pkg_name + script_extension);
|
||||
const command = await getCommand(os_version, pkg_name);
|
||||
return '\n. ' + script + '\n' + command + version;
|
||||
}
|
||||
exports.customPackage = customPackage;
|
||||
|
||||
|
||||
/***/ }),
|
||||
@ -1947,28 +1981,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.addTools = exports.addCustomTool = exports.addPackage = exports.addDevTools = exports.addArchive = exports.getCleanedToolsList = exports.getComposerUrl = exports.addComposer = exports.getWpCliUrl = exports.getSymfonyUri = exports.getDeployerUrl = exports.getPharUrl = exports.addPhive = exports.getCodeceptionUri = exports.getCodeceptionUriBuilder = exports.getUri = exports.parseTool = exports.getToolVersion = exports.getCommand = void 0;
|
||||
exports.addTools = exports.addPackage = exports.addDevTools = exports.addArchive = exports.getCleanedToolsList = exports.getComposerUrl = exports.addComposer = exports.getWpCliUrl = exports.getSymfonyUri = exports.getDeployerUrl = exports.getPharUrl = exports.addPhive = exports.getCodeceptionUri = exports.getCodeceptionUriBuilder = exports.getUri = exports.parseTool = exports.getToolVersion = void 0;
|
||||
const utils = __importStar(__webpack_require__(163));
|
||||
const httpm = __importStar(__webpack_require__(539));
|
||||
const path = __importStar(__webpack_require__(622));
|
||||
/**
|
||||
* Function to get command to setup tools
|
||||
*
|
||||
* @param os_version
|
||||
* @param suffix
|
||||
*/
|
||||
async function getCommand(os_version, suffix) {
|
||||
switch (os_version) {
|
||||
case 'linux':
|
||||
case 'darwin':
|
||||
return 'add_' + suffix + ' ';
|
||||
case 'win32':
|
||||
return 'Add-' + suffix.charAt(0).toUpperCase() + suffix.slice(1) + ' ';
|
||||
default:
|
||||
return await utils.log('Platform ' + os_version + ' is not supported', os_version, 'error');
|
||||
}
|
||||
}
|
||||
exports.getCommand = getCommand;
|
||||
/**
|
||||
* Function to get tool version
|
||||
*
|
||||
@ -2116,10 +2131,10 @@ exports.getCodeceptionUri = getCodeceptionUri;
|
||||
async function addPhive(version, os_version) {
|
||||
switch (version) {
|
||||
case 'latest':
|
||||
return ((await getCommand(os_version, 'tool')) +
|
||||
return ((await utils.getCommand(os_version, 'tool')) +
|
||||
'https://phar.io/releases/phive.phar phive');
|
||||
default:
|
||||
return ((await getCommand(os_version, 'tool')) +
|
||||
return ((await utils.getCommand(os_version, 'tool')) +
|
||||
'https://github.com/phar-io/phive/releases/download/' +
|
||||
version +
|
||||
'/phive-' +
|
||||
@ -2277,7 +2292,7 @@ exports.getCleanedToolsList = getCleanedToolsList;
|
||||
* @param os_version
|
||||
*/
|
||||
async function addArchive(tool, version, url, os_version) {
|
||||
return (await getCommand(os_version, 'tool')) + url + ' ' + tool;
|
||||
return (await utils.getCommand(os_version, 'tool')) + url + ' ' + tool;
|
||||
}
|
||||
exports.addArchive = addArchive;
|
||||
/**
|
||||
@ -2310,24 +2325,10 @@ exports.addDevTools = addDevTools;
|
||||
* @param os_version
|
||||
*/
|
||||
async function addPackage(tool, release, prefix, os_version) {
|
||||
const tool_command = await getCommand(os_version, 'composertool');
|
||||
const tool_command = await utils.getCommand(os_version, 'composertool');
|
||||
return tool_command + tool + ' ' + release + ' ' + prefix;
|
||||
}
|
||||
exports.addPackage = addPackage;
|
||||
/**
|
||||
* Function to get script to add tools with custom support.
|
||||
*
|
||||
* @param tool
|
||||
* @param version
|
||||
* @param os_version
|
||||
*/
|
||||
async function addCustomTool(tool, version, os_version) {
|
||||
const script_extension = await utils.scriptExtension(os_version);
|
||||
const script = path.join(__dirname, '../src/scripts/tools/' + tool + script_extension);
|
||||
const command = await getCommand(os_version, tool);
|
||||
return '. ' + script + '\n' + command + version;
|
||||
}
|
||||
exports.addCustomTool = addCustomTool;
|
||||
/**
|
||||
* Setup tools
|
||||
*
|
||||
@ -2350,7 +2351,7 @@ async function addTools(tools_csv, php_version, os_version) {
|
||||
case 'blackfire':
|
||||
case 'grpc_php_plugin':
|
||||
case 'protoc':
|
||||
script += await addCustomTool(tool, version, os_version);
|
||||
script += await utils.customPackage(tool, 'tools', version, os_version);
|
||||
break;
|
||||
case 'blackfire-player':
|
||||
url = await getPharUrl('https://get.blackfire.io', tool, 'v', version);
|
||||
@ -2401,7 +2402,7 @@ async function addTools(tools_csv, php_version, os_version) {
|
||||
script += await addArchive(tool, version, url, os_version);
|
||||
break;
|
||||
case 'pecl':
|
||||
script += await getCommand(os_version, 'pecl');
|
||||
script += await utils.getCommand(os_version, 'pecl');
|
||||
break;
|
||||
case 'phan':
|
||||
url = github + 'phan/phan/' + uri;
|
||||
@ -3628,22 +3629,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.addExtension = exports.addExtensionLinux = exports.addExtensionWindows = exports.addExtensionDarwin = exports.customExtension = void 0;
|
||||
const path = __importStar(__webpack_require__(622));
|
||||
exports.addExtension = exports.addExtensionLinux = exports.addExtensionWindows = exports.addExtensionDarwin = void 0;
|
||||
const utils = __importStar(__webpack_require__(163));
|
||||
/**
|
||||
* Function to get script to install custom extensions
|
||||
*
|
||||
* @param script
|
||||
* @param command
|
||||
*/
|
||||
async function customExtension(script, ...command) {
|
||||
return ('\n. ' +
|
||||
path.join(__dirname, '../src/scripts/ext/' + script) +
|
||||
'\n' +
|
||||
(await utils.joins(...command)));
|
||||
}
|
||||
exports.customExtension = customExtension;
|
||||
/**
|
||||
* Install and enable extensions for darwin
|
||||
*
|
||||
@ -3668,20 +3655,14 @@ async function addExtensionDarwin(extension_csv, version, pipe) {
|
||||
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):
|
||||
add_script += await customExtension('blackfire.sh', 'add_blackfire', extension);
|
||||
return;
|
||||
// match pdo_oci and oci8
|
||||
case /^pdo_oci$|^oci8$/.test(extension):
|
||||
add_script += await customExtension('oci.sh', 'add_oci', extension);
|
||||
return;
|
||||
// match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube
|
||||
case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension):
|
||||
add_script += await customExtension('ioncube.sh', 'add_ioncube');
|
||||
return;
|
||||
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
|
||||
case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension):
|
||||
case /^pdo_oci$|^oci8$/.test(extension):
|
||||
case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension):
|
||||
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
||||
add_script += await customExtension('phalcon.sh', 'add_phalcon', extension);
|
||||
add_script += await utils.customPackage(ext_name, 'ext', extension, 'darwin');
|
||||
return;
|
||||
// match pre-release versions. For example - xdebug-beta
|
||||
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
|
||||
@ -3744,23 +3725,17 @@ async function addExtensionWindows(extension_csv, version) {
|
||||
case /^:/.test(ext_name):
|
||||
remove_script += '\nRemove-Extension ' + ext_name.slice(1);
|
||||
break;
|
||||
// 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):
|
||||
add_script += await customExtension('blackfire.ps1', 'Add-Blackfire', extension);
|
||||
break;
|
||||
// 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 pdo_oci and oci8
|
||||
case /^pdo_oci$|^oci8$/.test(extension):
|
||||
add_script += await customExtension('oci.ps1', 'Add-OCI', extension);
|
||||
break;
|
||||
// match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube
|
||||
case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension):
|
||||
add_script += await customExtension('ioncube.ps1', 'Add-Ioncube');
|
||||
break;
|
||||
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
|
||||
case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension):
|
||||
case /^pdo_oci$|^oci8$/.test(extension):
|
||||
case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension):
|
||||
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
||||
add_script += await customExtension('phalcon.ps1', 'Add-Phalcon', extension);
|
||||
break;
|
||||
add_script += await utils.customPackage(ext_name, 'ext', extension, 'win32');
|
||||
return;
|
||||
// match pre-release versions. For example - xdebug-beta
|
||||
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
|
||||
add_script += await utils.joins('\nAdd-Extension', ext_name, ext_version);
|
||||
@ -3827,25 +3802,17 @@ async function addExtensionLinux(extension_csv, version, pipe) {
|
||||
remove_script += '\nremove_extension ' + ext_name.slice(1);
|
||||
return;
|
||||
// match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire
|
||||
// match 5.3blackfire-{semver}...5.6blackfire-{semver}, 7.0blackfire-{semver}...7.4blackfire-{semver}
|
||||
case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension):
|
||||
add_script += await customExtension('blackfire.sh', 'add_blackfire', extension);
|
||||
return;
|
||||
// match 5.3blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0
|
||||
// match pdo_oci and oci8
|
||||
case /^pdo_oci$|^oci8$/.test(extension):
|
||||
add_script += await customExtension('oci.sh', 'add_oci', extension);
|
||||
return;
|
||||
// match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube
|
||||
case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension):
|
||||
add_script += await customExtension('ioncube.sh', 'add_ioncube');
|
||||
return;
|
||||
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
|
||||
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
||||
add_script += await customExtension('phalcon.sh', 'add_phalcon', extension);
|
||||
return;
|
||||
// match 5.6gearman..7.4gearman
|
||||
case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension):
|
||||
case /^pdo_oci$|^oci8$/.test(extension):
|
||||
case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension):
|
||||
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
||||
case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension):
|
||||
add_script += await customExtension('gearman.sh', 'add_gearman');
|
||||
add_script += await utils.customPackage(ext_name, 'ext', extension, 'linux');
|
||||
return;
|
||||
// match pre-release versions. For example - xdebug-beta
|
||||
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
|
||||
|
@ -1,24 +1,5 @@
|
||||
import * as path from 'path';
|
||||
import * as utils from './utils';
|
||||
|
||||
/**
|
||||
* Function to get script to install custom extensions
|
||||
*
|
||||
* @param script
|
||||
* @param command
|
||||
*/
|
||||
export async function customExtension(
|
||||
script: string,
|
||||
...command: string[]
|
||||
): Promise<string> {
|
||||
return (
|
||||
'\n. ' +
|
||||
path.join(__dirname, '../src/scripts/ext/' + script) +
|
||||
'\n' +
|
||||
(await utils.joins(...command))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Install and enable extensions for darwin
|
||||
*
|
||||
@ -47,29 +28,20 @@ export async function addExtensionDarwin(
|
||||
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
|
||||
// match pdo_oci and oci8
|
||||
// match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube
|
||||
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
|
||||
case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(
|
||||
version_extension
|
||||
):
|
||||
add_script += await customExtension(
|
||||
'blackfire.sh',
|
||||
'add_blackfire',
|
||||
extension
|
||||
);
|
||||
return;
|
||||
// match pdo_oci and oci8
|
||||
case /^pdo_oci$|^oci8$/.test(extension):
|
||||
add_script += await customExtension('oci.sh', 'add_oci', extension);
|
||||
return;
|
||||
// match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube
|
||||
case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension):
|
||||
add_script += await customExtension('ioncube.sh', 'add_ioncube');
|
||||
return;
|
||||
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
|
||||
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
||||
add_script += await customExtension(
|
||||
'phalcon.sh',
|
||||
'add_phalcon',
|
||||
extension
|
||||
add_script += await utils.customPackage(
|
||||
ext_name,
|
||||
'ext',
|
||||
extension,
|
||||
'darwin'
|
||||
);
|
||||
return;
|
||||
// match pre-release versions. For example - xdebug-beta
|
||||
@ -154,33 +126,24 @@ export async function addExtensionWindows(
|
||||
case /^:/.test(ext_name):
|
||||
remove_script += '\nRemove-Extension ' + ext_name.slice(1);
|
||||
break;
|
||||
// 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(
|
||||
// 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 pdo_oci and oci8
|
||||
// match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube
|
||||
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
|
||||
case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(
|
||||
version_extension
|
||||
):
|
||||
add_script += await customExtension(
|
||||
'blackfire.ps1',
|
||||
'Add-Blackfire',
|
||||
extension
|
||||
);
|
||||
break;
|
||||
// match pdo_oci and oci8
|
||||
case /^pdo_oci$|^oci8$/.test(extension):
|
||||
add_script += await customExtension('oci.ps1', 'Add-OCI', extension);
|
||||
break;
|
||||
// match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube
|
||||
case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension):
|
||||
add_script += await customExtension('ioncube.ps1', 'Add-Ioncube');
|
||||
break;
|
||||
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
|
||||
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
||||
add_script += await customExtension(
|
||||
'phalcon.ps1',
|
||||
'Add-Phalcon',
|
||||
extension
|
||||
add_script += await utils.customPackage(
|
||||
ext_name,
|
||||
'ext',
|
||||
extension,
|
||||
'win32'
|
||||
);
|
||||
break;
|
||||
return;
|
||||
// match pre-release versions. For example - xdebug-beta
|
||||
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
|
||||
add_script += await utils.joins(
|
||||
@ -269,35 +232,24 @@ export async function addExtensionLinux(
|
||||
remove_script += '\nremove_extension ' + ext_name.slice(1);
|
||||
return;
|
||||
// match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire
|
||||
// match 5.3blackfire-{semver}...5.6blackfire-{semver}, 7.0blackfire-{semver}...7.4blackfire-{semver}
|
||||
// match 5.3blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0
|
||||
// match pdo_oci and oci8
|
||||
// match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube
|
||||
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
|
||||
// match 5.6gearman..7.4gearman
|
||||
case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(
|
||||
version_extension
|
||||
):
|
||||
add_script += await customExtension(
|
||||
'blackfire.sh',
|
||||
'add_blackfire',
|
||||
extension
|
||||
);
|
||||
return;
|
||||
// match pdo_oci and oci8
|
||||
case /^pdo_oci$|^oci8$/.test(extension):
|
||||
add_script += await customExtension('oci.sh', 'add_oci', extension);
|
||||
return;
|
||||
// match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube
|
||||
case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension):
|
||||
add_script += await customExtension('ioncube.sh', 'add_ioncube');
|
||||
return;
|
||||
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
|
||||
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
||||
add_script += await customExtension(
|
||||
'phalcon.sh',
|
||||
'add_phalcon',
|
||||
extension
|
||||
);
|
||||
return;
|
||||
// match 5.6gearman..7.4gearman
|
||||
case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension):
|
||||
add_script += await customExtension('gearman.sh', 'add_gearman');
|
||||
add_script += await utils.customPackage(
|
||||
ext_name,
|
||||
'ext',
|
||||
extension,
|
||||
'linux'
|
||||
);
|
||||
return;
|
||||
// match pre-release versions. For example - xdebug-beta
|
||||
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
|
||||
|
@ -21,7 +21,7 @@ Function Add-InstantClient() {
|
||||
}
|
||||
|
||||
# Function to install oci8 and pdo_oci.
|
||||
Function Add-OCI() {
|
||||
Function Add-Oci() {
|
||||
Param (
|
||||
[Parameter(Position = 0, Mandatory = $true)]
|
||||
[ValidateNotNull()]
|
||||
|
59
src/tools.ts
59
src/tools.ts
@ -1,32 +1,6 @@
|
||||
import * as utils from './utils';
|
||||
import * as httpm from '@actions/http-client';
|
||||
import {IHttpClientResponse as hcr} from '@actions/http-client/interfaces';
|
||||
import * as path from 'path';
|
||||
|
||||
/**
|
||||
* Function to get command to setup tools
|
||||
*
|
||||
* @param os_version
|
||||
* @param suffix
|
||||
*/
|
||||
export async function getCommand(
|
||||
os_version: string,
|
||||
suffix: string
|
||||
): Promise<string> {
|
||||
switch (os_version) {
|
||||
case 'linux':
|
||||
case 'darwin':
|
||||
return 'add_' + suffix + ' ';
|
||||
case 'win32':
|
||||
return 'Add-' + suffix.charAt(0).toUpperCase() + suffix.slice(1) + ' ';
|
||||
default:
|
||||
return await utils.log(
|
||||
'Platform ' + os_version + ' is not supported',
|
||||
os_version,
|
||||
'error'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get tool version
|
||||
@ -194,12 +168,12 @@ export async function addPhive(
|
||||
switch (version) {
|
||||
case 'latest':
|
||||
return (
|
||||
(await getCommand(os_version, 'tool')) +
|
||||
(await utils.getCommand(os_version, 'tool')) +
|
||||
'https://phar.io/releases/phive.phar phive'
|
||||
);
|
||||
default:
|
||||
return (
|
||||
(await getCommand(os_version, 'tool')) +
|
||||
(await utils.getCommand(os_version, 'tool')) +
|
||||
'https://github.com/phar-io/phive/releases/download/' +
|
||||
version +
|
||||
'/phive-' +
|
||||
@ -390,7 +364,7 @@ export async function addArchive(
|
||||
url: string,
|
||||
os_version: string
|
||||
): Promise<string> {
|
||||
return (await getCommand(os_version, 'tool')) + url + ' ' + tool;
|
||||
return (await utils.getCommand(os_version, 'tool')) + url + ' ' + tool;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -442,31 +416,10 @@ export async function addPackage(
|
||||
prefix: string,
|
||||
os_version: string
|
||||
): Promise<string> {
|
||||
const tool_command = await getCommand(os_version, 'composertool');
|
||||
const tool_command = await utils.getCommand(os_version, 'composertool');
|
||||
return tool_command + tool + ' ' + release + ' ' + prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get script to add tools with custom support.
|
||||
*
|
||||
* @param tool
|
||||
* @param version
|
||||
* @param os_version
|
||||
*/
|
||||
export async function addCustomTool(
|
||||
tool: string,
|
||||
version: string,
|
||||
os_version: string
|
||||
): Promise<string> {
|
||||
const script_extension: string = await utils.scriptExtension(os_version);
|
||||
const script: string = path.join(
|
||||
__dirname,
|
||||
'../src/scripts/tools/' + tool + script_extension
|
||||
);
|
||||
const command: string = await getCommand(os_version, tool);
|
||||
return '. ' + script + '\n' + command + version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup tools
|
||||
*
|
||||
@ -500,7 +453,7 @@ export async function addTools(
|
||||
case 'blackfire':
|
||||
case 'grpc_php_plugin':
|
||||
case 'protoc':
|
||||
script += await addCustomTool(tool, version, os_version);
|
||||
script += await utils.customPackage(tool, 'tools', version, os_version);
|
||||
break;
|
||||
case 'blackfire-player':
|
||||
url = await getPharUrl('https://get.blackfire.io', tool, 'v', version);
|
||||
@ -556,7 +509,7 @@ export async function addTools(
|
||||
script += await addArchive(tool, version, url, os_version);
|
||||
break;
|
||||
case 'pecl':
|
||||
script += await getCommand(os_version, 'pecl');
|
||||
script += await utils.getCommand(os_version, 'pecl');
|
||||
break;
|
||||
case 'phan':
|
||||
url = github + 'phan/phan/' + uri;
|
||||
|
49
src/utils.ts
49
src/utils.ts
@ -284,6 +284,31 @@ export async function getUnsupportedLog(
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get command to setup tools
|
||||
*
|
||||
* @param os_version
|
||||
* @param suffix
|
||||
*/
|
||||
export async function getCommand(
|
||||
os_version: string,
|
||||
suffix: string
|
||||
): Promise<string> {
|
||||
switch (os_version) {
|
||||
case 'linux':
|
||||
case 'darwin':
|
||||
return 'add_' + suffix + ' ';
|
||||
case 'win32':
|
||||
return 'Add-' + suffix.charAt(0).toUpperCase() + suffix.slice(1) + ' ';
|
||||
default:
|
||||
return await log(
|
||||
'Platform ' + os_version + ' is not supported',
|
||||
os_version,
|
||||
'error'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to join strings with space
|
||||
*
|
||||
@ -313,3 +338,27 @@ export async function scriptExtension(os_version: string): Promise<string> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get script to add tools with custom support.
|
||||
*
|
||||
* @param pkg
|
||||
* @param type
|
||||
* @param version
|
||||
* @param os_version
|
||||
*/
|
||||
export async function customPackage(
|
||||
pkg: string,
|
||||
type: string,
|
||||
version: string,
|
||||
os_version: string
|
||||
): Promise<string> {
|
||||
const pkg_name: string = pkg.replace(/\d+|pdo[_-]/, '');
|
||||
const script_extension: string = await scriptExtension(os_version);
|
||||
const script: string = path.join(
|
||||
__dirname,
|
||||
'../src/scripts/' + type + '/' + pkg_name + script_extension
|
||||
);
|
||||
const command: string = await getCommand(os_version, pkg_name);
|
||||
return '\n. ' + script + '\n' + command + version;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user