@zohodesk/codestandard-validator 0.0.7 → 1.0.0-exp-2

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.
Files changed (34) hide show
  1. package/.babelrc +1 -1
  2. package/bin/execute.js +1 -1
  3. package/build/hooks/Precommit/commit.js +50 -0
  4. package/build/hooks/Precommit/errorhelpers.js +39 -0
  5. package/build/hooks/Precommit/guard.js +50 -0
  6. package/build/hooks/Precommit/lint.js +96 -174
  7. package/build/hooks/Precommit/pre-commit.js +88 -29
  8. package/build/hooks/Precommit/utils.js +56 -0
  9. package/build/hooks/hook.js +40 -0
  10. package/build/lib/cli.js +2 -2
  11. package/build/lib/postinstall.js +3 -3
  12. package/build/utils/CloneCommonLinterRepo/cloneViaCdt.js +39 -26
  13. package/build/utils/ConfigFileUtils/createConfigFile.js +63 -0
  14. package/build/utils/ConfigFileUtils/getLintConfiguration.js +2 -2
  15. package/build/utils/FileAndFolderOperations/filterFiles.js +27 -2
  16. package/build/utils/General/getGeneralInfo.js +64 -3
  17. package/build/utils/General/getNodeModulesPath.js +4 -1
  18. package/build/utils/General/writeProjectDetailsToJson.js +5 -1
  19. package/build/utils/PluginsInstallation/arePluginsInstalled.js +2 -6
  20. package/build/utils/PluginsInstallation/checkIfPluginsAreInstalled.js +32 -59
  21. package/build/utils/PluginsInstallation/installPlugins.js +12 -65
  22. package/build/utils/PrecommitUsingGitSetup/update-git-precommithook.js +42 -35
  23. package/changeLog.md +7 -1
  24. package/index.js +1 -1
  25. package/jsonUtils/commonLinterRepoDetails.js +1 -1
  26. package/package.json +4 -2
  27. package/build/hooks/PrePush/pre-push.js +0 -247
  28. package/build/hooks/Precommit/filterUtils.js +0 -42
  29. package/build/utils/ConfigFileUtils/createConfigFiles.js +0 -68
  30. package/build/utils/EslintConfigFileUtils/createEslintConfigFile.js +0 -54
  31. package/build/utils/EslintConfigFileUtils/getEslintExecutablePath.js +0 -24
  32. package/build/utils/EslintConfigFileUtils/getLintConfiguration.js +0 -52
  33. package/build/utils/PluginsInstallation/Worker/installPluginsByWoker.js +0 -38
  34. package/build/utils/PluginsInstallation/Worker/worker.js +0 -33
