@zohodesk/codestandard-validator 0.0.4-exp-12 → 0.0.4-exp-8

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
@@ -15,9 +15,6 @@ const {
15
15
  const {
16
16
  installPlugins
17
17
  } = require("../utils/PluginsInstallation/installPlugins");
18
- const {
19
- checkIfPluginsAreInstalled
20
- } = require("../utils/PluginsInstallation/checkIfPluginsAreInstalled");
21
18
  const [,, action, ...options] = process.argv;
22
19
  async function run() {
23
20
  switch (action) {
@@ -33,10 +30,7 @@ async function run() {
33
30
  }
34
31
  case "setupPlugins":
35
32
  {
36
- let {
37
- uninstalledPlugins
38
- } = checkIfPluginsAreInstalled();
39
- await executeMethodsThatReturnBooleanValue("Some issue occurred in installing plugins", installPlugins, uninstalledPlugins);
33
+ await executeMethodsThatReturnBooleanValue("Some issue occurred in installing plugins", installPlugins, null);
40
34
  break;
41
35
  }
42
36
  case "setupExtension":
@@ -11,11 +11,10 @@ const {
11
11
  } = require('./printUninstalledPlugins');
12
12
  function arePluginsInstalled() {
13
13
  let {
14
- uninstalledPlugins,
15
- noPluginMessage
14
+ uninstalledPlugins
16
15
  } = checkIfPluginsAreInstalled();
17
- printUninstalledPlugins(uninstalledPlugins, noPluginMessage);
18
- installPlugins(uninstalledPlugins);
16
+ printUninstalledPlugins(uninstalledPlugins);
17
+ installPlugins();
19
18
  }
20
19
  module.exports = {
21
20
  arePluginsInstalled
@@ -114,10 +114,7 @@ function checkIfPluginsAreInstalled() {
114
114
  if (isPluginPresent && checkPluginHasProperVersion(packageName, pluginPath, version)) {
115
115
  return false;
116
116
  }
117
- return {
118
- packageName,
119
- version
120
- };
117
+ return `${packageName}@${version}`;
121
118
  }).filter(Boolean);
122
119
  if (uninstalledPlugins.length > 0) {
123
120
  // uninstalledPlugins = getUnInstalledPlugins(pluginsForCurrentRepo, pluginNamesOfDevDependencyPlugins, pluginsIndevDependencies);
@@ -1,27 +1,46 @@
1
1
  "use strict";
2
2
 
3
+ const {
4
+ execSync
5
+ } = require('child_process');
6
+ const {
7
+ checkIfPluginsAreInstalled
8
+ } = require('./checkIfPluginsAreInstalled');
9
+ const {
10
+ executeSynchronizedCommands
11
+ } = require('../General/executeSyncCommands');
3
12
  const {
4
13
  Logger
5
14
  } = require('../Logger/Logger');
6
15
  const {
7
16
  createVersionControlFile
8
17
  } = require('../FileAndFolderOperations/versionControl');
9
- const installPluginsByWorker = require('./Worker/installPluginsByWoker');
18
+ const {
19
+ getNodeModulesPath
20
+ } = require('../General/getNodeModulesPath');
10
21
 
11
22
  /**
12
23
  * @function installPlugins - installs uninstalled plugins for the project
13
24
  * @returns {boolean} - indicating if plugins to be installed are installed successfully or not
14
25
  */
15
- function installPlugins(pluginsToBeInstalled) {
26
+ function installPlugins() {
27
+ let {
28
+ uninstalledPlugins: pluginsToBeInstalled
29
+ } = checkIfPluginsAreInstalled();
16
30
  if (pluginsToBeInstalled.length > 0) {
31
+ let installCommand = `npm install --no-save ${pluginsToBeInstalled.join(' ')}`;
17
32
  Logger.log(Logger.INFO_TYPE, 'Installing plugins ....');
18
- try {
33
+ Logger.log(Logger.INFO_TYPE, `Install command being executed: ${installCommand}`);
34
+ let arePluginsInstalledSuccessfully = executeSynchronizedCommands(execSync, [installCommand, {
35
+ stdio: 'inherit',
36
+ cwd: getNodeModulesPath()
37
+ }], '', 'Some issue occured while installing plugins', false, true);
38
+ if (arePluginsInstalledSuccessfully) {
19
39
  Logger.log(Logger.SUCCESS_TYPE, 'Plugins installation successful');
20
- installPluginsByWorker(pluginsToBeInstalled);
21
40
  createVersionControlFile(pluginsToBeInstalled);
22
41
  return true;
23
- } catch (error) {
24
- Logger.log(Logger.FAILURE_TYPE, `Unable to install plugins.Kindly retry the command - ${error.message}`);
42
+ } else {
43
+ Logger.log(Logger.FAILURE_TYPE, "Unable to install plugins.Kindly retry the command");
25
44
  return false;
26
45
  }
27
46
  } else {
@@ -8,17 +8,17 @@ const {
8
8
  * @function printUninstalledPlugins - to notify the user regarding plugins for the repository has been installed or not
9
9
  * @param {Array} uninstalledPlugins - contains list of uninstalled plugins for the project
10
10
  */
11
- function printUninstalledPlugins(uninstalledPlugins, noPluginMessage) {
12
- // let commandToInstallPlugins = 'npx ZDPrecommit setupPlugins'
13
- if (uninstalledPlugins.length !== 0) {
11
+ function printUninstalledPlugins(uninstalledPlugins) {
12
+ let commandToInstallPlugins = 'npx ZDPrecommit setupPlugins';
13
+ if (uninstalledPlugins.uninstalledPlugins.length !== 0) {
14
14
  Logger.log(Logger.INFO_TYPE, 'The following plugins are not installed:');
15
- uninstalledPlugins.map(plugin => {
16
- Logger.log(Logger.INFO_TYPE, `"${plugin.packageName}@${plugin.version}"`);
15
+ uninstalledPlugins.uninstalledPlugins.map(plugin => {
16
+ Logger.log(Logger.INFO_TYPE, `"${plugin}"`);
17
17
  });
18
18
  // Logger.log(Logger.FAILURE_TYPE, `Kindly execute the command \x1b[37m"${commandToInstallPlugins}\x1b[0m" \x1b[31mfrom the location where package.json of the repo is present to install the plugins`)
19
- } else if (uninstalledPlugins.length === 0 && noPluginMessage.trim() === '') {
19
+ } else if (uninstalledPlugins.uninstalledPlugins.length === 0 && uninstalledPlugins.noPluginMessage.trim() === '') {
20
20
  Logger.log(Logger.INFO_TYPE, 'Plugins are installed already');
21
- } else if (uninstalledPlugins.length === 0 && noPluginMessage.trim() !== '') {
21
+ } else if (uninstalledPlugins.uninstalledPlugins.length === 0 && uninstalledPlugins.noPluginMessage.trim() !== '') {
22
22
  Logger.log(Logger.INFO_TYPE, 'No plugins present for the repository');
23
23
  }
24
24
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/codestandard-validator",
3
- "version": "0.0.4-exp-12",
3
+ "version": "0.0.4-exp-8",
4
4
  "description": "library to enforce code standard using eslint",
5
5
  "main": "index.js",
6
6
  "scripts": {