@zohodesk/testinglibrary 0.1.8-eslint-24 → 0.1.8-eslint-26
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.
|
@@ -73,6 +73,9 @@ function filterReportBasedDiff(resultJson, diffJson) {
|
|
|
73
73
|
resultJson = resultJson.filter(result => {
|
|
74
74
|
var _impactLineMap$get;
|
|
75
75
|
const isImpactFile = result.filePath;
|
|
76
|
+
if (isImpactFile.includes('.feature')) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
76
79
|
if (!isImpactFile) {
|
|
77
80
|
return false;
|
|
78
81
|
}
|
|
@@ -18,9 +18,13 @@ function getSummaryOfLint(cliParams) {
|
|
|
18
18
|
username,
|
|
19
19
|
lintEnv
|
|
20
20
|
} = (0, _cliArgsToObject.cliArgsToObject)(cliParams);
|
|
21
|
+
var $projectName = `${repo}_${branch}_${username}`;
|
|
22
|
+
if (lintEnv === 'pre-commit') {
|
|
23
|
+
$projectName = (0, _startSeverSonarQube.getProjectNameFrmGit)();
|
|
24
|
+
}
|
|
21
25
|
return {
|
|
22
|
-
projectName:
|
|
23
|
-
reportUrl: `https://serverlinter-np.zohodesk.csez.zohocorpin.com/project/issues?id=${
|
|
26
|
+
projectName: $projectName,
|
|
27
|
+
reportUrl: `https://serverlinter-np.zohodesk.csez.zohocorpin.com/project/issues?id=${$projectName}&resolve=false`,
|
|
24
28
|
jsonReportPath: (0, _eslintLintStage.getReportPath)().toString()
|
|
25
29
|
};
|
|
26
30
|
}
|
|
@@ -16,7 +16,6 @@ var _cliArgsToObject = require("../utils/cliArgsToObject");
|
|
|
16
16
|
var _sonarReportSummary = require("./sonarReportSummary");
|
|
17
17
|
var _logger = require("../utils/logger");
|
|
18
18
|
var _rootPath = require("../utils/rootPath");
|
|
19
|
-
var _fileUtils = require("../utils/fileUtils");
|
|
20
19
|
var _popUpCli = require("./popUpCli");
|
|
21
20
|
// Js script to start sonar Server
|
|
22
21
|
|
|
@@ -26,7 +25,7 @@ var _popUpCli = require("./popUpCli");
|
|
|
26
25
|
*/
|
|
27
26
|
|
|
28
27
|
function runSonarAnalysis(cliParams) {
|
|
29
|
-
var
|
|
28
|
+
var _filterSpecAndFeature, _filterSpecAndFeature2;
|
|
30
29
|
const {
|
|
31
30
|
diffPath,
|
|
32
31
|
repo,
|
|
@@ -46,13 +45,15 @@ function runSonarAnalysis(cliParams) {
|
|
|
46
45
|
if (lintEnv === 'pre-commit') {
|
|
47
46
|
project_name = getProjectNameFrmGit();
|
|
48
47
|
}
|
|
49
|
-
var resultFilesPath = diffPath ? (0, _eslintLintStage.getDiffFiles)(require((0, _eslintLintStage.getDiffJsonPath)(diffPath))).join(',') : [`${_path.default.resolve(process.cwd(), 'uat', 'modules')}`].join(',');
|
|
50
|
-
|
|
51
|
-
const source_directories_str = lintEnv == 'pre-commit' ? ' ' : source_directories.join(',');
|
|
48
|
+
var resultFilesPath = diffPath ? (_filterSpecAndFeature = filterSpecAndFeatureFiles((0, _eslintLintStage.getDiffFiles)(require((0, _eslintLintStage.getDiffJsonPath)(diffPath))))) === null || _filterSpecAndFeature === void 0 ? void 0 : _filterSpecAndFeature.stepFilesPath.join(',') : [`${_path.default.resolve(process.cwd(), 'uat', 'modules')}`].join(',');
|
|
49
|
+
var source_directories = diffPath ? (_filterSpecAndFeature2 = filterSpecAndFeatureFiles((0, _eslintLintStage.getDiffFiles)(require((0, _eslintLintStage.getDiffJsonPath)(diffPath))))) === null || _filterSpecAndFeature2 === void 0 ? void 0 : _filterSpecAndFeature2.featureFilesPath : [' '];
|
|
52
50
|
if (lintEnv == 'pre-commit') {
|
|
53
|
-
resultFilesPath = (0, _eslintLintStage.gitDiffFiles)().join(',');
|
|
51
|
+
resultFilesPath = filterSpecAndFeatureFiles((0, _eslintLintStage.gitDiffFiles)()).stepFilesPath.join(',');
|
|
54
52
|
}
|
|
55
|
-
|
|
53
|
+
if (lintEnv == 'pre-commit') {
|
|
54
|
+
source_directories = filterSpecAndFeatureFiles((0, _eslintLintStage.gitDiffFiles)()).featureFilesPath.join(',');
|
|
55
|
+
}
|
|
56
|
+
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}`, `-Dsonar.tests=${resultFilesPath}`, '-Dsonar.language=js', `-Dsonar.working.directory=${getSonarArtifactsDir()}`, `-Dsonar.eslint.reportPaths=${(0, _eslintLintStage.getReportPath)()}`, '-Dsonar.javascript.lcov.reportPaths=coverage/lcov-report/lcov.info'];
|
|
56
57
|
const child_process = (0, _child_process.spawn)('java', command);
|
|
57
58
|
child_process.stdout.on('data', data => {
|
|
58
59
|
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, data);
|
|
@@ -79,12 +80,13 @@ function runSonarAnalysis(cliParams) {
|
|
|
79
80
|
}
|
|
80
81
|
});
|
|
81
82
|
}
|
|
82
|
-
function
|
|
83
|
+
function filterSpecAndFeatureFiles(resultJson) {
|
|
83
84
|
return resultJson.reduce((filesPath, fileReport) => {
|
|
84
|
-
if (fileReport.
|
|
85
|
-
filesPath.featureFilesPath.push(fileReport
|
|
85
|
+
if (fileReport.includes('.feature')) {
|
|
86
|
+
filesPath.featureFilesPath.push(fileReport);
|
|
87
|
+
} else {
|
|
88
|
+
filesPath.stepFilesPath.push(fileReport);
|
|
86
89
|
}
|
|
87
|
-
filesPath.stepFilesPath.push(fileReport.filePath);
|
|
88
90
|
return filesPath;
|
|
89
91
|
}, {
|
|
90
92
|
stepFilesPath: [],
|
|
@@ -106,11 +108,11 @@ function getRepoName() {
|
|
|
106
108
|
return repoName.pop().split('/').pop().split('.')[0];
|
|
107
109
|
}
|
|
108
110
|
function getBranchName() {
|
|
109
|
-
const branchName = getSpawnOutput('git', ['branch'])[
|
|
111
|
+
const branchName = getSpawnOutput('git', ['branch'])[0]; // to get current branch
|
|
110
112
|
if (branchName.startsWith('*')) {
|
|
111
113
|
return branchName.replace('*', ' ').trim();
|
|
112
114
|
}
|
|
113
|
-
return branchName;
|
|
115
|
+
return branchName.trim();
|
|
114
116
|
}
|
|
115
117
|
function getSpawnOutput(command, params = []) {
|
|
116
118
|
const demon_process = (0, _child_process.spawnSync)(command, params, {
|