@zohodesk/codestandard-validator 0.0.7-exp-10 → 0.0.7-exp-12

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.
@@ -253,8 +253,10 @@ async function preCommitHook() {
253
253
  // Logger.log(Logger.SUCCESS_TYPE,`Commit Successful`)
254
254
  // process.exit(0)
255
255
  // }
256
+
257
+ // CssFiles not Enabled For while
256
258
  areFilesStaged = true;
257
- var stagedFiles = [...staged_filesJS, ...CssFiles];
259
+ var stagedFiles = [...staged_filesJS];
258
260
  for (let file in stagedFiles) {
259
261
  let currentFileName = stagedFiles[file];
260
262
  let changedLinesArray = [];
@@ -2,7 +2,8 @@
2
2
 
3
3
  const {
4
4
  getLastCommitHash,
5
- getStoredCommitHash
5
+ getStoredCommitHash,
6
+ updateJsonFile
6
7
  } = require("../utils/General/getGeneralInfo");
7
8
  const {
8
9
  executeMethodsThatReturnBooleanValue
@@ -11,17 +12,22 @@ const {
11
12
  cloneViaCdt
12
13
  } = require("../utils/CloneCommonLinterRepo/cloneViaCdt");
13
14
  const {
14
- checkIfPluginsAreInstalled
15
+ getPluginsToInstall
15
16
  } = require("../utils/PluginsInstallation/checkIfPluginsAreInstalled");
16
17
  const {
17
18
  installPlugins
18
19
  } = require("../utils/PluginsInstallation/installPlugins");
19
20
  async function hooks() {
21
+ var jsonFilePath = path.join(__dirname, '..', '..', 'jsonUtils', 'fsUtils.json');
20
22
  if (!(getLastCommitHash() == getStoredCommitHash())) {
23
+ updateJsonFile(jsonFilePath, data => {
24
+ data.commitHash = getLastCommitHash();
25
+ return data;
26
+ });
21
27
  await executeMethodsThatReturnBooleanValue("Make sure zgit.csez.zohocorpin.com is accessible", cloneViaCdt, null);
22
28
  const {
23
29
  uninstalledPlugins
24
- } = checkIfPluginsAreInstalled();
30
+ } = getPluginsToInstall();
25
31
  await executeMethodsThatReturnBooleanValue("Some issue occurred in installing plugins", installPlugins, uninstalledPlugins);
26
32
  }
27
33
  require('./Precommit/pre-commit');
package/build/lib/cli.js CHANGED
@@ -16,7 +16,7 @@ const {
16
16
  installPlugins
17
17
  } = require("../utils/PluginsInstallation/installPlugins");
18
18
  const {
19
- checkIfPluginsAreInstalled
19
+ getPluginsToInstall
20
20
  } = require("../utils/PluginsInstallation/checkIfPluginsAreInstalled");
21
21
  const [,, action, ...options] = process.argv;
22
22
  async function run() {
@@ -35,7 +35,7 @@ async function run() {
35
35
  {
36
36
  const {
37
37
  uninstalledPlugins
38
- } = checkIfPluginsAreInstalled();
38
+ } = getPluginsToInstall();
39
39
  await executeMethodsThatReturnBooleanValue("Some issue occurred in installing plugins", installPlugins, uninstalledPlugins);
40
40
  break;
41
41
  }
@@ -10,6 +10,9 @@ const {
10
10
  readOnlyToken,
11
11
  commitHashEndPoint
12
12
  } = require('../../../jsonUtils/commonLinterRepoDetails');
13
+ const {
14
+ Logger
15
+ } = require('../Logger/Logger');
13
16
 
14
17
  /**
15
18
  * @function getTimeStampInfo - to fetch various timestamp details
@@ -103,9 +106,23 @@ function getLastCommitHash() {
103
106
  */
104
107
 
105
108
  function getStoredCommitHash() {
106
- const commitInfoPath = path.join(__dirname, '..', '..', '..', 'jsonUtils', 'fsUtils.json');
109
+ const commitInfoPath = getJsonUtilsPath();
107
110
  return fs.existsSync(commitInfoPath) && require(commitInfoPath).commitHash;
108
111
  }
112
+ function getJsonUtilsPath() {
113
+ return path.join(__dirname, '..', '..', '..', 'jsonUtils', 'fsUtils.json');
114
+ }
115
+ function updateJsonFile(filePath, modifier) {
116
+ try {
117
+ const absolutePath = path.resolve(filePath);
118
+ const rawData = fs.readFileSync(absolutePath, "utf-8");
119
+ const jsonData = JSON.parse(rawData);
120
+ const updatedData = modifier(jsonData);
121
+ fs.writeFileSync(absolutePath, JSON.stringify(updatedData, null, 2), "utf-8");
122
+ } catch (error) {
123
+ Logger.log(Logger.FAILURE_TYPE, "Error updating JSON file");
124
+ }
125
+ }
109
126
  module.exports = {
110
127
  getSupportedLanguage,
111
128
  getTimeStampInfo,
@@ -113,5 +130,7 @@ module.exports = {
113
130
  getConfigurationPrecommit,
114
131
  getRunningEnv,
115
132
  getLastCommitHash,
116
- getStoredCommitHash
133
+ getStoredCommitHash,
134
+ getJsonUtilsPath,
135
+ updateJsonFile
117
136
  };
@@ -1,13 +1,16 @@
1
1
  "use strict";
2
2
 
3
3
  const path = require('path');
4
+ const {
5
+ getJsonUtilsPath
6
+ } = require('./getGeneralInfo');
4
7
 
5
8
  /**
6
9
  * @function getNodeModulesPath - fetches the absolute path where node_modules of project is present
7
10
  * @returns {string} - path where node_modules of the project is present
8
11
  */
9
12
  function getNodeModulesPath() {
10
- return require(path.join(__dirname, '..', '..', '..', 'jsonUtils', 'fsUtils.json')).nodeModulesPath;
13
+ return require(getJsonUtilsPath()).nodeModulesPath;
11
14
  }
12
15
  module.exports = {
13
16
  getNodeModulesPath
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  const {
4
- checkIfPluginsAreInstalled
4
+ getPluginsToInstall
5
5
  } = require('./checkIfPluginsAreInstalled');
6
6
  const {
7
7
  installPlugins
@@ -10,7 +10,7 @@ function arePluginsInstalled() {
10
10
  let {
11
11
  uninstalledPlugins,
12
12
  noPluginMessage
13
- } = checkIfPluginsAreInstalled();
13
+ } = getPluginsToInstall();
14
14
  let areAllPluginsInstalled = uninstalledPlugins.length === 0 ? true : false;
15
15
  if (!areAllPluginsInstalled) {
16
16
  installPlugins(uninstalledPlugins);
@@ -51,10 +51,42 @@ function checkIfPluginsAreInstalled() {
51
51
  packageName,
52
52
  version
53
53
  } = plugin;
54
- // const { isPluginPresent, pluginPath } = checkPluginsPresentInNodemodules(packageName) // circular installation loop so comment out
55
- // if( isPluginPresent && checkPluginHasProperVersion(packageName,pluginPath,version)){
56
- // return false
57
- // }
54
+ const {
55
+ isPluginPresent,
56
+ pluginPath
57
+ } = checkPluginsPresentInNodemodules(packageName); // circular installation loop so comment out
58
+ if (isPluginPresent && checkPluginHasProperVersion(packageName, pluginPath, version)) {
59
+ return false;
60
+ }
61
+ return `${packageName}@${version}`;
62
+ }).filter(Boolean);
63
+ if (uninstalledPlugins.length > 0) {
64
+ plugin.noPluginMessage = '';
65
+ plugin.uninstalledPlugins = uninstalledPlugins;
66
+ return plugin;
67
+ } else {
68
+ plugin.noPluginMessage = 'No plugins present for the repository';
69
+ plugin.uninstalledPlugins = [];
70
+ return plugin;
71
+ }
72
+ }
73
+
74
+ /**
75
+ * @function getPluginsToInstall - plugins need for this repository
76
+ * @returns {Array<String>}
77
+ */
78
+ function getPluginsToInstall() {
79
+ const pluginsForCurrentRepo = getAllPlugins();
80
+ var uninstalledPlugins = [];
81
+ var plugin = {
82
+ noPluginMessage: '',
83
+ uninstalledPlugins: []
84
+ };
85
+ uninstalledPlugins = pluginsForCurrentRepo.map(plugin => {
86
+ const {
87
+ packageName,
88
+ version
89
+ } = plugin;
58
90
  return `${packageName}@${version}`;
59
91
  }).filter(Boolean);
60
92
  if (uninstalledPlugins.length > 0) {
@@ -113,5 +145,6 @@ function checkPluginHasProperVersion(rulePluginName, installationPath, remotePlu
113
145
  return remotePluginExactVersion == packageJsonPluginExactVersion ? true : false;
114
146
  }
115
147
  module.exports = {
148
+ getPluginsToInstall,
116
149
  checkIfPluginsAreInstalled
117
150
  };
package/changeLog.md CHANGED
@@ -29,4 +29,10 @@
29
29
  # 0.0.6 - Support extended for .properties file
30
30
 
31
31
  1. The file types that are supported by this library can now be configured using the configuration file "lint.config.js"
32
- 2. Support for .properties file is also extended in this version along with existing support for file types .js, .jsx, .ts, .tsx
32
+ 2. Support for .properties file is also extended in this version along with existing support for file types .js, .jsx, .ts, .tsx
33
+
34
+
35
+ # - Support For Stylelint
36
+
37
+ 1. Enhancement Parser support CSS files and linter
38
+ 2. Clonet Configuration Flow Enhancement Validation
@@ -10,7 +10,7 @@
10
10
 
11
11
  module.exports = {
12
12
  endPoint: "zgit.csez.zohocorpin.com/code_standard/client_linter/linter_configuration.git",
13
- branch: "master",
13
+ branch: process.env.CONFIGURATION_BRANCH || "master",
14
14
  cacheDirectory: "./",
15
15
  commonLinterRepoName: "configuration",
16
16
  type: "git",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/codestandard-validator",
3
- "version": "0.0.7-exp-10",
3
+ "version": "0.0.7-exp-12",
4
4
  "description": "library to enforce code standard using eslint",
5
5
  "main": "index.js",
6
6
  "scripts": {