@zohodesk/react-cli 0.0.1-test.148.3 → 1.0.0-exp.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (180) hide show
  1. package/.eslintignore +7 -7
  2. package/.eslintrc.js +180 -183
  3. package/.prettierrc +6 -0
  4. package/{CHANGELOG.md → CHANGELOG-fz.md} +0 -0
  5. package/Changelog.md +1019 -0
  6. package/README.md +1161 -678
  7. package/bin/cli.js +483 -392
  8. package/docs/CustomChunks.md +26 -0
  9. package/docs/DevServerPort.md +39 -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/SelectorWeight.md +6 -0
  14. package/docs/TODOS.md +10 -0
  15. package/docs/ValueReplacer.md +60 -0
  16. package/docs/VariableConversion.md +724 -0
  17. package/docs/warnings_while_install.txt +35 -0
  18. package/files/eslintrc.js +62 -62
  19. package/files/prettierrc.js +3 -3
  20. package/lib/common/getEntries.js +9 -6
  21. package/lib/common/index.js +6 -6
  22. package/lib/common/splitChunks.js +60 -12
  23. package/lib/common/sslcertUpdater.js +59 -0
  24. package/lib/common/testPattern.js +69 -0
  25. package/lib/common/valueReplacer.js +55 -0
  26. package/lib/configs/jest.config.js +18 -8
  27. package/lib/configs/libAlias.js +38 -0
  28. package/lib/configs/resolvers.js +40 -0
  29. package/lib/configs/webpack.css.umd.config.js +4 -4
  30. package/lib/configs/webpack.dev.config.js +59 -54
  31. package/lib/configs/webpack.docs.config.js +74 -59
  32. package/lib/configs/webpack.docs1.config.js +122 -0
  33. package/lib/configs/webpack.impact.config.js +54 -50
  34. package/lib/configs/webpack.prod.config.js +72 -47
  35. package/lib/constants.js +31 -0
  36. package/lib/hooks/docsEntry.js +18 -0
  37. package/lib/jest/preProcessors/cssPreprocessor.js +16 -7
  38. package/lib/loaderUtils/configsAssetsLoaders.js +117 -0
  39. package/lib/loaderUtils/getCSSLoaders.js +89 -21
  40. package/lib/loaderUtils/index.js +4 -4
  41. package/lib/loaderUtils/windowsModification.js +11 -0
  42. package/lib/loaders/fileBountryLoader.js +17 -0
  43. package/lib/loaders/scriptInstrumentLoader.js +2 -2
  44. package/lib/loaders/selectorMappingLoader.js +75 -0
  45. package/lib/loaders/workerLoader.js +9 -9
  46. package/lib/pluginUtils/configHtmlWebpackPlugins.js +60 -0
  47. package/lib/pluginUtils/getDevPlugins.js +70 -45
  48. package/lib/pluginUtils/getDocsPlugins.js +21 -10
  49. package/lib/pluginUtils/getLibraryImactPlugins.js +23 -0
  50. package/lib/pluginUtils/getProdPlugins.js +74 -58
  51. package/lib/pluginUtils/index.js +12 -12
  52. package/lib/plugins/CdnChangePlugin.js +16 -2
  53. package/lib/plugins/EFCPlugin.js +52 -20
  54. package/lib/plugins/EFCPlugin.md +6 -0
  55. package/lib/plugins/EFCTemplatePlugin.js +151 -0
  56. package/lib/plugins/I18NInjectIntoIndexPlugin.js +4 -4
  57. package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +38 -38
  58. package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +30 -30
  59. package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +8 -8
  60. package/lib/plugins/I18nSplitPlugin/I18nSplit.md +95 -86
  61. package/lib/plugins/I18nSplitPlugin/README.md +25 -25
  62. package/lib/plugins/I18nSplitPlugin/index.js +57 -57
  63. package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +2 -2
  64. package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +1 -1
  65. package/lib/plugins/ManifestPlugin.js +8 -0
  66. package/lib/plugins/RequireVariablePublicPlugin.js +30 -0
  67. package/lib/plugins/ResourceHintsPlugin.js +17 -17
  68. package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +6 -6
  69. package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -0
  70. package/lib/plugins/SelectorPlugin.js +97 -0
  71. package/lib/plugins/ServiceWorkerPlugin.js +13 -9
  72. package/lib/plugins/SourceMapHookPlugin.js +9 -3
  73. package/lib/plugins/TPHashMappingPlugin.js +4 -4
  74. package/lib/plugins/VariableConversionCollector.js +352 -0
  75. package/lib/plugins/composeCommonPlugin.js +30 -0
  76. package/lib/plugins/index.js +36 -36
  77. package/lib/plugins/libraryImpactPlugin.js +14 -2
  78. package/lib/postcss-plugins/{ExcludeRTLPlugin.js → ExcludePlugin.js} +1 -1
  79. package/lib/postcss-plugins/RTLSplitPlugin.js +13 -13
  80. package/lib/postcss-plugins/ValueReplacer.js +46 -0
  81. package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +22 -0
  82. package/lib/postcss-plugins/__test__/test1Input.css +39 -0
  83. package/lib/postcss-plugins/__test__/test1Output.css +39 -0
  84. package/lib/postcss-plugins/hoverActivePlugin.js +389 -0
  85. package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +60 -0
  86. package/lib/postcss-plugins/variableModificationPlugin/index.js +307 -0
  87. package/lib/postcss-plugins/variableModifier.js +244 -0
  88. package/lib/schemas/index.js +173 -11
  89. package/lib/servers/devBuild.js +102 -0
  90. package/lib/servers/docsServerCore.js +16 -18
  91. package/lib/servers/getCliPath.js +28 -0
  92. package/lib/servers/httpsOptions.js +49 -0
  93. package/lib/servers/nowatchserver.js +206 -0
  94. package/lib/servers/server.js +114 -82
  95. package/lib/sh/pre-commit.sh +34 -34
  96. package/lib/sh/reportPublish.sh +45 -45
  97. package/lib/templates/linterConstant.js +1 -1
  98. package/lib/utils/buildstats.html +148 -148
  99. package/lib/utils/cssClassNameGenerate.js +9 -2
  100. package/lib/utils/cssURLReplacer.js +30 -43
  101. package/lib/utils/getCurrentBranch.js +1 -1
  102. package/lib/utils/getDependenciesImpactList.js +14 -12
  103. package/lib/utils/getFileType.js +49 -0
  104. package/lib/utils/getOptions.js +118 -10
  105. package/lib/utils/index.js +44 -20
  106. package/lib/utils/jsonHelper.js +12 -3
  107. package/lib/utils/reinstallDependencies.js +1 -1
  108. package/lib/utils/repoClone.js +16 -4
  109. package/lib/utils/resultSchema.json +73 -73
  110. package/lib/utils/rtl.js +19 -2
  111. package/lib/utils/useExitCleanup.js +55 -0
  112. package/npm8.md +9 -0
  113. package/package.json +121 -142
  114. package/postpublish.js +8 -0
  115. package/result.json +1 -0
  116. package/templates/app/.eslintrc.js +140 -140
  117. package/templates/app/README.md +12 -12
  118. package/templates/app/app/index.html +24 -24
  119. package/templates/app/app/properties/ApplicationResources_en_US.properties +1 -1
  120. package/templates/app/app/properties/i18nkeys.json +3 -3
  121. package/templates/app/docs/all.html +69 -69
  122. package/templates/app/mockapi/index.js +18 -18
  123. package/templates/app/package.json +37 -37
  124. package/templates/app/src/actions/SampleActions/index.js +37 -37
  125. package/templates/app/src/actions/index.js +65 -65
  126. package/templates/app/src/appUrls.js +19 -19
  127. package/templates/app/src/components/Alert/Alert.js +134 -134
  128. package/templates/app/src/components/Alert/Alert.module.css +79 -79
  129. package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -37
  130. package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -84
  131. package/templates/app/src/components/Sample/Sample.module.css +11 -11
  132. package/templates/app/src/components/Sample/SampleList.js +61 -61
  133. package/templates/app/src/components/Slider/Slider.css +41 -41
  134. package/templates/app/src/components/Slider/Slider.js +55 -55
  135. package/templates/app/src/containers/AlertContainer/index.js +15 -15
  136. package/templates/app/src/containers/AppContainer/index.js +96 -96
  137. package/templates/app/src/containers/AppContainer/index.module.css +27 -27
  138. package/templates/app/src/containers/CustomMatch/index.js +65 -65
  139. package/templates/app/src/containers/DevTools/index.js +10 -10
  140. package/templates/app/src/containers/Header/index.js +67 -67
  141. package/templates/app/src/containers/Header/index.module.css +43 -43
  142. package/templates/app/src/containers/Redirect/index.js +63 -63
  143. package/templates/app/src/containers/Redirector/index.js +47 -47
  144. package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -42
  145. package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -3
  146. package/templates/app/src/historyChange.js +5 -5
  147. package/templates/app/src/index.html +10 -10
  148. package/templates/app/src/index.js +24 -24
  149. package/templates/app/src/middleware/PromiseMiddleware.js +59 -59
  150. package/templates/app/src/reducers/alertData.js +11 -11
  151. package/templates/app/src/reducers/index.js +6 -6
  152. package/templates/app/src/reducers/samples.js +19 -19
  153. package/templates/app/src/store/configureStore.dev.js +51 -51
  154. package/templates/app/src/store/configureStore.js +5 -5
  155. package/templates/app/src/store/configureStore.prod.js +26 -26
  156. package/templates/app/src/util/Common.js +5 -5
  157. package/templates/app/src/util/RequestAPI.js +132 -132
  158. package/templates/docs/a.html +13 -0
  159. package/templates/docs/all.html +249 -249
  160. package/templates/docs/component.html +178 -178
  161. package/templates/docs/components.html +221 -221
  162. package/templates/docs/css/b.min.css +6 -6
  163. package/templates/docs/css/component.css +42 -42
  164. package/templates/docs/css/componentTest.css +6 -6
  165. package/templates/docs/css/hopscotch.css +585 -585
  166. package/templates/docs/css/style.css +1022 -1022
  167. package/templates/docs/docsEntry.js +14 -0
  168. package/templates/docs/docsRoot.js +3 -0
  169. package/templates/docs/impactReportTemplate.html +154 -154
  170. package/templates/docs/index.html +1501 -1493
  171. package/templates/docs/js/active-line.js +72 -72
  172. package/templates/docs/js/b.min.js +7 -7
  173. package/templates/docs/js/codemirror.js +9680 -9680
  174. package/templates/docs/js/designTokens.js +334 -334
  175. package/templates/docs/js/j.min.js +4 -4
  176. package/templates/docs/js/javascript.js +874 -874
  177. package/templates/docs/js/matchbrackets.js +145 -145
  178. package/unittest/index.html +37 -0
  179. package/cert/cert.pem +0 -105
  180. package/cert/key.pem +0 -30
