@zohodesk/codestandard-validator 1.0.0-exp-4 → 1.0.0-exp-6

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.
@@ -37,9 +37,7 @@ const {
37
37
  const {
38
38
  Logger
39
39
  } = require('../../utils/Logger/Logger');
40
- const {
41
- default: fetchProjectIssuesViaCurl
42
- } = require('../../utils/General/SonarQubeUtil');
40
+ // const { default: fetchProjectIssuesViaCurl } = require('../../utils/General/SonarQubeUtil');
43
41
  const execAsync = promisify(exec);
44
42
  async function lintFiles(filePath) {
45
43
  const ext = path.extname(filePath);
@@ -108,15 +106,11 @@ async function runLintWorkflow(files, branch) {
108
106
  await execute.executeLintHandler().finally(async () => {
109
107
  await execute.executeMetricHandler();
110
108
  /**
111
- * global.analytics.totalIssues = global.analytics.totalIssues + 1;
109
+ * global.analytics.totalIssues = global.analytics.totalIssues + 1;
112
110
  global.analytics.status = "FAILURE";
113
111
  global.analytics.message = 'Issues are detected, please review and resolve the errors'
114
112
  */
115
- const {
116
- issues,
117
- hasIssue,
118
- totalIssues
119
- } = fetchProjectIssuesViaCurl("projectName");
113
+ // const { issues, hasIssue, totalIssues } = fetchProjectIssuesViaCurl("projectName");
120
114
  });
121
115
  Logger.log(Logger.INFO_TYPE, global.analytics);
122
116
  return global.analytics.status == 'FAILURE' ? true : false;
@@ -6,7 +6,13 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _Logger = require("../Logger/Logger");
8
8
  var _getGeneralInfo = require("./getGeneralInfo");
9
- var _child_process = require("child_process");
9
+ const {
10
+ exec
11
+ } = require('child_process');
12
+ const {
13
+ promisify
14
+ } = require('util');
15
+ const execAsync = promisify(exec);
10
16
  /**
11
17
  * Constructs a URL for searching issues in SonarQube.
12
18
  *
@@ -72,14 +78,13 @@ function extractIssues(json) {
72
78
  * - {Array} issues: An array of extracted issues, or an empty array if an error occurred.
73
79
  */
74
80
 
75
- function fetchProjectIssuesViaCurl(componentKey) {
81
+ async function fetchProjectIssuesViaCurl(componentKey) {
76
82
  _Logger.Logger.log(_Logger.Logger.INFO_TYPE, `\n Fetching issues (curl) for component: ${componentKey}`);
77
83
  const url = buildIssuesSearchUrl(componentKey);
78
84
  try {
79
85
  const token = 'sqa_1f6675c05f63c4784dc741ce751efa0066d2693c' || decrypt(getAPIToken(), process.env.DECRYPT_TOKEN);
80
86
  const command = `curl --tlsv1.2 -s -u "${token}:" "${url}"`;
81
- console.log("command", command);
82
- const output = (0, _child_process.execSync)(command).toString();
87
+ const output = await execAsync(command).toString();
83
88
  const json = JSON.parse(output);
84
89
  const {
85
90
  issues,
@@ -104,5 +109,4 @@ function fetchProjectIssuesViaCurl(componentKey) {
104
109
  };
105
110
  }
106
111
  }
107
- console.log(fetchProjectIssuesViaCurl('zohogc_client_master_rajasekar.hm_Dev-report'));
108
112
  var _default = exports.default = fetchProjectIssuesViaCurl;
@@ -2,9 +2,6 @@
2
2
 
3
3
  /* eslint-disable no-console */
4
4
 
5
- const {
6
- execSync
7
- } = require('child_process');
8
5
  const {
9
6
  navigateToRootDirectory
10
7
  } = require('../General/RootDirectoryUtils/navigateToRootDirectory');
@@ -14,16 +11,23 @@ const {
14
11
  const {
15
12
  Logger
16
13
  } = require('../Logger/Logger');
14
+ const {
15
+ exec
16
+ } = require('child_process');
17
+ const {
18
+ promisify
19
+ } = require('util');
20
+ const execAsync = promisify(exec);
17
21
 
18
22
  /**
19
23
  * @function initializeHusky - creates a .husky folder at the root of the project with the husky execution script file
20
24
  * @returns {boolean} - indicating the success or failure of initializing husky process
21
25
  */
22
- function initializeHusky() {
26
+ async function initializeHusky() {
23
27
  let isNavigationToRootDirectorySuccessful = navigateToRootDirectory(getRootDirectory());
24
28
  if (isNavigationToRootDirectorySuccessful) {
25
29
  try {
26
- execSync('npx husky@7 install');
30
+ await execAsync('npx husky@7 install');
27
31
  return true;
28
32
  } catch (error) {
29
33
  Logger.log(Logger.FAILURE_TYPE, error.toString());
@@ -22,5 +22,8 @@ class LoggerImpl {
22
22
  const color = this.colors[type];
23
23
  this.consoleLogger.log(`${color[0]}${message}${color[1]}`);
24
24
  }
25
+ logger(message) {
26
+ this.consoleLogger.log(message);
27
+ }
25
28
  }
26
29
  module.exports.Logger = new LoggerImpl();
@@ -1,8 +1,5 @@
1
1
  "use strict";
2
2
 
3
- const {
4
- execSync
5
- } = require('child_process');
6
3
  const {
7
4
  writeFileSync
8
5
  } = require('fs');
@@ -16,26 +13,42 @@ const {
16
13
  getNodeModulesPath
17
14
  } = require('../General/getNodeModulesPath');
18
15
  const path = require('path');
16
+ const {
17
+ exec
18
+ } = require('child_process');
19
+ const {
20
+ promisify
21
+ } = require('util');
22
+ const execAsync = promisify(exec);
19
23
 
20
24
  /**
21
25
  * @function installPlugins - installs uninstalled plugins for the project
22
26
  * @returns {boolean} - indicating if plugins to be installed are installed successfully or not
23
27
  */
24
- function installPlugins(pluginsToBeInstalled) {
28
+ async function installPlugins(pluginsToBeInstalled) {
25
29
  if (pluginsToBeInstalled.length > 0) {
26
30
  let packageJsonBeforePluginsInstallation = getPackageJsonContentBeforeInstallingPlugins();
27
31
  Logger.log(Logger.INFO_TYPE, 'Installing plugins ....');
28
32
  const installCommand = `npm install --save-dev ${pluginsToBeInstalled.join(' ')} --legacy-peer-deps`;
29
33
  Logger.log(Logger.INFO_TYPE, `Install command being executed: ${installCommand}`);
30
- let arePluginsInstalledSuccessfully = executeSynchronizedCommands(execSync, [installCommand, {
31
- stdio: 'inherit',
32
- cwd: getNodeModulesPath()
33
- }], '', 'Some issue occured while installing plugins', false, true);
34
- if (arePluginsInstalledSuccessfully) {
34
+ try {
35
+ let {
36
+ stdout,
37
+ stderr
38
+ } = await execAsync(installCommand, {
39
+ cwd: getNodeModulesPath(),
40
+ shell: true
41
+ });
42
+ if (stdout) {
43
+ Logger.logger(stdout);
44
+ } else if (stderr) {
45
+ Logger.logger(stderr);
46
+ }
35
47
  Logger.log(Logger.SUCCESS_TYPE, 'Plugins installation successful');
36
48
  return restorePackageJsonContent(packageJsonBeforePluginsInstallation);
37
- } else {
49
+ } catch (error) {
38
50
  Logger.log(Logger.FAILURE_TYPE, "Unable to install plugins. Kindly retry the command");
51
+ Logger.log(Logger.FAILURE_TYPE, error);
39
52
  return false;
40
53
  }
41
54
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/codestandard-validator",
3
- "version": "1.0.0-exp-4",
3
+ "version": "1.0.0-exp-6",
4
4
  "description": "library to enforce code standard using eslint",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -15,7 +15,7 @@
15
15
  },
16
16
  "type": "commonjs",
17
17
  "dependencies": {
18
- "@zohodesk/codestandard-analytics": "1.0.2-exp-3",
18
+ "@zohodesk/codestandard-analytics": "1.0.2-exp-6",
19
19
  "@zohodesk-private/client_deployment_tool": "0.0.5",
20
20
  "eslint": "8.26.0",
21
21
  "stylelint": "16.23.0"