@zohodesk/testinglibrary 0.1.8-eslint-9 → 0.1.8-eslint-10
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 +2 -1
- package/build/lib/cli.js +3 -3
- package/build/{eslint-ci → lint-ci}/eslintLintStage.js +45 -40
- package/build/lint-ci/java-jar/sonar-scanner-cli-4.8.0.2856.jar +0 -0
- package/build/lint-ci/java-jar/startAnalysis.py +47 -0
- package/build/lint-ci/reportServerConfig.js +38 -0
- package/build/lint-ci/sonarReportSummary.js +26 -0
- package/build/lint-ci/startSever-sonarQube.js +107 -0
- package/build/setup-folder-structure/samples/git-ignore.sample.js +7 -1
- package/build/utils/rootPath.js +10 -0
- package/main.js +14 -0
- package/package.json +1 -1
- package/build/eslint-ci/java-jar/startAnalysis.py +0 -39
- package/build/eslint-ci/reportServerConfig.js +0 -46
- package/build/eslint-ci/startSever-sonarQube.js +0 -30
package/.babelrc
CHANGED
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("../
|
|
13
|
-
var _startSeverSonarQube = require("../
|
|
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;
|
|
@@ -60,7 +60,7 @@ switch (option) {
|
|
|
60
60
|
{
|
|
61
61
|
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Linting Started ...');
|
|
62
62
|
(0, _eslintLintStage.runEslintForDiff)(otherOptions).then(result => {
|
|
63
|
-
(0, _startSeverSonarQube.
|
|
63
|
+
(0, _startSeverSonarQube.runSonarAnalysis)(otherOptions);
|
|
64
64
|
});
|
|
65
65
|
break;
|
|
66
66
|
}
|
|
@@ -5,55 +5,35 @@ 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
|
|
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 =
|
|
46
|
-
const diffJSON = require(
|
|
23
|
+
const reportPath = getReportPath();
|
|
24
|
+
const diffJSON = diffPath ? require(getDiffJsonPath(diffPath)) : null;
|
|
47
25
|
const filteredDiffFiles = getDiffFiles(diffJSON);
|
|
48
|
-
const lintFiles = filteredDiffFiles
|
|
26
|
+
const lintFiles = !filteredDiffFiles ? [_path.default.resolve(process.cwd(), 'uat', 'modules')] : filteredDiffFiles;
|
|
49
27
|
await new Promise(resolve => {
|
|
50
28
|
(0, _child_process.exec)(`npx eslint ${lintFiles.join(' ')} --format=${format} -o ${reportPath}`, (stdout, stderr) => {
|
|
51
29
|
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, stderr);
|
|
52
30
|
});
|
|
53
|
-
resolve(
|
|
31
|
+
resolve({
|
|
32
|
+
status: 'executed'
|
|
33
|
+
});
|
|
54
34
|
}).finally(() => {
|
|
55
|
-
if (!(filteredDiffFiles.length === 0)) {
|
|
56
|
-
(0,
|
|
35
|
+
if (diffPath && !(filteredDiffFiles.length === 0)) {
|
|
36
|
+
(0, _fileUtils.writeFileContents)(reportPath, filterReport_JSON(require(reportPath), diffJSON));
|
|
57
37
|
}
|
|
58
38
|
});
|
|
59
39
|
}
|
|
@@ -62,7 +42,6 @@ function filterReport_JSON(resultJson, diffJson) {
|
|
|
62
42
|
resultJson = resultJson.filter(result => {
|
|
63
43
|
var _impactLineArray$get;
|
|
64
44
|
const isImpactFile = getPathFromTestDir(result.filePath);
|
|
65
|
-
console.log(isImpactFile);
|
|
66
45
|
if (!isImpactFile) {
|
|
67
46
|
return false;
|
|
68
47
|
}
|
|
@@ -79,10 +58,6 @@ function filterReport_JSON(resultJson, diffJson) {
|
|
|
79
58
|
});
|
|
80
59
|
return JSON.stringify(resultJson);
|
|
81
60
|
}
|
|
82
|
-
function getImpactsLine() {
|
|
83
|
-
const diffJson = _path.default.resolve(process.cwd(), 'diffContents.json');
|
|
84
|
-
return filterDiffJson(diffJson);
|
|
85
|
-
}
|
|
86
61
|
function filterDiffJson(diffJson) {
|
|
87
62
|
var _diffJson$diffs;
|
|
88
63
|
const diffFilesMap = new Map();
|
|
@@ -128,6 +103,9 @@ function splitFilterNumber(numberString) {
|
|
|
128
103
|
return resultedNum;
|
|
129
104
|
}
|
|
130
105
|
function getDiffFiles(diffJson) {
|
|
106
|
+
if (!diffJson) {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
131
109
|
return diffJson === null || diffJson === void 0 ? void 0 : diffJson.diffs.map(diff => {
|
|
132
110
|
return diff === null || diff === void 0 ? void 0 : diff.new_path;
|
|
133
111
|
});
|
|
@@ -138,6 +116,33 @@ function validateReport() {
|
|
|
138
116
|
process.exit(1);
|
|
139
117
|
}
|
|
140
118
|
}
|
|
141
|
-
function
|
|
142
|
-
|
|
143
|
-
}
|
|
119
|
+
function getReportPath(reportPath = null, reportOptions = {}) {
|
|
120
|
+
return reportPath ? reportPath : _path.default.resolve(process.cwd(), 'uat', 'lint-report', 'lintReport.json');
|
|
121
|
+
}
|
|
122
|
+
function getDiffJsonPath(diffJsonPath) {
|
|
123
|
+
return _path.default.resolve(diffJsonPath);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// function gitDiffFiles() {
|
|
127
|
+
// const childProcess = spawnSync('git', [
|
|
128
|
+
// 'diff',
|
|
129
|
+
// 'HEAD',
|
|
130
|
+
// 'HEAD~1',
|
|
131
|
+
// '--name-only'
|
|
132
|
+
// ]);
|
|
133
|
+
// const diff_Files = childProcess.stdout.toString().split('\n').filter(Boolean);
|
|
134
|
+
// var actualDiff_Files = diff_Files.map(filePath => {
|
|
135
|
+
// var fileName = path.basename(filePath);
|
|
136
|
+
// if (
|
|
137
|
+
// filePath.includes('/page-object-model/') ||
|
|
138
|
+
// filePath.includes('/assertions/')
|
|
139
|
+
// ) {
|
|
140
|
+
// return path.resolve(process.cwd(), '../', '../', filePath);
|
|
141
|
+
// }
|
|
142
|
+
// if (fileName.includes('.spec.js')) {
|
|
143
|
+
// return path.resolve(process.cwd(), '../', '../', filePath);
|
|
144
|
+
// }
|
|
145
|
+
// return false;
|
|
146
|
+
// });
|
|
147
|
+
// return actualDiff_Files;
|
|
148
|
+
// }
|
|
Binary file
|
|
@@ -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 = (0, _child_process.spawn)('java', command);
|
|
45
|
+
child.stdout.on('data', data => {
|
|
46
|
+
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, data);
|
|
47
|
+
});
|
|
48
|
+
child.stderr.on('data', errorOut => {
|
|
49
|
+
_logger.Logger.error(_logger.Logger.FAILURE_TYPE, errorOut);
|
|
50
|
+
});
|
|
51
|
+
child.on('error', error => {
|
|
52
|
+
_logger.Logger.error(_logger.Logger.FAILURE_TYPE, `Error: ${error.message}`);
|
|
53
|
+
});
|
|
54
|
+
child.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
|
|
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'))) {
|
package/build/utils/rootPath.js
CHANGED
|
@@ -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/main.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
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']);
|
package/package.json
CHANGED
|
@@ -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
|
-
}
|