@zohodesk/testinglibrary 0.1.8-eslint-9 → 0.1.8-eslint-11

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/.babelrc CHANGED
@@ -14,6 +14,7 @@
14
14
  ["@babel/plugin-transform-runtime"]
15
15
  ],
16
16
  "ignore": [
17
- "./src/setup-folder-structure/samples"
17
+ "./src/setup-folder-structure/samples",
18
+ "./src/lint-ci/java-jar"
18
19
  ]
19
20
  }
package/build/lib/cli.js CHANGED
@@ -9,8 +9,8 @@ var _setupProject = _interopRequireDefault(require("../setup-folder-structure/se
9
9
  var _parser = require("../parser/parser");
10
10
  var _clearCaches = _interopRequireDefault(require("../core/playwright/clear-caches"));
11
11
  var _helper = _interopRequireDefault(require("../setup-folder-structure/helper"));
12
- var _eslintLintStage = require("../eslint-ci/eslintLintStage");
13
- var _startSeverSonarQube = require("../eslint-ci/startSever-sonarQube");
12
+ var _eslintLintStage = require("../lint-ci/eslintLintStage");
13
+ var _startSeverSonarQube = require("../lint-ci/startSever-sonarQube");
14
14
  // import createJestRunner from '../core/jest/runner/jest-runner';
15
15
 
16
16
  const [,, option, ...otherOptions] = process.argv;
@@ -59,8 +59,8 @@ switch (option) {
59
59
  case 'lint':
60
60
  {
61
61
  _logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Linting Started ...');
62
- (0, _eslintLintStage.runEslintForDiff)(otherOptions).then(result => {
63
- (0, _startSeverSonarQube.sonarQubeIntegrateAnalysis)(otherOptions);
62
+ (0, _eslintLintStage.runEslintForDiff)(otherOptions).finally(result => {
63
+ (0, _startSeverSonarQube.runSonarAnalysis)(otherOptions);
64
64
  });
65
65
  break;
66
66
  }
@@ -5,64 +5,62 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.getDiffFiles = getDiffFiles;
8
+ exports.getDiffJsonPath = getDiffJsonPath;
9
+ exports.getReportPath = getReportPath;
8
10
  exports.runEslintForDiff = runEslintForDiff;
9
11
  var _getFilePath = require("../utils/getFilePath");
10
12
  var _child_process = require("child_process");
11
13
  var _path = _interopRequireDefault(require("path"));
12
14
  var _logger = require("../utils/logger");
13
15
  var _cliArgsToObject = require("../utils/cliArgsToObject");
14
- var _fs = require("fs");
15
- // function gitDiffFiles() {
16
- // const childProcess = spawnSync('git', [
17
- // 'diff',
18
- // 'HEAD',
19
- // 'HEAD~1',
20
- // '--name-only'
21
- // ]);
22
- // const diff_Files = childProcess.stdout.toString().split('\n').filter(Boolean);
23
- // var actualDiff_Files = diff_Files.map(filePath => {
24
- // var fileName = path.basename(filePath);
25
- // if (
26
- // filePath.includes('/page-object-model/') ||
27
- // filePath.includes('/assertions/')
28
- // ) {
29
- // return path.resolve(process.cwd(), '../', '../', filePath);
30
- // }
31
- // if (fileName.includes('.spec.js')) {
32
- // return path.resolve(process.cwd(), '../', '../', filePath);
33
- // }
34
- // return false;
35
- // });
36
- // return actualDiff_Files;
37
- // }
38
-
16
+ var _fileUtils = require("../utils/fileUtils");
39
17
  async function runEslintForDiff(cliParams, options = {}) {
40
18
  // $(git diff --name-only HEAD HEAD~1 | grep -E '\.(js|jsx)$' | xargs)
41
19
  const {
42
- diffPath
20
+ diffPath = null
43
21
  } = (0, _cliArgsToObject.cliArgsToObject)(cliParams);
44
22
  const format = 'json';
45
- const reportPath = _path.default.resolve(process.cwd(), 'uat', 'eslint-report', 'lintReport.json');
46
- const diffJSON = require(_path.default.resolve(diffPath));
23
+ const reportPath = getReportPath();
24
+ const diffJSON = diffPath ? require(getDiffJsonPath(diffPath)) : null;
47
25
  const filteredDiffFiles = getDiffFiles(diffJSON);
48
- const lintFiles = filteredDiffFiles.length === 0 ? [_path.default.resolve(process.cwd(), 'uat', 'modules')] : filteredDiffFiles;
49
- await new Promise(resolve => {
50
- (0, _child_process.exec)(`npx eslint ${lintFiles.join(' ')} --format=${format} -o ${reportPath}`, (stdout, stderr) => {
51
- _logger.Logger.log(_logger.Logger.FAILURE_TYPE, stderr);
26
+ const lintFiles = !filteredDiffFiles ? [_path.default.resolve(process.cwd(), 'uat', 'modules')] : filteredDiffFiles;
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);
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
+ });
52
47
  });
53
- resolve(require(reportPath));
54
- }).finally(() => {
55
- if (!(filteredDiffFiles.length === 0)) {
56
- (0, _fs.writeFileSync)(reportPath, filterReport_JSON(require(reportPath), diffJSON));
57
- }
58
48
  });
49
+
50
+ // .finally(() => {
51
+ // if (diffPath && !(filteredDiffFiles.length === 0)) {
52
+ // writeFileContents(
53
+ // reportPath,
54
+ // filterReport_JSON(require(reportPath), diffJSON)
55
+ // );
56
+ // }
57
+ // });
59
58
  }
60
59
  function filterReport_JSON(resultJson, diffJson) {
61
60
  const impactLineArray = filterDiffJson(diffJson);
62
61
  resultJson = resultJson.filter(result => {
63
62
  var _impactLineArray$get;
64
63
  const isImpactFile = getPathFromTestDir(result.filePath);
65
- console.log(isImpactFile);
66
64
  if (!isImpactFile) {
67
65
  return false;
68
66
  }
@@ -79,10 +77,6 @@ function filterReport_JSON(resultJson, diffJson) {
79
77
  });
80
78
  return JSON.stringify(resultJson);
81
79
  }
82
- function getImpactsLine() {
83
- const diffJson = _path.default.resolve(process.cwd(), 'diffContents.json');
84
- return filterDiffJson(diffJson);
85
- }
86
80
  function filterDiffJson(diffJson) {
87
81
  var _diffJson$diffs;
88
82
  const diffFilesMap = new Map();
@@ -128,6 +122,9 @@ function splitFilterNumber(numberString) {
128
122
  return resultedNum;
129
123
  }
130
124
  function getDiffFiles(diffJson) {
125
+ if (!diffJson) {
126
+ return null;
127
+ }
131
128
  return diffJson === null || diffJson === void 0 ? void 0 : diffJson.diffs.map(diff => {
132
129
  return diff === null || diff === void 0 ? void 0 : diff.new_path;
133
130
  });
@@ -138,6 +135,38 @@ function validateReport() {
138
135
  process.exit(1);
139
136
  }
140
137
  }
141
- function parseJsonReport() {
142
- const parsejson = _path.default.resolve(process.cwd(), 'uat', 'eslint-report', 'lintReport.json');
143
- }
138
+ function getReportPath(reportPath = null, reportOptions = {}) {
139
+ let jsonReportPath = _path.default.resolve(process.cwd(), 'uat', 'lint-report', 'lintReport.json');
140
+ if (!(0, _fileUtils.checkIfFileExists)(reportPath | jsonReportPath)) {
141
+ _logger.Logger.log(_logger.Logger.FAILURE_TYPE, 'Cannot Find JSON Report ...');
142
+ process.exit(0);
143
+ }
144
+ return reportPath ? reportPath : jsonReportPath;
145
+ }
146
+ function getDiffJsonPath(diffJsonPath) {
147
+ return _path.default.resolve(diffJsonPath);
148
+ }
149
+
150
+ // function gitDiffFiles() {
151
+ // const childProcess = spawnSync('git', [
152
+ // 'diff',
153
+ // 'HEAD',
154
+ // 'HEAD~1',
155
+ // '--name-only'
156
+ // ]);
157
+ // const diff_Files = childProcess.stdout.toString().split('\n').filter(Boolean);
158
+ // var actualDiff_Files = diff_Files.map(filePath => {
159
+ // var fileName = path.basename(filePath);
160
+ // if (
161
+ // filePath.includes('/page-object-model/') ||
162
+ // filePath.includes('/assertions/')
163
+ // ) {
164
+ // return path.resolve(process.cwd(), '../', '../', filePath);
165
+ // }
166
+ // if (fileName.includes('.spec.js')) {
167
+ // return path.resolve(process.cwd(), '../', '../', filePath);
168
+ // }
169
+ // return false;
170
+ // });
171
+ // return actualDiff_Files;
172
+ // }
@@ -0,0 +1,47 @@
1
+ import subprocess
2
+ import os
3
+ import json
4
+
5
+ # params Hardcoding
6
+
7
+ def run_sonar_analysis():
8
+ # os.path.join(os.getcwd(),'uat')
9
+ project_key = "UAT_Testing"
10
+ project_name = "developer"
11
+ sonar_token = "developer"
12
+ sonarqube_host_url = "https://serverlinter-np.zohodesk.csez.zohocorpin.com/"
13
+ sonar_scanner_path = os.path.join('./','sonar-scanner-cli-4.8.0.2856.jar') # Path to your SonarScanner executable
14
+ source_directories = [
15
+ os.path.join(os.getcwd(),'uat','modules','Setup','feature-files','SetupMenuCategories.feature')
16
+ ]
17
+
18
+ # Convert array to a comma-separated string
19
+ source_directories_str = ",".join(source_directories)
20
+
21
+ with open(os.path.join(os.getcwd(),'reportEslint.json'), "r") as file:
22
+ data = json.load(file)
23
+ # SonarScanner command
24
+ testFilePath_str = ",".join(paserPathFrmJson(data))
25
+ command = [
26
+ "java",
27
+ "-jar",
28
+ sonar_scanner_path,
29
+ "-Dsonar.host.url=" + sonarqube_host_url ,
30
+ "-Dsonar.projectKey=" + project_key,
31
+ f"-Dsonar.login={project_name}",
32
+ "-Dsonar.password=" + sonar_token,
33
+ "-Dsonar.sources=" + source_directories_str,
34
+ "-Dsonar.tests=" + testFilePath_str,
35
+ "-Dsonar.language=js",
36
+ "-Dsonar.eslint.reportPaths= " + os.path.join(os.getcwd(),'reportEslint.json'),
37
+ "-Dsonar.javascript.lcov.reportPaths=coverage/lcov-report/lcov.info"
38
+ ]
39
+
40
+ # Run SonarScanner
41
+ subprocess.run(command)
42
+
43
+ def paserPathFrmJson(resultJson):
44
+ return list(map(lambda result: result["filePath"], resultJson))
45
+
46
+ if __name__ == "__main__":
47
+ run_sonar_analysis()
@@ -0,0 +1,38 @@
1
+ // import path from 'path';
2
+ // import { cliArgsToObject } from '../utils/cliArgsToObject';
3
+ // import { Logger } from '../utils/logger';
4
+
5
+ // function getProperties(
6
+ // cliParams,
7
+ // login,
8
+ // password,
9
+ // sources,
10
+ // testDir,
11
+ // language,
12
+ // eslintReportPath,
13
+ // serverArtifactsDir
14
+ // ) {
15
+ // const { repo, branch, username } = cliArgsToObject(cliParams);
16
+ // var isProjectNameDefined = false;
17
+ // const projectName =
18
+ // repo && branch && username
19
+ // ? `${repo}_${branch}_${username}`
20
+ // : (isProjectNameDefined = true);
21
+ // if (isProjectNameDefined && login && password && eslintReportPath) {
22
+ // Logger.log(Logger.FAILURE_TYPE, 'Project Properties is Missing');
23
+ // process.exit(0);
24
+ // }
25
+ // return {
26
+ // projectName,
27
+ // login,
28
+ // password,
29
+ // sources,
30
+ // testDir,
31
+ // language,
32
+ // eslintReportPath,
33
+ // serverArtifactsDir
34
+ // };
35
+ // }
36
+
37
+ // export { getDefaultServerProperties, getProperties };
38
+ "use strict";
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.writeSummaryOfLint = writeSummaryOfLint;
8
+ var _path = _interopRequireDefault(require("path"));
9
+ var _fileUtils = require("../utils/fileUtils");
10
+ var _cliArgsToObject = require("../utils/cliArgsToObject");
11
+ var _eslintLintStage = require("./eslintLintStage");
12
+ function getSummaryOfLint(cliParams) {
13
+ const {
14
+ repo,
15
+ branch,
16
+ username
17
+ } = (0, _cliArgsToObject.cliArgsToObject)(cliParams);
18
+ return {
19
+ projectNameL: `${repo}_${branch},${username}`,
20
+ reportUrl: `https://serverlinter.zohodesk.csez.zohocorpin.com/project/issues?id=${repo}_${branch}_${username}&resolve=false`,
21
+ jsonReportPath: (0, _eslintLintStage.getReportPath)().toString()
22
+ };
23
+ }
24
+ function writeSummaryOfLint(cliParams) {
25
+ (0, _fileUtils.writeFileContents)(_path.default.resolve(process.cwd(), 'uat', 'lint-report', 'lint-summary.json'), JSON.stringify(getSummaryOfLint(cliParams)));
26
+ }
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.runSonarAnalysis = runSonarAnalysis;
8
+ var _path = _interopRequireDefault(require("path"));
9
+ var _fs = _interopRequireDefault(require("fs"));
10
+ var _child_process = require("child_process");
11
+ var _eslintLintStage = require("./eslintLintStage");
12
+ var _cliArgsToObject = require("../utils/cliArgsToObject");
13
+ var _sonarReportSummary = require("./sonarReportSummary");
14
+ var _logger = require("../utils/logger");
15
+ var _rootPath = require("../utils/rootPath");
16
+ // Js script to start sonar Server
17
+
18
+ /**
19
+ * cli cmd :
20
+ * npx ZDTestingFramework lint -- --lintEnv=ci --diffPath="" --repo="deskClientApp" --branch="" --username=""
21
+ */
22
+
23
+ function runSonarAnalysis(cliParams) {
24
+ var _getFilePathFrmReport, _getFilePathFrmReport2;
25
+ const {
26
+ diffPath,
27
+ repo,
28
+ branch,
29
+ username,
30
+ login = null,
31
+ password = null
32
+ } = (0, _cliArgsToObject.cliArgsToObject)(cliParams);
33
+ const sonarqube_host_url = 'https://serverlinter-np.zohodesk.csez.zohocorpin.com/';
34
+ const sonar_scanner_path = (0, _rootPath.getSonarJarPath)();
35
+ const {
36
+ Dlogin,
37
+ Dpassword
38
+ } = getCredentials(login, password);
39
+ const project_name = repo && branch && branch ? `${repo}_${branch}_${username}` : 'UAT_Testing';
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) || [' '];
42
+ const source_directories_str = source_directories.join(',');
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 child_process = (0, _child_process.spawn)('java', command);
45
+ child_process.stdout.on('data', data => {
46
+ _logger.Logger.log(_logger.Logger.SUCCESS_TYPE, data);
47
+ });
48
+ child_process.stderr.on('data', errorOut => {
49
+ _logger.Logger.error(_logger.Logger.FAILURE_TYPE, errorOut);
50
+ });
51
+ child_process.on('error', error => {
52
+ _logger.Logger.error(_logger.Logger.FAILURE_TYPE, `Error: ${error.message}`);
53
+ });
54
+ child_process.on('close', code => {
55
+ _logger.Logger.log(_logger.Logger.SUCCESS_TYPE, `Lint Stage Executed & Status - ${code === 0 ? 'Success' : 'Failure'}`);
56
+ (0, _sonarReportSummary.writeSummaryOfLint)(cliParams);
57
+ });
58
+ }
59
+ function getFilePathFrmReport(resultJson) {
60
+ return resultJson.reduce((filesPath, fileReport) => {
61
+ if (fileReport.filePath.includes('.feature')) {
62
+ filesPath.featureFilesPath.push(fileReport.filePath);
63
+ }
64
+ filesPath.stepFilesPath.push(fileReport.filePath);
65
+ return filesPath;
66
+ }, {
67
+ stepFilesPath: [],
68
+ featureFilesPath: []
69
+ });
70
+ }
71
+ function getCredentials(login, password) {
72
+ if (login && password) {
73
+ return {
74
+ Dlogin: login,
75
+ Dpassword: password
76
+ };
77
+ }
78
+ return {
79
+ Dlogin: 'developer',
80
+ Dpassword: 'developer'
81
+ };
82
+ }
83
+
84
+ // import scanner from 'sonarqube-scanner';
85
+ // import { generateConfigFromFile } from '../core/playwright/readConfigFile';
86
+ // const postCallBack = () => process.exit();
87
+ // import path from 'path';
88
+ // import { getReportPath } from './eslintLintStage';
89
+ // const serverHostUrl = 'https://serverlinter-np.zohodesk.csez.zohocorpin.com';
90
+ // function sonarQubeIntegrateAnalysis(cliParams, option) {
91
+ // const testDir = path.resolve(process.cwd(), 'uat', 'modules');
92
+ // const eslintResult = getReportPath();
93
+ // const artifactsPath = path.resolve(process.cwd(), 'uat', '.scannerwork');
94
+ // const options = getProperties(
95
+ // cliParams,
96
+ // 'developer',
97
+ // 'developer',
98
+ // '',
99
+ // testDir,
100
+ // 'js',
101
+ // eslintResult,
102
+ // artifactsPath
103
+ // );
104
+ // scanner({ serverUrl: serverHostUrl, options: options }, postCallBack);
105
+ // }
106
+
107
+ // export { sonarQubeIntegrateAnalysis };
@@ -14,7 +14,13 @@ const reportRelativepath = path.relative(gitIgnoreAbsolutePath, reportPath)
14
14
  const absolutePathfeaturegen = path.resolve(process.cwd(), 'uat', '.features-gen');
15
15
  const featuregenRelativePath = path.relative(gitIgnoreAbsolutePath,absolutePathfeaturegen)
16
16
 
17
- const dirpathtoIgnore = `${testResultsRelativepath}\n${reportRelativepath}\n${featuregenRelativePath}`
17
+ const absolutePathScannerworkFolder = path.resolve(process.cwd(),'uat','.scanerwork')
18
+ const scannerWorkPath = path.relative(gitIgnoreAbsolutePath,absolutePathScannerworkFolder)
19
+
20
+ const absoluteLintPath = path.resolve(process.cwd(),'uat','lint-report')
21
+ const lintReportpath = path.relative(gitIgnoreAbsolutePath,absoluteLintPath)
22
+
23
+ const dirpathtoIgnore = `${testResultsRelativepath}\n${reportRelativepath}\n${featuregenRelativePath}\n${scannerWorkPath}\n${lintReportpath}`
18
24
 
19
25
  function updateGitIgnore() {
20
26
  if (existsSync(path.resolve(process.cwd(), '../', '../', '.gitignore'))) {
@@ -8,10 +8,12 @@ exports.getBinPath = getBinPath;
8
8
  exports.getExecutableBinaryPath = getExecutableBinaryPath;
9
9
  exports.getRootNodeModulesPath = getRootNodeModulesPath;
10
10
  exports.getRootPath = getRootPath;
11
+ exports.getSonarJarPath = getSonarJarPath;
11
12
  var _path = _interopRequireDefault(require("path"));
12
13
  var _fs = _interopRequireDefault(require("fs"));
13
14
  var _logger = require("./logger");
14
15
  var _getFilePath = _interopRequireDefault(require("./getFilePath"));
16
+ var _fileUtils = require("./fileUtils");
15
17
  function findBinaryPath(directory, command) {
16
18
  const binaryPath = _path.default.join(directory, '.bin', (0, _getFilePath.default)(command));
17
19
  if (_fs.default.existsSync(binaryPath)) {
@@ -43,4 +45,12 @@ function getExecutableBinaryPath(command) {
43
45
  _logger.Logger.log(_logger.Logger.FAILURE_TYPE, `Error: Could not find executable bin ${command} file. Make sure to npm install before proceeding`);
44
46
  process.exit();
45
47
  }
48
+ }
49
+ function getSonarJarPath() {
50
+ const jarPath = _path.default.resolve('node_modules', '@zohodesk', 'testinglibrary', 'build', 'lint-ci', 'java-jar', 'sonar-scanner-cli-4.8.0.2856.jar');
51
+ if ((0, _fileUtils.checkIfFileExists)(jarPath)) {
52
+ return jarPath;
53
+ }
54
+ _logger.Logger.log(_logger.Logger.FAILURE_TYPE, 'Cannot Find Java-Jar');
55
+ process.exit(0);
46
56
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/testinglibrary",
3
- "version": "0.1.8-eslint-9",
3
+ "version": "0.1.8-eslint-11",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "scripts": {
@@ -1,39 +0,0 @@
1
- import subprocess
2
-
3
- # params Hardcoding
4
-
5
- def run_sonar_analysis():
6
- project_key = "UAT_Testing"
7
- project_name = "developer"
8
- sonar_token = "developer"
9
- sonarqube_host_url = "https://serverlinter-np.zohodesk.csez.zohocorpin.com/"
10
- sonar_scanner_path = "./sonar-scanner-cli-4.8.0.2856.jar" # Path to your SonarScanner executable
11
- source_directories = [
12
- "./uat/modules/Setup/feature-files/SetupMenuCategories.feature",
13
- "./uat/modules/Setup/feature-files/SetupMenuPanelHide.feature",
14
- "./uat/modules/Setup/feature-files/SearchClear.feature",
15
- ]
16
-
17
- # Convert array to a comma-separated string
18
- source_directories_str = ",".join(source_directories)
19
-
20
- # SonarScanner command
21
- command = [
22
- "java",
23
- "-jar",
24
- sonar_scanner_path,
25
- "-Dsonar.host.url=" + sonarqube_host_url ,
26
- "-Dsonar.projectKey=" + project_key,
27
- "-Dsonar.login=" + project_name,
28
- "-Dsonar.password=" + sonar_token,
29
- "-Dsonar.sources=" + source_directories_str, # Specify the source directory for your JavaScript files # Specify the test directory for your JavaScript test files
30
- "-Dsonar.language=js",
31
- "-Dsonar.javascript.lcov.reportPaths=coverage/lcov-report/lcov.info", # If you have code coverage reports
32
- "-Dsonar.eslint.eslintconfigpath=./eslintrc.js"
33
- ]
34
-
35
- # Run SonarScanner
36
- subprocess.run(command)
37
-
38
- if __name__ == "__main__":
39
- run_sonar_analysis()
@@ -1,46 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.getDefaultServerProperties = getDefaultServerProperties;
8
- exports.getProperties = getProperties;
9
- var _path = _interopRequireDefault(require("path"));
10
- var _cliArgsToObject = require("../utils/cliArgsToObject");
11
- var _logger = require("../utils/logger");
12
- function getDefaultServerProperties() {
13
- return {
14
- 'sonar.projectName': 'UAT_Testing',
15
- 'sonar..login': "developer",
16
- 'sonar.password': "developer",
17
- 'sonar.sources': '',
18
- 'sonar.tests': `${_path.default.resolve(process.cwd(), 'uat', 'modules')}`,
19
- 'sonar.language': 'js',
20
- 'sonar.eslint.reportPaths': `${_path.default.resolve(process.cwd(), 'uat', 'eslint-report', 'lintReport.json')}`,
21
- 'sonar.working.directory': `${_path.default.resolve(process.cwd(), 'uat', 'modules', '.scannerwork')}`
22
- };
23
- }
24
- function getProperties(cliParams, login, password, sources, testDir, language, eslintReportPath, serverArtifactsDir) {
25
- const {
26
- repo,
27
- branch,
28
- username
29
- } = (0, _cliArgsToObject.cliArgsToObject)(cliParams);
30
- var isProjectNameDefined = false;
31
- const projectName = repo && branch && username ? `${repo}_${branch}_${username}` : isProjectNameDefined = true;
32
- if (isProjectNameDefined && login && password && eslintReportPath) {
33
- _logger.Logger.log(_logger.Logger.FAILURE_TYPE, 'Project Properties is Missing');
34
- process.exit(0);
35
- }
36
- return {
37
- 'sonar.projectName': projectName,
38
- 'sonar.login': login,
39
- 'sonar.password': password,
40
- 'sonar.sources': sources,
41
- 'sonar.tests': testDir,
42
- 'sonar.language': language,
43
- 'sonar.eslint.reportPaths': eslintReportPath,
44
- 'sonar.working.directory': serverArtifactsDir
45
- };
46
- }
@@ -1,30 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.sonarQubeIntegrateAnalysis = sonarQubeIntegrateAnalysis;
8
- var _sonarqubeScanner = _interopRequireDefault(require("sonarqube-scanner"));
9
- var _readConfigFile = require("../core/playwright/readConfigFile");
10
- var _path = _interopRequireDefault(require("path"));
11
- var _reportServerConfig = require("./reportServerConfig");
12
- // Js script to start sonar Server
13
-
14
- /**
15
- * cli cmd :
16
- * npx ZDTestingFramework lint -- --lintEnv=ci --diffPath="" --repo="deskClientApp" --branch="" --username=""
17
- */
18
-
19
- const postCallBack = () => process.exit();
20
- const serverHostUrl = 'https://serverlinter-np.zohodesk.csez.zohocorpin.com';
21
- function sonarQubeIntegrateAnalysis(cliParams, option) {
22
- const testDir = _path.default.resolve(process.cwd(), 'uat', 'modules');
23
- const eslintResult = _path.default.resolve(process.cwd(), 'uat', 'eslint-report', 'lintReport.json');
24
- const artifactsPath = _path.default.resolve(process.cwd(), 'uat', '.scannerwork');
25
- const options = (0, _reportServerConfig.getProperties)(cliParams, 'developer', 'developer', '', testDir, 'js', eslintResult, artifactsPath);
26
- (0, _sonarqubeScanner.default)({
27
- serverUrl: serverHostUrl,
28
- options: options
29
- }, postCallBack);
30
- }