@zohodesk/codestandard-validator 0.0.2-exp-2 → 0.0.2-exp-3

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.
@@ -31,12 +31,12 @@ const {
31
31
  */
32
32
  async function postInstall() {
33
33
  try {
34
- await executeMethodsThatReturnBooleanValue("Some issue in writing node_modules path to json", writeFsPaths, null);
34
+ // await executeMethodsThatReturnBooleanValue("Some issue in writing node_modules path to json", writeFsPaths, null);
35
35
  isGitInitialized() ? await executeMethodsThatReturnBooleanValue("Some issue occurred in setting up husky.", setupHusky, null) : null;
36
- await executeMethodsThatReturnBooleanValue("Make sure zgit.csez.zohocorpin.com is accessible", cloneViaCdt, null);
37
- await executeMethodsThatReturnBooleanValue("Some issue occurred in creating eslint config file.", createEslintConfigFile, null);
38
- Logger.log(Logger.SUCCESS_TYPE, "Pre commit setup successful");
39
- arePluginsInstalled();
36
+ // await executeMethodsThatReturnBooleanValue("Make sure zgit.csez.zohocorpin.com is accessible", cloneViaCdt, null);
37
+ // await executeMethodsThatReturnBooleanValue("Some issue occurred in creating eslint config file.", createEslintConfigFile, null);
38
+ // Logger.log(Logger.SUCCESS_TYPE, "Pre commit setup successful");
39
+ // arePluginsInstalled();
40
40
  } catch (error) {
41
41
  Logger.log(Logger.FAILURE_TYPE, `Kindly retry npm install. & ${error.message}`);
42
42
  }
@@ -23,7 +23,7 @@ function initializeHusky() {
23
23
  let isNavigationToRootDirectorySuccessful = navigateToRootDirectory(getRootDirectory());
24
24
  if (isNavigationToRootDirectorySuccessful) {
25
25
  try {
26
- execSync('npx husky init');
26
+ execSync('npx husky install');
27
27
  return true;
28
28
  } catch (error) {
29
29
  Logger.log(Logger.FAILURE_TYPE, error.toString());
@@ -5,8 +5,7 @@ const {
5
5
  execSync
6
6
  } = require('child_process');
7
7
  const {
8
- readdirSync,
9
- readFileSync
8
+ readdirSync
10
9
  } = require('fs');
11
10
  const path = require('path');
12
11
  const initializeHusky = require('./initializeHusky');
@@ -20,6 +19,9 @@ const {
20
19
  const {
21
20
  Logger
22
21
  } = require('../Logger/Logger');
22
+ const {
23
+ getRootDirectory
24
+ } = require('../General/RootDirectoryUtils/getRootDirectory');
23
25
  let isCustomPrecommitConfigurationSuccessful = false;
24
26
 
25
27
  /**
@@ -54,16 +56,25 @@ function setupHusky() {
54
56
  * @returns {boolean} - indicating if husky package installed successfully or not
55
57
  */
56
58
  function installHuskyPackage() {
59
+ // checking globally so removed
60
+ // const nodeModulesPathOfProject = path.join(getNodeModulesPath(),'node_modules')
61
+ // let pluginsInNodeModules = executeSynchronizedCommands(readdirSync,[nodeModulesPathOfProject],'','Unable to get directories in node_modules when checking if husky is installed',true,false)
57
62
  let husky = {
58
63
  packageName: 'husky',
59
- version: '9.1.5'
64
+ version: '7.0.4'
60
65
  };
61
- const nodeModulesPathOfProject = path.join(getNodeModulesPath(), 'node_modules');
62
- let pluginsInNodeModules = executeSynchronizedCommands(readdirSync, [nodeModulesPathOfProject], '', 'Unable to get directories in node_modules when checking if husky is installed', true, false);
63
- let isHuskyInstalled = pluginsInNodeModules.includes(husky.packageName) ? true : false;
64
- if (!isHuskyInstalled && checkPackageVersion(husky)) {
66
+
67
+ // let isHuskyInstalled = pluginsInNodeModules.includes(husky.packageName) ? true : false
68
+ try {
69
+ const huskyVersion = execSync("husky -v", {
70
+ cwd: getRootDirectory()
71
+ }).toString();
72
+ if (huskyVersion.trim() == husky.version) {
73
+ throw new Error("error");
74
+ }
75
+ } catch {
65
76
  Logger.log(Logger.INFO_TYPE, 'Installing husky package ....');
66
- let installCommand = `npm install ${husky.packageName}@${husky.version} --save-dev --save-exact`;
77
+ let installCommand = `npm install ${husky.packageName}@${husky.version} --save-dev --save-exact -g`;
67
78
  let isHuskyPackageInstalled = executeSynchronizedCommands(execSync, [installCommand, {
68
79
  stdio: 'inherit'
69
80
  }], 'Husky package Installed Successfully', 'Unable to install husky package', false, true);
@@ -72,12 +83,6 @@ function installHuskyPackage() {
72
83
  Logger.log(Logger.SUCCESS_TYPE, 'Husky package already installed!');
73
84
  return true;
74
85
  }
75
- function checkPackageVersion(npmPackage) {
76
- const {
77
- devDependencies
78
- } = JSON.parse(readFileSync(path.resolve(getNodeModulesPath(), 'package.json')));
79
- return devDependencies[npmPackage.packageName] == npmPackage.version ? true : false;
80
- }
81
86
  module.exports = {
82
87
  setupHusky
83
88
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/codestandard-validator",
3
- "version": "0.0.2-exp-2",
3
+ "version": "0.0.2-exp-3",
4
4
  "description": "library to enforce code standard using eslint",
5
5
  "main": "index.js",
6
6
  "scripts": {