@zohodesk/codestandard-validator 0.0.6-exp-9 → 0.0.6-exp-11
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/lib/cli.js
CHANGED
|
@@ -13,14 +13,19 @@ const {
|
|
|
13
13
|
installEslintExtension
|
|
14
14
|
} = require("../utils/ExtensionInstallation/installEslintExtension");
|
|
15
15
|
const {
|
|
16
|
-
|
|
17
|
-
} = require("../
|
|
16
|
+
default: validateRemotePackages
|
|
17
|
+
} = require("../hooks/Precommit/pre-commit");
|
|
18
|
+
const {
|
|
19
|
+
Logger
|
|
20
|
+
} = require("../utils/Logger/Logger");
|
|
18
21
|
const [,, action, ...options] = process.argv;
|
|
22
|
+
const path = require("path");
|
|
19
23
|
async function run() {
|
|
20
24
|
switch (action) {
|
|
21
25
|
case "setup":
|
|
22
26
|
{
|
|
23
|
-
|
|
27
|
+
process.chdir(path.resolve(__dirname, '..', '..'));
|
|
28
|
+
require("./postinstall");
|
|
24
29
|
break;
|
|
25
30
|
}
|
|
26
31
|
case "init":
|
|
@@ -30,7 +35,7 @@ async function run() {
|
|
|
30
35
|
}
|
|
31
36
|
case "setupPlugins":
|
|
32
37
|
{
|
|
33
|
-
|
|
38
|
+
validateRemotePackages();
|
|
34
39
|
break;
|
|
35
40
|
}
|
|
36
41
|
case "setupExtension":
|
|
@@ -40,6 +45,7 @@ async function run() {
|
|
|
40
45
|
}
|
|
41
46
|
default:
|
|
42
47
|
{
|
|
48
|
+
Logger.log(Logger.FAILURE_TYPE, `oops! command not supported :( ...`);
|
|
43
49
|
break;
|
|
44
50
|
}
|
|
45
51
|
}
|
|
@@ -6,6 +6,13 @@ const fs = require("fs");
|
|
|
6
6
|
const {
|
|
7
7
|
execSync
|
|
8
8
|
} = require('child_process');
|
|
9
|
+
const {
|
|
10
|
+
Logger
|
|
11
|
+
} = require('../Logger/Logger');
|
|
12
|
+
const {
|
|
13
|
+
readOnlyToken,
|
|
14
|
+
commitHashEndPoint
|
|
15
|
+
} = require('../../../jsonUtils/commonLinterRepoDetails');
|
|
9
16
|
|
|
10
17
|
/**
|
|
11
18
|
* @function getTimeStampInfo - to fetch various timestamp details
|
|
@@ -60,21 +67,55 @@ function getSupportedLanguage() {
|
|
|
60
67
|
const _language = supportedExtensions;
|
|
61
68
|
return _language;
|
|
62
69
|
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @function getRunningEnv - Retrieves the current running environment by executing the `npm config get lint_env` command.
|
|
73
|
+
* @returns {string} The current lint environment value set in the npm config.
|
|
74
|
+
*/
|
|
75
|
+
|
|
63
76
|
function getRunningEnv() {
|
|
64
77
|
const command = "npm config get lint_env";
|
|
65
78
|
return execSync(command, {
|
|
66
79
|
shell: true
|
|
67
80
|
}).toString().trim();
|
|
68
81
|
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @function getLastCommitHash - Fetches the last commit hash from a GitLab project using its API.
|
|
85
|
+
*
|
|
86
|
+
* @note This function assumes access to a specific GitLab instance and a hardcoded token and project ID.
|
|
87
|
+
* @returns {string} The latest commit hash (SHA) from the specified GitLab repository.
|
|
88
|
+
* @throws {Error} Will throw an error if the API request fails or returns unexpected data.
|
|
89
|
+
*/
|
|
90
|
+
|
|
69
91
|
function getLastCommitHash() {
|
|
70
|
-
|
|
71
|
-
|
|
92
|
+
try {
|
|
93
|
+
const cmd = `curl --header "PRIVATE-TOKEN: ${readOnlyToken}" --url ${commitHashEndPoint}`;
|
|
94
|
+
return JSON.parse(execSync(cmd))[0]["id"];
|
|
95
|
+
} catch (err) {
|
|
96
|
+
Logger.log(Logger.FAILURE_TYPE, err);
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
72
99
|
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* @function getRequiredInfoPath - Returns the absolute path to the `fsUtils.json` file located in the `jsonUtils` directory at the project root.
|
|
103
|
+
* @returns {string} The full path to the `fsUtils.json` file.
|
|
104
|
+
*/
|
|
105
|
+
|
|
73
106
|
function getRequiredInfoPath() {
|
|
74
107
|
return path.join(process.cwd(), 'jsonUtils', 'fsUtils.json');
|
|
75
108
|
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* @function getStoredCommitHash - Loads and returns the stored commit hash from `fsUtils.json`.
|
|
112
|
+
* @returns {string} The commit hash stored in the `fsUtils.json` file.
|
|
113
|
+
* @throws {Error} Will throw if the file does not exist or does not contain a `commitHash` key.
|
|
114
|
+
*/
|
|
115
|
+
|
|
76
116
|
function getStoredCommitHash() {
|
|
77
|
-
|
|
117
|
+
const commitInfoPath = path.join(__dirname, '..', '..', '..', 'jsonUtils', 'fsUtils.json');
|
|
118
|
+
return fs.existsSync(commitInfoPath) && require(commitInfoPath).commitHash;
|
|
78
119
|
}
|
|
79
120
|
module.exports = {
|
|
80
121
|
getSupportedLanguage,
|
|
@@ -14,5 +14,10 @@ module.exports = {
|
|
|
14
14
|
cacheDirectory: "./",
|
|
15
15
|
commonLinterRepoName: "configuration",
|
|
16
16
|
type: "git",
|
|
17
|
-
user:"rajasekar.hm"
|
|
18
|
-
|
|
17
|
+
user:"rajasekar.hm",
|
|
18
|
+
commitHashEndPoint:"https://zgit.csez.zohocorpin.com/api/v4/projects/19251/repository/commits",
|
|
19
|
+
readOnlyToken:"k-CyU3t5CCA1Fyzm8dvN"
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
package/package.json
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zohodesk/codestandard-validator",
|
|
3
|
-
"version": "0.0.6-exp-
|
|
3
|
+
"version": "0.0.6-exp-11",
|
|
4
4
|
"description": "library to enforce code standard using eslint",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
|
-
"postinstall": "node bin/postinstall.js",
|
|
9
8
|
"build": "babel -d ./build ./src --copy-files"
|
|
10
9
|
},
|
|
11
10
|
"author": "",
|