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

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 (226) hide show
  1. package/.eslintignore +1 -0
  2. package/.eslintrc.js +46 -3
  3. package/CHANGELOG.md +5 -0
  4. package/README.md +650 -0
  5. package/bin/cli.js +134 -27
  6. package/cert/cert.pem +37 -129
  7. package/cert/key.pem +27 -27
  8. package/cert/passphrase.pem +1 -0
  9. package/files/eslintrc.js +62 -0
  10. package/files/prettierrc.js +3 -0
  11. package/lib/babel/cmjs-plugins-presets.js +16 -9
  12. package/lib/babel/es-plugins-presets.js +26 -14
  13. package/lib/common/getEntries.js +33 -24
  14. package/lib/common/getPublicPathConfig.js +40 -0
  15. package/lib/common/index.js +27 -13
  16. package/lib/common/splitChunks.js +64 -26
  17. package/lib/common/sslcertUpdater.js +59 -0
  18. package/lib/common/templateParameters.js +25 -0
  19. package/lib/configs/jest.config.js +18 -28
  20. package/lib/configs/webpack.component.umd.config.js +31 -37
  21. package/lib/configs/webpack.css.umd.config.js +44 -44
  22. package/lib/configs/webpack.dev.config.js +113 -57
  23. package/lib/configs/webpack.docs.config.js +104 -98
  24. package/lib/configs/webpack.impact.config.js +116 -0
  25. package/lib/configs/webpack.prod.config.js +154 -86
  26. package/lib/hooks/docsProptypeHook.js +32 -38
  27. package/lib/jest/commitedFilesResult.js +144 -71
  28. package/lib/jest/coverageCollector.js +62 -29
  29. package/lib/jest/jsonMaker.js +54 -0
  30. package/lib/jest/preProcessors/cssPreprocessor.js +16 -18
  31. package/lib/jest/preProcessors/jsPreprocessor.js +5 -6
  32. package/lib/jest/preProcessors/otherFilesPreprocessor.js +5 -6
  33. package/lib/jest/result.js +91 -41
  34. package/lib/jest/run.js +74 -27
  35. package/lib/jest/setup.js +103 -102
  36. package/lib/loaderUtils/getCSSLoaders.js +77 -0
  37. package/lib/loaderUtils/getDevJsLoaders.js +30 -23
  38. package/lib/loaderUtils/index.js +14 -7
  39. package/lib/loaders/docsLoader.js +15 -15
  40. package/lib/loaders/docsPropsLoader.js +14 -17
  41. package/lib/loaders/fileBountryLoader.js +17 -0
  42. package/lib/loaders/fileLoader.js +47 -38
  43. package/lib/loaders/scriptInstrumentLoader.js +21 -20
  44. package/lib/loaders/selectorMappingLoader.js +75 -0
  45. package/lib/loaders/workerLoader.js +136 -0
  46. package/lib/middlewares/HMRMiddleware.js +59 -41
  47. package/lib/middlewares/SSTMiddleware.js +21 -0
  48. package/lib/pluginUtils/getDevPlugins.js +173 -26
  49. package/lib/pluginUtils/getDocsPlugins.js +32 -17
  50. package/lib/pluginUtils/getLibraryImactPlugins.js +23 -0
  51. package/lib/pluginUtils/getLibraryPlugins.js +8 -10
  52. package/lib/pluginUtils/getProdPlugins.js +238 -37
  53. package/lib/pluginUtils/getServerPlugins.js +8 -11
  54. package/lib/pluginUtils/getUMDCSSPlugins.js +11 -15
  55. package/lib/pluginUtils/getUMDComponentPlugins.js +11 -15
  56. package/lib/pluginUtils/index.js +36 -43
  57. package/lib/plugins/CdnChangePlugin.js +77 -0
  58. package/lib/plugins/CleanupStatsPlugin.js +28 -0
  59. package/lib/plugins/EFCPlugin.js +211 -0
  60. package/lib/plugins/EFCPlugin.md +6 -0
  61. package/lib/plugins/I18NInjectIntoIndexPlugin.js +141 -0
  62. package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +60 -0
  63. package/lib/plugins/I18nSplitPlugin/I18nDependency.js +44 -0
  64. package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +266 -0
  65. package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +183 -0
  66. package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +100 -0
  67. package/lib/plugins/I18nSplitPlugin/I18nSplit.md +86 -0
  68. package/lib/plugins/I18nSplitPlugin/README.md +25 -0
  69. package/lib/plugins/I18nSplitPlugin/index.js +185 -0
  70. package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +64 -0
  71. package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +13 -0
  72. package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +26 -0
  73. package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +40 -0
  74. package/lib/plugins/I18nSplitPlugin/utils/index.js +31 -0
  75. package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +112 -0
  76. package/lib/plugins/ManifestPlugin.js +52 -63
  77. package/lib/plugins/ModuleStatsPlugin.js +98 -97
  78. package/lib/plugins/OptimizeJSPlugin.js +24 -41
  79. package/lib/plugins/PublicPathCallbackPlugin.js +63 -0
  80. package/lib/plugins/PublicPathChangePlugin.js +187 -174
  81. package/lib/plugins/ReportGeneratePlugin.js +181 -0
  82. package/lib/plugins/RequireVariablePublicPlugin.js +30 -0
  83. package/lib/plugins/ResourceHintsPlugin.js +53 -35
  84. package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +80 -0
  85. package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +82 -0
  86. package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -0
  87. package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +26 -0
  88. package/lib/plugins/ScriptInstrumentPlugin.js +22 -37
  89. package/lib/plugins/ServiceWorkerPlugin.js +107 -0
  90. package/lib/plugins/ShadowDOMSupportPlugin.js +270 -0
  91. package/lib/plugins/SourceMapHookPlugin.js +25 -31
  92. package/lib/plugins/TPHashMappingPlugin.js +67 -0
  93. package/lib/plugins/UglifyCSSPlugin.js +23 -30
  94. package/lib/plugins/UnusedFilesFindPlugin.js +150 -97
  95. package/lib/plugins/index.js +118 -55
  96. package/lib/plugins/libraryImpactPlugin.js +190 -0
  97. package/lib/plugins/webpackwatchrunplugin.js +26 -0
  98. package/lib/postcss-plugins/ExcludeRTLPlugin.js +23 -0
  99. package/lib/postcss-plugins/RTLSplitPlugin.js +138 -0
  100. package/lib/schemas/index.js +463 -52
  101. package/lib/servers/clusterHubServer.js +22 -26
  102. package/lib/servers/docsServer.js +3 -5
  103. package/lib/servers/docsServerCore.js +93 -85
  104. package/lib/servers/helpServer.js +19 -21
  105. package/lib/servers/httpsOptions.js +19 -0
  106. package/lib/servers/impactServer.js +99 -92
  107. package/lib/servers/mockserver.js +44 -0
  108. package/lib/servers/nowatchserver.js +275 -0
  109. package/lib/servers/scrServer.js +147 -0
  110. package/lib/servers/server.js +118 -124
  111. package/lib/servers/ssServer.js +107 -65
  112. package/lib/sh/reportPublish.sh +16 -10
  113. package/lib/templates/CoverageScriptTemplate.js +45 -18
  114. package/lib/templates/WMSTemplate.js +17 -18
  115. package/lib/templates/linterConstant.js +10 -0
  116. package/lib/utils/babelPresets.js +12 -5
  117. package/lib/utils/buildstats.html +148 -0
  118. package/lib/utils/clean.js +12 -11
  119. package/lib/utils/copy.js +13 -127
  120. package/lib/utils/copyTimezones.js +21 -0
  121. package/lib/utils/createEventStream.js +24 -19
  122. package/lib/utils/cssClassNameGenerate.js +70 -0
  123. package/lib/utils/cssURLReplacer.js +67 -54
  124. package/lib/utils/dependencyPostPublish.js +42 -0
  125. package/lib/utils/fileUtils.js +125 -0
  126. package/lib/utils/folderIterator.js +47 -0
  127. package/lib/utils/getComponents.js +126 -0
  128. package/lib/utils/getCurrentBranch.js +11 -17
  129. package/lib/utils/getDependenciesImpactList.js +151 -0
  130. package/lib/utils/getHash.js +26 -0
  131. package/lib/utils/getIp.js +20 -0
  132. package/lib/utils/getOptions.js +55 -30
  133. package/lib/utils/getServerURL.js +25 -8
  134. package/lib/utils/index.js +259 -82
  135. package/lib/utils/init.js +2 -2
  136. package/lib/utils/initPreCommitHook.js +40 -31
  137. package/lib/utils/jsonHelper.js +97 -0
  138. package/lib/utils/libraryImpactConfig.js +63 -0
  139. package/lib/utils/lint/addScripts.js +27 -0
  140. package/lib/utils/lint/checkExistingConfig.js +67 -0
  141. package/lib/utils/lint/copyConfigs.js +24 -0
  142. package/lib/utils/lint/index.js +54 -0
  143. package/lib/utils/lint/lintScripts.js +11 -0
  144. package/lib/utils/lint/lintSetup.js +31 -0
  145. package/lib/utils/lint/lintStagedPreCommitHook.js +7 -0
  146. package/lib/utils/lint/question.js +30 -0
  147. package/lib/utils/lintReporter.js +142 -0
  148. package/lib/utils/mailSender.js +16 -25
  149. package/lib/utils/pullOrigin.js +28 -0
  150. package/lib/utils/reinstallDependencies.js +133 -0
  151. package/lib/utils/removeAttributes.js +25 -23
  152. package/lib/utils/repoClone.js +56 -63
  153. package/lib/utils/request.js +64 -77
  154. package/lib/utils/resultSchema.json +73 -0
  155. package/lib/utils/rtl.js +42 -0
  156. package/lib/utils/setEnvVariables.js +5 -6
  157. package/lib/utils/ssTestHack.js +48 -0
  158. package/lib/utils/switchBranch.js +28 -0
  159. package/lib/utils/urlConcat.js +22 -0
  160. package/package.json +92 -64
  161. package/templates/app/.eslintrc.js +140 -0
  162. package/templates/app/README.md +12 -12
  163. package/templates/app/app/index.html +24 -8
  164. package/templates/app/app/properties/ApplicationResources_en_US.properties +1 -1
  165. package/templates/app/app/properties/i18nkeys.json +3 -3
  166. package/templates/app/docs/all.html +69 -69
  167. package/templates/app/mockapi/index.js +18 -13
  168. package/templates/app/package.json +37 -17
  169. package/templates/app/src/actions/SampleActions/index.js +37 -0
  170. package/templates/app/src/actions/index.js +65 -0
  171. package/templates/app/src/appUrls.js +19 -0
  172. package/templates/app/src/components/Alert/Alert.js +134 -0
  173. package/templates/app/src/components/Alert/Alert.module.css +79 -0
  174. package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -0
  175. package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -0
  176. package/templates/app/src/components/Sample/Sample.module.css +11 -0
  177. package/templates/app/src/components/Sample/SampleList.js +61 -0
  178. package/templates/app/src/components/Slider/Slider.css +41 -0
  179. package/templates/app/src/components/Slider/Slider.js +55 -0
  180. package/templates/app/src/containers/AlertContainer/index.js +15 -0
  181. package/templates/app/src/containers/AppContainer/index.js +96 -0
  182. package/templates/app/src/containers/AppContainer/index.module.css +27 -0
  183. package/templates/app/src/containers/CustomMatch/index.js +65 -0
  184. package/templates/app/src/containers/DevTools/index.js +10 -0
  185. package/templates/app/src/containers/Header/index.js +67 -0
  186. package/templates/app/src/containers/Header/index.module.css +43 -0
  187. package/templates/app/src/containers/Redirect/index.js +63 -0
  188. package/templates/app/src/containers/Redirector/index.js +47 -0
  189. package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -0
  190. package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -0
  191. package/templates/app/src/historyChange.js +5 -0
  192. package/templates/app/src/index.html +10 -0
  193. package/templates/app/src/index.js +24 -0
  194. package/templates/app/src/middleware/PromiseMiddleware.js +59 -0
  195. package/templates/app/src/reducers/alertData.js +11 -0
  196. package/templates/app/src/reducers/index.js +6 -0
  197. package/templates/app/src/reducers/samples.js +19 -0
  198. package/templates/app/src/store/configureStore.dev.js +51 -0
  199. package/templates/app/src/store/configureStore.js +5 -0
  200. package/templates/app/src/store/configureStore.prod.js +26 -0
  201. package/templates/app/src/util/Common.js +5 -0
  202. package/templates/app/src/util/RequestAPI.js +132 -0
  203. package/templates/appold/README.md +12 -0
  204. package/templates/appold/app/index.html +8 -0
  205. package/templates/appold/app/properties/ApplicationResources_en_US.properties +1 -0
  206. package/templates/appold/app/properties/i18nkeys.json +3 -0
  207. package/templates/appold/docs/all.html +69 -0
  208. package/templates/appold/mockapi/index.js +13 -0
  209. package/templates/{app → appold}/mockapi/tickets.json +0 -0
  210. package/templates/appold/package.json +17 -0
  211. package/templates/appold/src/components/Text/Text.css +0 -0
  212. package/templates/appold/src/components/Text/Text.js +23 -0
  213. package/templates/appold/src/components/Text/__tests__/Text.spec.js +30 -0
  214. package/templates/appold/src/components/Text/docs/Text__default.docs.js +16 -0
  215. package/templates/appold/src/components/docs.js +1 -0
  216. package/templates/appold/src/components/index.js +5 -0
  217. package/templates/appold/src/index.js +13 -0
  218. package/templates/docs/all.html +1 -1
  219. package/templates/docs/component.html +110 -69
  220. package/templates/docs/components.html +221 -0
  221. package/templates/docs/css/component.css +12 -14
  222. package/templates/docs/css/componentTest.css +7 -0
  223. package/templates/docs/css/style.css +150 -206
  224. package/templates/docs/impactReportTemplate.html +154 -0
  225. package/templates/docs/index.html +1482 -1336
  226. package/templates/library/src/index.js +0 -0
