@zohodesk/codestandard-validator 0.0.6 → 0.0.7-exp-2

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.
@@ -8,13 +8,14 @@ const path = require("path");
8
8
  * @property {boolean} impactBased - Indicates if the linting is impact-based.
9
9
  * @property {string} lintReportPath - The path to the lint report JSON file.
10
10
  * @property {string} metricServerHost - The URL of the SonarQube server.
11
- * @property {string} meticHandler_api_token - The token for authentication with the SonarQube server.
12
- * @property {string} metric_token - The token for authentication with the SonarQube server.
11
+ * @property {string} meticHandler_api_token - The token to authenticate sonarQube apis.
12
+ * @property {string} metric_token - The token to authenticate sonarQube.
13
13
  * @property {string} gitEndPoint - API EndPoint for Git Actions
14
14
  * @property {string} tsConfigurationPath - The path of the ts configuration Path
15
15
  * @property {number} projectId - project id of repository
16
16
  * @property {boolean} impactBasedPrecommit - Indicates if the linting is impact-based in pre commit
17
17
  * @property {boolean} shouldWarningsAbortCommit - Indicates if eslint warnings should abort the commit
18
+ * @property {string} pushMetricsOnPreCommit - Indicates to push metrics to sonarQube or not
18
19
  * @property {string} token - Encrypted Authentication Token
19
20
  * @property {string} compareBranch - Branch to compare diff
20
21
  */