@@ -1,24 +0,0 @@
1
- "use strict";
2
-
3
- const path = require('path');
4
- const {
5
- readdirSync
6
- } = require('fs');
7
- const {
8
- getNodeModulesPath
9
- } = require('../General/getNodeModulesPath');
10
- const {
11
- executeSynchronizedCommands
12
- } = require('../General/executeSyncCommands');
13
- const {
14
- getLibraryInstalledLocation
15
- } = require('../General/getLibraryInstalledLocation');
16
- function getEslintExecutablePath() {
17
- let eslintLibraryName = 'eslint';
18
- let librariesInNodeModulesOfProject = executeSynchronizedCommands(readdirSync, [path.join(getNodeModulesPath(), 'node_modules')], '', 'Unable to get the plugins inside node_modules', true, false);
19
- let isEslintInstalledinProject = librariesInNodeModulesOfProject.some(library => library === eslintLibraryName);
20
- return isEslintInstalledinProject ? path.join(getNodeModulesPath(), 'node_modules', eslintLibraryName, 'bin', 'eslint.js') : path.join(getLibraryInstalledLocation(), 'node_modules', eslintLibraryName, 'bin', 'eslint.js');
21
- }
22
- module.exports = {
23
- getEslintExecutablePath
24
- };
@@ -1,52 +0,0 @@
1
- "use strict";
2
-
3
- const path = require('path');
4
- const {
5
- existsSync
6
- } = require('fs');
7
- const {
8
- endPoint,
9
- commonLinterRepoName
10
- } = require("../../../jsonUtils/commonLinterRepoDetails.js");
11
- const {
12
- getRepoName
13
- } = require('../GitActions/gitActions');
14
- const {
15
- getLibraryInstalledLocation
16
- } = require('../General/getLibraryInstalledLocation');
17
- const {
18
- executeMethodsThatMayThrowException
19
- } = require("../General/wrapperFunctionToExecuteAFunction");
20
-
21
- /**
22
- * @function getLintConfiguration - returns eslint configuration file from common linters repo
23
- * @returns {object} - containing properties of the eslint configuration file
24
- */
25
- function getServicePathElseCommon() {
26
- const repoName = getRepoName();
27
- const libraryInstalledLocation = getLibraryInstalledLocation();
28
- let commonConfigPath = path.join(libraryInstalledLocation, commonLinterRepoName, 'common', 'index.js');
29
- const _configurationPath = repoName && existsSync(path.join(libraryInstalledLocation, commonLinterRepoName, 'services', repoName, 'index.js')) ? path.join(libraryInstalledLocation, commonLinterRepoName, 'services', repoName, 'index.js') : commonConfigPath;
30
- let _pathOfServiceSpecificEslintConfigFile = repoName && existsSync(path.join(libraryInstalledLocation, commonLinterRepoName, 'services', repoName, '.eslintrc.js')) ? path.join(libraryInstalledLocation, commonLinterRepoName, 'services', repoName, '.eslintrc.js') : path.join(libraryInstalledLocation, commonLinterRepoName, 'common', '.eslintrc.js');
31
- let _pluginVersionPath = repoName && existsSync(path.join(libraryInstalledLocation, commonLinterRepoName, 'services', repoName, 'pluginVersion.js')) ? path.join(libraryInstalledLocation, commonLinterRepoName, 'services', repoName, 'pluginVersion.js') : undefined;
32
- return {
33
- configurationPath: _configurationPath,
34
- pathOfServiceSpecificEslintConfigFile: _pathOfServiceSpecificEslintConfigFile,
35
- pluginVersionPath: _pluginVersionPath
36
- };
37
- }
38
- function getLintConfigurationUtil() {
39
- const {
40
- configurationPath
41
- } = getServicePathElseCommon();
42
- const exceptionHandleObject = {
43
- rulesConfig: [{}, {}],
44
- plugins: [],
45
- extendPlugins: []
46
- };
47
- return executeMethodsThatMayThrowException(exceptionHandleObject, `Kindly Ensure that Configuration is setup in Configuration repo \n ${endPoint}`, require, configurationPath);
48
- }
49
- module.exports = {
50
- getLintConfigurationUtil,
51
- getServicePathElseCommon
52
- };
@@ -1,38 +0,0 @@
1
- "use strict";
2
-
3
- const {
4
- Worker
5
- } = require('worker_threads');
6
- const {
7
- Logger
8
- } = require('../../Logger/Logger');
9
- async function installPluginsByWorker(plugins) {
10
- try {
11
- const results = await Promise.all(plugins.map(pkg => runWorker({
12
- packageName: pkg.packageName,
13
- version: pkg.version
14
- })));
15
- Logger.log(Logger.SUCCESS_TYPE, 'Package are installed By from workers:', results.join('\n'));
16
- } catch (error) {
17
- Logger.log(Logger.FAILURE_TYPE, 'Error:', error);
18
- }
19
- }
20
- function runWorker(data) {
21
- return new Promise((resolve, reject) => {
22
- const worker = new Worker(`${__dirname}/worker.js`, {
23
- workerData: data
24
- });
25
- worker.on('message', result => {
26
- resolve(result);
27
- });
28
- worker.on('error', error => {
29
- reject(error);
30
- });
31
- worker.on('exit', code => {
32
- if (code !== 0) {
33
- reject(new Error(`Worker stopped with exit code ${code}`));
34
- }
35
- });
36
- });
37
- }
38
- module.exports = installPluginsByWorker;
@@ -1,33 +0,0 @@
1
- "use strict";
2
-
3
- const {
4
- workerData,
5
- parentPort
6
- } = require('worker_threads');
7
- const {
8
- spawnSync
9
- } = require('child_process');
10
- const {
11
- getNodeModulesPath
12
- } = require('../../General/getNodeModulesPath');
13
- function performanceInstalllation({
14
- packageName,
15
- version
16
- }) {
17
- const start = performance.now();
18
- try {
19
- require.resolve(packageName);
20
- } catch (err) {
21
- spawnSync('npm', ['install', `${packageName}@${version}`, '--no-save'], {
22
- stdio: 'inherit',
23
- cwd: getNodeModulesPath()
24
- });
25
- }
26
- const end = performance.now();
27
- return `Package ${packageName}@${version} installed successfully and installed in ${end - start} ms`;
28
- }
29
- const result = performanceInstalllation({
30
- packageName: workerData.packageName,
31
- version: workerData.version
32
- });
33
- parentPort.postMessage(result);