@zohodesk/react-cli 1.1.29-exp.2 → 1.1.29-exp.3

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 (222) hide show
  1. package/README.md +18 -0
  2. package/lib/babel/babel-option-utils/babel-preset-react-option.js +3 -0
  3. package/lib/babel/cmjs-plugins-presets.js +13 -2
  4. package/lib/babel/es-plugins-presets.js +14 -3
  5. package/lib/common/buildEs.js +0 -1
  6. package/lib/common/getEntries.js +13 -2
  7. package/lib/common/getPublicPathConfig.js +6 -0
  8. package/lib/common/index.js +6 -1
  9. package/lib/common/runPreProcess.js +15 -6
  10. package/lib/common/splitChunks.js +21 -2
  11. package/lib/common/sslcertUpdater.js +18 -7
  12. package/lib/common/templateParameters.js +2 -0
  13. package/lib/common/testPattern.js +21 -10
  14. package/lib/common/valueReplacer.js +16 -1
  15. package/lib/configs/jest.config.js +11 -2
  16. package/lib/configs/libAlias.js +16 -10
  17. package/lib/configs/resolvers.js +16 -6
  18. package/lib/configs/webpack.component.umd.config.js +6 -1
  19. package/lib/configs/webpack.css.umd.config.js +14 -6
  20. package/lib/configs/webpack.dev.config.js +14 -1
  21. package/lib/configs/webpack.docs.config.js +9 -1
  22. package/lib/configs/webpack.impact.config.js +8 -1
  23. package/lib/configs/webpack.prod.config.js +17 -4
  24. package/lib/constants.js +18 -9
  25. package/lib/deprecationLogger.js +7 -0
  26. package/lib/hooks/docsProptypeHook.js +8 -4
  27. package/lib/jest/commitedFilesResult.js +46 -4
  28. package/lib/jest/coverageCollector.js +12 -1
  29. package/lib/jest/jsonMaker.js +6 -0
  30. package/lib/jest/preProcessors/cssPreprocessor.js +9 -1
  31. package/lib/jest/preProcessors/jsPreprocessor.js +11 -2
  32. package/lib/jest/preProcessors/otherFilesPreprocessor.js +4 -1
  33. package/lib/jest/result.js +23 -1
  34. package/lib/jest/run.js +18 -7
  35. package/lib/jest/setup.js +60 -8
  36. package/lib/loaderUtils/configsAssetsLoaders.js +12 -2
  37. package/lib/loaderUtils/getCSSLoaders.js +22 -10
  38. package/lib/loaderUtils/getDevJsLoaders.js +13 -4
  39. package/lib/loaderUtils/index.js +4 -1
  40. package/lib/loaderUtils/tests/windowsModification.test.js +1 -0
  41. package/lib/loaderUtils/windowsModification.js +3 -2
  42. package/lib/loaders/__test__/markdownLoader.spec.js +1 -0
  43. package/lib/loaders/composeLoader.js +37 -13
  44. package/lib/loaders/docsLoader.js +12 -1
  45. package/lib/loaders/docsPropsLoader.js +8 -4
  46. package/lib/loaders/enhancedReactLiveConverter.js +23 -2
  47. package/lib/loaders/fileBountryLoader.js +3 -1
  48. package/lib/loaders/fileLoader.js +23 -12
  49. package/lib/loaders/markdownLoader.js +19 -14
  50. package/lib/loaders/reactLiveConvertor.js +15 -5
  51. package/lib/loaders/scriptInstrumentLoader.js +16 -7
  52. package/lib/loaders/selectorMappingLoader.js +26 -7
  53. package/lib/loaders/workerLoader.js +24 -9
  54. package/lib/logger.js +4 -0
  55. package/lib/middlewares/HMRMiddleware.js +27 -13
  56. package/lib/middlewares/SSTMiddleware.js +5 -1
  57. package/lib/pluginUtils/configHtmlWebpackPlugins.js +24 -1
  58. package/lib/pluginUtils/getDevPlugins.js +42 -9
  59. package/lib/pluginUtils/getDocsPlugins.js +13 -3
  60. package/lib/pluginUtils/getLibraryImactPlugins.js +6 -5
  61. package/lib/pluginUtils/getLibraryPlugins.js +8 -2
  62. package/lib/pluginUtils/getProdPlugins.js +47 -8
  63. package/lib/pluginUtils/getServerPlugins.js +8 -2
  64. package/lib/pluginUtils/getUMDCSSPlugins.js +10 -2
  65. package/lib/pluginUtils/getUMDComponentPlugins.js +10 -2
  66. package/lib/pluginUtils/index.js +9 -1
  67. package/lib/plugins/CdnChangePlugin.js +18 -2
  68. package/lib/plugins/CleanupStatsPlugin.js +5 -0
  69. package/lib/plugins/CssOrderControlPlugin.js +6 -3
  70. package/lib/plugins/CustomAttributePlugin.js +19 -14
  71. package/lib/plugins/CustomScriptLoadingStrategyPlugin.js +23 -3
  72. package/lib/plugins/EFCPlugin.js +34 -20
  73. package/lib/plugins/EFCTemplatePlugin.js +30 -19
  74. package/lib/plugins/EfcResourceCleanupPlugin.js +3 -0
  75. package/lib/plugins/EventsHandlingPlugin.js +4 -2
  76. package/lib/plugins/I18NInjectIntoIndexPlugin.js +37 -14
  77. package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +15 -10
  78. package/lib/plugins/I18nSplitPlugin/I18nDependency.js +10 -4
  79. package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +155 -78
  80. package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +81 -198
  81. package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +23 -12
  82. package/lib/plugins/I18nSplitPlugin/index.js +24 -13
  83. package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +12 -2
  84. package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +1 -0
  85. package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +5 -0
  86. package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +8 -1
  87. package/lib/plugins/I18nSplitPlugin/utils/index.js +4 -0
  88. package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +20 -0
  89. package/lib/plugins/I18nSplitPlugin/utils/unicodeConversion.js +1 -0
  90. package/lib/plugins/ManifestPlugin.js +18 -1
  91. package/lib/plugins/MinifyPlugin.js +10 -1
  92. package/lib/plugins/ModuleStatsPlugin.js +24 -1
  93. package/lib/plugins/OptimizeJSPlugin.js +10 -2
  94. package/lib/plugins/PublicPathCallbackPlugin.js +12 -1
  95. package/lib/plugins/PublicPathChangePlugin.js +39 -6
  96. package/lib/plugins/ReportGeneratePlugin.js +32 -5
  97. package/lib/plugins/RequireVariablePublicPlugin.js +8 -1
  98. package/lib/plugins/ResourceHintsPlugin.js +13 -4
  99. package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +17 -12
  100. package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +17 -10
  101. package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +5 -2
  102. package/lib/plugins/ScriptInstrumentPlugin.js +8 -1
  103. package/lib/plugins/SelectorPlugin.js +32 -6
  104. package/lib/plugins/ServiceWorkerPlugin.js +22 -5
  105. package/lib/plugins/ShadowDOMSupportPlugin.js +41 -4
  106. package/lib/plugins/SourceMapHookPlugin.js +12 -2
  107. package/lib/plugins/StatsPlugin.js +14 -0
  108. package/lib/plugins/TPHashMappingPlugin.js +18 -3
  109. package/lib/plugins/UnusedFilesFindPlugin.js +39 -4
  110. package/lib/plugins/VariableConversionCollector.js +42 -15
  111. package/lib/plugins/index.js +20 -1
  112. package/lib/plugins/libraryImpactPlugin.js +33 -1
  113. package/lib/plugins/utils/classHandling.js +6 -0
  114. package/lib/plugins/utils/fileHandling.js +15 -6
  115. package/lib/plugins/utils/tests/fileHandling.test.js +4 -0
  116. package/lib/plugins/variableConvertorUtils.js +29 -14
  117. package/lib/plugins/webpackwatchrunplugin.js +5 -0
  118. package/lib/postcss-plugins/EmptyPlugin.js +4 -3
  119. package/lib/postcss-plugins/ExcludePlugin.js +5 -1
  120. package/lib/postcss-plugins/IncludePlugin.js +5 -1
  121. package/lib/postcss-plugins/RTLSplitPlugin.js +27 -14
  122. package/lib/postcss-plugins/SelectorReplace.js +16 -1
  123. package/lib/postcss-plugins/ValueReplacer.js +6 -7
  124. package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +3 -0
  125. package/lib/postcss-plugins/__test__/selectorReplace.test.js +3 -6
  126. package/lib/postcss-plugins/__test__/valueReplacer.spec.js +5 -2
  127. package/lib/postcss-plugins/hoverActivePlugin.js +67 -31
  128. package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +7 -0
  129. package/lib/postcss-plugins/variableModificationPlugin/index.js +49 -28
  130. package/lib/schemas/index.js +10 -3
  131. package/lib/servers/clusterHubServer.js +11 -1
  132. package/lib/servers/devBuild.js +26 -14
  133. package/lib/servers/docsServer.js +3 -1
  134. package/lib/servers/docsServerCore.js +22 -1
  135. package/lib/servers/getCliPath.js +9 -0
  136. package/lib/servers/helpServer.js +6 -1
  137. package/lib/servers/httpsOptions.js +8 -2
  138. package/lib/servers/impactServer.js +35 -3
  139. package/lib/servers/mockserver.js +10 -1
  140. package/lib/servers/nowatchserver.js +37 -12
  141. package/lib/servers/requireLocalOrGlobal.js +17 -6
  142. package/lib/servers/scrServer.js +21 -14
  143. package/lib/servers/server.js +36 -6
  144. package/lib/servers/ssServer.js +17 -1
  145. package/lib/templates/CoverageScriptTemplate.js +14 -0
  146. package/lib/templates/WMSTemplate.js +13 -7
  147. package/lib/templates/linterConstant.js +4 -2
  148. package/lib/utils/babelPresets.js +7 -3
  149. package/lib/utils/clean.js +9 -3
  150. package/lib/utils/copy.js +7 -1
  151. package/lib/utils/copyTimezones.js +9 -1
  152. package/lib/utils/createEventStream.js +6 -1
  153. package/lib/utils/cssClassNameGenerate.js +30 -10
  154. package/lib/utils/cssURLReplacer.js +22 -1
  155. package/lib/utils/dependencyPostPublish.js +10 -1
  156. package/lib/utils/deprecationSupport.js +32 -7
  157. package/lib/utils/fileUtils.js +28 -1
  158. package/lib/utils/folderIterator.js +13 -2
  159. package/lib/utils/getComponents.js +21 -0
  160. package/lib/utils/getCurrentBranch.js +5 -0
  161. package/lib/utils/getDependenciesImpactList.js +22 -1
  162. package/lib/utils/getFileType.js +10 -2
  163. package/lib/utils/getHash.js +8 -1
  164. package/lib/utils/getIp.js +2 -0
  165. package/lib/utils/getOptions.js +53 -16
  166. package/lib/utils/getServerURL.js +10 -1
  167. package/lib/utils/index.js +51 -4
  168. package/lib/utils/init.js +1 -0
  169. package/lib/utils/initPreCommitHook.js +30 -7
  170. package/lib/utils/jsonHelper.js +22 -3
  171. package/lib/utils/libraryImpactConfig.js +5 -2
  172. package/lib/utils/lint/addScripts.js +5 -2
  173. package/lib/utils/lint/checkExistingConfig.js +12 -3
  174. package/lib/utils/lint/copyConfigs.js +3 -0
  175. package/lib/utils/lint/index.js +9 -0
  176. package/lib/utils/lint/lintScripts.js +1 -0
  177. package/lib/utils/lint/lintSetup.js +4 -3
  178. package/lib/utils/lint/lintStagedPreCommitHook.js +1 -0
  179. package/lib/utils/lint/question.js +7 -0
  180. package/lib/utils/lintReporter.js +20 -0
  181. package/lib/utils/log.js +1 -0
  182. package/lib/utils/mailSender.js +8 -1
  183. package/lib/utils/object-manipulation.js +17 -1
  184. package/lib/utils/pullOrigin.js +4 -0
  185. package/lib/utils/reinstallDependencies.js +29 -1
  186. package/lib/utils/removeAttributes.js +8 -1
  187. package/lib/utils/repoClone.js +28 -3
  188. package/lib/utils/request.js +12 -0
  189. package/lib/utils/rtl.js +17 -5
  190. package/lib/utils/selectorReplacer.js +16 -10
  191. package/lib/utils/setEnvVariables.js +2 -0
  192. package/lib/utils/ssTestHack.js +11 -1
  193. package/lib/utils/switchBranch.js +5 -0
  194. package/lib/utils/typeCheck.js +1 -0
  195. package/lib/utils/urlConcat.js +4 -0
  196. package/lib/utils/useExitCleanup.js +10 -9
  197. package/lib/utils/variableConverter.js +31 -22
  198. package/{package-lock.json → npm-shrinkwrap.json} +2333 -2101
  199. package/package.json +3 -2
  200. package/lib/plugins/I18nSplitPlugin/utils/applyMetaManifest.js +0 -279
  201. package/lib/plugins/I18nSplitPlugin/utils/createMetaManifest.js +0 -51
  202. package/lib/plugins/I18nSplitPlugin/utils/createRegularManifest.js +0 -48
  203. package/lib/plugins/newi18nsplitplugin/18nPlugin1.js +0 -306
  204. package/lib/plugins/newi18nsplitplugin/18nPlugin2.js +0 -363
  205. package/lib/plugins/newi18nsplitplugin/18nPlugin3.js +0 -694
  206. package/lib/plugins/newi18nsplitplugin/18nPlugin_hashed.js +0 -1258
  207. package/lib/plugins/newi18nsplitplugin/18nPlugin_working.js +0 -542
  208. package/lib/plugins/newi18nsplitplugin/18nplugin.js +0 -974
  209. package/lib/plugins/newi18nsplitplugin/ChunkManager.js +0 -131
  210. package/lib/plugins/newi18nsplitplugin/GenerateModuleIdToKeysMapPlugin.js +0 -59
  211. package/lib/plugins/newi18nsplitplugin/I18nDiffPlugin.js +0 -262
  212. package/lib/plugins/newi18nsplitplugin/I18nDownloadLogic.js +0 -166
  213. package/lib/plugins/newi18nsplitplugin/I18nPropertiesPlugin.js +0 -111
  214. package/lib/plugins/newi18nsplitplugin/KeyCollector.js +0 -163
  215. package/lib/plugins/newi18nsplitplugin/ManifestGenerator.js +0 -88
  216. package/lib/plugins/newi18nsplitplugin/UnicodeConversionPlugin.js +0 -101
  217. package/lib/plugins/newi18nsplitplugin/constants.js +0 -162
  218. package/lib/plugins/newi18nsplitplugin/utils/I18nKeyHasher.js +0 -78
  219. package/lib/plugins/newi18nsplitplugin/utils/getJsResourceKeys.js +0 -22
  220. package/lib/plugins/newi18nsplitplugin/utils/i18nChunkUtils.js +0 -18
  221. package/lib/plugins/newi18nsplitplugin/utils/manifestGenerator.js +0 -580
  222. package/lib/plugins/newi18nsplitplugin/utils/propertiesUtils.js +0 -54
