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

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 +859 -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 +99 -84
  33. package/lib/configs/webpack.docs.config.js +65 -57
  34. package/lib/configs/webpack.impact.config.js +109 -0
  35. package/lib/configs/webpack.prod.config.js +147 -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 +368 -0
  117. package/lib/postcss-plugins/variableModifier.js +243 -0
  118. package/lib/schemas/index.js +541 -65
  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
@@ -1,100 +1,63 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
- var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
3
+ var _express = _interopRequireDefault(require("express"));
4
4
 
5
- var _express = require('express');
5
+ var _gitlab = require("gitlab");
6
6
 
7
- var _express2 = _interopRequireDefault(_express);
7
+ var _esprima = _interopRequireDefault(require("esprima"));
8
8
 
9
- var _gitlab = require('gitlab');
10
-
11
- var _esprima = require('esprima');
12
-
13
- var _esprima2 = _interopRequireDefault(_esprima);
14
-
15
- var _utils = require('../utils');
9
+ var _utils = require("../utils");
16
10
 
17
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
12
 
19
- function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
20
-
21
- var options = (0, _utils.getOptions)();
22
- var server = options.impact.server;
23
-
24
- var serverUrl = (0, _utils.getServerURL)(server, 'htt' + 'p');
25
- var port = server.port;
26
-
27
-
28
- var services = new _gitlab.ProjectsBundle({
13
+ let options = (0, _utils.getOptions)();
14
+ let {
15
+ impact: {
16
+ server
17
+ }
18
+ } = options;
19
+ let serverUrl = (0, _utils.getServerURL)(server, 'htt' + 'p');
20
+ let {
21
+ port
22
+ } = server;
23
+ const services = new _gitlab.ProjectsBundle({
29
24
  url: 'https://git.csez.zohocorpin.com',
30
25
  token: 'n6aqQz3RfzqRGPyMTPy8'
31
26
  });
32
-
33
- var app = (0, _express2.default)();
34
-
35
- app.use(_express2.default.json());
36
- app.use(_express2.default.urlencoded({
27
+ let app = (0, _express.default)();
28
+ app.use(_express.default.json());
29
+ app.use(_express.default.urlencoded({
37
30
  extended: true
38
31
  }));
39
32
 
40
- app.post('/impact/build', function (req, res) {
41
- req.setTimeout(0);
42
- var subUrl = '/logs/reactbuildinfo.txt';
43
- var build = req.body;
44
-
45
- var url = build.buildUrl.substr(0, build.buildUrl.lastIndexOf('/'));
46
- url = url + subUrl;
47
- getDetails(url, function (body, esprimaObj, componentObj, err) {
48
- if (err) {
49
- return err;
50
- }
51
- var responseObj = {};
52
- Object.keys(esprimaObj).forEach(function (file) {
53
- responseObj[file] = [];
54
- body[file].forEach(function (changedLine) {
55
- Object.keys(esprimaObj[file]).forEach(function (method) {
56
- if (esprimaObj[file][method].includes(changedLine)) {
57
- if (!responseObj[file].includes(method)) {
58
- responseObj[file].push(method);
59
- }
60
- }
61
- });
62
- });
63
- if (!responseObj[file].length) {
64
- delete responseObj[file];
65
- }
66
- });
67
-
68
- var resObj = {
69
- chnagedMethods: responseObj,
70
- changedLocators: componentObj
71
- };
72
- res.send(resObj);
73
- res.end();
74
- });
75
- });
76
33
  function traverseJSON(parsed, file) {
77
- var parsedObj = {};
78
- parsed.forEach(function (Block) {
34
+ let parsedObj = {};
35
+ parsed.forEach(Block => {
79
36
  if (Block.type === 'FunctionDeclaration' || Block.type === 'ExportDefaultDeclaration' || Block.type === 'ExportNamedDeclaration') {
80
- var ParsedTemp = void 0;
37
+ let ParsedTemp;
38
+
81
39
  if (Block.type === 'FunctionDeclaration') {
82
40
  ParsedTemp = Block;
83
41
  } else {
84
42
  ParsedTemp = Block.declaration;
85
43
  }
44
+
86
45
  if (ParsedTemp) {
87
46
  if (ParsedTemp.id) {
88
- var funcname = ParsedTemp.id.name;
47
+ let funcname = ParsedTemp.id.name;
48
+
89
49
  if (funcname !== 'mapStateToProps') {
90
50
  if (!funcname.includes('_')) {
91
51
  if (!Object.prototype.hasOwnProperty.call(parsedObj, 'file')) {
92
52
  parsedObj[file] = {};
93
53
  }
94
- var tempArray = [];
95
- for (var j = ParsedTemp.loc.start.line; j < ParsedTemp.loc.end.line; j++) {
54
+
55
+ let tempArray = [];
56
+
57
+ for (let j = ParsedTemp.loc.start.line; j < ParsedTemp.loc.end.line; j++) {
96
58
  tempArray.push(j);
97
59
  }
60
+
98
61
  parsedObj[file][funcname] = tempArray;
99
62
  }
100
63
  }
@@ -104,44 +67,42 @@ function traverseJSON(parsed, file) {
104
67
  });
105
68
  return parsedObj;
106
69
  }
70
+
107
71
  function getDetails(url, callback) {
108
- var changeObj = {};
109
- var compObj = {};
110
- (0, _utils.request)({ url: url }).then(function (res) {
111
- var body = JSON.parse(res.body);
72
+ let changeObj = {};
73
+ let compObj = {};
74
+ (0, _utils.request)({
75
+ url
76
+ }).then(res => {
77
+ let body = JSON.parse(res.body);
78
+
112
79
  if (body.includes('Source_Changeset')) {
113
- var branch = void 0,
114
- changeSet = void 0;
80
+ let branch, changeSet;
115
81
  body = body.split('\n');
116
- body.forEach(function (content) {
82
+ body.forEach(content => {
117
83
  if (content.includes('Source_Changeset')) {
118
- var _content$split = content.split('='),
119
- _content$split2 = _slicedToArray(_content$split, 2),
120
- __changeSet = _content$split2[1];
121
-
84
+ let [, __changeSet] = content.split('=');
122
85
  changeSet = __changeSet;
123
86
  }
124
- if (content.includes('SourceCoLabel')) {
125
- var _content$split3 = content.split('='),
126
- _content$split4 = _slicedToArray(_content$split3, 1),
127
- __branch = _content$split4[0];
128
87
 
88
+ if (content.includes('SourceCoLabel')) {
89
+ let [__branch] = content.split('=');
129
90
  branch = __branch;
130
91
  }
131
92
  });
132
- services.Commits.diff(1143, changeSet
133
- //'587efd32ce14620750a38ab74bc744fc52f2943a '
134
- ).then(function (result) {
135
- var promises = [];
93
+ services.Commits.diff(1143, changeSet //'587efd32ce14620750a38ab74bc744fc52f2943a '
94
+ ).then(result => {
95
+ let promises = [];
96
+
136
97
  if (result) {
137
- result.forEach(function (change) {
138
- var p = new Promise(function (resolve) {
139
- var filename = change.new_path;
98
+ result.forEach(change => {
99
+ let p = new Promise(resolve => {
100
+ let filename = change.new_path;
140
101
  changeObj[filename] = [];
141
102
  compObj[filename] = [];
142
- var diffList = change.diff.split('\n');
143
- var tempObj = {};
144
- diffList.forEach(function (diff) {
103
+ let diffList = change.diff.split('\n');
104
+ let tempObj = {};
105
+ diffList.forEach(diff => {
145
106
  if (diff.indexOf('data-id') >= 0) {
146
107
  if (diff.indexOf('//') >= 0) {
147
108
  if (diff.substr(diff.indexOf('//') + 1).includes('data-id')) {
@@ -150,22 +111,27 @@ function getDetails(url, callback) {
150
111
  tempObj.changedId = null;
151
112
  }
152
113
  }
114
+
153
115
  if (!diff.indexOf('-')) {
154
116
  //eslint-disable-next-line
155
117
  tempObj.defaultId = diff.match(/(data-id=.*)/g)[0].match(/["']([^"']+?)['"]/g)[0];
156
- var tempIndex = diffList.indexOf(diff);
118
+ let tempIndex = diffList.indexOf(diff);
119
+
157
120
  if (diffList[tempIndex + 1].indexOf('data-id') === -1) {
158
121
  tempObj.changedId = null;
159
122
  }
160
123
  }
124
+
161
125
  if (!diff.indexOf('+')) {
162
126
  //eslint-disable-next-line
163
127
  tempObj.changedId = diff.match(/(data-id=.*)/g)[0].match(/["']([^"']+?)['"]/g)[0];
164
- var _tempIndex = diffList.indexOf(diff);
165
- if (diffList[_tempIndex - 1].indexOf('data-id') === -1) {
128
+ let tempIndex = diffList.indexOf(diff);
129
+
130
+ if (diffList[tempIndex - 1].indexOf('data-id') === -1) {
166
131
  tempObj.defaultId = null;
167
132
  }
168
133
  }
134
+
169
135
  if (Object.prototype.hasOwnProperty.call(tempObj, 'defaultId') && Object.prototype.hasOwnProperty.call(tempObj, 'changedId')) {
170
136
  if (tempObj.defaultId !== tempObj.changedId) {
171
137
  compObj[filename].push(tempObj);
@@ -173,34 +139,39 @@ function getDetails(url, callback) {
173
139
  }
174
140
  }
175
141
  }
142
+
176
143
  if (diff.startsWith('@')) {
177
- var _diff$split = diff.split('@@'),
178
- _diff$split2 = _slicedToArray(_diff$split, 2),
179
- content = _diff$split2[1];
144
+ let [, content] = diff.split('@@');
145
+ let tempList = content.split(' ');
146
+ let startingLine = parseInt(tempList[1].split(',')[0]) * -1 + 3;
147
+ let furtherLines = parseInt(tempList[2].split(',')[0]) + 3;
180
148
 
181
- var tempList = content.split(' ');
182
- var startingLine = parseInt(tempList[1].split(',')[0]) * -1 + 3;
183
- var furtherLines = parseInt(tempList[2].split(',')[0]) + 3;
184
149
  if (parseInt(tempList[1].split(',')[1]) > 6) {
185
150
  changeObj[filename].push(startingLine);
186
151
  }
152
+
187
153
  if (parseInt(tempList[2].split(',')[1]) > 6) {
188
- var endValue = parseInt(tempList[2].split(',')[1]) - 6;
189
- for (var i = furtherLines; i < furtherLines + endValue; i++) {
154
+ let endValue = parseInt(tempList[2].split(',')[1]) - 6;
155
+
156
+ for (let i = furtherLines; i < furtherLines + endValue; i++) {
190
157
  changeObj[filename].push(i);
191
158
  }
192
159
  }
193
160
  }
194
161
  });
162
+
195
163
  if (!filename.includes('.spec.js') && !filename.includes('.docs.js') && !filename.includes('.css') && filename.includes('.js')) {
196
164
  try {
197
- services.RepositoryFiles.show(1143, filename, branch).then(function (res) {
198
- var code = Buffer.from(res.content, 'base64').toString('ascii');
199
- var parsed = _esprima2.default.parseModule(code, {
165
+ services.RepositoryFiles.show(1143, filename, branch).then(res => {
166
+ let code = Buffer.from(res.content, 'base64').toString('ascii');
167
+
168
+ let parsed = _esprima.default.parseModule(code, {
200
169
  jsx: true,
201
170
  loc: true
202
171
  });
203
- var methodDetail = traverseJSON(parsed.body, filename);
172
+
173
+ let methodDetail = traverseJSON(parsed.body, filename);
174
+
204
175
  if (Object.keys(methodDetail).length) {
205
176
  resolve(methodDetail);
206
177
  } else {
@@ -216,21 +187,58 @@ function getDetails(url, callback) {
216
187
  });
217
188
  promises.push(p);
218
189
  });
219
- Promise.all(promises).then(function (resPromise) {
220
- callback(changeObj, Object.assign.apply(Object, [{}].concat(_toConsumableArray(resPromise))), compObj);
190
+ Promise.all(promises).then(resPromise => {
191
+ callback(changeObj, Object.assign({}, ...resPromise), compObj);
221
192
  });
222
193
  }
223
194
  });
224
195
  }
225
- }).catch(function (err) {
226
- return err;
227
- });
196
+ }).catch(err => err);
228
197
  }
229
198
 
230
- app.listen(port, function (err) {
199
+ app.post('/impact/build', (req, res) => {
200
+ req.setTimeout(0);
201
+ let subUrl = '/logs/reactbuildinfo.txt';
202
+ let {
203
+ body: build
204
+ } = req;
205
+ let url = build.buildUrl.substr(0, build.buildUrl.lastIndexOf('/'));
206
+ url = url + subUrl;
207
+ getDetails(url, (body, esprimaObj, componentObj, err) => {
208
+ if (err) {
209
+ return err;
210
+ }
211
+
212
+ let responseObj = {};
213
+ Object.keys(esprimaObj).forEach(file => {
214
+ responseObj[file] = [];
215
+ body[file].forEach(changedLine => {
216
+ Object.keys(esprimaObj[file]).forEach(method => {
217
+ if (esprimaObj[file][method].includes(changedLine)) {
218
+ if (!responseObj[file].includes(method)) {
219
+ responseObj[file].push(method);
220
+ }
221
+ }
222
+ });
223
+ });
224
+
225
+ if (!responseObj[file].length) {
226
+ delete responseObj[file];
227
+ }
228
+ });
229
+ let resObj = {
230
+ chnagedMethods: responseObj,
231
+ changedLocators: componentObj
232
+ };
233
+ res.send(resObj);
234
+ res.end();
235
+ });
236
+ });
237
+ app.listen(port, err => {
231
238
  if (err) {
232
239
  throw err;
233
240
  }
234
- (0, _utils.log)('Listening at ' + serverUrl + '/impact/build/');
241
+
242
+ (0, _utils.log)(`Listening at ${serverUrl}/impact/build/`);
235
243
  (0, _utils.log)('payload like => {buildUrl:test_build_url}');
236
244
  });
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ var _express = _interopRequireDefault(require("express"));
4
+
5
+ var _fs = _interopRequireDefault(require("fs"));
6
+
7
+ var _path = _interopRequireDefault(require("path"));
8
+
9
+ var _utils = require("../utils");
10
+
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+
13
+ let options = (0, _utils.getOptions)();
14
+ let {
15
+ app: {
16
+ server: {
17
+ mockPort
18
+ }
19
+ }
20
+ } = options;
21
+ const app = (0, _express.default)();
22
+ app.use(_express.default.json());
23
+ app.use(_express.default.urlencoded({
24
+ extended: true
25
+ }));
26
+ let appPath = process.cwd();
27
+
28
+ let mockServerPath = _path.default.join(appPath, 'mockapi', 'index.js');
29
+
30
+ if (_fs.default.existsSync(mockServerPath)) {
31
+ let mockServer = require(mockServerPath);
32
+
33
+ mockServer(app);
34
+ } else {
35
+ (0, _utils.log)('You must export a function from mockapi folder by only we can provide mock api hook');
36
+ }
37
+
38
+ app.listen(mockPort, err => {
39
+ if (err) {
40
+ (0, _utils.log)('error', err);
41
+ } else {
42
+ (0, _utils.log)(`mock server listening port: ${mockPort}`);
43
+ }
44
+ });
@@ -0,0 +1,200 @@
1
+ "use strict";
2
+
3
+ var _path = _interopRequireDefault(require("path"));
4
+
5
+ var _https = _interopRequireDefault(require("https"));
6
+
7
+ var _express = _interopRequireDefault(require("express"));
8
+
9
+ var _ws = _interopRequireDefault(require("ws"));
10
+
11
+ var _httpProxyMiddleware = require("http-proxy-middleware");
12
+
13
+ var _utils = require("../utils");
14
+
15
+ var _httpsOptions = require("./httpsOptions");
16
+
17
+ var _devBuild = require("./devBuild");
18
+
19
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
+
21
+ // import webpack from 'webpack';
22
+ let options = (0, _utils.getOptions)(); // let args = process.argv.slice(3);
23
+
24
+ let {
25
+ app: {
26
+ context,
27
+ server
28
+ }
29
+ } = options;
30
+ let {
31
+ host,
32
+ port,
33
+ domain,
34
+ disableContextURL,
35
+ hasMock,
36
+ mockPort
37
+ } = server;
38
+ let isCompatableHttp2 = Number(process.version.slice(1).split('.')[0]) >= 8;
39
+ let contextURL = disableContextURL ? '' : `/${context}`;
40
+ let serverUrl = (0, _utils.getServerURL)(server, 'htt' + 'ps');
41
+ const {
42
+ zipname,
43
+ cssSelectorZipPath,
44
+ outputFolderLocation
45
+ } = (0, _devBuild.getPaths)();
46
+ const app = (0, _express.default)();
47
+
48
+ if (hasMock) {
49
+ app.use(server.mockPrefix, (0, _httpProxyMiddleware.createProxyMiddleware)({
50
+ target: 'ht' + `tp://localhost:${mockPort}`,
51
+ changeOrigin: true
52
+ }));
53
+ } // Nb@$#3NGscc
54
+
55
+
56
+ app.use(_express.default.json());
57
+ app.use(_express.default.urlencoded({
58
+ extended: true
59
+ }));
60
+
61
+ const staticPart = _express.default.static(outputFolderLocation, {
62
+ cacheControl: true,
63
+ setHeaders: function (res) {
64
+ if (options.app.enableDevCache) {
65
+ res.setHeader('Cache-Control', 'public, max-age=604800');
66
+ }
67
+
68
+ res.setHeader('Access-Control-Allow-Origin', '*');
69
+ }
70
+ });
71
+
72
+ if (contextURL === '') {
73
+ app.use(staticPart);
74
+ } else {
75
+ app.use(contextURL, staticPart);
76
+ }
77
+
78
+ app.use((req, res, next) => {
79
+ res.setHeader('Access-Control-Allow-Origin', '*');
80
+ next();
81
+ }).use(`${contextURL}/fonts`, _express.default.static(`${context}/fonts`));
82
+ app.use('/wms/*', (req, res) => {
83
+ res.sendFile(_path.default.join(__dirname, '..', '..', 'templates', 'wms', 'index.html'));
84
+ });
85
+
86
+ const httpsServer = _https.default.createServer(_httpsOptions.httpsOptions, app);
87
+
88
+ const wss = new _ws.default.Server({
89
+ server: httpsServer
90
+ });
91
+ let wsPool = [];
92
+ wss.on('connection', ws => {
93
+ wsPool.push(ws);
94
+ ws.on('close', () => {
95
+ wsPool = wsPool.filter(ws1 => ws1 !== ws);
96
+ });
97
+ ws.on('message', message => {
98
+ (0, _utils.log)('received: %s', message);
99
+ });
100
+ ws.send('something');
101
+ });
102
+ app.post('/wmsmockapi', (req, res) => {
103
+ wsPool.forEach(ws => {
104
+ let {
105
+ body
106
+ } = req;
107
+
108
+ try {
109
+ ws.send(JSON.stringify(body));
110
+ } catch (e) {
111
+ (0, _utils.log)(e, body);
112
+ }
113
+ });
114
+ res.send('success');
115
+ }); // let webpackCompilation;
116
+ // compiler.hooks.afterCompile.tap('ReactCLI', compilation => {
117
+ // webpackCompilation = compilation;
118
+ // });
119
+
120
+ if (zipname) {
121
+ app.use(`/zips/${zipname}.zip`, (req, res) => {
122
+ res.download(_path.default.join(process.cwd(), cssSelectorZipPath), err => {
123
+ if (err) {
124
+ throw err;
125
+ }
126
+
127
+ console.log(`${zipname}.zip downloaded`);
128
+ });
129
+ });
130
+ app.use('/zips/build.zip', (req, res) => {
131
+ res.download(_path.default.join(process.cwd(), 'build.zip'), err => {
132
+ if (err) {
133
+ throw err;
134
+ }
135
+
136
+ console.log('build.zip downloaded');
137
+ });
138
+ });
139
+ }
140
+
141
+ if (contextURL) {
142
+ app.use(contextURL, _express.default.static(context));
143
+ app.use(`${contextURL}/*`, (req, res) => {
144
+ // let indexHtml = webpackCompilation.assets['index.html'];
145
+ res.sendFile(_path.default.join(outputFolderLocation, 'index.html')); // let indexHtml = webpackCompilation.assets['index.html'];
146
+ // res.send(indexHtml && indexHtml.source());
147
+ });
148
+ } else {
149
+ app.use(_express.default.static(context));
150
+ app.use('/*', _express.default.static(context));
151
+ }
152
+
153
+ httpsServer.listen(port, err => {
154
+ if (err) {
155
+ throw err;
156
+ }
157
+
158
+ (0, _utils.log)(`Listening at ${serverUrl}${contextURL}/`);
159
+ });
160
+
161
+ if (isCompatableHttp2) {
162
+ const http2 = require('http2');
163
+
164
+ const http2Server = http2.createSecureServer(_httpsOptions.httpsOptions); // eslint-disable-next-line no-unused-vars
165
+
166
+ http2Server.on('stream', (stream, headers) => {
167
+ stream.respond({
168
+ 'content-type': 'text/html',
169
+ ':status': 200
170
+ });
171
+ stream.end('<h1>Hello World! <br>Working with http2</h1>');
172
+ });
173
+ let http2Port = Number(port) + 1;
174
+ http2Server.listen(http2Port, err => {
175
+ if (err) {
176
+ throw err;
177
+ }
178
+
179
+ (0, _utils.log)(`Listening at ${(0, _utils.getServerURL)({
180
+ host,
181
+ domain,
182
+ port: http2Port
183
+ }, 'htt' + 'ps')}${contextURL}/`, 'http2 server');
184
+ });
185
+ } else {
186
+ (0, _utils.log)('Your node version didn\'t adopted http2 support. Kindly update that to 8 LTS or above you can engage the http2');
187
+ }
188
+
189
+ let httpPort = Number(port) + (isCompatableHttp2 ? 2 : 1);
190
+ app.listen(httpPort, err => {
191
+ if (err) {
192
+ throw err;
193
+ }
194
+
195
+ (0, _utils.log)(`Listening at ${(0, _utils.getServerURL)({
196
+ host,
197
+ domain,
198
+ port: httpPort
199
+ }, 'ht' + 'tp')}${contextURL}/`);
200
+ });