@zohodesk/testinglibrary 0.1.8-eslint-20 → 0.1.8-eslint-23

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
- var _requestJarAPI = require("./requestJarAPI");
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 reportPath ? reportPath : jsonReportPath;
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
- const {
4
- spawn
5
- } = require('child_process');
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(getSummaryOfLint(cliParams)));
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') {
@@ -62,8 +64,19 @@ function runSonarAnalysis(cliParams) {
62
64
  _logger.Logger.error(_logger.Logger.FAILURE_TYPE, `Error: ${error.message}`);
63
65
  });
64
66
  child_process.on('close', code => {
65
- _logger.Logger.log(_logger.Logger.SUCCESS_TYPE, `Lint Stage Executed & Status - ${code === 0 ? 'Success' : 'Failure'}`);
67
+ _logger.Logger.log(_logger.Logger.SUCCESS_TYPE, `Report to Server 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(1);
76
+ } else {
77
+ (0, _popUpCli.showMsgPopUp)('NoIssueFound');
78
+ }
79
+ }
67
80
  });
68
81
  }
69
82
  function getFilePathFrmReport(resultJson) {
@@ -79,24 +92,27 @@ function getFilePathFrmReport(resultJson) {
79
92
  });
80
93
  }
81
94
  function getProjectNameFrmGit() {
82
- return `${getRepoName()}_${getBranchName()}_${getGitUsername()}`;
95
+ let $repoName = getRepoName();
96
+ let $branchName = getBranchName();
97
+ let $username = getGitUsername();
98
+ return $repoName && $branchName && $username ? `${$repoName}_${$branchName}_${$username}` : 'desk_default_project';
83
99
  }
84
100
  function getGitUsername() {
85
- const userName = getSpwanOutput('git', ['config', 'user.email']);
101
+ const userName = getSpawnOutput('git', ['config', 'user.email']);
86
102
  return userName.pop().split('@')[0];
87
103
  }
88
104
  function getRepoName() {
89
- const repoName = getSpwanOutput('git', ['remote', 'get-url', 'origin']);
105
+ const repoName = getSpawnOutput('git', ['remote', 'get-url', 'origin']);
90
106
  return repoName.pop().split('/').pop().split('.')[0];
91
107
  }
92
108
  function getBranchName() {
93
- const branchName = getSpwanOutput('git', ['branch']).shift();
109
+ const branchName = getSpawnOutput('git', ['branch'])[1]; // to get current branch
94
110
  if (branchName.startsWith('*')) {
95
111
  return branchName.replace('*', ' ').trim();
96
112
  }
97
113
  return branchName;
98
114
  }
99
- function getSpwanOutput(command, params = []) {
115
+ function getSpawnOutput(command, params = []) {
100
116
  const demon_process = (0, _child_process.spawnSync)(command, params, {
101
117
  shell: true
102
118
  });
@@ -114,6 +130,39 @@ function getCredentials(login, password) {
114
130
  Dpassword: 'developer'
115
131
  };
116
132
  }
133
+ function getLintStatus() {
134
+ var reportStatus = true;
135
+ const report = require((0, _eslintLintStage.getReportPath)());
136
+ if (report.length == 0) {
137
+ reportStatus = true;
138
+ return {
139
+ status: true,
140
+ message: 'passed'
141
+ };
142
+ }
143
+ if (report.length != 0) {
144
+ for (let i = 0; i < report.length; i++) {
145
+ if (report[i].messages != 0) {
146
+ reportStatus = false;
147
+ break;
148
+ }
149
+ }
150
+ if (reportStatus) {
151
+ return {
152
+ status: reportStatus,
153
+ message: 'passed'
154
+ };
155
+ }
156
+ return {
157
+ status: reportStatus,
158
+ message: 'failed'
159
+ };
160
+ }
161
+ return {
162
+ status: reportStatus,
163
+ message: 'passed'
164
+ };
165
+ }
117
166
  function getSonarArtifactsDir() {
118
167
  return _path.default.resolve(process.cwd(), 'uat', 'lint-report', '.scannerwork');
119
168
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/testinglibrary",
3
- "version": "0.1.8",
3
+ "version": "0.1.8-eslint-21",
4
4
  "lockfileVersion": 1,
5
5
  "requires": true,
6
6
  "dependencies": {
@@ -2497,6 +2497,12 @@
2497
2497
  "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.0.tgz",
2498
2498
  "integrity": "sha512-FS7hV565M5l1R08MXqo8odwMTB02C2UqzB17RVgu9EyuYFBqJZ3/ZY97sQD5FewVu1UyDFc1yztUDrAwT0EypA=="
2499
2499
  },
2500
+ "adm-zip": {
2501
+ "version": "0.5.12",
2502
+ "resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.5.12.tgz",
2503
+ "integrity": "sha512-6TVU49mK6KZb4qG6xWaaM4C7sA/sgUMLy/JYMOzkcp3BvVLpW0fXDFQiIzAuxFCt/2+xD7fNIiPFAoLZPhVNLQ==",
2504
+ "dev": true
2505
+ },
2500
2506
  "agent-base": {
2501
2507
  "version": "6.0.2",
2502
2508
  "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz",
@@ -2991,6 +2997,12 @@
2991
2997
  "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
2992
2998
  "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
2993
2999
  },
3000
+ "color-support": {
3001
+ "version": "1.1.3",
3002
+ "resolved": "https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz",
3003
+ "integrity": "sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg==",
3004
+ "dev": true
3005
+ },
2994
3006
  "combined-stream": {
2995
3007
  "version": "1.0.8",
2996
3008
  "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
@@ -3433,6 +3445,15 @@
3433
3445
  "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.4.1.tgz",
3434
3446
  "integrity": "sha512-Wrk35e8ydCKDj/ArClo1VrPVmN8zph5V4AtHwIuHhvMXsKf73UT3BOD+azBIW+3wOJ4FhEH7zyaJCFvChjYvMA=="
3435
3447
  },
3448
+ "fancy-log": {
3449
+ "version": "2.0.0",
3450
+ "resolved": "https://registry.npmjs.org/fancy-log/-/fancy-log-2.0.0.tgz",
3451
+ "integrity": "sha512-9CzxZbACXMUXW13tS0tI8XsGGmxWzO2DmYrGuBJOJ8k8q2K7hwfJA5qHjuPPe8wtsco33YR9wc+Rlr5wYFvhSA==",
3452
+ "dev": true,
3453
+ "requires": {
3454
+ "color-support": "^1.1.3"
3455
+ }
3456
+ },
3436
3457
  "fast-glob": {
3437
3458
  "version": "3.3.1",
3438
3459
  "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.1.tgz",
@@ -4725,6 +4746,15 @@
4725
4746
  }
4726
4747
  }
4727
4748
  },
4749
+ "jest-sonar-reporter": {
4750
+ "version": "2.0.0",
4751
+ "resolved": "https://registry.npmjs.org/jest-sonar-reporter/-/jest-sonar-reporter-2.0.0.tgz",
4752
+ "integrity": "sha512-ZervDCgEX5gdUbdtWsjdipLN3bKJwpxbvhkYNXTAYvAckCihobSLr9OT/IuyNIRT1EZMDDwR6DroWtrq+IL64w==",
4753
+ "dev": true,
4754
+ "requires": {
4755
+ "xml": "^1.0.1"
4756
+ }
4757
+ },
4728
4758
  "jest-util": {
4729
4759
  "version": "29.7.0",
4730
4760
  "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.7.0.tgz",
@@ -5119,6 +5149,12 @@
5119
5149
  "tslib": "^2.0.3"
5120
5150
  }
5121
5151
  },
5152
+ "node-downloader-helper": {
5153
+ "version": "2.1.9",
5154
+ "resolved": "https://registry.npmjs.org/node-downloader-helper/-/node-downloader-helper-2.1.9.tgz",
5155
+ "integrity": "sha512-FSvAol2Z8UP191sZtsUZwHIN0eGoGue3uEXGdWIH5228e9KH1YHXT7fN8Oa33UGf+FbqGTQg3sJfrRGzmVCaJA==",
5156
+ "dev": true
5157
+ },
5122
5158
  "node-environment-flags": {
5123
5159
  "version": "1.0.6",
5124
5160
  "resolved": "https://registry.npmjs.org/node-environment-flags/-/node-environment-flags-1.0.6.tgz",
@@ -5797,6 +5833,12 @@
5797
5833
  "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz",
5798
5834
  "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A=="
5799
5835
  },
5836
+ "shell-quote": {
5837
+ "version": "1.8.1",
5838
+ "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.8.1.tgz",
5839
+ "integrity": "sha512-6j1W9l1iAs/4xYBI1SYOVZyFcCis9b4KCLQ8fgAGG07QvzaRLVVRQvAy85yNmmZSjYjg4MWh4gNvlPujU/5LpA==",
5840
+ "dev": true
5841
+ },
5800
5842
  "side-channel": {
5801
5843
  "version": "1.0.4",
5802
5844
  "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz",
@@ -5823,6 +5865,56 @@
5823
5865
  "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz",
5824
5866
  "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q=="
5825
5867
  },
5868
+ "slugify": {
5869
+ "version": "1.6.6",
5870
+ "resolved": "https://registry.npmjs.org/slugify/-/slugify-1.6.6.tgz",
5871
+ "integrity": "sha512-h+z7HKHYXj6wJU+AnS/+IH8Uh9fdcX1Lrhg1/VMdf9PwoBQXFcXiAdsy2tSK0P6gKwJLXp02r90ahUCqHk9rrw==",
5872
+ "dev": true
5873
+ },
5874
+ "sonarqube-scanner": {
5875
+ "version": "3.3.0",
5876
+ "resolved": "https://registry.npmjs.org/sonarqube-scanner/-/sonarqube-scanner-3.3.0.tgz",
5877
+ "integrity": "sha512-G1A6nXT3GwoK5eRwHfFrR/7ThiDfaRefWPIFQ+ifwFOQ/V9OwziLpZBdWZgmZp21kBRnzAMvjcTzgZMqGBXQKA==",
5878
+ "dev": true,
5879
+ "requires": {
5880
+ "adm-zip": "^0.5.10",
5881
+ "fancy-log": "^2.0.0",
5882
+ "https-proxy-agent": "^7.0.1",
5883
+ "jest-sonar-reporter": "^2.0.0",
5884
+ "mkdirp": "^3.0.1",
5885
+ "node-downloader-helper": "^2.1.9",
5886
+ "progress": "^2.0.3",
5887
+ "shell-quote": "^1.8.1",
5888
+ "slugify": "^1.6.6"
5889
+ },
5890
+ "dependencies": {
5891
+ "agent-base": {
5892
+ "version": "7.1.0",
5893
+ "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.0.tgz",
5894
+ "integrity": "sha512-o/zjMZRhJxny7OyEF+Op8X+efiELC7k7yOjMzgfzVqOzXqkBkWI79YoTdOtsuWd5BWhAGAuOY/Xa6xpiaWXiNg==",
5895
+ "dev": true,
5896
+ "requires": {
5897
+ "debug": "^4.3.4"
5898
+ }
5899
+ },
5900
+ "https-proxy-agent": {
5901
+ "version": "7.0.4",
5902
+ "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.4.tgz",
5903
+ "integrity": "sha512-wlwpilI7YdjSkWaQ/7omYBMTliDcmCN8OLihO6I9B86g06lMyAoqgoDpV0XqoaPOKj+0DIdAvnsWfyAAhmimcg==",
5904
+ "dev": true,
5905
+ "requires": {
5906
+ "agent-base": "^7.0.2",
5907
+ "debug": "4"
5908
+ }
5909
+ },
5910
+ "mkdirp": {
5911
+ "version": "3.0.1",
5912
+ "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-3.0.1.tgz",
5913
+ "integrity": "sha512-+NsyUUAZDmo6YVHzL/stxSu3t9YS1iljliy3BSDrXJ/dkn1KYdmtZODGGjLcc9XLgVVpH4KshHB8XmZgMhaBXg==",
5914
+ "dev": true
5915
+ }
5916
+ }
5917
+ },
5826
5918
  "source-map": {
5827
5919
  "version": "0.6.1",
5828
5920
  "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
@@ -6387,6 +6479,12 @@
6387
6479
  "resolved": "https://registry.npmjs.org/ws/-/ws-8.14.2.tgz",
6388
6480
  "integrity": "sha512-wEBG1ftX4jcglPxgFCMJmZ2PLtSbJ2Peg6TmpJFTbe9GZYOQCDPdMYu/Tm0/bGZkw8paZnJY45J4K2PZrLYq8g=="
6389
6481
  },
6482
+ "xml": {
6483
+ "version": "1.0.1",
6484
+ "resolved": "https://registry.npmjs.org/xml/-/xml-1.0.1.tgz",
6485
+ "integrity": "sha512-huCv9IH9Tcf95zuYCsQraZtWnJvBtLVE0QHMOs8bWyZAFZNDcYjsPq1nEx8jKA9y+Beo9v+7OBPRisQTjinQMw==",
6486
+ "dev": true
6487
+ },
6390
6488
  "xml-name-validator": {
6391
6489
  "version": "4.0.0",
6392
6490
  "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-4.0.0.tgz",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/testinglibrary",
3
- "version": "0.1.8-eslint-20",
3
+ "version": "0.1.8-eslint-23",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "scripts": {