@@ -0,0 +1,206 @@
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
+ const options = (0, _utils.getOptions)(); // let args = process.argv.slice(3);
23
+
24
+ const httpsOptions = (0, _httpsOptions.httpsOptionsWithUserFriendlyError)(options);
25
+ const {
26
+ app: {
27
+ context,
28
+ server
29
+ }
30
+ } = options;
31
+ const {
32
+ host,
33
+ port,
34
+ domain,
35
+ disableContextURL,
36
+ hasMock,
37
+ mockPort
38
+ } = server;
39
+ const isCompatableHttp2 = Number(process.version.slice(1).split('.')[0]) >= 8;
40
+ const contextURL = disableContextURL ? '' : `/${context}`;
41
+ const serverUrl = (0, _utils.getServerURL)(server, 'htt' + 'ps');
42
+ const {
43
+ zipname,
44
+ cssSelectorZipPath,
45
+ outputFolderLocation
46
+ } = (0, _devBuild.getPaths)();
47
+ const app = (0, _express.default)();
48
+
49
+ if (hasMock) {
50
+ app.use(server.mockPrefix, (0, _httpProxyMiddleware.createProxyMiddleware)({
51
+ target: 'ht' + `tp://localhost:${mockPort}`,
52
+ changeOrigin: true
53
+ }));
54
+ } // Nb@$#3NGscc
55
+
56
+
57
+ app.use(_express.default.json());
58
+ app.use(_express.default.urlencoded({
59
+ extended: true
60
+ }));
61
+
62
+ const staticPart = _express.default.static(outputFolderLocation, {
63
+ cacheControl: true,
64
+ setHeaders: function (res) {
65
+ if (options.app.enableDevCache) {
66
+ res.setHeader('Cache-Control', 'public, max-age=604800');
67
+ }
68
+
69
+ res.setHeader('Access-Control-Allow-Origin', '*');
70
+ }
71
+ });
72
+
73
+ if (contextURL === '') {
74
+ app.use(staticPart);
75
+ } else {
76
+ app.use(contextURL, staticPart);
77
+ }
78
+
79
+ app.use((req, res, next) => {
80
+ res.setHeader('Access-Control-Allow-Origin', '*');
81
+ next();
82
+ }).use(`${contextURL}/fonts`, _express.default.static(`${context}/fonts`));
83
+ app.use('/wms/*', (req, res) => {
84
+ res.sendFile(_path.default.join(__dirname, '..', '..', 'templates', 'wms', 'index.html'));
85
+ });
86
+
87
+ const httpsServer = _https.default.createServer(httpsOptions, app);
88
+
89
+ if (httpsOptions) {
90
+ const wss = new _ws.default.Server({
91
+ server: httpsServer
92
+ });
93
+ let wsPool = [];
94
+ wss.on('connection', ws => {
95
+ wsPool.push(ws);
96
+ ws.on('close', () => {
97
+ wsPool = wsPool.filter(ws1 => ws1 !== ws);
98
+ });
99
+ ws.on('message', message => {
100
+ (0, _utils.log)('received: %s', message);
101
+ });
102
+ ws.send('something');
103
+ });
104
+ app.post('/wmsmockapi', (req, res) => {
105
+ wsPool.forEach(ws => {
106
+ const {
107
+ body
108
+ } = req;
109
+
110
+ try {
111
+ ws.send(JSON.stringify(body));
112
+ } catch (e) {
113
+ (0, _utils.log)(e, body);
114
+ }
115
+ });
116
+ res.send('success');
117
+ });
118
+ } // let webpackCompilation;
119
+ // compiler.hooks.afterCompile.tap('ReactCLI', compilation => {
120
+ // webpackCompilation = compilation;
121
+ // });
122
+
123
+
124
+ if (zipname) {
125
+ app.use(`/zips/${zipname}.zip`, (req, res) => {
126
+ res.download(_path.default.join(process.cwd(), cssSelectorZipPath), err => {
127
+ if (err) {
128
+ throw err;
129
+ }
130
+
131
+ console.log(`${zipname}.zip downloaded`);
132
+ });
133
+ });
134
+ app.use('/zips/build.zip', (req, res) => {
135
+ res.download(_path.default.join(process.cwd(), 'build.zip'), err => {
136
+ if (err) {
137
+ throw err;
138
+ }
139
+
140
+ console.log('build.zip downloaded');
141
+ });
142
+ });
143
+ }
144
+
145
+ if (contextURL) {
146
+ app.use(contextURL, _express.default.static(context));
147
+ app.use(`${contextURL}/*`, (req, res) => {
148
+ // let indexHtml = webpackCompilation.assets['index.html'];
149
+ res.sendFile(_path.default.join(outputFolderLocation, 'index.html')); // let indexHtml = webpackCompilation.assets['index.html'];
150
+ // res.send(indexHtml && indexHtml.source());
151
+ });
152
+ } else {
153
+ app.use(_express.default.static(context));
154
+ app.use('/*', _express.default.static(context));
155
+ }
156
+
157
+ if (httpsOptions) {
158
+ httpsServer.listen(port, err => {
159
+ if (err) {
160
+ throw err;
161
+ }
162
+
163
+ (0, _utils.log)(`Listening at ${serverUrl}${contextURL}/`);
164
+ });
165
+
166
+ if (isCompatableHttp2) {
167
+ const http2 = require('http2');
168
+
169
+ const http2Server = http2.createSecureServer(httpsOptions); // eslint-disable-next-line no-unused-vars
170
+
171
+ http2Server.on('stream', (stream, headers) => {
172
+ stream.respond({
173
+ 'content-type': 'text/html',
174
+ ':status': 200
175
+ });
176
+ stream.end('<h1>Hello World! <br>Working with http2</h1>');
177
+ });
178
+ const http2Port = Number(port) + 1;
179
+ http2Server.listen(http2Port, err => {
180
+ if (err) {
181
+ throw err;
182
+ }
183
+
184
+ (0, _utils.log)(`Listening at ${(0, _utils.getServerURL)({
185
+ host,
186
+ domain,
187
+ port: http2Port
188
+ }, 'htt' + 'ps')}${contextURL}/`, 'http2 server');
189
+ });
190
+ } else {
191
+ (0, _utils.log)("Your node version didn't adopted http2 support. Kindly update that to 8 LTS or above you can engage the http2");
192
+ }
193
+ }
194
+
195
+ const httpPort = Number(port) + (isCompatableHttp2 ? 2 : 1);
196
+ app.listen(httpPort, err => {
197
+ if (err) {
198
+ throw err;
199
+ }
200
+
201
+ (0, _utils.log)(`Listening at ${(0, _utils.getServerURL)({
202
+ host,
203
+ domain,
204
+ port: httpPort
205
+ }, 'ht' + 'tp')}${contextURL}/`);
206
+ });
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
 