@@ -1,19 +1,28 @@
1
1
  "use strict";
2
2
 
3
3
  var _path = _interopRequireDefault(require("path"));
4
+
4
5
  var _https = _interopRequireDefault(require("https"));
6
+
5
7
  var _express = _interopRequireDefault(require("express"));
8
+
6
9
  var _ws = _interopRequireDefault(require("ws"));
10
+
7
11
  var _httpProxyMiddleware = require("http-proxy-middleware");
12
+
8
13
  var _utils = require("../utils");
14
+
9
15
  var _httpsOptions = require("./httpsOptions");
16
+
10
17
  var _devBuild = require("./devBuild");
18
+
11
19
  var _logger = require("../logger");
12
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
20
+
21
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22
+
13
23
  // import webpack from 'webpack';
24
+ const options = (0, _utils.getOptions)(); // let args = process.argv.slice(3);
14
25
 
15
- const options = (0, _utils.getOptions)();
16
- // let args = process.argv.slice(3);
17
26
  const httpsOptions = (0, _httpsOptions.httpsOptionsWithUserFriendlyError)(options);
18
27
  const {
19
28
  app: {
@@ -38,31 +47,37 @@ const {
38
47
  outputFolderLocation
39
48
  } = (0, _devBuild.getPaths)();
40
49
  const app = (0, _express.default)();
50
+
41
51
  if (hasMock) {
42
52
  app.use(server.mockPrefix, (0, _httpProxyMiddleware.createProxyMiddleware)({
43
53
  target: 'ht' + `tp://localhost:${mockPort}`,
44
54
  changeOrigin: true
45
55
  }));
46
- }
47
- // Nb@$#3NGscc
56
+ } // Nb@$#3NGscc
57
+
58
+
48
59
  app.use(_express.default.json());
49
60
  app.use(_express.default.urlencoded({
50
61
  extended: true
51
62
  }));
63
+
52
64
  const staticPart = _express.default.static(outputFolderLocation, {
53
65
  cacheControl: true,
54
66
  setHeaders: function (res) {
55
67
  if (options.app.enableDevCache) {
56
68
  res.setHeader('Cache-Control', 'public, max-age=604800');
57
69
  }
70
+
58
71
  res.setHeader('Access-Control-Allow-Origin', '*');
59
72
  }
60
73
  });
74
+
61
75
  if (contextURL === '') {
62
76
  app.use(staticPart);
63
77
  } else {
64
78
  app.use(contextURL, staticPart);
65
79
  }
80
+
66
81
  app.use((req, res, next) => {
67
82
  res.setHeader('Access-Control-Allow-Origin', '*');
68
83
  next();
@@ -70,7 +85,9 @@ app.use((req, res, next) => {
70
85
  app.use('/wms/*', (req, res) => {
71
86
  res.sendFile(_path.default.join(__dirname, '..', '..', 'templates', 'wms', 'index.html'));
72
87
  });
88
+
73
89
  const httpsServer = _https.default.createServer(httpsOptions, app);
90
+
74
91
  if (httpsOptions) {
75
92
  const wss = new _ws.default.Server({
76
93
  server: httpsServer
@@ -91,6 +108,7 @@ if (httpsOptions) {
91
108
  const {
92
109
  body
93
110
  } = req;
111
+
94
112
  try {
95
113
  ws.send(JSON.stringify(body));
96
114
  } catch (e) {
@@ -99,19 +117,19 @@ if (httpsOptions) {
99
117
  });
100
118
  res.send('success');
101
119
  });
102
- }
103
-
104
- // let webpackCompilation;
120
+ } // let webpackCompilation;
105
121
  // compiler.hooks.afterCompile.tap('ReactCLI', compilation => {
106
122
  // webpackCompilation = compilation;
107
123
  // });
108
124
 
125
+
109
126
  if (zipname) {
110
127
  app.use(`/zips/${zipname}.zip`, (req, res) => {
111
128
  res.download(_path.default.join(process.cwd(), cssSelectorZipPath), err => {
112
129
  if (err) {
113
130
  throw err;
114
131
  }
132
+
115
133
  (0, _logger.messageLogger)(`${zipname}.zip downloaded`);
116
134
  });
117
135
  });
@@ -120,34 +138,38 @@ if (zipname) {
120
138
  if (err) {
121
139
  throw err;
122
140
  }
141
+
123
142
  (0, _logger.messageLogger)('build.zip downloaded');
124
143
  });
125
144
  });
126
145
  }
146
+
127
147
  if (contextURL) {
128
148
  app.use(contextURL, _express.default.static(context));
129
149
  app.use(`${contextURL}/*`, (req, res) => {
130
150
  // let indexHtml = webpackCompilation.assets['index.html'];
131
- res.sendFile(_path.default.join(outputFolderLocation, 'index.html'));
132
- // let indexHtml = webpackCompilation.assets['index.html'];
151
+ res.sendFile(_path.default.join(outputFolderLocation, 'index.html')); // let indexHtml = webpackCompilation.assets['index.html'];
133
152
  // res.send(indexHtml && indexHtml.source());
134
153
  });
135
154
  } else {
136
155
  app.use(_express.default.static(context));
137
156
  app.use('/*', _express.default.static(context));
138
157
  }
158
+
139
159
  if (httpsOptions) {
140
160
  httpsServer.listen(port, err => {
141
161
  if (err) {
142
162
  throw err;
143
163
  }
164
+
144
165
  (0, _utils.log)(`Listening at ${serverUrl}${contextURL}/`);
145
166
  });
167
+
146
168
  if (isCompatableHttp2) {
147
169
  const http2 = require('http2');
148
- const http2Server = http2.createSecureServer(httpsOptions);
149
170
 
150
- // eslint-disable-next-line no-unused-vars
171
+ const http2Server = http2.createSecureServer(httpsOptions); // eslint-disable-next-line no-unused-vars
172
+
151
173
  http2Server.on('stream', (stream, headers) => {
152
174
  stream.respond({
153
175
  'content-type': 'text/html',
@@ -160,6 +182,7 @@ if (httpsOptions) {
160
182
  if (err) {
161
183
  throw err;
162
184
  }
185
+
163
186
  (0, _utils.log)(`Listening at ${(0, _utils.getServerURL)({
164
187
  host,
165
188
  domain,
@@ -170,11 +193,13 @@ if (httpsOptions) {
170
193
  (0, _utils.log)('Your node version didn\'t adopted http2 support. Kindly update that to 8 LTS or above you can engage the http2');
171
194
  }
172
195
  }
196
+
173
197
  const httpPort = Number(port) + (isCompatableHttp2 ? 2 : 1);
174
198
  app.listen(httpPort, err => {
175
199
  if (err) {
176
200
  throw err;
177
201
  }
202
+
178
203
  (0, _utils.log)(`Listening at ${(0, _utils.getServerURL)({
179
204
  host,
180
205
  domain,
@@ -7,10 +7,17 @@ exports.globalNodeModules = void 0;
7
7
  exports.requireGlobal = requireGlobal;
8
8
  exports.requireLocal = requireLocal;
9
9
  exports.requireLocalOrGlobal = requireLocalOrGlobal;
10
+
10
11
  var _child_process = require("child_process");
12
+
11
13
  var _path = _interopRequireDefault(require("path"));
12
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
- const globalNodeModules = exports.globalNodeModules = _path.default.join(`${(0, _child_process.execSync)('npm config get prefix')}`.trim(), 'lib');
14
+
15
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
+
17
+ const globalNodeModules = _path.default.join(`${(0, _child_process.execSync)('npm config get prefix')}`.trim(), 'lib');
18
+
19
+ exports.globalNodeModules = globalNodeModules;
20
+
14
21
  function requireLocalOrGlobal(moduleName, opts = {}) {
15
22
  let {
16
23
  global = true
@@ -18,17 +25,19 @@ function requireLocalOrGlobal(moduleName, opts = {}) {
18
25
  const {
19
26
  local = true
20
27
  } = opts;
21
- const isRelativePath = moduleName[0] === '.';
22
- // NOTE: if starts with . then it only mean local
28
+ const isRelativePath = moduleName[0] === '.'; // NOTE: if starts with . then it only mean local
29
+
23
30
  if (isRelativePath) {
24
31
  global = false;
25
32
  }
33
+
26
34
  try {
27
- const paths = [local && process.cwd(), global && globalNodeModules].filter(Boolean);
28
- // x({ paths, globalNodeModules, global, local, opts });
35
+ const paths = [local && process.cwd(), global && globalNodeModules].filter(Boolean); // x({ paths, globalNodeModules, global, local, opts });
36
+
29
37
  const moduleResolvePath = require.resolve(moduleName, {
30
38
  paths
31
39
  });
40
+
32
41
  return require(moduleResolvePath);
33
42
  } catch (error) {
34
43
  // NOTE: since we return null we can check out side
@@ -36,12 +45,14 @@ function requireLocalOrGlobal(moduleName, opts = {}) {
36
45
  return null;
37
46
  }
38
47
  }
48
+
39
49
  function requireLocal(moduleName) {
40
50
  return requireLocalOrGlobal(moduleName, {
41
51
  global: false,
42
52
  local: true
43
53
  });
44
54
  }
55
+
45
56
  function requireGlobal(moduleName) {
46
57
  return requireLocalOrGlobal(moduleName, {
47
58
  global: true,
@@ -1,14 +1,20 @@
1
1
  "use strict";
2
2
 
3
3
  var _screenshotTest = _interopRequireDefault(require("@zohodesk/screenshot-test"));
4
+
4
5
  var _jsonHelper = require("../utils/jsonHelper");
6
+
5
7
  var _child_process = require("child_process");
8
+
6
9
  var _utils = require("../utils");
10
+
7
11
  var _docsServerCore = _interopRequireDefault(require("./docsServerCore"));
12
+
8
13
  var _SSTMiddleware = _interopRequireDefault(require("../middlewares/SSTMiddleware"));
9
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
- //Getting variables from flag and exe
11
14
 
15
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
+
17
+ //Getting variables from flag and exe
12
18
  let cwd = process.cwd();
13
19
  let options = (0, _utils.getOptions)();
14
20
  let {
@@ -30,8 +36,8 @@ let {
30
36
  }
31
37
  } = options;
32
38
  let resultFileName = `${cwd}/result.json`;
33
- let docsServerInstance;
34
- // let impactedComponentList = null;
39
+ let docsServerInstance; // let impactedComponentList = null;
40
+
35
41
  let url = (0, _utils.getServerURL)(Object.assign(server, {
36
42
  host: server.iphost
37
43
  }), 'ht' + 'tp');
@@ -39,16 +45,12 @@ let commitID = (0, _child_process.execSync)('git log --first-parent --pretty="fo
39
45
  cwd: cwd
40
46
  }).toString() || '';
41
47
  let [latestCommitHash, lastCommitHash] = commitID.split('\n');
42
- let script = 'var Objlist = {};for (i in componentList) {try { if (componentList[i].prototype.isReactComponent) Objlist[i] = componentList[i].docs.componentGroup;}catch (err) {console.log(i, err);}};if (Object.keys(Objlist).length < 5) {Objlist = false;}return Objlist;';
43
-
44
- // Variable getting part end //
48
+ let script = 'var Objlist = {};for (i in componentList) {try { if (componentList[i].prototype.isReactComponent) Objlist[i] = componentList[i].docs.componentGroup;}catch (err) {console.log(i, err);}};if (Object.keys(Objlist).length < 5) {Objlist = false;}return Objlist;'; // Variable getting part end //
45
49
 
46
50
  (0, _jsonHelper.jsonHelper)(resultFileName, 'tests.screenshotTest.compareBranch', referBranch);
47
51
  (0, _jsonHelper.jsonHelper)(resultFileName, 'tests.screenshotTest.TestBranch', currentBranch);
48
52
  (0, _jsonHelper.jsonHelper)(resultFileName, 'tests.screenshotTest.isExecuted', true);
49
- (0, _utils.log)('Test Branch Name :- ', currentBranch);
50
-
51
- // function declaration part //
53
+ (0, _utils.log)('Test Branch Name :- ', currentBranch); // function declaration part //
52
54
 
53
55
  let closeServer = serverInstance => {
54
56
  (0, _utils.log)('Docs service stopped!');
@@ -60,9 +62,9 @@ let closeServer = serverInstance => {
60
62
  http.close();
61
63
  https.close();
62
64
  wdm.close();
63
- };
65
+ }; //eslint-disable-next-line
66
+
64
67
 
65
- //eslint-disable-next-line
66
68
  let afterFirstScreenShotCollected = () => {
67
69
  closeServer(docsServerInstance);
68
70
  (0, _utils.switchBranch)('git', referBranch).then(() => {
@@ -72,6 +74,7 @@ let afterFirstScreenShotCollected = () => {
72
74
  });
73
75
  });
74
76
  };
77
+
75
78
  let onSStestEnd = (status, resultObject, message) => {
76
79
  if (status) {
77
80
  (0, _jsonHelper.jsonHelper)(resultFileName, 'tests.screenshotTest.endTime', Date.now());
@@ -79,8 +82,8 @@ let onSStestEnd = (status, resultObject, message) => {
79
82
  (0, _jsonHelper.jsonHelper)(resultFileName, 'tests.screenshotTest.result', resultObject);
80
83
  (0, _jsonHelper.jsonHelper)(resultFileName, 'tests.screenshotTest.message', message);
81
84
  (0, _jsonHelper.setTestInfoStatus)(resultFileName, true);
82
- (0, _utils.log)(message);
83
- //'Screenshot test completed successfully.'
85
+ (0, _utils.log)(message); //'Screenshot test completed successfully.'
86
+
84
87
  closeServer(docsServerInstance);
85
88
  } else {
86
89
  (0, _jsonHelper.jsonHelper)(resultFileName, 'tests.screenshotTest.isPassed', false);
@@ -95,6 +98,7 @@ let onSStestEnd = (status, resultObject, message) => {
95
98
  throw new Error('Component list undefined! Please check component Docs');
96
99
  }
97
100
  };
101
+
98
102
  let run = (listOfComponents = [], configObject) => {
99
103
  docsServerInstance = (0, _docsServerCore.default)(true);
100
104
  docsServerInstance.app.use((0, _SSTMiddleware.default)(docsServerInstance.compiler, mData => {
@@ -103,11 +107,13 @@ let run = (listOfComponents = [], configObject) => {
103
107
  configObject.impactedComponentList = finalResultObject.impactedComponentList;
104
108
  configObject.unDocsComList = finalResultObject.unDocsComList;
105
109
  }
110
+
106
111
  _screenshotTest.default.run(configObject, (status, finalObj, message) => {
107
112
  onSStestEnd(status, finalObj, message);
108
113
  });
109
114
  }));
110
115
  };
116
+
111
117
  (0, _jsonHelper.jsonHelper)(resultFileName, 'tests.screenshotTest.startTime', Date.now());
112
118
  (0, _utils.ssTestHack)();
113
119
  let scrObject = {
@@ -125,6 +131,7 @@ let scrObject = {
125
131
  script,
126
132
  tableName
127
133
  };
134
+
128
135
  if (isImpactRun) {
129
136
  if (!isStore) {
130
137
  (0, _utils.getDependenciesImpactList)(currentBranch, referBranch, tokenGit, serviceName).then(impactedList => {
@@ -1,19 +1,30 @@
1
1
  "use strict";
2
2
 
3
3
  var _path = _interopRequireDefault(require("path"));
4
+
4
5
  var _https = _interopRequireDefault(require("https"));
6
+
5
7
  var _webpack = _interopRequireDefault(require("webpack"));
8
+
6
9
  var _express = _interopRequireDefault(require("express"));
10
+
7
11
  var _ws = _interopRequireDefault(require("ws"));
12
+
8
13
  var _compression = _interopRequireDefault(require("compression"));
14
+
9
15
  var _webpackDevMiddleware = _interopRequireDefault(require("webpack-dev-middleware"));
16
+
10
17
  var _httpProxyMiddleware = require("http-proxy-middleware");
18
+
11
19
  var _HMRMiddleware = _interopRequireDefault(require("../middlewares/HMRMiddleware"));
20
+
12
21
  var _utils = require("../utils");
22
+
13
23
  var _httpsOptions = require("./httpsOptions");
14
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
- // import fs from 'fs';
16
24
 
25
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
26
+
27
+ // import fs from 'fs';
17
28
  const options = (0, _utils.getOptions)();
18
29
  const httpsOptions = (0, _httpsOptions.httpsOptionsWithUserFriendlyError)(options);
19
30
  const {
@@ -38,17 +49,20 @@ const {
38
49
  writeToDisk
39
50
  } = options.impactService;
40
51
  const app = (0, _express.default)();
52
+
41
53
  if (hasMock) {
42
54
  app.use(server.mockPrefix, (0, _httpProxyMiddleware.createProxyMiddleware)({
43
55
  target: 'ht' + `tp://localhost:${mockPort}`,
44
56
  changeOrigin: true
45
57
  }));
46
58
  }
59
+
47
60
  app.use(_express.default.json());
48
61
  app.use(_express.default.urlencoded({
49
62
  extended: true
50
63
  }));
51
64
  let config;
65
+
52
66
  if (mode === 'prod') {
53
67
  config = require('../configs/webpack.prod.config');
54
68
  app.use((0, _compression.default)());
@@ -57,6 +71,7 @@ if (mode === 'prod') {
57
71
  } else {
58
72
  throw new Error('You must configure valid option in mode');
59
73
  }
74
+
60
75
  const compiler = (0, _webpack.default)(config);
61
76
  const webpackServerOptions = {
62
77
  logLevel: 'error',
@@ -69,21 +84,24 @@ const webpackServerOptions = {
69
84
  },
70
85
  compress: mode === 'prod'
71
86
  };
87
+
72
88
  if (options.app.disableWatch) {
73
89
  webpackServerOptions.watchOptions = {
74
90
  ignored: /./
75
91
  };
76
92
  }
93
+
77
94
  if (writeToDisk) {
78
95
  webpackServerOptions.writeToDisk = true;
79
96
  }
97
+
80
98
  app.use((0, _webpackDevMiddleware.default)(compiler, webpackServerOptions));
81
99
  app.use((0, _HMRMiddleware.default)(compiler, {
82
100
  path: '/sockjs-node/info'
83
101
  }));
84
102
  app.use((req, res, next) => {
85
- res.setHeader('Access-Control-Allow-Origin', req.get('origin') || '*');
86
- // res.setHeader('Access-Control-Allow-Origin', req.get('origin'));
103
+ res.setHeader('Access-Control-Allow-Origin', req.get('origin') || '*'); // res.setHeader('Access-Control-Allow-Origin', req.get('origin'));
104
+
87
105
  res.setHeader('Access-Control-Allow-Private-Network', true);
88
106
  res.setHeader('Access-Control-Allow-Credentials', true);
89
107
  next();
@@ -94,7 +112,9 @@ app.options('/*', (req, res) => {
94
112
  app.use('/wms/*', (req, res) => {
95
113
  res.sendFile(_path.default.join(__dirname, '..', '..', 'templates', 'wms', 'index.html'));
96
114
  });
115
+
97
116
  const httpsServer = _https.default.createServer(httpsOptions, app);
117
+
98
118
  if (httpsOptions) {
99
119
  const wss = new _ws.default.Server({
100
120
  server: httpsServer
@@ -115,6 +135,7 @@ if (httpsOptions) {
115
135
  const {
116
136
  body
117
137
  } = req;
138
+
118
139
  try {
119
140
  ws.send(JSON.stringify(body));
120
141
  } catch (e) {
@@ -124,6 +145,7 @@ if (httpsOptions) {
124
145
  res.send('success');
125
146
  });
126
147
  }
148
+
127
149
  let webpackCompilation;
128
150
  let initalHTML;
129
151
  compiler.hooks.afterCompile.tap('ReactCLI', compilation => {
@@ -131,10 +153,12 @@ compiler.hooks.afterCompile.tap('ReactCLI', compilation => {
131
153
  });
132
154
  compiler.hooks.done.tap('ReactCLI', () => {
133
155
  const indexHtml = webpackCompilation.assets['index.html'];
156
+
134
157
  if (indexHtml) {
135
158
  initalHTML = indexHtml.source();
136
159
  }
137
160
  });
161
+
138
162
  if (contextURL) {
139
163
  app.use(contextURL, _express.default.static(context));
140
164
  app.use(`${contextURL}/*`, (req, res) => {
@@ -144,18 +168,21 @@ if (contextURL) {
144
168
  app.use(_express.default.static(context));
145
169
  app.use('/*', _express.default.static(context));
146
170
  }
171
+
147
172
  if (httpsOptions) {
148
173
  httpsServer.listen(port, err => {
149
174
  if (err) {
150
175
  throw err;
151
176
  }
177
+
152
178
  (0, _utils.log)(`Listening at ${serverUrl}${contextURL}/`);
153
179
  });
180
+
154
181
  if (isCompatableHttp2) {
155
182
  const http2 = require('http2');
156
- const http2Server = http2.createSecureServer(httpsOptions);
157
183
 
158
- // eslint-disable-next-line no-unused-vars
184
+ const http2Server = http2.createSecureServer(httpsOptions); // eslint-disable-next-line no-unused-vars
185
+
159
186
  http2Server.on('stream', (stream, headers) => {
160
187
  stream.respond({
161
188
  'content-type': 'text/html',
@@ -168,6 +195,7 @@ if (httpsOptions) {
168
195
  if (err) {
169
196
  throw err;
170
197
  }
198
+
171
199
  (0, _utils.log)(`Listening at ${(0, _utils.getServerURL)({
172
200
  host,
173
201
  domain,
@@ -178,11 +206,13 @@ if (httpsOptions) {
178
206
  (0, _utils.log)('Your node version didn\'t adopted http2 support. Kindly update that to 8 LTS or above you can engage the http2');
179
207
  }
180
208
  }
209
+
181
210
  const httpPort = Number(port) + (isCompatableHttp2 ? 2 : 1);
182
211
  app.listen(httpPort, err => {
183
212
  if (err) {
184
213
  throw err;
185
214
  }
215
+
186
216
  (0, _utils.log)(`Listening at ${(0, _utils.getServerURL)({
187
217
  host,
188
218
  domain,
@@ -1,11 +1,17 @@
1
1
  "use strict";
2
2
 
3
3
  var _screenshotTest = _interopRequireDefault(require("@zohodesk/screenshot-test"));
4
+
4
5
  var _jsonHelper = require("../utils/jsonHelper");
6
+
5
7
  var _utils = require("../utils");
8
+
6
9
  var _docsServerCore = _interopRequireDefault(require("./docsServerCore"));
10
+
7
11
  var _SSTMiddleware = _interopRequireDefault(require("../middlewares/SSTMiddleware"));
8
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
+
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
+
9
15
  let options = (0, _utils.getOptions)();
10
16
  let impactedComponentObject = null;
11
17
  let docsServerInstance;
@@ -21,6 +27,7 @@ let {
21
27
  server
22
28
  }
23
29
  } = options;
30
+
24
31
  function closeServer(serverInstance) {
25
32
  (0, _utils.log)('Docs service stopped!');
26
33
  let {
@@ -32,10 +39,12 @@ function closeServer(serverInstance) {
32
39
  https.close();
33
40
  wdm.close();
34
41
  }
42
+
35
43
  (0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'tests.screenshotTest.compareBranch', referBranch);
36
44
  (0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'tests.screenshotTest.TestBranch', currentBranch);
37
45
  (0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'tests.screenshotTest.isExecuted', true);
38
46
  (0, _utils.log)('Test Branch Name :- ', currentBranch);
47
+
39
48
  let afterFirstScreenShotCollected = () => {
40
49
  closeServer(docsServerInstance);
41
50
  (0, _utils.switchBranch)('git', referBranch).then(() => {
@@ -45,6 +54,7 @@ let afterFirstScreenShotCollected = () => {
45
54
  });
46
55
  });
47
56
  };
57
+
48
58
  let onSStestEnd = (status, resultObject, isLastRun, runSSTest) => {
49
59
  if (status) {
50
60
  if (!isLastRun) {
@@ -72,13 +82,17 @@ let onSStestEnd = (status, resultObject, isLastRun, runSSTest) => {
72
82
  throw new Error('Component list undefined! Please check component Docs');
73
83
  }
74
84
  };
85
+
75
86
  (0, _utils.ssTestHack)();
87
+
76
88
  let getDocsServerInstance = beforeJobs => {
77
89
  if (typeof beforeJobs === 'function') {
78
90
  beforeJobs();
79
91
  }
92
+
80
93
  return (0, _docsServerCore.default)(true);
81
94
  };
95
+
82
96
  let runSSTest = (onBefore, isLastRun, mode, branch, listOfComponents) => {
83
97
  let url = (0, _utils.getServerURL)(Object.assign(server, {
84
98
  host: server.iphost
@@ -86,6 +100,7 @@ let runSSTest = (onBefore, isLastRun, mode, branch, listOfComponents) => {
86
100
  docsServerInstance = getDocsServerInstance(onBefore);
87
101
  docsServerInstance.app.use((0, _SSTMiddleware.default)(docsServerInstance.compiler, mData => {
88
102
  impactedComponentObject = (0, _utils.getComponents)(mData, listOfComponents);
103
+
89
104
  _screenshotTest.default.run({
90
105
  branch,
91
106
  seleniumHub: seleniumHub,
@@ -100,6 +115,7 @@ let runSSTest = (onBefore, isLastRun, mode, branch, listOfComponents) => {
100
115
  });
101
116
  }));
102
117
  };
118
+
103
119
  (0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'tests.screenshotTest.startTime', Date.now());
104
120
  (0, _utils.getDependenciesImpactList)(currentBranch, referBranch).then(impactedList => {
105
121
  (0, _utils.log)('from here ');
@@ -8,21 +8,27 @@ window.ClientCoverage = {
8
8
  localStorage.setItem(property, JSON.stringify(defaultVal));
9
9
  return defaultVal;
10
10
  }
11
+
11
12
  localStorage.setItem(property, JSON.stringify(defaultVal));
12
13
  return defaultVal || {};
13
14
  },
15
+
14
16
  clearLocalStorage(property) {
15
17
  localStorage.removeItem(property);
16
18
  }
19
+
17
20
  },
18
21
  JS: {
19
22
  jsMethodInstrumentObject: {},
20
23
  jsStorageKey: 'jsClientCoverageObject',
24
+
21
25
  init() {
22
26
  this.jsMethodInstrumentObject = ClientCoverage.LocalStorageWrapper.getLocalStorage(this.jsStorageKey, this.jsMethodInstrumentObject);
23
27
  },
28
+
24
29
  visitMethod(jsFileName, jsMethodName) {
25
30
  this.init();
31
+
26
32
  if (this.jsMethodInstrumentObject.hasOwnProperty(jsFileName)) {
27
33
  if (!this.jsMethodInstrumentObject[jsFileName].includes(jsMethodName)) {
28
34
  this.jsMethodInstrumentObject[jsFileName].push(jsMethodName);
@@ -31,27 +37,35 @@ window.ClientCoverage = {
31
37
  this.jsMethodInstrumentObject[jsFileName] = [];
32
38
  this.jsMethodInstrumentObject[jsFileName].push(jsMethodName);
33
39
  }
40
+
34
41
  localStorage.setItem(this.jsStorageKey, JSON.stringify(this.jsMethodInstrumentObject));
35
42
  },
43
+
36
44
  clear() {
37
45
  this.jsMethodInstrumentObject = {};
38
46
  ClientCoverage.LocalStorageWrapper.clearLocalStorage(this.jsStorageKey);
39
47
  },
48
+
40
49
  getData() {
41
50
  return {
42
51
  methods: this.jsMethodInstrumentObject
43
52
  };
44
53
  }
54
+
45
55
  },
56
+
46
57
  getCoverageData() {
47
58
  return {
48
59
  JS: this.JS.getData()
49
60
  };
50
61
  },
62
+
51
63
  clear() {
52
64
  this.JS.clear();
53
65
  },
66
+
54
67
  init() {
55
68
  this.JS.init();
56
69
  }
70
+
57
71
  };