@zohodesk/codestandard-validator 0.0.2 → 0.0.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.
@@ -23,7 +23,7 @@ function initializeHusky() {
23
23
  let isNavigationToRootDirectorySuccessful = navigateToRootDirectory(getRootDirectory());
24
24
  if (isNavigationToRootDirectorySuccessful) {
25
25
  try {
26
- execSync('npx husky install');
26
+ execSync('npx husky@7 install');
27
27
  return true;
28
28
  } catch (error) {
29
29
  Logger.log(Logger.FAILURE_TYPE, error.toString());
@@ -1,21 +1,8 @@
1
1
  "use strict";
2
2
 
3
3
  /* eslint-disable no-console */
4
- const {
5
- execSync
6
- } = require('child_process');
7
- const {
8
- readdirSync
9
- } = require('fs');
10
- const path = require('path');
11
4
  const initializeHusky = require('./initializeHusky');
12
5
  const configurePrecommitHook = require('./configurePrecommitHook');
13
- const {
14
- getNodeModulesPath
15
- } = require('../General/getNodeModulesPath');
16
- const {
17
- executeSynchronizedCommands
18
- } = require('../General/executeSyncCommands');
19
6
  const {
20
7
  Logger
21
8
  } = require('../Logger/Logger');
@@ -26,51 +13,21 @@ let isCustomPrecommitConfigurationSuccessful = false;
26
13
  * @returns {boolean} - indicating whether entire custom precommit hook setup using husky process is success or failure
27
14
  */
28
15
  function setupHusky() {
29
- let isHuskyPackageInstalled = installHuskyPackage();
30
- if (isHuskyPackageInstalled) {
31
- let isHuskyInitializedSuccessfully = initializeHusky();
32
- if (isHuskyInitializedSuccessfully) {
33
- Logger.log(Logger.SUCCESS_TYPE, 'Husky installation successful');
34
- isCustomPrecommitConfigurationSuccessful = configurePrecommitHook();
35
- if (isCustomPrecommitConfigurationSuccessful) {
36
- Logger.log(Logger.SUCCESS_TYPE, 'Custom pre commit hook setup was successful');
37
- return true;
38
- } else {
39
- Logger.log(Logger.FAILURE_TYPE, 'Couldn\'t configure custom pre commit hook');
40
- return false;
41
- }
16
+ let isHuskyInitializedSuccessfully = initializeHusky();
17
+ if (isHuskyInitializedSuccessfully) {
18
+ Logger.log(Logger.SUCCESS_TYPE, 'Husky installation successful');
19
+ isCustomPrecommitConfigurationSuccessful = configurePrecommitHook();
20
+ if (isCustomPrecommitConfigurationSuccessful) {
21
+ Logger.log(Logger.SUCCESS_TYPE, 'Custom pre commit hook setup was successful');
22
+ return true;
42
23
  } else {
24
+ Logger.log(Logger.FAILURE_TYPE, 'Couldn\'t configure custom pre commit hook');
43
25
  return false;
44
26
  }
45
27
  } else {
46
- Logger.log(Logger.FAILURE_TYPE, 'Some issue in installing husky package.');
47
28
  return false;
48
29
  }
49
30
  }
50
-
51
- /**
52
- * @function installHuskyPackage - installs husky package if not installed for the project
53
- * @returns {boolean} - indicating if husky package installed successfully or not
54
- */
55
- function installHuskyPackage() {
56
- const nodeModulesPathOfProject = path.join(getNodeModulesPath(), 'node_modules');
57
- let pluginsInNodeModules = executeSynchronizedCommands(readdirSync, [nodeModulesPathOfProject], '', 'Unable to get directories in node_modules when checking if husky is installed', true, false);
58
- let husky = {
59
- packageName: 'husky',
60
- version: '^7.0.4'
61
- };
62
- let isHuskyInstalled = pluginsInNodeModules.includes(husky.packageName) ? true : false;
63
- if (!isHuskyInstalled) {
64
- Logger.log(Logger.INFO_TYPE, 'Installing husky package ....');
65
- let installCommand = `npm install ${husky.packageName}@${husky.version} --save-dev`;
66
- let isHuskyPackageInstalled = executeSynchronizedCommands(execSync, [installCommand, {
67
- stdio: 'inherit'
68
- }], 'Husky package Installed Successfully', 'Unable to install husky package', false, true);
69
- return isHuskyPackageInstalled;
70
- }
71
- Logger.log(Logger.SUCCESS_TYPE, 'Husky package already installed!');
72
- return true;
73
- }
74
31
  module.exports = {
75
32
  setupHusky
76
33
  };
package/changeLog.md CHANGED
@@ -10,4 +10,7 @@
10
10
  1. Sets up a custom precommit hook using husky
11
11
  2. clones the common linter configuration repository in developer branch
12
12
  3. Based on the cloned configuration folder creates a eslint config file
13
- 4. Checks for eslint rule violations in the staged files(Impact based) and aborts/allows commit accordingly
13
+ 4. Checks for eslint rule violations in the staged files(Impact based) and aborts/allows commit accordingly
14
+
15
+ # 0.0.3 - modifications in usage of Husky package
16
+ 1. The husky package is not installed and the required huksy package version is temporarily downloaded from npm registry and used
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/codestandard-validator",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "library to enforce code standard using eslint",
5
5
  "main": "index.js",
6
6
  "scripts": {