@zohodesk/codestandard-validator 0.0.6-exp-13 → 0.0.6-exp-15
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.
|
@@ -51,10 +51,13 @@ function checkIfPluginsAreInstalled() {
|
|
|
51
51
|
packageName,
|
|
52
52
|
version
|
|
53
53
|
} = plugin;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
const {
|
|
55
|
+
isPluginPresent,
|
|
56
|
+
pluginPath
|
|
57
|
+
} = checkPluginsPresentInNodemodules(packageName);
|
|
58
|
+
if (isPluginPresent && checkPluginHasProperVersion(packageName, pluginPath, version)) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
58
61
|
return `${packageName}@${version}`;
|
|
59
62
|
}).filter(Boolean);
|
|
60
63
|
if (uninstalledPlugins.length > 0) {
|
|
@@ -28,8 +28,11 @@ function installPlugins(pluginsToBeInstalled) {
|
|
|
28
28
|
Logger.log(Logger.INFO_TYPE, 'Plugins are already installed');
|
|
29
29
|
return true;
|
|
30
30
|
}
|
|
31
|
-
const
|
|
32
|
-
|
|
31
|
+
const {
|
|
32
|
+
packageJsonContentBeforePluginsInstallation,
|
|
33
|
+
packageLockJsonContentBeforePluginsInstallation
|
|
34
|
+
} = getPackageJsonContentBeforeInstallingPlugins();
|
|
35
|
+
const installCommand = `npm install --save-dev ${pluginsToBeInstalled.join(' ')}`;
|
|
33
36
|
Logger.log(Logger.INFO_TYPE, 'Installing plugins...');
|
|
34
37
|
Logger.log(Logger.INFO_TYPE, `Install command being executed: ${installCommand}`);
|
|
35
38
|
const installed = executeSynchronizedCommands(execSync, [installCommand, {
|
|
@@ -41,7 +44,10 @@ function installPlugins(pluginsToBeInstalled) {
|
|
|
41
44
|
return false;
|
|
42
45
|
}
|
|
43
46
|
Logger.log(Logger.SUCCESS_TYPE, 'Plugins installation successful');
|
|
44
|
-
const restored = restorePackageJsonContent(
|
|
47
|
+
const restored = restorePackageJsonContent({
|
|
48
|
+
packageJsonContentBeforePluginsInstallation,
|
|
49
|
+
packageLockJsonContentBeforePluginsInstallation
|
|
50
|
+
});
|
|
45
51
|
if (!restored) {
|
|
46
52
|
Logger.log(Logger.FAILURE_TYPE, 'Unable to restore package.json content');
|
|
47
53
|
return false;
|
|
@@ -56,18 +62,29 @@ function installPlugins(pluginsToBeInstalled) {
|
|
|
56
62
|
*/
|
|
57
63
|
function getPackageJsonContentBeforeInstallingPlugins() {
|
|
58
64
|
let packageJsonFilePath = `${getNodeModulesPath()}/package.json`;
|
|
65
|
+
let packageLockJsonFilePath = `${getNodeModulesPath()}/package-lock.json`;
|
|
59
66
|
let packageJsonContentBeforePluginsInstallation = require(packageJsonFilePath);
|
|
60
|
-
|
|
67
|
+
let packageLockJsonContentBeforePluginsInstallation = require(packageLockJsonFilePath);
|
|
68
|
+
return {
|
|
69
|
+
packageJsonContentBeforePluginsInstallation,
|
|
70
|
+
packageLockJsonContentBeforePluginsInstallation
|
|
71
|
+
};
|
|
61
72
|
}
|
|
62
73
|
|
|
63
74
|
/**
|
|
64
75
|
* @function restorePackageJsonContent - restore the same content as it was before installing plugins
|
|
65
76
|
* @returns {Boolean} - indicating the success or failure of restoring package.json content
|
|
66
77
|
*/
|
|
67
|
-
function restorePackageJsonContent(
|
|
78
|
+
function restorePackageJsonContent(obj) {
|
|
79
|
+
const {
|
|
80
|
+
packageJsonContentBeforePluginsInstallation,
|
|
81
|
+
packageLockJsonContentBeforePluginsInstallation
|
|
82
|
+
} = obj;
|
|
68
83
|
let packageJsonFilePath = `${getNodeModulesPath()}/package.json`;
|
|
84
|
+
let packageLockJsonFilePath = `${getNodeModulesPath()}/package-lock.json`;
|
|
69
85
|
let isPackageJsonRestored = executeSynchronizedCommands(writeFileSync, [packageJsonFilePath, JSON.stringify(packageJsonContentBeforePluginsInstallation, null, 2)], 'Package.json content restored successfully', 'Unable to restore package.json content', false, true);
|
|
70
|
-
|
|
86
|
+
let isPackageLockJsonRestored = executeSynchronizedCommands(writeFileSync, [packageLockJsonFilePath, JSON.stringify(packageLockJsonContentBeforePluginsInstallation, null, 2)], 'Packagk Locj.json content restored successfully', 'Unable to restore package-lock.json content', false, true);
|
|
87
|
+
return isPackageJsonRestored && isPackageLockJsonRestored;
|
|
71
88
|
}
|
|
72
89
|
module.exports = {
|
|
73
90
|
installPlugins
|