@zohodesk/codestandard-validator 0.0.7-exp-9 → 0.0.7-exp-11
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/hooks/Precommit/pre-commit.js +8 -9
- package/build/hooks/hook.js +2 -2
- package/build/lib/cli.js +2 -2
- package/build/utils/PluginsInstallation/arePluginsInstalled.js +2 -2
- package/build/utils/PluginsInstallation/checkIfPluginsAreInstalled.js +31 -1
- package/build/utils/PluginsInstallation/installPlugins.js +1 -10
- package/index.js +1 -1
- package/package.json +1 -1
|
@@ -8,7 +8,7 @@ const fs = require('fs');
|
|
|
8
8
|
const path = require('path');
|
|
9
9
|
const {
|
|
10
10
|
getEslintExecutablePath
|
|
11
|
-
} = require('../../utils/
|
|
11
|
+
} = require('../../utils/ConfigFileUtils/getEslintExecutablePath');
|
|
12
12
|
const {
|
|
13
13
|
getNodeModulesPath
|
|
14
14
|
} = require('../../utils/General/getNodeModulesPath');
|
|
@@ -152,16 +152,15 @@ function findStyleLintErrors(filePath) {
|
|
|
152
152
|
cwd: getNodeModulesPath()
|
|
153
153
|
}, (error, stderr, stdout) => {
|
|
154
154
|
if (stdout) {
|
|
155
|
-
resolve(
|
|
155
|
+
resolve(stdout.trim().split('\n'));
|
|
156
156
|
}
|
|
157
|
-
if
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
// else if(error){
|
|
161
|
-
// Logger.log(Logger.FAILURE_TYPE,error)
|
|
162
|
-
// reject("Error executing eslint command")
|
|
157
|
+
// if(stderr){
|
|
158
|
+
// resolve(stderr.trim().split('\n'))
|
|
163
159
|
// }
|
|
164
|
-
else {
|
|
160
|
+
else if (error) {
|
|
161
|
+
Logger.log(Logger.FAILURE_TYPE, error);
|
|
162
|
+
reject("Error executing stylelint command");
|
|
163
|
+
} else {
|
|
165
164
|
resolve([]);
|
|
166
165
|
}
|
|
167
166
|
});
|
package/build/hooks/hook.js
CHANGED
|
@@ -11,7 +11,7 @@ const {
|
|
|
11
11
|
cloneViaCdt
|
|
12
12
|
} = require("../utils/CloneCommonLinterRepo/cloneViaCdt");
|
|
13
13
|
const {
|
|
14
|
-
|
|
14
|
+
getPluginsToInstall
|
|
15
15
|
} = require("../utils/PluginsInstallation/checkIfPluginsAreInstalled");
|
|
16
16
|
const {
|
|
17
17
|
installPlugins
|
|
@@ -21,7 +21,7 @@ async function hooks() {
|
|
|
21
21
|
await executeMethodsThatReturnBooleanValue("Make sure zgit.csez.zohocorpin.com is accessible", cloneViaCdt, null);
|
|
22
22
|
const {
|
|
23
23
|
uninstalledPlugins
|
|
24
|
-
} =
|
|
24
|
+
} = getPluginsToInstall();
|
|
25
25
|
await executeMethodsThatReturnBooleanValue("Some issue occurred in installing plugins", installPlugins, uninstalledPlugins);
|
|
26
26
|
}
|
|
27
27
|
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
|
-
|
|
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
|
-
} =
|
|
38
|
+
} = getPluginsToInstall();
|
|
39
39
|
await executeMethodsThatReturnBooleanValue("Some issue occurred in installing plugins", installPlugins, uninstalledPlugins);
|
|
40
40
|
break;
|
|
41
41
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
const {
|
|
4
|
-
|
|
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
|
-
} =
|
|
13
|
+
} = getPluginsToInstall();
|
|
14
14
|
let areAllPluginsInstalled = uninstalledPlugins.length === 0 ? true : false;
|
|
15
15
|
if (!areAllPluginsInstalled) {
|
|
16
16
|
installPlugins(uninstalledPlugins);
|
|
@@ -54,7 +54,7 @@ function checkIfPluginsAreInstalled() {
|
|
|
54
54
|
const {
|
|
55
55
|
isPluginPresent,
|
|
56
56
|
pluginPath
|
|
57
|
-
} = checkPluginsPresentInNodemodules(packageName);
|
|
57
|
+
} = checkPluginsPresentInNodemodules(packageName); // circular installation loop so comment out
|
|
58
58
|
if (isPluginPresent && checkPluginHasProperVersion(packageName, pluginPath, version)) {
|
|
59
59
|
return false;
|
|
60
60
|
}
|
|
@@ -71,6 +71,35 @@ function checkIfPluginsAreInstalled() {
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
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;
|
|
90
|
+
return `${packageName}@${version}`;
|
|
91
|
+
}).filter(Boolean);
|
|
92
|
+
if (uninstalledPlugins.length > 0) {
|
|
93
|
+
plugin.noPluginMessage = '';
|
|
94
|
+
plugin.uninstalledPlugins = uninstalledPlugins;
|
|
95
|
+
return plugin;
|
|
96
|
+
} else {
|
|
97
|
+
plugin.noPluginMessage = 'No plugins present for the repository';
|
|
98
|
+
plugin.uninstalledPlugins = [];
|
|
99
|
+
return plugin;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
74
103
|
/**
|
|
75
104
|
* @function returnExactPluginVersion - to return the exact plugin version after removing caret or tilde symbol if present
|
|
76
105
|
* @param {string} pluginVersion
|
|
@@ -116,5 +145,6 @@ function checkPluginHasProperVersion(rulePluginName, installationPath, remotePlu
|
|
|
116
145
|
return remotePluginExactVersion == packageJsonPluginExactVersion ? true : false;
|
|
117
146
|
}
|
|
118
147
|
module.exports = {
|
|
148
|
+
getPluginsToInstall,
|
|
119
149
|
checkIfPluginsAreInstalled
|
|
120
150
|
};
|
|
@@ -30,21 +30,12 @@ function installPlugins(pluginsToBeInstalled) {
|
|
|
30
30
|
if (pluginsToBeInstalled.length > 0) {
|
|
31
31
|
let packageJsonBeforePluginsInstallation = getPackageJsonContentBeforeInstallingPlugins();
|
|
32
32
|
Logger.log(Logger.INFO_TYPE, 'Installing plugins ....');
|
|
33
|
+
const installCommand = `npm install --save-dev ${pluginsToBeInstalled.join(' ')} --legacy-peer-deps`;
|
|
33
34
|
Logger.log(Logger.INFO_TYPE, `Install command being executed: ${installCommand}`);
|
|
34
35
|
let arePluginsInstalledSuccessfully = executeSynchronizedCommands(execSync, [installCommand, {
|
|
35
36
|
stdio: 'inherit',
|
|
36
37
|
cwd: getNodeModulesPath()
|
|
37
38
|
}], '', 'Some issue occured while installing plugins', false, true);
|
|
38
|
-
const installCommand = ['install', '--save-dev', ...pluginsToBeInstalled, '--legacy-peer-deps'];
|
|
39
|
-
const result = spawn('npm', installCommand, {
|
|
40
|
-
stdio: 'inherit',
|
|
41
|
-
shell: true,
|
|
42
|
-
cwd: getNodeModulesPath()
|
|
43
|
-
});
|
|
44
|
-
if (result.error) {
|
|
45
|
-
Logger.log('Error running npm install:', result.error);
|
|
46
|
-
process.exit(1);
|
|
47
|
-
}
|
|
48
39
|
if (arePluginsInstalledSuccessfully) {
|
|
49
40
|
Logger.log(Logger.SUCCESS_TYPE, 'Plugins installation successful');
|
|
50
41
|
let isPackageJsonRestored = restorePackageJsonContent(packageJsonBeforePluginsInstallation);
|
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { getLintConfigurationUtil } = require("./build/utils/
|
|
1
|
+
const { getLintConfigurationUtil } = require("./build/utils/ConfigFileUtils/getLintConfiguration");
|
|
2
2
|
const { rulesConfig, plugins, extendPlugins } = getLintConfigurationUtil();
|
|
3
3
|
|
|
4
4
|
module.exports = {
|