@zohodesk/codestandard-validator 1.1.1 → 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.
- package/build/hooks/Precommit/commit.js +0 -5
- package/build/hooks/Precommit/guard.js +0 -3
- package/build/hooks/hook.js +12 -5
- package/build/lib/postinstall.js +7 -10
- package/build/utils/CloneCommonLinterRepo/cloneViaCdt.js +0 -7
- package/build/utils/General/getGeneralInfo.js +2 -1
- package/build/utils/PluginsInstallation/installPlugins.js +1 -2
- package/changeLog.md +6 -5
- package/jest.config.js +5 -0
- package/jest.setup.js +1 -0
- package/package.json +5 -4
|
@@ -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() {
|
package/build/hooks/hook.js
CHANGED
|
@@ -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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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 {
|
package/build/lib/postinstall.js
CHANGED
|
@@ -30,17 +30,14 @@ const path = require('path');
|
|
|
30
30
|
* @returns {void}
|
|
31
31
|
*/
|
|
32
32
|
async function postInstall() {
|
|
33
|
+
var actualNodeMoulesPath = path.resolve(process.cwd(), '..', '..', '..');
|
|
34
|
+
const config = require(path.join(actualNodeMoulesPath, 'lint.config.js'));
|
|
35
|
+
process.env.SONARQUBE_EXTERNAL = config.metric_token;
|
|
36
|
+
process.env.SONARQUBE = config.meticHandler_api_token;
|
|
37
|
+
process.env.ZGIT_TOKEN = config.token;
|
|
38
|
+
process.env.TOOL_TOKEN = config.toolToken;
|
|
33
39
|
try {
|
|
34
|
-
await executeMethodsThatReturnBooleanValue('Some issue in writing node_modules path to json', writeFsPaths, null)
|
|
35
|
-
const {
|
|
36
|
-
getNodeModulesPath
|
|
37
|
-
} = require('../utils/General/getNodeModulesPath');
|
|
38
|
-
const config = require(path.join(getNodeModulesPath(), 'lint.config.js'));
|
|
39
|
-
process.env.SONARQUBE_EXTERNAL = config.metric_token;
|
|
40
|
-
process.env.SONARQUBE = config.meticHandler_api_token;
|
|
41
|
-
process.env.ZGIT_TOKEN = config.token;
|
|
42
|
-
process.env.TOOL_TOKEN = config.toolToken;
|
|
43
|
-
});
|
|
40
|
+
await executeMethodsThatReturnBooleanValue('Some issue in writing node_modules path to json', writeFsPaths, null);
|
|
44
41
|
isGitInitialized() ? await executeMethodsThatReturnBooleanValue('Some issue occurred in setting up husky.', setupHusky, null) : null;
|
|
45
42
|
await executeMethodsThatReturnBooleanValue('Make sure zgit.csez.zohocorpin.com is accessible', cloneViaCdt, null);
|
|
46
43
|
await executeMethodsThatReturnBooleanValue('Some issue occurred in creating eslint config file.', createConfigFile, null);
|
|
@@ -17,12 +17,8 @@ const {
|
|
|
17
17
|
executeSynchronizedCommands
|
|
18
18
|
} = require('../General/executeSyncCommands');
|
|
19
19
|
const {
|
|
20
|
-
getConfigurationPrecommit,
|
|
21
20
|
getRunningEnv
|
|
22
21
|
} = require("../General/getGeneralInfo");
|
|
23
|
-
const {
|
|
24
|
-
decrypt
|
|
25
|
-
} = require("../General/Hash");
|
|
26
22
|
const {
|
|
27
23
|
Logger
|
|
28
24
|
} = require("../Logger/Logger");
|
|
@@ -42,9 +38,6 @@ const {
|
|
|
42
38
|
*/
|
|
43
39
|
function cloneViaCdt() {
|
|
44
40
|
try {
|
|
45
|
-
const {
|
|
46
|
-
token
|
|
47
|
-
} = getConfigurationPrecommit();
|
|
48
41
|
const currentEnv = getRunningEnv();
|
|
49
42
|
Logger.log(Logger.INFO_TYPE, `Application is running in the following environment:${currentEnv || "Development"}`);
|
|
50
43
|
|
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
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.
|
|
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": "
|
|
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.3",
|
|
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
|
}
|