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

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.
@@ -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());
@@ -4,22 +4,17 @@
4
4
  const {
5
5
  execSync
6
6
  } = require('child_process');
7
- const {
8
- readdirSync,
9
- readFileSync
10
- } = require('fs');
11
- const path = require('path');
12
7
  const initializeHusky = require('./initializeHusky');
13
8
  const configurePrecommitHook = require('./configurePrecommitHook');
14
- const {
15
- getNodeModulesPath
16
- } = require('../General/getNodeModulesPath');
17
9
  const {
18
10
  executeSynchronizedCommands
19
11
  } = require('../General/executeSyncCommands');
20
12
  const {
21
13
  Logger
22
14
  } = require('../Logger/Logger');
15
+ const {
16
+ getRootDirectory
17
+ } = require('../General/RootDirectoryUtils/getRootDirectory');
23
18
  let isCustomPrecommitConfigurationSuccessful = false;
24
19
 
25
20
  /**
@@ -54,16 +49,25 @@ function setupHusky() {
54
49
  * @returns {boolean} - indicating if husky package installed successfully or not
55
50
  */
56
51
  function installHuskyPackage() {
52
+ // checking globally so removed
53
+ // const nodeModulesPathOfProject = path.join(getNodeModulesPath(),'node_modules')
54
+ // let pluginsInNodeModules = executeSynchronizedCommands(readdirSync,[nodeModulesPathOfProject],'','Unable to get directories in node_modules when checking if husky is installed',true,false)
57
55
  let husky = {
58
56
  packageName: 'husky',
59
- version: '9.1.5'
57
+ version: '7.0.4'
60
58
  };
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)) {
59
+
60
+ // let isHuskyInstalled = pluginsInNodeModules.includes(husky.packageName) ? true : false
61
+ try {
62
+ const huskyVersion = execSync("husky -v", {
63
+ cwd: getRootDirectory()
64
+ }).toString();
65
+ if (!(huskyVersion.trim() == husky.version)) {
66
+ throw new Error("error");
67
+ }
68
+ } catch {
65
69
  Logger.log(Logger.INFO_TYPE, 'Installing husky package ....');
66
- let installCommand = `npm install ${husky.packageName}@${husky.version} --save-dev --save-exact`;
70
+ let installCommand = `npm install ${husky.packageName}@${husky.version} --save-dev --save-exact -g`;
67
71
  let isHuskyPackageInstalled = executeSynchronizedCommands(execSync, [installCommand, {
68
72
  stdio: 'inherit'
69
73
  }], 'Husky package Installed Successfully', 'Unable to install husky package', false, true);
@@ -72,12 +76,6 @@ function installHuskyPackage() {
72
76
  Logger.log(Logger.SUCCESS_TYPE, 'Husky package already installed!');
73
77
  return true;
74
78
  }
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
79
  module.exports = {
82
80
  setupHusky
83
81
  };
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-4",
4
4
  "description": "library to enforce code standard using eslint",
5
5
  "main": "index.js",
6
6
  "scripts": {