@@ -1,140 +1,132 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
- var _fs = require('fs');
3
+ var _path = _interopRequireDefault(require("path"));
4
4
 
5
- var _fs2 = _interopRequireDefault(_fs);
5
+ var _https = _interopRequireDefault(require("https"));
6
6
 
7
- var _path = require('path');
7
+ var _webpack = _interopRequireDefault(require("webpack"));
8
8
 
9
- var _path2 = _interopRequireDefault(_path);
9
+ var _express = _interopRequireDefault(require("express"));
10
10
 
11
- var _https = require('https');
11
+ var _ws = _interopRequireDefault(require("ws"));
12
12
 
13
- var _https2 = _interopRequireDefault(_https);
13
+ var _compression = _interopRequireDefault(require("compression"));
14
14
 
15
- var _webpack = require('webpack');
15
+ var _webpackDevMiddleware = _interopRequireDefault(require("webpack-dev-middleware"));
16
16
 
17
- var _webpack2 = _interopRequireDefault(_webpack);
17
+ var _httpProxyMiddleware = require("http-proxy-middleware");
18
18
 
19
- var _express = require('express');
19
+ var _HMRMiddleware = _interopRequireDefault(require("../middlewares/HMRMiddleware"));
20
20
 
21
- var _express2 = _interopRequireDefault(_express);
21
+ var _utils = require("../utils");
22
22
 
