@zohodesk/testinglibrary 0.1.8-eslint-4 → 0.1.8-eslint-7

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,133 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.getDiffFiles = getDiffFiles;
8
+ exports.runEslintForDiff = runEslintForDiff;
9
+ var _getFilePath = require("../utils/getFilePath");
10
+ var _child_process = require("child_process");
11
+ var _path = _interopRequireDefault(require("path"));
12
+ var _logger = require("../utils/logger");
13
+ 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
+
39
+ function runEslintForDiff(cliParams, options = {}) {
40
+ // $(git diff --name-only HEAD HEAD~1 | grep -E '\.(js|jsx)$' | xargs)
41
+ const {
42
+ diffPath
43
+ } = (0, _cliArgsToObject.cliArgsToObject)(cliParams);
44
+ const format = 'json';
45
+ const reportPath = _path.default.resolve(process.cwd(), 'uat', 'eslint-report', 'lintReport.json');
46
+ const diffJSON = require(_path.default.resolve(diffPath));
47
+ const filteredDiffFiles = getDiffFiles(diffJSON);
48
+ const lintFiles = filteredDiffFiles.length === 0 ? [_path.default.resolve(process.cwd(), 'uat', 'modules')] : filteredDiffFiles;
49
+ return 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);
52
+ resolve(stdout);
53
+ });
54
+ }).then(response => {
55
+ (0, _fs.writeFileSync)(reportPath, filterReport_JSON(require(reportPath), diffJSON));
56
+ });
57
+ }
58
+ function filterReport_JSON(resultJson, diffJson) {
59
+ const impactLineArray = filterDiffJson(diffJson);
60
+ resultJson = resultJson.filter(result => {
61
+ var _impactLineArray$get;
62
+ if (((_impactLineArray$get = impactLineArray.get(getPathFromTestDir(result.filePath))) === null || _impactLineArray$get === void 0 ? void 0 : _impactLineArray$get.length) !== 0) {
63
+ result.messages = result.messages.filter(errorMsg => {
64
+ if (impactLineArray.get(getPathFromTestDir(result.filePath)).includes(errorMsg.line)) {
65
+ return true;
66
+ }
67
+ return false;
68
+ });
69
+ return true;
70
+ }
71
+ return false;
72
+ });
73
+ return JSON.stringify(resultJson);
74
+ }
75
+ function getImpactsLine() {
76
+ const diffJson = _path.default.resolve(process.cwd(), 'diffContents.json');
77
+ return filterDiffJson(diffJson);
78
+ }
79
+ function filterDiffJson(diffJson) {
80
+ var _diffJson$diffs;
81
+ const diffFilesMap = new Map();
82
+ diffJson === null || diffJson === void 0 || (_diffJson$diffs = diffJson.diffs) === null || _diffJson$diffs === void 0 || _diffJson$diffs.forEach(diff => {
83
+ const diffMatch = [];
84
+ const regex = /@@(.*?)@@/g;
85
+ let match;
86
+ while ((match = regex.exec(diff.diff)) !== null) {
87
+ diffMatch.push(...splitFilterNumber(match[1]));
88
+ }
89
+ const diffPathKey = getPathFromTestDir(diff.new_path);
90
+ if (diffPathKey) {
91
+ diffFilesMap.set(diffPathKey, diffMatch);
92
+ }
93
+ });
94
+ return diffFilesMap;
95
+ }
96
+ function getPathFromTestDir(diffPath) {
97
+ if (!(diffPath !== null && diffPath !== void 0 && diffPath.contains('uat'))) {
98
+ return undefined;
99
+ }
100
+ const indexOfDiff = diffPath.split('/').indexOf('uat');
101
+ const diffActualPath = diffPath.slice(indexOfDiff).join('/');
102
+ return diffActualPath;
103
+ }
104
+ function splitFilterNumber(numberString) {
105
+ var resultedNum = [];
106
+ numberString.split(' ').join(',').split(',').filter(element => {
107
+ if (element.startsWith('-')) {
108
+ resultedNum.push(element.replace('-', ' ').trim());
109
+ // return element.replace('-', ' ').trim();
110
+ return true;
111
+ }
112
+ if (element.startsWith('+')) {
113
+ resultedNum.push(element.replace('+', ' ').trim());
114
+ return true;
115
+ }
116
+ return false;
117
+ });
118
+ return resultedNum;
119
+ }
120
+ function getDiffFiles(diffJson) {
121
+ return diffJson === null || diffJson === void 0 ? void 0 : diffJson.diffs.map(diff => {
122
+ return diff === null || diff === void 0 ? void 0 : diff.new_path;
123
+ });
124
+ }
125
+ function validateReport() {
126
+ if (1) {} else {
127
+ throw new Error('Report Failed');
128
+ process.exit(1);
129
+ }
130
+ }
131
+ function parseJsonReport() {
132
+ const parsejson = _path.default.resolve(process.cwd(), 'uat', 'eslint-report', 'lintReport.json');
133
+ }
@@ -0,0 +1,39 @@
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()
@@ -0,0 +1,39 @@
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
+ function getDefaultServerProperties() {
12
+ return {
13
+ 'sonar.projectName': 'UAT_Testing',
14
+ 'sonar..login': "developer",
15
+ 'sonar.password': "developer",
16
+ 'sonar.sources': '',
17
+ 'sonar.tests': `${_path.default.resolve(process.cwd(), 'uat', 'modules')}`,
18
+ 'sonar.language': 'js',
19
+ 'sonar.eslint.reportPaths': `${_path.default.resolve(process.cwd(), 'uat', 'eslint-report', 'lintReport.json')}`,
20
+ 'sonar.working.directory': `${_path.default.resolve(process.cwd(), 'uat', 'modules', '.scannerwork')}`
21
+ };
22
+ }
23
+ function getProperties(cliParams, login, password, sources, testDir, language, eslintReportPath, serverArtifactsDir) {
24
+ const {
25
+ repo,
26
+ branch,
27
+ username
28
+ } = (0, _cliArgsToObject.cliArgsToObject)(cliParams);
29
+ return {
30
+ 'sonar.projectName': `${repo}_${branch}_${username}`,
31
+ 'sonar.login': login,
32
+ 'sonar.password': password,
33
+ 'sonar.sources': sources,
34
+ 'sonar.tests': testDir,
35
+ 'sonar.language': language,
36
+ 'sonar.eslint.reportPaths': eslintReportPath,
37
+ 'sonar.working.directory': serverArtifactsDir
38
+ };
39
+ }
@@ -0,0 +1,30 @@
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
+ }
package/build/lib/cli.js CHANGED
@@ -9,11 +9,10 @@ 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 _pipelineLintStage = require("../integrateEslintReport/pipelineLintStage");
13
- var _EslintSonarQube_Integrate = require("../integrateEslintReport/Eslint-sonarQube_Integrate");
12
+ var _eslintLintStage = require("../eslint-ci/eslintLintStage");
13
+ var _startSeverSonarQube = require("../eslint-ci/startSever-sonarQube");
14
14
  // import createJestRunner from '../core/jest/runner/jest-runner';
