@zohodesk/react-cli 0.0.1-beta.99 → 0.0.1-betaa.138.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 (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
@@ -1,84 +1,83 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
- var _path = require('path');
3
+ var _path = _interopRequireDefault(require("path"));
4
4
 
5
- var _path2 = _interopRequireDefault(_path);
5
+ var _utils = require("../utils");
6
6
 
7
- var _utils = require('../utils');
7
+ var _common = require("../common");
8
8
 
9
- var _common = require('../common');
9
+ var _pluginUtils = require("../pluginUtils");
10
10
 
11
- var _pluginUtils = require('../pluginUtils');
12
-
13
- var _loaderUtils = require('../loaderUtils');
11
+ var _loaderUtils = require("../loaderUtils");
14
12
 
15
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
14
 
17
- var options = (0, _utils.getOptions)();
18
-
19
- var _options$app = options.app,
20
- folder = _options$app.folder,
21
- context = _options$app.context,
22
- enableChunkHash = _options$app.enableChunkHash,
23
- outputFolder = _options$app.outputFolder,
24
- disableES5Transpile = _options$app.disableES5Transpile,
25
- removeAttribute = _options$app.removeAttribute,
26
- enableSMap = _options$app.enableSMap,
27
- server = _options$app.server,
28
- hasRTL = _options$app.hasRTL,
29
- rtlExclude = _options$app.rtlExclude,
30
- cssUniqueness = _options$app.cssUniqueness,
31
- mode = _options$app.server.mode,
32
- seperateCssModules = _options$app.seperateCssModules,
33
- changeRuntimeChunkChar = _options$app.changeRuntimeChunkChar,
34
- cssHashSelectors = _options$app.cssHashSelectors,
35
- classNamePrefix = _options$app.classNamePrefix,
36
- selectorReplace = _options$app.selectorReplace,
37
- removePropTypes = _options$app.removePropTypes;
38
-
39
-
40
- var appPath = process.cwd();
41
-
42
- var isDevelopment = mode === 'prod' || mode === 'dev' || mode === 'dev-no-warn';
15
+ let options = (0, _utils.getOptions)();
16
+ let {
17
+ app: {
18
+ folder,
19
+ context,
20
+ enableChunkHash,
21
+ outputFolder,
22
+ disableES5Transpile,
23
+ removeAttribute,
24
+ enableSMap,
25
+ server,
26
+ hasRTL,
27
+ rtlExclude,
28
+ cssUniqueness,
29
+ server: {
30
+ mode
31
+ },
32
+ seperateCssModules,
33
+ changeRuntimeChunkChar,
34
+ cssHashSelectors,
35
+ classNamePrefix,
36
+ selectorReplace,
37
+ removePropTypes
38
+ }
39
+ } = options;
40
+ let appPath = process.cwd();
41
+ let isDevelopment = mode === 'prod' || mode === 'dev' || mode === 'dev-no-warn';
43
42
  enableChunkHash = !isDevelopment && enableChunkHash;
44
-
45
- var output = {
46
- path: _path2.default.resolve(appPath, outputFolder),
43
+ let output = {
44
+ path: _path.default.resolve(appPath, outputFolder),
47
45
  filename: enableChunkHash ? './js/[name].[chunkhash:20]_.js' : './js/[name]_.js',
48
46
  chunkFilename: enableChunkHash ? './js/[name].[chunkhash:20]_.js' : './js/[name]_.js',
49
- jsonpFunction: context + 'Jsonp',
47
+ jsonpFunction: `${context}Jsonp`,
50
48
  sourceMapFilename: enableChunkHash ? 'smap/[name].[chunkhash:20]_.map' : 'smap/[name]_.map'
51
49
  };
52
50
 
53
51
  if (isDevelopment) {
54
- var disableContextURL = server.disableContextURL;
55
-
56
- var contextURL = disableContextURL ? '' : context;
57
- var serverUrl = (0, _utils.getServerURL)(server);
58
- output.publicPath = [serverUrl, contextURL].filter(function (a) {
59
- return a;
60
- }).join('/') + '/';
52
+ let {
53
+ disableContextURL
54
+ } = server;
55
+ let contextURL = disableContextURL ? '' : context;
56
+ let serverUrl = (0, _utils.getServerURL)(server, 'https');
57
+ output.publicPath = `${[serverUrl, contextURL].filter(a => a).join('/')}/`;
61
58
  }
62
59
 
63
- var shouldRemovePropTypes = !isDevelopment && removePropTypes;
64
-
60
+ let shouldRemovePropTypes = !isDevelopment && removePropTypes;
65
61
  module.exports = {
66
62
  entry: (0, _common.getEntries)(options, 'production'),
67
63
  devtool: isDevelopment ? 'cheap-module-source-map' : enableSMap ? 'hidden-source-map' : 'none',
68
64
  mode: 'production',
69
- output: output,
65
+ output,
70
66
  optimization: {
71
67
  splitChunks: _common.splitChunks,
72
68
  runtimeChunk: {
73
- name: function name(entrypoint) {
74
- return changeRuntimeChunkChar ? './runtime-' + entrypoint.name : './runtime~' + entrypoint.name;
75
- }
69
+ name: entrypoint => changeRuntimeChunkChar ? `./runtime-${entrypoint.name}` : `./runtime~${entrypoint.name}`
76
70
  },
77
71
  concatenateModules: true,
78
72
  minimize: true,
79
73
  moduleIds: 'named'
80
74
  },
81
- stats: { children: false },
75
+ stats: {
76
+ children: false,
77
+ colors: true,
78
+ // excludeAssets: /i18n/,
79
+ warningsFilter: /\[mini-css-extract-plugin\]/
80
+ },
82
81
  plugins: (0, _pluginUtils.getProdPlugins)(options, output.publicPath),
83
82
  module: {
84
83
  /* strictExportPresence for break the build when imported module not present in respective file */
@@ -88,23 +87,24 @@ module.exports = {
88
87
  use: [{
89
88
  loader: 'babel-loader',
90
89
  options: {
91
- presets: [[require.resolve('babel-preset-env'), disableES5Transpile ? {
90
+ presets: [[require.resolve('@babel/preset-env'), disableES5Transpile ? {
92
91
  modules: false,
93
- useBuiltIns: true,
92
+ useBuiltIns: 'usage',
93
+ corejs: 3,
94
94
  targets: {
95
- browsers: ['Chrome >= 60', 'Safari >= 10.1', 'iOS >= 10.3', 'Firefox >= 54', 'Edge >= 15']
95
+ browsers: ['last 3 Chrome versions', 'last 3 Firefox versions', 'last 3 Edge versions', 'last 3 Safari versions']
96
96
  }
97
- } : { modules: false }], require.resolve('babel-preset-react')],
98
- plugins: disableES5Transpile ? [removeAttribute ? require.resolve('../utils/removeAttributes') : false, require.resolve('babel-plugin-syntax-dynamic-import'), require.resolve('babel-plugin-lodash'), require.resolve('babel-plugin-syntax-object-rest-spread'), shouldRemovePropTypes ? [require.resolve('babel-plugin-transform-react-remove-prop-types'), removePropTypes] : false].filter(Boolean) : [removeAttribute ? require.resolve('../utils/removeAttributes') : false, [require.resolve('babel-plugin-transform-runtime'), {
97
+ } : {
98
+ modules: false
99
+ }], require.resolve('@babel/preset-react')],
100
+ plugins: disableES5Transpile ? [removeAttribute ? require.resolve('../utils/removeAttributes') : false, require.resolve('@babel/plugin-syntax-dynamic-import'), require.resolve('babel-plugin-lodash'), require.resolve('@babel/plugin-proposal-object-rest-spread')].filter(Boolean) : [removeAttribute ? require.resolve('../utils/removeAttributes') : false, shouldRemovePropTypes ? [require.resolve('babel-plugin-transform-react-remove-prop-types'), removePropTypes] : false[(require.resolve('@babel/plugin-transform-runtime'), {
99
101
  helpers: true,
100
- polyfill: true,
101
- regenerator: false,
102
- moduleName: 'babel-runtime'
103
- }], require.resolve('babel-plugin-syntax-dynamic-import'), require.resolve('babel-plugin-lodash'), require.resolve('babel-plugin-syntax-object-rest-spread'), shouldRemovePropTypes ? [require.resolve('babel-plugin-transform-react-remove-prop-types'), removePropTypes] : false].filter(Boolean),
102
+ regenerator: false
103
+ }, require.resolve('@babel/plugin-proposal-object-rest-spread'))], require.resolve('@babel/plugin-syntax-dynamic-import'), require.resolve('babel-plugin-lodash')].filter(Boolean),
104
104
  cacheDirectory: true
105
105
  }
106
106
  }],
107
- include: _path2.default.join(appPath, folder)
107
+ include: _path.default.join(appPath, folder)
108
108
  }, seperateCssModules ? {
109
109
  test: /\.css$/,
110
110
  exclude: /\.module\.css$/,
@@ -119,7 +119,7 @@ module.exports = {
119
119
  options: {
120
120
  limit: 1000,
121
121
  name: enableChunkHash ? './images/[name].[hash:20].[ext]' : './images/[name].[ext]',
122
- fallback: _path2.default.join(__dirname, '..', 'loaders', 'fileLoader.js')
122
+ fallback: _path.default.join(__dirname, '..', 'loaders', 'fileLoader.js')
123
123
  }
124
124
  }]
125
125
  }, {
@@ -129,7 +129,7 @@ module.exports = {
129
129
  options: {
130
130
  limit: 1000,
131
131
  name: enableChunkHash ? './fonts/[name].[hash:20].[ext]' : './fonts/[name].[ext]',
132
- fallback: _path2.default.join(__dirname, '..', 'loaders', 'fileLoader.js')
132
+ fallback: _path.default.join(__dirname, '..', 'loaders', 'fileLoader.js')
133
133
  }
134
134
  }]
135
135
  }, {
@@ -139,7 +139,7 @@ module.exports = {
139
139
  options: {
140
140
  limit: 1,
141
141
  name: enableChunkHash ? './fonts/[name].[hash:20].[ext]' : './fonts/[name].[ext]',
142
- fallback: _path2.default.join(__dirname, '..', 'loaders', 'fileLoader.js')
142
+ fallback: _path.default.join(__dirname, '..', 'loaders', 'fileLoader.js')
143
143
  }
144
144
  }]
145
145
  }, {
@@ -155,25 +155,45 @@ module.exports = {
155
155
  use: [{
156
156
  loader: 'html-loader',
157
157
  options: {
158
- interpolate: 'require',
159
- ignoreCustomFragments: [/\{\{.*?}}/, /\$\{.*?}/],
160
- minimize: true,
161
- removeComments: true,
162
- collapseWhitespace: false,
163
- removeAttributeQuotes: false,
164
- minifyCSS: false,
165
- minifyJS: false
158
+ minimize: false
166
159
  }
167
160
  }]
161
+ }, {
162
+ test: /\.worker.js$/,
163
+ use: {
164
+ loader: require.resolve('../loaders/workerLoader.js'),
165
+ options: {
166
+ esModule: true,
167
+ filename: 'js/[name].[chunkhash:20].js'
168
+ }
169
+ }
168
170
  }].filter(Boolean)
169
171
  },