23
- var _ws = require('ws');
24
-
25
- var _ws2 = _interopRequireDefault(_ws);
26
-
27
- var _compression = require('compression');
28
-
29
- var _compression2 = _interopRequireDefault(_compression);
30
-
31
- var _webpackDevMiddleware = require('webpack-dev-middleware');
32
-
33
- var _webpackDevMiddleware2 = _interopRequireDefault(_webpackDevMiddleware);
34
-
35
- var _HMRMiddleware = require('../middlewares/HMRMiddleware');
36
-
37
- var _HMRMiddleware2 = _interopRequireDefault(_HMRMiddleware);
38
-
39
- var _utils = require('../utils');
23
+ var _httpsOptions = require("./httpsOptions");
40
24
 
41
25
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
42
26
 
43
- var options = (0, _utils.getOptions)();
44
- var _options$app = options.app,
45
- context = _options$app.context,
46
- server = _options$app.server;
47
- var host = server.host,
48
- port = server.port,
49
- domain = server.domain,
50
- mode = server.mode,
51
- disableContextURL = server.disableContextURL,
52
- hasMock = server.hasMock;
53
-
54
-
55
- var isCompatableHttp2 = Number(process.version.substr(1).split('.')[0]) >= 8;
56
-
57
- var contextURL = disableContextURL ? '' : '/' + context;
58
- var serverUrl = (0, _utils.getServerURL)(server, 'htt' + 'ps');
27
+ // import fs from 'fs';
28
+ let options = (0, _utils.getOptions)();
29
+ let {
30
+ app: {
31
+ context,
32
+ server
33
+ }
34
+ } = options;
35
+ let {
36
+ host,
37
+ port,
38
+ domain,
39
+ mode,
40
+ disableContextURL,
41
+ hasMock,
42
+ mockPort
43
+ } = server;
44
+ let isCompatableHttp2 = Number(process.version.substr(1).split('.')[0]) >= 8;
45
+ let contextURL = disableContextURL ? '' : `/${context}`;
46
+ let serverUrl = (0, _utils.getServerURL)(server, 'htt' + 'ps');
47
+ const {
48
+ writeToDisk
49
+ } = options.impactService;
50
+ const app = (0, _express.default)();
59
51
 
