@zohodesk/codestandard-validator 0.0.2-exp-13 → 0.0.2-exp-15
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/postinstall.js
CHANGED
|
@@ -31,8 +31,8 @@ const {
|
|
|
31
31
|
*/
|
|
32
32
|
async function postInstall() {
|
|
33
33
|
try {
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
await executeMethodsThatReturnBooleanValue("Some issue in writing node_modules path to json", writeFsPaths, null);
|
|
35
|
+
isGitInitialized() ? await executeMethodsThatReturnBooleanValue("Some issue occurred in setting up husky.", setupHusky, null) : null;
|
|
36
36
|
await executeMethodsThatReturnBooleanValue("Make sure zgit.csez.zohocorpin.com is accessible", cloneViaCdt, null);
|
|
37
37
|
await executeMethodsThatReturnBooleanValue("Some issue occurred in creating eslint config file.", createEslintConfigFile, null);
|
|
38
38
|
Logger.log(Logger.SUCCESS_TYPE, "Pre commit setup successful");
|
|
@@ -21,24 +21,34 @@ var {
|
|
|
21
21
|
endPoint,
|
|
22
22
|
branch,
|
|
23
23
|
cacheDirectory,
|
|
24
|
-
commonLinterRepoName
|
|
24
|
+
commonLinterRepoName,
|
|
25
|
+
user
|
|
25
26
|
} = require('../../../jsonUtils/commonLinterRepoDetails');
|
|
26
27
|
const {
|
|
27
|
-
|
|
28
|
+
getConfigurationPrecommit,
|
|
29
|
+
getRunningEnv
|
|
28
30
|
} = require("../General/getGeneralInfo");
|
|
31
|
+
const {
|
|
32
|
+
decrypt
|
|
33
|
+
} = require("../General/Hash");
|
|
34
|
+
const {
|
|
35
|
+
Logger
|
|
36
|
+
} = require("../Logger/Logger");
|
|
29
37
|
/**
|
|
30
38
|
* @function cloneViaCdt - Using the "clint development tool" clones the common linter_configuration repo into precommit library
|
|
31
39
|
* @returns {boolean} - indicating the success or failure of the cloning process
|
|
32
40
|
*/
|
|
33
41
|
|
|
34
42
|
function cloneViaCdt() {
|
|
43
|
+
const {
|
|
44
|
+
token
|
|
45
|
+
} = getConfigurationPrecommit();
|
|
35
46
|
removeFolder(getDeleteDirPath());
|
|
36
|
-
const
|
|
37
|
-
const userName = cliArgs.lintUsername || undefined;
|
|
38
|
-
const token = cliArgs.lintToken || undefined;
|
|
47
|
+
const userName = user;
|
|
39
48
|
var absoluteEndPoint = `https://${endPoint}`;
|
|
40
|
-
if (
|
|
41
|
-
|
|
49
|
+
if (getRunningEnv() === "CI") {
|
|
50
|
+
Logger.log(Logger.INFO_TYPE, `Running in CI`);
|
|
51
|
+
absoluteEndPoint = `https://${userName}:${decrypt(token, 12)}@${endPoint}`;
|
|
42
52
|
}
|
|
43
53
|
var commandToCloneCommonConfigRepo = `npx cdt clone --clone:type=${type} --clone:url=${absoluteEndPoint} --clone:branch=${branch} --clone:cacheDir=${cacheDirectory} --clone:proj:name=${commonLinterRepoName}`;
|
|
44
54
|
let isCommonConfigurationClonedSuccessfully = executeSynchronizedCommands(execSync, [commandToCloneCommonConfigRepo, {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.encrypt = exports.decrypt = void 0;
|
|
7
|
+
const caesarCipher = (str, shift) => {
|
|
8
|
+
return str.split("").map(char => {
|
|
9
|
+
let code = char.charCodeAt();
|
|
10
|
+
if (code >= 65 && code <= 90) {
|
|
11
|
+
return String.fromCharCode((code - 65 + shift) % 26 + 65);
|
|
12
|
+
} else if (code >= 97 && code <= 122) {
|
|
13
|
+
return String.fromCharCode((code - 97 + shift) % 26 + 97);
|
|
14
|
+
}
|
|
15
|
+
return char;
|
|
16
|
+
}).join("");
|
|
17
|
+
};
|
|
18
|
+
const encrypt = (plaintext, shift) => caesarCipher(plaintext, shift);
|
|
19
|
+
exports.encrypt = encrypt;
|
|
20
|
+
const decrypt = (ciphertext, shift) => caesarCipher(ciphertext, 26 - shift);
|
|
21
|
+
exports.decrypt = decrypt;
|
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
const os = require('os');
|
|
4
4
|
const path = require('path');
|
|
5
5
|
const fs = require("fs");
|
|
6
|
+
const {
|
|
7
|
+
execSync
|
|
8
|
+
} = require('child_process');
|
|
6
9
|
|
|
7
10
|
/**
|
|
8
11
|
* @function getTimeStampInfo - to fetch various timestamp details
|
|
@@ -58,33 +61,16 @@ function getSupportedLanguage() {
|
|
|
58
61
|
_language.push('.tsx');
|
|
59
62
|
return _language;
|
|
60
63
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
* @returns {Object}
|
|
67
|
-
*/
|
|
68
|
-
function cliArgsToObject(cliArgs, isKeyNeedToBeAdded = null) {
|
|
69
|
-
const processEnv = {};
|
|
70
|
-
cliArgs.forEach(option => {
|
|
71
|
-
if (/^--./.test(option)) {
|
|
72
|
-
const equIndex = option.indexOf('=');
|
|
73
|
-
let key = option.slice(2, equIndex);
|
|
74
|
-
let value = option.slice(equIndex + 1);
|
|
75
|
-
if (equIndex === -1) {
|
|
76
|
-
key = option.slice(2);
|
|
77
|
-
value = true;
|
|
78
|
-
}
|
|
79
|
-
processEnv[key] = value;
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
return processEnv;
|
|
64
|
+
function getRunningEnv() {
|
|
65
|
+
const command = "npm config get lint_env";
|
|
66
|
+
return execSync(command, {
|
|
67
|
+
shell: true
|
|
68
|
+
}).toString().trim();
|
|
83
69
|
}
|
|
84
70
|
module.exports = {
|
|
85
71
|
getSupportedLanguage,
|
|
86
72
|
getTimeStampInfo,
|
|
87
73
|
getEnv,
|
|
88
74
|
getConfigurationPrecommit,
|
|
89
|
-
|
|
75
|
+
getRunningEnv
|
|
90
76
|
};
|