@zohodesk/react-cli 0.0.1-beta.16 → 0.0.1-beta.162

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 (228) hide show
  1. package/.eslintignore +1 -0
  2. package/.eslintrc.js +46 -3
  3. package/CHANGELOG.md +5 -0
  4. package/README.md +708 -0
  5. package/bin/cli.js +134 -27
  6. package/cert/cert.pem +37 -129
  7. package/cert/key.pem +27 -27
  8. package/cert/passphrase.pem +1 -0
  9. package/files/eslintrc.js +62 -0
  10. package/files/prettierrc.js +3 -0
  11. package/lib/babel/cmjs-plugins-presets.js +16 -9
  12. package/lib/babel/es-plugins-presets.js +26 -14
  13. package/lib/common/getEntries.js +33 -24
  14. package/lib/common/getPublicPathConfig.js +40 -0
  15. package/lib/common/index.js +27 -13
  16. package/lib/common/splitChunks.js +64 -26
  17. package/lib/common/sslcertUpdater.js +59 -0
  18. package/lib/common/templateParameters.js +25 -0
  19. package/lib/configs/jest.config.js +26 -27
  20. package/lib/configs/libAlias.js +31 -0
  21. package/lib/configs/webpack.component.umd.config.js +31 -37
  22. package/lib/configs/webpack.css.umd.config.js +44 -44
  23. package/lib/configs/webpack.dev.config.js +96 -56
  24. package/lib/configs/webpack.docs.config.js +104 -98
  25. package/lib/configs/webpack.impact.config.js +116 -0
  26. package/lib/configs/webpack.prod.config.js +137 -85
  27. package/lib/hooks/docsProptypeHook.js +32 -38
  28. package/lib/jest/commitedFilesResult.js +144 -71
  29. package/lib/jest/coverageCollector.js +62 -29
  30. package/lib/jest/jsonMaker.js +54 -0
  31. package/lib/jest/preProcessors/cssPreprocessor.js +16 -18
  32. package/lib/jest/preProcessors/jsPreprocessor.js +5 -6
  33. package/lib/jest/preProcessors/otherFilesPreprocessor.js +5 -6
  34. package/lib/jest/result.js +91 -41
  35. package/lib/jest/run.js +74 -27
  36. package/lib/jest/setup.js +103 -102
  37. package/lib/loaderUtils/getCSSLoaders.js +77 -0
  38. package/lib/loaderUtils/getDevJsLoaders.js +30 -23
  39. package/lib/loaderUtils/index.js +14 -7
  40. package/lib/loaders/docsLoader.js +15 -15
  41. package/lib/loaders/docsPropsLoader.js +14 -17
  42. package/lib/loaders/fileBountryLoader.js +17 -0
  43. package/lib/loaders/fileLoader.js +47 -38
  44. package/lib/loaders/scriptInstrumentLoader.js +21 -20
  45. package/lib/loaders/selectorMappingLoader.js +75 -0
  46. package/lib/loaders/workerLoader.js +136 -0
  47. package/lib/middlewares/HMRMiddleware.js +59 -41
  48. package/lib/middlewares/SSTMiddleware.js +21 -0
  49. package/lib/pluginUtils/getDevPlugins.js +175 -26
  50. package/lib/pluginUtils/getDocsPlugins.js +32 -17
  51. package/lib/pluginUtils/getLibraryImactPlugins.js +23 -0
  52. package/lib/pluginUtils/getLibraryPlugins.js +8 -10
  53. package/lib/pluginUtils/getProdPlugins.js +240 -37
  54. package/lib/pluginUtils/getServerPlugins.js +8 -11
  55. package/lib/pluginUtils/getUMDCSSPlugins.js +11 -15
  56. package/lib/pluginUtils/getUMDComponentPlugins.js +11 -15
  57. package/lib/pluginUtils/index.js +36 -43
  58. package/lib/plugins/CdnChangePlugin.js +77 -0
  59. package/lib/plugins/CleanupStatsPlugin.js +28 -0
  60. package/lib/plugins/EFCPlugin.js +241 -0
  61. package/lib/plugins/EFCPlugin.md +6 -0
  62. package/lib/plugins/EFCTemplatePlugin.js +151 -0
  63. package/lib/plugins/I18NInjectIntoIndexPlugin.js +141 -0
  64. package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +60 -0
  65. package/lib/plugins/I18nSplitPlugin/I18nDependency.js +44 -0
  66. package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +266 -0
  67. package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +183 -0
  68. package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +100 -0
  69. package/lib/plugins/I18nSplitPlugin/I18nSplit.md +86 -0
  70. package/lib/plugins/I18nSplitPlugin/README.md +25 -0
  71. package/lib/plugins/I18nSplitPlugin/index.js +185 -0
  72. package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +64 -0
  73. package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +13 -0
  74. package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +26 -0
  75. package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +40 -0
  76. package/lib/plugins/I18nSplitPlugin/utils/index.js +31 -0
  77. package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +112 -0
  78. package/lib/plugins/ManifestPlugin.js +59 -62
  79. package/lib/plugins/ModuleStatsPlugin.js +98 -97
  80. package/lib/plugins/OptimizeJSPlugin.js +24 -41
  81. package/lib/plugins/PublicPathCallbackPlugin.js +63 -0
  82. package/lib/plugins/PublicPathChangePlugin.js +187 -174
  83. package/lib/plugins/ReportGeneratePlugin.js +181 -0
  84. package/lib/plugins/RequireVariablePublicPlugin.js +30 -0
  85. package/lib/plugins/ResourceHintsPlugin.js +53 -35
  86. package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +80 -0
  87. package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +82 -0
  88. package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -0
  89. package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +26 -0
  90. package/lib/plugins/ScriptInstrumentPlugin.js +22 -37
  91. package/lib/plugins/ServiceWorkerPlugin.js +107 -0
  92. package/lib/plugins/ShadowDOMSupportPlugin.js +270 -0
  93. package/lib/plugins/SourceMapHookPlugin.js +25 -31
  94. package/lib/plugins/TPHashMappingPlugin.js +67 -0
  95. package/lib/plugins/UglifyCSSPlugin.js +23 -30
  96. package/lib/plugins/UnusedFilesFindPlugin.js +150 -97
  97. package/lib/plugins/index.js +118 -55
  98. package/lib/plugins/libraryImpactPlugin.js +190 -0
  99. package/lib/plugins/webpackwatchrunplugin.js +26 -0
  100. package/lib/postcss-plugins/ExcludeRTLPlugin.js +23 -0
  101. package/lib/postcss-plugins/RTLSplitPlugin.js +138 -0
  102. package/lib/schemas/index.js +466 -52
  103. package/lib/servers/clusterHubServer.js +22 -26
  104. package/lib/servers/docsServer.js +3 -5
  105. package/lib/servers/docsServerCore.js +93 -85
  106. package/lib/servers/helpServer.js +19 -21
  107. package/lib/servers/httpsOptions.js +19 -0
  108. package/lib/servers/impactServer.js +99 -92
  109. package/lib/servers/mockserver.js +44 -0
  110. package/lib/servers/nowatchserver.js +275 -0
  111. package/lib/servers/scrServer.js +147 -0
  112. package/lib/servers/server.js +118 -124
  113. package/lib/servers/ssServer.js +107 -65
  114. package/lib/sh/reportPublish.sh +16 -10
  115. package/lib/templates/CoverageScriptTemplate.js +45 -18
  116. package/lib/templates/WMSTemplate.js +17 -18
  117. package/lib/templates/linterConstant.js +10 -0
  118. package/lib/utils/babelPresets.js +12 -5
  119. package/lib/utils/buildstats.html +148 -0
  120. package/lib/utils/clean.js +12 -11
  121. package/lib/utils/copy.js +13 -127
  122. package/lib/utils/copyTimezones.js +21 -0
  123. package/lib/utils/createEventStream.js +24 -19
  124. package/lib/utils/cssClassNameGenerate.js +77 -0
  125. package/lib/utils/cssURLReplacer.js +67 -54
  126. package/lib/utils/dependencyPostPublish.js +42 -0
  127. package/lib/utils/fileUtils.js +125 -0
  128. package/lib/utils/folderIterator.js +47 -0
  129. package/lib/utils/getComponents.js +126 -0
  130. package/lib/utils/getCurrentBranch.js +11 -17
  131. package/lib/utils/getDependenciesImpactList.js +151 -0
  132. package/lib/utils/getHash.js +26 -0
  133. package/lib/utils/getIp.js +20 -0
  134. package/lib/utils/getOptions.js +55 -30
  135. package/lib/utils/getServerURL.js +25 -8
  136. package/lib/utils/index.js +259 -82
  137. package/lib/utils/init.js +2 -2
  138. package/lib/utils/initPreCommitHook.js +40 -31
  139. package/lib/utils/jsonHelper.js +97 -0
  140. package/lib/utils/libraryImpactConfig.js +63 -0
  141. package/lib/utils/lint/addScripts.js +27 -0
  142. package/lib/utils/lint/checkExistingConfig.js +67 -0
  143. package/lib/utils/lint/copyConfigs.js +24 -0
  144. package/lib/utils/lint/index.js +54 -0
  145. package/lib/utils/lint/lintScripts.js +11 -0
  146. package/lib/utils/lint/lintSetup.js +31 -0
  147. package/lib/utils/lint/lintStagedPreCommitHook.js +7 -0
  148. package/lib/utils/lint/question.js +30 -0
  149. package/lib/utils/lintReporter.js +142 -0
  150. package/lib/utils/mailSender.js +16 -25
  151. package/lib/utils/pullOrigin.js +28 -0
  152. package/lib/utils/reinstallDependencies.js +133 -0
  153. package/lib/utils/removeAttributes.js +25 -23
  154. package/lib/utils/repoClone.js +56 -63
  155. package/lib/utils/request.js +64 -77
  156. package/lib/utils/resultSchema.json +73 -0
  157. package/lib/utils/rtl.js +42 -0
  158. package/lib/utils/setEnvVariables.js +5 -6
  159. package/lib/utils/ssTestHack.js +48 -0
  160. package/lib/utils/switchBranch.js +28 -0
  161. package/lib/utils/urlConcat.js +22 -0
  162. package/package.json +92 -64
  163. package/templates/app/.eslintrc.js +140 -0
  164. package/templates/app/README.md +12 -12
  165. package/templates/app/app/index.html +24 -8
  166. package/templates/app/app/properties/ApplicationResources_en_US.properties +1 -1
  167. package/templates/app/app/properties/i18nkeys.json +3 -3
  168. package/templates/app/docs/all.html +69 -69
  169. package/templates/app/mockapi/index.js +18 -13
  170. package/templates/app/package.json +37 -17
  171. package/templates/app/src/actions/SampleActions/index.js +37 -0
  172. package/templates/app/src/actions/index.js +65 -0
  173. package/templates/app/src/appUrls.js +19 -0
  174. package/templates/app/src/components/Alert/Alert.js +134 -0
  175. package/templates/app/src/components/Alert/Alert.module.css +79 -0
  176. package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -0
  177. package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -0
  178. package/templates/app/src/components/Sample/Sample.module.css +11 -0
  179. package/templates/app/src/components/Sample/SampleList.js +61 -0
  180. package/templates/app/src/components/Slider/Slider.css +41 -0
  181. package/templates/app/src/components/Slider/Slider.js +55 -0
  182. package/templates/app/src/containers/AlertContainer/index.js +15 -0
  183. package/templates/app/src/containers/AppContainer/index.js +96 -0
  184. package/templates/app/src/containers/AppContainer/index.module.css +27 -0
  185. package/templates/app/src/containers/CustomMatch/index.js +65 -0
  186. package/templates/app/src/containers/DevTools/index.js +10 -0
  187. package/templates/app/src/containers/Header/index.js +67 -0
  188. package/templates/app/src/containers/Header/index.module.css +43 -0
  189. package/templates/app/src/containers/Redirect/index.js +63 -0
  190. package/templates/app/src/containers/Redirector/index.js +47 -0
  191. package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -0
  192. package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -0
  193. package/templates/app/src/historyChange.js +5 -0
  194. package/templates/app/src/index.html +10 -0
  195. package/templates/app/src/index.js +24 -0
  196. package/templates/app/src/middleware/PromiseMiddleware.js +59 -0
  197. package/templates/app/src/reducers/alertData.js +11 -0
  198. package/templates/app/src/reducers/index.js +6 -0
  199. package/templates/app/src/reducers/samples.js +19 -0
  200. package/templates/app/src/store/configureStore.dev.js +51 -0
  201. package/templates/app/src/store/configureStore.js +5 -0
  202. package/templates/app/src/store/configureStore.prod.js +26 -0
  203. package/templates/app/src/util/Common.js +5 -0
  204. package/templates/app/src/util/RequestAPI.js +132 -0
  205. package/templates/appold/README.md +12 -0
  206. package/templates/appold/app/index.html +8 -0
  207. package/templates/appold/app/properties/ApplicationResources_en_US.properties +1 -0
  208. package/templates/appold/app/properties/i18nkeys.json +3 -0
  209. package/templates/appold/docs/all.html +69 -0
  210. package/templates/appold/mockapi/index.js +13 -0
  211. package/templates/{app → appold}/mockapi/tickets.json +0 -0
  212. package/templates/appold/package.json +17 -0
  213. package/templates/appold/src/components/Text/Text.css +0 -0
  214. package/templates/appold/src/components/Text/Text.js +23 -0
  215. package/templates/appold/src/components/Text/__tests__/Text.spec.js +30 -0
  216. package/templates/appold/src/components/Text/docs/Text__default.docs.js +16 -0
  217. package/templates/appold/src/components/docs.js +1 -0
  218. package/templates/appold/src/components/index.js +5 -0
  219. package/templates/appold/src/index.js +13 -0
  220. package/templates/docs/all.html +1 -1
  221. package/templates/docs/component.html +110 -69
  222. package/templates/docs/components.html +221 -0
  223. package/templates/docs/css/component.css +12 -14
  224. package/templates/docs/css/componentTest.css +7 -0
  225. package/templates/docs/css/style.css +150 -206
  226. package/templates/docs/impactReportTemplate.html +154 -0
  227. package/templates/docs/index.html +1482 -1336
  228. package/templates/library/src/index.js +0 -0
