@zohodesk/react-cli 0.0.1-beta.17 → 0.0.1-beta.170

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 (292) hide show
  1. package/.eslintignore +1 -0
  2. package/.eslintrc.js +49 -10
  3. package/.prettierrc +6 -0
  4. package/CHANGELOG.md +5 -0
  5. package/README.md +855 -0
  6. package/bin/cli.js +215 -46
  7. package/cert/Tsicsezwild-22-23.crt +37 -0
  8. package/cert/Tsicsezwild-22-23.key +27 -0
  9. package/docs/CustomChunks.md +26 -0
  10. package/docs/DevStart.md +18 -0
  11. package/docs/HoverActive.md +12 -0
  12. package/docs/InstallNode.md +28 -0
  13. package/docs/TODOS.md +10 -0
  14. package/docs/ValueReplacer.md +60 -0
  15. package/docs/warnings_while_install.txt +35 -0
  16. package/files/eslintrc.js +62 -0
  17. package/files/prettierrc.js +3 -0
  18. package/lib/babel/cmjs-plugins-presets.js +24 -0
  19. package/lib/babel/es-plugins-presets.js +34 -0
  20. package/lib/common/getEntries.js +33 -46
  21. package/lib/common/getPublicPathConfig.js +40 -0
  22. package/lib/common/index.js +24 -19
  23. package/lib/common/splitChunks.js +110 -25
  24. package/lib/common/sslcertUpdater.js +59 -0
  25. package/lib/common/templateParameters.js +25 -0
  26. package/lib/common/testPattern.js +69 -0
  27. package/lib/common/valueReplacer.js +55 -0
  28. package/lib/configs/jest.config.js +31 -27
  29. package/lib/configs/libAlias.js +31 -0
  30. package/lib/configs/webpack.component.umd.config.js +46 -53
  31. package/lib/configs/webpack.css.umd.config.js +47 -46
  32. package/lib/configs/webpack.dev.config.js +98 -84
  33. package/lib/configs/webpack.docs.config.js +64 -57
  34. package/lib/configs/webpack.impact.config.js +108 -0
  35. package/lib/configs/webpack.prod.config.js +146 -104
  36. package/lib/hooks/docsProptypeHook.js +32 -38
  37. package/lib/jest/commitedFilesResult.js +144 -71
  38. package/lib/jest/coverageCollector.js +68 -35
  39. package/lib/jest/jsonMaker.js +54 -0
  40. package/lib/jest/preProcessors/cssPreprocessor.js +16 -18
  41. package/lib/jest/preProcessors/jsPreprocessor.js +5 -6
  42. package/lib/jest/preProcessors/otherFilesPreprocessor.js +5 -6
  43. package/lib/jest/result.js +92 -42
  44. package/lib/jest/run.js +75 -28
  45. package/lib/jest/setup.js +103 -102
  46. package/lib/loaderUtils/configsAssetsLoaders.js +117 -0
  47. package/lib/loaderUtils/getCSSLoaders.js +113 -0
  48. package/lib/loaderUtils/getDevJsLoaders.js +35 -23
  49. package/lib/loaderUtils/index.js +14 -7
  50. package/lib/loaders/docsLoader.js +15 -15
  51. package/lib/loaders/docsPropsLoader.js +14 -17
  52. package/lib/loaders/fileBountryLoader.js +17 -0
  53. package/lib/loaders/fileLoader.js +47 -38
  54. package/lib/loaders/scriptInstrumentLoader.js +23 -20
  55. package/lib/loaders/selectorMappingLoader.js +75 -0
  56. package/lib/loaders/workerLoader.js +136 -0
  57. package/lib/middlewares/HMRMiddleware.js +90 -72
  58. package/lib/middlewares/SSTMiddleware.js +21 -0
  59. package/lib/pluginUtils/getDevPlugins.js +177 -30
  60. package/lib/pluginUtils/getDocsPlugins.js +36 -15
  61. package/lib/pluginUtils/getLibraryImactPlugins.js +23 -0
  62. package/lib/pluginUtils/getLibraryPlugins.js +8 -10
  63. package/lib/pluginUtils/getProdPlugins.js +244 -37
  64. package/lib/pluginUtils/getServerPlugins.js +8 -11
  65. package/lib/pluginUtils/getUMDCSSPlugins.js +14 -18
  66. package/lib/pluginUtils/getUMDComponentPlugins.js +14 -9
  67. package/lib/pluginUtils/index.js +36 -43
  68. package/lib/plugins/CdnChangePlugin.js +77 -0
  69. package/lib/plugins/CleanupStatsPlugin.js +28 -0
  70. package/lib/plugins/EFCPlugin.js +241 -0
  71. package/lib/plugins/EFCPlugin.md +6 -0
  72. package/lib/plugins/EFCTemplatePlugin.js +151 -0
  73. package/lib/plugins/I18NInjectIntoIndexPlugin.js +141 -0
  74. package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +60 -0
  75. package/lib/plugins/I18nSplitPlugin/I18nDependency.js +44 -0
  76. package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +266 -0
  77. package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +183 -0
  78. package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +100 -0
  79. package/lib/plugins/I18nSplitPlugin/I18nSplit.md +95 -0
  80. package/lib/plugins/I18nSplitPlugin/README.md +25 -0
  81. package/lib/plugins/I18nSplitPlugin/index.js +185 -0
  82. package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +64 -0
  83. package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +13 -0
  84. package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +26 -0
  85. package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +40 -0
  86. package/lib/plugins/I18nSplitPlugin/utils/index.js +31 -0
  87. package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +112 -0
  88. package/lib/plugins/ManifestPlugin.js +86 -0
  89. package/lib/plugins/ModuleStatsPlugin.js +98 -97
  90. package/lib/plugins/OptimizeJSPlugin.js +41 -0
  91. package/lib/plugins/PublicPathCallbackPlugin.js +63 -0
  92. package/lib/plugins/PublicPathChangePlugin.js +226 -0
  93. package/lib/plugins/ReportGeneratePlugin.js +181 -0
  94. package/lib/plugins/RequireVariablePublicPlugin.js +30 -0
  95. package/lib/plugins/ResourceHintsPlugin.js +67 -0
  96. package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +80 -0
  97. package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +82 -0
  98. package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -0
  99. package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +26 -0
  100. package/lib/plugins/ScriptInstrumentPlugin.js +22 -37
  101. package/lib/plugins/ServiceWorkerPlugin.js +107 -0
  102. package/lib/plugins/ShadowDOMSupportPlugin.js +270 -0
  103. package/lib/plugins/SourceMapHookPlugin.js +25 -59
  104. package/lib/plugins/TPHashMappingPlugin.js +67 -0
  105. package/lib/plugins/UglifyCSSPlugin.js +39 -0
  106. package/lib/plugins/UnusedFilesFindPlugin.js +150 -97
  107. package/lib/plugins/index.js +127 -37
  108. package/lib/plugins/libraryImpactPlugin.js +190 -0
  109. package/lib/plugins/webpackwatchrunplugin.js +26 -0
  110. package/lib/postcss-plugins/ExcludePlugin.js +23 -0
  111. package/lib/postcss-plugins/RTLSplitPlugin.js +138 -0
  112. package/lib/postcss-plugins/ValueReplacer.js +46 -0
  113. package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +22 -0
  114. package/lib/postcss-plugins/__test__/test1Input.css +39 -0
  115. package/lib/postcss-plugins/__test__/test1Output.css +39 -0
  116. package/lib/postcss-plugins/hoverActivePlugin.js +365 -0
  117. package/lib/postcss-plugins/variableModifier.js +243 -0
  118. package/lib/schemas/index.js +534 -66
  119. package/lib/servers/clusterHubServer.js +22 -26
  120. package/lib/servers/devBuild.js +102 -0
  121. package/lib/servers/docsServer.js +3 -5
  122. package/lib/servers/docsServerCore.js +94 -79
  123. package/lib/servers/getCliPath.js +28 -0
  124. package/lib/servers/helpServer.js +19 -21
  125. package/lib/servers/httpsOptions.js +18 -0
  126. package/lib/servers/impactServer.js +123 -115
  127. package/lib/servers/mockserver.js +44 -0
  128. package/lib/servers/nowatchserver.js +200 -0
  129. package/lib/servers/scrServer.js +147 -0
  130. package/lib/servers/server.js +134 -132
  131. package/lib/servers/ssServer.js +106 -70
  132. package/lib/sh/reportPublish.sh +16 -10
  133. package/lib/templates/CoverageScriptTemplate.js +45 -18
  134. package/lib/templates/WMSTemplate.js +17 -18
  135. package/lib/templates/linterConstant.js +10 -0
  136. package/lib/utils/babelPresets.js +12 -4
  137. package/lib/utils/buildstats.html +148 -0
  138. package/lib/utils/clean.js +12 -11
  139. package/lib/utils/copy.js +16 -109
  140. package/lib/utils/copyTimezones.js +21 -0
  141. package/lib/utils/createEventStream.js +24 -19
  142. package/lib/utils/cssClassNameGenerate.js +77 -0
  143. package/lib/utils/cssURLReplacer.js +136 -0
  144. package/lib/utils/dependencyPostPublish.js +42 -0
  145. package/lib/utils/fileUtils.js +125 -0
  146. package/lib/utils/folderIterator.js +47 -0
  147. package/lib/utils/getComponents.js +126 -0
  148. package/lib/utils/getCurrentBranch.js +11 -17
  149. package/lib/utils/getDependenciesImpactList.js +151 -0
  150. package/lib/utils/getHash.js +26 -0
  151. package/lib/utils/getIp.js +20 -0
  152. package/lib/utils/getOptions.js +113 -28
  153. package/lib/utils/getServerURL.js +25 -8
  154. package/lib/utils/index.js +283 -68
  155. package/lib/utils/init.js +2 -2
  156. package/lib/utils/initPreCommitHook.js +47 -27
  157. package/lib/utils/jsonHelper.js +106 -0
  158. package/lib/utils/libraryImpactConfig.js +63 -0
  159. package/lib/utils/lint/addScripts.js +27 -0
  160. package/lib/utils/lint/checkExistingConfig.js +67 -0
  161. package/lib/utils/lint/copyConfigs.js +24 -0
  162. package/lib/utils/lint/index.js +54 -0
  163. package/lib/utils/lint/lintScripts.js +11 -0
  164. package/lib/utils/lint/lintSetup.js +31 -0
  165. package/lib/utils/lint/lintStagedPreCommitHook.js +7 -0
  166. package/lib/utils/lint/question.js +30 -0
  167. package/lib/utils/lintReporter.js +142 -0
  168. package/lib/utils/mailSender.js +16 -25
  169. package/lib/utils/pullOrigin.js +28 -0
  170. package/lib/utils/reinstallDependencies.js +133 -0
  171. package/lib/utils/removeAttributes.js +25 -23
  172. package/lib/utils/repoClone.js +59 -63
  173. package/lib/utils/request.js +64 -77
  174. package/lib/utils/resultSchema.json +73 -0
  175. package/lib/utils/rtl.js +59 -0
  176. package/lib/utils/setEnvVariables.js +13 -0
  177. package/lib/utils/ssTestHack.js +48 -0
  178. package/lib/utils/switchBranch.js +28 -0
  179. package/lib/utils/urlConcat.js +22 -0
  180. package/lib/utils/useExitCleanup.js +55 -0
  181. package/npm8.md +9 -0
  182. package/package.json +96 -64
  183. package/postpublish.js +6 -0
  184. package/templates/app/.eslintrc.js +140 -0
  185. package/templates/app/README.md +12 -12
  186. package/templates/app/app/index.html +24 -8
  187. package/templates/app/app/properties/ApplicationResources_en_US.properties +1 -1
  188. package/templates/app/app/properties/i18nkeys.json +3 -3
  189. package/templates/app/docs/all.html +69 -69
  190. package/templates/app/mockapi/index.js +18 -13
  191. package/templates/app/package.json +37 -17
  192. package/templates/app/src/actions/SampleActions/index.js +37 -0
  193. package/templates/app/src/actions/index.js +65 -0
  194. package/templates/app/src/appUrls.js +19 -0
  195. package/templates/app/src/components/Alert/Alert.js +134 -0
  196. package/templates/app/src/components/Alert/Alert.module.css +79 -0
  197. package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -0
  198. package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -0
  199. package/templates/app/src/components/Sample/Sample.module.css +11 -0
  200. package/templates/app/src/components/Sample/SampleList.js +61 -0
  201. package/templates/app/src/components/Slider/Slider.css +41 -0
  202. package/templates/app/src/components/Slider/Slider.js +55 -0
  203. package/templates/app/src/containers/AlertContainer/index.js +15 -0
  204. package/templates/app/src/containers/AppContainer/index.js +96 -0
  205. package/templates/app/src/containers/AppContainer/index.module.css +27 -0
  206. package/templates/app/src/containers/CustomMatch/index.js +65 -0
  207. package/templates/app/src/containers/DevTools/index.js +10 -0
  208. package/templates/app/src/containers/Header/index.js +67 -0
  209. package/templates/app/src/containers/Header/index.module.css +43 -0
  210. package/templates/app/src/containers/Redirect/index.js +63 -0
  211. package/templates/app/src/containers/Redirector/index.js +47 -0
  212. package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -0
  213. package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -0
  214. package/templates/app/src/historyChange.js +5 -0
  215. package/templates/app/src/index.html +10 -0
  216. package/templates/app/src/index.js +24 -0
  217. package/templates/app/src/middleware/PromiseMiddleware.js +59 -0
  218. package/templates/app/src/reducers/alertData.js +11 -0
  219. package/templates/app/src/reducers/index.js +6 -0
  220. package/templates/app/src/reducers/samples.js +19 -0
  221. package/templates/app/src/store/configureStore.dev.js +51 -0
  222. package/templates/app/src/store/configureStore.js +5 -0
  223. package/templates/app/src/store/configureStore.prod.js +26 -0
  224. package/templates/app/src/util/Common.js +5 -0
  225. package/templates/app/src/util/RequestAPI.js +132 -0
  226. package/templates/appold/README.md +12 -0
  227. package/templates/appold/app/index.html +8 -0
  228. package/templates/appold/app/properties/ApplicationResources_en_US.properties +1 -0
  229. package/templates/appold/app/properties/i18nkeys.json +3 -0
  230. package/templates/appold/docs/all.html +69 -0
  231. package/templates/appold/mockapi/index.js +13 -0
  232. package/templates/{app → appold}/mockapi/tickets.json +0 -0
  233. package/templates/appold/package.json +17 -0
  234. package/templates/appold/src/components/Text/Text.css +0 -0
  235. package/templates/appold/src/components/Text/Text.js +23 -0
  236. package/templates/appold/src/components/Text/__tests__/Text.spec.js +30 -0
  237. package/templates/appold/src/components/Text/docs/Text__default.docs.js +16 -0
  238. package/templates/appold/src/components/docs.js +1 -0
  239. package/templates/appold/src/components/index.js +5 -0
  240. package/templates/appold/src/index.js +13 -0
  241. package/templates/docs/all.html +1 -1
  242. package/templates/docs/component.html +110 -69
  243. package/templates/docs/components.html +221 -0
  244. package/templates/docs/css/component.css +12 -14
  245. package/templates/docs/css/componentTest.css +7 -0
  246. package/templates/docs/css/style.css +150 -206
  247. package/templates/docs/impactReportTemplate.html +154 -0
  248. package/templates/docs/index.html +1482 -1336
  249. package/templates/library/src/index.js +0 -0
  250. package/.npmignore +0 -3
  251. package/cert/cert.pem +0 -129
  252. package/cert/key.pem +0 -27
  253. package/lib/common/getInsertAt.js +0 -36
  254. package/lib/common/getInsertIntoFunction.js +0 -13
  255. package/lib/configs/webpack.server.config.js +0 -93
  256. package/lib/plugins/ChunkManifestReplacePlugin.js +0 -94
  257. package/lib/plugins/RuntimePublicPathPlugin.js +0 -46
  258. package/lib/rmcntrlm.sh +0 -14
  259. package/lib/servers/nodeServer.js +0 -238
  260. package/lib/templates/HMRTemplate.js +0 -256
  261. package/lib/templates/publicPathTemplate.js +0 -16
  262. package/lib/utils/setConfig.js +0 -14
  263. package/node_modules/history/CHANGES.md +0 -395
  264. package/node_modules/history/DOMUtils.js +0 -3
  265. package/node_modules/history/ExecutionEnvironment.js +0 -3
  266. package/node_modules/history/LICENSE +0 -21
  267. package/node_modules/history/LocationUtils.js +0 -3
  268. package/node_modules/history/PathUtils.js +0 -3
  269. package/node_modules/history/README.md +0 -282
  270. package/node_modules/history/cjs/history.js +0 -933
  271. package/node_modules/history/cjs/history.min.js +0 -1
  272. package/node_modules/history/createBrowserHistory.js +0 -3
  273. package/node_modules/history/createHashHistory.js +0 -3
  274. package/node_modules/history/createMemoryHistory.js +0 -3
  275. package/node_modules/history/createTransitionManager.js +0 -3
  276. package/node_modules/history/es/DOMUtils.js +0 -7
  277. package/node_modules/history/es/ExecutionEnvironment.js +0 -7
  278. package/node_modules/history/es/LocationUtils.js +0 -7
  279. package/node_modules/history/es/PathUtils.js +0 -7
  280. package/node_modules/history/es/createBrowserHistory.js +0 -7
  281. package/node_modules/history/es/createHashHistory.js +0 -7
  282. package/node_modules/history/es/createMemoryHistory.js +0 -7
  283. package/node_modules/history/es/createTransitionManager.js +0 -7
  284. package/node_modules/history/es/warnAboutDeprecatedESMImport.js +0 -35
  285. package/node_modules/history/esm/history.js +0 -904
  286. package/node_modules/history/index.js +0 -7
  287. package/node_modules/history/package.json +0 -134
  288. package/node_modules/history/umd/history.js +0 -1059
  289. package/node_modules/history/umd/history.min.js +0 -1
  290. package/node_modules/history/warnAboutDeprecatedCJSRequire.js +0 -35
  291. package/templates/app/.npmignore +0 -9
  292. package/templates/library/.npmignore +0 -9