60
- var app = (0, _express2.default)();
52
+ if (hasMock) {
53
+ app.use(server.mockPrefix, (0, _httpProxyMiddleware.createProxyMiddleware)({
54
+ target: 'ht' + `tp://localhost:${mockPort}`,
55
+ changeOrigin: true
56
+ }));
57
+ }
61
58
 
62
- app.use(_express2.default.json());
63
- app.use(_express2.default.urlencoded({
59
+ app.use(_express.default.json());
60
+ app.use(_express.default.urlencoded({
64
61
  extended: true
65
62
  }));
63
+ let config;
66
64
 
67
- var config = void 0;
68
65
  if (mode === 'prod') {
69
66
  config = require('../configs/webpack.prod.config');
70
- app.use((0, _compression2.default)());
71
- } else if (mode === 'dev') {
67
+ app.use((0, _compression.default)());
68
+ } else if (mode === 'dev' || mode === 'dev-no-warn') {
72
69
  config = require('../configs/webpack.dev.config');
73
70
  } else {
74
71
  throw new Error('You must configure valid option in mode');
75
72
  }
76
73
 
77
- process.isDevelopment = true;
78
-
79
- var compiler = (0, _webpack2.default)(config);
80
- var appPath = process.cwd();
81
-
82
- app.use((0, _webpackDevMiddleware2.default)(compiler, {
74
+ let compiler = (0, _webpack.default)(config);
75
+ let webpackServerOptions = {
83
76
  logLevel: 'error',
84
- publicPath: mode === 'prod' ? contextURL === '' ? serverUrl + '/' + contextURL : serverUrl + contextURL : config.output.publicPath,
85
- headers: { 'Access-Control-Allow-Origin': '*' },
77
+ publicPath: mode === 'prod' ? contextURL === '' ? `${serverUrl}/${contextURL}` : serverUrl + contextURL : config.output.publicPath,
78
+ headers: options.app.enableDevCache ? {
79
+ 'Cache-Control': 'public, max-age=604800',
80
+ 'Access-Control-Allow-Origin': '*'
81
+ } : {
82
+ 'Access-Control-Allow-Origin': '*'
83
+ },
86
84
  compress: mode === 'prod'
87
- }));
85
+ };
88
86
 
89
- app.use((0, _HMRMiddleware2.default)(compiler, { path: '/sockjs-node/info' }));
87
+ if (options.app.disableWatch) {
88
+ webpackServerOptions.watchOptions = {
89
+ ignored: /./
90
+ };
91
+ }
90
92
 
91
- if (hasMock) {
92
- var mockServerPath = _path2.default.join(appPath, 'mockapi', 'index.js');
93
- if (_fs2.default.existsSync(mockServerPath)) {
94
- var mockServer = require(mockServerPath);
95
- mockServer(app);
96
- } else {
97
- (0, _utils.log)('You must export a function from mockapi folder by only we can provide mock api hook');
98
- }
93
+ if (writeToDisk) {
94
+ webpackServerOptions.writeToDisk = true;
99
95
  }
100
96
 
101
- app.use(function (req, res, next) {
97
+ app.use((0, _webpackDevMiddleware.default)(compiler, webpackServerOptions));
98
+ app.use((0, _HMRMiddleware.default)(compiler, {
99
+ path: '/sockjs-node/info'
100
+ }));
101
+ app.use((req, res, next) => {
102
102
  res.setHeader('Access-Control-Allow-Origin', '*');
103
103
  next();
104
- }).use(contextURL + '/fonts', _express2.default.static(context + '/fonts'));
105
-
106
- app.use('/wms/*', function (req, res) {
107
- res.sendFile(_path2.default.join(__dirname, '..', '..', 'templates', 'wms', 'index.html'));
104
+ }).use(`${contextURL}/fonts`, _express.default.static(`${context}/fonts`));
105
+ app.use('/wms/*', (req, res) => {
106
+ res.sendFile(_path.default.join(__dirname, '..', '..', 'templates', 'wms', 'index.html'));
108
107
  });
109
108
 
110
- var httpsServer = _https2.default.createServer({
111
- key: _fs2.default.readFileSync(_path2.default.join(__dirname, '../../cert/key.pem')),
112
- cert: _fs2.default.readFileSync(_path2.default.join(__dirname, '../../cert/cert.pem')),
113
- passphrase: 'zddqa1585f82'
114
- }, app);
115
-
116
- var wss = new _ws2.default.Server({ server: httpsServer });
117
- var wsPool = [];
109
+ const httpsServer = _https.default.createServer(_httpsOptions.httpsOptions, app);
118
110
 
119
- wss.on('connection', function (ws) {
111
+ const wss = new _ws.default.Server({
112
+ server: httpsServer
113
+ });
114
+ let wsPool = [];
115
+ wss.on('connection', ws => {
120
116
  wsPool.push(ws);
121
-
122
- ws.on('close', function () {
123
- wsPool = wsPool.filter(function (ws1) {
124
- return ws1 !== ws;
125
- });
117
+ ws.on('close', () => {
118
+ wsPool = wsPool.filter(ws1 => ws1 !== ws);
126
119
  });
127
-
128
- ws.on('message', function (message) {
120
+ ws.on('message', message => {
129
121
  (0, _utils.log)('received: %s', message);
130
122
  });
131
-
132
123
  ws.send('something');
133
124
  });
134
-
135
- app.post('/wmsmockapi', function (req, res) {
136
- wsPool.forEach(function (ws) {
137
- var body = req.body;
125
+ app.post('/wmsmockapi', (req, res) => {
126
+ wsPool.forEach(ws => {
127
+ let {
128
+ body
129
+ } = req;
138
130
 
139
131
  try {
140
132
  ws.send(JSON.stringify(body));
@@ -142,67 +134,69 @@ app.post('/wmsmockapi', function (req, res) {
142
134
  (0, _utils.log)(e, body);
143
135
  }
144
136
  });
145
-
146
137
  res.send('success');
147
138
  });
139
+ let webpackCompilation;
140
+ compiler.hooks.afterCompile.tap('ReactCLI', compilation => {
141
+ webpackCompilation = compilation;
142
+ });
148
143
 
149
144
  if (contextURL) {
150
- app.use(contextURL, _express2.default.static(context));
151
- app.use(contextURL + '/*', _express2.default.static(context));
145
+ app.use(contextURL, _express.default.static(context));
146
+ app.use(`${contextURL}/*`, (req, res) => {
147
+ let indexHtml = webpackCompilation.assets['index.html'];
148
+ res.send(indexHtml && indexHtml.source());
149
+ });
152
150
  } else {
153
- app.use(_express2.default.static(context));
154
- app.use('/*', _express2.default.static(context));
151
+ app.use(_express.default.static(context));
152
+ app.use('/*', _express.default.static(context));
155
153
  }
156
154
 
157
- httpsServer.listen(port, function (err) {
155
+ httpsServer.listen(port, err => {
158
156
  if (err) {
159
157
  throw err;
160
158
  }
161
- (0, _utils.log)('Listening at ' + serverUrl + contextURL + '/');
159
+
160
+ (0, _utils.log)(`Listening at ${serverUrl}${contextURL}/`);
162
161
  });
163
162
 
164
163
  if (isCompatableHttp2) {
165
- var http2 = require('http2');
166
- var http2Server = http2.createSecureServer({
167
- key: _fs2.default.readFileSync(_path2.default.join(__dirname, '../../cert/key.pem')),
168
- cert: _fs2.default.readFileSync(_path2.default.join(__dirname, '../../cert/cert.pem')),
169
- passphrase: 'zddqa1585f82'
170
- });
164
+ const http2 = require('http2');
165
+
166
+ const http2Server = http2.createSecureServer(_httpsOptions.httpsOptions); // eslint-disable-next-line no-unused-vars
171
167
 
172
- //eslint-disable-next-line
173
- http2Server.on('stream', function (stream, headers) {
168
+ http2Server.on('stream', (stream, headers) => {
174
169
  stream.respond({
175
170
  'content-type': 'text/html',
176
171
  ':status': 200
177
172
  });
178
173
  stream.end('<h1>Hello World! <br>Working with http2</h1>');
179
174
  });
180
-
181
- var http2Port = Number(port) + 1;
182
-
183
- http2Server.listen(http2Port, function (err) {
175
+ let http2Port = Number(port) + 1;
176
+ http2Server.listen(http2Port, err => {
184
177
  if (err) {
185
178
  throw err;
186
179
  }
187
- (0, _utils.log)('Listening at ' + (0, _utils.getServerURL)({
188
- host: host,
189
- domain: domain,
180
+
181
+ (0, _utils.log)(`Listening at ${(0, _utils.getServerURL)({
182
+ host,
183
+ domain,
190
184
  port: http2Port
191
- }, 'htt' + 'ps') + contextURL + '/', 'http2 server');
185
+ }, 'htt' + 'ps')}${contextURL}/`, 'http2 server');
192
186
  });
193
187
  } else {
194
188
  (0, _utils.log)('Your node version didn\'t adopted http2 support. Kindly update that to 8 LTS or above you can engage the http2');
195
189
  }
196
190
 
197
- var httpPort = Number(port) + (isCompatableHttp2 ? 2 : 1);
198
-
199
- app.listen(httpPort, function (err) {
191
+ let httpPort = Number(port) + (isCompatableHttp2 ? 2 : 1);
192
+ app.listen(httpPort, err => {
200
193
  if (err) {
201
194
  throw err;
202
195
  }
203
- (0, _utils.log)('Listening at ' + (0, _utils.getServerURL)({
204
- host: host,
205
- domain: domain,
196
+
197
+ (0, _utils.log)(`Listening at ${(0, _utils.getServerURL)({
198
+ host,
199
+ domain,
206
200
  port: httpPort
207
- }, 'ht' + 'tp') + contextURL + '/');
201
+ }, 'ht' + 'tp')}${contextURL}/`);
208
202
  });
@@ -1,81 +1,123 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
- var _child_process = require('child_process');
3
+ var _screenshotTest = _interopRequireDefault(require("@zohodesk/screenshot-test"));
4
4
 
5
- var _screenshotTest = require('@zohodesk/screenshot-test');
5
+ var _jsonHelper = require("../utils/jsonHelper");
6
6
 
7
- var _screenshotTest2 = _interopRequireDefault(_screenshotTest);
7
+ var _utils = require("../utils");
8
8
 
9
- var _utils = require('../utils');
9
+ var _docsServerCore = _interopRequireDefault(require("./docsServerCore"));
10
10
 
11
- var _docsServerCore = require('./docsServerCore');
12
-
13
- var _docsServerCore2 = _interopRequireDefault(_docsServerCore);
11
+ var _SSTMiddleware = _interopRequireDefault(require("../middlewares/SSTMiddleware"));
14
12
 
15
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
14
 
17
- var options = (0, _utils.getOptions)();
18
- var _options$ssTest = options.ssTest,
19
- seleniumHub = _options$ssTest.seleniumHub,
20
- remoteBranch = _options$ssTest.remoteBranch,
21
- referBranch = _options$ssTest.referBranch,
22
- server = options.docs.server;
15
+ let options = (0, _utils.getOptions)();
16
+ let impactedComponentObject = null;
17
+ let docsServerInstance;
18
+ let {
19
+ ssTest: {
20
+ seleniumHub,
21
+ referBranch,
22
+ currentBranch,
23
+ enableImage,
24
+ pathToSubProjects
25
+ },
26
+ docs: {
27
+ server
28
+ }
29
+ } = options;
30
+
31
+ function closeServer(serverInstance) {
32
+ (0, _utils.log)('Docs service stopped!');
33
+ let {
34
+ http,
35
+ https,
36
+ wdm
37
+ } = serverInstance;
38
+ http.close();
39
+ https.close();
40
+ wdm.close();
41
+ }
23
42
 
43
+ (0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'tests.screenshotTest.compareBranch', referBranch);
44
+ (0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'tests.screenshotTest.TestBranch', currentBranch);
45
+ (0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'tests.screenshotTest.isExecuted', true);
46
+ (0, _utils.log)('Test Branch Name :- ', currentBranch);
47
+
48
+ let afterFirstScreenShotCollected = () => {
49
+ closeServer(docsServerInstance);
50
+ (0, _utils.switchBranch)('git', referBranch).then(() => {
51
+ (0, _utils.log)('Reference Branch Name :- ', (0, _utils.getCurrentBranch)());
52
+ (0, _utils.reinstallDependencies)(pathToSubProjects).then(() => {
53
+ (0, _utils.ssTestHack)();
54
+ });
55
+ });
56
+ };
24
57
 
25
- var docsServerInstance = (0, _docsServerCore2.default)(true);
58
+ let onSStestEnd = (status, resultObject, isLastRun, runSSTest) => {
59
+ if (status) {
60
+ if (!isLastRun) {
61
+ (0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'tests.screenshotTest.result', resultObject);
62
+ runSSTest(afterFirstScreenShotCollected, true, 'reference', referBranch, impactedComponentObject);
63
+ } else {
64
+ (0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'tests.screenshotTest.endTime', Date.now());
65
+ (0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'tests.screenshotTest.isPassed', true);
66
+ (0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'tests.screenshotTest.result', resultObject);
67
+ (0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'tests.screenshotTest.message', 'Screenshot test succesfully completed.');
68
+ (0, _jsonHelper.setTestInfoStatus)(`${process.cwd()}/result.json`, true);
69
+ (0, _utils.log)('Screenshot test completed succesfully.');
70
+ closeServer(docsServerInstance);
71
+ }
72
+ } else {
73
+ (0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'tests.screenshotTest.isPassed', false);
74
+ (0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'tests.screenshotTest.message', 'Component list undefined! Please check component Docs');
75
+ (0, _jsonHelper.setTestInfoStatus)(`${process.cwd()}/result.json`, false);
76
+ (0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'testInfo.failures', {
77
+ type: 'screenshotTest',
78
+ message: 'Component list undefined! Please check component Docs'
79
+ });
80
+ closeServer(docsServerInstance);
81
+ (0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'tests.screenshotTest.endTime', Date.now());
82
+ throw new Error('Component list undefined! Please check component Docs');
83
+ }
84
+ };
26
85
 
27
- (0, _utils.log)((0, _utils.getCurrentBranch)(), 'Test Branch');
86
+ (0, _utils.ssTestHack)();
28
87
 
29
- if (remoteBranch) {
30
- docsServerInstance.http.post('/repo/merge', function (req, res) {
31
- var ref = req.body.ref;
88
+ let getDocsServerInstance = beforeJobs => {
89
+ if (typeof beforeJobs === 'function') {
90
+ beforeJobs();
91
+ }
32
92
 
33
- if (ref && ref.endsWith(remoteBranch)) {
34
- (0, _child_process.spawnSync)('git', ['pull', 'origin', remoteBranch], {
35
- stdio: 'inherit'
36
- });
37
- }
38
- res.send('done');
39
- });
40
- }
41
-
42
- var afterFirstScreenShotCollected = function afterFirstScreenShotCollected() {
43
- (0, _child_process.spawnSync)('git', ['checkout', referBranch], { encoding: 'utf8' });
44
- (0, _utils.log)((0, _utils.getCurrentBranch)(), 'Reference Branch');
93
+ return (0, _docsServerCore.default)(true);
45
94
  };
46
- var runSSTest = function runSSTest(onBefore, isLastRun, mode) {
47
- typeof onBefore === 'function' && onBefore();
48
- _screenshotTest2.default.run({
49
- seleniumHub: seleniumHub,
50
- url: (0, _utils.getServerURL)(server, 'ht' + 'tps') + '/docs/component.html',
51
- browserList: ['chrome'],
52
- mode: mode,
53
- script: 'var Objlist={};for (i in Component){try{if(Component[i].prototype.isReactComponent){Objlist[i]=Component[i].docs.componentGroup;}}catch(err){console.log(i,err);}}; return Objlist'
54
- }, function (status) {
55
- if (status) {
56
- if (!isLastRun) {
57
- runSSTest(afterFirstScreenShotCollected, true, 'reference');
58
- } else {
59
- (0, _utils.log)('Screenshot test succesfully completed.');
60
- var http = docsServerInstance.http,
61
- https = docsServerInstance.https,
62
- wdm = docsServerInstance.wdm;
63
-
64
- http.close();
65
- https.close();
66
- wdm.close();
67
- }
68
- } else {
69
- var _http = docsServerInstance.http,
70
- _https = docsServerInstance.https,
71
- _wdm = docsServerInstance.wdm;
72
-
73
- _http.close();
74
- _https.close();
75
- _wdm.close();
76
- throw new Error('Component list undefined! Please check component Docs');
77
- }
78
- });
95
+
96
+ let runSSTest = (onBefore, isLastRun, mode, branch, listOfComponents) => {
97
+ let url = (0, _utils.getServerURL)(Object.assign(server, {
98
+ host: server.iphost
99
+ }), 'ht' + 'tp');
100
+ docsServerInstance = getDocsServerInstance(onBefore);
101
+ docsServerInstance.app.use((0, _SSTMiddleware.default)(docsServerInstance.compiler, mData => {
102
+ impactedComponentObject = (0, _utils.getComponents)(mData, listOfComponents);
103
+
104
+ _screenshotTest.default.run({
105
+ branch,
106
+ seleniumHub: seleniumHub,
107
+ url: `${url}/docs/components.html`,
108
+ browserList: ['chrome'],
109
+ mode,
110
+ enableImage,
111
+ impactedComponentObject,
112
+ script: 'var Objlist = {};for (i in Component) {try { if (Component[i].prototype.isReactComponent) Objlist[i] = Component[i].docs.componentGroup;}catch (err) {console.log(i, err);}};if (Object.keys(Objlist).length < 5) {Objlist = false;}return Objlist;'
113
+ }, (status, finalObj) => {
114
+ onSStestEnd(status, finalObj, isLastRun, runSSTest);
115
+ });
116
+ }));
79
117
  };
80
118
 
81
- runSSTest(null, null, 'test');
119
+ (0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'tests.screenshotTest.startTime', Date.now());
120
+ (0, _utils.getDependenciesImpactList)(currentBranch, referBranch).then(impactedList => {
121
+ (0, _utils.log)('from here ');
122
+ runSSTest(null, null, 'test', currentBranch, impactedList);
123
+ });
@@ -2,13 +2,12 @@
2
2
  branchName=$2
3
3
  url=$1
4
4
  zipUrl=$3
5
- commitMessage=$8
6
-
7
5
  unique=$(date +"%d_%m_%y_Time_%H_%M_%S")
8
6
  publishFolder=$branchName"_"$unique
9
7
 
10
8
  rm -rf ./reports
11
9
  rm -rf ./scrTemplate
10
+ rm -rf ./errTemplate
12
11
  rm -rf ./css
13
12
  rm -rf ./js
14
13
  rm -rf ./index.html
@@ -18,13 +17,20 @@ curl $zipUrl | tar xz
18
17
  cp -rf ./reports/css ./css
19
18
  cp -rf ./reports/js ./js
20
19
  cp -rf ./reports/index.html ./index.html
20
+ if [ -d "./screenShots" ] ; then
21
+ cp -rf ./scrTemplate/* ./screenShots/
22
+ else
23
+ mkdir ./screenShots
24
+ cp -rf ./scrTemplate/* ./screenShots/
25
+ fi
21
26
 
22
- cp -rf ./scrTemplate/css ./screenShots/css
23
- cp -rf ./scrTemplate/js ./screenShots/js
24
- cp -rf ./scrTemplate/images ./screenShots/images
25
- cp -rf ./scrTemplate/index.html ./screenShots/index.html
27
+ [ ! -f "./result.json" ] && touch result.json && cp -rf ./errTemplate/* ./result.json
28
+ [ ! -d "./commitCoverage" ] && mkdir commitCoverage && cp -rf ./errTemplate/* ./commitCoverage/
29
+ [ ! -d "./unittest" ] && mkdir unittest && cp -rf ./errTemplate/* ./unittest/
30
+ [ ! -d "./coverageTest" ] && mkdir coverageTest && cp -rf ./errTemplate/* ./coverageTest/
31
+ [ ! -d "./coverage" ] && mkdir coverage && cp -rf ./errTemplate/* ./coverage/
26
32
 
27
- tar -czvf $publishFolder.tar.gz coverage screenShots unittest coverageTest commitCoverage ./css ./js ./index.html
33
+ tar -czvf $publishFolder.tar.gz coverage screenShots unittest coverageTest commitCoverage ./css ./js ./index.html ./result.json
28
34
 
29
35
  curl -i -F name=file -F file=@$publishFolder.tar.gz $url"/cgi-bin/upload.py"
30
36
  replace=$publishFolder
@@ -33,7 +39,7 @@ subject="Client Report - React - $publishFolder"
33
39
  msg="<p><b>Report URL - <a href='$reportUrl'>Link</a></b></p>
34
40
  <p><b>Report Branchname - $branchName</b></p>
35
41
  <p><b>Report Unique ID - $unique</b></p>
36
- <p><b>Report Developer - $6</b></p>
37
- <p><b>Report commitMessage - $commitMessage</b></p>"
42
+ <p><b>Report Developer - $6</b></p>"
38
43
  #node mailSender.js <from> <pass> <to> <subject> <text>
39
- node ./node_modules/@zohodesk/react-cli/lib/utils/mailSender $4 $5 $6 "$subject" "$msg" $7
44
+ BASEDIR=$(dirname "$0")
45
+ node $BASEDIR"/../utils/mailSender" $4 $5 $6 "$subject" "$msg" $7 $8 "$reportUrl"
@@ -1,44 +1,71 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
3
  window.ClientCoverage = {
4
4
  LocalStorageWrapper: {
5
- getLocalStorage: function getLocalStorage(property, defaultVal) {
5
+ getLocalStorage(property, defaultVal) {
6
6
  if (localStorage.hasOwnProperty(property)) {
7
7
  Object.assign(defaultVal, JSON.parse(localStorage.getItem(property)));
8
- localStorage.setItem(property, JSON.stringify(defaultVal));return defaultVal;
8
+ localStorage.setItem(property, JSON.stringify(defaultVal));
9
+ return defaultVal;
9
10
  }
10
- localStorage.setItem(property, JSON.stringify(defaultVal));return defaultVal || {};
11
+
12
+ localStorage.setItem(property, JSON.stringify(defaultVal));
13
+ return defaultVal || {};
11
14
  },
12
- clearLocalStorage: function clearLocalStorage(property) {
15
+
16
+ clearLocalStorage(property) {
13
17
  localStorage.removeItem(property);
14
18
  }
15
- }, JS: {
16
- jsMethodInstrumentObject: {}, jsStorageKey: 'jsClientCoverageObject', init: function init() {
19
+
20
+ },
21
+ JS: {
22
+ jsMethodInstrumentObject: {},
23
+ jsStorageKey: 'jsClientCoverageObject',
24
+
25
+ init() {
17
26
  this.jsMethodInstrumentObject = ClientCoverage.LocalStorageWrapper.getLocalStorage(this.jsStorageKey, this.jsMethodInstrumentObject);
18
27
  },
19
- visitMethod: function visitMethod(jsFileName, jsMethodName) {
20
- this.init();if (this.jsMethodInstrumentObject.hasOwnProperty(jsFileName)) {
28
+
29
+ visitMethod(jsFileName, jsMethodName) {
30
+ this.init();
31
+
32
+ if (this.jsMethodInstrumentObject.hasOwnProperty(jsFileName)) {
21
33
  if (!this.jsMethodInstrumentObject[jsFileName].includes(jsMethodName)) {
22
34
  this.jsMethodInstrumentObject[jsFileName].push(jsMethodName);
23
35
  }
24
36
  } else {
25
- this.jsMethodInstrumentObject[jsFileName] = [];this.jsMethodInstrumentObject[jsFileName].push(jsMethodName);
37
+ this.jsMethodInstrumentObject[jsFileName] = [];
38
+ this.jsMethodInstrumentObject[jsFileName].push(jsMethodName);
26
39
  }
40
+
27
41
  localStorage.setItem(this.jsStorageKey, JSON.stringify(this.jsMethodInstrumentObject));
28
42
  },
29
- clear: function clear() {
30
- this.jsMethodInstrumentObject = {};ClientCoverage.LocalStorageWrapper.clearLocalStorage(this.jsStorageKey);
43
+
44
+ clear() {
45
+ this.jsMethodInstrumentObject = {};
46
+ ClientCoverage.LocalStorageWrapper.clearLocalStorage(this.jsStorageKey);
31
47
  },
32
- getData: function getData() {
33
- return { methods: this.jsMethodInstrumentObject };
48
+
49
+ getData() {
50
+ return {
51
+ methods: this.jsMethodInstrumentObject
52
+ };
34
53
  }
35
- }, getCoverageData: function getCoverageData() {
36
- return { JS: this.JS.getData() };
54
+
55
+ },
56
+
57
+ getCoverageData() {
58
+ return {
59
+ JS: this.JS.getData()
60
+ };
37
61
  },
38
- clear: function clear() {
62
+
63
+ clear() {
39
64
  this.JS.clear();
40
65
  },
41
- init: function init() {
66
+
67
+ init() {
42
68
  this.JS.init();
43
69
  }
70
+
44
71
  };