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

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
@@ -33,7 +33,7 @@ async function run() {
33
33
  }
34
34
  case "setupPlugins":
35
35
  {
36
- let {
36
+ const {
37
37
  uninstalledPlugins
38
38
  } = checkIfPluginsAreInstalled();
39
39
  await executeMethodsThatReturnBooleanValue("Some issue occurred in installing plugins", installPlugins, uninstalledPlugins);
@@ -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,44 @@
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
26
  function installPlugins(pluginsToBeInstalled) {
27
+ // let {uninstalledPlugins : pluginsToBeInstalled} = checkIfPluginsAreInstalled()
16
28
  if (pluginsToBeInstalled.length > 0) {
29
+ let installCommand = `npm install --no-save ${pluginsToBeInstalled.join(' ')}`;
17
30
  Logger.log(Logger.INFO_TYPE, 'Installing plugins ....');
18
- try {
31
+ Logger.log(Logger.INFO_TYPE, `Install command being executed: ${installCommand}`);
32
+ let arePluginsInstalledSuccessfully = executeSynchronizedCommands(execSync, [installCommand, {
33
+ stdio: 'inherit',
34
+ cwd: getNodeModulesPath()
35
+ }], '', 'Some issue occured while installing plugins', false, true);
36
+ if (arePluginsInstalledSuccessfully) {
19
37
  Logger.log(Logger.SUCCESS_TYPE, 'Plugins installation successful');
20
- installPluginsByWorker(pluginsToBeInstalled);
21
38
  createVersionControlFile(pluginsToBeInstalled);
22
39
  return true;
23
- } catch (error) {
24
- Logger.log(Logger.FAILURE_TYPE, `Unable to install plugins.Kindly retry the command - ${error.message}`);
40
+ } else {
41
+ Logger.log(Logger.FAILURE_TYPE, "Unable to install plugins.Kindly retry the command");
25
42
  return false;
26
43
  }
27
44
  } else {
@@ -9,11 +9,11 @@ const {
9
9
  * @param {Array} uninstalledPlugins - contains list of uninstalled plugins for the project
10
10
  */
11
11
  function printUninstalledPlugins(uninstalledPlugins, noPluginMessage) {
12
- // let commandToInstallPlugins = 'npx ZDPrecommit setupPlugins'
12
+ let commandToInstallPlugins = 'npx ZDPrecommit setupPlugins';
13
13
  if (uninstalledPlugins.length !== 0) {
14
14
  Logger.log(Logger.INFO_TYPE, 'The following plugins are not installed:');
15
15
  uninstalledPlugins.map(plugin => {
16
- Logger.log(Logger.INFO_TYPE, `"${plugin.packageName}@${plugin.version}"`);
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
19
  } else if (uninstalledPlugins.length === 0 && noPluginMessage.trim() === '') {
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-13",
4
4
  "description": "library to enforce code standard using eslint",
5
5
  "main": "index.js",
6
6
  "scripts": {