@zohodesk/codestandard-validator 1.1.2 → 1.1.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.
@@ -9,7 +9,6 @@ const {
9
9
  } = require("../../utils/Logger/Logger");
10
10
  const {
11
11
  handleMergeCommit,
12
- ensurePluginsInstalled,
13
12
  safeGetStagedFiles,
14
13
  safeGetBranch
15
14
  } = require("./guard");
@@ -30,10 +29,6 @@ async function preCommitHook() {
30
29
  return;
31
30
  }
32
31
  ;
33
- if (!(await ensurePluginsInstalled())) {
34
- return;
35
- }
36
- ;
37
32
  const stagedFiles = await safeGetStagedFiles();
38
33
  if (stagedFiles.length === 0) {
39
34
  Logger.log(Logger.INFO_TYPE, "No staged files. Commit skipped.");
@@ -21,9 +21,6 @@ async function handleMergeCommit() {
21
21
  }
22
22
  async function ensurePluginsInstalled() {
23
23
  if (areAllPluginsInstalled()) return true;
24
- Logger.log(Logger.FAILURE_TYPE, "Commit failed since some lint plugins are not installed");
25
- Logger.log(Logger.INFO_TYPE, `Run \x1b[37mnpx ZDPrecommit setupPlugins \x1b[33m in the project root to install them.`);
26
- process.exit(1);
27
24
  return false;
28
25
  }
29
26
  async function safeGetStagedFiles() {
@@ -21,6 +21,9 @@ const path = require('path');
21
21
  const {
22
22
  Logger
23
23
  } = require('../utils/Logger/Logger');
24
+ const {
25
+ ensurePluginsInstalled
26
+ } = require('./Precommit/guard');
24
27
  const config = require(path.join(process.cwd(), 'lint.config.js'));
25
28
  process.env.SONARQUBE_EXTERNAL = config.metric_token;
26
29
  process.env.SONARQUBE = config.meticHandler_api_token;
@@ -28,11 +31,15 @@ process.env.ZGIT_TOKEN = config.token;
28
31
  process.env.TOOL_TOKEN = config.toolToken;
29
32
  async function hooks() {
30
33
  var jsonFilePath = path.join(__dirname, '..', '..', 'jsonUtils', 'fsUtils.json');
31
- if (!(getLastCommitHash() == getStoredCommitHash())) {
32
- updateJsonFile(jsonFilePath, data => {
33
- data.commitHash = getLastCommitHash();
34
- return data;
35
- });
34
+ let latestCommit = getLastCommitHash();
35
+ let storedCommit = getStoredCommitHash();
36
+ if (!(latestCommit == storedCommit) || !(await ensurePluginsInstalled())) {
37
+ if (storedCommit != latestCommit) {
38
+ updateJsonFile(jsonFilePath, data => {
39
+ data.commitHash = latestCommit;
40
+ return data;
41
+ });
42
+ }
36
43
  Logger.log(Logger.INFO_TYPE, `Some rules and plugins are being fetched from a remote source and installed...`);
37
44
  await executeMethodsThatReturnBooleanValue('Make sure zgit.csez.zohocorpin.com is accessible', cloneViaCdt, null);
38
45
  const {
@@ -131,5 +131,6 @@ module.exports = {
131
131
  getLastCommitHash,
132
132
  getStoredCommitHash,
133
133
  getJsonUtilsPath,
134
- updateJsonFile
134
+ updateJsonFile,
135
+ getConfigPath
135
136
  };
@@ -14,8 +14,7 @@ const {
14
14
  } = require('../General/getNodeModulesPath');
15
15
  const path = require('path');
16
16
  const {
17
- spawnSync,
18
- spawn
17
+ spawnSync
19
18
  } = require('child_process');
20
19
 
21
20
  /**
package/changeLog.md CHANGED
@@ -1,11 +1,8 @@
1
1
  # Code standard library
2
2
 
3
- # 0.0.0
3
+ # 0.0.0 - Initial Setup
4
4
  1. Testing version of the library
5
5
 
6
- # 0.0.1
7
- 1. This version was mistakenly published without the build folder which will be corrected in the next release
8
-
9
6
  # 0.0.2 - first stable release of the library
10
7
  1. Sets up a custom precommit hook using husky
11
8
  2. clones the common linter configuration repository in developer branch
@@ -40,4 +37,8 @@
40
37
 
41
38
  # 1.1.0 - SonarQube Enable
42
39
 
43
- 1. Enable sonarqube with flag with backward compactibility
40
+ 1. Enable sonarqube with flag with backward compactibility
41
+
42
+ # 1.1.3 - SonarQube Enable
43
+
44
+ 1. Remote Installtion flow moved to before and handled process.exit removed
package/jest.config.js ADDED
@@ -0,0 +1,5 @@
1
+ module.exports = {
2
+ testEnvironment: 'node',
3
+ clearMocks: true,
4
+ setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
5
+ };
package/jest.setup.js ADDED
@@ -0,0 +1 @@
1
+ // Intentionally empty. Tests use local mocks for dependencies like Logger, fs, etc.
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@zohodesk/codestandard-validator",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "library to enforce code standard using eslint",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1",
7
+ "test": "jest",
8
8
  "postinstall": "node bin/postinstall.js",
9
9
  "build": "babel -d ./build ./src --copy-files"
10
10
  },
@@ -15,8 +15,8 @@
15
15
  },
16
16
  "type": "commonjs",
17
17
  "dependencies": {
18
- "@zohodesk/codestandard-analytics": "1.1.4",
19
18
  "@zohodesk-private/client_deployment_tool": "0.0.5",
19
+ "@zohodesk/codestandard-analytics": "1.1.4",
20
20
  "eslint": "8.26.0",
21
21
  "stylelint": "16.23.0"
22
22
  },
@@ -24,6 +24,7 @@
24
24
  "@babel/core": "7.24.7",
25
25
  "@babel/plugin-transform-runtime": "7.24.7",
26
26
  "@babel/preset-env": "7.24.7",
27
- "husky": "7.0.4"
27
+ "husky": "7.0.4",
28
+ "jest": "29.7.0"
28
29
  }
29
30
  }