@@ -1,43 +1,52 @@
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 _path = require('path');
8
+ var _path = _interopRequireDefault(require("path"));
8
9
 
9
- var _path2 = _interopRequireDefault(_path);
10
-
11
- var _utils = require('../utils');
10
+ var _utils = require("../utils");
12
11
 
13
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
13
 
15
- var getEntries = function getEntries(appSchemas, mode) {
16
- var appPath = process.cwd();
17
- var _appSchemas$app = appSchemas.app,
18
- isReactMig = _appSchemas$app.isReactMig,
19
- hasWidget = _appSchemas$app.hasWidget,
20
- hasEFC = _appSchemas$app.hasEFC,
21
- server = _appSchemas$app.server,
22
- folder = _appSchemas$app.folder;
23
-
24
-
25
- var mainJs = [];
26
- var entry = { main: mainJs };
27
-
28
- if (mode === 'dev') {
29
- mainJs.push(_path2.default.join(__dirname, '..', 'templates', 'WMSTemplate') + '?wmsPath=wss:' + (0, _utils.getServerURL)(server));
14
+ let getEntries = (appSchemas, mode) => {
15
+ let appPath = process.cwd();
16
+ let {
17
+ isReactMig,
18
+ hasWidget,
19
+ server,
20
+ folder
21
+ } = appSchemas.app;
22
+ const {
23
+ hasEFC: prevOptionForEnableEFC
24
+ } = appSchemas.app;
25
+ const {
26
+ hasEFC: newOptionForEnableEFC
27
+ } = appSchemas.efc;
28
+ const hasEFC = newOptionForEnableEFC || prevOptionForEnableEFC;
29
+ let mainJs = [];
30
+ let entry = {
31
+ main: mainJs
32
+ };
33
+
34
+ if (mode === 'dev' || mode === 'dev-no-warn') {
35
+ mainJs.push(`${_path.default.join(__dirname, '..', 'templates', 'WMSTemplate')}?wmsPath=wss:${(0, _utils.getServerURL)(server)}`);
30
36
  }
31
37
 
32
- mainJs.push(_path2.default.join(appPath, folder, isReactMig ? 'migration.js' : 'index.js'));
38
+ mainJs.push(_path.default.join(appPath, folder, isReactMig ? 'migration.js' : 'index.js'));
33
39
 
34
40
  if (hasWidget) {
35
- entry.widget = [_path2.default.join(appPath, folder, 'widget.js')];
41
+ entry.widget = [_path.default.join(appPath, folder, 'widget.js')];
36
42
  }
43
+
37
44
  if (hasEFC) {
38
- entry.efc = [_path2.default.join(appPath, folder, 'efc.js')];
45
+ entry.efc = [_path.default.join(appPath, folder, 'efc.js')];
39
46
  }
40
47
 
41
48
  return entry;
42
49
  };
43
- exports.default = getEntries;
50
+
51
+ var _default = getEntries;
52
+ exports.default = _default;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _utils = require("../utils");
9
+
10
+ let {
11
+ app: {
12
+ publicPaths,
13
+ cdnMapping: {
14
+ isCdnEnabled,
15
+ variableName
16
+ },
17
+ server: {
18
+ mode
19
+ }
20
+ }
21
+ } = (0, _utils.getOptions)();
22
+ let isDevelopment = mode === 'dev' || mode === 'prod' || mode === 'dev-no-warn';
23
+
24
+ var _default = url => {
25
+ let type = (0, _utils.getFileType)(url);
26
+
27
+ if (!isDevelopment) {
28
+ if (publicPaths && publicPaths.callback) {
29
+ return `${publicPaths.callback}(${JSON.stringify(type)}) + ${JSON.stringify(url)}`;
30
+ } else if (isCdnEnabled) {
31
+ return `window["${variableName}"] + ${JSON.stringify(url)}`;
32
+ } else if (publicPaths) {
33
+ return `__REACT_CLI_${type.toUpperCase()}_PUBLIC_PATH__ + ${JSON.stringify(url)}`;
34
+ }
35
+ }
36
+
37
+ return `__webpack_public_path__ + ${JSON.stringify(url)}`;
38
+ };
39
+
40
+ exports.default = _default;
@@ -1,25 +1,39 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
-
7
- var _splitChunks = require('./splitChunks');
8
-
9
- Object.defineProperty(exports, 'splitChunks', {
6
+ Object.defineProperty(exports, "splitChunks", {
10
7
  enumerable: true,
11
- get: function get() {
12
- return _interopRequireDefault(_splitChunks).default;
8
+ get: function () {
9
+ return _splitChunks.default;
13
10
  }
14
11
  });
15
-
16
- var _getEntries = require('./getEntries');
17
-
18
- Object.defineProperty(exports, 'getEntries', {
12
+ Object.defineProperty(exports, "getEntries", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _getEntries.default;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "getPublicPathConfig", {
19
19
  enumerable: true,
20
- get: function get() {
21
- return _interopRequireDefault(_getEntries).default;
20
+ get: function () {
21
+ return _getPublicPathConfig.default;
22
22
  }
23
23
  });
24
+ Object.defineProperty(exports, "templateParameters", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _templateParameters.default;
28
+ }
29
+ });
30
+
31
+ var _splitChunks = _interopRequireDefault(require("./splitChunks"));
32
+
33
+ var _getEntries = _interopRequireDefault(require("./getEntries"));
34
+
35
+ var _getPublicPathConfig = _interopRequireDefault(require("./getPublicPathConfig"));
36
+
37
+ var _templateParameters = _interopRequireDefault(require("./templateParameters"));
24
38
 
25
39
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -1,41 +1,79 @@
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 _path = require('path');
8
+ var _path = _interopRequireDefault(require("path"));
8
9
 
9
- var _path2 = _interopRequireDefault(_path);
10
+ var _utils = require("../utils");
11
+
12
+ var _os = _interopRequireDefault(require("os"));
10
13
 
11
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
15
 
13
- var isVendor = function isVendor(module) {
14
- var userRequest = module.userRequest;
16
+ let isWindows = _os.default.platform().toLowerCase() === 'win32';
17
+ let ps = _path.default.sep;
18
+ let options = (0, _utils.getOptions)();
19
+ let {
20
+ app: {
21
+ vendorExclude,
22
+ customChunks,
23
+ vendorInclude
24
+ }
25
+ } = options;
15
26
 
16
- return userRequest && userRequest.indexOf('node_modules') >= 0 && userRequest.indexOf('node_modules/script-loader') === -1 && userRequest.indexOf('node_modules/raw-loader') === -1 && userRequest.indexOf('node_modules' + _path2.default.sep + 'react') === -1 && userRequest.indexOf('.css') === -1 && userRequest.indexOf('publicPathConfig.js') === -1;
27
+ let isVendor = function isVendor(module) {
28
+ let {
29
+ userRequest
30
+ } = module;
31
+ let excludeList = ['script-loader', 'raw-loader', 'react', 'react-dom'];
32
+ excludeList = [...excludeList, ...vendorExclude];
33
+ return userRequest && (vendorInclude.some(item => userRequest.indexOf(item) !== -1) || userRequest.indexOf('node_modules') >= 0 && userRequest.endsWith('.css') === false && userRequest.endsWith('publicPathConfig.js') === false && excludeList.every(item => userRequest.indexOf(`node_modules${ps}${item}${ps}`) === -1));
17
34
  };
18
35
 
19
- var isReact = function isReact(module) {
20
- var userRequest = module.userRequest;
21
-
22
- return userRequest && userRequest.indexOf('node_modules' + _path2.default.sep + 'react') >= 0;
36
+ let isReact = module => {
37
+ let {
38
+ userRequest
39
+ } = module;
40
+ let reactBundle = ['react', 'react-dom'];
41
+ return userRequest && reactBundle.some(pkg => userRequest.indexOf(`node_modules${ps}${pkg}${ps}`) >= 0);
23
42
  };
24
43
 
25
- exports.default = {
26
- cacheGroups: {
27
- default: false,
28
- 'react.vendor': {
29
- name: 'react.vendor',
30
- chunks: 'all',
31
- minChunks: 1,
32
- test: isReact
33
- },
34
- vendor: {
35
- name: 'vendor',
36
- chunks: 'all',
37
- minChunks: 1,
38
- test: isVendor
39
- }
44
+ let defaultChunks = {
45
+ 'react.vendor': {
46
+ name: 'react.vendor',
47
+ chunks: 'all',
48
+ minChunks: 1,
49
+ test: isReact,
50
+ priority: -10
51
+ },
52
+ vendor: {
53
+ name: 'vendor',
54
+ chunks: 'all',
55
+ minChunks: 1,
56
+ test: isVendor,
57
+ priority: -10
40
58
  }
41
- };
59
+ };
60
+ let customChunksConfig = {};
61
+ customChunks.map(({
62
+ name,
63
+ pattern,
64
+ size = 2
65
+ }, index) => customChunksConfig[name] = {
66
+ name,
67
+ test: new RegExp(isWindows ? pattern.replace(/\//g, '\\') : pattern),
68
+ chunks: 'all',
69
+ enforce: true,
70
+ minChunks: size,
71
+ priority: -10 * (index + 2)
72
+ });
73
+ var _default = {
74
+ cacheGroups: Object.assign({
75
+ default: false,
76
+ vendors: false
77
+ }, defaultChunks, customChunksConfig)
78
+ };
79
+ exports.default = _default;
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+
3
+ var _https = _interopRequireDefault(require("https"));
4
+
5
+ var _http = _interopRequireDefault(require("http"));
6
+
7
+ var _path = _interopRequireDefault(require("path"));
8
+
9
+ var _fs = _interopRequireDefault(require("fs"));
10
+
11
+ var _getOptions = _interopRequireDefault(require("../utils/getOptions"));
12
+
13
+ var _urlConcat = require("../utils/urlConcat");
14
+
15
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
+
17
+ const {
18
+ sslCertURL
19
+ } = (0, _getOptions.default)();
20
+
21
+ const CRET_FOLDER_PATH = _path.default.join(__dirname, '..', '..', 'cert');
22
+
23
+ console.log({
24
+ CRET_FOLDER_PATH,
25
+ sslCertURL
26
+ });
27
+ const CERT_PATH = 'cert.pem';
28
+ const KEY_PATH = 'key.pem';
29
+ const PASSPHRASE_PATH = 'passphrase.pem';
30
+
31
+ function updateSSlFile(sslCertURL, filename) {
32
+ let url = (0, _urlConcat.urlConcat)(sslCertURL, filename);
33
+ console.log({
34
+ url
35
+ });
36
+ (url.startsWith('https://') ? _https.default : _http.default).get(url, resp => {
37
+ let fpath = _path.default.join(CRET_FOLDER_PATH, filename);
38
+
39
+ let data = ''; // A chunk of data has been received.
40
+
41
+ resp.on('data', chunk => {
42
+ data += chunk;
43
+ }); // The whole response has been received. Print out the result.
44
+
45
+ resp.on('end', () => {
46
+ _fs.default.writeFileSync(fpath, data);
47
+ }); // return;
48
+ }).on('error', err => {
49
+ console.log(`Error: ${err.message}`);
50
+ });
51
+ }
52
+
53
+ if (!sslCertURL) {
54
+ throw 'sslCertURL not given';
55
+ }
56
+
57
+ updateSSlFile(sslCertURL, PASSPHRASE_PATH);
58
+ updateSSlFile(sslCertURL, CERT_PATH);
59
+ updateSSlFile(sslCertURL, KEY_PATH);
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _default = (compilation, assets, assetTags, options) => {
9
+ Object.keys(assetTags).forEach(rootTag => {
10
+ assetTags[rootTag].forEach(tag => {
11
+ tag.attributes.nonce = '{{--CSP-nonce}}';
12
+ });
13
+ });
14
+ return {
15
+ compilation,
16
+ webpackConfig: compilation.options,
17
+ htmlWebpackPlugin: {
18
+ tags: assetTags,
19
+ files: assets,
20
+ options
21
+ }
22
+ };
23
+ };
24
+
25
+ exports.default = _default;
@@ -1,25 +1,34 @@
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 _libAlias = require("./libAlias");
6
6
 
7
7
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
8
 
9
- var appPath = process.cwd();
9
+ let appPath = process.cwd(); // '^@root(.*)$': '<rootDir>/src$1',
10
+ // '^@components(.*)$': '<rootDir>/src/components$1',
10
11
 
11
- var commonConfig = {
12
+ let moduleNameMapper = Object.keys(_libAlias.libAlias).reduce((previousValue, key) => {
13
+ previousValue[`^${key}(.*)$`] = `${moduleNameMapper[key]}$1`;
14
+ return previousValue;
15
+ }, {});
16
+ let commonConfig = {
12
17
  coverageReporters: ['json', 'html', 'json-summary', 'text'],
13
18
  collectCoverage: true,
14
- moduleDirectories: [_path2.default.resolve(__dirname, '..', '..', 'node_modules'), 'node_modules'],
19
+ moduleDirectories: [_path.default.resolve(__dirname, '..', '..', 'node_modules'), 'node_modules'],
15
20
  transform: {
16
- '^.+\\.(js|jsx)$': _path2.default.resolve(__dirname, '..', 'jest', 'preProcessors', 'jsPreprocessor.js'),
17
- '^.+\\.css$': _path2.default.resolve(__dirname, '..', 'jest', 'preProcessors', 'cssPreprocessor.js'),
18
- '^(?!.*\\.(js|jsx|css|json)$)': _path2.default.resolve(__dirname, '..', 'jest', 'preProcessors', 'otherFilesPreprocessor.js')
21
+ '^.+\\.(js|jsx)$': _path.default.resolve(__dirname, '..', 'jest', 'preProcessors', 'jsPreprocessor.js'),
22
+ '^.+\\.css$': _path.default.resolve(__dirname, '..', 'jest', 'preProcessors', 'cssPreprocessor.js'),
23
+ '^(?!.*\\.(js|jsx|css|json)$)': _path.default.resolve(__dirname, '..', 'jest', 'preProcessors', 'otherFilesPreprocessor.js')
19
24
  },
20
- transformIgnorePatterns: ['/node_modules.*?.js$'],
25
+ moduleNameMapper: { ...moduleNameMapper,
26
+ '\\.(css|less)$': 'identity-obj-proxy'
27
+ },
28
+ transformIgnorePatterns: ['/node_modules/(?!(@zohodesk)/)'],
29
+ // transformIgnorePatterns: ['/node_modules.*?.js$'],
21
30
  moduleFileExtensions: ['js'],
22
- setupFiles: [_path2.default.resolve(appPath, '__testUtils__', 'globals.js'), _path2.default.resolve(__dirname, '..', 'jest', 'setup.js')],
31
+ setupFiles: [_path.default.resolve(appPath, '__testUtils__', 'globals.js'), _path.default.resolve(__dirname, '..', 'jest', 'setup.js')],
23
32
  globals: {
24
33
  __DEVELOPMENT__: true,
25
34
  __DOCS__: false,
@@ -27,20 +36,13 @@ var commonConfig = {
27
36
  }
28
37
  };
29
38
 
30
- module.exports = function () {
31
- for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
32
- args[_key] = arguments[_key];
33
- }
34
-
35
- var appFolder = args[0],
36
- _args$ = args[1],
37
- forCommittedFiles = _args$ === undefined ? false : _args$;
38
-
39
+ module.exports = (...args) => {
40
+ let [appFolder, forCommittedFiles = false] = args;
39
41
 
40
42
  if (forCommittedFiles) {
41
43
  return Object.assign({}, commonConfig, {
42
- coverageDirectory: _path2.default.resolve(appPath, 'commitCoverage'),
43
- testResultsProcessor: _path2.default.resolve(__dirname, '..', 'jest', 'commitedFilesResult.js')
44
+ coverageDirectory: _path.default.resolve(appPath, 'commitCoverage'),
45
+ testResultsProcessor: _path.default.resolve(__dirname, '..', 'jest', 'commitedFilesResult.js')
44
46
  });
45
47
  }
46
48
 
@@ -48,11 +50,8 @@ module.exports = function () {
48
50
  rootDir: appPath,
49
51
  testPathIgnorePatterns: ['/node_modules/', 'docs'],
50
52
  unmockedModulePathPatterns: ['__tests__', 'node_modules', '.*'],
51
- roots: ['<rootDir>/' + appFolder + '/'],
53
+ roots: [`<rootDir>/${appFolder}/`],
52
54
  testRegex: '(/__tests__/.*|\\.(test|spec))\\.(jsx|js|json|node)$',
53
- moduleNameMapper: {
54
- '\\.(css|less)$': 'identity-obj-proxy'
55
- },
56
- testResultsProcessor: _path2.default.resolve(__dirname, '..', 'jest', 'result.js')
55
+ testResultsProcessor: _path.default.resolve(__dirname, '..', 'jest', 'result.js')
57
56
  });
58
57
  };
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.libAlias = void 0;
7
+ // the reason for alias at the time was code tree shaking
8
+ // tree shaking was most compactable with ES module system
9
+ // FIXME: But there is a posiblity when these package does not have lib,
10
+ // app will work because of alias, But may be jest won't work because of not alais
11
+ // So need to think about use alais in jest
12
+ const libAlias = {
13
+ '@zohodesk/components/lib': '@zohodesk/components/es',
14
+ // '@zohodesk/zc-custom/lib': '@zohodesk/zc-custom/es',
15
+ '@zohodesk/dot/lib': '@zohodesk/dot/es',
16
+ '@zohodesk/i18n/lib': '@zohodesk/i18n/es',
17
+ '@zohodesk/icons/lib': '@zohodesk/icons/es',
18
+ '@zohodesk/normalizer/lib': '@zohodesk/normalizer/es',
19
+ '@zohodesk/perf-components/lib': '@zohodesk/perf-components/es',
20
+ '@zohodesk/perf-middleware/lib': '@zohodesk/perf-middleware/es',
21
+ '@zohodesk/permissions/lib': '@zohodesk/permissions/es',
22
+ '@zohodesk/platform-middleware/lib': '@zohodesk/platform-middleware/es',
23
+ '@zohodesk/react-dnd/lib': '@zohodesk/react-dnd/es',
24
+ '@zohodesk/router-middleware/lib': '@zohodesk/router-middleware/es',
25
+ '@zohodesk/storage/lib': '@zohodesk/storage/es',
26
+ '@zohodesk/svg/lib': '@zohodesk/svg/es',
27
+ '@zohodesk/timetracker/lib': '@zohodesk/timetracker/es',
28
+ '@zohodesk/variables/lib': '@zohodesk/variables/es',
29
+ '@zohodesk/virtualizer/lib': '@zohodesk/virtualizer/es'
30
+ };
31
+ exports.libAlias = libAlias;
@@ -1,41 +1,38 @@
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 _miniCssExtractPlugin = _interopRequireDefault(require("mini-css-extract-plugin"));
6
6
 
7
- var _miniCssExtractPlugin = require('mini-css-extract-plugin');
7
+ var _utils = require("../utils");
8
8
 
9
- var _miniCssExtractPlugin2 = _interopRequireDefault(_miniCssExtractPlugin);
10
-
11
- var _utils = require('../utils');
12
-
13
- var _pluginUtils = require('../pluginUtils');
9
+ var _pluginUtils = require("../pluginUtils");
14
10
 
15
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
12
 
17
- var options = (0, _utils.getOptions)();
18
-
19
- var _options$umd$componen = options.umd.component,
20
- umdVar = _options$umd$componen.umdVar,
21
- isHtml = _options$umd$componen.isHtml,
22
- isDocs = _options$umd$componen.isDocs,
23
- watch = _options$umd$componen.watch,
24
- outputFolder = _options$umd$componen.outputFolder,
25
- cssUniqueness = _options$umd$componen.cssUniqueness,
26
- folder = _options$umd$componen.folder;
27
-
28
-
29
- var appPath = process.cwd();
30
- var className = cssUniqueness ? 'fz__[hash:base64:5]' : '[name]__[local]';
31
-
13
+ let options = (0, _utils.getOptions)();
14
+ let {
15
+ umd: {
16
+ component: {
17
+ umdVar,
18
+ isHtml,
19
+ isDocs,
20
+ watch,
21
+ outputFolder,
22
+ cssUniqueness,
23
+ folder
24
+ }
25
+ }
26
+ } = options;
27
+ let appPath = process.cwd();
28
+ let className = cssUniqueness ? 'fz__[hash:base64:5]' : '[name]__[local]';
32
29
  module.exports = {
33
30
  watch: watch,
34
31
  entry: {
35
- main: _path2.default.join(appPath, folder, isHtml ? 'html.js' : 'index.js')
32
+ main: _path.default.join(appPath, folder, isHtml ? 'html.js' : 'index.js')
36
33
  },
37
34
  output: {
38
- path: _path2.default.join(appPath, outputFolder),
35
+ path: _path.default.join(appPath, outputFolder),
39
36
  filename: 'js/[name].js',
40
37
  library: umdVar,
41
38
  libraryTarget: 'umd'
@@ -51,21 +48,18 @@ module.exports = {
51
48
  use: [{
52
49
  loader: 'babel-loader',
53
50
  options: {
54
- presets: [[require.resolve('babel-preset-env'), { modules: false }], require.resolve('babel-preset-react')],
55
- plugins: [[require.resolve('babel-plugin-transform-runtime'), {
56
- helpers: true,
57
- polyfill: true,
58
- regenerator: false,
59
- moduleName: 'babel-runtime'
60
- }]],
51
+ presets: [[require.resolve('@babel/preset-env'), {
52
+ modules: false
53
+ }], require.resolve('@babel/preset-react')],
54
+ plugins: [require.resolve('@babel/plugin-proposal-object-rest-spread')],
61
55
  cacheDirectory: true
62
56
  }
63
57
  }],
64
- include: _path2.default.join(appPath, 'src')
58
+ include: _path.default.join(appPath, 'src')
65
59
  }, {
66
60
  test: /(\.module)?\.css$/,
67
61
  use: [{
68
- loader: _miniCssExtractPlugin2.default.loader,
62
+ loader: _miniCssExtractPlugin.default.loader,
69
63
  options: {
70
64
  publicPath: '../'
71
65
  }
@@ -101,9 +95,9 @@ module.exports = {
101
95
  }]
102
96
  },
103
97
  resolve: {
104
- modules: [_path2.default.resolve(__dirname, '..', '..', 'node_modules'), 'node_modules']
98
+ modules: [_path.default.resolve(__dirname, '..', '..', 'node_modules'), 'node_modules']
105
99
  },
106
100
  resolveLoader: {
107
- modules: [_path2.default.resolve(__dirname, '..', '..', 'node_modules'), 'node_modules']
101
+ modules: [_path.default.resolve(__dirname, '..', '..', 'node_modules'), 'node_modules']
108
102
  }
109
103
  };