mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 03:41:06 +07:00
Rename os_version => os
This commit is contained in:
parent
c2c73b16c1
commit
cad2a1bda3
@ -2,7 +2,7 @@ import * as config from '../src/config';
|
|||||||
|
|
||||||
describe('Config tests', () => {
|
describe('Config tests', () => {
|
||||||
it.each`
|
it.each`
|
||||||
ini_values | os_version | output
|
ini_values | os | output
|
||||||
${'a=b, c=d'} | ${'win32'} | ${'Add-Content "$php_dir\\php.ini" "a=b\nc=d"'}
|
${'a=b, c=d'} | ${'win32'} | ${'Add-Content "$php_dir\\php.ini" "a=b\nc=d"'}
|
||||||
${'a=b, c=d'} | ${'linux'} | ${'echo "a=b\nc=d" | sudo tee -a "${pecl_file:-${ini_file[@]}}"'}
|
${'a=b, c=d'} | ${'linux'} | ${'echo "a=b\nc=d" | sudo tee -a "${pecl_file:-${ini_file[@]}}"'}
|
||||||
${'a=b, c=d'} | ${'darwin'} | ${'echo "a=b\nc=d" | sudo tee -a "${pecl_file:-${ini_file[@]}}"'}
|
${'a=b, c=d'} | ${'darwin'} | ${'echo "a=b\nc=d" | sudo tee -a "${pecl_file:-${ini_file[@]}}"'}
|
||||||
@ -10,12 +10,7 @@ describe('Config tests', () => {
|
|||||||
${'a="~(b)"'} | ${'win32'} | ${'Add-Content "$php_dir\\php.ini" "a=\'~(b)\'"'}
|
${'a="~(b)"'} | ${'win32'} | ${'Add-Content "$php_dir\\php.ini" "a=\'~(b)\'"'}
|
||||||
${'a="b, c"'} | ${'win32'} | ${'Add-Content "$php_dir\\php.ini" "a=b, c"'}
|
${'a="b, c"'} | ${'win32'} | ${'Add-Content "$php_dir\\php.ini" "a=b, c"'}
|
||||||
${'a=b, c=d'} | ${'openbsd'} | ${'Platform openbsd is not supported'}
|
${'a=b, c=d'} | ${'openbsd'} | ${'Platform openbsd is not supported'}
|
||||||
`(
|
`('checking addINIValues on $os', async ({ini_values, os, output}) => {
|
||||||
'checking addINIValues on $os_version',
|
expect(await config.addINIValues(ini_values, os)).toContain(output);
|
||||||
async ({ini_values, os_version, output}) => {
|
});
|
||||||
expect(await config.addINIValues(ini_values, os_version)).toContain(
|
|
||||||
output
|
|
||||||
);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
@ -110,7 +110,9 @@ describe('Extension tests', () => {
|
|||||||
const [formula, extension]: string[] = line.split('=');
|
const [formula, extension]: string[] = line.split('=');
|
||||||
const prefix: string =
|
const prefix: string =
|
||||||
extension == 'xdebug' ? 'zend_extension' : 'extension';
|
extension == 'xdebug' ? 'zend_extension' : 'extension';
|
||||||
const output: string = fs.existsSync(`src/scripts/extensions/${extension}.sh`)
|
const output: string = fs.existsSync(
|
||||||
|
`src/scripts/extensions/${extension}.sh`
|
||||||
|
)
|
||||||
? `add_${extension}`
|
? `add_${extension}`
|
||||||
: `add_brew_extension ${formula} ${prefix}`;
|
: `add_brew_extension ${formula} ${prefix}`;
|
||||||
return [formula, '7.3', output];
|
return [formula, '7.3', output];
|
||||||
|
@ -18,17 +18,17 @@ jest.mock('../src/install', () => ({
|
|||||||
return script;
|
return script;
|
||||||
}),
|
}),
|
||||||
run: jest.fn().mockImplementation(async (): Promise<string> => {
|
run: jest.fn().mockImplementation(async (): Promise<string> => {
|
||||||
const os_version: string = process.env['RUNNER_OS'] || '';
|
const os: string = process.env['RUNNER_OS'] || '';
|
||||||
const version: string = await utils.parseVersion(
|
const version: string = await utils.parseVersion(
|
||||||
await utils.getInput('php-version', true)
|
await utils.getInput('php-version', true)
|
||||||
);
|
);
|
||||||
const ini_file: string = await utils.parseIniFile(
|
const ini_file: string = await utils.parseIniFile(
|
||||||
await utils.getInput('ini-file', false)
|
await utils.getInput('ini-file', false)
|
||||||
);
|
);
|
||||||
const tool = await utils.scriptTool(os_version);
|
const tool = await utils.scriptTool(os);
|
||||||
const filename = os_version + (await utils.scriptExtension(os_version));
|
const filename = os + (await utils.scriptExtension(os));
|
||||||
return [
|
return [
|
||||||
await install.getScript(filename, version, os_version),
|
await install.getScript(filename, version, os),
|
||||||
tool,
|
tool,
|
||||||
filename,
|
filename,
|
||||||
version,
|
version,
|
||||||
|
@ -6,7 +6,7 @@ interface IData {
|
|||||||
version?: string;
|
version?: string;
|
||||||
domain?: string;
|
domain?: string;
|
||||||
extension?: string;
|
extension?: string;
|
||||||
os_version?: string;
|
os?: string;
|
||||||
php_version?: string;
|
php_version?: string;
|
||||||
release?: string;
|
release?: string;
|
||||||
repository?: string;
|
repository?: string;
|
||||||
@ -23,7 +23,7 @@ function getData(data: IData): Record<string, string> {
|
|||||||
version: data.version || '',
|
version: data.version || '',
|
||||||
domain: data.domain || 'https://example.com',
|
domain: data.domain || 'https://example.com',
|
||||||
extension: data.extension || '.phar',
|
extension: data.extension || '.phar',
|
||||||
os_version: data.os_version || 'linux',
|
os: data.os || 'linux',
|
||||||
php_version: data.php_version || '7.4',
|
php_version: data.php_version || '7.4',
|
||||||
release: data.release || [data.tool, data.version].join(':'),
|
release: data.release || [data.tool, data.version].join(':'),
|
||||||
repository: data.repository || '',
|
repository: data.repository || '',
|
||||||
@ -197,45 +197,42 @@ describe('Tools tests', () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
it.each`
|
it.each`
|
||||||
os_version | script
|
os | script
|
||||||
${'linux'} | ${'add_tool https://example.com/tool.phar tool "-v"'}
|
${'linux'} | ${'add_tool https://example.com/tool.phar tool "-v"'}
|
||||||
${'darwin'} | ${'add_tool https://example.com/tool.phar tool "-v"'}
|
${'darwin'} | ${'add_tool https://example.com/tool.phar tool "-v"'}
|
||||||
${'win32'} | ${'Add-Tool https://example.com/tool.phar tool "-v"'}
|
${'win32'} | ${'Add-Tool https://example.com/tool.phar tool "-v"'}
|
||||||
${'openbsd'} | ${'Platform openbsd is not supported'}
|
${'openbsd'} | ${'Platform openbsd is not supported'}
|
||||||
`('checking addArchive: $os_version', async ({os_version, script}) => {
|
`('checking addArchive: $os', async ({os, script}) => {
|
||||||
const data = getData({
|
const data = getData({
|
||||||
tool: 'tool',
|
tool: 'tool',
|
||||||
version: 'latest',
|
version: 'latest',
|
||||||
version_parameter: JSON.stringify('-v'),
|
version_parameter: JSON.stringify('-v'),
|
||||||
os_version: os_version
|
os: os
|
||||||
});
|
});
|
||||||
data['url'] = 'https://example.com/tool.phar';
|
data['url'] = 'https://example.com/tool.phar';
|
||||||
expect(await tools.addArchive(data)).toContain(script);
|
expect(await tools.addArchive(data)).toContain(script);
|
||||||
});
|
});
|
||||||
|
|
||||||
it.each`
|
it.each`
|
||||||
os_version | script | scope
|
os | script | scope
|
||||||
${'linux'} | ${'add_composertool tool tool:1.2.3 user/ global'} | ${'global'}
|
${'linux'} | ${'add_composertool tool tool:1.2.3 user/ global'} | ${'global'}
|
||||||
${'darwin'} | ${'add_composertool tool tool:1.2.3 user/ scoped'} | ${'scoped'}
|
${'darwin'} | ${'add_composertool tool tool:1.2.3 user/ scoped'} | ${'scoped'}
|
||||||
${'win32'} | ${'Add-Composertool tool tool:1.2.3 user/ scoped'} | ${'scoped'}
|
${'win32'} | ${'Add-Composertool tool tool:1.2.3 user/ scoped'} | ${'scoped'}
|
||||||
${'openbsd'} | ${'Platform openbsd is not supported'} | ${'global'}
|
${'openbsd'} | ${'Platform openbsd is not supported'} | ${'global'}
|
||||||
`(
|
`('checking addPackage: $os, $scope', async ({os, script, scope}) => {
|
||||||
'checking addPackage: $os_version, $scope',
|
const data = getData({
|
||||||
async ({os_version, script, scope}) => {
|
tool: 'tool',
|
||||||
const data = getData({
|
version: '1.2.3',
|
||||||
tool: 'tool',
|
repository: 'user/tool',
|
||||||
version: '1.2.3',
|
os: os,
|
||||||
repository: 'user/tool',
|
scope: scope
|
||||||
os_version: os_version,
|
});
|
||||||
scope: scope
|
data['release'] = [data['tool'], data['version']].join(':');
|
||||||
});
|
expect(await tools.addPackage(data)).toContain(script);
|
||||||
data['release'] = [data['tool'], data['version']].join(':');
|
});
|
||||||
expect(await tools.addPackage(data)).toContain(script);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
it.each`
|
it.each`
|
||||||
version | php_version | os_version | script
|
version | php_version | os | script
|
||||||
${'latest'} | ${'7.4'} | ${'linux'} | ${'add_tool https://github.com/phar-io/phive/releases/download/3.2.1/phive-3.2.1.phar phive'}
|
${'latest'} | ${'7.4'} | ${'linux'} | ${'add_tool https://github.com/phar-io/phive/releases/download/3.2.1/phive-3.2.1.phar phive'}
|
||||||
${'1.2.3'} | ${'7.4'} | ${'darwin'} | ${'add_tool https://github.com/phar-io/phive/releases/download/1.2.3/phive-1.2.3.phar phive'}
|
${'1.2.3'} | ${'7.4'} | ${'darwin'} | ${'add_tool https://github.com/phar-io/phive/releases/download/1.2.3/phive-1.2.3.phar phive'}
|
||||||
${'1.2.3'} | ${'7.2'} | ${'win32'} | ${'Add-Tool https://github.com/phar-io/phive/releases/download/0.14.5/phive-0.14.5.phar phive'}
|
${'1.2.3'} | ${'7.2'} | ${'win32'} | ${'Add-Tool https://github.com/phar-io/phive/releases/download/0.14.5/phive-0.14.5.phar phive'}
|
||||||
@ -243,15 +240,15 @@ describe('Tools tests', () => {
|
|||||||
${'latest'} | ${'5.6'} | ${'win32'} | ${'Add-Tool https://github.com/phar-io/phive/releases/download/0.12.1/phive-0.12.1.phar phive'}
|
${'latest'} | ${'5.6'} | ${'win32'} | ${'Add-Tool https://github.com/phar-io/phive/releases/download/0.12.1/phive-0.12.1.phar phive'}
|
||||||
${'latest'} | ${'5.5'} | ${'win32'} | ${'Phive is not supported on PHP 5.5'}
|
${'latest'} | ${'5.5'} | ${'win32'} | ${'Phive is not supported on PHP 5.5'}
|
||||||
`(
|
`(
|
||||||
'checking addPhive: $version, $php_version, $os_version',
|
'checking addPhive: $version, $php_version, $os',
|
||||||
async ({version, php_version, os_version, script}) => {
|
async ({version, php_version, os, script}) => {
|
||||||
const data = getData({
|
const data = getData({
|
||||||
tool: 'phive',
|
tool: 'phive',
|
||||||
repository: 'phar-io/phive',
|
repository: 'phar-io/phive',
|
||||||
version_parameter: 'status',
|
version_parameter: 'status',
|
||||||
version: version,
|
version: version,
|
||||||
php_version: php_version,
|
php_version: php_version,
|
||||||
os_version: os_version
|
os: os
|
||||||
});
|
});
|
||||||
script = await tools.addPhive(data);
|
script = await tools.addPhive(data);
|
||||||
expect(script).toContain(script);
|
expect(script).toContain(script);
|
||||||
@ -322,7 +319,7 @@ describe('Tools tests', () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
it.each`
|
it.each`
|
||||||
version | os_version | uri
|
version | os | uri
|
||||||
${'latest'} | ${'linux'} | ${'releases/latest/download/symfony_linux_amd64'}
|
${'latest'} | ${'linux'} | ${'releases/latest/download/symfony_linux_amd64'}
|
||||||
${'1.2.3'} | ${'linux'} | ${'releases/download/v1.2.3/symfony_linux_amd64'}
|
${'1.2.3'} | ${'linux'} | ${'releases/download/v1.2.3/symfony_linux_amd64'}
|
||||||
${'latest'} | ${'darwin'} | ${'releases/latest/download/symfony_darwin_amd64'}
|
${'latest'} | ${'darwin'} | ${'releases/latest/download/symfony_darwin_amd64'}
|
||||||
@ -330,18 +327,15 @@ describe('Tools tests', () => {
|
|||||||
${'latest'} | ${'win32'} | ${'releases/latest/download/symfony_windows_amd64.exe'}
|
${'latest'} | ${'win32'} | ${'releases/latest/download/symfony_windows_amd64.exe'}
|
||||||
${'1.2.3'} | ${'win32'} | ${'releases/download/v1.2.3/symfony_windows_amd64.exe'}
|
${'1.2.3'} | ${'win32'} | ${'releases/download/v1.2.3/symfony_windows_amd64.exe'}
|
||||||
${'latest'} | ${'openbsd'} | ${'Platform openbsd is not supported'}
|
${'latest'} | ${'openbsd'} | ${'Platform openbsd is not supported'}
|
||||||
`(
|
`('checking addSymfony: $version, $os', async ({version, os, uri}) => {
|
||||||
'checking addSymfony: $version, $os_version',
|
const data = getData({
|
||||||
async ({version, os_version, uri}) => {
|
tool: 'symfony',
|
||||||
const data = getData({
|
php_version: '7.4',
|
||||||
tool: 'symfony',
|
version: version,
|
||||||
php_version: '7.4',
|
os: os
|
||||||
version: version,
|
});
|
||||||
os_version: os_version
|
expect(await tools.addSymfony(data)).toContain(uri);
|
||||||
});
|
});
|
||||||
expect(await tools.addSymfony(data)).toContain(uri);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
it.each`
|
it.each`
|
||||||
version | uri
|
version | uri
|
||||||
@ -359,7 +353,7 @@ describe('Tools tests', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it.each`
|
it.each`
|
||||||
tool | os_version | script
|
tool | os | script
|
||||||
${'phpize'} | ${'linux'} | ${'add_devtools phpize'}
|
${'phpize'} | ${'linux'} | ${'add_devtools phpize'}
|
||||||
${'php-config'} | ${'linux'} | ${'add_devtools php-config'}
|
${'php-config'} | ${'linux'} | ${'add_devtools php-config'}
|
||||||
${'phpize'} | ${'darwin'} | ${'add_devtools phpize'}
|
${'phpize'} | ${'darwin'} | ${'add_devtools phpize'}
|
||||||
@ -367,17 +361,14 @@ describe('Tools tests', () => {
|
|||||||
${'phpize'} | ${'win32'} | ${'Add-Log "$tick" "phpize" "phpize is not a windows tool"'}
|
${'phpize'} | ${'win32'} | ${'Add-Log "$tick" "phpize" "phpize is not a windows tool"'}
|
||||||
${'php-config'} | ${'win32'} | ${'Add-Log "$tick" "php-config" "php-config is not a windows tool"'}
|
${'php-config'} | ${'win32'} | ${'Add-Log "$tick" "php-config" "php-config is not a windows tool"'}
|
||||||
${'phpize'} | ${'openbsd'} | ${'Platform openbsd is not supported'}
|
${'phpize'} | ${'openbsd'} | ${'Platform openbsd is not supported'}
|
||||||
`(
|
`('checking addDevTools: $tool, $os', async ({tool, os, script}) => {
|
||||||
'checking addDevTools: $tool, $os_version',
|
const data = getData({
|
||||||
async ({tool, os_version, script}) => {
|
version: '7.4',
|
||||||
const data = getData({
|
tool: tool,
|
||||||
version: '7.4',
|
os: os
|
||||||
tool: tool,
|
});
|
||||||
os_version: os_version
|
expect(await tools.addDevTools(data)).toContain(script);
|
||||||
});
|
});
|
||||||
expect(await tools.addDevTools(data)).toContain(script);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
it.each([
|
it.each([
|
||||||
[
|
[
|
||||||
|
@ -70,7 +70,7 @@ describe('Utils tests', () => {
|
|||||||
expect(await utils.parseIniFile('php.ini-production')).toBe('production');
|
expect(await utils.parseIniFile('php.ini-production')).toBe('production');
|
||||||
expect(await utils.parseIniFile('php.ini-development')).toBe('development');
|
expect(await utils.parseIniFile('php.ini-development')).toBe('development');
|
||||||
expect(await utils.parseIniFile('invalid')).toBe('production');
|
expect(await utils.parseIniFile('invalid')).toBe('production');
|
||||||
})
|
});
|
||||||
|
|
||||||
it('checking asyncForEach', async () => {
|
it('checking asyncForEach', async () => {
|
||||||
const array: Array<string> = ['a', 'b', 'c'];
|
const array: Array<string> = ['a', 'b', 'c'];
|
||||||
|
172
dist/index.js
vendored
172
dist/index.js
vendored
@ -51,28 +51,28 @@ async function addINIValuesWindows(ini_values_csv) {
|
|||||||
return ('Add-Content "$php_dir\\php.ini" "' + ini_values.join('\n') + '"' + script);
|
return ('Add-Content "$php_dir\\php.ini" "' + ini_values.join('\n') + '"' + script);
|
||||||
}
|
}
|
||||||
exports.addINIValuesWindows = addINIValuesWindows;
|
exports.addINIValuesWindows = addINIValuesWindows;
|
||||||
async function addINIValues(ini_values_csv, os_version, no_step = false) {
|
async function addINIValues(ini_values_csv, os, no_step = false) {
|
||||||
let script = '\n';
|
let script = '\n';
|
||||||
switch (no_step) {
|
switch (no_step) {
|
||||||
case true:
|
case true:
|
||||||
script +=
|
script +=
|
||||||
(await utils.stepLog('Add php.ini values', os_version)) +
|
(await utils.stepLog('Add php.ini values', os)) +
|
||||||
(await utils.suppressOutput(os_version)) +
|
(await utils.suppressOutput(os)) +
|
||||||
'\n';
|
'\n';
|
||||||
break;
|
break;
|
||||||
case false:
|
case false:
|
||||||
default:
|
default:
|
||||||
script += (await utils.stepLog('Add php.ini values', os_version)) + '\n';
|
script += (await utils.stepLog('Add php.ini values', os)) + '\n';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
switch (os_version) {
|
switch (os) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return script + (await addINIValuesWindows(ini_values_csv));
|
return script + (await addINIValuesWindows(ini_values_csv));
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
case 'linux':
|
case 'linux':
|
||||||
return script + (await addINIValuesUnix(ini_values_csv));
|
return script + (await addINIValuesUnix(ini_values_csv));
|
||||||
default:
|
default:
|
||||||
return await utils.log('Platform ' + os_version + ' is not supported', os_version, 'error');
|
return await utils.log('Platform ' + os + ' is not supported', os, 'error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.addINIValues = addINIValues;
|
exports.addINIValues = addINIValues;
|
||||||
@ -117,69 +117,65 @@ async function checkXdebugError(extension, version) {
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
exports.checkXdebugError = checkXdebugError;
|
exports.checkXdebugError = checkXdebugError;
|
||||||
async function addCoverageXdebug(extension, version, os_version, pipe) {
|
async function addCoverageXdebug(extension, version, os, pipe) {
|
||||||
let script = '\n';
|
let script = '\n';
|
||||||
let message = await checkXdebugError(extension, version);
|
let message = await checkXdebugError(extension, version);
|
||||||
let status = '$cross';
|
let status = '$cross';
|
||||||
if (!message) {
|
if (!message) {
|
||||||
script +=
|
script +=
|
||||||
(await extensions.addExtension(':pcov:false', version, os_version, true)) + pipe;
|
(await extensions.addExtension(':pcov:false', version, os, true)) + pipe;
|
||||||
extension = extension == 'xdebug3' ? 'xdebug' : extension;
|
extension = extension == 'xdebug3' ? 'xdebug' : extension;
|
||||||
script +=
|
script +=
|
||||||
(await extensions.addExtension(extension, version, os_version, true)) +
|
(await extensions.addExtension(extension, version, os, true)) + pipe;
|
||||||
pipe;
|
|
||||||
message = 'Xdebug enabled as coverage driver';
|
message = 'Xdebug enabled as coverage driver';
|
||||||
status = '$tick';
|
status = '$tick';
|
||||||
}
|
}
|
||||||
script += await utils.addLog(status, extension, message, os_version);
|
script += await utils.addLog(status, extension, message, os);
|
||||||
return script;
|
return script;
|
||||||
}
|
}
|
||||||
exports.addCoverageXdebug = addCoverageXdebug;
|
exports.addCoverageXdebug = addCoverageXdebug;
|
||||||
async function addCoveragePCOV(version, os_version, pipe) {
|
async function addCoveragePCOV(version, os, pipe) {
|
||||||
let script = '\n';
|
let script = '\n';
|
||||||
switch (true) {
|
switch (true) {
|
||||||
default:
|
default:
|
||||||
script +=
|
script +=
|
||||||
(await extensions.addExtension(':xdebug:false', version, os_version, true)) + pipe;
|
(await extensions.addExtension(':xdebug:false', version, os, true)) +
|
||||||
script +=
|
|
||||||
(await extensions.addExtension('pcov', version, os_version, true)) +
|
|
||||||
pipe;
|
pipe;
|
||||||
script +=
|
script +=
|
||||||
(await config.addINIValues('pcov.enabled=1', os_version, true)) + '\n';
|
(await extensions.addExtension('pcov', version, os, true)) + pipe;
|
||||||
script += await utils.addLog('$tick', 'coverage: pcov', 'PCOV enabled as coverage driver', os_version);
|
script += (await config.addINIValues('pcov.enabled=1', os, true)) + '\n';
|
||||||
|
script += await utils.addLog('$tick', 'coverage: pcov', 'PCOV enabled as coverage driver', os);
|
||||||
break;
|
break;
|
||||||
case /5\.[3-6]|7\.0/.test(version):
|
case /5\.[3-6]|7\.0/.test(version):
|
||||||
script += await utils.addLog('$cross', 'pcov', 'PHP 7.1 or newer is required', os_version);
|
script += await utils.addLog('$cross', 'pcov', 'PHP 7.1 or newer is required', os);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return script;
|
return script;
|
||||||
}
|
}
|
||||||
exports.addCoveragePCOV = addCoveragePCOV;
|
exports.addCoveragePCOV = addCoveragePCOV;
|
||||||
async function disableCoverage(version, os_version, pipe) {
|
async function disableCoverage(version, os, pipe) {
|
||||||
let script = '\n';
|
let script = '\n';
|
||||||
script +=
|
script +=
|
||||||
(await extensions.addExtension(':pcov:false', version, os_version, true)) +
|
(await extensions.addExtension(':pcov:false', version, os, true)) + pipe;
|
||||||
pipe;
|
|
||||||
script +=
|
script +=
|
||||||
(await extensions.addExtension(':xdebug:false', version, os_version, true)) + pipe;
|
(await extensions.addExtension(':xdebug:false', version, os, true)) + pipe;
|
||||||
script += await utils.addLog('$tick', 'none', 'Disabled Xdebug and PCOV', os_version);
|
script += await utils.addLog('$tick', 'none', 'Disabled Xdebug and PCOV', os);
|
||||||
return script;
|
return script;
|
||||||
}
|
}
|
||||||
exports.disableCoverage = disableCoverage;
|
exports.disableCoverage = disableCoverage;
|
||||||
async function addCoverage(coverage_driver, version, os_version) {
|
async function addCoverage(coverage_driver, version, os) {
|
||||||
coverage_driver = coverage_driver.toLowerCase();
|
coverage_driver = coverage_driver.toLowerCase();
|
||||||
const script = '\n' + (await utils.stepLog('Setup Coverage', os_version));
|
const script = '\n' + (await utils.stepLog('Setup Coverage', os));
|
||||||
const pipe = (await utils.suppressOutput(os_version)) + '\n';
|
const pipe = (await utils.suppressOutput(os)) + '\n';
|
||||||
switch (coverage_driver) {
|
switch (coverage_driver) {
|
||||||
case 'pcov':
|
case 'pcov':
|
||||||
return script + (await addCoveragePCOV(version, os_version, pipe));
|
return script + (await addCoveragePCOV(version, os, pipe));
|
||||||
case 'xdebug':
|
case 'xdebug':
|
||||||
case 'xdebug2':
|
case 'xdebug2':
|
||||||
case 'xdebug3':
|
case 'xdebug3':
|
||||||
return (script +
|
return (script + (await addCoverageXdebug(coverage_driver, version, os, pipe)));
|
||||||
(await addCoverageXdebug(coverage_driver, version, os_version, pipe)));
|
|
||||||
case 'none':
|
case 'none':
|
||||||
return script + (await disableCoverage(version, os_version, pipe));
|
return script + (await disableCoverage(version, os, pipe));
|
||||||
default:
|
default:
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
@ -381,19 +377,19 @@ async function addExtensionLinux(extension_csv, version) {
|
|||||||
return add_script + remove_script;
|
return add_script + remove_script;
|
||||||
}
|
}
|
||||||
exports.addExtensionLinux = addExtensionLinux;
|
exports.addExtensionLinux = addExtensionLinux;
|
||||||
async function addExtension(extension_csv, version, os_version, no_step = false) {
|
async function addExtension(extension_csv, version, os, no_step = false) {
|
||||||
const log = await utils.stepLog('Setup Extensions', os_version);
|
const log = await utils.stepLog('Setup Extensions', os);
|
||||||
let script = '\n';
|
let script = '\n';
|
||||||
switch (no_step) {
|
switch (no_step) {
|
||||||
case true:
|
case true:
|
||||||
script += log + (await utils.suppressOutput(os_version));
|
script += log + (await utils.suppressOutput(os));
|
||||||
break;
|
break;
|
||||||
case false:
|
case false:
|
||||||
default:
|
default:
|
||||||
script += log;
|
script += log;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
switch (os_version) {
|
switch (os) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return script + (await addExtensionWindows(extension_csv, version));
|
return script + (await addExtensionWindows(extension_csv, version));
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
@ -401,7 +397,7 @@ async function addExtension(extension_csv, version, os_version, no_step = false)
|
|||||||
case 'linux':
|
case 'linux':
|
||||||
return script + (await addExtensionLinux(extension_csv, version));
|
return script + (await addExtensionLinux(extension_csv, version));
|
||||||
default:
|
default:
|
||||||
return await utils.log('Platform ' + os_version + ' is not supported', os_version, 'error');
|
return await utils.log('Platform ' + os + ' is not supported', os, 'error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.addExtension = addExtension;
|
exports.addExtension = addExtension;
|
||||||
@ -447,7 +443,7 @@ const tools = __importStar(__nccwpck_require__(740));
|
|||||||
const utils = __importStar(__nccwpck_require__(918));
|
const utils = __importStar(__nccwpck_require__(918));
|
||||||
const path_1 = __importDefault(__nccwpck_require__(17));
|
const path_1 = __importDefault(__nccwpck_require__(17));
|
||||||
const fs_1 = __importDefault(__nccwpck_require__(147));
|
const fs_1 = __importDefault(__nccwpck_require__(147));
|
||||||
async function getScript(filename, version, os_version) {
|
async function getScript(filename, version, os) {
|
||||||
const url = 'https://setup-php.com/sponsor';
|
const url = 'https://setup-php.com/sponsor';
|
||||||
process.env['fail_fast'] = await utils.getInput('fail-fast', false);
|
process.env['fail_fast'] = await utils.getInput('fail-fast', false);
|
||||||
const extension_csv = await utils.getInput('extensions', false);
|
const extension_csv = await utils.getInput('extensions', false);
|
||||||
@ -457,17 +453,17 @@ async function getScript(filename, version, os_version) {
|
|||||||
const script_path = path_1.default.join(__dirname, '../src/scripts', filename);
|
const script_path = path_1.default.join(__dirname, '../src/scripts', filename);
|
||||||
let script = '\n';
|
let script = '\n';
|
||||||
if (extension_csv) {
|
if (extension_csv) {
|
||||||
script += await extensions.addExtension(extension_csv, version, os_version);
|
script += await extensions.addExtension(extension_csv, version, os);
|
||||||
}
|
}
|
||||||
script += await tools.addTools(tools_csv, version, os_version);
|
script += await tools.addTools(tools_csv, version, os);
|
||||||
if (coverage_driver) {
|
if (coverage_driver) {
|
||||||
script += await coverage.addCoverage(coverage_driver, version, os_version);
|
script += await coverage.addCoverage(coverage_driver, version, os);
|
||||||
}
|
}
|
||||||
if (ini_values_csv) {
|
if (ini_values_csv) {
|
||||||
script += await config.addINIValues(ini_values_csv, os_version);
|
script += await config.addINIValues(ini_values_csv, os);
|
||||||
}
|
}
|
||||||
script += '\n' + (await utils.stepLog(`Sponsor setup-php`, os_version));
|
script += '\n' + (await utils.stepLog(`Sponsor setup-php`, os));
|
||||||
script += '\n' + (await utils.addLog('$tick', 'setup-php', url, os_version));
|
script += '\n' + (await utils.addLog('$tick', 'setup-php', url, os));
|
||||||
fs_1.default.appendFileSync(script_path, script, { mode: 0o755 });
|
fs_1.default.appendFileSync(script_path, script, { mode: 0o755 });
|
||||||
return script_path;
|
return script_path;
|
||||||
}
|
}
|
||||||
@ -481,10 +477,10 @@ async function run() {
|
|||||||
const version = await utils.parseVersion(await utils.getInput('php-version', true));
|
const version = await utils.parseVersion(await utils.getInput('php-version', true));
|
||||||
const ini_file = await utils.parseIniFile(await utils.getInput('ini-file', false));
|
const ini_file = await utils.parseIniFile(await utils.getInput('ini-file', false));
|
||||||
if (version) {
|
if (version) {
|
||||||
const os_version = process.platform;
|
const os = process.platform;
|
||||||
const tool = await utils.scriptTool(os_version);
|
const tool = await utils.scriptTool(os);
|
||||||
const script = os_version + (await utils.scriptExtension(os_version));
|
const script = os + (await utils.scriptExtension(os));
|
||||||
const location = await getScript(script, version, os_version);
|
const location = await getScript(script, version, os);
|
||||||
await (0, exec_1.exec)(await utils.joins(tool, location, version, ini_file, __dirname));
|
await (0, exec_1.exec)(await utils.joins(tool, location, version, ini_file, __dirname));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -659,12 +655,12 @@ async function getPharUrl(data) {
|
|||||||
}
|
}
|
||||||
exports.getPharUrl = getPharUrl;
|
exports.getPharUrl = getPharUrl;
|
||||||
async function addArchive(data) {
|
async function addArchive(data) {
|
||||||
return ((await utils.getCommand(data['os_version'], 'tool')) +
|
return ((await utils.getCommand(data['os'], 'tool')) +
|
||||||
(await utils.joins(data['url'], data['tool'], data['version_parameter'])));
|
(await utils.joins(data['url'], data['tool'], data['version_parameter'])));
|
||||||
}
|
}
|
||||||
exports.addArchive = addArchive;
|
exports.addArchive = addArchive;
|
||||||
async function addPackage(data) {
|
async function addPackage(data) {
|
||||||
const command = await utils.getCommand(data['os_version'], 'composertool');
|
const command = await utils.getCommand(data['os'], 'composertool');
|
||||||
const parts = data['repository'].split('/');
|
const parts = data['repository'].split('/');
|
||||||
const args = await utils.joins(parts[1], data['release'], parts[0] + '/', data['scope']);
|
const args = await utils.joins(parts[1], data['release'], parts[0] + '/', data['scope']);
|
||||||
return command + args;
|
return command + args;
|
||||||
@ -715,19 +711,19 @@ async function addDeployer(data) {
|
|||||||
}
|
}
|
||||||
exports.addDeployer = addDeployer;
|
exports.addDeployer = addDeployer;
|
||||||
async function addDevTools(data) {
|
async function addDevTools(data) {
|
||||||
switch (data['os_version']) {
|
switch (data['os']) {
|
||||||
case 'linux':
|
case 'linux':
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
return 'add_devtools ' + data['tool'];
|
return 'add_devtools ' + data['tool'];
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return await utils.addLog('$tick', data['tool'], data['tool'] + ' is not a windows tool', 'win32');
|
return await utils.addLog('$tick', data['tool'], data['tool'] + ' is not a windows tool', 'win32');
|
||||||
default:
|
default:
|
||||||
return await utils.log('Platform ' + data['os_version'] + ' is not supported', data['os_version'], 'error');
|
return await utils.log('Platform ' + data['os'] + ' is not supported', data['os'], 'error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.addDevTools = addDevTools;
|
exports.addDevTools = addDevTools;
|
||||||
async function addPECL(data) {
|
async function addPECL(data) {
|
||||||
return await utils.getCommand(data['os_version'], 'pecl');
|
return await utils.getCommand(data['os'], 'pecl');
|
||||||
}
|
}
|
||||||
exports.addPECL = addPECL;
|
exports.addPECL = addPECL;
|
||||||
async function addPhing(data) {
|
async function addPhing(data) {
|
||||||
@ -739,7 +735,7 @@ exports.addPhing = addPhing;
|
|||||||
async function addPhive(data) {
|
async function addPhive(data) {
|
||||||
switch (true) {
|
switch (true) {
|
||||||
case /5\.[3-5]/.test(data['php_version']):
|
case /5\.[3-5]/.test(data['php_version']):
|
||||||
return await utils.addLog('$cross', 'phive', 'Phive is not supported on PHP ' + data['php_version'], data['os_version']);
|
return await utils.addLog('$cross', 'phive', 'Phive is not supported on PHP ' + data['php_version'], data['os']);
|
||||||
case /5\.6|7\.0/.test(data['php_version']):
|
case /5\.6|7\.0/.test(data['php_version']):
|
||||||
data['version'] = '0.12.1';
|
data['version'] = '0.12.1';
|
||||||
break;
|
break;
|
||||||
@ -765,16 +761,16 @@ async function addPHPUnitTools(data) {
|
|||||||
exports.addPHPUnitTools = addPHPUnitTools;
|
exports.addPHPUnitTools = addPHPUnitTools;
|
||||||
async function addSymfony(data) {
|
async function addSymfony(data) {
|
||||||
let filename;
|
let filename;
|
||||||
switch (data['os_version']) {
|
switch (data['os']) {
|
||||||
case 'linux':
|
case 'linux':
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
filename = 'symfony_' + data['os_version'] + '_amd64';
|
filename = 'symfony_' + data['os'] + '_amd64';
|
||||||
break;
|
break;
|
||||||
case 'win32':
|
case 'win32':
|
||||||
filename = 'symfony_windows_amd64.exe';
|
filename = 'symfony_windows_amd64.exe';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return await utils.log('Platform ' + data['os_version'] + ' is not supported', data['os_version'], 'error');
|
return await utils.log('Platform ' + data['os'] + ' is not supported', data['os'], 'error');
|
||||||
}
|
}
|
||||||
if (data['version'] === 'latest') {
|
if (data['version'] === 'latest') {
|
||||||
data['uri'] = ['releases/latest/download', filename].join('/');
|
data['uri'] = ['releases/latest/download', filename].join('/');
|
||||||
@ -798,7 +794,7 @@ async function addWPCLI(data) {
|
|||||||
return await addArchive(data);
|
return await addArchive(data);
|
||||||
}
|
}
|
||||||
exports.addWPCLI = addWPCLI;
|
exports.addWPCLI = addWPCLI;
|
||||||
async function getData(release, php_version, os_version) {
|
async function getData(release, php_version, os) {
|
||||||
var _a, _b, _c, _d, _e;
|
var _a, _b, _c, _d, _e;
|
||||||
const json_file_path = path_1.default.join(__dirname, '../src/configs/tools.json');
|
const json_file_path = path_1.default.join(__dirname, '../src/configs/tools.json');
|
||||||
const json_file = fs_1.default.readFileSync(json_file_path, 'utf8');
|
const json_file = fs_1.default.readFileSync(json_file_path, 'utf8');
|
||||||
@ -832,7 +828,7 @@ async function getData(release, php_version, os_version) {
|
|||||||
data['github'] = 'https://github.com';
|
data['github'] = 'https://github.com';
|
||||||
(_a = data['domain']) !== null && _a !== void 0 ? _a : (data['domain'] = data['github']);
|
(_a = data['domain']) !== null && _a !== void 0 ? _a : (data['domain'] = data['github']);
|
||||||
(_b = data['extension']) !== null && _b !== void 0 ? _b : (data['extension'] = '.phar');
|
(_b = data['extension']) !== null && _b !== void 0 ? _b : (data['extension'] = '.phar');
|
||||||
data['os_version'] = os_version;
|
data['os'] = os;
|
||||||
data['php_version'] = php_version;
|
data['php_version'] = php_version;
|
||||||
data['prefix'] = data['github'] === data['domain'] ? 'releases' : '';
|
data['prefix'] = data['github'] === data['domain'] ? 'releases' : '';
|
||||||
data['verb'] = data['github'] === data['domain'] ? 'download' : '';
|
data['verb'] = data['github'] === data['domain'] ? 'download' : '';
|
||||||
@ -860,21 +856,21 @@ exports.functionRecord = {
|
|||||||
symfony: addSymfony,
|
symfony: addSymfony,
|
||||||
wp_cli: addWPCLI
|
wp_cli: addWPCLI
|
||||||
};
|
};
|
||||||
async function addTools(tools_csv, php_version, os_version) {
|
async function addTools(tools_csv, php_version, os) {
|
||||||
let script = '\n';
|
let script = '\n';
|
||||||
if (tools_csv === 'none') {
|
if (tools_csv === 'none') {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
script += await utils.stepLog('Setup Tools', os_version);
|
script += await utils.stepLog('Setup Tools', os);
|
||||||
}
|
}
|
||||||
const tools_list = await filterList(await utils.CSVArray(tools_csv));
|
const tools_list = await filterList(await utils.CSVArray(tools_csv));
|
||||||
await utils.asyncForEach(tools_list, async function (release) {
|
await utils.asyncForEach(tools_list, async function (release) {
|
||||||
const data = await getData(release, php_version, os_version);
|
const data = await getData(release, php_version, os);
|
||||||
script += '\n';
|
script += '\n';
|
||||||
switch (true) {
|
switch (true) {
|
||||||
case data['error'] !== undefined:
|
case data['error'] !== undefined:
|
||||||
script += await utils.addLog('$cross', data['tool'], data['error'], data['os_version']);
|
script += await utils.addLog('$cross', data['tool'], data['error'], data['os']);
|
||||||
break;
|
break;
|
||||||
case 'phar' === data['type']:
|
case 'phar' === data['type']:
|
||||||
data['url'] = await getUrl(data);
|
data['url'] = await getUrl(data);
|
||||||
@ -884,7 +880,7 @@ async function addTools(tools_csv, php_version, os_version) {
|
|||||||
script += await addPackage(data);
|
script += await addPackage(data);
|
||||||
break;
|
break;
|
||||||
case 'custom-package' === data['type']:
|
case 'custom-package' === data['type']:
|
||||||
script += await utils.customPackage(data['tool'].split('-')[0], 'tools', data['version'], data['os_version']);
|
script += await utils.customPackage(data['tool'].split('-')[0], 'tools', data['version'], data['os']);
|
||||||
break;
|
break;
|
||||||
case 'custom-function' === data['type']:
|
case 'custom-function' === data['type']:
|
||||||
script += await exports.functionRecord[data['function']](data);
|
script += await exports.functionRecord[data['function']](data);
|
||||||
@ -892,7 +888,7 @@ async function addTools(tools_csv, php_version, os_version) {
|
|||||||
case /^none$/.test(data['tool']):
|
case /^none$/.test(data['tool']):
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
script += await utils.addLog('$cross', data['tool'], 'Tool ' + data['tool'] + ' is not supported', data['os_version']);
|
script += await utils.addLog('$cross', data['tool'], 'Tool ' + data['tool'] + ' is not supported', data['os']);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -1037,8 +1033,8 @@ async function color(type) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.color = color;
|
exports.color = color;
|
||||||
async function log(message, os_version, log_type) {
|
async function log(message, os, log_type) {
|
||||||
switch (os_version) {
|
switch (os) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return ('printf "\\033[' +
|
return ('printf "\\033[' +
|
||||||
(await color(log_type)) +
|
(await color(log_type)) +
|
||||||
@ -1052,27 +1048,27 @@ async function log(message, os_version, log_type) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.log = log;
|
exports.log = log;
|
||||||
async function stepLog(message, os_version) {
|
async function stepLog(message, os) {
|
||||||
switch (os_version) {
|
switch (os) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return 'Step-Log "' + message + '"';
|
return 'Step-Log "' + message + '"';
|
||||||
case 'linux':
|
case 'linux':
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
return 'step_log "' + message + '"';
|
return 'step_log "' + message + '"';
|
||||||
default:
|
default:
|
||||||
return await log('Platform ' + os_version + ' is not supported', os_version, 'error');
|
return await log('Platform ' + os + ' is not supported', os, 'error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.stepLog = stepLog;
|
exports.stepLog = stepLog;
|
||||||
async function addLog(mark, subject, message, os_version) {
|
async function addLog(mark, subject, message, os) {
|
||||||
switch (os_version) {
|
switch (os) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return 'Add-Log "' + mark + '" "' + subject + '" "' + message + '"';
|
return 'Add-Log "' + mark + '" "' + subject + '" "' + message + '"';
|
||||||
case 'linux':
|
case 'linux':
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
return 'add_log "' + mark + '" "' + subject + '" "' + message + '"';
|
return 'add_log "' + mark + '" "' + subject + '" "' + message + '"';
|
||||||
default:
|
default:
|
||||||
return await log('Platform ' + os_version + ' is not supported', os_version, 'error');
|
return await log('Platform ' + os + ' is not supported', os, 'error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.addLog = addLog;
|
exports.addLog = addLog;
|
||||||
@ -1126,33 +1122,33 @@ async function getExtensionPrefix(extension) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.getExtensionPrefix = getExtensionPrefix;
|
exports.getExtensionPrefix = getExtensionPrefix;
|
||||||
async function suppressOutput(os_version) {
|
async function suppressOutput(os) {
|
||||||
switch (os_version) {
|
switch (os) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return ' >$null 2>&1';
|
return ' >$null 2>&1';
|
||||||
case 'linux':
|
case 'linux':
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
return ' >/dev/null 2>&1';
|
return ' >/dev/null 2>&1';
|
||||||
default:
|
default:
|
||||||
return await log('Platform ' + os_version + ' is not supported', os_version, 'error');
|
return await log('Platform ' + os + ' is not supported', os, 'error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.suppressOutput = suppressOutput;
|
exports.suppressOutput = suppressOutput;
|
||||||
async function getUnsupportedLog(extension, version, os_version) {
|
async function getUnsupportedLog(extension, version, os) {
|
||||||
return ('\n' +
|
return ('\n' +
|
||||||
(await addLog('$cross', extension, [extension, 'is not supported on PHP', version].join(' '), os_version)) +
|
(await addLog('$cross', extension, [extension, 'is not supported on PHP', version].join(' '), os)) +
|
||||||
'\n');
|
'\n');
|
||||||
}
|
}
|
||||||
exports.getUnsupportedLog = getUnsupportedLog;
|
exports.getUnsupportedLog = getUnsupportedLog;
|
||||||
async function getCommand(os_version, suffix) {
|
async function getCommand(os, suffix) {
|
||||||
switch (os_version) {
|
switch (os) {
|
||||||
case 'linux':
|
case 'linux':
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
return 'add_' + suffix + ' ';
|
return 'add_' + suffix + ' ';
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return 'Add-' + suffix.charAt(0).toUpperCase() + suffix.slice(1) + ' ';
|
return 'Add-' + suffix.charAt(0).toUpperCase() + suffix.slice(1) + ' ';
|
||||||
default:
|
default:
|
||||||
return await log('Platform ' + os_version + ' is not supported', os_version, 'error');
|
return await log('Platform ' + os + ' is not supported', os, 'error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.getCommand = getCommand;
|
exports.getCommand = getCommand;
|
||||||
@ -1160,35 +1156,35 @@ async function joins(...str) {
|
|||||||
return [...str].join(' ');
|
return [...str].join(' ');
|
||||||
}
|
}
|
||||||
exports.joins = joins;
|
exports.joins = joins;
|
||||||
async function scriptExtension(os_version) {
|
async function scriptExtension(os) {
|
||||||
switch (os_version) {
|
switch (os) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return '.ps1';
|
return '.ps1';
|
||||||
case 'linux':
|
case 'linux':
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
return '.sh';
|
return '.sh';
|
||||||
default:
|
default:
|
||||||
return await log('Platform ' + os_version + ' is not supported', os_version, 'error');
|
return await log('Platform ' + os + ' is not supported', os, 'error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.scriptExtension = scriptExtension;
|
exports.scriptExtension = scriptExtension;
|
||||||
async function scriptTool(os_version) {
|
async function scriptTool(os) {
|
||||||
switch (os_version) {
|
switch (os) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return 'pwsh';
|
return 'pwsh';
|
||||||
case 'linux':
|
case 'linux':
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
return 'bash';
|
return 'bash';
|
||||||
default:
|
default:
|
||||||
return await log('Platform ' + os_version + ' is not supported', os_version, 'error');
|
return await log('Platform ' + os + ' is not supported', os, 'error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.scriptTool = scriptTool;
|
exports.scriptTool = scriptTool;
|
||||||
async function customPackage(pkg, type, version, os_version) {
|
async function customPackage(pkg, type, version, os) {
|
||||||
const pkg_name = pkg.replace(/\d+|(pdo|pecl)[_-]/, '');
|
const pkg_name = pkg.replace(/\d+|(pdo|pecl)[_-]/, '');
|
||||||
const script_extension = await scriptExtension(os_version);
|
const script_extension = await scriptExtension(os);
|
||||||
const script = path.join(__dirname, '../src/scripts/' + type + '/' + pkg_name + script_extension);
|
const script = path.join(__dirname, '../src/scripts/' + type + '/' + pkg_name + script_extension);
|
||||||
const command = await getCommand(os_version, pkg_name);
|
const command = await getCommand(os, pkg_name);
|
||||||
return '\n. ' + script + '\n' + command + version;
|
return '\n. ' + script + '\n' + command + version;
|
||||||
}
|
}
|
||||||
exports.customPackage = customPackage;
|
exports.customPackage = customPackage;
|
||||||
|
@ -45,28 +45,28 @@ export async function addINIValuesWindows(
|
|||||||
* Function to add custom ini values
|
* Function to add custom ini values
|
||||||
*
|
*
|
||||||
* @param ini_values_csv
|
* @param ini_values_csv
|
||||||
* @param os_version
|
* @param os
|
||||||
* @param no_step
|
* @param no_step
|
||||||
*/
|
*/
|
||||||
export async function addINIValues(
|
export async function addINIValues(
|
||||||
ini_values_csv: string,
|
ini_values_csv: string,
|
||||||
os_version: string,
|
os: string,
|
||||||
no_step = false
|
no_step = false
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
let script = '\n';
|
let script = '\n';
|
||||||
switch (no_step) {
|
switch (no_step) {
|
||||||
case true:
|
case true:
|
||||||
script +=
|
script +=
|
||||||
(await utils.stepLog('Add php.ini values', os_version)) +
|
(await utils.stepLog('Add php.ini values', os)) +
|
||||||
(await utils.suppressOutput(os_version)) +
|
(await utils.suppressOutput(os)) +
|
||||||
'\n';
|
'\n';
|
||||||
break;
|
break;
|
||||||
case false:
|
case false:
|
||||||
default:
|
default:
|
||||||
script += (await utils.stepLog('Add php.ini values', os_version)) + '\n';
|
script += (await utils.stepLog('Add php.ini values', os)) + '\n';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
switch (os_version) {
|
switch (os) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return script + (await addINIValuesWindows(ini_values_csv));
|
return script + (await addINIValuesWindows(ini_values_csv));
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
@ -74,8 +74,8 @@ export async function addINIValues(
|
|||||||
return script + (await addINIValuesUnix(ini_values_csv));
|
return script + (await addINIValuesUnix(ini_values_csv));
|
||||||
default:
|
default:
|
||||||
return await utils.log(
|
return await utils.log(
|
||||||
'Platform ' + os_version + ' is not supported',
|
'Platform ' + os + ' is not supported',
|
||||||
os_version,
|
os,
|
||||||
'error'
|
'error'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -20,13 +20,13 @@ export async function checkXdebugError(
|
|||||||
*
|
*
|
||||||
* @param extension
|
* @param extension
|
||||||
* @param version
|
* @param version
|
||||||
* @param os_version
|
* @param os
|
||||||
* @param pipe
|
* @param pipe
|
||||||
*/
|
*/
|
||||||
export async function addCoverageXdebug(
|
export async function addCoverageXdebug(
|
||||||
extension: string,
|
extension: string,
|
||||||
version: string,
|
version: string,
|
||||||
os_version: string,
|
os: string,
|
||||||
pipe: string
|
pipe: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
let script = '\n';
|
let script = '\n';
|
||||||
@ -34,20 +34,14 @@ export async function addCoverageXdebug(
|
|||||||
let status = '$cross';
|
let status = '$cross';
|
||||||
if (!message) {
|
if (!message) {
|
||||||
script +=
|
script +=
|
||||||
(await extensions.addExtension(
|
(await extensions.addExtension(':pcov:false', version, os, true)) + pipe;
|
||||||
':pcov:false',
|
|
||||||
version,
|
|
||||||
os_version,
|
|
||||||
true
|
|
||||||
)) + pipe;
|
|
||||||
extension = extension == 'xdebug3' ? 'xdebug' : extension;
|
extension = extension == 'xdebug3' ? 'xdebug' : extension;
|
||||||
script +=
|
script +=
|
||||||
(await extensions.addExtension(extension, version, os_version, true)) +
|
(await extensions.addExtension(extension, version, os, true)) + pipe;
|
||||||
pipe;
|
|
||||||
message = 'Xdebug enabled as coverage driver';
|
message = 'Xdebug enabled as coverage driver';
|
||||||
status = '$tick';
|
status = '$tick';
|
||||||
}
|
}
|
||||||
script += await utils.addLog(status, extension, message, os_version);
|
script += await utils.addLog(status, extension, message, os);
|
||||||
return script;
|
return script;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,36 +49,30 @@ export async function addCoverageXdebug(
|
|||||||
* Function to setup PCOV
|
* Function to setup PCOV
|
||||||
*
|
*
|
||||||
* @param version
|
* @param version
|
||||||
* @param os_version
|
* @param os
|
||||||
* @param pipe
|
* @param pipe
|
||||||
*/
|
*/
|
||||||
export async function addCoveragePCOV(
|
export async function addCoveragePCOV(
|
||||||
version: string,
|
version: string,
|
||||||
os_version: string,
|
os: string,
|
||||||
pipe: string
|
pipe: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
let script = '\n';
|
let script = '\n';
|
||||||
switch (true) {
|
switch (true) {
|
||||||
default:
|
default:
|
||||||
script +=
|
script +=
|
||||||
(await extensions.addExtension(
|
(await extensions.addExtension(':xdebug:false', version, os, true)) +
|
||||||
':xdebug:false',
|
|
||||||
version,
|
|
||||||
os_version,
|
|
||||||
true
|
|
||||||
)) + pipe;
|
|
||||||
script +=
|
|
||||||
(await extensions.addExtension('pcov', version, os_version, true)) +
|
|
||||||
pipe;
|
pipe;
|
||||||
script +=
|
script +=
|
||||||
(await config.addINIValues('pcov.enabled=1', os_version, true)) + '\n';
|
(await extensions.addExtension('pcov', version, os, true)) + pipe;
|
||||||
|
script += (await config.addINIValues('pcov.enabled=1', os, true)) + '\n';
|
||||||
|
|
||||||
// success
|
// success
|
||||||
script += await utils.addLog(
|
script += await utils.addLog(
|
||||||
'$tick',
|
'$tick',
|
||||||
'coverage: pcov',
|
'coverage: pcov',
|
||||||
'PCOV enabled as coverage driver',
|
'PCOV enabled as coverage driver',
|
||||||
os_version
|
os
|
||||||
);
|
);
|
||||||
// version is not supported
|
// version is not supported
|
||||||
break;
|
break;
|
||||||
@ -94,7 +82,7 @@ export async function addCoveragePCOV(
|
|||||||
'$cross',
|
'$cross',
|
||||||
'pcov',
|
'pcov',
|
||||||
'PHP 7.1 or newer is required',
|
'PHP 7.1 or newer is required',
|
||||||
os_version
|
os
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -106,31 +94,20 @@ export async function addCoveragePCOV(
|
|||||||
* Function to disable Xdebug and PCOV
|
* Function to disable Xdebug and PCOV
|
||||||
*
|
*
|
||||||
* @param version
|
* @param version
|
||||||
* @param os_version
|
* @param os
|
||||||
* @param pipe
|
* @param pipe
|
||||||
*/
|
*/
|
||||||
export async function disableCoverage(
|
export async function disableCoverage(
|
||||||
version: string,
|
version: string,
|
||||||
os_version: string,
|
os: string,
|
||||||
pipe: string
|
pipe: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
let script = '\n';
|
let script = '\n';
|
||||||
script +=
|
script +=
|
||||||
(await extensions.addExtension(':pcov:false', version, os_version, true)) +
|
(await extensions.addExtension(':pcov:false', version, os, true)) + pipe;
|
||||||
pipe;
|
|
||||||
script +=
|
script +=
|
||||||
(await extensions.addExtension(
|
(await extensions.addExtension(':xdebug:false', version, os, true)) + pipe;
|
||||||
':xdebug:false',
|
script += await utils.addLog('$tick', 'none', 'Disabled Xdebug and PCOV', os);
|
||||||
version,
|
|
||||||
os_version,
|
|
||||||
true
|
|
||||||
)) + pipe;
|
|
||||||
script += await utils.addLog(
|
|
||||||
'$tick',
|
|
||||||
'none',
|
|
||||||
'Disabled Xdebug and PCOV',
|
|
||||||
os_version
|
|
||||||
);
|
|
||||||
|
|
||||||
return script;
|
return script;
|
||||||
}
|
}
|
||||||
@ -140,29 +117,27 @@ export async function disableCoverage(
|
|||||||
*
|
*
|
||||||
* @param coverage_driver
|
* @param coverage_driver
|
||||||
* @param version
|
* @param version
|
||||||
* @param os_version
|
* @param os
|
||||||
*/
|
*/
|
||||||
export async function addCoverage(
|
export async function addCoverage(
|
||||||
coverage_driver: string,
|
coverage_driver: string,
|
||||||
version: string,
|
version: string,
|
||||||
os_version: string
|
os: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
coverage_driver = coverage_driver.toLowerCase();
|
coverage_driver = coverage_driver.toLowerCase();
|
||||||
const script: string =
|
const script: string = '\n' + (await utils.stepLog('Setup Coverage', os));
|
||||||
'\n' + (await utils.stepLog('Setup Coverage', os_version));
|
const pipe: string = (await utils.suppressOutput(os)) + '\n';
|
||||||
const pipe: string = (await utils.suppressOutput(os_version)) + '\n';
|
|
||||||
switch (coverage_driver) {
|
switch (coverage_driver) {
|
||||||
case 'pcov':
|
case 'pcov':
|
||||||
return script + (await addCoveragePCOV(version, os_version, pipe));
|
return script + (await addCoveragePCOV(version, os, pipe));
|
||||||
case 'xdebug':
|
case 'xdebug':
|
||||||
case 'xdebug2':
|
case 'xdebug2':
|
||||||
case 'xdebug3':
|
case 'xdebug3':
|
||||||
return (
|
return (
|
||||||
script +
|
script + (await addCoverageXdebug(coverage_driver, version, os, pipe))
|
||||||
(await addCoverageXdebug(coverage_driver, version, os_version, pipe))
|
|
||||||
);
|
);
|
||||||
case 'none':
|
case 'none':
|
||||||
return script + (await disableCoverage(version, os_version, pipe));
|
return script + (await disableCoverage(version, os, pipe));
|
||||||
default:
|
default:
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
@ -327,20 +327,20 @@ export async function addExtensionLinux(
|
|||||||
*
|
*
|
||||||
* @param extension_csv
|
* @param extension_csv
|
||||||
* @param version
|
* @param version
|
||||||
* @param os_version
|
* @param os
|
||||||
* @param no_step
|
* @param no_step
|
||||||
*/
|
*/
|
||||||
export async function addExtension(
|
export async function addExtension(
|
||||||
extension_csv: string,
|
extension_csv: string,
|
||||||
version: string,
|
version: string,
|
||||||
os_version: string,
|
os: string,
|
||||||
no_step = false
|
no_step = false
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const log: string = await utils.stepLog('Setup Extensions', os_version);
|
const log: string = await utils.stepLog('Setup Extensions', os);
|
||||||
let script = '\n';
|
let script = '\n';
|
||||||
switch (no_step) {
|
switch (no_step) {
|
||||||
case true:
|
case true:
|
||||||
script += log + (await utils.suppressOutput(os_version));
|
script += log + (await utils.suppressOutput(os));
|
||||||
break;
|
break;
|
||||||
case false:
|
case false:
|
||||||
default:
|
default:
|
||||||
@ -348,7 +348,7 @@ export async function addExtension(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (os_version) {
|
switch (os) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return script + (await addExtensionWindows(extension_csv, version));
|
return script + (await addExtensionWindows(extension_csv, version));
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
@ -357,8 +357,8 @@ export async function addExtension(
|
|||||||
return script + (await addExtensionLinux(extension_csv, version));
|
return script + (await addExtensionLinux(extension_csv, version));
|
||||||
default:
|
default:
|
||||||
return await utils.log(
|
return await utils.log(
|
||||||
'Platform ' + os_version + ' is not supported',
|
'Platform ' + os + ' is not supported',
|
||||||
os_version,
|
os,
|
||||||
'error'
|
'error'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -13,12 +13,12 @@ import fs from 'fs';
|
|||||||
*
|
*
|
||||||
* @param filename
|
* @param filename
|
||||||
* @param version
|
* @param version
|
||||||
* @param os_version
|
* @param os
|
||||||
*/
|
*/
|
||||||
export async function getScript(
|
export async function getScript(
|
||||||
filename: string,
|
filename: string,
|
||||||
version: string,
|
version: string,
|
||||||
os_version: string
|
os: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const url = 'https://setup-php.com/sponsor';
|
const url = 'https://setup-php.com/sponsor';
|
||||||
// taking inputs
|
// taking inputs
|
||||||
@ -30,17 +30,17 @@ export async function getScript(
|
|||||||
const script_path = path.join(__dirname, '../src/scripts', filename);
|
const script_path = path.join(__dirname, '../src/scripts', filename);
|
||||||
let script = '\n';
|
let script = '\n';
|
||||||
if (extension_csv) {
|
if (extension_csv) {
|
||||||
script += await extensions.addExtension(extension_csv, version, os_version);
|
script += await extensions.addExtension(extension_csv, version, os);
|
||||||
}
|
}
|
||||||
script += await tools.addTools(tools_csv, version, os_version);
|
script += await tools.addTools(tools_csv, version, os);
|
||||||
if (coverage_driver) {
|
if (coverage_driver) {
|
||||||
script += await coverage.addCoverage(coverage_driver, version, os_version);
|
script += await coverage.addCoverage(coverage_driver, version, os);
|
||||||
}
|
}
|
||||||
if (ini_values_csv) {
|
if (ini_values_csv) {
|
||||||
script += await config.addINIValues(ini_values_csv, os_version);
|
script += await config.addINIValues(ini_values_csv, os);
|
||||||
}
|
}
|
||||||
script += '\n' + (await utils.stepLog(`Sponsor setup-php`, os_version));
|
script += '\n' + (await utils.stepLog(`Sponsor setup-php`, os));
|
||||||
script += '\n' + (await utils.addLog('$tick', 'setup-php', url, os_version));
|
script += '\n' + (await utils.addLog('$tick', 'setup-php', url, os));
|
||||||
|
|
||||||
fs.appendFileSync(script_path, script, {mode: 0o755});
|
fs.appendFileSync(script_path, script, {mode: 0o755});
|
||||||
|
|
||||||
@ -65,10 +65,10 @@ export async function run(): Promise<void> {
|
|||||||
await utils.getInput('ini-file', false)
|
await utils.getInput('ini-file', false)
|
||||||
);
|
);
|
||||||
if (version) {
|
if (version) {
|
||||||
const os_version: string = process.platform;
|
const os: string = process.platform;
|
||||||
const tool = await utils.scriptTool(os_version);
|
const tool = await utils.scriptTool(os);
|
||||||
const script = os_version + (await utils.scriptExtension(os_version));
|
const script = os + (await utils.scriptExtension(os));
|
||||||
const location = await getScript(script, version, os_version);
|
const location = await getScript(script, version, os);
|
||||||
await exec(
|
await exec(
|
||||||
await utils.joins(tool, location, version, ini_file, __dirname)
|
await utils.joins(tool, location, version, ini_file, __dirname)
|
||||||
);
|
);
|
||||||
|
42
src/tools.ts
42
src/tools.ts
@ -185,7 +185,7 @@ export async function getPharUrl(data: RS): Promise<string> {
|
|||||||
*/
|
*/
|
||||||
export async function addArchive(data: RS): Promise<string> {
|
export async function addArchive(data: RS): Promise<string> {
|
||||||
return (
|
return (
|
||||||
(await utils.getCommand(data['os_version'], 'tool')) +
|
(await utils.getCommand(data['os'], 'tool')) +
|
||||||
(await utils.joins(data['url'], data['tool'], data['version_parameter']))
|
(await utils.joins(data['url'], data['tool'], data['version_parameter']))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -196,7 +196,7 @@ export async function addArchive(data: RS): Promise<string> {
|
|||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
export async function addPackage(data: RS): Promise<string> {
|
export async function addPackage(data: RS): Promise<string> {
|
||||||
const command = await utils.getCommand(data['os_version'], 'composertool');
|
const command = await utils.getCommand(data['os'], 'composertool');
|
||||||
const parts: string[] = data['repository'].split('/');
|
const parts: string[] = data['repository'].split('/');
|
||||||
const args: string = await utils.joins(
|
const args: string = await utils.joins(
|
||||||
parts[1],
|
parts[1],
|
||||||
@ -275,7 +275,7 @@ export async function addDeployer(data: RS): Promise<string> {
|
|||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
export async function addDevTools(data: RS): Promise<string> {
|
export async function addDevTools(data: RS): Promise<string> {
|
||||||
switch (data['os_version']) {
|
switch (data['os']) {
|
||||||
case 'linux':
|
case 'linux':
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
return 'add_devtools ' + data['tool'];
|
return 'add_devtools ' + data['tool'];
|
||||||
@ -288,8 +288,8 @@ export async function addDevTools(data: RS): Promise<string> {
|
|||||||
);
|
);
|
||||||
default:
|
default:
|
||||||
return await utils.log(
|
return await utils.log(
|
||||||
'Platform ' + data['os_version'] + ' is not supported',
|
'Platform ' + data['os'] + ' is not supported',
|
||||||
data['os_version'],
|
data['os'],
|
||||||
'error'
|
'error'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -301,7 +301,7 @@ export async function addDevTools(data: RS): Promise<string> {
|
|||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
export async function addPECL(data: RS): Promise<string> {
|
export async function addPECL(data: RS): Promise<string> {
|
||||||
return await utils.getCommand(data['os_version'], 'pecl');
|
return await utils.getCommand(data['os'], 'pecl');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -327,7 +327,7 @@ export async function addPhive(data: RS): Promise<string> {
|
|||||||
'$cross',
|
'$cross',
|
||||||
'phive',
|
'phive',
|
||||||
'Phive is not supported on PHP ' + data['php_version'],
|
'Phive is not supported on PHP ' + data['php_version'],
|
||||||
data['os_version']
|
data['os']
|
||||||
);
|
);
|
||||||
case /5\.6|7\.0/.test(data['php_version']):
|
case /5\.6|7\.0/.test(data['php_version']):
|
||||||
data['version'] = '0.12.1';
|
data['version'] = '0.12.1';
|
||||||
@ -364,18 +364,18 @@ export async function addPHPUnitTools(data: RS): Promise<string> {
|
|||||||
*/
|
*/
|
||||||
export async function addSymfony(data: RS): Promise<string> {
|
export async function addSymfony(data: RS): Promise<string> {
|
||||||
let filename: string;
|
let filename: string;
|
||||||
switch (data['os_version']) {
|
switch (data['os']) {
|
||||||
case 'linux':
|
case 'linux':
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
filename = 'symfony_' + data['os_version'] + '_amd64';
|
filename = 'symfony_' + data['os'] + '_amd64';
|
||||||
break;
|
break;
|
||||||
case 'win32':
|
case 'win32':
|
||||||
filename = 'symfony_windows_amd64.exe';
|
filename = 'symfony_windows_amd64.exe';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return await utils.log(
|
return await utils.log(
|
||||||
'Platform ' + data['os_version'] + ' is not supported',
|
'Platform ' + data['os'] + ' is not supported',
|
||||||
data['os_version'],
|
data['os'],
|
||||||
'error'
|
'error'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -411,12 +411,12 @@ export async function addWPCLI(data: RS): Promise<string> {
|
|||||||
*
|
*
|
||||||
* @param release
|
* @param release
|
||||||
* @param php_version
|
* @param php_version
|
||||||
* @param os_version
|
* @param os
|
||||||
*/
|
*/
|
||||||
export async function getData(
|
export async function getData(
|
||||||
release: string,
|
release: string,
|
||||||
php_version: string,
|
php_version: string,
|
||||||
os_version: string
|
os: string
|
||||||
): Promise<RS> {
|
): Promise<RS> {
|
||||||
const json_file_path = path.join(__dirname, '../src/configs/tools.json');
|
const json_file_path = path.join(__dirname, '../src/configs/tools.json');
|
||||||
const json_file: string = fs.readFileSync(json_file_path, 'utf8');
|
const json_file: string = fs.readFileSync(json_file_path, 'utf8');
|
||||||
@ -450,7 +450,7 @@ export async function getData(
|
|||||||
data['github'] = 'https://github.com';
|
data['github'] = 'https://github.com';
|
||||||
data['domain'] ??= data['github'];
|
data['domain'] ??= data['github'];
|
||||||
data['extension'] ??= '.phar';
|
data['extension'] ??= '.phar';
|
||||||
data['os_version'] = os_version;
|
data['os'] = os;
|
||||||
data['php_version'] = php_version;
|
data['php_version'] = php_version;
|
||||||
data['prefix'] = data['github'] === data['domain'] ? 'releases' : '';
|
data['prefix'] = data['github'] === data['domain'] ? 'releases' : '';
|
||||||
data['verb'] = data['github'] === data['domain'] ? 'download' : '';
|
data['verb'] = data['github'] === data['domain'] ? 'download' : '';
|
||||||
@ -484,22 +484,22 @@ export const functionRecord: Record<string, (data: RS) => Promise<string>> = {
|
|||||||
*
|
*
|
||||||
* @param tools_csv
|
* @param tools_csv
|
||||||
* @param php_version
|
* @param php_version
|
||||||
* @param os_version
|
* @param os
|
||||||
*/
|
*/
|
||||||
export async function addTools(
|
export async function addTools(
|
||||||
tools_csv: string,
|
tools_csv: string,
|
||||||
php_version: string,
|
php_version: string,
|
||||||
os_version: string
|
os: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
let script = '\n';
|
let script = '\n';
|
||||||
if (tools_csv === 'none') {
|
if (tools_csv === 'none') {
|
||||||
return '';
|
return '';
|
||||||
} else {
|
} else {
|
||||||
script += await utils.stepLog('Setup Tools', os_version);
|
script += await utils.stepLog('Setup Tools', os);
|
||||||
}
|
}
|
||||||
const tools_list = await filterList(await utils.CSVArray(tools_csv));
|
const tools_list = await filterList(await utils.CSVArray(tools_csv));
|
||||||
await utils.asyncForEach(tools_list, async function (release: string) {
|
await utils.asyncForEach(tools_list, async function (release: string) {
|
||||||
const data: RS = await getData(release, php_version, os_version);
|
const data: RS = await getData(release, php_version, os);
|
||||||
script += '\n';
|
script += '\n';
|
||||||
switch (true) {
|
switch (true) {
|
||||||
case data['error'] !== undefined:
|
case data['error'] !== undefined:
|
||||||
@ -507,7 +507,7 @@ export async function addTools(
|
|||||||
'$cross',
|
'$cross',
|
||||||
data['tool'],
|
data['tool'],
|
||||||
data['error'],
|
data['error'],
|
||||||
data['os_version']
|
data['os']
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 'phar' === data['type']:
|
case 'phar' === data['type']:
|
||||||
@ -522,7 +522,7 @@ export async function addTools(
|
|||||||
data['tool'].split('-')[0],
|
data['tool'].split('-')[0],
|
||||||
'tools',
|
'tools',
|
||||||
data['version'],
|
data['version'],
|
||||||
data['os_version']
|
data['os']
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 'custom-function' === data['type']:
|
case 'custom-function' === data['type']:
|
||||||
@ -535,7 +535,7 @@ export async function addTools(
|
|||||||
'$cross',
|
'$cross',
|
||||||
data['tool'],
|
data['tool'],
|
||||||
'Tool ' + data['tool'] + ' is not supported',
|
'Tool ' + data['tool'] + ' is not supported',
|
||||||
data['os_version']
|
data['os']
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
98
src/utils.ts
98
src/utils.ts
@ -170,15 +170,15 @@ export async function color(type: string): Promise<string> {
|
|||||||
* Log to console
|
* Log to console
|
||||||
*
|
*
|
||||||
* @param message
|
* @param message
|
||||||
* @param os_version
|
* @param os
|
||||||
* @param log_type
|
* @param log_type
|
||||||
*/
|
*/
|
||||||
export async function log(
|
export async function log(
|
||||||
message: string,
|
message: string,
|
||||||
os_version: string,
|
os: string,
|
||||||
log_type: string
|
log_type: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
switch (os_version) {
|
switch (os) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return (
|
return (
|
||||||
'printf "\\033[' +
|
'printf "\\033[' +
|
||||||
@ -201,24 +201,17 @@ export async function log(
|
|||||||
* Function to log a step
|
* Function to log a step
|
||||||
*
|
*
|
||||||
* @param message
|
* @param message
|
||||||
* @param os_version
|
* @param os
|
||||||
*/
|
*/
|
||||||
export async function stepLog(
|
export async function stepLog(message: string, os: string): Promise<string> {
|
||||||
message: string,
|
switch (os) {
|
||||||
os_version: string
|
|
||||||
): Promise<string> {
|
|
||||||
switch (os_version) {
|
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return 'Step-Log "' + message + '"';
|
return 'Step-Log "' + message + '"';
|
||||||
case 'linux':
|
case 'linux':
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
return 'step_log "' + message + '"';
|
return 'step_log "' + message + '"';
|
||||||
default:
|
default:
|
||||||
return await log(
|
return await log('Platform ' + os + ' is not supported', os, 'error');
|
||||||
'Platform ' + os_version + ' is not supported',
|
|
||||||
os_version,
|
|
||||||
'error'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,26 +220,22 @@ export async function stepLog(
|
|||||||
* @param mark
|
* @param mark
|
||||||
* @param subject
|
* @param subject
|
||||||
* @param message
|
* @param message
|
||||||
* @param os_version
|
* @param os
|
||||||
*/
|
*/
|
||||||
export async function addLog(
|
export async function addLog(
|
||||||
mark: string,
|
mark: string,
|
||||||
subject: string,
|
subject: string,
|
||||||
message: string,
|
message: string,
|
||||||
os_version: string
|
os: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
switch (os_version) {
|
switch (os) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return 'Add-Log "' + mark + '" "' + subject + '" "' + message + '"';
|
return 'Add-Log "' + mark + '" "' + subject + '" "' + message + '"';
|
||||||
case 'linux':
|
case 'linux':
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
return 'add_log "' + mark + '" "' + subject + '" "' + message + '"';
|
return 'add_log "' + mark + '" "' + subject + '" "' + message + '"';
|
||||||
default:
|
default:
|
||||||
return await log(
|
return await log('Platform ' + os + ' is not supported', os, 'error');
|
||||||
'Platform ' + os_version + ' is not supported',
|
|
||||||
os_version,
|
|
||||||
'error'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -322,21 +311,17 @@ export async function getExtensionPrefix(extension: string): Promise<string> {
|
|||||||
/**
|
/**
|
||||||
* Function to get the suffix to suppress console output
|
* Function to get the suffix to suppress console output
|
||||||
*
|
*
|
||||||
* @param os_version
|
* @param os
|
||||||
*/
|
*/
|
||||||
export async function suppressOutput(os_version: string): Promise<string> {
|
export async function suppressOutput(os: string): Promise<string> {
|
||||||
switch (os_version) {
|
switch (os) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return ' >$null 2>&1';
|
return ' >$null 2>&1';
|
||||||
case 'linux':
|
case 'linux':
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
return ' >/dev/null 2>&1';
|
return ' >/dev/null 2>&1';
|
||||||
default:
|
default:
|
||||||
return await log(
|
return await log('Platform ' + os + ' is not supported', os, 'error');
|
||||||
'Platform ' + os_version + ' is not supported',
|
|
||||||
os_version,
|
|
||||||
'error'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -345,12 +330,12 @@ export async function suppressOutput(os_version: string): Promise<string> {
|
|||||||
*
|
*
|
||||||
* @param extension
|
* @param extension
|
||||||
* @param version
|
* @param version
|
||||||
* @param os_version
|
* @param os
|
||||||
*/
|
*/
|
||||||
export async function getUnsupportedLog(
|
export async function getUnsupportedLog(
|
||||||
extension: string,
|
extension: string,
|
||||||
version: string,
|
version: string,
|
||||||
os_version: string
|
os: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
return (
|
return (
|
||||||
'\n' +
|
'\n' +
|
||||||
@ -358,7 +343,7 @@ export async function getUnsupportedLog(
|
|||||||
'$cross',
|
'$cross',
|
||||||
extension,
|
extension,
|
||||||
[extension, 'is not supported on PHP', version].join(' '),
|
[extension, 'is not supported on PHP', version].join(' '),
|
||||||
os_version
|
os
|
||||||
)) +
|
)) +
|
||||||
'\n'
|
'\n'
|
||||||
);
|
);
|
||||||
@ -367,25 +352,18 @@ export async function getUnsupportedLog(
|
|||||||
/**
|
/**
|
||||||
* Function to get command to setup tools
|
* Function to get command to setup tools
|
||||||
*
|
*
|
||||||
* @param os_version
|
* @param os
|
||||||
* @param suffix
|
* @param suffix
|
||||||
*/
|
*/
|
||||||
export async function getCommand(
|
export async function getCommand(os: string, suffix: string): Promise<string> {
|
||||||
os_version: string,
|
switch (os) {
|
||||||
suffix: string
|
|
||||||
): Promise<string> {
|
|
||||||
switch (os_version) {
|
|
||||||
case 'linux':
|
case 'linux':
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
return 'add_' + suffix + ' ';
|
return 'add_' + suffix + ' ';
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return 'Add-' + suffix.charAt(0).toUpperCase() + suffix.slice(1) + ' ';
|
return 'Add-' + suffix.charAt(0).toUpperCase() + suffix.slice(1) + ' ';
|
||||||
default:
|
default:
|
||||||
return await log(
|
return await log('Platform ' + os + ' is not supported', os, 'error');
|
||||||
'Platform ' + os_version + ' is not supported',
|
|
||||||
os_version,
|
|
||||||
'error'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -401,42 +379,34 @@ export async function joins(...str: string[]): Promise<string> {
|
|||||||
/**
|
/**
|
||||||
* Function to get script extensions
|
* Function to get script extensions
|
||||||
*
|
*
|
||||||
* @param os_version
|
* @param os
|
||||||
*/
|
*/
|
||||||
export async function scriptExtension(os_version: string): Promise<string> {
|
export async function scriptExtension(os: string): Promise<string> {
|
||||||
switch (os_version) {
|
switch (os) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return '.ps1';
|
return '.ps1';
|
||||||
case 'linux':
|
case 'linux':
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
return '.sh';
|
return '.sh';
|
||||||
default:
|
default:
|
||||||
return await log(
|
return await log('Platform ' + os + ' is not supported', os, 'error');
|
||||||
'Platform ' + os_version + ' is not supported',
|
|
||||||
os_version,
|
|
||||||
'error'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function to get script tool
|
* Function to get script tool
|
||||||
*
|
*
|
||||||
* @param os_version
|
* @param os
|
||||||
*/
|
*/
|
||||||
export async function scriptTool(os_version: string): Promise<string> {
|
export async function scriptTool(os: string): Promise<string> {
|
||||||
switch (os_version) {
|
switch (os) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return 'pwsh';
|
return 'pwsh';
|
||||||
case 'linux':
|
case 'linux':
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
return 'bash';
|
return 'bash';
|
||||||
default:
|
default:
|
||||||
return await log(
|
return await log('Platform ' + os + ' is not supported', os, 'error');
|
||||||
'Platform ' + os_version + ' is not supported',
|
|
||||||
os_version,
|
|
||||||
'error'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -446,21 +416,21 @@ export async function scriptTool(os_version: string): Promise<string> {
|
|||||||
* @param pkg
|
* @param pkg
|
||||||
* @param type
|
* @param type
|
||||||
* @param version
|
* @param version
|
||||||
* @param os_version
|
* @param os
|
||||||
*/
|
*/
|
||||||
export async function customPackage(
|
export async function customPackage(
|
||||||
pkg: string,
|
pkg: string,
|
||||||
type: string,
|
type: string,
|
||||||
version: string,
|
version: string,
|
||||||
os_version: string
|
os: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const pkg_name: string = pkg.replace(/\d+|(pdo|pecl)[_-]/, '');
|
const pkg_name: string = pkg.replace(/\d+|(pdo|pecl)[_-]/, '');
|
||||||
const script_extension: string = await scriptExtension(os_version);
|
const script_extension: string = await scriptExtension(os);
|
||||||
const script: string = path.join(
|
const script: string = path.join(
|
||||||
__dirname,
|
__dirname,
|
||||||
'../src/scripts/' + type + '/' + pkg_name + script_extension
|
'../src/scripts/' + type + '/' + pkg_name + script_extension
|
||||||
);
|
);
|
||||||
const command: string = await getCommand(os_version, pkg_name);
|
const command: string = await getCommand(os, pkg_name);
|
||||||
return '\n. ' + script + '\n' + command + version;
|
return '\n. ' + script + '\n' + command + version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user