170
172
  externals: {
171
173
  ZC: '$ZC'
172
174
  },
173
175
  resolve: {
174
- modules: [_path2.default.resolve(__dirname, '..', '..', 'node_modules'), 'node_modules']
176
+ modules: [_path.default.resolve(__dirname, '..', '..', 'node_modules'), 'node_modules'],
177
+ alias: disableES5Transpile ? {
178
+ '@zohodesk/components/lib': '@zohodesk/components/es',
179
+ '@zohodesk/dot/lib': '@zohodesk/dot/es',
180
+ '@zohodesk/i18n/lib': '@zohodesk/i18n/es',
181
+ '@zohodesk/icons/lib': '@zohodesk/icons/es',
182
+ '@zohodesk/normalizer/lib': '@zohodesk/normalizer/es',
183
+ '@zohodesk/perf-components/lib': '@zohodesk/perf-components/es',
184
+ '@zohodesk/perf-middleware/lib': '@zohodesk/perf-middleware/es',
185
+ '@zohodesk/permissions/lib': '@zohodesk/permissions/es',
186
+ '@zohodesk/platform-middleware/lib': '@zohodesk/platform-middleware/es',
187
+ '@zohodesk/react-dnd/lib': '@zohodesk/react-dnd/es',
188
+ '@zohodesk/router-middleware/lib': '@zohodesk/router-middleware/es',
189
+ '@zohodesk/storage/lib': '@zohodesk/storage/es',
190
+ '@zohodesk/svg/lib': '@zohodesk/svg/es',
191
+ '@zohodesk/timetracker/lib': '@zohodesk/timetracker/es',
192
+ '@zohodesk/variables/lib': '@zohodesk/variables/es',
193
+ '@zohodesk/virtualizer/lib': '@zohodesk/virtualizer/es'
194
+ } : {}
175
195
  },
