@zohodesk/codestandard-validator 1.0.0-exp-8 → 1.0.0-exp-9

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.
@@ -16,10 +16,6 @@ const {
16
16
  const {
17
17
  runLintWorkflow
18
18
  } = require("./lint");
19
- process.env.SONARQUBE_EXTERNAL = 7; // sonarqube_external
20
- process.env.SONARQUBE = 12;
21
- process.env.ZGIT_TOKEN = 12; // sonarqube & zgit
22
-
23
19
  global.analytics = {
24
20
  status: "SUCCESS",
25
21
  sonarQubeStatus: false,
@@ -10,6 +10,9 @@ const path = require("path");
10
10
  const {
11
11
  getNodeModulesPath
12
12
  } = require("../../utils/General/getNodeModulesPath");
13
+ const {
14
+ getRootDirectory
15
+ } = require("../../utils/General/RootDirectoryUtils/getRootDirectory");
13
16
  function getAbsolutePath(p1, p2) {
14
17
  if (path.isAbsolute(p2)) {
15
18
  return path.normalize(p2);
@@ -18,7 +21,7 @@ function getAbsolutePath(p1, p2) {
18
21
  }
19
22
  async function calculateGitDiffForFile(branch, file) {
20
23
  try {
21
- const stdout = execSync(`git diff -U0 ${branch.trim()} -- ${getAbsolutePath(getNodeModulesPath(), file)}`).toString();
24
+ const stdout = execSync(`git diff -U0 ${branch.trim()} -- ${getAbsolutePath(getNodeModulesPath(), path.resolve(getRootDirectory(), file))}`).toString();
22
25
  return stdout;
23
26
  } catch (err) {
24
27
  throw err;
@@ -48,7 +48,6 @@ async function findEslintErrors(file) {
48
48
  const nodeModulesPath = getNodeModulesPath();
49
49
  const eslintPath = getEslintExecutablePath();
50
50
  const eslintConfig = `${nodeModulesPath}/.eslintrc.js`;
51
- var rulesArrayReport = [];
52
51
  if (!fs.existsSync(nodeModulesPath)) {
53
52
  Logger.log(Logger.INFO_TYPE, 'node_modules not found');
54
53
  return [];
@@ -57,7 +56,7 @@ async function findEslintErrors(file) {
57
56
  Logger.log(Logger.INFO_TYPE, 'Eslint executable not found. Make sure eslint plugin is installed');
58
57
  return [];
59
58
  }
60
- return execSync(`npx --ignore-existing "${eslintPath}" --config "${eslintConfig}" --no-inline-config --resolve-plugins-relative-to="${nodeModulesPath}/node_modules" ${file}`).then(({
59
+ return execSync(`npx --ignore-existing "${eslintPath}" --config "${eslintConfig}" --no-inline-config --resolve-plugins-relative-to="${nodeModulesPath}/node_modules" ${path.resolve(getRootDirectory(), file)}`).then(({
61
60
  stderr
62
61
  }) => stderr ? stderr.toString().trim().split('\n') : []).catch(err => {
63
62
  Logger.log(Logger.FAILURE_TYPE, err);
@@ -123,7 +123,7 @@ function findEslintErrors(file) {
123
123
  if (isNodeModulesPresent) {
124
124
  if (isEslintExecutablePresent) {
125
125
  return new Promise((resolve, reject) => {
126
- exec(`npx --ignore-existing "${eslintExecutablePath}" --config "${eslintConfigurationFilePath}" --no-inline-config --resolve-plugins-relative-to="${nodeModulesPathOfProject}/node_modules" ${file}`, (error, stderr, stdout) => {
126
+ exec(`npx --ignore-existing "${eslintExecutablePath}" --config "${eslintConfigurationFilePath}" --no-inline-config --resolve-plugins-relative-to="${nodeModulesPathOfProject}/node_modules" ${path.resolve(getRootDirectory(), file)}`, (error, stderr, stdout) => {
127
127
  if (stderr) {
128
128
  resolve(stderr.trim().split('\n'));
129
129
  } else if (error) {
@@ -156,11 +156,7 @@ function findStyleLintErrors(filePath) {
156
156
  }, (error, stderr, stdout) => {
157
157
  if (stdout) {
158
158
  resolve(stdout.trim().split('\n'));
159
- }
160
- // if(stderr){
161
- // resolve(stderr.trim().split('\n'))
162
- // }
163
- else if (error) {
159
+ } else if (error) {
164
160
  Logger.log(Logger.FAILURE_TYPE, error);
165
161
  reject("Error executing stylelint command");
166
162
  } else {
@@ -181,7 +177,7 @@ function findStyleLintErrors(filePath) {
181
177
  * @returns {Promise<Array<string>>} - array of command line report as a string
182
178
  */
183
179
  async function calculateGitDiffForFile(branch_name, file) {
184
- let gitDiffCommand = `git diff -U0 ${branch_name.trim()} ${file}`;
180
+ let gitDiffCommand = `git diff -U0 ${branch_name.trim()} ${path.resolve(getRootDirectory(), file)}`;
185
181
  return new Promise((resolve, reject) => {
186
182
  exec(gitDiffCommand, (error, stderr) => {
187
183
  if (stderr) {
@@ -9,6 +9,8 @@ const {
9
9
  const {
10
10
  checkIfPluginsAreInstalled
11
11
  } = require("../../utils/PluginsInstallation/checkIfPluginsAreInstalled");
12
+ const fs = require("fs");
13
+ const path = require("path");
12
14
  async function isMergeCommit() {
13
15
  try {
14
16
  const stdout = await execSync("git rev-parse -q --verify MERGE_HEAD").toString();
@@ -21,6 +21,10 @@ const path = require('path');
21
21
  const {
22
22
  Logger
23
23
  } = require('../utils/Logger/Logger');
24
+ const config = require(path.join(process.cwd(), 'lint.config.js'));
25
+ process.env.SONARQUBE_EXTERNAL = config.metric_token;
26
+ process.env.SONARQUBE = config.meticHandler_api_token;
27
+ process.env.ZGIT_TOKEN = config.token;
24
28
  async function hooks() {
25
29
  var jsonFilePath = path.join(__dirname, '..', '..', 'jsonUtils', 'fsUtils.json');
26
30
  if (!(getLastCommitHash() == getStoredCommitHash())) {
package/build/lib/cli.js CHANGED
@@ -18,13 +18,7 @@ const {
18
18
  const {
19
19
  getPluginsToInstall
20
20
  } = require("../utils/PluginsInstallation/checkIfPluginsAreInstalled");
21
- const path = require("path");
22
21
  const [,, action, ...options] = process.argv;
23
- const config = require(path.resolve(process.cwd(), 'lint.config.js'))(function () {
24
- process.env.SONARQUBE_EXTERNAL = config.metric_token;
25
- process.env.SONARQUBE = config.meticHandler_api_token;
26
- process.env.ZGIT_TOKEN = config.token;
27
- })();
28
22
  async function run() {
29
23
  switch (action) {
30
24
  case "setup":
@@ -25,7 +25,7 @@ module.exports = {
25
25
  impactBased: true,
26
26
  lintReportPath: path.resolve(process.cwd(), "lint-report", "lintReport.json"),
27
27
  metricServerHost: "https://client-linters.zdesk.csez.zohocorpin.com",
28
- meticHandler_api_token: "DBWyfB46DBWyfB4dRIN1",
28
+ meticHandler_api_token: "YWRtaW46YWRtaW4yMDI1",
29
29
  metric_token: "sqa_371336f636584b54f662c6495a46228fdc6abaa8",
30
30
  branchDiffPath: path.resolve(process.cwd(), "diffBranch.json"),
31
31
  gitEndPoint: "https://zgit.csez.zohocorpin.com",
@@ -54,7 +54,7 @@ function cloneViaCdt() {
54
54
 
55
55
  // Construct endpoint with credentials if in CI or automation
56
56
  const isAutomatedEnv = currentEnv === "CI" || currentEnv === "DEVAUTOMATION";
57
- const authenticatedEndpoint = isAutomatedEnv ? `https://${user}:${decrypt(token, 12)}@${endPoint}` : `https://${endPoint}`;
57
+ const authenticatedEndpoint = isAutomatedEnv ? `https://${user}:${process.env.ZGIT_TOKEN}@${endPoint}` : `https://${endPoint}`;
58
58
  const cloneCommand = ['npx cdt clone', `--clone:type=${type}`, `--clone:url=${authenticatedEndpoint}`, `--clone:branch=${branch}`, `--clone:cacheDir=${cacheDirectory}`, `--clone:proj:name=${commonLinterRepoName}`].join(' ');
59
59
 
60
60
  // Execute the CDT command
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/codestandard-validator",
3
- "version": "1.0.0-exp-8",
3
+ "version": "1.0.0-exp-9",
4
4
  "description": "library to enforce code standard using eslint",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/hash.js DELETED
@@ -1,30 +0,0 @@
1
- const caesarCipher = (str, shift) => {
2
- return str
3
- .split("")
4
- .map((char) => {
5
- let code = char.charCodeAt();
6
- if (code >= 65 && code <= 90) {
7
- return String.fromCharCode(((code - 65 + shift) % 26) + 65);
8
- } else if (code >= 97 && code <= 122) {
9
- return String.fromCharCode(((code - 97 + shift) % 26) + 97);
10
- }
11
- return char;
12
- })
13
- .join("");
14
- };
15
-
16
- const encrypt = (plaintext, shift) => caesarCipher(plaintext, shift);
17
-
18
- const decrypt = (ciphertext, shift) => caesarCipher(ciphertext, 26 - shift);
19
-
20
-
21
- const encode = (data) => btoa(data)
22
-
23
-
24
- const decode = (encode_data) => atob(encode_data)
25
-
26
- export { encrypt, decrypt,encode ,decode };
27
-
28
- console.log(decrypt("KIDfmI46KIDfmI4kYPU1",7))
29
- console.log(decrypt("zxh_371336m636584i54m662j6495h46228mkj6hihh8",7))
30
- console.log(decrypt("w-OkG3f5OOM1Rkly8phZ",12))