@zohodesk/testinglibrary 0.1.8-eslint-10 → 0.1.8-eslint-12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/lib/cli.js +1 -1
- package/build/lint-ci/eslintLintStage.js +34 -10
- package/build/lint-ci/startSever-sonarQube.js +6 -6
- package/build/utils/rootPath.js +1 -1
- package/package.json +1 -1
- package/main.js +0 -14
package/build/lib/cli.js
CHANGED
|
@@ -59,7 +59,7 @@ switch (option) {
|
|
|
59
59
|
case 'lint':
|
|
60
60
|
{
|
|
61
61
|
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Linting Started ...');
|
|
62
|
-
(0, _eslintLintStage.runEslintForDiff)(otherOptions).
|
|
62
|
+
(0, _eslintLintStage.runEslintForDiff)(otherOptions).finally(result => {
|
|
63
63
|
(0, _startSeverSonarQube.runSonarAnalysis)(otherOptions);
|
|
64
64
|
});
|
|
65
65
|
break;
|
|
@@ -24,18 +24,37 @@ async function runEslintForDiff(cliParams, options = {}) {
|
|
|
24
24
|
const diffJSON = diffPath ? require(getDiffJsonPath(diffPath)) : null;
|
|
25
25
|
const filteredDiffFiles = getDiffFiles(diffJSON);
|
|
26
26
|
const lintFiles = !filteredDiffFiles ? [_path.default.resolve(process.cwd(), 'uat', 'modules')] : filteredDiffFiles;
|
|
27
|
-
await new Promise(resolve => {
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
return await new Promise(resolve => {
|
|
28
|
+
const command = ['eslint', `${lintFiles.join(' ')}`, `--format=${format}`, '-o', `${reportPath}`];
|
|
29
|
+
const lint_process = (0, _child_process.spawn)('npx', command);
|
|
30
|
+
lint_process.stdout.on('data', data => {
|
|
31
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, data);
|
|
30
32
|
});
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
lint_process.stderr.on('data', errorOutput => {
|
|
34
|
+
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, errorOutput);
|
|
35
|
+
});
|
|
36
|
+
lint_process.on('error', error => {
|
|
37
|
+
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, error);
|
|
38
|
+
});
|
|
39
|
+
lint_process.on('close', onClose => {
|
|
40
|
+
if (diffPath && !(filteredDiffFiles.length === 0)) {
|
|
41
|
+
(0, _fileUtils.writeFileContents)(reportPath, filterReport_JSON(require(reportPath), diffJSON));
|
|
42
|
+
}
|
|
43
|
+
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, `Lint Executed ...`);
|
|
44
|
+
resolve({
|
|
45
|
+
status: 'success'
|
|
46
|
+
});
|
|
33
47
|
});
|
|
34
|
-
}).finally(() => {
|
|
35
|
-
if (diffPath && !(filteredDiffFiles.length === 0)) {
|
|
36
|
-
(0, _fileUtils.writeFileContents)(reportPath, filterReport_JSON(require(reportPath), diffJSON));
|
|
37
|
-
}
|
|
38
48
|
});
|
|
49
|
+
|
|
50
|
+
// .finally(() => {
|
|
51
|
+
// if (diffPath && !(filteredDiffFiles.length === 0)) {
|
|
52
|
+
// writeFileContents(
|
|
53
|
+
// reportPath,
|
|
54
|
+
// filterReport_JSON(require(reportPath), diffJSON)
|
|
55
|
+
// );
|
|
56
|
+
// }
|
|
57
|
+
// });
|
|
39
58
|
}
|
|
40
59
|
function filterReport_JSON(resultJson, diffJson) {
|
|
41
60
|
const impactLineArray = filterDiffJson(diffJson);
|
|
@@ -117,7 +136,12 @@ function validateReport() {
|
|
|
117
136
|
}
|
|
118
137
|
}
|
|
119
138
|
function getReportPath(reportPath = null, reportOptions = {}) {
|
|
120
|
-
|
|
139
|
+
let jsonReportPath = reportPath || _path.default.resolve(process.cwd(), 'uat', 'lint-report', 'lintReport.json');
|
|
140
|
+
if (!(0, _fileUtils.checkIfFileExists)(jsonReportPath)) {
|
|
141
|
+
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, 'Cannot Find JSON Report ...');
|
|
142
|
+
process.exit(0);
|
|
143
|
+
}
|
|
144
|
+
return reportPath ? reportPath : jsonReportPath;
|
|
121
145
|
}
|
|
122
146
|
function getDiffJsonPath(diffJsonPath) {
|
|
123
147
|
return _path.default.resolve(diffJsonPath);
|
|
@@ -38,20 +38,20 @@ function runSonarAnalysis(cliParams) {
|
|
|
38
38
|
} = getCredentials(login, password);
|
|
39
39
|
const project_name = repo && branch && branch ? `${repo}_${branch}_${username}` : 'UAT_Testing';
|
|
40
40
|
const resultFilesPath = diffPath ? (_getFilePathFrmReport = getFilePathFrmReport(require((0, _eslintLintStage.getReportPath)()))) === null || _getFilePathFrmReport === void 0 ? void 0 : _getFilePathFrmReport.stepFilesPath.join(',') : [' '].join('');
|
|
41
|
-
const source_directories = ((_getFilePathFrmReport2 = getFilePathFrmReport(require((0, _eslintLintStage.getReportPath)()))) === null || _getFilePathFrmReport2 === void 0 ? void 0 : _getFilePathFrmReport2.featureFilesPath) || [
|
|
41
|
+
const source_directories = ((_getFilePathFrmReport2 = getFilePathFrmReport(require((0, _eslintLintStage.getReportPath)()))) === null || _getFilePathFrmReport2 === void 0 ? void 0 : _getFilePathFrmReport2.featureFilesPath) || [' '];
|
|
42
42
|
const source_directories_str = source_directories.join(',');
|
|
43
43
|
const command = ['-jar', sonar_scanner_path, `-Dsonar.host.url=${sonarqube_host_url}`, `-Dsonar.projectKey=${project_name}`, `-Dsonar.login=${Dlogin}`, `-Dsonar.password=${Dpassword}`, `-Dsonar.sources=${source_directories_str}`, `-Dsonar.tests=${resultFilesPath}`, '-Dsonar.language=js', `-Dsonar.eslint.reportPaths=${(0, _eslintLintStage.getReportPath)()}`, '-Dsonar.javascript.lcov.reportPaths=coverage/lcov-report/lcov.info'];
|
|
44
|
-
const
|
|
45
|
-
|
|
44
|
+
const child_process = (0, _child_process.spawn)('java', command);
|
|
45
|
+
child_process.stdout.on('data', data => {
|
|
46
46
|
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, data);
|
|
47
47
|
});
|
|
48
|
-
|
|
48
|
+
child_process.stderr.on('data', errorOut => {
|
|
49
49
|
_logger.Logger.error(_logger.Logger.FAILURE_TYPE, errorOut);
|
|
50
50
|
});
|
|
51
|
-
|
|
51
|
+
child_process.on('error', error => {
|
|
52
52
|
_logger.Logger.error(_logger.Logger.FAILURE_TYPE, `Error: ${error.message}`);
|
|
53
53
|
});
|
|
54
|
-
|
|
54
|
+
child_process.on('close', code => {
|
|
55
55
|
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, `Lint Stage Executed & Status - ${code === 0 ? 'Success' : 'Failure'}`);
|
|
56
56
|
(0, _sonarReportSummary.writeSummaryOfLint)(cliParams);
|
|
57
57
|
});
|
package/build/utils/rootPath.js
CHANGED
|
@@ -51,6 +51,6 @@ function getSonarJarPath() {
|
|
|
51
51
|
if ((0, _fileUtils.checkIfFileExists)(jarPath)) {
|
|
52
52
|
return jarPath;
|
|
53
53
|
}
|
|
54
|
-
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, '
|
|
54
|
+
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, 'cannot find - Java-Jar');
|
|
55
55
|
process.exit(0);
|
|
56
56
|
}
|
package/package.json
CHANGED
package/main.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
function reduceUnderstand(arrayOfAll) {
|
|
2
|
-
console.log(arrayOfAll);
|
|
3
|
-
const numbers = arrayOfAll.reduce((prev, index) => {
|
|
4
|
-
console.log('=>', index);
|
|
5
|
-
if (typeof index == 'number') {
|
|
6
|
-
prev.push(index);
|
|
7
|
-
}
|
|
8
|
-
return prev;
|
|
9
|
-
}, []);
|
|
10
|
-
|
|
11
|
-
console.log(numbers);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
reduceUnderstand([1, 'd', 2, 3, 's', '5', 'x', 'r', '6', '9']);
|