@zohodesk/react-cli 0.0.1-beta.99 → 0.0.1-betaa.138.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (202) hide show
  1. package/.eslintignore +7 -7
  2. package/.eslintrc.js +183 -183
  3. package/CHANGELOG.md +5 -0
  4. package/README.md +636 -491
  5. package/bin/cli.js +372 -367
  6. package/files/eslintrc.js +57 -0
  7. package/files/prettierrc.js +3 -0
  8. package/lib/babel/cmjs-plugins-presets.js +16 -9
  9. package/lib/babel/es-plugins-presets.js +26 -14
  10. package/lib/common/getEntries.js +31 -22
  11. package/lib/common/getPublicPathConfig.js +27 -13
  12. package/lib/common/index.js +21 -25
  13. package/lib/common/splitChunks.js +62 -53
  14. package/lib/common/templateParameters.js +10 -8
  15. package/lib/configs/jest.config.js +15 -25
  16. package/lib/configs/webpack.component.umd.config.js +31 -37
  17. package/lib/configs/webpack.css.umd.config.js +44 -47
  18. package/lib/configs/webpack.dev.config.js +70 -52
  19. package/lib/configs/webpack.docs.config.js +106 -106
  20. package/lib/configs/webpack.prod.config.js +95 -75
  21. package/lib/hooks/docsProptypeHook.js +32 -38
  22. package/lib/jest/commitedFilesResult.js +103 -74
  23. package/lib/jest/coverageCollector.js +41 -21
  24. package/lib/jest/jsonMaker.js +15 -16
  25. package/lib/jest/preProcessors/cssPreprocessor.js +16 -18
  26. package/lib/jest/preProcessors/jsPreprocessor.js +3 -5
  27. package/lib/jest/preProcessors/otherFilesPreprocessor.js +5 -6
  28. package/lib/jest/result.js +90 -45
  29. package/lib/jest/run.js +43 -43
  30. package/lib/jest/setup.js +102 -95
  31. package/lib/loaderUtils/getCSSLoaders.js +21 -22
  32. package/lib/loaderUtils/getDevJsLoaders.js +25 -23
  33. package/lib/loaderUtils/index.js +11 -13
  34. package/lib/loaders/docsLoader.js +15 -15
  35. package/lib/loaders/docsPropsLoader.js +14 -17
  36. package/lib/loaders/fileLoader.js +33 -35
  37. package/lib/loaders/scriptInstrumentLoader.js +21 -20
  38. package/lib/loaders/workerLoader.js +136 -0
  39. package/lib/middlewares/HMRMiddleware.js +54 -45
  40. package/lib/middlewares/SSTMiddleware.js +8 -5
  41. package/lib/pluginUtils/getDevPlugins.js +114 -52
  42. package/lib/pluginUtils/getDocsPlugins.js +25 -29
  43. package/lib/pluginUtils/getLibraryPlugins.js +8 -10
  44. package/lib/pluginUtils/getProdPlugins.js +163 -74
  45. package/lib/pluginUtils/getServerPlugins.js +8 -11
  46. package/lib/pluginUtils/getUMDCSSPlugins.js +11 -15
  47. package/lib/pluginUtils/getUMDComponentPlugins.js +11 -15
  48. package/lib/pluginUtils/index.js +36 -43
  49. package/lib/plugins/CdnChangePlugin.js +63 -0
  50. package/lib/plugins/CleanupStatsPlugin.js +18 -32
  51. package/lib/plugins/CustomAttributePlugin.js +79 -0
  52. package/lib/plugins/CustomAttributePlugin.md +35 -0
  53. package/lib/plugins/EFCPlugin.js +185 -0
  54. package/lib/plugins/I18NInjectIntoIndexPlugin.js +118 -52
  55. package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +60 -0
  56. package/lib/plugins/I18nSplitPlugin/I18nDependency.js +44 -0
  57. package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +266 -0
  58. package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +183 -0
  59. package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +100 -0
  60. package/lib/plugins/I18nSplitPlugin/I18nSplit.md +86 -0
  61. package/lib/plugins/I18nSplitPlugin/README.md +25 -0
  62. package/lib/plugins/I18nSplitPlugin/index.js +185 -0
  63. package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +64 -0
  64. package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +13 -0
  65. package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +26 -0
  66. package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +40 -0
  67. package/lib/plugins/I18nSplitPlugin/utils/index.js +31 -0
  68. package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +112 -0
  69. package/lib/plugins/ManifestPlugin.js +52 -63
  70. package/lib/plugins/ModuleStatsPlugin.js +83 -173
  71. package/lib/plugins/OptimizeJSPlugin.js +24 -41
  72. package/lib/plugins/PublicPathCallbackPlugin.js +42 -116
  73. package/lib/plugins/PublicPathChangePlugin.js +175 -284
  74. package/lib/plugins/ReportGeneratePlugin.js +150 -151
  75. package/lib/plugins/ResourceHintsPlugin.js +53 -35
  76. package/lib/plugins/ScriptInstrumentPlugin.js +22 -37
  77. package/lib/plugins/ServiceWorkerPlugin.js +81 -57
  78. package/lib/plugins/ShadowDOMSupportPlugin.js +153 -234
  79. package/lib/plugins/SourceMapHookPlugin.js +21 -33
  80. package/lib/plugins/TPHashMappingPlugin.js +67 -0
  81. package/lib/plugins/UglifyCSSPlugin.js +23 -30
  82. package/lib/plugins/UnusedFilesFindPlugin.js +137 -152
  83. package/lib/plugins/index.js +100 -91
  84. package/lib/plugins/webpackwatchrunplugin.js +18 -30
  85. package/lib/postcss-plugins/ExcludeRTLPlugin.js +14 -17
  86. package/lib/schemas/index.js +336 -81
  87. package/lib/servers/clusterHubServer.js +22 -26
  88. package/lib/servers/docsServer.js +3 -5
  89. package/lib/servers/docsServerCore.js +84 -91
  90. package/lib/servers/helpServer.js +19 -21
  91. package/lib/servers/impactServer.js +99 -92
  92. package/lib/servers/mockserver.js +24 -24
  93. package/lib/servers/scrServer.js +78 -98
  94. package/lib/servers/server.js +101 -122
  95. package/lib/servers/ssServer.js +63 -61
  96. package/lib/sh/pre-commit.sh +34 -34
  97. package/lib/sh/reportPublish.sh +45 -46
  98. package/lib/templates/CoverageScriptTemplate.js +45 -18
  99. package/lib/templates/WMSTemplate.js +17 -18
  100. package/lib/templates/linterConstant.js +6 -4
  101. package/lib/utils/babelPresets.js +12 -5
  102. package/lib/utils/buildstats.html +148 -148
  103. package/lib/utils/clean.js +12 -11
  104. package/lib/utils/copy.js +12 -34
  105. package/lib/utils/copyTimezones.js +9 -16
  106. package/lib/utils/createEventStream.js +24 -19
  107. package/lib/utils/cssClassNameGenerate.js +44 -73
  108. package/lib/utils/cssURLReplacer.js +60 -54
  109. package/lib/utils/dependencyPostPublish.js +20 -19
  110. package/lib/utils/fileUtils.js +66 -54
  111. package/lib/utils/folderIterator.js +20 -21
  112. package/lib/utils/getComponents.js +70 -27
  113. package/lib/utils/getCurrentBranch.js +11 -17
  114. package/lib/utils/getDependenciesImpactList.js +114 -187
  115. package/lib/utils/getHash.js +9 -13
  116. package/lib/utils/getIp.js +9 -9
  117. package/lib/utils/getOptions.js +26 -29
  118. package/lib/utils/getServerURL.js +19 -10
  119. package/lib/utils/index.js +147 -126
  120. package/lib/utils/init.js +2 -2
  121. package/lib/utils/initPreCommitHook.js +40 -32
  122. package/lib/utils/jsonHelper.js +37 -21
  123. package/lib/utils/lint/addScripts.js +27 -0
  124. package/lib/utils/lint/checkExistingConfig.js +67 -0
  125. package/lib/utils/lint/copyConfigs.js +24 -0
  126. package/lib/utils/lint/index.js +54 -0
  127. package/lib/utils/lint/lintScripts.js +11 -0
  128. package/lib/utils/lint/lintSetup.js +31 -0
  129. package/lib/utils/lint/lintStagedPreCommitHook.js +7 -0
  130. package/lib/utils/lint/question.js +30 -0
  131. package/lib/utils/lintReporter.js +70 -56
  132. package/lib/utils/mailSender.js +12 -27
  133. package/lib/utils/pullOrigin.js +21 -18
  134. package/lib/utils/reinstallDependencies.js +76 -85
  135. package/lib/utils/removeAttributes.js +25 -23
  136. package/lib/utils/repoClone.js +47 -45
  137. package/lib/utils/request.js +64 -77
  138. package/lib/utils/resultSchema.json +73 -73
  139. package/lib/utils/rtl.js +22 -29
  140. package/lib/utils/setEnvVariables.js +5 -6
  141. package/lib/utils/ssTestHack.js +21 -19
  142. package/lib/utils/switchBranch.js +21 -20
  143. package/lib/utils/urlConcat.js +22 -0
  144. package/package.json +141 -136
  145. package/templates/app/.eslintrc.js +140 -140
  146. package/templates/app/README.md +12 -12
  147. package/templates/app/app/index.html +24 -24
  148. package/templates/app/app/properties/ApplicationResources_en_US.properties +1 -1
  149. package/templates/app/app/properties/i18nkeys.json +3 -3
  150. package/templates/app/docs/all.html +69 -69
  151. package/templates/app/mockapi/index.js +18 -18
  152. package/templates/app/package.json +37 -37
  153. package/templates/app/src/actions/SampleActions/index.js +37 -37
  154. package/templates/app/src/actions/index.js +65 -65
  155. package/templates/app/src/appUrls.js +19 -19
  156. package/templates/app/src/components/Alert/Alert.js +134 -134
  157. package/templates/app/src/components/Alert/Alert.module.css +79 -79
  158. package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -37
  159. package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -84
  160. package/templates/app/src/components/Sample/Sample.module.css +11 -11
  161. package/templates/app/src/components/Sample/SampleList.js +61 -61
  162. package/templates/app/src/components/Slider/Slider.css +41 -41
  163. package/templates/app/src/components/Slider/Slider.js +55 -55
  164. package/templates/app/src/containers/AlertContainer/index.js +15 -15
  165. package/templates/app/src/containers/AppContainer/index.js +96 -96
  166. package/templates/app/src/containers/AppContainer/index.module.css +27 -27
  167. package/templates/app/src/containers/CustomMatch/index.js +65 -65
  168. package/templates/app/src/containers/DevTools/index.js +10 -10
  169. package/templates/app/src/containers/Header/index.js +67 -67
  170. package/templates/app/src/containers/Header/index.module.css +43 -43
  171. package/templates/app/src/containers/Redirect/index.js +63 -63
  172. package/templates/app/src/containers/Redirector/index.js +47 -47
  173. package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -42
  174. package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -3
  175. package/templates/app/src/historyChange.js +5 -5
  176. package/templates/app/src/index.html +10 -10
  177. package/templates/app/src/index.js +24 -24
  178. package/templates/app/src/middleware/PromiseMiddleware.js +59 -59
  179. package/templates/app/src/reducers/alertData.js +11 -11
  180. package/templates/app/src/reducers/index.js +6 -6
  181. package/templates/app/src/reducers/samples.js +19 -19
  182. package/templates/app/src/store/configureStore.dev.js +51 -51
  183. package/templates/app/src/store/configureStore.js +5 -5
  184. package/templates/app/src/store/configureStore.prod.js +26 -26
  185. package/templates/app/src/util/Common.js +5 -5
  186. package/templates/app/src/util/RequestAPI.js +132 -132
  187. package/templates/docs/all.html +249 -249
  188. package/templates/docs/component.html +178 -178
  189. package/templates/docs/components.html +221 -221
  190. package/templates/docs/css/b.min.css +6 -6
  191. package/templates/docs/css/component.css +42 -42
  192. package/templates/docs/css/componentTest.css +6 -6
  193. package/templates/docs/css/hopscotch.css +585 -585
  194. package/templates/docs/css/style.css +1022 -1022
  195. package/templates/docs/index.html +1493 -1493
  196. package/templates/docs/js/active-line.js +72 -72
  197. package/templates/docs/js/b.min.js +7 -7
  198. package/templates/docs/js/codemirror.js +9680 -9680
  199. package/templates/docs/js/designTokens.js +334 -334
  200. package/templates/docs/js/j.min.js +4 -4
  201. package/templates/docs/js/javascript.js +874 -874
  202. package/templates/docs/js/matchbrackets.js +145 -145
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _webpack = require("webpack");
9
+
10
+ var _fs = _interopRequireDefault(require("fs"));
11
+
12
+ var _path = _interopRequireDefault(require("path"));
13
+
14
+ var _crypto = _interopRequireDefault(require("crypto"));
15
+
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+
18
+ /**
19
+ * Plugin that generates hash for the provided list of third party files
20
+ * Map the provided key with the file hash and add it to the list of exisiting global constants.
21
+ * Plugin in turn uses the defineplugin to generate global constants.
22
+ */
23
+ class TPHashMappingPlugin {
24
+ constructor(options) {
25
+ this.fileMappings = options.fileMappings;
26
+ this.tpFolder = options.tpFolder;
27
+ return new _webpack.DefinePlugin(this.getFiles());
28
+ }
29
+
30
+ getHash(content) {
31
+ let hash = _crypto.default.createHash('md5');
32
+
33
+ let data = hash.update(content, 'utf-8');
34
+ let gen_hash = data.digest('hex');
35
+ return gen_hash;
36
+ }
37
+
38
+ getFiles() {
39
+ let hashMapping = {};
40
+ this.fileMappings.forEach(fileInfo => {
41
+ let filePath = `${_path.default.join(this.tpFolder, fileInfo.filePath, fileInfo.fileName)}`;
42
+
43
+ if (_fs.default.existsSync(filePath)) {
44
+ let fileContent = _fs.default.readFileSync(filePath, {
45
+ encoding: 'utf-8'
46
+ });
47
+
48
+ let generatedHash = this.getHash(fileContent);
49
+ let outputFileSplit = fileInfo.fileName.split('.');
50
+ outputFileSplit.splice(outputFileSplit.length - 1, 0, generatedHash);
51
+ let outputFileName = outputFileSplit.join('.');
52
+ let outputFilePath = `${_path.default.join(this.tpFolder, fileInfo.filePath, outputFileName)}`;
53
+
54
+ _fs.default.writeFileSync(outputFilePath, fileContent);
55
+
56
+ hashMapping[fileInfo.key] = JSON.stringify(generatedHash);
57
+ } else {
58
+ throw new Error(`Third party file ${fileInfo.fileName} does not exist`);
59
+ }
60
+ });
61
+ return hashMapping;
62
+ }
63
+
64
+ }
65
+
66
+ var _default = TPHashMappingPlugin;
67
+ exports.default = _default;
@@ -1,46 +1,39 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.default = void 0;
6
7
 