@@ -23,15 +24,16 @@ module.exports = {
23
24
  ruleConfigurationPath: path.resolve(process.cwd(), ".eslintrc.js"),
24
25
  impactBased: true,
25
26
  lintReportPath: path.resolve(process.cwd(), "lint-report", "lintReport.json"),
26
- metricServerHost: "https://client-linters.zohodesk.csez.zohocorpin.com",
27
- meticHandler_api_token: "oyRcKJZxm2RkXytfAzVtmyRlLIftou5anC==",
28
- metric_token: "zxh_9737850jh2l53ml17223929ihii73072j54j2260",
27
+ metricServerHost: "https://client-linters.zdesk.csez.zohocorpin.com",
28
+ meticHandler_api_token: "KIDfmI46KIDfmI4kYPU1",
29
+ metric_token: "zxh_371336m636584i54m662j6495h46228mkj6hihh8",
29
30
  branchDiffPath: path.resolve(process.cwd(), "diffBranch.json"),
30
31
  gitEndPoint: "https://zgit.csez.zohocorpin.com",
31
32
  tsConfigurationPath: path.resolve(process.cwd(), 'tsconfig.json'),
32
33
  projectId: `project-id`,
33
34
  impactBasedPrecommit: true,
34
35
  shouldWarningsAbortCommit: false,
36
+ pushMetricsOnPreCommit: true,
35
37
  token: "w-OkG3f5OOM1Rkly8phZ",
36
38
  compareBranch: 'release',
37
39
  supportedExtensions: ['.js', '.jsx', '.ts', '.tsx', '.properties']
@@ -49,9 +49,9 @@ function cloneViaCdt() {
49
49
  const runningEnv = getRunningEnv();
50
50
  if (runningEnv === "CI" || runningEnv === "DEVAUTOMATION") {
51
51
  Logger.log(Logger.INFO_TYPE, `Running in ${runningEnv}`);
52
- absoluteEndPoint = `https://${userName}:${decrypt(token, 12)}@${endPoint}`;
52
+ absoluteEndPoint = `https://${userName}:${decrypt(token, process.env.DECRYPT_TOKEN || 12)}@${endPoint}`;
53
53
  }
54
- var commandToCloneCommonConfigRepo = `npx cdt clone --clone:type=${type} --clone:url=${absoluteEndPoint} --clone:branch=${branch} --clone:cacheDir=${cacheDirectory} --clone:proj:name=${commonLinterRepoName}`;
54
+ var commandToCloneCommonConfigRepo = `npx cdt clone --clone:type=${type} --clone:url=${absoluteEndPoint} --clone:branch=${process.env.CONFIGURATION_BRANCH || branch} --clone:cacheDir=${cacheDirectory} --clone:proj:name=${commonLinterRepoName}`;
55
55
  let isCommonConfigurationClonedSuccessfully = executeSynchronizedCommands(execSync, [commandToCloneCommonConfigRepo, {
56
56
  cwd: getClonedDirPath()
57
57
  }], `Lint Configuration Cloned Successfully - ${getRepoName() || 'common'}`, 'Could not clone the linters common repo', false, true);
@@ -14,11 +14,11 @@ function arePluginsInstalled() {
14
14
  uninstalledPlugins,
15
15
  noPluginMessage
16
16
  } = checkIfPluginsAreInstalled();
17
- let areAllPluginsInstalled = uninstalledPlugins.length === 0 ? true : false;
18
- if (!areAllPluginsInstalled) {
19
- installPlugins(uninstalledPlugins);
20
- }
21
- // printUninstalledPlugins(uninstalledPlugins,noPluginMessage)
17
+ // let areAllPluginsInstalled = uninstalledPlugins.length === 0 ? true : false
18
+ // if(!areAllPluginsInstalled){
19
+ // installPlugins(uninstalledPlugins)
20
+ // }
21
+ printUninstalledPlugins(uninstalledPlugins, noPluginMessage);
22
22
  }
23
23
  module.exports = {
24
24
  arePluginsInstalled
@@ -1,22 +1,17 @@
1
1
  "use strict";
2
2
 
3
3
  const {
4
- readdirSync,
5
4
  existsSync
6
5
  } = require('fs');
7
6
  const path = require('path');
8
- const {
9
- getNodeModulesPath
10
- } = require('../General/getNodeModulesPath');
7
+ // const { getNodeModulesPath } = require('../General/getNodeModulesPath')
11
8
  const {
12
9
  Logger
13
10
  } = require('../Logger/Logger');
14
11
  const {
15
12
  getLibraryInstalledLocation
16
13
  } = require('../General/getLibraryInstalledLocation');
17
- const {
18
- executeSynchronizedCommands
19
- } = require('../General/executeSyncCommands');
14
+ // const { executeSynchronizedCommands } = require('../General/executeSyncCommands')
20
15
  const {
21
16
  endPoint,
22
17
  commonLinterRepoName
@@ -27,32 +22,35 @@ const {
27
22
  const {
28
23
  getServicePathElseCommon
29
24
  } = require('../EslintConfigFileUtils/getLintConfiguration');
30
- function getUnInstalledPlugins(pluginsForCurrentRepo, pluginNamesOfDevDependencyPlugins, devDependencies) {
31
- let pluginsInNodeModules = executeSynchronizedCommands(readdirSync, [path.join(getNodeModulesPath(), 'node_modules')], '', 'Unable to get the plugins inside node_modules', true, false);
32
- let pluginsToBeInstalled = [];
33
- pluginsForCurrentRepo.filter(plugin => {
34
- if (plugin.packageName.startsWith('@')) {
35
- let scope = plugin.packageName.split('/')[0];
36
- let pluginName = plugin.packageName.split('/')[1];
37
- let scopedPlugins = executeSynchronizedCommands(readdirSync, [path.join(getNodeModulesPath(), 'node_modules', scope)], '', 'Unable to get the plugins inside the scope inside node_modules', true, false);
38
- let isPluginInstalled = scopedPlugins.includes(pluginName) ? true : false;
39
- if (!isPluginInstalled) {
40
- pluginsToBeInstalled.push(`${plugin.packageName}@${plugin.version}`);
41
- }
42
- } else {
43
- let isPluginInstalled = pluginsInNodeModules.includes(plugin.packageName) ? true : false;
44
- if (!isPluginInstalled) {
45
- pluginsToBeInstalled.push(`${plugin.packageName}@${plugin.version}`);
46
- }
47
- }
48
- if (pluginNamesOfDevDependencyPlugins.includes(plugin.packageName)) {
49
- if (plugin.version !== devDependencies[plugin.packageName]) {
50
- pluginsToBeInstalled.push(`${plugin.packageName}@${plugin.version}`);
51
- }
52
- }
53
- });
54
- return pluginsToBeInstalled;
55
- }
25
+
26
+ // function getUnInstalledPlugins(pluginsForCurrentRepo,pluginNamesOfDevDependencyPlugins,devDependencies){
27
+ // let pluginsInNodeModules = executeSynchronizedCommands(readdirSync,[path.join(getNodeModulesPath(),'node_modules')],'','Unable to get the plugins inside node_modules',true,false)
28
+ // let pluginsToBeInstalled = []
29
+ // pluginsForCurrentRepo.filter(plugin => {
30
+ // if(plugin.packageName.startsWith('@')){
31
+ // let scope = plugin.packageName.split('/')[0]
32
+ // let pluginName = plugin.packageName.split('/')[1]
33
+ // let scopedPlugins = executeSynchronizedCommands(readdirSync,[path.join(getNodeModulesPath(),'node_modules',scope)],'','Unable to get the plugins inside the scope inside node_modules',true,false)
34
+ // let isPluginInstalled = scopedPlugins.includes(pluginName) ? true : false
35
+ // if(!isPluginInstalled){
36
+ // pluginsToBeInstalled.push(`${plugin.packageName}@${plugin.version}`)
37
+ // }
38
+ // }
39
+ // else{
40
+ // let isPluginInstalled = pluginsInNodeModules.includes(plugin.packageName) ? true : false
41
+ // if(!isPluginInstalled){
42
+ // pluginsToBeInstalled.push(`${plugin.packageName}@${plugin.version}`)
43
+ // }
44
+ // }
45
+ // if(pluginNamesOfDevDependencyPlugins.includes(plugin.packageName)){
46
+ // if(plugin.version !== devDependencies[plugin.packageName]){
47
+ // pluginsToBeInstalled.push(`${plugin.packageName}@${plugin.version}`)
48
+ // }
49
+ // }
50
+ // })
51
+ // return pluginsToBeInstalled
52
+ // }
53
+
56
54
  function getAllPlugins() {
57
55
  let serviceSpecificPlugins = [];
58
56
  const pathToCommonPluginsFile = path.join(getLibraryInstalledLocation(), commonLinterRepoName, 'common', 'pluginVersion.js');
@@ -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,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/codestandard-validator",
3
- "version": "0.0.6",
3
+ "version": "0.0.7-exp-2",
4
4
  "description": "library to enforce code standard using eslint",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,42 +0,0 @@
1
- "use strict";
2
-
3
- const path = require('path');
4
- const {
5
- existsSync
6
- } = require('fs');
7
-
8
- // this file code implementation will be removed a
9
-
10
- function filterStagedFilesError(files) {
11
- // first index pop for file name
12
- if ((files === null || files === void 0 ? void 0 : files.length) == 0) {
13
- return [];
14
- }
15
- const fileName = files[0];
16
- if (existsSync(fileName)) {
17
- if (fileName.includes('uat')) {
18
- return [...filterByErrorMessage(files, 'Do not hardcode content. Use I18N key instead'), ...files.slice(files.length - 2)];
19
- }
20
- if (fileName.includes('src')) {
21
- return [...filterByErrorMessage(files, 'playwright'), ...files.slice(files.length - 2)];
22
- }
23
- }
24
- }
25
- function filterByErrorMessage(files, errorMessage) {
26
- return files.filter(fileContent => {
27
- if (errorMessage == 'Do not hardcode content. Use I18N key instead' && fileContent.includes('warning')) {
28
- return false;
29
- }
30
- if (fileContent.includes(errorMessage)) {
31
- return false;
32
- }
33
- return true;
34
- });
35
- }
36
- function allowedFiles(file) {
37
- return file.includes('uat') || file.includes('jsapps/supportapp/src') && !file.includes('jsapps/supportapp/src/__testsutils__/') && !file.includes('jsapps/supportapp/src/_actions/') && !file.includes('jsapps/supportapp/src/_doubts/') && !file.includes('jsapps/supportapp/src/_integration/') && !file.includes('jsapps/supportapp/src/_middleware/') && !file.includes('jsapps/supportapp/src/_pubSub/') && !file.includes('jsapps/supportapp/src/_reducers/') && !file.includes('jsapps/supportapp/src/_selectors/') && !file.includes('jsapps/supportapp/src/_store/') && !file.includes('jsapps/supportapp/src/_url/') && !file.includes('jsapps/supportapp/src/_utils/') && !file.includes('.docs.js') && !file.includes('.spec.js') && !file.includes('.specs.js') && !file.includes('.test.js');
38
- }
39
- module.exports = {
40
- filterStagedFilesError,
41
- allowedFiles
42
- };