176
196
  resolveLoader: {
177
- modules: [_path2.default.resolve(__dirname, '..', '..', 'node_modules'), 'node_modules']
197
+ modules: [_path.default.resolve(__dirname, '..', '..', 'node_modules'), 'node_modules']
178
198
  }
179
199
  };
@@ -1,51 +1,45 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
- var _propTypes = require('prop-types');
4
-
5
- var _propTypes2 = _interopRequireDefault(_propTypes);
3
+ var _propTypes = _interopRequireDefault(require("prop-types"));
6
4
 
7
5
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
6
 
9
- _propTypes2.default.array.hookType = 'array';
10
- _propTypes2.default.bool.hookType = 'bool';
11
- _propTypes2.default.func.hookType = 'func';
12
- _propTypes2.default.number.hookType = 'number';
13
- _propTypes2.default.object.hookType = 'object';
14
- _propTypes2.default.string.hookType = 'string';
15
- _propTypes2.default.symbol.hookType = 'symbol';
16
- _propTypes2.default.element.hookType = 'element';
17
- _propTypes2.default.node.hookType = 'element';
18
- _propTypes2.default.array.isRequired.hookType = 'array';
19
- _propTypes2.default.bool.isRequired.hookType = 'bool';
20
- _propTypes2.default.func.isRequired.hookType = 'func';
21
- _propTypes2.default.number.isRequired.hookType = 'number';
22
- _propTypes2.default.object.isRequired.hookType = 'object';
23
- _propTypes2.default.string.isRequired.hookType = 'string';
24
- _propTypes2.default.symbol.isRequired.hookType = 'symbol';
25
- _propTypes2.default.element.isRequired.hookType = 'element';
26
- _propTypes2.default.node.isRequired.hookType = 'element';
27
- function proxy(fn, type) {
28
- var oneOf = fn;
29
- return function () {
30
- for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
31
- args[_key] = arguments[_key];
32
- }
7
+ _propTypes.default.array.hookType = 'array';
8
+ _propTypes.default.bool.hookType = 'bool';
9
+ _propTypes.default.func.hookType = 'func';
10
+ _propTypes.default.number.hookType = 'number';
11
+ _propTypes.default.object.hookType = 'object';
12
+ _propTypes.default.string.hookType = 'string';
13
+ _propTypes.default.symbol.hookType = 'symbol';
14
+ _propTypes.default.element.hookType = 'element';
15
+ _propTypes.default.node.hookType = 'element';
16
+ _propTypes.default.array.isRequired.hookType = 'array';
17
+ _propTypes.default.bool.isRequired.hookType = 'bool';
18
+ _propTypes.default.func.isRequired.hookType = 'func';
19
+ _propTypes.default.number.isRequired.hookType = 'number';
20
+ _propTypes.default.object.isRequired.hookType = 'object';
21
+ _propTypes.default.string.isRequired.hookType = 'string';
22
+ _propTypes.default.symbol.isRequired.hookType = 'symbol';
23
+ _propTypes.default.element.isRequired.hookType = 'element';
24
+ _propTypes.default.node.isRequired.hookType = 'element';
33
25
 
34
- var a = oneOf.apply(undefined, args);
35
- var type1 = Array.isArray(args) && Array.isArray(args[0]) ? type + '[' + args[0].map(function (data) {
36
- return typeof data === 'function' ? data.hookType //arrayOf shape complex type not mention
37
- : JSON.stringify(data);
38
- }) + ']' : type;
26
+ function proxy(fn, type) {
27
+ let oneOf = fn;
28
+ return (...args) => {
29
+ let a = oneOf(...args);
30
+ let type1 = Array.isArray(args) && Array.isArray(args[0]) ? `${type}[${args[0].map(data => typeof data === 'function' ? data.hookType //arrayOf shape complex type not mention
31
+ : JSON.stringify(data))}]` : type;
39
32
  a.hookType = type1;
33
+
40
34
  if (a.isRequired) {
41
35
  a.isRequired.hookType = type1;
42
36
  }
37
+
43
38
  return a;
44
39
  };
45
40
  }
46
- _propTypes2.default.oneOf = proxy(_propTypes2.default.oneOf, 'enum');
47
- _propTypes2.default.oneOfType = proxy(_propTypes2.default.oneOfType, 'union');
48
- _propTypes2.default.arrayOf = proxy(_propTypes2.default.arrayOf, 'arrayOf');
49
- _propTypes2.default.shape = proxy(_propTypes2.default.shape, 'shape');
50
41
 
51
- // export default PropTypes;
42
+ _propTypes.default.oneOf = proxy(_propTypes.default.oneOf, 'enum');
43
+ _propTypes.default.oneOfType = proxy(_propTypes.default.oneOfType, 'union');
44
+ _propTypes.default.arrayOf = proxy(_propTypes.default.arrayOf, 'arrayOf');
45
+ _propTypes.default.shape = proxy(_propTypes.default.shape, 'shape'); // export default PropTypes;
@@ -1,171 +1,200 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
- var _fs = require('fs');
3
+ var _fs = _interopRequireDefault(require("fs"));
4
4
 
5
- var _fs2 = _interopRequireDefault(_fs);
5
+ var _utils = require("../utils");
6
6
 
7
- var _utils = require('../utils');
7
+ var _jsonMaker = _interopRequireDefault(require("./jsonMaker"));
8
8
 
9
- var _jsonMaker = require('./jsonMaker');
10
-
11
- var _jsonMaker2 = _interopRequireDefault(_jsonMaker);
12
-
13
- var _jsonHelper = require('../utils/jsonHelper');
9
+ var _jsonHelper = require("../utils/jsonHelper");
14
10
 
15
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
12
 
17
- var result = function result(inp) {
13
+ let result = inp => {
18
14
  inp.endTime = Date.now();
19
- var testPathPattern = process.argv[process.argv.length - 1];
15
+ let testPathPattern = process.argv[process.argv.length - 1];
20
16
 
21
17
  if (testPathPattern.indexOf('--') !== -1) {
22
18
  testPathPattern = '';
23
19
  } else {
24
- testPathPattern = _fs2.default.realpathSync(process.cwd());
20
+ testPathPattern = _fs.default.realpathSync(process.cwd());
25
21
  }
26
- var testPathRegex = new RegExp(testPathPattern);
27
- var testResults = inp.testResults;
28
22
 
29
- var testFilesArr = [];
30
- var testCaseFiles = [];
31
- var jsonData = void 0;
23
+ let testPathRegex = new RegExp(testPathPattern);
24
+ let {
25
+ testResults
26
+ } = inp;
27
+ let testFilesArr = [];
28
+ let testCaseFiles = [];
29
+ let jsonData;
32
30
 
33
- if (_fs2.default.existsSync('./coverageTest/result.json')) {
34
- jsonData = JSON.parse(_fs2.default.readFileSync('./coverageTest/result.json', 'utf8'));
31
+ if (_fs.default.existsSync('./coverageTest/result.json')) {
32
+ jsonData = JSON.parse(_fs.default.readFileSync('./coverageTest/result.json', 'utf8'));
35
33
  }
36
- testResults.forEach(function (testResult) {
37
- var filePath = testResult.testFilePath;
34
+
35
+ testResults.forEach(testResult => {
36
+ let filePath = testResult.testFilePath;
38
37
 
39
38
  if (!testPathRegex.test(filePath)) {
40
39
  return;
41
40
  }
41
+
42
42
  filePath = filePath.replace('.spec', '');
43
43
  filePath = filePath.replace('/__tests__', '');
44
44
  filePath = filePath.replace('/__test__', '');
45
- var relatPath = filePath.replace(process.cwd(), '').substring(1);
46
- var fileJson = {};
45
+ let relatPath = filePath.replace(process.cwd(), '').substring(1);
46
+ let fileJson = {};
47
47
  fileJson.testPath = testResult.testFilePath;
48
48
  fileJson.sourcePath = filePath;
49
49
  fileJson.data = testResult;
50
50
  testFilesArr.push(fileJson);
51
+
51
52
  if (jsonData.FILES.includes(relatPath) || jsonData.FILES.includes(testResult.testFilePath.replace(process.cwd(), ''))) {
52
53
  jsonData.FILES.includes(relatPath) ? testCaseFiles.push(relatPath) : jsonData.FILES.includes(testResult.testFilePath.replace(process.cwd(), '')) ? testCaseFiles.push(testResult.testFilePath.replace(process.cwd(), '')) : '';
53
54
  }
54
55
  });
55
- var coverageSummary = {};
56
- if (_fs2.default.existsSync('./commitCoverage/coverage-summary.json')) {
57
- coverageSummary = _fs2.default.readFileSync('./commitCoverage/coverage-summary.json').toString();
56
+ let coverageSummary = {};
57
+
58
+ if (_fs.default.existsSync('./commitCoverage/coverage-summary.json')) {
59
+ coverageSummary = _fs.default.readFileSync('./commitCoverage/coverage-summary.json').toString();
60
+
58
61
  if (coverageSummary.indexOf('\\') !== -1) {
59
62
  coverageSummary = coverageSummary.replace(/\\/g, '\\\\');
60
63
  }
61
64
  }
62
65
 
63
- var excludeTestArray = '{}';
64
- if (_fs2.default.existsSync('./__testUtils__/conf/excludeTest.json')) {
65
- excludeTestArray = _fs2.default.readFileSync('./__testUtils__/conf/excludeTest.json').toString();
66
+ let excludeTestArray = '{}';
67
+
68
+ if (_fs.default.existsSync('./__testUtils__/conf/excludeTest.json')) {
69
+ excludeTestArray = _fs.default.readFileSync('./__testUtils__/conf/excludeTest.json').toString();
70
+
66
71
  if (excludeTestArray.indexOf('\\') !== -1) {
67
72
  excludeTestArray = excludeTestArray.replace(/\\/g, '\\\\');
68
73
  }
69
74
  }
70
75
 
71
- var coverageJson = JSON.parse(coverageSummary);
72
- var linesPercent = 0;
73
- var functionPercent = 0;
74
- var statementPerment = 0;
75
- var branchesPercent = 0;
76
+ let coverageJson = JSON.parse(coverageSummary);
77
+ let linesPercent = 0;
78
+ let functionPercent = 0;
79
+ let statementPerment = 0;
80
+ let branchesPercent = 0;
81
+ let fileList = '<h4>Changed files in last code check-in</h4><ul>';
82
+ let i = 0;
83
+ let excludeTestJSON = JSON.parse(excludeTestArray);
76
84
 
77
- var fileList = '<h4>Changed files in last code check-in</h4><ul>';
78
- var i = 0;
79
- var excludeTestJSON = JSON.parse(excludeTestArray);
80
85
  if (Object.keys(excludeTestArray).length > 0) {
81
86
  jsonData.FILES = jsonData.FILES.filter(function (value) {
82
87
  if (!excludeTestJSON.test.exclude.includes(value)) {
88
+ let excludeDir = excludeTestJSON.test.exclude.filter(function (excludeFile) {
89
+ if (value.indexOf(excludeFile) > -1) {
90
+ return value;
91
+ }
92
+ });
93
+
94
+ if (excludeDir.length > 0) {
95
+ return null;
96
+ }
97
+
83
98
  return value;
84
99
  }
100
+
85
101
  return null;
86
102
  });
87
103
  }
88
104
 
89
- var _loop = function _loop() {
90
- var coverageData = void 0;
91
- var curSourceFile = jsonData.FILES[i];
105
+ for (i; i < jsonData.FILES.length; i++) {
106
+ let coverageData;
107
+ let curSourceFile = jsonData.FILES[i];
92
108
  curSourceFile.replace(process.cwd(), '').substring(1);
93
- fileList = fileList + '<li>' + curSourceFile + '</li>';
94
- Object.keys(coverageJson).forEach(function (coverageFile) {
109
+ fileList = `${fileList}<li>${curSourceFile}</li>`;
110
+ Object.keys(coverageJson).forEach(coverageFile => {
95
111
  if (coverageFile.includes(curSourceFile) || coverageFile === 'total') {
96
112
  coverageData = coverageJson[coverageFile];
97
113
  }
98
114
  });
99
115
 
100
116
  if (!coverageData) {
101
- (0, _utils.log)('Can\'t able to find source for ' + testFilesArr[i].testPath + '\n Please check the file name and the path is correct for test file');
102
- return 'continue';
117
+ (0, _utils.log)(`Can't able to find source for ${testFilesArr[i].testPath}\n Please check the file name and the path is correct for test file`);
118
+ continue;
103
119
  }
120
+
104
121
  linesPercent += coverageData.lines.pct;
105
122
  functionPercent += coverageData.functions.pct;
106
123
  statementPerment += coverageData.statements.pct;
107
124
  branchesPercent += coverageData.branches.pct;
108
- };
125
+ }
109
126
 
110
- for (i; i < jsonData.FILES.length; i++) {
111
- var _ret = _loop();
127
+ fileList = `${fileList}</ul>`;
112
128
 
113
- if (_ret === 'continue') continue;
114
- }
115
- fileList = fileList + '</ul>';
116
- if (!testFilesArr.length) {
129
+ if (!jsonData.FILES.length) {
117
130
  fileList = '<div></div>';
118
131
  }
119
- var uncoveredList = '<h4>Uncovered files :- </h4><ul>';
120
- uncoveredList = uncoveredList + '</ul>';
121
- var fileCoverage = testCaseFiles.length / jsonData.FILES.length * 100;
132
+
133
+ let uncoveredList = '<h4>Uncovered files :- </h4><ul>';
134
+ let fileCoverage = 0;
135
+
136
+ if (jsonData.FILES.length > 0) {
137
+ fileCoverage = testCaseFiles.length / jsonData.FILES.length * 100;
138
+ }
139
+
122
140
  fileCoverage = fileCoverage.toFixed(2);
123
141
  fileCoverage = Number(fileCoverage);
142
+
124
143
  if (Number.isNaN(fileCoverage)) {
125
144
  (0, _utils.log)('This build does\'t have any JS changes!');
126
145
  fileCoverage = 0;
127
146
  } else {
128
- (0, _utils.log)('FileCoverage ' + fileCoverage + '%');
147
+ (0, _utils.log)(`FileCoverage ${fileCoverage}%`);
129
148
  }
130
149
 
131
- var totalLinesPercent = linesPercent / (i * 100) * 100;
132
- var totalFunctionPercent = functionPercent / (i * 100) * 100;
133
- var totalStatementPercent = statementPerment / (i * 100) * 100;
134
- var totalBranchesPercent = branchesPercent / (i * 100) * 100;
135
- var totalPercentage = totalLinesPercent + totalFunctionPercent + totalStatementPercent + totalBranchesPercent;
136
- var coverage = (totalPercentage / 4).toFixed(2);
150
+ let totalLinesPercent = linesPercent / (i * 100) * 100;
151
+ let totalFunctionPercent = functionPercent / (i * 100) * 100;
152
+ let totalStatementPercent = statementPerment / (i * 100) * 100;
153
+ let totalBranchesPercent = branchesPercent / (i * 100) * 100;
154
+ let totalPercentage = totalLinesPercent + totalFunctionPercent + totalStatementPercent + totalBranchesPercent;
155
+ let coverage = (totalPercentage / 4).toFixed(2);
137
156
  coverage = Number(coverage);
157
+
138
158
  if (Number.isNaN(coverage)) {
139
- (0, _jsonHelper.jsonHelper)(process.cwd() + '/result.json', 'tests.modifiedFileUnitCase.testInfo', 'can\'t get coverage for this test');
159
+ (0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'tests.modifiedFileUnitCase.testInfo', 'can\'t get coverage for this test');
140
160
  coverage = 0;
161
+ uncoveredList = uncoveredList + 'No Component changes with this build, You can proceed this build </ul>';
141
162
  } else {
142
- (0, _jsonMaker2.default)(inp, coverage, true, 'modifiedFileUnitCase', fileCoverage);
143
- (0, _jsonHelper.jsonHelper)(process.cwd() + '/result.json', 'tests.modifiedFileUnitCase.isBuildVerified', coverage > 60);
144
- (0, _jsonHelper.jsonHelper)(process.cwd() + '/result.json', 'tests.modifiedFileUnitCase.testInfo', 'Test coverage value generated');
145
- // jsonHelper(
163
+ (0, _jsonMaker.default)(inp, coverage, true, 'modifiedFileUnitCase', fileCoverage);
164
+ (0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'tests.modifiedFileUnitCase.isBuildVerified', coverage > 60);
165
+ (0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'tests.modifiedFileUnitCase.testInfo', 'Test coverage value generated'); // jsonHelper(
146
166
  // `${process.cwd()}/result.json`,
147
167
  // 'testInfo.isBuildVerified',
148
168
  // coverage > 60
149
169
  // );
150
- (0, _jsonHelper.setTestInfoStatus)(process.cwd() + '/result.json', true /*coverage > 60*/);
170
+
171
+ (0, _jsonHelper.setTestInfoStatus)(`${process.cwd()}/result.json`, true
172
+ /*coverage > 60*/
173
+ );
174
+
151
175
  if (coverage < 60) {
152
- (0, _jsonHelper.jsonHelper)(process.cwd() + '/result.json', 'testInfo.failures', [{
176
+ (0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'testInfo.failures', [{
153
177
  type: 'modifiedUnitcases',
154
178
  message: 'Need to cover 60% above for changed files'
155
179
  }]);
180
+ uncoveredList = uncoveredList + 'Ask developer to cover 60% above for changed files </ul>';
181
+ } else {
182
+ uncoveredList = uncoveredList + 'You can proceed this build </ul>';
156
183
  }
157
184
 
158
- (0, _utils.log)('COVERAGE ' + coverage + '%');
185
+ (0, _utils.log)(`COVERAGE ${coverage}%`);
159
186
  }
160
187
 
161
- var html = '<html><head><style>.red{font-weight:bold;color:red;}.green{font-weight:bold;color:green;}</style></head><body><br/>CODE COVERAGE <span class="' + (coverage < 60 ? 'red' : 'green') + '">' + coverage + '%</span> <br/> less than 60% consider failure<br/><br/> FILE COVERAGE:<span class="' + (fileCoverage < 60 ? 'red' : 'green') + '">' + fileCoverage + '%</span> <br/> less than 60% consider failure' + fileList + uncoveredList + '</body></html>';
188
+ let html = `<html><head><style>.red{font-weight:bold;color:red;}.green{font-weight:bold;color:green;}</style></head><body><br/>CODE COVERAGE <span class="${coverage < 60 ? 'red' : 'green'}">${coverage}%</span> <br/> less than 60% consider failure<br/><br/> FILE COVERAGE:<span class="${fileCoverage < 60 ? 'red' : 'green'}">${fileCoverage}%</span> <br/> less than 60% consider failure${fileList}${uncoveredList}</body></html>`;
189
+
190
+ if (!_fs.default.existsSync('./coverageTest')) {
191
+ _fs.default.mkdirSync('./coverageTest');
162
192
 
163
- if (!_fs2.default.existsSync('./coverageTest')) {
164
- _fs2.default.mkdirSync('./coverageTest');
165
- _fs2.default.writeFileSync('./coverageTest/index.html', html, 'utf8');
193
+ _fs.default.writeFileSync('./coverageTest/index.html', html, 'utf8');
166
194
  } else {
167
- _fs2.default.writeFileSync('./coverageTest/index.html', html, 'utf8');
195
+ _fs.default.writeFileSync('./coverageTest/index.html', html, 'utf8');
168
196
  }
197
+
169
198
  return inp;
170
199
  };
171
200