7
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
8
+ var _webpackSources = require("webpack-sources");
8
9
 
9
- var _webpackSources = require('webpack-sources');
10
-
11
- var _uglifycss = require('uglifycss');
12
-
13
- var _uglifycss2 = _interopRequireDefault(_uglifycss);
10
+ var _uglifycss = _interopRequireDefault(require("uglifycss"));
14
11
 
15
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
13
 
17
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
18
-
19
- var UglifyCSSPlugin = function () {
20
- function UglifyCSSPlugin() {
21
- _classCallCheck(this, UglifyCSSPlugin);
22
- }
14
+ class UglifyCSSPlugin {
15
+ apply(compiler) {
16
+ compiler.hooks.emit.tap('UglifyCSSPlugin', compilation => {
17
+ Object.keys(compilation.assets).forEach(filename => {
18
+ if (/\.css$/.test(filename)) {
19
+ try {
20
+ let asset = compilation.assets[filename].source();
23
21
 
24
- _createClass(UglifyCSSPlugin, [{
25
- key: 'apply',
26
- value: function apply(compiler) {
27
- compiler.hooks.emit.tap('UglifyCSSPlugin', function (compilation) {
28
- Object.keys(compilation.assets).forEach(function (filename) {
29
- if (/\.css$/.test(filename)) {
30
- try {
31
- var asset = compilation.assets[filename].source();
32
- var result = _uglifycss2.default.processString(asset);
33
- compilation.assets[filename] = new _webpackSources.RawSource(result);
34
- } catch (e) {
35
- compilation.errors.push(e);
22
+ if (typeof asset !== 'string') {
23
+ asset = asset.toString();
36
24
  }
25
+
26
+ const result = _uglifycss.default.processString(asset);
27
+
28
+ compilation.assets[filename] = new _webpackSources.RawSource(result);
29
+ } catch (e) {
30
+ compilation.errors.push(e);
37
31
  }
38
- });
32
+ }
39
33
  });
40
- }
41
- }]);
34
+ });
35
+ }
42
36
 
43
- return UglifyCSSPlugin;
44
- }();
37
+ }
45
38
 
46
39
  exports.default = UglifyCSSPlugin;
@@ -1,48 +1,35 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.default = void 0;
6
7
 
7
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
8
+ var _path = _interopRequireDefault(require("path"));
8
9
 
9
- var _path = require('path');
10
+ var _fs = _interopRequireDefault(require("fs"));
10
11
 
11
- var _path2 = _interopRequireDefault(_path);
12
-
13
- var _fs = require('fs');
14
-
15
- var _fs2 = _interopRequireDefault(_fs);
16
-
17
- var _utils = require('../utils');
12
+ var _utils = require("../utils");
18
13
 
19
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
15
 
21
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
16
+ let excludeDocsJSON = '{}';
17
+
18
+ if (_fs.default.existsSync('./__testUtils__/conf/excludeDocs.json')) {
19
+ excludeDocsJSON = _fs.default.readFileSync('./__testUtils__/conf/excludeDocs.json').toString();
22
20
 
23
- var excludeDocsJSON = '{}';
24
- if (_fs2.default.existsSync('./__testUtils__/conf/excludeDocs.json')) {
25
- excludeDocsJSON = _fs2.default.readFileSync('./__testUtils__/conf/excludeDocs.json').toString();
26
21
  if (excludeDocsJSON.indexOf('\\') !== -1) {
27
22
  excludeDocsJSON = excludeDocsJSON.replace(/\\/g, '\\\\');
28
23
  }
29
24
  }
30
- var excludeDocsArray = JSON.parse(excludeDocsJSON);
31
- // if (Object.keys(excludeDocsArray).length > 0) {
32
- // }
33
-
34
- var getRegex = function getRegex(regexString) {
35
- return regexString.map(function (str) {
36
- return new RegExp(str);
37
- });
38
- };
39
25
 
40
- var UnusedFilesFindPlugin = function () {
41
- function UnusedFilesFindPlugin() {
42
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
26
+ let excludeDocsArray = JSON.parse(excludeDocsJSON); // if (Object.keys(excludeDocsArray).length > 0) {
27
+ // }
43
28
 
44
- _classCallCheck(this, UnusedFilesFindPlugin);
29
+ let getRegex = regexString => regexString.map(str => new RegExp(str));
45
30
 
31
+ class UnusedFilesFindPlugin {
32
+ constructor(options = {}) {
46
33
  this.usedFilesExcludes = getRegex(options.usedFilesExcludes);
47
34
  this.appFilesExcludes = getRegex(options.appFilesExcludes);
48
35
  this.origin = options.origin;
@@ -50,157 +37,155 @@ var UnusedFilesFindPlugin = function () {
50
37
  this.sstest = options.ssTest || false;
51
38
  this.outputFileName = options.outputFileName;
52
39
  this.docsFilename = options.docsFilename || 'Undocsfiles.json';
40
+
53
41
  if (!this.origin) {
54
42
  throw new Error('You must provide origin point of the app');
55
43
  }
56
44
  }
57
45
 
58
- _createClass(UnusedFilesFindPlugin, [{
59
- key: 'isIgnoredUsedFile',
60
- value: function isIgnoredUsedFile(file) {
61
- var result = void 0;
62
- for (var i = 0; i < this.usedFilesExcludes.length; i++) {
63
- var exclude = this.usedFilesExcludes[i];
64
- result = exclude.test(file);
65
- if (result) {
66
- break;
67
- }
46
+ isIgnoredUsedFile(file) {
47
+ let result;
48
+
49
+ for (let i = 0; i < this.usedFilesExcludes.length; i++) {
50
+ let exclude = this.usedFilesExcludes[i];
51
+ result = exclude.test(file);
52
+
53
+ if (result) {
54
+ break;
68
55
  }
69
- return result;
70
56
  }
71
- }, {
72
- key: 'unDocumentedFiles',
73
- value: function unDocumentedFiles(outputPath) {
74
- var status = _fs2.default.existsSync(_path2.default.join(outputPath, this.outputFileName));
75
- var unDocsCompObj = {};
76
- if (status) {
77
- var data = _fs2.default.readFileSync(_path2.default.join(outputPath, this.outputFileName)).toString();
78
- var walkSync = function walkSync(dir) {
79
- var filelist = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
80
- var undocList = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
81
-
82
- var files = _fs2.default.readdirSync(dir);
83
- files.forEach(function (file) {
84
- if (_fs2.default.statSync(dir + '/' + file).isDirectory()) {
85
- filelist = walkSync(dir + '/' + file, filelist, undocList); //eslint-disable-line
57
+
58
+ return result;
59
+ }
60
+
61
+ unDocumentedFiles(outputPath) {
62
+ let status = _fs.default.existsSync(_path.default.join(outputPath, this.outputFileName));
63
+
64
+ let unDocsCompObj = {};
65
+
66
+ if (status) {
67
+ let data = _fs.default.readFileSync(_path.default.join(outputPath, this.outputFileName)).toString();
68
+
69
+ let walkSync = (dir, filelist = [], undocList = []) => {
70
+ let files = _fs.default.readdirSync(dir);
71
+
72
+ files.forEach(file => {
73
+ if (_fs.default.statSync(`${dir}/${file}`).isDirectory()) {
74
+ filelist = walkSync(`${dir}/${file}`, filelist, undocList); //eslint-disable-line
75
+ } else {
76
+ if (file.includes('.docs')) {
77
+ if (!(`${dir}/${file}` in JSON.parse(data))) {
78
+ filelist.push(`${dir.replace(_path.default.join(process.cwd(), 'src', 'components'), '')}/${file}`);
79
+ }
86
80
  } else {
87
- if (file.includes('.docs')) {
88
- if (!(dir + '/' + file in JSON.parse(data))) {
89
- filelist.push(dir.replace(_path2.default.join(process.cwd(), 'src', 'components'), '') + '/' + file);
90
- }
91
- } else {
92
- if (file.includes('.js') && !file.includes('.spec') && !file.includes('.json')) {
93
- if (!files.includes('docs')) {
94
- if (!excludeDocsArray.docs.exclude.includes(dir.replace(_path2.default.join(process.cwd(), 'src', 'components'), '') + '/' + file)) {
95
- undocList.push(dir.replace(_path2.default.join(process.cwd(), 'src', 'components'), '') + '/' + file);
96
- }
81
+ if (file.includes('.js') && !file.includes('.spec') && !file.includes('.json')) {
82
+ if (!files.includes('docs')) {
83
+ if (!excludeDocsArray.docs.exclude.includes(`${dir.replace(_path.default.join(process.cwd(), 'src', 'components'), '')}/${file}`)) {
84
+ undocList.push(`${dir.replace(_path.default.join(process.cwd(), 'src', 'components'), '')}/${file}`);
97
85
  }
98
86
  }
99
87
  }
100
88
  }
101
- });
102
- unDocsCompObj.withoutDocs = undocList;
103
- return filelist;
104
- };
105
- unDocsCompObj.noEnteredComp = walkSync(_path2.default.join(process.cwd(), 'src', 'components'), [], []);
106
-
107
- (0, _utils.writeFile)(_path2.default.join(outputPath, this.docsFilename), JSON.stringify(unDocsCompObj));
108
- Object.keys(unDocsCompObj).forEach(function (key) {
109
- if (unDocsCompObj[key].length > 0) {
110
- if (key === 'withoutDocs') {
111
- (0, _utils.log)('\x1b[36m%s\x1b[0m', '\nPlease write docs file for below componenst :- \n');
112
- unDocsCompObj[key].forEach(function (value) {
113
- if (!excludeDocsArray.docs.exclude.includes(value)) {
114
- (0, _utils.log)('\x1b[33m%s\x1b[0m', '' + value);
115
- }
116
- });
117
- }
118
89
  }
119
90
  });
120
- }
121
- }
122
- }, {
123
- key: 'isIgnoredAllFile',
124
- value: function isIgnoredAllFile(file) {
125
- var result = void 0;
126
- for (var i = 0; i < this.appFilesExcludes.length; i++) {
127
- var exclude = this.appFilesExcludes[i];
128
- result = exclude.test(file);
129
- if (result) {
130
- break;
131
- }
132
- }
133
- return result;
134
- }
135
- }, {
136
- key: 'getAllFiles',
137
- value: function getAllFiles(rootPath) {
138
- var _this = this;
139
-
140
- var allFiles = [];
141
- var files = _fs2.default.readdirSync(rootPath).map(function (file) {
142
- return _path2.default.join(rootPath, file);
143
- });
144
- files.forEach(function (file) {
145
- if (_fs2.default.statSync(file).isDirectory()) {
146
- allFiles = allFiles.concat(_this.getAllFiles(file));
147
- } else {
148
- if (!_this.isIgnoredAllFile(file)) {
149
- allFiles.push(file);
91
+ unDocsCompObj.withoutDocs = undocList;
92
+ return filelist;
93
+ };
94
+
95
+ unDocsCompObj.noEnteredComp = walkSync(_path.default.join(process.cwd(), 'src', 'components'), [], []);
96
+ (0, _utils.writeFile)(_path.default.join(outputPath, this.docsFilename), JSON.stringify(unDocsCompObj));
97
+ Object.keys(unDocsCompObj).forEach(key => {
98
+ if (unDocsCompObj[key].length > 0) {
99
+ if (key === 'withoutDocs') {
100
+ (0, _utils.log)('\x1b[36m%s\x1b[0m', '\nPlease write docs file for below componenst :- \n');
101
+ unDocsCompObj[key].forEach(value => {
102
+ if (!excludeDocsArray.docs.exclude.includes(value)) {
103
+ (0, _utils.log)('\x1b[33m%s\x1b[0m', `${value}`);
104
+ }
105
+ });
150
106
  }
151
107
  }
152
108
  });
153
- return allFiles;
154
109
  }
155
- }, {
156
- key: 'apply',
157
- value: function apply(compiler) {
158
- var _this2 = this;
110
+ }
159
111
 
160
- compiler.hooks.afterEmit.tap('UnusedFilesShowPlugin', function (compilation) {
161
- var outputPath = compilation.compiler.options.output.path;
112
+ isIgnoredAllFile(file) {
113
+ let result;
162
114
 
163
- var usedFiles = Array.from(compilation.fileDependencies).reduce(function (files, usedFile) {
164
- if (!_this2.isIgnoredUsedFile(usedFile)) {
165
- files[usedFile] = true;
166
- }
167
- return files;
168
- }, {});
115
+ for (let i = 0; i < this.appFilesExcludes.length; i++) {
116
+ let exclude = this.appFilesExcludes[i];
117
+ result = exclude.test(file);
169
118
 
170
- var allFiles = _this2.getAllFiles(_this2.origin);
119
+ if (result) {
120
+ break;
121
+ }
122
+ }
171
123
 
172
- var unusedFiles = [];
173
- allFiles.forEach(function (file) {
174
- if (!usedFiles[file]) {
175
- unusedFiles.push(file);
176
- }
177
- });
124
+ return result;
125
+ }
178
126
 
179
- if (!unusedFiles.length) {
180
- (0, _utils.log)('There is no unused files');
181
- } else {
182
- if (_this2.outputFileName) {
183
- (0, _utils.log)('You can see unused files info from ' + _path2.default.join(outputPath, _this2.outputFileName) + ' path');
184
- (0, _utils.makeDir)(outputPath);
185
- (0, _utils.writeFile)(_path2.default.join(outputPath, _this2.outputFileName), JSON.stringify(unusedFiles)).then(function () {
186
- if (_this2.sstest) {
187
- _this2.unDocumentedFiles(outputPath);
188
- }
189
- });
190
- }
127
+ getAllFiles(rootPath) {
128
+ let allFiles = [];
129
+
130
+ let files = _fs.default.readdirSync(rootPath).map(file => _path.default.join(rootPath, file));
131
+
132
+ files.forEach(file => {
133
+ if (_fs.default.statSync(file).isDirectory()) {
134
+ allFiles = allFiles.concat(this.getAllFiles(file));
135
+ } else {
136
+ if (!this.isIgnoredAllFile(file)) {
137
+ allFiles.push(file);
138
+ }
139
+ }
140
+ });
141
+ return allFiles;
142
+ }
143
+
144
+ apply(compiler) {
145
+ compiler.hooks.afterEmit.tap('UnusedFilesShowPlugin', compilation => {
146
+ let {
147
+ path: outputPath
148
+ } = compilation.compiler.options.output;
149
+ let usedFiles = Array.from(compilation.fileDependencies).reduce((files, usedFile) => {
150
+ if (!this.isIgnoredUsedFile(usedFile)) {
151
+ files[usedFile] = true;
191
152
  }
192
153
 
193
- if (_this2.delete) {
194
- unusedFiles.forEach(function (file) {
195
- _fs2.default.unlinkSync(file);
196
- (0, _utils.log)('Deleted - ' + file);
197
- });
154
+ return files;
155
+ }, {});
156
+ let allFiles = this.getAllFiles(this.origin);
157
+ let unusedFiles = [];
158
+ allFiles.forEach(file => {
159
+ if (!usedFiles[file]) {
160
+ unusedFiles.push(file);
198
161
  }
199
162
  });
200
- }
201
- }]);
202
163
 
203
- return UnusedFilesFindPlugin;
204
- }();
164
+ if (!unusedFiles.length) {
165
+ (0, _utils.log)('There is no unused files');
166
+ } else {
167
+ if (this.outputFileName) {
168
+ (0, _utils.log)(`You can see unused files info from ${_path.default.join(outputPath, this.outputFileName)} path`);
169
+ (0, _utils.makeDir)(outputPath);
170
+ (0, _utils.writeFile)(_path.default.join(outputPath, this.outputFileName), JSON.stringify(unusedFiles)).then(() => {
171
+ if (this.sstest) {
172
+ this.unDocumentedFiles(outputPath);
173
+ }
174
+ });
175
+ }
176
+ }
177
+
178
+ if (this.delete) {
179
+ unusedFiles.forEach(file => {
180
+ _fs.default.unlinkSync(file);
181
+
182
+ (0, _utils.log)(`Deleted - ${file}`);
183
+ });
184
+ }
185
+ });
186
+ }
187
+
188
+ }
205
189
 
206
- exports.default = UnusedFilesFindPlugin;
190
+ var _default = UnusedFilesFindPlugin;
191
+ exports.default = _default;