@zohodesk/testinglibrary 0.1.8-eslint-20 → 0.1.8-eslint-21
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.
|
@@ -16,8 +16,7 @@ var _path = _interopRequireDefault(require("path"));
|
|
|
16
16
|
var _logger = require("../utils/logger");
|
|
17
17
|
var _cliArgsToObject = require("../utils/cliArgsToObject");
|
|
18
18
|
var _fileUtils = require("../utils/fileUtils");
|
|
19
|
-
|
|
20
|
-
var _console = require("console");
|
|
19
|
+
// import { requestJAR } from './requestJarAPI';
|
|
21
20
|
async function runEslintForDiff(cliParams, options = {}) {
|
|
22
21
|
// $(git diff --name-only HEAD HEAD~1 | grep -E '\.(js|jsx)$' | xargs)
|
|
23
22
|
// await requestJAR(cliParams);
|
|
@@ -149,7 +148,7 @@ function getDiffFiles(diffJson) {
|
|
|
149
148
|
}
|
|
150
149
|
function getReportPath(reportPath = null, reportOptions = {}) {
|
|
151
150
|
let jsonReportPath = reportPath || _path.default.resolve(process.cwd(), 'uat', 'lint-report', 'lintReport.json');
|
|
152
|
-
return
|
|
151
|
+
return jsonReportPath;
|
|
153
152
|
}
|
|
154
153
|
function getDiffJsonPath(diffJsonPath) {
|
|
155
154
|
return _path.default.resolve(diffJsonPath);
|
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.showMsgPopUp = showMsgPopUp;
|
|
8
|
+
var _startSeverSonarQube = require("./startSever-sonarQube");
|
|
9
|
+
var _path = _interopRequireDefault(require("path"));
|
|
10
|
+
function showMsgPopUp(condition) {
|
|
11
|
+
// java -jar ./IDEMessagePluginRecent.jar project_name "BothStagedAndUnstaged" server_url java_version_output
|
|
12
|
+
const command = 'java';
|
|
13
|
+
const params = ['-jar', `${getPopupJarPath()}`, (0, _startSeverSonarQube.getProjectNameFrmGit)(), condition, 'java version 11'];
|
|
14
|
+
switch (condition) {
|
|
15
|
+
case 'NoIssueFound':
|
|
16
|
+
(0, _startSeverSonarQube.getSpawnOutput)(command, params);
|
|
17
|
+
break;
|
|
18
|
+
case 'IssueFound':
|
|
19
|
+
(0, _startSeverSonarQube.getSpawnOutput)(command, params);
|
|
20
|
+
break;
|
|
21
|
+
case 'BothStagedAndUnstaged':
|
|
22
|
+
(0, _startSeverSonarQube.getSpawnOutput)(command, params);
|
|
23
|
+
break;
|
|
24
|
+
default:
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function getPopupJarPath() {
|
|
29
|
+
return _path.default.resolve('node_modules', '@zohodesk', 'testinglibrary', 'build', 'lint-ci', 'java-jar', 'IDEMessagePluginRecent.jar');
|
|
30
|
+
}
|
|
@@ -4,6 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
+
exports.getSummaryOfLint = getSummaryOfLint;
|
|
7
8
|
exports.writeSummaryOfLint = writeSummaryOfLint;
|
|
8
9
|
var _path = _interopRequireDefault(require("path"));
|
|
9
10
|
var _fileUtils = require("../utils/fileUtils");
|
|
@@ -24,5 +25,8 @@ function getSummaryOfLint(cliParams) {
|
|
|
24
25
|
};
|
|
25
26
|
}
|
|
26
27
|
function writeSummaryOfLint(cliParams) {
|
|
27
|
-
(0, _fileUtils.writeFileContents)(_path.default.resolve(process.cwd(), 'uat', 'lint-report', 'lint-summary.json'), JSON.stringify(
|
|
28
|
+
(0, _fileUtils.writeFileContents)(_path.default.resolve(process.cwd(), 'uat', 'lint-report', 'lint-summary.json'), JSON.stringify({
|
|
29
|
+
...getSummaryOfLint(cliParams),
|
|
30
|
+
...(0, _startSeverSonarQube.getLintStatus)()
|
|
31
|
+
}));
|
|
28
32
|
}
|
|
@@ -4,7 +4,9 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
+
exports.getLintStatus = getLintStatus;
|
|
7
8
|
exports.getProjectNameFrmGit = getProjectNameFrmGit;
|
|
9
|
+
exports.getSpawnOutput = getSpawnOutput;
|
|
8
10
|
exports.runSonarAnalysis = runSonarAnalysis;
|
|
9
11
|
var _path = _interopRequireDefault(require("path"));
|
|
10
12
|
var _fs = _interopRequireDefault(require("fs"));
|
|
@@ -15,6 +17,7 @@ var _sonarReportSummary = require("./sonarReportSummary");
|
|
|
15
17
|
var _logger = require("../utils/logger");
|
|
16
18
|
var _rootPath = require("../utils/rootPath");
|
|
17
19
|
var _fileUtils = require("../utils/fileUtils");
|
|
20
|
+
var _popUpCli = require("./popUpCli");
|
|
18
21
|
// Js script to start sonar Server
|
|
19
22
|
|
|
20
23
|
/**
|
|
@@ -44,7 +47,6 @@ function runSonarAnalysis(cliParams) {
|
|
|
44
47
|
project_name = getProjectNameFrmGit();
|
|
45
48
|
}
|
|
46
49
|
var resultFilesPath = diffPath ? (0, _eslintLintStage.getDiffFiles)(require((0, _eslintLintStage.getDiffJsonPath)(diffPath))).join(',') : [`${_path.default.resolve(process.cwd(), 'uat', 'modules')}`].join(',');
|
|
47
|
-
console.log('&&', (0, _fileUtils.checkIfFileExists)((0, _eslintLintStage.getReportPath)()));
|
|
48
50
|
const source_directories = ((_getFilePathFrmReport = getFilePathFrmReport(require((0, _eslintLintStage.getReportPath)()))) === null || _getFilePathFrmReport === void 0 ? void 0 : _getFilePathFrmReport.featureFilesPath) || [' '];
|
|
49
51
|
const source_directories_str = lintEnv == 'pre-commit' ? ' ' : source_directories.join(',');
|
|
50
52
|
if (lintEnv == 'pre-commit') {
|
|
@@ -64,6 +66,22 @@ function runSonarAnalysis(cliParams) {
|
|
|
64
66
|
child_process.on('close', code => {
|
|
65
67
|
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, `Lint Stage Executed & Status - ${code === 0 ? 'Success' : 'Failure'}`);
|
|
66
68
|
(0, _sonarReportSummary.writeSummaryOfLint)(cliParams);
|
|
69
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, `report url - ${(0, _sonarReportSummary.getSummaryOfLint)(cliParams).reportUrl}`);
|
|
70
|
+
if (lintEnv == 'pre-commit') {
|
|
71
|
+
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'lint triggered from pre-commit ...');
|
|
72
|
+
if (!getLintStatus().status && getLintStatus().message == 'failed') {
|
|
73
|
+
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, 'rules violated .. ');
|
|
74
|
+
(0, _popUpCli.showMsgPopUp)('IssueFound');
|
|
75
|
+
process.exit(0);
|
|
76
|
+
} else {
|
|
77
|
+
(0, _popUpCli.showMsgPopUp)('NoIssueFound');
|
|
78
|
+
}
|
|
79
|
+
if (!getLintStatus().status && getLintStatus().message == 'failed') {
|
|
80
|
+
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, 'rules violated .. ');
|
|
81
|
+
(0, _popUpCli.showMsgPopUp)('IssueFound');
|
|
82
|
+
process.exit(0);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
67
85
|
});
|
|
68
86
|
}
|
|
69
87
|
function getFilePathFrmReport(resultJson) {
|
|
@@ -82,21 +100,21 @@ function getProjectNameFrmGit() {
|
|
|
82
100
|
return `${getRepoName()}_${getBranchName()}_${getGitUsername()}`;
|
|
83
101
|
}
|
|
84
102
|
function getGitUsername() {
|
|
85
|
-
const userName =
|
|
103
|
+
const userName = getSpawnOutput('git', ['config', 'user.email']);
|
|
86
104
|
return userName.pop().split('@')[0];
|
|
87
105
|
}
|
|
88
106
|
function getRepoName() {
|
|
89
|
-
const repoName =
|
|
107
|
+
const repoName = getSpawnOutput('git', ['remote', 'get-url', 'origin']);
|
|
90
108
|
return repoName.pop().split('/').pop().split('.')[0];
|
|
91
109
|
}
|
|
92
110
|
function getBranchName() {
|
|
93
|
-
const branchName =
|
|
111
|
+
const branchName = getSpawnOutput('git', ['branch']).shift();
|
|
94
112
|
if (branchName.startsWith('*')) {
|
|
95
113
|
return branchName.replace('*', ' ').trim();
|
|
96
114
|
}
|
|
97
115
|
return branchName;
|
|
98
116
|
}
|
|
99
|
-
function
|
|
117
|
+
function getSpawnOutput(command, params = []) {
|
|
100
118
|
const demon_process = (0, _child_process.spawnSync)(command, params, {
|
|
101
119
|
shell: true
|
|
102
120
|
});
|
|
@@ -114,6 +132,39 @@ function getCredentials(login, password) {
|
|
|
114
132
|
Dpassword: 'developer'
|
|
115
133
|
};
|
|
116
134
|
}
|
|
135
|
+
function getLintStatus() {
|
|
136
|
+
var reportStatus = true;
|
|
137
|
+
const report = require((0, _eslintLintStage.getReportPath)());
|
|
138
|
+
if (report.length == 0) {
|
|
139
|
+
reportStatus = true;
|
|
140
|
+
return {
|
|
141
|
+
status: true,
|
|
142
|
+
message: 'passed'
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
if (report.length != 0) {
|
|
146
|
+
for (i = 0; i < report.length; i++) {
|
|
147
|
+
if (fileReport.messages != 0 && fileReport.errorCount != 0) {
|
|
148
|
+
reportStatus = false;
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (reportStatus) {
|
|
153
|
+
return {
|
|
154
|
+
status: reportStatus,
|
|
155
|
+
message: 'passed'
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
return {
|
|
159
|
+
status: reportStatus,
|
|
160
|
+
message: 'failed'
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
return {
|
|
164
|
+
status: reportStatus,
|
|
165
|
+
message: 'passed'
|
|
166
|
+
};
|
|
167
|
+
}
|
|
117
168
|
function getSonarArtifactsDir() {
|
|
118
169
|
return _path.default.resolve(process.cwd(), 'uat', 'lint-report', '.scannerwork');
|
|
119
170
|
}
|