3
- var _fs = _interopRequireDefault(require("fs"));
4
-
5
3
  var _path = _interopRequireDefault(require("path"));
6
4
 
7
5
  var _https = _interopRequireDefault(require("https"));
@@ -22,16 +20,20 @@ var _HMRMiddleware = _interopRequireDefault(require("../middlewares/HMRMiddlewar
22
20
 
23
21
  var _utils = require("../utils");
24
22
 
23
+ var _httpsOptions = require("./httpsOptions");
24
+
25
25
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
26
26
 
27
- let options = (0, _utils.getOptions)();
28
- let {
27
+ // import fs from 'fs';
28
+ const options = (0, _utils.getOptions)();
29
+ const httpsOptions = (0, _httpsOptions.httpsOptionsWithUserFriendlyError)(options);
30
+ const {
29
31
  app: {
30
32
  context,
31
33
  server
32
34
  }
33
35
  } = options;
34
- let {
36
+ const {
35
37
  host,
36
38
  port,
37
39
  domain,
@@ -40,13 +42,16 @@ let {
40
42
  hasMock,
41
43
  mockPort
42
44
  } = server;
43
- let isCompatableHttp2 = Number(process.version.substr(1).split('.')[0]) >= 8;
44
- let contextURL = disableContextURL ? '' : `/${context}`;
45
- let serverUrl = (0, _utils.getServerURL)(server, 'htt' + 'ps');
45
+ const isCompatableHttp2 = Number(process.version.substr(1).split('.')[0]) >= 8;
46
+ const contextURL = disableContextURL ? '' : `/${context}`;
47
+ const serverUrl = (0, _utils.getServerURL)(server, 'htt' + 'ps');
48
+ const {
49
+ writeToDisk
50
+ } = options.impactService;
46
51
  const app = (0, _express.default)();
47
52
 
48
53
  if (hasMock) {
49
- app.use('/api', (0, _httpProxyMiddleware.createProxyMiddleware)({
54
+ app.use(server.mockPrefix, (0, _httpProxyMiddleware.createProxyMiddleware)({
50
55
  target: 'ht' + `tp://localhost:${mockPort}`,
51
56
  changeOrigin: true
52
57
  }));
@@ -65,119 +70,146 @@ if (mode === 'prod') {
65
70
  config = require('../configs/webpack.dev.config');
66
71
  } else {
67
72
  throw new Error('You must configure valid option in mode');
68
- }
73
+ } // console.log({ contextURL });
69
74
 
70
- let compiler = (0, _webpack.default)(config);
71
- app.use((0, _webpackDevMiddleware.default)(compiler, {
75
+
76
+ const compiler = (0, _webpack.default)(config);
77
+ const webpackServerOptions = {
72
78
  logLevel: 'error',
73
79
  publicPath: mode === 'prod' ? contextURL === '' ? `${serverUrl}/${contextURL}` : serverUrl + contextURL : config.output.publicPath,
74
- headers: {
80
+ headers: options.app.enableDevCache ? {
81
+ 'Cache-Control': 'public, max-age=604800',
82
+ 'Access-Control-Allow-Origin': '*'
83
+ } : {
75
84
  'Access-Control-Allow-Origin': '*'
76
85
  },
77
86
  compress: mode === 'prod'
78
- }));
87
+ };
88
+
89
+ if (options.app.disableWatch) {
90
+ webpackServerOptions.watchOptions = {
91
+ ignored: /./
92
+ };
93
+ }
94
+
95
+ if (writeToDisk) {
96
+ webpackServerOptions.writeToDisk = true;
97
+ }
98
+
99
+ app.use((0, _webpackDevMiddleware.default)(compiler, webpackServerOptions));
79
100
  app.use((0, _HMRMiddleware.default)(compiler, {
80
101
  path: '/sockjs-node/info'
81
102
  }));
82
103
  app.use((req, res, next) => {
83
- res.setHeader('Access-Control-Allow-Origin', '*');
104
+ //console.log('origin', req.get('origin'));
105
+ res.setHeader('Access-Control-Allow-Origin', req.get('origin') || '*'); // res.setHeader('Access-Control-Allow-Origin', req.get('origin'));
106
+
107
+ res.setHeader('Access-Control-Allow-Private-Network', true);
108
+ res.setHeader('Access-Control-Allow-Credentials', true);
84
109
  next();
85
110
  }).use(`${contextURL}/fonts`, _express.default.static(`${context}/fonts`));
111
+ app.options('/*', (req, res) => {
112
+ res.send('Ok');
113
+ });
86
114
  app.use('/wms/*', (req, res) => {
87
115
  res.sendFile(_path.default.join(__dirname, '..', '..', 'templates', 'wms', 'index.html'));
88
116
  });
89
117
 
90
- const httpsServer = _https.default.createServer({
91
- key: _fs.default.readFileSync(_path.default.join(__dirname, '../../cert/key.pem')),
92
- cert: _fs.default.readFileSync(_path.default.join(__dirname, '../../cert/cert.pem')),
93
- passphrase: '9i1pqink!k11'
94
- }, app);
118
+ const httpsServer = _https.default.createServer(httpsOptions, app);
95
119
 
96
- const wss = new _ws.default.Server({
97
- server: httpsServer
98
- });
99
- let wsPool = [];
100
- wss.on('connection', ws => {
101
- wsPool.push(ws);
102
- ws.on('close', () => {
103
- wsPool = wsPool.filter(ws1 => ws1 !== ws);
120
+ if (httpsOptions) {
121
+ const wss = new _ws.default.Server({
122
+ server: httpsServer
104
123
  });
105
- ws.on('message', message => {
106
- (0, _utils.log)('received: %s', message);
124
+ let wsPool = [];
125
+ wss.on('connection', ws => {
126
+ wsPool.push(ws);
127
+ ws.on('close', () => {
128
+ wsPool = wsPool.filter(ws1 => ws1 !== ws);
129
+ });
130
+ ws.on('message', message => {
131
+ (0, _utils.log)('received: %s', message);
132
+ });
133
+ ws.send('something');
107
134
  });
108
- ws.send('something');
109
- });
110
- app.post('/wmsmockapi', (req, res) => {
111
- wsPool.forEach(ws => {
112
- let {
113
- body
114
- } = req;
115
-
116
- try {
117
- ws.send(JSON.stringify(body));
118
- } catch (e) {
119
- (0, _utils.log)(e, body);
120
- }
135
+ app.post('/wmsmockapi', (req, res) => {
136
+ wsPool.forEach(ws => {
137
+ const {
138
+ body
139
+ } = req;
140
+
141
+ try {
142
+ ws.send(JSON.stringify(body));
143
+ } catch (e) {
144
+ (0, _utils.log)(e, body);
145
+ }
146
+ });
147
+ res.send('success');
121
148
  });
122
- res.send('success');
123
- });
149
+ }
150
+
124
151
  let webpackCompilation;
152
+ let initalHTML;
125
153
  compiler.hooks.afterCompile.tap('ReactCLI', compilation => {
126
154
  webpackCompilation = compilation;
127
155
  });
156
+ compiler.hooks.done.tap('ReactCLI', () => {
157
+ const indexHtml = webpackCompilation.assets['index.html'];
158
+
159
+ if (indexHtml) {
160
+ initalHTML = indexHtml.source();
161
+ }
162
+ });
128
163
 
129
164
  if (contextURL) {
130
165
  app.use(contextURL, _express.default.static(context));
131
166
  app.use(`${contextURL}/*`, (req, res) => {
132
- let indexHtml = webpackCompilation.assets['index.html'];
133
- res.send(indexHtml && indexHtml.source());
167
+ res.send(initalHTML);
134
168
  });
135
169
  } else {
136
170
  app.use(_express.default.static(context));
137
171
  app.use('/*', _express.default.static(context));
138
172
  }
139
173
 
140
- httpsServer.listen(port, err => {
141
- if (err) {
142
- throw err;
143
- }
144
-
145
- (0, _utils.log)(`Listening at ${serverUrl}${contextURL}/`);
146
- });
147
-
148
- if (isCompatableHttp2) {
149
- const http2 = require('http2');
150
-
151
- const http2Server = http2.createSecureServer({
152
- key: _fs.default.readFileSync(_path.default.join(__dirname, '../../cert/key.pem')),
153
- cert: _fs.default.readFileSync(_path.default.join(__dirname, '../../cert/cert.pem')),
154
- passphrase: '9i1pqink!k11'
155
- }); //eslint-disable-next-line
156
-
157
- http2Server.on('stream', (stream, headers) => {
158
- stream.respond({
159
- 'content-type': 'text/html',
160
- ':status': 200
161
- });
162
- stream.end('<h1>Hello World! <br>Working with http2</h1>');
163
- });
164
- let http2Port = Number(port) + 1;
165
- http2Server.listen(http2Port, err => {
174
+ if (httpsOptions) {
175
+ httpsServer.listen(port, err => {
166
176
  if (err) {
167
177
  throw err;
168
178
  }
169
179
 
170
- (0, _utils.log)(`Listening at ${(0, _utils.getServerURL)({
171
- host,
172
- domain,
173
- port: http2Port
174
- }, 'htt' + 'ps')}${contextURL}/`, 'http2 server');
180
+ (0, _utils.log)(`Listening at ${serverUrl}${contextURL}/`);
175
181
  });
176
- } else {
177
- (0, _utils.log)("Your node version didn't adopted http2 support. Kindly update that to 8 LTS or above you can engage the http2");
182
+
183
+ if (isCompatableHttp2) {
184
+ const http2 = require('http2');
185
+
186
+ const http2Server = http2.createSecureServer(httpsOptions); // eslint-disable-next-line no-unused-vars
187
+
188
+ http2Server.on('stream', (stream, headers) => {
189
+ stream.respond({
190
+ 'content-type': 'text/html',
191
+ ':status': 200
192
+ });
193
+ stream.end('<h1>Hello World! <br>Working with http2</h1>');
194
+ });
195
+ const http2Port = Number(port) + 1;
196
+ http2Server.listen(http2Port, err => {
197
+ if (err) {
198
+ throw err;
199
+ }
200
+
201
+ (0, _utils.log)(`Listening at ${(0, _utils.getServerURL)({
202
+ host,
203
+ domain,
204
+ port: http2Port
205
+ }, 'htt' + 'ps')}${contextURL}/`, 'http2 server');
206
+ });
207
+ } else {
208
+ (0, _utils.log)("Your node version didn't adopted http2 support. Kindly update that to 8 LTS or above you can engage the http2");
209
+ }
178
210
  }
179
211
 
180
- let httpPort = Number(port) + (isCompatableHttp2 ? 2 : 1);
212
+ const httpPort = Number(port) + (isCompatableHttp2 ? 2 : 1);
181
213
  app.listen(httpPort, err => {
182
214
  if (err) {
183
215
  throw err;
@@ -186,6 +218,6 @@ app.listen(httpPort, err => {
186
218
  (0, _utils.log)(`Listening at ${(0, _utils.getServerURL)({
187
219
  host,
188
220
  domain,
189
- port: httpPort
221
+ port: port
190
222
  }, 'ht' + 'tp')}${contextURL}/`);
191
223
  });
@@ -1,34 +1,34 @@
1
- #!/bin/sh
2
-
3
- STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -E "\.(js)$") # Get staged files
4
-
5
- CURRENT_BRANCH=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p') # Get branch name
6
-
7
- echo "Branch Name - $CURRENT_BRANCH"
8
-
9
- if [[ "$STAGED_FILES" = "" ]]; then
10
- exit 0
11
- fi
12
-
13
- IS_FAILED=false
14
- FILES=""
15
-
16
- for FILE in $STAGED_FILES # Add files with space separation
17
- do
18
- FILES+="$FILE "
19
- done
20
-
21
- npm run lint --prefix ${PREFIX_PATH} $FILES # Run ESLint
22
-
23
- if [[ "$?" != 0 ]]; then
24
- IS_FAILED=true
25
- fi
26
-
27
- if $IS_FAILED; then
28
- echo "\033[41mCOMMIT FAILED:\033[0m Your commit contains files that should pass ESLint but do not. Please fix the ESLint errors and try again.\n"
29
- exit 1
30
- else
31
- echo "\033[42mCOMMIT SUCCEEDED\033[0m\n"
32
- fi
33
-
34
- exit $?
1
+ #!/bin/sh
2
+
3
+ STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -E "\.(js)$") # Get staged files
4
+
5
+ CURRENT_BRANCH=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p') # Get branch name
6
+
7
+ echo "Branch Name - $CURRENT_BRANCH"
8
+
9
+ if [[ "$STAGED_FILES" = "" ]]; then
10
+ exit 0
11
+ fi
12
+
13
+ IS_FAILED=false
14
+ FILES=""
15
+
16
+ for FILE in $STAGED_FILES # Add files with space separation
17
+ do
18
+ FILES+="$FILE "
19
+ done
20
+
21
+ npm run lint --prefix ${PREFIX_PATH} $FILES # Run ESLint
22
+
23
+ if [[ "$?" != 0 ]]; then
24
+ IS_FAILED=true
25
+ fi
26
+
27
+ if $IS_FAILED; then
28
+ echo "\033[41mCOMMIT FAILED:\033[0m Your commit contains files that should pass ESLint but do not. Please fix the ESLint errors and try again.\n"
29
+ exit 1
30
+ else
31
+ echo "\033[42mCOMMIT SUCCEEDED\033[0m\n"
32
+ fi
33
+
34
+ exit $?
@@ -1,45 +1,45 @@
1
- #!/bin/bash
2
- branchName=$2
3
- url=$1
4
- zipUrl=$3
5
- unique=$(date +"%d_%m_%y_Time_%H_%M_%S")
6
- publishFolder=$branchName"_"$unique
7
-
8
- rm -rf ./reports
9
- rm -rf ./scrTemplate
10
- rm -rf ./errTemplate
11
- rm -rf ./css
12
- rm -rf ./js
13
- rm -rf ./index.html
14
-
15
- curl $zipUrl | tar xz
16
-
17
- cp -rf ./reports/css ./css
18
- cp -rf ./reports/js ./js
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
26
-
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/
32
-
33
- tar -czvf $publishFolder.tar.gz coverage screenShots unittest coverageTest commitCoverage ./css ./js ./index.html ./result.json
34
-
35
- curl -i -F name=file -F file=@$publishFolder.tar.gz $url"/cgi-bin/upload.py"
36
- replace=$publishFolder
37
- reportUrl=$url"/"$replace
38
- subject="Client Report - React - $publishFolder"
39
- msg="<p><b>Report URL - <a href='$reportUrl'>Link</a></b></p>
40
- <p><b>Report Branchname - $branchName</b></p>
41
- <p><b>Report Unique ID - $unique</b></p>
42
- <p><b>Report Developer - $6</b></p>"
43
- #node mailSender.js <from> <pass> <to> <subject> <text>
44
- BASEDIR=$(dirname "$0")
45
- node $BASEDIR"/../utils/mailSender" $4 $5 $6 "$subject" "$msg" $7 $8 "$reportUrl"
1
+ #!/bin/bash
2
+ branchName=$2
3
+ url=$1
4
+ zipUrl=$3
5
+ unique=$(date +"%d_%m_%y_Time_%H_%M_%S")
6
+ publishFolder=$branchName"_"$unique
7
+
8
+ rm -rf ./reports
9
+ rm -rf ./scrTemplate
10
+ rm -rf ./errTemplate
11
+ rm -rf ./css
12
+ rm -rf ./js
13
+ rm -rf ./index.html
14
+
15
+ curl $zipUrl | tar xz
16
+
17
+ cp -rf ./reports/css ./css
18
+ cp -rf ./reports/js ./js
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
26
+
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/
32
+
33
+ tar -czvf $publishFolder.tar.gz coverage screenShots unittest coverageTest commitCoverage ./css ./js ./index.html ./result.json
34
+
35
+ curl -i -F name=file -F file=@$publishFolder.tar.gz $url"/cgi-bin/upload.py"
36
+ replace=$publishFolder
37
+ reportUrl=$url"/"$replace
38
+ subject="Client Report - React - $publishFolder"
39
+ msg="<p><b>Report URL - <a href='$reportUrl'>Link</a></b></p>
40
+ <p><b>Report Branchname - $branchName</b></p>
41
+ <p><b>Report Unique ID - $unique</b></p>
42
+ <p><b>Report Developer - $6</b></p>"
43
+ #node mailSender.js <from> <pass> <to> <subject> <text>
44
+ BASEDIR=$(dirname "$0")
45
+ node $BASEDIR"/../utils/mailSender" $4 $5 $6 "$subject" "$msg" $7 $8 "$reportUrl"
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.endTag = exports.htmlTemplate = void 0;
6
+ exports.htmlTemplate = exports.endTag = void 0;
7
7
  const htmlTemplate = '<!DOCTYPE html><html> <head> <title>Eslint Security Rule</title> <style type="text/css"> body{margin: 0; font: 93.75%/1.6 -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica, Arial, sans-serif;}body, html{width: 100%; height: 100%;}.pkCont{}.pkEmpty{height: 300px;display: flex;align-items: center;justify-content: center;font-size: 20px;}.pkUl{margin: 0; padding: 0; list-style-type: none;}.pkLi{}.pkRow{display: flex; padding: 12px 16px;}.pkArrowCont{cursor: pointer; width: 50px; display: flex; align-items: center; justify-content: center; background-color: #f4f5f5; border-radius: 4px;}.pkArrow{width: 1px; height: 1px; border: 5px solid; border-color: #000 transparent transparent; margin-top: 7px;}.pkDetailsOpen .pkArrow{margin: 0 0 7px; border-color: transparent transparent #000;}.pkFileName{font-weight: 600; margin: 0 8px;}.pkUrl{flex: 1; min-width: 0; min-height: 0; word-break: break-word; word-wrap: break-word; color: blue;}.pkDetails{margin-left: 66px; display: none;}.pkDetailsOpen .pkDetails{display: block;}.pkDetailsHead{font-weight: 600; display: flex; border: 1px solid #e5e5e5; padding: 3px 8px;}.pkDetailsBody{max-height: 400px; overflow: auto;}.pkDetailsRow{display: flex; padding: 10px 8px;}.pkDetailsRow:nth-child(even){background-color: #f4f5f5;}.pkDetailsCol{word-break: break-word; word-wrap: break-word;}.pkError{color: red;}.pkDetailsCol:nth-child(1){width: 10%;}.pkDetailsCol:nth-child(2){width: 10%;}.pkDetailsCol:nth-child(3){width: 40%;}.pkDetailsCol:nth-child(4){width: 40%;}</style> <script>function toggleWrapper(element){var classArray=element.parentElement.parentElement.className; if (classArray.includes("pkDetailsOpen")){element.parentElement.parentElement.className="pkLi";}else{element.parentElement.parentElement.className="pkLi pkDetailsOpen";}}</script> </head> <body> <div class="pkCont">';
8
8
  exports.htmlTemplate = htmlTemplate;
9
9
  const endTag = '</div></body></html>';