@zohodesk/testinglibrary 0.1.8-eslint-24 → 0.1.8-eslint-25

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: lintEnv === 'pre-commit' ? (0, _startSeverSonarQube.getProjectNameFrmGit)() : `${repo}_${branch},${username}`,
23
- reportUrl: `https://serverlinter-np.zohodesk.csez.zohocorpin.com/project/issues?id=${repo}_${branch}_${username}&resolve=false`,
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 _getFilePathFrmReport;
28
+ var _filterSpecAndFeature, _filterSpecAndFeature2;
30
29
  const {
31
30
  diffPath,
32
31
  repo,
@@ -46,13 +45,17 @@ 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
- const source_directories = ((_getFilePathFrmReport = getFilePathFrmReport(require((0, _eslintLintStage.getReportPath)()))) === null || _getFilePathFrmReport === void 0 ? void 0 : _getFilePathFrmReport.featureFilesPath) || [' '];
51
- const source_directories_str = lintEnv == 'pre-commit' ? ' ' : source_directories.join(',');
48
+ console.log(filterSpecAndFeatureFiles((0, _eslintLintStage.getDiffFiles)(require((0, _eslintLintStage.getDiffJsonPath)(diffPath)))));
49
+ 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(',');
50
+ const source_directories = ((_filterSpecAndFeature2 = filterSpecAndFeatureFiles((0, _eslintLintStage.getDiffFiles)(require((0, _eslintLintStage.getDiffJsonPath)(diffPath))))) === null || _filterSpecAndFeature2 === void 0 ? void 0 : _filterSpecAndFeature2.featureFilesPath) || [' '];
52
51
  if (lintEnv == 'pre-commit') {
53
- resultFilesPath = (0, _eslintLintStage.gitDiffFiles)().join(',');
52
+ resultFilesPath = filterSpecAndFeatureFiles((0, _eslintLintStage.gitDiffFiles)()).stepFilesPath.join(',');
54
53
  }
55
- 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.working.directory=${getSonarArtifactsDir()}`, `-Dsonar.eslint.reportPaths=${(0, _eslintLintStage.getReportPath)()}`, '-Dsonar.javascript.lcov.reportPaths=coverage/lcov-report/lcov.info'];
54
+ if (lintEnv == 'pre-commit') {
55
+ source_directories = filterSpecAndFeatureFiles((0, _eslintLintStage.gitDiffFiles)()).featureFilesPath.join(',');
56
+ }
57
+ 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.join(',')}`, `-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'];
58
+ console.log(command);
56
59
  const child_process = (0, _child_process.spawn)('java', command);
57
60
  child_process.stdout.on('data', data => {
58
61
  _logger.Logger.log(_logger.Logger.SUCCESS_TYPE, data);
@@ -79,12 +82,13 @@ function runSonarAnalysis(cliParams) {
79
82
  }
80
83
  });
81
84
  }
82
- function getFilePathFrmReport(resultJson) {
85
+ function filterSpecAndFeatureFiles(resultJson) {
83
86
  return resultJson.reduce((filesPath, fileReport) => {
84
- if (fileReport.filePath.includes('.feature')) {
85
- filesPath.featureFilesPath.push(fileReport.filePath);
87
+ if (fileReport.includes('.feature')) {
88
+ filesPath.featureFilesPath.push(fileReport);
89
+ } else {
90
+ filesPath.stepFilesPath.push(fileReport);
86
91
  }
87
- filesPath.stepFilesPath.push(fileReport.filePath);
88
92
  return filesPath;
89
93
  }, {
90
94
  stepFilesPath: [],
@@ -106,11 +110,11 @@ function getRepoName() {
106
110
  return repoName.pop().split('/').pop().split('.')[0];
107
111
  }
108
112
  function getBranchName() {
109
- const branchName = getSpawnOutput('git', ['branch'])[1]; // to get current branch
113
+ const branchName = getSpawnOutput('git', ['branch'])[0]; // to get current branch
110
114
  if (branchName.startsWith('*')) {
111
115
  return branchName.replace('*', ' ').trim();
112
116
  }
113
- return branchName;
117
+ return branchName.trim();
114
118
  }
115
119
  function getSpawnOutput(command, params = []) {
116
120
  const demon_process = (0, _child_process.spawnSync)(command, params, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/testinglibrary",
3
- "version": "0.1.8-eslint-24",
3
+ "version": "0.1.8-eslint-25",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "scripts": {