mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-24 04:41:06 +07:00
Improve code quality
This commit is contained in:
parent
2937ad6e7a
commit
67f23b6380
@ -17,7 +17,6 @@
|
|||||||
"camelcase": "off",
|
"camelcase": "off",
|
||||||
"require-atomic-updates": "off",
|
"require-atomic-updates": "off",
|
||||||
"@typescript-eslint/ban-ts-ignore": "off",
|
"@typescript-eslint/ban-ts-ignore": "off",
|
||||||
"@typescript-eslint/camelcase": "off",
|
"@typescript-eslint/camelcase": "off"
|
||||||
"@typescript-eslint/no-unused-vars": "off"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,16 +1,6 @@
|
|||||||
import * as io from '@actions/io';
|
import * as io from '@actions/io';
|
||||||
import * as path from 'path';
|
|
||||||
import * as fs from 'fs';
|
|
||||||
import * as matchers from '../src/matchers';
|
import * as matchers from '../src/matchers';
|
||||||
|
|
||||||
async function cleanup(path: string): Promise<void> {
|
|
||||||
fs.unlink(path, error => {
|
|
||||||
if (error) {
|
|
||||||
console.log(error);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
jest.mock('@actions/io');
|
jest.mock('@actions/io');
|
||||||
|
|
||||||
describe('Matchers', () => {
|
describe('Matchers', () => {
|
||||||
|
@ -55,12 +55,12 @@ describe('Utils tests', () => {
|
|||||||
path.join(__dirname, '../src/scripts/win32.ps1'),
|
path.join(__dirname, '../src/scripts/win32.ps1'),
|
||||||
'utf8'
|
'utf8'
|
||||||
);
|
);
|
||||||
expect(await utils.readScript('darwin.sh', '7.4', 'darwin')).toBe(darwin);
|
expect(await utils.readScript('darwin.sh')).toBe(darwin);
|
||||||
expect(await utils.readScript('darwin.sh', '7.3', 'darwin')).toBe(darwin);
|
expect(await utils.readScript('darwin.sh')).toBe(darwin);
|
||||||
expect(await utils.readScript('linux.sh', '7.4', 'linux')).toBe(linux);
|
expect(await utils.readScript('linux.sh')).toBe(linux);
|
||||||
expect(await utils.readScript('linux.sh', '7.3', 'linux')).toBe(linux);
|
expect(await utils.readScript('linux.sh')).toBe(linux);
|
||||||
expect(await utils.readScript('win32.ps1', '7.4', 'win32')).toBe(win32);
|
expect(await utils.readScript('win32.ps1')).toBe(win32);
|
||||||
expect(await utils.readScript('win32.ps1', '7.3', 'win32')).toBe(win32);
|
expect(await utils.readScript('win32.ps1')).toBe(win32);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('checking writeScripts', async () => {
|
it('checking writeScripts', async () => {
|
||||||
|
525
dist/index.js
vendored
525
dist/index.js
vendored
File diff suppressed because it is too large
Load Diff
@ -44,6 +44,7 @@ export async function addINIValuesWindows(
|
|||||||
*
|
*
|
||||||
* @param ini_values_csv
|
* @param ini_values_csv
|
||||||
* @param os_version
|
* @param os_version
|
||||||
|
* @param no_step
|
||||||
*/
|
*/
|
||||||
export async function addINIValues(
|
export async function addINIValues(
|
||||||
ini_values_csv: string,
|
ini_values_csv: string,
|
||||||
|
@ -115,12 +115,10 @@ export async function addExtensionDarwin(
|
|||||||
*
|
*
|
||||||
* @param extension_csv
|
* @param extension_csv
|
||||||
* @param version
|
* @param version
|
||||||
* @param pipe
|
|
||||||
*/
|
*/
|
||||||
export async function addExtensionWindows(
|
export async function addExtensionWindows(
|
||||||
extension_csv: string,
|
extension_csv: string,
|
||||||
version: string,
|
version: string
|
||||||
pipe: string
|
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const extensions: Array<string> = await utils.extensionArray(extension_csv);
|
const extensions: Array<string> = await utils.extensionArray(extension_csv);
|
||||||
let script = '\n';
|
let script = '\n';
|
||||||
@ -313,7 +311,7 @@ export async function addExtension(
|
|||||||
|
|
||||||
switch (os_version) {
|
switch (os_version) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return script + (await addExtensionWindows(extension_csv, version, pipe));
|
return script + (await addExtensionWindows(extension_csv, version));
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
return script + (await addExtensionDarwin(extension_csv, version, pipe));
|
return script + (await addExtensionDarwin(extension_csv, version, pipe));
|
||||||
case 'linux':
|
case 'linux':
|
||||||
|
@ -35,7 +35,7 @@ export async function build(
|
|||||||
tools_csv = 'pecl, ' + tools_csv;
|
tools_csv = 'pecl, ' + tools_csv;
|
||||||
}
|
}
|
||||||
|
|
||||||
let script: string = await utils.readScript(filename, version, os_version);
|
let script: string = await utils.readScript(filename);
|
||||||
script += await tools.addTools(tools_csv, version, os_version);
|
script += await tools.addTools(tools_csv, version, os_version);
|
||||||
|
|
||||||
if (extension_csv) {
|
if (extension_csv) {
|
||||||
|
15
src/tools.ts
15
src/tools.ts
@ -4,6 +4,7 @@ import * as utils from './utils';
|
|||||||
* Function to get command to setup tools
|
* Function to get command to setup tools
|
||||||
*
|
*
|
||||||
* @param os_version
|
* @param os_version
|
||||||
|
* @param suffix
|
||||||
*/
|
*/
|
||||||
export async function getCommand(
|
export async function getCommand(
|
||||||
os_version: string,
|
os_version: string,
|
||||||
@ -69,6 +70,8 @@ export async function parseTool(
|
|||||||
/**
|
/**
|
||||||
* Function to get the url of tool with the given version
|
* Function to get the url of tool with the given version
|
||||||
*
|
*
|
||||||
|
* @param tool
|
||||||
|
* @param extension
|
||||||
* @param version
|
* @param version
|
||||||
* @param prefix
|
* @param prefix
|
||||||
* @param version_prefix
|
* @param version_prefix
|
||||||
@ -167,16 +170,14 @@ export async function getCodeceptionUri(
|
|||||||
case /(^2\.(1\.[0-5]|0\.\d+)|^1\.[6-8]\.\d+).*/.test(version):
|
case /(^2\.(1\.[0-5]|0\.\d+)|^1\.[6-8]\.\d+).*/.test(version):
|
||||||
return codecept;
|
return codecept;
|
||||||
default:
|
default:
|
||||||
return await codecept;
|
return codecept;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper function to get script to setup phive
|
* Helper function to get script to setup phive
|
||||||
*
|
*
|
||||||
* @param tool
|
|
||||||
* @param version
|
* @param version
|
||||||
* @param url
|
|
||||||
* @param os_version
|
* @param os_version
|
||||||
*/
|
*/
|
||||||
export async function addPhive(
|
export async function addPhive(
|
||||||
@ -204,6 +205,9 @@ export async function addPhive(
|
|||||||
/**
|
/**
|
||||||
* Function to get the phar url in domain/tool-version.phar format
|
* Function to get the phar url in domain/tool-version.phar format
|
||||||
*
|
*
|
||||||
|
* @param domain
|
||||||
|
* @param tool
|
||||||
|
* @param prefix
|
||||||
* @param version
|
* @param version
|
||||||
*/
|
*/
|
||||||
export async function getPharUrl(
|
export async function getPharUrl(
|
||||||
@ -293,7 +297,7 @@ export async function getWpCliUrl(version: string): Promise<string> {
|
|||||||
/**
|
/**
|
||||||
* Function to add/move composer in the tools list
|
* Function to add/move composer in the tools list
|
||||||
*
|
*
|
||||||
* @param tools
|
* @param tools_list
|
||||||
*/
|
*/
|
||||||
export async function addComposer(tools_list: string[]): Promise<string[]> {
|
export async function addComposer(tools_list: string[]): Promise<string[]> {
|
||||||
const regex = /^composer($|:.*)/;
|
const regex = /^composer($|:.*)/;
|
||||||
@ -402,7 +406,8 @@ export async function addPackage(
|
|||||||
/**
|
/**
|
||||||
* Setup tools
|
* Setup tools
|
||||||
*
|
*
|
||||||
* @param tool_csv
|
* @param tools_csv
|
||||||
|
* @param php_version
|
||||||
* @param os_version
|
* @param os_version
|
||||||
*/
|
*/
|
||||||
export async function addTools(
|
export async function addTools(
|
||||||
|
11
src/utils.ts
11
src/utils.ts
@ -65,7 +65,6 @@ export async function color(type: string): Promise<string> {
|
|||||||
* @param message
|
* @param message
|
||||||
* @param os_version
|
* @param os_version
|
||||||
* @param log_type
|
* @param log_type
|
||||||
* @param prefix
|
|
||||||
*/
|
*/
|
||||||
export async function log(
|
export async function log(
|
||||||
message: string,
|
message: string,
|
||||||
@ -121,6 +120,7 @@ export async function stepLog(
|
|||||||
* @param mark
|
* @param mark
|
||||||
* @param subject
|
* @param subject
|
||||||
* @param message
|
* @param message
|
||||||
|
* @param os_version
|
||||||
*/
|
*/
|
||||||
export async function addLog(
|
export async function addLog(
|
||||||
mark: string,
|
mark: string,
|
||||||
@ -147,14 +147,8 @@ export async function addLog(
|
|||||||
* Read the scripts
|
* Read the scripts
|
||||||
*
|
*
|
||||||
* @param filename
|
* @param filename
|
||||||
* @param version
|
|
||||||
* @param os_version
|
|
||||||
*/
|
*/
|
||||||
export async function readScript(
|
export async function readScript(filename: string): Promise<string> {
|
||||||
filename: string,
|
|
||||||
version: string,
|
|
||||||
os_version: string
|
|
||||||
): Promise<string> {
|
|
||||||
return fs.readFileSync(
|
return fs.readFileSync(
|
||||||
path.join(__dirname, '../src/scripts/' + filename),
|
path.join(__dirname, '../src/scripts/' + filename),
|
||||||
'utf8'
|
'utf8'
|
||||||
@ -165,7 +159,6 @@ export async function readScript(
|
|||||||
* Write final script which runs
|
* Write final script which runs
|
||||||
*
|
*
|
||||||
* @param filename
|
* @param filename
|
||||||
* @param version
|
|
||||||
* @param script
|
* @param script
|
||||||
*/
|
*/
|
||||||
export async function writeScript(
|
export async function writeScript(
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
/* Basic Options */
|
/* Basic Options */
|
||||||
// "incremental": true, /* Enable incremental compilation */
|
// "incremental": true, /* Enable incremental compilation */
|
||||||
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
|
"target": "ES2020", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
|
||||||
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
||||||
// "allowJs": true, /* Allow javascript files to be compiled. */
|
// "allowJs": true, /* Allow javascript files to be compiled. */
|
||||||
// "checkJs": true, /* Report errors in .js files. */
|
// "checkJs": true, /* Report errors in .js files. */
|
||||||
|
Loading…
Reference in New Issue
Block a user