15
15
 
16
- _pipelineLintStage.runEslintForDiff;
17
16
  const [,, option, ...otherOptions] = process.argv;
18
17
  // const args = process.argv.slice(3);
19
18
  // const appPath = process.cwd();
@@ -60,8 +59,10 @@ switch (option) {
60
59
  case 'lint-ci':
61
60
  {
62
61
  _logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Linting Started ...');
63
- (0, _pipelineLintStage.runEslintForDiff)();
64
- (0, _EslintSonarQube_Integrate.sonarQubeIntegrateAnalysis)();
62
+ (0, _eslintLintStage.runEslintForDiff)(otherOptions).then(result => {
63
+ (0, _startSeverSonarQube.sonarQubeIntegrateAnalysis)(otherOptions);
64
+ });
65
+ break;
65
66
  }
66
67
  case 'help':
67
68
  default:
@@ -14,7 +14,10 @@ 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 dirpathtoIgnore = `/${testResultsRelativepath}\n/${reportRelativepath}\n/${featuregenRelativePath}\n/${scannerWorkPath}`
18
21
 
19
22
  function updateGitIgnore() {
20
23
  if (existsSync(path.resolve(process.cwd(), '../', '../', '.gitignore'))) {
package/lintjson.json ADDED
@@ -0,0 +1,105 @@
1
+ [
2
+ {
3
+ "filePath": "/Users/raja-17710/deskApp/desk_client_app/jsapps/supportapp/uat/modules/Setup/page-object-model/SetupHomePage.js",
4
+ "messages": [
5
+ {
6
+ "ruleId": "playwright/no-raw-locators",
7
+ "severity": 1,
8
+ "message": "Usage of raw locator detected. Use methods like .getByRole() or .getByText() instead of raw locators.",
9
+ "line": 18,
10
+ "column": 21,
11
+ "nodeType": "CallExpression",
12
+ "messageId": "noRawLocator",
13
+ "endLine": 18,
14
+ "endColumn": 76
15
+ },
16
+ {
17
+ "ruleId": "playwright/no-raw-locators",
18
+ "severity": 1,
19
+ "message": "Usage of raw locator detected. Use methods like .getByRole() or .getByText() instead of raw locators.",
20
+ "line": 31,
21
+ "column": 18,
22
+ "nodeType": "CallExpression",
23
+ "messageId": "noRawLocator",
24
+ "endLine": 31,
25
+ "endColumn": 52
26
+ },
27
+ {
28
+ "ruleId": "playwright/no-raw-locators",
29
+ "severity": 1,
30
+ "message": "Usage of raw locator detected. Use methods like .getByRole() or .getByText() instead of raw locators.",
31
+ "line": 35,
32
+ "column": 12,
33
+ "nodeType": "CallExpression",
34
+ "messageId": "noRawLocator",
35
+ "endLine": 35,
36
+ "endColumn": 65
37
+ },
38
+ {
39
+ "ruleId": "playwright/no-raw-locators",
40
+ "severity": 1,
41
+ "message": "Usage of raw locator detected. Use methods like .getByRole() or .getByText() instead of raw locators.",
42
+ "line": 52,
43
+ "column": 11,
44
+ "nodeType": "CallExpression",
45
+ "messageId": "noRawLocator",
46
+ "endLine": 52,
47
+ "endColumn": 40
48
+ }
49
+ ],
50
+ "errorCount": 0,
51
+ "fatalErrorCount": 0,
52
+ "warningCount": 4,
53
+ "fixableErrorCount": 0,
54
+ "fixableWarningCount": 0,
55
+ "source": "import { expect } from '@zohodesk/testinglibrary';\nimport {\n SETUP_HOME_PAGE_SELECTORS,\n SETUP_MENUPANEL_SELECTORS,\n getSetupModuleSelector,\n hiddenModuleName\n} from '../dom-selectors/SetupSelectors';\n\nconst moduleConst = {\n HELP_CENTER: 'HelpCenter',\n DEFALUT_LANDING_PAGE: 'Email'\n};\n\nclass SetupHomePage {\n constructor(page) {\n this.page = page;\n this.defaultMenu = moduleConst.DEFALUT_LANDING_PAGE;\n this.homePage = page.locator(SETUP_HOME_PAGE_SELECTORS.SETUP_HOME_PAGE);\n }\n\n getHomePageSearchInput() {\n return this.homePage.getByPlaceholder(\n SETUP_MENUPANEL_SELECTORS.MENU_PANEL_SEARCH_PLACE_HOLDER\n );\n }\n\n async visitSetupHomePage() {\n const { SETUP_ICON_LABEL, SETUP_HOME_PAGE } = SETUP_HOME_PAGE_SELECTORS;\n await this.page.goto(process.env.domain);\n await this.page.getByLabel(SETUP_ICON_LABEL).click();\n await expect(this.page.locator(SETUP_HOME_PAGE)).toBeVisible();\n }\n\n getModule(moduleName) {\n return this.page.locator(getSetupModuleSelector(moduleName));\n }\n\n async selectModule(moduleTobeSelected = this.defaultMenu) {\n await this.homePage.getByRole('link', { name: moduleTobeSelected }).click();\n }\n\n async searchHomePage(inputText) {\n await this.getHomePageSearchInput().fill(inputText);\n }\n\n async hoverModule(module) {\n await this.homePage.getByText(module).hover();\n }\n\n async getandAccessHiddenElement(module) {\n const moduleName = hiddenModuleName(module);\n await this.page.locator(moduleName).click();\n }\n\n async clickHighlightedMenu(menuName) {\n await this.page\n .getByRole('listitem')\n .filter({ hasText: menuName })\n .first()\n .click();\n }\n}\n\nexport default SetupHomePage;\n",
56
+ "usedDeprecatedRules": [
57
+ {
58
+ "ruleId": "lines-around-directive",
59
+ "replacedBy": ["padding-line-between-statements"]
60
+ },
61
+ { "ruleId": "global-require", "replacedBy": [] },
62
+ { "ruleId": "no-buffer-constructor", "replacedBy": [] },
63
+ { "ruleId": "no-new-require", "replacedBy": [] },
64
+ { "ruleId": "no-path-concat", "replacedBy": [] }
65
+ ]
66
+ },
67
+ {
68
+ "filePath": "/Users/raja-17710/deskApp/desk_client_app/jsapps/supportapp/uat/modules/Setup/steps/SearchClear.spec.js",
69
+ "messages": [],
70
+ "errorCount": 0,
71
+ "fatalErrorCount": 0,
72
+ "warningCount": 0,
73
+ "fixableErrorCount": 0,
74
+ "fixableWarningCount": 0,
75
+ "usedDeprecatedRules": [
76
+ {
77
+ "ruleId": "lines-around-directive",
78
+ "replacedBy": ["padding-line-between-statements"]
79
+ },
80
+ { "ruleId": "global-require", "replacedBy": [] },
81
+ { "ruleId": "no-buffer-constructor", "replacedBy": [] },
82
+ { "ruleId": "no-new-require", "replacedBy": [] },
83
+ { "ruleId": "no-path-concat", "replacedBy": [] }
84
+ ]
85
+ },
86
+ {
87
+ "filePath": "/Users/raja-17710/deskApp/desk_client_app/jsapps/supportapp/uat/modules/Setup/steps/SetupHomePageSearch.spec.js",
88
+ "messages": [],
89
+ "errorCount": 0,
90
+ "fatalErrorCount": 0,
91
+ "warningCount": 0,
92
+ "fixableErrorCount": 0,
93
+ "fixableWarningCount": 0,
94
+ "usedDeprecatedRules": [
95
+ {
96
+ "ruleId": "lines-around-directive",
97
+ "replacedBy": ["padding-line-between-statements"]
98
+ },
99
+ { "ruleId": "global-require", "replacedBy": [] },
100
+ { "ruleId": "no-buffer-constructor", "replacedBy": [] },
101
+ { "ruleId": "no-new-require", "replacedBy": [] },
102
+ { "ruleId": "no-path-concat", "replacedBy": [] }
103
+ ]
104
+ }
105
+ ]
package/main.js ADDED
@@ -0,0 +1,61 @@
1
+ const path = require('path');
2
+ function filterDiffJson(diffJson) {
3
+ let matches = [];
4
+ // console.log(diffJson);
5
+ diffJson?.diffs?.forEach(diffCode => {
6
+ const diffMatch = [];
7
+ const regex = /@@(.*?)@@/g;
8
+ let match;
9
+ while ((match = regex.exec(diffCode.diff)) !== null) {
10
+ diffMatch.push(numParse(match[1]));
11
+ }
12
+ matches.push({
13
+ pathFile: diffCode.new_path,
14
+ diff: diffMatch
15
+ });
16
+ });
17
+ return matches;
18
+ }
19
+
20
+ function numParse(numberParse) {
21
+ var resultedNum = [];
22
+ numberParse
23
+ .split(' ')
24
+ .join(',')
25
+ .split(',')
26
+ .filter(element => {
27
+ if (element.startsWith('-')) {
28
+ resultedNum.push(element.replace('-', ' ').trim());
29
+ // return element.replace('-', ' ').trim();
30
+ return true;
31
+ }
32
+
33
+ if (element.startsWith('+')) {
34
+ resultedNum.push(element.replace('+', ' ').trim());
35
+ return true;
36
+ }
37
+ return false;
38
+ });
39
+ return resultedNum;
40
+ }
41
+
42
+ function getDiffFiles(diffJson) {
43
+ return diffJson?.diffs.map(diff => {
44
+ return diff?.new_path;
45
+ });
46
+ }
47
+
48
+ const checkAry = [18, 31];
49
+
50
+ function validateDiff() {
51
+ const diffJson = require(path.resolve(process.cwd(), 'lintjson.json'));
52
+ diffJson.map(diff => {
53
+ diff.messages = diff.messages.filter(msg => {
54
+ if (checkAry.includes(msg.line)) {
55
+ return true;
56
+ }
57
+ return false;
58
+ });
59
+ });
60
+ }
61
+ validateDiff();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/testinglibrary",
3
- "version": "0.1.8-eslint-4",
3
+ "version": "0.1.8-eslint-7",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "scripts": {
@@ -1,27 +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
- const postCallBack = () => process.exit();
12
- const serverHostUrl = 'https://serverlinter-np.zohodesk.csez.zohocorpin.com';
13
- const options = {
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
- };
22
- function sonarQubeIntegrateAnalysis() {
23
- (0, _sonarqubeScanner.default)({
24
- serverUrl: serverHostUrl,
25
- options: options
26
- }, postCallBack);
27
- }
@@ -1,41 +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.runEslintForDiff = runEslintForDiff;
8
- var _getFilePath = require("../utils/getFilePath");
9
- var _child_process = require("child_process");
10
- var _path = _interopRequireDefault(require("path"));
11
- var _logger = require("../utils/logger");
12
- function gitDiffFiles() {
13
- const childProcess = (0, _child_process.spawnSync)('git', ['diff', 'HEAD', 'HEAD~1', '--name-only']);
14
- const diff_Files = childProcess.stdout.toString().split('\n').filter(Boolean);
15
- var actualDiff_Files = diff_Files.map(filePath => {
16
- var fileName = _path.default.basename(filePath);
17
- if (filePath.includes('/page-object-model/') || filePath.includes('/assertions/')) {
18
- return _path.default.resolve(process.cwd(), '../', '../', filePath);
19
- }
20
- if (fileName.includes('.spec.js')) {
21
- return _path.default.resolve(process.cwd(), '../', '../', filePath);
22
- }
23
- return false;
24
- });
25
- return actualDiff_Files;
26
- }
27
- function runEslintForDiff() {
28
- // $(git diff --name-only HEAD HEAD~1 | grep -E '\.(js|jsx)$' | xargs)
29
- const format = 'json';
30
- const reportPath = _path.default.resolve(process.cwd(), 'uat', 'eslint-report', 'lintReport.json');
31
- return new Promise(resolve => {
32
- (0, _child_process.exec)(`npx eslint ${getLintFiles()} --format=${format} -o ${reportPath}`, (stdout, stderr) => {
33
- _logger.Logger.log(_logger.Logger.FAILURE_TYPE, stderr);
34
- resolve(stdout);
35
- });
36
- });
37
- }
38
- function getLintFiles() {
39
- var _gitDiffFiles;
40
- return ((_gitDiffFiles = gitDiffFiles()) === null || _gitDiffFiles === void 0 ? void 0 : _gitDiffFiles.join(' ')) || _path.default.resolve(process.cwd(), 'uat', 'modules');
41
- }