Improve code quality

This commit is contained in:
Shivam Mathur 2020-03-12 07:57:40 +05:30
parent 2937ad6e7a
commit 67f23b6380
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A
11 changed files with 877 additions and 1054 deletions

View File

@ -17,7 +17,6 @@
"camelcase": "off",
"require-atomic-updates": "off",
"@typescript-eslint/ban-ts-ignore": "off",
"@typescript-eslint/camelcase": "off",
"@typescript-eslint/no-unused-vars": "off"
"@typescript-eslint/camelcase": "off"
}
}

View File

@ -1,16 +1,6 @@
import * as io from '@actions/io';
import * as path from 'path';
import * as fs from 'fs';
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');
describe('Matchers', () => {

View File

@ -55,12 +55,12 @@ describe('Utils tests', () => {
path.join(__dirname, '../src/scripts/win32.ps1'),
'utf8'
);
expect(await utils.readScript('darwin.sh', '7.4', 'darwin')).toBe(darwin);
expect(await utils.readScript('darwin.sh', '7.3', 'darwin')).toBe(darwin);
expect(await utils.readScript('linux.sh', '7.4', 'linux')).toBe(linux);
expect(await utils.readScript('linux.sh', '7.3', 'linux')).toBe(linux);
expect(await utils.readScript('win32.ps1', '7.4', 'win32')).toBe(win32);
expect(await utils.readScript('win32.ps1', '7.3', 'win32')).toBe(win32);
expect(await utils.readScript('darwin.sh')).toBe(darwin);
expect(await utils.readScript('darwin.sh')).toBe(darwin);
expect(await utils.readScript('linux.sh')).toBe(linux);
expect(await utils.readScript('linux.sh')).toBe(linux);
expect(await utils.readScript('win32.ps1')).toBe(win32);
expect(await utils.readScript('win32.ps1')).toBe(win32);
});
it('checking writeScripts', async () => {

525
dist/index.js vendored

File diff suppressed because it is too large Load Diff

View File

@ -44,6 +44,7 @@ export async function addINIValuesWindows(
*
* @param ini_values_csv
* @param os_version
* @param no_step
*/
export async function addINIValues(
ini_values_csv: string,

View File

@ -115,12 +115,10 @@ export async function addExtensionDarwin(
*
* @param extension_csv
* @param version
* @param pipe
*/
export async function addExtensionWindows(
extension_csv: string,
version: string,
pipe: string
version: string
): Promise<string> {
const extensions: Array<string> = await utils.extensionArray(extension_csv);
let script = '\n';
@ -313,7 +311,7 @@ export async function addExtension(
switch (os_version) {
case 'win32':
return script + (await addExtensionWindows(extension_csv, version, pipe));
return script + (await addExtensionWindows(extension_csv, version));
case 'darwin':
return script + (await addExtensionDarwin(extension_csv, version, pipe));
case 'linux':

View File

@ -35,7 +35,7 @@ export async function build(
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);
if (extension_csv) {

View File

@ -4,6 +4,7 @@ import * as utils from './utils';
* Function to get command to setup tools
*
* @param os_version
* @param suffix
*/
export async function getCommand(
os_version: string,
@ -69,6 +70,8 @@ export async function parseTool(
/**
* Function to get the url of tool with the given version
*
* @param tool
* @param extension
* @param version
* @param 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):
return codecept;
default:
return await codecept;
return codecept;
}
}
/**
* Helper function to get script to setup phive
*
* @param tool
* @param version
* @param url
* @param os_version
*/
export async function addPhive(
@ -204,6 +205,9 @@ export async function addPhive(
/**
* Function to get the phar url in domain/tool-version.phar format
*
* @param domain
* @param tool
* @param prefix
* @param version
*/
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
*
* @param tools
* @param tools_list
*/
export async function addComposer(tools_list: string[]): Promise<string[]> {
const regex = /^composer($|:.*)/;
@ -402,7 +406,8 @@ export async function addPackage(
/**
* Setup tools
*
* @param tool_csv
* @param tools_csv
* @param php_version
* @param os_version
*/
export async function addTools(

View File

@ -65,7 +65,6 @@ export async function color(type: string): Promise<string> {
* @param message
* @param os_version
* @param log_type
* @param prefix
*/
export async function log(
message: string,
@ -121,6 +120,7 @@ export async function stepLog(
* @param mark
* @param subject
* @param message
* @param os_version
*/
export async function addLog(
mark: string,
@ -147,14 +147,8 @@ export async function addLog(
* Read the scripts
*
* @param filename
* @param version
* @param os_version
*/
export async function readScript(
filename: string,
version: string,
os_version: string
): Promise<string> {
export async function readScript(filename: string): Promise<string> {
return fs.readFileSync(
path.join(__dirname, '../src/scripts/' + filename),
'utf8'
@ -165,7 +159,6 @@ export async function readScript(
* Write final script which runs
*
* @param filename
* @param version
* @param script
*/
export async function writeScript(

View File

@ -2,7 +2,7 @@
"compilerOptions": {
/* Basic Options */
// "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'. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */