@zohodesk/client_build_tool 0.0.22-exp.4 → 0.0.22-exp.5

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 (240) hide show
  1. package/README.md +0 -723
  2. package/README_backup.md +0 -723
  3. package/app/README.MD +30 -0
  4. package/app/es/test.js +47 -0
  5. package/app/package.json +12 -0
  6. package/lib/schemas/defaultConfigValues.js +3 -6
  7. package/lib/shared/babel/babelWebConfig.js +2 -1
  8. package/lib/shared/bundler/webpack/custom_plugins/BundleIntegrityReport/utils.js +15 -0
  9. package/lib/shared/bundler/webpack/entryConfig.js +2 -3
  10. package/lib/shared/bundler/webpack/moduleConcatenationConfig.js +18 -0
  11. package/lib/shared/bundler/webpack/optimizationConfig.js +8 -10
  12. package/lib/shared/bundler/webpack/pluginConfigs/configHtmlWebpackPlugin.js +1 -1
  13. package/lib/shared/bundler/webpack/pluginConfigs/configI18nSplitPlugin.js +1 -1
  14. package/lib/shared/bundler/webpack/pluginConfigs/configServiceWorkerPlugin.js +1 -1
  15. package/package.json +1 -1
  16. package/es/allCommandsConfigs.js +0 -15
  17. package/es/commands/build/commandExecutor.js +0 -6
  18. package/es/commands/build/config.js +0 -5
  19. package/es/commands/build/optionsProcessor.js +0 -25
  20. package/es/commands/build/preProcessor.js +0 -4
  21. package/es/commands/buildEs/commandExecutor.js +0 -29
  22. package/es/commands/buildEs/config.js +0 -5
  23. package/es/commands/buildEs/preProcessor.js +0 -9
  24. package/es/commands/buildLib/commandExecutor.js +0 -24
  25. package/es/commands/buildLib/config.js +0 -5
  26. package/es/commands/buildLib/preProcessor.js +0 -9
  27. package/es/commands/mockserver/commandExecutor.js +0 -32
  28. package/es/commands/mockserver/config.js +0 -5
  29. package/es/commands/pre_process/commandExecutor.js +0 -10
  30. package/es/commands/pre_process/config.js +0 -5
  31. package/es/commands/start/commandExecutor.js +0 -4
  32. package/es/commands/start/config.js +0 -5
  33. package/es/commands/start/optionsProcessor.js +0 -21
  34. package/es/commands/start/preProcessor.js +0 -4
  35. package/es/commands/template/commandExecutor.js +0 -17
  36. package/es/commands/template/config.js +0 -5
  37. package/es/commands/version/commandExecutor.js +0 -5
  38. package/es/commands/version/config.js +0 -5
  39. package/es/commandsRouter.js +0 -58
  40. package/es/index.js +0 -4
  41. package/es/logger.js +0 -23
  42. package/es/schemas/applyValuesToSchema/index.js +0 -25
  43. package/es/schemas/applyValuesToSchema/isObject.js +0 -3
  44. package/es/schemas/applyValuesToSchema/isValid.js +0 -7
  45. package/es/schemas/cliArgsToObject.js +0 -32
  46. package/es/schemas/defaultConfigValues.js +0 -394
  47. package/es/schemas/defaultConfigValuesOnly.js +0 -196
  48. package/es/schemas/deprecatedOptionsHandler.js +0 -60
  49. package/es/schemas/getNpmVersion.js +0 -13
  50. package/es/schemas/giveDefaultValue.js +0 -11
  51. package/es/schemas/npmConfigToObject.js +0 -27
  52. package/es/schemas/readOptions.js +0 -67
  53. package/es/schemas/readOptionsForConfigFile.js +0 -28
  54. package/es/shared/babel/addDefaultPlugins.js +0 -8
  55. package/es/shared/babel/babelWebConfig.js +0 -43
  56. package/es/shared/babel/babel_plugins/removeAttributesPlugin.js +0 -21
  57. package/es/shared/babel/getBabelPlugin.js +0 -36
  58. package/es/shared/babel/runBabelForJSFile.js +0 -15
  59. package/es/shared/babel/runBabelForTsFile.js +0 -34
  60. package/es/shared/bundler/webpack/common/decidePublicPath.js +0 -45
  61. package/es/shared/bundler/webpack/common/libAlias.js +0 -24
  62. package/es/shared/bundler/webpack/common/modeUtils.js +0 -24
  63. package/es/shared/bundler/webpack/common/nameTemplates.js +0 -95
  64. package/es/shared/bundler/webpack/common/resourceBasedPublicPath.js +0 -12
  65. package/es/shared/bundler/webpack/configCustomLoaders.js +0 -3
  66. package/es/shared/bundler/webpack/cssLoaders.js +0 -8
  67. package/es/shared/bundler/webpack/custom_plugins/BundleIntegrityReport/index.js +0 -76
  68. package/es/shared/bundler/webpack/custom_plugins/CdnChangePlugin/index.js +0 -102
  69. package/es/shared/bundler/webpack/custom_plugins/CdnChangePlugin/webpackCustomJsUrlLoader.js +0 -36
  70. package/es/shared/bundler/webpack/custom_plugins/ChunkHierarchyPlugin.js +0 -65
  71. package/es/shared/bundler/webpack/custom_plugins/CssCustomOrderPlugin.js +0 -37
  72. package/es/shared/bundler/webpack/custom_plugins/CustomScriptLoadingPlugin.js +0 -97
  73. package/es/shared/bundler/webpack/custom_plugins/EFCTemplatePlugin.js +0 -98
  74. package/es/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nNumericIndexPlugin.js +0 -211
  75. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/ContributionGuide.md +0 -11
  76. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nFilesEmitPlugin.js +0 -160
  77. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nKeysIdentifer.js +0 -66
  78. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nRuntimeDealerPlugin.js +0 -201
  79. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nSplit.md +0 -95
  80. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/LocaleChunkAssetsStore.js +0 -59
  81. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/ModulesI18nKeysStore.js +0 -82
  82. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/README.md +0 -25
  83. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/constants.js +0 -13
  84. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/createHash.js +0 -15
  85. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/getI18nLoadingRuntimeModule.js +0 -72
  86. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/index.js +0 -23
  87. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/iterateModulesInChunk.js +0 -40
  88. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/optionsHandler.js +0 -59
  89. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/pathCreator.js +0 -15
  90. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/readI18nValues.js +0 -22
  91. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/templateFileName.js +0 -35
  92. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/templateHashHelpers.js +0 -70
  93. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/collectI18nKeys.js +0 -56
  94. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/getChunkModules.js +0 -6
  95. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/hashUtils.js +0 -10
  96. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/index.js +0 -2
  97. package/es/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/propertiesUtils.js +0 -121
  98. package/es/shared/bundler/webpack/custom_plugins/InitialHtmlPlugin.js +0 -85
  99. package/es/shared/bundler/webpack/custom_plugins/InjectChunkGraphPlugin.js +0 -47
  100. package/es/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/addFilesNamesToManifestJson.js +0 -20
  101. package/es/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/createInitialEntries.js +0 -11
  102. package/es/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/createManifestJson.js +0 -26
  103. package/es/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/findInitialFileNames.js +0 -11
  104. package/es/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/index.js +0 -34
  105. package/es/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/removeHashFromFileName.js +0 -11
  106. package/es/shared/bundler/webpack/custom_plugins/MurphyInjectorPlugin/index.js +0 -79
  107. package/es/shared/bundler/webpack/custom_plugins/RTLSplitPlugin.js +0 -0
  108. package/es/shared/bundler/webpack/custom_plugins/ResourceHintsPlugin.js +0 -185
  109. package/es/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +0 -47
  110. package/es/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/RtlCssPlugin.js +0 -70
  111. package/es/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/RtrSplit.md +0 -34
  112. package/es/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/replaceCssDirTemplate.js +0 -14
  113. package/es/shared/bundler/webpack/custom_plugins/RuntimeResourceCleanup/index.js +0 -63
  114. package/es/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/classHandling.js +0 -9
  115. package/es/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/index.js +0 -63
  116. package/es/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/selectorWeightPrefixAdder.js +0 -43
  117. package/es/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/windowsModification.js +0 -7
  118. package/es/shared/bundler/webpack/custom_plugins/ServiceWorkerPlugin.js +0 -104
  119. package/es/shared/bundler/webpack/custom_plugins/ServiceWorkerPluginUtils.js +0 -6
  120. package/es/shared/bundler/webpack/custom_plugins/SourceMapPlugin/index.js +0 -74
  121. package/es/shared/bundler/webpack/custom_plugins/TPHashMappingPlugin/addHashToFilePath.js +0 -10
  122. package/es/shared/bundler/webpack/custom_plugins/TPHashMappingPlugin/index.js +0 -36
  123. package/es/shared/bundler/webpack/custom_plugins/UglifyCSSPlugin/index.js.js +0 -35
  124. package/es/shared/bundler/webpack/custom_plugins/VariableConversionCollector/ErrorHandler.js +0 -52
  125. package/es/shared/bundler/webpack/custom_plugins/VariableConversionCollector/index.js +0 -341
  126. package/es/shared/bundler/webpack/custom_plugins/custom_attribute_plugin/index.js +0 -67
  127. package/es/shared/bundler/webpack/custom_plugins/emitAsset.js +0 -7
  128. package/es/shared/bundler/webpack/custom_plugins/getInitialAssetsFuncTemplate.js +0 -43
  129. package/es/shared/bundler/webpack/custom_plugins/getInitialI18nAssetsArrayStr.js +0 -79
  130. package/es/shared/bundler/webpack/defaultVendorPatternList.js +0 -3
  131. package/es/shared/bundler/webpack/devtoolConfig.js +0 -6
  132. package/es/shared/bundler/webpack/entryConfig.js +0 -25
  133. package/es/shared/bundler/webpack/externals.js +0 -10
  134. package/es/shared/bundler/webpack/getCSSLoaders.js +0 -17
  135. package/es/shared/bundler/webpack/getFilenameFromModule.js +0 -15
  136. package/es/shared/bundler/webpack/jsLoaders.js +0 -16
  137. package/es/shared/bundler/webpack/loaderConfigs/assetLoaders.js +0 -4
  138. package/es/shared/bundler/webpack/loaderConfigs/babelLoaderConfig.js +0 -10
  139. package/es/shared/bundler/webpack/loaderConfigs/checkIsPatternsMatchFilename.js +0 -45
  140. package/es/shared/bundler/webpack/loaderConfigs/configHtmlTemplateLoader.js +0 -11
  141. package/es/shared/bundler/webpack/loaderConfigs/configPostCssLoader.js +0 -23
  142. package/es/shared/bundler/webpack/loaderConfigs/configWebWorkerLoader.js +0 -13
  143. package/es/shared/bundler/webpack/loaderConfigs/configsAssetsLoaders.js +0 -71
  144. package/es/shared/bundler/webpack/loaderConfigs/cssClassNameGenerate.js +0 -56
  145. package/es/shared/bundler/webpack/loaderConfigs/getCssLoaderOptions.js +0 -11
  146. package/es/shared/bundler/webpack/loaderConfigs/i18nIdReplaceLoaderConfig.js +0 -40
  147. package/es/shared/bundler/webpack/loaders/i18nIdReplaceLoader.js +0 -116
  148. package/es/shared/bundler/webpack/loaders/miniCssFallBackLoader.js +0 -5
  149. package/es/shared/bundler/webpack/loaders/workerLoader.js +0 -121
  150. package/es/shared/bundler/webpack/optimizationConfig.js +0 -42
  151. package/es/shared/bundler/webpack/outputConfig.js +0 -35
  152. package/es/shared/bundler/webpack/pluginConfigs/configBundleAnalyzer.js +0 -30
  153. package/es/shared/bundler/webpack/pluginConfigs/configBundleIntegrityReport.js +0 -27
  154. package/es/shared/bundler/webpack/pluginConfigs/configCSSMinifierPlugin.js +0 -17
  155. package/es/shared/bundler/webpack/pluginConfigs/configCdnChangePlugin.js +0 -16
  156. package/es/shared/bundler/webpack/pluginConfigs/configChunkHierarchyPlugin.js +0 -10
  157. package/es/shared/bundler/webpack/pluginConfigs/configCopyPublicFolders.js +0 -50
  158. package/es/shared/bundler/webpack/pluginConfigs/configCssCustomOrderPlugin.js +0 -8
  159. package/es/shared/bundler/webpack/pluginConfigs/configCustomAttributesPlugin.js +0 -12
  160. package/es/shared/bundler/webpack/pluginConfigs/configCustomScriptLoadingStrategyPlugin.js +0 -67
  161. package/es/shared/bundler/webpack/pluginConfigs/configEFCTemplatePlugin.js +0 -37
  162. package/es/shared/bundler/webpack/pluginConfigs/configEnvVariables.js +0 -43
  163. package/es/shared/bundler/webpack/pluginConfigs/configHtmlWebpackPlugin.js +0 -52
  164. package/es/shared/bundler/webpack/pluginConfigs/configI18nNumericIndexPlugin.js +0 -17
  165. package/es/shared/bundler/webpack/pluginConfigs/configI18nSplitPlugin.js +0 -29
  166. package/es/shared/bundler/webpack/pluginConfigs/configIgnorePlugin.js +0 -8
  167. package/es/shared/bundler/webpack/pluginConfigs/configInjectChunkGraphPlugin.js +0 -12
  168. package/es/shared/bundler/webpack/pluginConfigs/configManifestJsonPlugin.js +0 -36
  169. package/es/shared/bundler/webpack/pluginConfigs/configMiniCSSExtractPlugin.js +0 -13
  170. package/es/shared/bundler/webpack/pluginConfigs/configMurphyInjectorPlugin.js +0 -19
  171. package/es/shared/bundler/webpack/pluginConfigs/configProgressPlugin.js +0 -18
  172. package/es/shared/bundler/webpack/pluginConfigs/configResourceHintsPlugin.js +0 -11
  173. package/es/shared/bundler/webpack/pluginConfigs/configRtlCssPlugin.js +0 -19
  174. package/es/shared/bundler/webpack/pluginConfigs/configRuntimeResourceCleanup.js +0 -20
  175. package/es/shared/bundler/webpack/pluginConfigs/configSelectorWeightPlugin.js +0 -18
  176. package/es/shared/bundler/webpack/pluginConfigs/configServiceWorkerPlugin.js +0 -29
  177. package/es/shared/bundler/webpack/pluginConfigs/configSourceMapPlugin.js +0 -12
  178. package/es/shared/bundler/webpack/pluginConfigs/configTPHashMappingPlugin.js +0 -20
  179. package/es/shared/bundler/webpack/pluginConfigs/configVariableConversionPlugin.js +0 -15
  180. package/es/shared/bundler/webpack/plugins.js +0 -33
  181. package/es/shared/bundler/webpack/resolvers.js +0 -70
  182. package/es/shared/bundler/webpack/splitChunksConfig.js +0 -106
  183. package/es/shared/bundler/webpack/statsConfig.js +0 -23
  184. package/es/shared/bundler/webpack/tsLoaders.js +0 -16
  185. package/es/shared/bundler/webpack/utils/index.js +0 -8
  186. package/es/shared/bundler/webpack/utils/object-manipulation.js +0 -82
  187. package/es/shared/bundler/webpack/utils/updateArrayWithDefault.js +0 -29
  188. package/es/shared/bundler/webpack/webpackBuild.js +0 -14
  189. package/es/shared/bundler/webpack/webpackConfig.js +0 -35
  190. package/es/shared/commands-utils/doBasicRequirementCheck.js +0 -10
  191. package/es/shared/commands-utils/getCliPath.js +0 -28
  192. package/es/shared/commands-utils/index.js +0 -3
  193. package/es/shared/commands-utils/log.js +0 -4
  194. package/es/shared/commands-utils/readArgsFormCommandLine.js +0 -4
  195. package/es/shared/commands-utils/readOptionFormCommandLine.js +0 -4
  196. package/es/shared/commands-utils/spawnSyncIO.js +0 -24
  197. package/es/shared/constants.js +0 -22
  198. package/es/shared/fileUtils/copyFile.js +0 -23
  199. package/es/shared/fileUtils/directoryIterator.js +0 -12
  200. package/es/shared/fileUtils/watchRun.js +0 -96
  201. package/es/shared/postcss/custom_postcss_plugins/EmptyPlugin.js +0 -18
  202. package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/constants.js +0 -2
  203. package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/handleIgnores.js +0 -58
  204. package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/index.js +0 -122
  205. package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/insertBefore.js +0 -22
  206. package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/isPreviouslyProcessed.js +0 -11
  207. package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/replaceUtils.js +0 -13
  208. package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/separateHoveredSelectorAndNormalSelector.js +0 -17
  209. package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/specialCases.js +0 -32
  210. package/es/shared/postcss/custom_postcss_plugins/HoverActivePlugin/typeCheckUtils.js +0 -28
  211. package/es/shared/postcss/custom_postcss_plugins/RTLSplitPlugin.js +0 -125
  212. package/es/shared/postcss/custom_postcss_plugins/SelectorReplace.js +0 -82
  213. package/es/shared/postcss/custom_postcss_plugins/ValueReplacer.js +0 -50
  214. package/es/shared/postcss/custom_postcss_plugins/VariableModificationPlugin/index.js +0 -318
  215. package/es/shared/postcss/filterPluginsAllowedForSpecficFile.js +0 -41
  216. package/es/shared/postcss/getAllowedPostCssPlugins.js +0 -20
  217. package/es/shared/postcss/getSpecificPostCssPlugin.js +0 -38
  218. package/es/shared/postcss/runPostCssForCssFile.js +0 -25
  219. package/es/shared/pre_process/runPreProcess.js +0 -47
  220. package/es/shared/server/configWebpackDevMiddleware.js +0 -26
  221. package/es/shared/server/corsHandling.js +0 -23
  222. package/es/shared/server/getIp.js +0 -18
  223. package/es/shared/server/getServerURL.js +0 -28
  224. package/es/shared/server/httpsOptions.js +0 -36
  225. package/es/shared/server/initExpressApp.js +0 -9
  226. package/es/shared/server/initialHTMLHandling.js +0 -92
  227. package/es/shared/server/mockApiHandler.js +0 -53
  228. package/es/shared/server/mockServer.js +0 -34
  229. package/es/shared/server/serveContextFiles.js +0 -17
  230. package/es/shared/server/serverBywebpackDevMiddleware.js +0 -21
  231. package/es/shared/server/startHttpServer.js +0 -18
  232. package/es/shared/server/startHttpsServer.js +0 -26
  233. package/es/shared/server/unwanted/addHttp2Server.js +0 -32
  234. package/es/shared/server/unwanted/configWebpackDevMiddleware.js +0 -35
  235. package/es/shared/server/unwanted/mockApiSupport.js +0 -11
  236. package/es/shared/server/unwanted/websocketMockSetup.js +0 -36
  237. package/es/shared/server/urlConcat.js +0 -35
  238. package/es/shared/utils/requireLocalOrGlobal.js +0 -57
  239. package/es/shared/utils/utils.js +0 -0
  240. package/es/shared/utils/versionPrint.js +0 -9
@@ -1,92 +0,0 @@
1
- /* eslint-disable no-use-before-define */
2
- import { messageLogger, verboseLogger } from "../../logger";
3
- export function initialHTMLHandling(compiler, app, options) {
4
- const {
5
- enableMockReplace
6
- } = options;
7
- const {
8
- i18nChunkSplit
9
- } = options;
10
- const {
11
- rtlSplit
12
- } = options.css.plugins;
13
- const {
14
- httpsUrl,
15
- httpUrl,
16
- contextURL
17
- } = options.serverExtras;
18
- let initialHTML;
19
- compiler.hooks.afterCompile.tap('ReactCLI', compilation => {
20
- const indexHtml = compilation.assets['index.html']; // compiler.outputFileSystem.readFileSync("build/index.html");
21
-
22
- if (indexHtml) {
23
- initialHTML = indexHtml.source();
24
- }
25
- });
26
- compiler.hooks.compile.tap('ReactCLI', () => {
27
- messageLogger('Webpack re-building .......');
28
- });
29
- app.use(`${contextURL}/*`, (req, res) => {
30
- const newHTML = modifyInitialHTML({
31
- initialHTML,
32
- options,
33
- enableMockReplace,
34
- req
35
- });
36
- res.send(newHTML);
37
- });
38
-
39
- function modifyInitialHTML(_ref) {
40
- let {
41
- initialHTML,
42
- enableMockReplace,
43
- req
44
- } = _ref;
45
- let newHTML = enableMockReplace && initialHTML ? mockReplace(initialHTML, req.query) : initialHTML;
46
-
47
- if (req.protocol === 'http') {
48
- newHTML = newHTML.replaceAll(httpsUrl, httpUrl);
49
- }
50
-
51
- return newHTML;
52
- }
53
-
54
- function mockReplace(inputHTML, query) {
55
- const {
56
- dir,
57
- locale
58
- } = query || {};
59
- let newHTML = inputHTML;
60
-
61
- if (i18nChunkSplit.chunkSplitEnable) {
62
- newHTML = replaceWithRandomLocale(newHTML, i18nChunkSplit.templateLabel, locale);
63
- }
64
-
65
- if (rtlSplit.enableRTLSplit) {
66
- newHTML = replaceWithRandomDir(newHTML, rtlSplit.templateLabel, dir);
67
- }
68
-
69
- return newHTML;
70
- }
71
-
72
- function replaceWithRandomLocale(initialHTML, templateLabel, queryLocale) {
73
- const locales = ['ar_EG', 'da_DK', 'de_DE', 'en_US', 'es_AR', 'es_ES', 'fr_FR', 'hi_IN', 'in_ID', 'it_IT', 'iw_IL', 'ja_JP', 'nl_NL', 'pl_PL', 'pt_BR', 'pt_PT', 'ro_RO', 'ru_RU', 'sv_SE', 'ta_IN', 'te_IN', 'tr_TR', 'zh_CN', 'zh_TW']; // app.use(`/desk/*`, (req, res) => {
74
- // const locale = 'ta_IN';
75
-
76
- const locale = queryLocale || locales[Math.floor(Math.random() * locales.length)];
77
- verboseLogger({
78
- locale
79
- });
80
- return initialHTML.replaceAll(templateLabel, locale);
81
- }
82
-
83
- function replaceWithRandomDir(initialHTML, templateLabel, queryDir) {
84
- const dirs = ['ltr', 'rtl']; // const dir = 'rtl';
85
-
86
- const dir = queryDir || dirs[Math.floor(Math.random() * dirs.length)];
87
- verboseLogger({
88
- dir
89
- });
90
- return initialHTML.replaceAll(templateLabel, dir);
91
- }
92
- }
@@ -1,53 +0,0 @@
1
- import { existsSync } from 'fs';
2
- import { createProxyMiddleware } from 'http-proxy-middleware';
3
- import { joinWithAppPath } from "../constants";
4
- import { errorLogger, messageLogger } from "../../logger";
5
- export function mockApiHandler(app, options) {
6
- const {
7
- enable,
8
- separateSeverPort,
9
- mockEntryFile,
10
- mockPrefix
11
- } = options.mockServer;
12
-
13
- if (!enable) {
14
- return;
15
- }
16
-
17
- if (separateSeverPort) {
18
- app.use(mockPrefix, createProxyMiddleware({
19
- // eslint-disable-next-line no-useless-concat
20
- target: 'ht' + `tp://localhost:${separateSeverPort}`,
21
- changeOrigin: true
22
- }));
23
- messageLogger(`Please make sure you run mock Server separately in specified port (${separateSeverPort})`);
24
- messageLogger(`If not running already you can run "cbt mock:server --mock_port=${separateSeverPort}"`);
25
- } else {
26
- // eslint-disable-next-line no-use-before-define
27
- handleMockApi(mockEntryFile, app);
28
- }
29
- }
30
- export function handleMockApi(mockEntryFile, app) {
31
- const entryFilePath = joinWithAppPath(mockEntryFile); // eslint-disable-next-line no-use-before-define
32
-
33
- const mockFunc = safeRequire(entryFilePath);
34
-
35
- if (typeof mockFunc === 'function') {
36
- // eslint-disable-next-line no-use-before-define
37
- mockFunc(app);
38
- return;
39
- }
40
-
41
- mockFunc?.mockApi?.(app);
42
- } // function handleMockApi(params) {
43
- // }
44
-
45
- function safeRequire(entryFilePath) {
46
- if (!existsSync(entryFilePath)) {
47
- errorLogger(`${entryFilePath} file not exists for mockapi, Please check the file presence`);
48
- return null;
49
- } // eslint-disable-next-line import/no-dynamic-require, global-require
50
-
51
-
52
- return require(entryFilePath);
53
- }
@@ -1,34 +0,0 @@
1
- #!/usr/bin/env node
2
- import { getOptions } from "../../schemas/readOptions";
3
- import { corsHandling } from "./corsHandling";
4
- import { getServerUrl } from "./getServerURL";
5
- import { initExpressApp } from "./initExpressApp";
6
- import { handleMockApi } from "./mockApiHandler";
7
- import { startHttpServer } from "./startHttpServer";
8
-
9
- function getMockServerExtras(options) {
10
- const {
11
- separateSeverPort
12
- } = options.mockServer;
13
- const httpPort = Number(separateSeverPort);
14
- const httpUrl = getServerUrl({
15
- domain: 'localhost',
16
- port: httpPort,
17
- protocol: 'http'
18
- });
19
- return {
20
- httpPort,
21
- httpUrl,
22
- isHttps: false
23
- };
24
- }
25
-
26
- const options = getOptions();
27
- const {
28
- mockEntryFile
29
- } = options.mockServer;
30
- options.serverExtras = getMockServerExtras(options);
31
- const app = initExpressApp();
32
- corsHandling(app, options);
33
- startHttpServer(app, options);
34
- handleMockApi(mockEntryFile, app);
@@ -1,17 +0,0 @@
1
- import express from 'express';
2
- export function serveContextFiles(app, options) {
3
- const {
4
- context,
5
- contextFolderPath
6
- } = options;
7
- const {
8
- contextURL
9
- } = options.serverExtras;
10
- app.use(`${contextURL}/fonts`, express.static(`${context}/fonts`));
11
-
12
- if (contextURL) {
13
- app.use(contextURL, express.static(contextFolderPath));
14
- } else {
15
- app.use(express.static(context));
16
- }
17
- }
@@ -1,21 +0,0 @@
1
- import { corsHandling } from "./corsHandling";
2
- import { initExpressApp } from "./initExpressApp";
3
- import { configWebpackDevMiddleware } from "./configWebpackDevMiddleware"; // import { serveContextFiles } from './serveContextFiles';
4
-
5
- import { startHttpsServer } from "./startHttpsServer";
6
- import { initialHTMLHandling } from "./initialHTMLHandling";
7
- import { startHttpServer } from "./startHttpServer";
8
- import { mockApiHandler } from "./mockApiHandler"; // import { startHttpServer } from './startHttpServer';
9
-
10
- export function run(options) {
11
- const app = initExpressApp();
12
- corsHandling(app, options);
13
- mockApiHandler(app, options);
14
- const {
15
- compiler
16
- } = configWebpackDevMiddleware(app, options); // serveContextFiles(app, options);
17
-
18
- startHttpsServer(app, options);
19
- startHttpServer(app, options);
20
- initialHTMLHandling(compiler, app, options);
21
- }
@@ -1,18 +0,0 @@
1
- import { messageLogger } from "../../logger";
2
- export function startHttpServer(app, options) {
3
- const {
4
- serverExtras
5
- } = options;
6
- const {
7
- httpPort,
8
- httpUrl
9
- } = serverExtras;
10
- app.listen(httpPort, err => {
11
- if (err) {
12
- throw err;
13
- }
14
-
15
- messageLogger(`Listening at ${httpUrl}`);
16
- });
17
- return app;
18
- }
@@ -1,26 +0,0 @@
1
- import https from 'https';
2
- import { messageLogger } from "../../logger";
3
- export function startHttpsServer(app, options) {
4
- const {
5
- httpsOptions,
6
- serverExtras
7
- } = options;
8
- const {
9
- httpsPort,
10
- httpsUrl
11
- } = serverExtras;
12
-
13
- if (!httpsOptions) {
14
- return null;
15
- }
16
-
17
- const httpsServer = https.createServer(httpsOptions, app);
18
- httpsServer.listen(httpsPort, err => {
19
- if (err) {
20
- throw err;
21
- }
22
-
23
- messageLogger(`Listening at ${httpsUrl}`);
24
- });
25
- return httpsServer;
26
- }
@@ -1,32 +0,0 @@
1
- import { getServerURL, log } from "../../../src/utils";
2
- import { httpsOptions } from "../../../src/servers/httpsOptions";
3
- export function addHttp2Server(http2Port, host, domain, contextURL) {
4
- const isCompatableHttp2 = Number(process.version.slice(1).split('.')[0]) >= 8;
5
-
6
- if (isCompatableHttp2) {
7
- const http2 = require('http2');
8
-
9
- const http2Server = http2.createSecureServer(httpsOptions); // eslint-disable-next-line no-unused-vars
10
-
11
- http2Server.on('stream', (stream, headers) => {
12
- stream.respond({
13
- 'content-type': 'text/html',
14
- ':status': 200
15
- });
16
- stream.end('<h1>Hello World! <br>Working with http2</h1>');
17
- });
18
- http2Server.listen(http2Port, err => {
19
- if (err) {
20
- throw err;
21
- }
22
-
23
- log(`Listening at ${getServerURL({
24
- host,
25
- domain,
26
- port: http2Port
27
- }, 'htt' + 'ps')}${contextURL}/`, 'http2 server');
28
- });
29
- } else {
30
- log('Your node version didn\'t adopted http2 support. Kindly update that to 8 LTS or above you can engage the http2');
31
- }
32
- }
@@ -1,35 +0,0 @@
1
- import webpackDevMiddleware from 'webpack-dev-middleware';
2
- export function configWebpackDevMiddleware(_ref) {
3
- let {
4
- publicPath,
5
- writeToDisk,
6
- enableDevCache,
7
- disableWatch,
8
- compress,
9
- compiler
10
- } = _ref;
11
- let webpackServerOptions = {
12
- logLevel: 'error',
13
- publicPath,
14
- headers: {
15
- 'Access-Control-Allow-Origin': '*'
16
- },
17
- compress
18
- };
19
-
20
- if (enableDevCache) {
21
- webpackServerOptions.headers['Cache-Control'] = 'public, max-age=604800';
22
- }
23
-
24
- if (disableWatch) {
25
- webpackServerOptions.watchOptions = {
26
- ignored: /./
27
- };
28
- }
29
-
30
- if (writeToDisk) {
31
- webpackServerOptions.writeToDisk = true;
32
- }
33
-
34
- return webpackDevMiddleware(compiler, webpackServerOptions);
35
- }
@@ -1,11 +0,0 @@
1
- import { createProxyMiddleware } from 'http-proxy-middleware';
2
- export function mockApiSupport(app, server) {
3
- const {
4
- mockPrefix,
5
- mockPort
6
- } = server;
7
- app.use(mockPrefix, createProxyMiddleware({
8
- target: 'ht' + `tp://localhost:${mockPort}`,
9
- changeOrigin: true
10
- }));
11
- }
@@ -1,36 +0,0 @@
1
- import WebSocket from 'ws';
2
- import { messageLogger } from "../../../logger";
3
- import { getTemplatePath } from "../../constants";
4
- export function websocketMockSetup(app, httpsServer) {
5
- app.use('/wms/*', (req, res) => {
6
- res.sendFile(getTemplatePath('wms', 'index.html'));
7
- });
8
- const wss = new WebSocket.Server({
9
- server: httpsServer
10
- });
11
- let wsPool = [];
12
- wss.on('connection', ws => {
13
- wsPool.push(ws);
14
- ws.on('close', () => {
15
- wsPool = wsPool.filter(ws1 => ws1 !== ws);
16
- });
17
- ws.on('message', message => {
18
- messageLogger('received: %s', message);
19
- });
20
- ws.send('something');
21
- });
22
- app.post('/wmsmockapi', (req, res) => {
23
- wsPool.forEach(ws => {
24
- const {
25
- body
26
- } = req;
27
-
28
- try {
29
- ws.send(JSON.stringify(body));
30
- } catch (e) {
31
- messageLogger(e, body);
32
- }
33
- });
34
- res.send('success');
35
- });
36
- }
@@ -1,35 +0,0 @@
1
- /* eslint-disable no-use-before-define */
2
-
3
- /**
4
- *
5
- * @param {String} url
6
- * @param {String} path
7
- */
8
- export function serverPathConcat(url, path) {
9
- const slashRemovedUrl = removeLastSlash(url);
10
- const slashRemovedPath = removeFrontSlash(path);
11
-
12
- if (slashRemovedUrl === '') {
13
- return `${path}/`;
14
- }
15
-
16
- return `${[slashRemovedUrl, slashRemovedPath].filter(a => a).join('/')}/`;
17
- }
18
- export function urlConcat(url, path) {
19
- const slashRemovedUrl = removeLastSlash(url);
20
- const slashRemovedPath = removeFrontSlash(path);
21
-
22
- if (slashRemovedUrl === '') {
23
- return path;
24
- }
25
-
26
- return `${slashRemovedUrl}/${slashRemovedPath}`;
27
- }
28
-
29
- function removeLastSlash(url) {
30
- return url.replace(/\/+$/, '');
31
- }
32
-
33
- function removeFrontSlash(url) {
34
- return url.replace(/^\/+/, '');
35
- }
@@ -1,57 +0,0 @@
1
- import { execSync } from 'child_process';
2
- import path from 'path';
3
- import { appPath } from "../constants";
4
- import { verboseLogger } from "../../logger";
5
- export const globalNodeModules = path.join(`${execSync('npm config get prefix')}`.trim(), 'lib');
6
- export function requireLocalOrGlobal(moduleName) {
7
- let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
8
- let {
9
- global = true
10
- } = opts;
11
- const {
12
- local = true
13
- } = opts;
14
- const isRelativePath = moduleName[0] === '.'; // NOTE: if starts with . then it only mean local
15
-
16
- if (isRelativePath) {
17
- global = false;
18
- }
19
-
20
- const paths = [local && appPath, global && globalNodeModules].filter(Boolean); // eslint-disable-next-line no-use-before-define
21
-
22
- return requireInFolder(moduleName, paths);
23
- }
24
- export function requireInFolder(moduleName, paths) {
25
- try {
26
- const moduleResolvePath = require.resolve(moduleName, {
27
- paths
28
- }); // eslint-disable-next-line import/no-dynamic-require, global-require
29
-
30
-
31
- return require(moduleResolvePath);
32
- } catch (error) {
33
- // NOTE: since we return null we can check out side
34
- verboseLogger('Re validate: ', error);
35
- return null;
36
- }
37
- }
38
- export function requireLocal(moduleName) {
39
- return requireInFolder(moduleName, [appPath]);
40
- }
41
- export function requireGlobal(moduleName) {
42
- const isRelativePath = moduleName[0] === '.'; // NOTE: if starts with . then it only mean local
43
-
44
- if (isRelativePath) {
45
- return null;
46
- }
47
-
48
- return requireInFolder(moduleName, [globalNodeModules]);
49
- }
50
- export function requireAllPossible(moduleName) {
51
- const localP = requireLocal(moduleName);
52
- const globalP = localP ? null : requireGlobal(moduleName);
53
- return {
54
- local: localP,
55
- global: globalP
56
- };
57
- }
File without changes
@@ -1,9 +0,0 @@
1
- import { execSync } from 'child_process';
2
- import { messageLogger } from "../../logger";
3
- import data from "../../../package.json";
4
- export function versionPrint() {
5
- let logger = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : messageLogger;
6
- logger(`Client Build Tool Version : ${data.version}`);
7
- logger(`Node Js Version : ${process.version}`);
8
- logger(`Npm Version : ${execSync('npm --version')}`);
9
- }