@zohodesk/testinglibrary 0.1.8-eslint-17 → 0.1.8-eslint-19

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.
@@ -0,0 +1 @@
1
+ {}
@@ -35,26 +35,27 @@ async function runEslintForDiff(cliParams, options = {}) {
35
35
  return await new Promise(resolve => {
36
36
  const command = ['eslint', lintFiles.join(' '), `--format=${format}`, '-o', `${reportPath}`];
37
37
  try {
38
- const lint_process = (0, _child_process.spawnSync)('npx', command, {
38
+ const lint_process = (0, _child_process.spawn)('npx', command, {
39
39
  shell: true,
40
40
  cwd: process.cwd()
41
41
  });
42
- if (lint_process.stderr) {
43
- _logger.Logger.log(_logger.Logger.FAILURE_TYPE, lint_process.stderr.toString());
44
- }
45
- if (lint_process.error) {
46
- throw lintFiles.error;
47
- }
42
+ lint_process.stdout.on('data', data => {
43
+ _logger.Logger.log(_logger.Logger.INFO_TYPE, data);
44
+ });
45
+ lint_process.stderr.on('error', err => {
46
+ _logger.Logger.log(_logger.Logger.FAILURE_TYPE, err);
47
+ });
48
+ lint_process.on('close', onclose => {
49
+ if (diffPath && !(filteredDiffFiles.length === 0)) {
50
+ (0, _fileUtils.writeFileContents)(reportPath, filterReport_JSON(require(reportPath), diffJSON));
51
+ }
52
+ resolve({
53
+ status: 'success'
54
+ });
55
+ });
48
56
  } catch (error) {
49
57
  _logger.Logger.log(_logger.Logger.INFO_TYPE, error);
50
58
  _logger.Logger.log(_logger.Logger.FAILURE_TYPE, 'Execution Failed');
51
- } finally {
52
- if (diffPath && !(filteredDiffFiles.length === 0)) {
53
- (0, _fileUtils.writeFileContents)(reportPath, filterReport_JSON(require(reportPath), diffJSON));
54
- }
55
- resolve({
56
- status: 'success'
57
- });
58
59
  }
59
60
  });
60
61
  }
@@ -100,7 +101,7 @@ function filterDiffJson(diffJson) {
100
101
  return diffFilesMap;
101
102
  }
102
103
  function getRootDir() {
103
- return _path.default.resolve(process.cwd());
104
+ return process.cwd();
104
105
  }
105
106
  function getPathFromTestDir(diffPath) {
106
107
  if (!diffPath.includes('uat')) {
@@ -142,11 +143,13 @@ function getDiffJsonPath(diffJsonPath) {
142
143
  return _path.default.resolve(diffJsonPath);
143
144
  }
144
145
  function gitDiffFiles() {
145
- const command = 'git diff HEAD HEAD~1 --name-only';
146
+ const command = 'git diff --cached -U0 HEAD --name-only';
146
147
  const child = (0, _child_process.spawnSync)(command, {
147
148
  shell: true
148
149
  });
149
- return child.stdout.toString().split('\n').map(filePath => _path.default.resolve(getRootLintPath(), filePath));
150
+ const diffFiles = child.stdout.toString().split('\n').map(filePath => _path.default.resolve(getRootLintPath(), filePath));
151
+ diffFiles.pop(); // remove last empty string
152
+ return diffFiles;
150
153
  }
151
154
  function getRootLintPath() {
152
155
  const childProcess = (0, _child_process.spawnSync)('git', ['rev-parse', '--show-toplevel'], {
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ const {
4
+ spawn
5
+ } = require('child_process');
@@ -18,8 +18,8 @@ function getSummaryOfLint(cliParams) {
18
18
  lintEnv
19
19
  } = (0, _cliArgsToObject.cliArgsToObject)(cliParams);
20
20
  return {
21
- projectNameL: lintEnv === 'pre-commit' ? (0, _startSeverSonarQube.getProjectNameFrmGit)() : `${repo}_${branch},${username}`,
22
- reportUrl: `https://serverlinter.zohodesk.csez.zohocorpin.com/project/issues?id=${repo}_${branch}_${username}&resolve=false`,
21
+ projectName: lintEnv === 'pre-commit' ? (0, _startSeverSonarQube.getProjectNameFrmGit)() : `${repo}_${branch},${username}`,
22
+ reportUrl: `https://serverlinter-np.zohodesk.csez.zohocorpin.com/project/issues?id=${repo}_${branch}_${username}&resolve=false`,
23
23
  jsonReportPath: (0, _eslintLintStage.getReportPath)().toString()
24
24
  };
25
25
  }
@@ -48,10 +48,9 @@ function runSonarAnalysis(cliParams) {
48
48
  if (lintEnv == 'pre-commit') {
49
49
  resultFilesPath = (0, _eslintLintStage.gitDiffFiles)().join(',');
50
50
  }
51
- 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'];
51
+ 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'];
52
52
  const child_process = (0, _child_process.spawn)('java', command);
53
53
  child_process.stdout.on('data', data => {
54
- _logger.Logger.log(_logger.Logger.INFO_TYPE, 'sending report to server ...');
55
54
  _logger.Logger.log(_logger.Logger.SUCCESS_TYPE, data);
56
55
  });
57
56
  child_process.stderr.on('data', errorOut => {
@@ -96,7 +95,7 @@ function getBranchName() {
96
95
  return branchName;
97
96
  }
98
97
  function getSpwanOutput(command, params = []) {
99
- const demon_process = (0, _child_process.spawnSync)(command, {
98
+ const demon_process = (0, _child_process.spawnSync)(command, params, {
100
99
  shell: true
101
100
  });
102
101
  return demon_process.stdout.toString().split('\n').filter(Boolean);
@@ -113,6 +112,9 @@ function getCredentials(login, password) {
113
112
  Dpassword: 'developer'
114
113
  };
115
114
  }
115
+ function getSonarArtifactsDir() {
116
+ return _path.default.resolve(process.cwd(), 'uat', 'lint-report', '.scannerwork');
117
+ }
116
118
 
117
119
  // import scanner from 'sonarqube-scanner';
118
120
  // import { generateConfigFromFile } from '../core/playwright/readConfigFile';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/testinglibrary",
3
- "version": "0.1.8-eslint-17",
3
+ "version": "0.1.8-eslint-19",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "scripts": {