@zohodesk/codestandard-validator 0.0.6-exp-2 → 0.0.6-exp-3
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 +12 -7
- package/build/lib/cli.js +3 -9
- package/build/utils/General/getGeneralInfo.js +5 -1
- package/build/utils/HuskySetup/configurePrecommitHook.js +1 -1
- package/build/utils/PluginsInstallation/arePluginsInstalled.js +5 -9
- package/build/utils/PluginsInstallation/installPlugins.js +22 -29
- package/package.json +1 -1
- /package/bin/{execute.js → precommit.js} +0 -0
|
@@ -8,19 +8,24 @@ const {
|
|
|
8
8
|
} = require("../../utils/EslintConfigFileUtils/createEslintConfigFile");
|
|
9
9
|
const {
|
|
10
10
|
getLastCommitHash,
|
|
11
|
-
|
|
11
|
+
getStoredCommitHash
|
|
12
12
|
} = require("../../utils/General/getGeneralInfo");
|
|
13
|
+
const {
|
|
14
|
+
executeMethodsThatReturnBooleanValue
|
|
15
|
+
} = require("../../utils/General/wrapperFunctionToExecuteAFunction");
|
|
16
|
+
const {
|
|
17
|
+
Logger
|
|
18
|
+
} = require("../../utils/Logger/Logger");
|
|
13
19
|
const {
|
|
14
20
|
arePluginsInstalled
|
|
15
21
|
} = require("../../utils/PluginsInstallation/arePluginsInstalled");
|
|
16
22
|
async function validateRemotePackages() {
|
|
17
23
|
try {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
Logger.log(Logger.SUCCESS_TYPE, "Pre commit setup successfull");
|
|
24
|
+
if (!(getStoredCommitHash() == getLastCommitHash())) {
|
|
25
|
+
await executeMethodsThatReturnBooleanValue("Make sure zgit.csez.zohocorpin.com is accessible", cloneViaCdt, null);
|
|
26
|
+
await executeMethodsThatReturnBooleanValue("Some issue occurred in creating eslint config file.", createEslintConfigFile, null);
|
|
27
|
+
Logger.log(Logger.SUCCESS_TYPE, "Pre commit setup successfull");
|
|
28
|
+
}
|
|
24
29
|
arePluginsInstalled();
|
|
25
30
|
} catch (error) {
|
|
26
31
|
Logger.log(Logger.FAILURE_TYPE, `Kindly retry npm install. & ${error.message}`);
|
package/build/lib/cli.js
CHANGED
|
@@ -13,11 +13,8 @@ const {
|
|
|
13
13
|
installEslintExtension
|
|
14
14
|
} = require("../utils/ExtensionInstallation/installEslintExtension");
|
|
15
15
|
const {
|
|
16
|
-
|
|
17
|
-
} = require("../utils/PluginsInstallation/
|
|
18
|
-
const {
|
|
19
|
-
checkIfPluginsAreInstalled
|
|
20
|
-
} = require("../utils/PluginsInstallation/checkIfPluginsAreInstalled");
|
|
16
|
+
arePluginsInstalled
|
|
17
|
+
} = require("../utils/PluginsInstallation/arePluginsInstalled");
|
|
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
|
-
|
|
37
|
-
uninstalledPlugins
|
|
38
|
-
} = checkIfPluginsAreInstalled();
|
|
39
|
-
await executeMethodsThatReturnBooleanValue("Some issue occurred in installing plugins", installPlugins, uninstalledPlugins);
|
|
33
|
+
arePluginsInstalled();
|
|
40
34
|
break;
|
|
41
35
|
}
|
|
42
36
|
case "setupExtension":
|
|
@@ -73,6 +73,9 @@ function getLastCommitHash() {
|
|
|
73
73
|
function getRequiredInfoPath() {
|
|
74
74
|
return path.join(process.cwd(), 'jsonUtils', 'fsUtils.json');
|
|
75
75
|
}
|
|
76
|
+
function getStoredCommitHash() {
|
|
77
|
+
return require(path.join(__dirname, '..', '..', '..', 'jsonUtils', 'fsUtils.json')).commitHash;
|
|
78
|
+
}
|
|
76
79
|
module.exports = {
|
|
77
80
|
getSupportedLanguage,
|
|
78
81
|
getTimeStampInfo,
|
|
@@ -80,5 +83,6 @@ module.exports = {
|
|
|
80
83
|
getConfigurationPrecommit,
|
|
81
84
|
getRunningEnv,
|
|
82
85
|
getLastCommitHash,
|
|
83
|
-
getRequiredInfoPath
|
|
86
|
+
getRequiredInfoPath,
|
|
87
|
+
getStoredCommitHash
|
|
84
88
|
};
|
|
@@ -21,7 +21,7 @@ const {
|
|
|
21
21
|
*/
|
|
22
22
|
function configurePrecommitHook() {
|
|
23
23
|
let rootDirectory = getRootDirectory();
|
|
24
|
-
let customPrecomitHookPath = path.join(getLibraryInstalledLocation(), "bin", "
|
|
24
|
+
let customPrecomitHookPath = path.join(getLibraryInstalledLocation(), "bin", "precommit.js");
|
|
25
25
|
let customPrePushHookPath = path.join(getLibraryInstalledLocation(), "bin", "push.js");
|
|
26
26
|
let huskyPrecommitPath = path.join(rootDirectory, ".husky", "pre-commit");
|
|
27
27
|
let huskyPrePushPath = path.join(rootDirectory, ".husky", "pre-push");
|
|
@@ -1,24 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
const {
|
|
4
|
+
executeMethodsThatReturnBooleanValue
|
|
5
|
+
} = require('../General/wrapperFunctionToExecuteAFunction');
|
|
3
6
|
const {
|
|
4
7
|
checkIfPluginsAreInstalled
|
|
5
8
|
} = require('./checkIfPluginsAreInstalled');
|
|
6
|
-
const {
|
|
7
|
-
printUninstalledPlugins
|
|
8
|
-
} = require('./printUninstalledPlugins');
|
|
9
9
|
const {
|
|
10
10
|
installPlugins
|
|
11
11
|
} = require('./installPlugins');
|
|
12
|
-
function arePluginsInstalled() {
|
|
12
|
+
async function arePluginsInstalled() {
|
|
13
13
|
let {
|
|
14
14
|
uninstalledPlugins,
|
|
15
15
|
noPluginMessage
|
|
16
16
|
} = checkIfPluginsAreInstalled();
|
|
17
|
-
|
|
18
|
-
if (!areAllPluginsInstalled) {
|
|
19
|
-
installPlugins(uninstalledPlugins);
|
|
20
|
-
}
|
|
21
|
-
// printUninstalledPlugins(uninstalledPlugins,noPluginMessage)
|
|
17
|
+
await executeMethodsThatReturnBooleanValue("Some issue occurred in installing plugins", installPlugins, uninstalledPlugins);
|
|
22
18
|
}
|
|
23
19
|
module.exports = {
|
|
24
20
|
arePluginsInstalled
|
|
@@ -6,9 +6,6 @@ const {
|
|
|
6
6
|
const {
|
|
7
7
|
writeFileSync
|
|
8
8
|
} = require('fs');
|
|
9
|
-
const {
|
|
10
|
-
checkIfPluginsAreInstalled
|
|
11
|
-
} = require('./checkIfPluginsAreInstalled');
|
|
12
9
|
const {
|
|
13
10
|
executeSynchronizedCommands
|
|
14
11
|
} = require('../General/executeSyncCommands');
|
|
@@ -27,34 +24,30 @@ const {
|
|
|
27
24
|
* @returns {boolean} - indicating if plugins to be installed are installed successfully or not
|
|
28
25
|
*/
|
|
29
26
|
function installPlugins(pluginsToBeInstalled) {
|
|
30
|
-
|
|
31
|
-
if (pluginsToBeInstalled.length > 0) {
|
|
32
|
-
let packageJsonBeforePluginsInstallation = getPackageJsonContentBeforeInstallingPlugins();
|
|
33
|
-
let installCommand = `npm install --save-dev ${pluginsToBeInstalled.join(' ')}`;
|
|
34
|
-
Logger.log(Logger.INFO_TYPE, 'Installing plugins ....');
|
|
35
|
-
Logger.log(Logger.INFO_TYPE, `Install command being executed: ${installCommand}`);
|
|
36
|
-
let arePluginsInstalledSuccessfully = executeSynchronizedCommands(execSync, [installCommand, {
|
|
37
|
-
stdio: 'inherit',
|
|
38
|
-
cwd: getNodeModulesPath()
|
|
39
|
-
}], '', 'Some issue occured while installing plugins', false, true);
|
|
40
|
-
if (arePluginsInstalledSuccessfully) {
|
|
41
|
-
Logger.log(Logger.SUCCESS_TYPE, 'Plugins installation successful');
|
|
42
|
-
let isPackageJsonRestored = restorePackageJsonContent(packageJsonBeforePluginsInstallation);
|
|
43
|
-
if (isPackageJsonRestored) {
|
|
44
|
-
createVersionControlFile(pluginsToBeInstalled);
|
|
45
|
-
// return true
|
|
46
|
-
} else {
|
|
47
|
-
Logger.log(Logger.FAILURE_TYPE, 'Unable to restore package.json content');
|
|
48
|
-
// return false
|
|
49
|
-
}
|
|
50
|
-
} else {
|
|
51
|
-
Logger.log(Logger.FAILURE_TYPE, "Unable to install plugins.Kindly retry the command");
|
|
52
|
-
// return false
|
|
53
|
-
}
|
|
54
|
-
} else {
|
|
27
|
+
if (pluginsToBeInstalled.length === 0) {
|
|
55
28
|
Logger.log(Logger.INFO_TYPE, 'Plugins are already installed');
|
|
56
|
-
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
const packageJsonBackup = getPackageJsonContentBeforeInstallingPlugins();
|
|
32
|
+
const installCommand = `npm install --save-dev ${pluginsToBeInstalled.join(' ')}`;
|
|
33
|
+
Logger.log(Logger.INFO_TYPE, 'Installing plugins...');
|
|
34
|
+
Logger.log(Logger.INFO_TYPE, `Install command being executed: ${installCommand}`);
|
|
35
|
+
const installed = executeSynchronizedCommands(execSync, [installCommand, {
|
|
36
|
+
stdio: 'inherit',
|
|
37
|
+
cwd: getNodeModulesPath()
|
|
38
|
+
}], '', 'Some issue occurred while installing plugins', false, true);
|
|
39
|
+
if (!installed) {
|
|
40
|
+
Logger.log(Logger.FAILURE_TYPE, 'Unable to install plugins. Kindly retry the command');
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
Logger.log(Logger.SUCCESS_TYPE, 'Plugins installation successful');
|
|
44
|
+
const restored = restorePackageJsonContent(packageJsonBackup);
|
|
45
|
+
if (!restored) {
|
|
46
|
+
Logger.log(Logger.FAILURE_TYPE, 'Unable to restore package.json content');
|
|
47
|
+
return false;
|
|
57
48
|
}
|
|
49
|
+
createVersionControlFile(pluginsToBeInstalled);
|
|
50
|
+
return true;
|
|
58
51
|
}
|
|
59
52
|
|
|
60
53
|
/**
|
package/package.json
CHANGED
|
File without changes
|