@@ -0,0 +1,24 @@
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
+ module: {
12
+ mode
13
+ }
14
+ } = (0, _utils.getOptions)();
15
+ let isProd = mode.toLowerCase() === 'prod';
16
+
17
+ var _default = () => ({
18
+ presets: [require.resolve('@babel/preset-env'), require.resolve('@babel/preset-react')],
19
+ plugins: [[require.resolve('babel-plugin-transform-define'), isProd ? {
20
+ __DOCS__: false
21
+ } : {}]]
22
+ });
23
+
24
+ exports.default = _default;
@@ -0,0 +1,34 @@
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
+ module: {
12
+ mode,
13
+ disableES5Transpile
14
+ }
15
+ } = (0, _utils.getOptions)();
16
+ let isProd = mode.toLowerCase() === 'prod';
17
+
18
+ var _default = () => ({
19
+ presets: [[require.resolve('@babel/preset-env'), disableES5Transpile ? {
20
+ modules: false,
21
+ useBuiltIns: 'usage',
22
+ corejs: 3,
23
+ targets: {
24
+ browsers: ['last 3 Chrome versions', 'last 3 Firefox versions', 'last 3 Edge versions', 'last 3 Safari versions']
25
+ }
26
+ } : {
27
+ modules: false
28
+ }], require.resolve('@babel/preset-react')],
29
+ plugins: [[require.resolve('babel-plugin-transform-define'), isProd ? {
30
+ __DOCS__: false
31
+ } : {}], require.resolve('@babel/plugin-syntax-dynamic-import')]
32
+ });
33
+
34
+ exports.default = _default;
@@ -1,65 +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
- js = _appSchemas$app.staticDomainKeys.js;
24
-
25
-
26
- var mainJs = [];
27
- var entry = { main: mainJs };
28
-
29
- if (mode === 'development') {
30
- var hotReload = server.hotReload;
31
-
32
-
33
- mainJs.push(_path2.default.join(__dirname, '..', 'templates', 'WMSTemplate') + '?wmsPath=wss:' + (0, _utils.getServerURL)(server));
34
-
35
- if (hotReload) {
36
- // let url = getServerURL(server);
37
- // mainJs.push(require.resolve('react-dev-utils/webpackHotDevClient'));
38
- // mainJs.push(require.resolve('react-error-overlay'));
39
- }
40
- } else if (mode === 'production') {
41
- mainJs.push(require.resolve('../templates/publicPathTemplate.js') + '?js=' + js);
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)}`);
42
36
  }
43
37
 
44
- 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'));
45
39
 
46
40
  if (hasWidget) {
47
- entry.widget = [];
48
- entry.efc = [];
49
- if (mode === 'production') {
50
- /* no need this one - webpack4 multi entry build system updated*/
51
- entry.widget.push(require.resolve('../templates/publicPathTemplate.js') + '?js=' + js);
52
- }
53
- entry.widget.push(_path2.default.join(appPath, folder, 'widget.js'));
41
+ entry.widget = [_path.default.join(appPath, folder, 'widget.js')];
54
42
  }
43
+
55
44
  if (hasEFC) {
56
- if (mode === 'production') {
57
- /* no need this one - webpack4 multi entry build system updated*/
58
- entry.efc.push(require.resolve('../templates/publicPathTemplate.js') + '?js=' + js);
59
- }
60
- entry.efc.push(_path2.default.join(appPath, folder, 'efc.js'));
45
+ entry.efc = [_path.default.join(appPath, folder, 'efc.js')];
61
46
  }
62
47
 
63
48
  return entry;
64
49
  };
65
- 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,34 +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, "getEntries", {
10
7
  enumerable: true,
11
- get: function get() {
12
- return _interopRequireDefault(_splitChunks).default;
8
+ get: function () {
9
+ return _getEntries.default;
13
10
  }
14
11
  });
15
-
16
- var _getEntries = require('./getEntries');
17
-
18
- Object.defineProperty(exports, 'getEntries', {
12
+ Object.defineProperty(exports, "getPublicPathConfig", {
19
13
  enumerable: true,
20
- get: function get() {
21
- return _interopRequireDefault(_getEntries).default;
14
+ get: function () {
15
+ return _getPublicPathConfig.default;
22
16
  }
23
17
  });
24
-
25
- var _getInsertIntoFunction = require('./getInsertIntoFunction');
26
-
27
- Object.defineProperty(exports, 'getInsertIntoFunction', {
18
+ Object.defineProperty(exports, "splitChunks", {
28
19
  enumerable: true,
29
- get: function get() {
30
- return _interopRequireDefault(_getInsertIntoFunction).default;
20
+ get: function () {
21
+ return _splitChunks.default;
31
22
  }
32
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"));
33
38
 
34
39
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -1,41 +1,126 @@
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 _os = _interopRequireDefault(require("os"));
11
+
12
+ var _utils = require("../utils");
13
+
14
+ var _testPattern = require("./testPattern");
10
15
 
11
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
17
 
13
- var isVendor = function isVendor(module) {
14
- var userRequest = module.userRequest;
18
+ let isWindows = _os.default.platform().toLowerCase() === 'win32';
19
+ let ps = _path.default.sep;
20
+ let options = (0, _utils.getOptions)();
21
+ let {
22
+ app: {
23
+ vendorExclude,
24
+ customChunks,
25
+ vendorInclude
26
+ }
27
+ } = options;
15
28
 
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;
29
+ let isVendor = function isVendor(module) {
30
+ let {
31
+ userRequest
32
+ } = module;
33
+ let excludeList = ['script-loader', 'raw-loader', 'react', 'react-dom'];
34
+ excludeList = [...excludeList, ...vendorExclude];
35
+ 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
36
  };
18
37
 
19
- var isReact = function isReact(module) {
20
- var userRequest = module.userRequest;
38
+ let isReact = module => {
39
+ let {
40
+ userRequest
41
+ } = module;
42
+ let reactBundle = ['react', 'react-dom'];
43
+ return userRequest && reactBundle.some(pkg => userRequest.indexOf(`node_modules${ps}${pkg}${ps}`) >= 0);
44
+ };
21
45
 
22
- return userRequest && userRequest.indexOf('node_modules' + _path2.default.sep + 'react') >= 0;
46
+ let defaultChunks = {
47
+ 'react.vendor': {
48
+ name: 'react.vendor',
49
+ chunks: 'all',
50
+ minChunks: 1,
51
+ test: isReact,
52
+ enforce: true,
53
+ // priority: 10
54
+ priority: -10
55
+ },
56
+ vendor: {
57
+ name: 'vendor',
58
+ chunks: 'all',
59
+ // chunks: 'initial',
60
+ minChunks: 1,
61
+ test: isVendor,
62
+ // priority: 19,
63
+ priority: -10
64
+ }
23
65
  };
66
+ let customChunksConfig = {};
67
+ customChunks.map((obj, index) => ({
68
+ name: obj.name,
69
+ pattern: obj.pattern,
70
+ minChunks: obj.minChunks || obj.size || 2,
71
+ rules: obj.rules,
72
+ // includeDepenency: obj.includeDepenency || false,
73
+ priority: obj.priority || -10 * (index + 2),
74
+ enforce: obj.enforce || true,
75
+ maxSize: obj.maxSize,
76
+ // || 0,
77
+ minSize: obj.minSize,
78
+ // || 20000,
79
+ chunks: obj.chunks || 'all'
80
+ })).map(({
81
+ name,
82
+ pattern,
83
+ minChunks,
84
+ rules,
85
+ priority,
86
+ // includeDepenency,
87
+ enforce,
88
+ minSize,
89
+ maxSize,
90
+ chunks = 'all'
91
+ }) => {
92
+ let obj = {
93
+ name,
94
+ test: rules ? m => {
95
+ const {
96
+ userRequest
97
+ } = m;
98
+ return (0, _testPattern.testPattern)(userRequest, rules); // return (
99
+ // pkgs.some(p => isRelated(userRequest, p)) ||
100
+ // (includeDepenency && isDependency(m, pkgs))
101
+ // );
102
+ } : new RegExp(isWindows ? pattern.replace(/\//g, '\\') : pattern),
103
+ chunks,
104
+ enforce,
105
+ minChunks,
106
+ priority
107
+ };
24
108
 
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
- }
109
+ if (minSize !== undefined) {
110
+ obj.minSize = minSize;
40
111
  }
41
- };
112
+
113
+ if (maxSize !== undefined) {
114
+ obj.maxSize = maxSize;
115
+ }
116
+
117
+ return customChunksConfig[name] = obj;
118
+ });
119
+ var _default = {
120
+ minSize: 12000,
121
+ cacheGroups: Object.assign({
122
+ default: false,
123
+ vendors: false
124
+ }, defaultChunks, customChunksConfig)
125
+ };
126
+ 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;
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isDependency = isDependency;
7
+ exports.isRelatedPackage = exports.isRelated = void 0;
8
+ exports.testPattern = testPattern;
9
+
10
+ var _path = require("path");
11
+
12
+ // in our development we only use windows, mac and linux
13
+ const isWindows = _path.sep !== '/'; // this function will return true if pattern matched
14
+
15
+ function _testPattern(req, pattern) {
16
+ let modifyedPattern = pattern;
17
+
18
+ if (/[*.$^]/.test(modifyedPattern)) {
19
+ if (isWindows) {
20
+ // modifyedPattern = pattern.replace(/\//g, ps.replace(/\\/g, '\\\\'));
21
+ modifyedPattern = modifyedPattern.replace(/\//g, '\\\\');
22
+ }
23
+
24
+ modifyedPattern = modifyedPattern.replace(/\./g, '\\.').replace(/\*/g, '.*');
25
+ const re = new RegExp(modifyedPattern);
26
+ return re.test(req);
27
+ }
28
+
29
+ if (isWindows) {
30
+ // modifyedPattern = pattern.replace(/\//g, ps.replace(/\\/g, '\\\\'));
31
+ modifyedPattern = modifyedPattern.replace(/\//g, '\\');
32
+ }
33
+
34
+ return req.indexOf(modifyedPattern) !== -1;
35
+ }
36
+
37
+ function testPattern(req, pattern) {
38
+ if (!req || !pattern) {
39
+ return false;
40
+ }
41
+
42
+ if (Array.isArray(pattern)) {
43
+ // eslint-disable-next-line no-unused-vars
44
+ return pattern.every(p => testPattern(req, p));
45
+ }
46
+
47
+ if (pattern[0] === '!') {
48
+ return !_testPattern(req, pattern.slice(1));
49
+ }
50
+
51
+ return _testPattern(req, pattern);
52
+ }
53
+
54
+ const isRelated = (req, item) => req && req.indexOf(item) !== -1; // export const isRelated = (req, item) => testPattern(req, item);
55
+
56
+
57
+ exports.isRelated = isRelated;
58
+
59
+ const isRelatedPackage = (req, item) => isRelated(req, `node_modules${_path.sep}${item}${_path.sep}`) !== -1; // export const isRelated = (req, item) => testPattern(req, item);
60
+
61
+
62
+ exports.isRelatedPackage = isRelatedPackage;
63
+
64
+ function isDependency(m, excludeList) {
65
+ // let reasons = m.reasons.map(r => r.module.userRequest);
66
+ // m.reasons.some(r => !r.module || !r.module.userRequest) && console.log(m.reasons);
67
+ return m.reasons.some(r => excludeList.some(item => r.module && isRelated(r.module.userRequest, item)));
68
+ } // export function queryHandler(conditions, pattern) {
69
+ // }
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+
3
+ var _postcss = _interopRequireDefault(require("postcss"));
4
+
5
+ var _path = _interopRequireDefault(require("path"));
6
+
7
+ var _fs = _interopRequireDefault(require("fs"));
8
+
9
+ var _folderIterator = _interopRequireDefault(require("../utils/folderIterator"));
10
+
11
+ var _utils = require("../utils");
12
+
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
+
15
+ const cwd = process.cwd();
16
+
17
+ const src = _path.default.join(cwd, process.argv[2]);
18
+
19
+ const dist = _path.default.join(cwd, process.argv[3]);
20
+
21
+ const docopy = process.argv[4] === 'true';
22
+ const {
23
+ css: {
24
+ valueReplacer
25
+ }
26
+ } = (0, _utils.getOptions)();
27
+
28
+ if (!_fs.default.existsSync(dist)) {
29
+ _fs.default.mkdirSync(dist, {
30
+ recursive: true
31
+ });
32
+ }
33
+
34
+ (0, _folderIterator.default)(src, dist, docopy ? false : ['.css'], false, (fromPath, toPath) => {
35
+ //console.log({ fromPath: fromPath, toPath: toPath });
36
+ let css = _fs.default.readFileSync(fromPath);
37
+
38
+ if (docopy && !fromPath.endsWith('.css')) {
39
+ //console.log(toPath,'....');
40
+ _fs.default.writeFileSync(toPath, css);
41
+
42
+ return;
43
+ }
44
+
45
+ (0, _postcss.default)([valueReplacer && require('../postcss-plugins/ValueReplacer')(valueReplacer)]).process(css, {
46
+ from: fromPath,
47
+ to: toPath
48
+ }).then(result => {
49
+ _fs.default.writeFile(toPath, result.css, () => true);
50
+
51
+ if (result.map) {
52
+ _fs.default.writeFile(`${toPath}.map`, result.map, () => true);
53
+ }
54
+ });
55
+ });