@zohodesk/react-cli 0.0.1-beta.177 → 0.0.1-beta.179

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. package/.eslintignore +7 -7
  2. package/.eslintrc.js +180 -180
  3. package/.prettierrc +6 -6
  4. package/Changelog.md +1019 -0
  5. package/README.md +1153 -1100
  6. package/bin/cli.js +482 -482
  7. package/docs/CustomChunks.md +26 -26
  8. package/docs/DevServerPort.md +39 -0
  9. package/docs/DevStart.md +18 -18
  10. package/docs/HoverActive.md +12 -12
  11. package/docs/InstallNode.md +28 -28
  12. package/docs/SelectorWeight.md +6 -6
  13. package/docs/TODOS.md +10 -10
  14. package/docs/ValueReplacer.md +60 -60
  15. package/docs/VariableConversion.md +724 -724
  16. package/docs/warnings_while_install.txt +35 -35
  17. package/files/eslintrc.js +62 -62
  18. package/files/prettierrc.js +3 -3
  19. package/lib/configs/resolvers.js +40 -0
  20. package/lib/configs/webpack.css.umd.config.js +4 -4
  21. package/lib/configs/webpack.dev.config.js +4 -11
  22. package/lib/configs/webpack.docs.config.js +4 -11
  23. package/lib/configs/webpack.impact.config.js +5 -7
  24. package/lib/configs/webpack.prod.config.js +8 -12
  25. package/lib/constants.js +31 -0
  26. package/lib/loaderUtils/configsAssetsLoaders.js +35 -35
  27. package/lib/loaders/workerLoader.js +9 -9
  28. package/lib/pluginUtils/getDevPlugins.js +5 -5
  29. package/lib/pluginUtils/getProdPlugins.js +5 -5
  30. package/lib/plugins/EFCPlugin.md +6 -6
  31. package/lib/plugins/I18NInjectIntoIndexPlugin.js +4 -4
  32. package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +38 -38
  33. package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +30 -30
  34. package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +8 -8
  35. package/lib/plugins/I18nSplitPlugin/I18nSplit.md +95 -95
  36. package/lib/plugins/I18nSplitPlugin/README.md +25 -25
  37. package/lib/plugins/I18nSplitPlugin/index.js +57 -57
  38. package/lib/plugins/ResourceHintsPlugin.js +17 -17
  39. package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +6 -6
  40. package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -30
  41. package/lib/plugins/ServiceWorkerPlugin.js +9 -9
  42. package/lib/plugins/TPHashMappingPlugin.js +4 -4
  43. package/lib/plugins/VariableConversionCollector.js +54 -54
  44. package/lib/postcss-plugins/RTLSplitPlugin.js +10 -10
  45. package/lib/postcss-plugins/__test__/test1Input.css +38 -38
  46. package/lib/postcss-plugins/__test__/test1Output.css +38 -38
  47. package/lib/postcss-plugins/hoverActivePlugin.js +3 -3
  48. package/lib/schemas/index.js +8 -0
  49. package/lib/servers/docsServerCore.js +13 -12
  50. package/lib/servers/httpsOptions.js +40 -9
  51. package/lib/servers/nowatchserver.js +12 -11
  52. package/lib/servers/server.js +23 -20
  53. package/lib/sh/pre-commit.sh +34 -34
  54. package/lib/sh/reportPublish.sh +45 -45
  55. package/lib/utils/buildstats.html +148 -148
  56. package/lib/utils/getFileType.js +2 -2
  57. package/lib/utils/getOptions.js +13 -13
  58. package/lib/utils/getServerURL.js +12 -3
  59. package/lib/utils/resultSchema.json +73 -73
  60. package/npm8.md +9 -9
  61. package/package.json +121 -147
  62. package/postpublish.js +8 -6
  63. package/templates/app/.eslintrc.js +140 -140
  64. package/templates/app/README.md +12 -12
  65. package/templates/app/app/index.html +24 -24
  66. package/templates/app/app/properties/ApplicationResources_en_US.properties +1 -1
  67. package/templates/app/app/properties/i18nkeys.json +3 -3
  68. package/templates/app/docs/all.html +69 -69
  69. package/templates/app/mockapi/index.js +18 -18
  70. package/templates/app/package.json +37 -37
  71. package/templates/app/src/actions/SampleActions/index.js +37 -37
  72. package/templates/app/src/actions/index.js +65 -65
  73. package/templates/app/src/appUrls.js +19 -19
  74. package/templates/app/src/components/Alert/Alert.js +134 -134
  75. package/templates/app/src/components/Alert/Alert.module.css +79 -79
  76. package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -37
  77. package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -84
  78. package/templates/app/src/components/Sample/Sample.module.css +11 -11
  79. package/templates/app/src/components/Sample/SampleList.js +61 -61
  80. package/templates/app/src/components/Slider/Slider.css +41 -41
  81. package/templates/app/src/components/Slider/Slider.js +55 -55
  82. package/templates/app/src/containers/AlertContainer/index.js +15 -15
  83. package/templates/app/src/containers/AppContainer/index.js +96 -96
  84. package/templates/app/src/containers/AppContainer/index.module.css +27 -27
  85. package/templates/app/src/containers/CustomMatch/index.js +65 -65
  86. package/templates/app/src/containers/DevTools/index.js +10 -10
  87. package/templates/app/src/containers/Header/index.js +67 -67
  88. package/templates/app/src/containers/Header/index.module.css +43 -43
  89. package/templates/app/src/containers/Redirect/index.js +63 -63
  90. package/templates/app/src/containers/Redirector/index.js +47 -47
  91. package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -42
  92. package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -3
  93. package/templates/app/src/historyChange.js +5 -5
  94. package/templates/app/src/index.html +10 -10
  95. package/templates/app/src/index.js +24 -24
  96. package/templates/app/src/middleware/PromiseMiddleware.js +59 -59
  97. package/templates/app/src/reducers/alertData.js +11 -11
  98. package/templates/app/src/reducers/index.js +6 -6
  99. package/templates/app/src/reducers/samples.js +19 -19
  100. package/templates/app/src/store/configureStore.dev.js +51 -51
  101. package/templates/app/src/store/configureStore.js +5 -5
  102. package/templates/app/src/store/configureStore.prod.js +26 -26
  103. package/templates/app/src/util/Common.js +5 -5
  104. package/templates/app/src/util/RequestAPI.js +132 -132
  105. package/templates/docs/all.html +249 -249
  106. package/templates/docs/component.html +178 -178
  107. package/templates/docs/components.html +221 -221
  108. package/templates/docs/css/b.min.css +6 -6
  109. package/templates/docs/css/component.css +42 -42
  110. package/templates/docs/css/componentTest.css +6 -6
  111. package/templates/docs/css/hopscotch.css +585 -585
  112. package/templates/docs/css/style.css +1022 -1022
  113. package/templates/docs/impactReportTemplate.html +154 -154
  114. package/templates/docs/index.html +1501 -1501
  115. package/templates/docs/js/active-line.js +72 -72
  116. package/templates/docs/js/b.min.js +7 -7
  117. package/templates/docs/js/codemirror.js +9680 -9680
  118. package/templates/docs/js/designTokens.js +334 -334
  119. package/templates/docs/js/j.min.js +4 -4
  120. package/templates/docs/js/javascript.js +874 -874
  121. package/templates/docs/js/matchbrackets.js +145 -145
  122. package/cert/Tsicsezwild-22-23.crt +0 -37
  123. package/cert/Tsicsezwild-22-23.key +0 -27
  124. /package/{CHANGELOG.md → CHANGELOG-fz.md} +0 -0
@@ -24,12 +24,12 @@ const isCss = filename => _path.default.extname(filename) === '.css'; // this p
24
24
 
25
25
  class RtlCssPlugin {
26
26
  constructor(options = {}) {
27
- /**
28
- * @typedef {Object} Options
29
- * @property {String} filename [not used]
30
- * @property {String} dirVarName
31
- * @property {Boolean} sourcemap
32
- * @property {Object} config
27
+ /**
28
+ * @typedef {Object} Options
29
+ * @property {String} filename [not used]
30
+ * @property {String} dirVarName
31
+ * @property {Boolean} sourcemap
32
+ * @property {Object} config
33
33
  */
34
34
  this.options = {
35
35
  filename: options.filename || '[name].rtl.css',
@@ -1,30 +1,30 @@
1
- # RTL Split
2
-
3
- we are doing in build time generating rtl related css code by using @zohodesk/postcss-rt npm.
4
- It was automated, That postcss plugin create rtl reacted css and put them into same file, with css selector [dir=rtl] and ltr realted css with [dir=ltr].
5
- Here is problem mostly no one need rtl and ltr related css at the same time in browser,
6
- we are try to split them by [dir] and load which type of css is needed.
7
- For this purpose we created RTL Split Plugin
8
-
9
-
10
- # To Try it out rtl-ltr split
11
- ### how to use this feature?
12
-
13
- to use this feature use have give the below oprtions
14
- `package.json`
15
- ```json
16
- {
17
- /// ...some things
18
- "react-cli": {
19
- // ...some things
20
- "css": {
21
- "enableRTLSplit": true,
22
- "templateLabel": "{{--dir}}",// this is for html template css file path dir template
23
- "disableMiniFiySelector": false,
24
- "dirVarName": "document.dir" // this will be used for download css based on dir
25
- },
26
- // ...some things
27
- }
28
- }
29
- ```
30
-
1
+ # RTL Split
2
+
3
+ we are doing in build time generating rtl related css code by using @zohodesk/postcss-rt npm.
4
+ It was automated, That postcss plugin create rtl reacted css and put them into same file, with css selector [dir=rtl] and ltr realted css with [dir=ltr].
5
+ Here is problem mostly no one need rtl and ltr related css at the same time in browser,
6
+ we are try to split them by [dir] and load which type of css is needed.
7
+ For this purpose we created RTL Split Plugin
8
+
9
+
10
+ # To Try it out rtl-ltr split
11
+ ### how to use this feature?
12
+
13
+ to use this feature use have give the below oprtions
14
+ `package.json`
15
+ ```json
16
+ {
17
+ /// ...some things
18
+ "react-cli": {
19
+ // ...some things
20
+ "css": {
21
+ "enableRTLSplit": true,
22
+ "templateLabel": "{{--dir}}",// this is for html template css file path dir template
23
+ "disableMiniFiySelector": false,
24
+ "dirVarName": "document.dir" // this will be used for download css based on dir
25
+ },
26
+ // ...some things
27
+ }
28
+ }
29
+ ```
30
+
@@ -51,11 +51,11 @@ class ServiceWorkerPlugin {
51
51
  if (err) {
52
52
  throw new Error(err);
53
53
  } else {
54
- /* const extractedChunks = compilation.chunks.filter(chunk => {
55
- if ('canBeInitial' in chunk) {
56
- return chunk.canBeInitial();
57
- }
58
- return chunk.isInitial();
54
+ /* const extractedChunks = compilation.chunks.filter(chunk => {
55
+ if ('canBeInitial' in chunk) {
56
+ return chunk.canBeInitial();
57
+ }
58
+ return chunk.isInitial();
59
59
  }); */
60
60
  // let [js, css, , , i18nPublicPath] = this.publicPaths;
61
61
  // let initialChunkUrls = [];
@@ -64,10 +64,10 @@ class ServiceWorkerPlugin {
64
64
  let entrypoint = compilation.entrypoints.get('main');
65
65
  let initialChunkUrls = entrypoint.getFiles();
66
66
  const cssDirTemplate = '@dir@';
67
- /**
68
- * NOTE:
69
- * if chunkSplitEnable is false means,
70
- * serviceWorker will get i18n files path for html
67
+ /**
68
+ * NOTE:
69
+ * if chunkSplitEnable is false means,
70
+ * serviceWorker will get i18n files path for html
71
71
  */
72
72
 
73
73
  let initalI18nAssets = chunkSplitEnable ? entrypoint.chunks.filter(chunk => _I18nKeysIdentifer.default.isChunkHasI18n(chunk)).map(chunk => (0, _getI18nFileUrlPathTemplate.getI18nFileUrlPathTemplate)(compilation, chunk, this.i18nFileNameTemplate, '@locale@')) : [];
@@ -15,10 +15,10 @@ var _crypto = _interopRequireDefault(require("crypto"));
15
15
 
16
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
17
 
18
- /**
19
- * Plugin that generates hash for the provided list of third party files
20
- * Map the provided key with the file hash and add it to the list of exisiting global constants.
21
- * Plugin in turn uses the defineplugin to generate global constants.
18
+ /**
19
+ * Plugin that generates hash for the provided list of third party files
20
+ * Map the provided key with the file hash and add it to the list of exisiting global constants.
21
+ * Plugin in turn uses the defineplugin to generate global constants.
22
22
  */
23
23
  class TPHashMappingPlugin {
24
24
  constructor(options) {
@@ -26,15 +26,15 @@ const {
26
26
  const supportedProps = ['font-size', 'margin', 'margin-top', 'margin-bottom', 'margin-left', 'margin-right', 'padding', 'padding-top', 'padding-bottom', 'padding-left', 'padding-right', '^top', '^right', '^bottom', '^left', '^width', 'min-width', 'max-width', '^height', 'min-height', 'max-height', 'text-indent', 'clip', 'flex-basis', 'row-gap', 'gap', 'column-gap', 'flex']; // const avoidProps = [];
27
27
  // -- is issue IO --
28
28
 
29
- /*
30
- issues eg :
31
- issues = ['--zd_size', '--zd_font_size', '--size', '--size_'];
32
- input :
33
- --zd_size
34
- output :
35
- true
36
- comment :
37
- do not execute when --zd_size comes as prop
29
+ /*
30
+ issues eg :
31
+ issues = ['--zd_size', '--zd_font_size', '--size', '--size_'];
32
+ input :
33
+ --zd_size
34
+ output :
35
+ true
36
+ comment :
37
+ do not execute when --zd_size comes as prop
38
38
  */
39
39
 
40
40
  function isIgnoreValuePresent(ignoreVals, prop) {
@@ -47,14 +47,14 @@ function isIgnoreValuePresent(ignoreVals, prop) {
47
47
  return present;
48
48
  } // -- to convert the hyphen values to values --
49
49
 
50
- /*
51
- input :
52
- var(--zdt_uploadlist_default_width)
53
- output :
54
- --zdt_uploadlist_default_width
55
-
56
- comment :
57
- to make the variable object using the output as key and decl.prop such as font-size as value
50
+ /*
51
+ input :
52
+ var(--zdt_uploadlist_default_width)
53
+ output :
54
+ --zdt_uploadlist_default_width
55
+
56
+ comment :
57
+ to make the variable object using the output as key and decl.prop such as font-size as value
58
58
  */
59
59
 
60
60
 
@@ -154,13 +154,13 @@ class VariableConversionCollector {
154
154
  }
155
155
  };
156
156
  }
157
- /*
158
- purpose of tap : to create a variable object such as:
159
- {
160
- --zdt_uploadlist_default_width : width,
161
- --zdt_uploadlist_default_height : height,
162
- }
163
- which will help in the conversion further
157
+ /*
158
+ purpose of tap : to create a variable object such as:
159
+ {
160
+ --zdt_uploadlist_default_width : width,
161
+ --zdt_uploadlist_default_height : height,
162
+ }
163
+ which will help in the conversion further
164
164
  */
165
165
 
166
166
 
@@ -216,19 +216,19 @@ class VariableConversionCollector {
216
216
  });
217
217
  });
218
218
  });
219
- /*
220
- current value example:
221
- {
222
- --zdt_uploadlist_default_width : --zd_upload_width,
223
- --zd_upload_width : width
224
- }
225
- expected value :
226
- {
227
- --zdt_uploadlist_default_width : width,
228
- --zd_upload_width : width
229
- }
230
-
231
- conversion is done in the while loop below
219
+ /*
220
+ current value example:
221
+ {
222
+ --zdt_uploadlist_default_width : --zd_upload_width,
223
+ --zd_upload_width : width
224
+ }
225
+ expected value :
226
+ {
227
+ --zdt_uploadlist_default_width : width,
228
+ --zd_upload_width : width
229
+ }
230
+
231
+ conversion is done in the while loop below
232
232
  */
233
233
 
234
234
  Object.keys(variables).forEach(key => {
@@ -240,17 +240,17 @@ class VariableConversionCollector {
240
240
  });
241
241
  }); // -- conversion for the root using rootConvertor --
242
242
 
243
- /*
244
- input :
245
- .a{
246
- padding : 20px
247
- }
248
- output :
249
- // on settingObject file :
250
- { padding : { replacements : { px : 'zd_size$$' }}}
251
- .a{
252
- padding : zd_size20;
253
- }
243
+ /*
244
+ input :
245
+ .a{
246
+ padding : 20px
247
+ }
248
+ output :
249
+ // on settingObject file :
250
+ { padding : { replacements : { px : 'zd_size$$' }}}
251
+ .a{
252
+ padding : zd_size20;
253
+ }
254
254
  */
255
255
 
256
256
  compilation.hooks.optimizeModules.tap('VariableConversionCollector', modules => {
@@ -262,12 +262,12 @@ class VariableConversionCollector {
262
262
  });
263
263
  });
264
264
  });
265
- /*
266
- purpose of tap : to display the errors encountered so far
267
- input :
268
- all css files
269
- output :
270
- all errors that are present in the errTable arr
265
+ /*
266
+ purpose of tap : to display the errors encountered so far
267
+ input :
268
+ all css files
269
+ output :
270
+ all errors that are present in the errTable arr
271
271
  */
272
272
 
273
273
  compiler.hooks.afterEmit.tap('error-display', () => {
@@ -38,11 +38,11 @@ function selectorMinifySameDir(selector, direction) {
38
38
  const regex = getRegex(direction);
39
39
  return selector.replace(regex, '').trim();
40
40
  }
41
- /**
42
- * this funtion will remove given rule,
43
- * if given selector and it's previous sibiling rule selector are same
44
- * current rule properties will move to previous sibiling rule.
45
- * @param {Rule} rule current rule
41
+ /**
42
+ * this funtion will remove given rule,
43
+ * if given selector and it's previous sibiling rule selector are same
44
+ * current rule properties will move to previous sibiling rule.
45
+ * @param {Rule} rule current rule
46
46
  */
47
47
 
48
48
 
@@ -57,11 +57,11 @@ function mergeIfSameSelector(rule) {
57
57
  rule.remove();
58
58
  }
59
59
  }
60
- /**
61
- * this funtion will remove given rule,
62
- * if given selector and it's previous sibiling rule selector are same
63
- * current rule properties will move to previous sibiling rule.
64
- * @param {Rule} rule current rule
60
+ /**
61
+ * this funtion will remove given rule,
62
+ * if given selector and it's previous sibiling rule selector are same
63
+ * current rule properties will move to previous sibiling rule.
64
+ * @param {Rule} rule current rule
65
65
  */
66
66
 
67
67
 
@@ -1,39 +1,39 @@
1
- /*Hover_active:ignore*/
2
- g,a:hover{
3
- color : red
4
- }
5
- /*Hover:ignore*/
6
- h:hover{
7
- background : yellow
8
- }
9
-
10
- /* Hover_active:ignore */
11
- g,d+e:hover{
12
- color : black
13
- }
14
-
15
- g,d e:hover{
16
- color : black
17
- }
18
-
19
- @media screen and (max-width:61.25em){
20
- /* Hover_active:ignore */
21
- a,b,a:hover, b:hover{
22
- background-color : blue
23
- }
24
- a + b,a:hover + b:hover{
25
- background-color : blue
26
- }
27
- a b:hover{
28
- background-color : blue
29
- }
30
-
31
- .cc:hover {
32
- color: red;
33
- }
34
-
35
- c:hover{
36
- color : red
37
- }
38
-
1
+ /*Hover_active:ignore*/
2
+ g,a:hover{
3
+ color : red
4
+ }
5
+ /*Hover:ignore*/
6
+ h:hover{
7
+ background : yellow
8
+ }
9
+
10
+ /* Hover_active:ignore */
11
+ g,d+e:hover{
12
+ color : black
13
+ }
14
+
15
+ g,d e:hover{
16
+ color : black
17
+ }
18
+
19
+ @media screen and (max-width:61.25em){
20
+ /* Hover_active:ignore */
21
+ a,b,a:hover, b:hover{
22
+ background-color : blue
23
+ }
24
+ a + b,a:hover + b:hover{
25
+ background-color : blue
26
+ }
27
+ a b:hover{
28
+ background-color : blue
29
+ }
30
+
31
+ .cc:hover {
32
+ color: red;
33
+ }
34
+
35
+ c:hover{
36
+ color : red
37
+ }
38
+
39
39
  }
@@ -1,39 +1,39 @@
1
- /*Hover_active:ignore*/
2
- g,a:hover{
3
- color : red
4
- }
5
- /*Hover:ignore*/
6
- h:hover{
7
- background : yellow
8
- }
9
-
10
- /* Hover_active:ignore */
11
- g,d+e:hover{
12
- color : black
13
- }
14
-
15
- g,d e:hover{
16
- color : black
17
- }
18
-
19
- @media screen and (max-width:61.25em){
20
- /* Hover_active:ignore */
21
- a,b,a:hover, b:hover{
22
- background-color : blue
23
- }
24
- a + b,a:hover + b:hover{
25
- background-color : blue
26
- }
27
- a b:hover{
28
- background-color : blue
29
- }
30
-
31
- .cc:hover {
32
- color: red;
33
- }
34
-
35
- c:hover{
36
- color : red
37
- }
38
-
1
+ /*Hover_active:ignore*/
2
+ g,a:hover{
3
+ color : red
4
+ }
5
+ /*Hover:ignore*/
6
+ h:hover{
7
+ background : yellow
8
+ }
9
+
10
+ /* Hover_active:ignore */
11
+ g,d+e:hover{
12
+ color : black
13
+ }
14
+
15
+ g,d e:hover{
16
+ color : black
17
+ }
18
+
19
+ @media screen and (max-width:61.25em){
20
+ /* Hover_active:ignore */
21
+ a,b,a:hover, b:hover{
22
+ background-color : blue
23
+ }
24
+ a + b,a:hover + b:hover{
25
+ background-color : blue
26
+ }
27
+ a b:hover{
28
+ background-color : blue
29
+ }
30
+
31
+ .cc:hover {
32
+ color: red;
33
+ }
34
+
35
+ c:hover{
36
+ color : red
37
+ }
38
+
39
39
  }
@@ -4,9 +4,9 @@ var _postcss = _interopRequireDefault(require("postcss"));
4
4
 
5
5
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
6
6
 
7
- /**
8
- * we have give support for ignore(exclude) comments
9
- * These are the comments' keyword
7
+ /**
8
+ * we have give support for ignore(exclude) comments
9
+ * These are the comments' keyword
10
10
  */
11
11
  const hoverIgnoreQuery = 'Hover:ignore',
12
12
  activeIgnoreQuery = 'Active:ignore',
@@ -91,6 +91,10 @@ var _default = {
91
91
  cssDirStatement: null
92
92
  },
93
93
  app: {
94
+ moduleResolvePath: {
95
+ value: '',
96
+ cli: 'module_resolve_path'
97
+ },
94
98
  // this option only for impact testing
95
99
  devCssFileBountry: {
96
100
  value: '',
@@ -137,6 +141,10 @@ var _default = {
137
141
  value: 'dev',
138
142
  cli: 'app_mode'
139
143
  },
144
+ httpsCerts: {
145
+ value: null,
146
+ cli: 'https_certs'
147
+ },
140
148
  branch: {
141
149
  value: 'master',
142
150
  cli: 'app_branch'
@@ -29,28 +29,29 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
29
29
 
30
30
  // import fs from 'fs';
31
31
  var _default = isSSTest => {
32
- let options = (0, _utils.getOptions)();
33
- let {
32
+ const options = (0, _utils.getOptions)();
33
+ const httpsOptions = (0, _httpsOptions.httpsOptionsWithUserFriendlyError)(options);
34
+ const {
34
35
  docs: {
35
36
  server
36
37
  }
37
38
  } = options;
38
- let {
39
+ const {
39
40
  port,
40
41
  branch,
41
42
  host,
42
43
  domain,
43
44
  iphost
44
45
  } = server;
45
- let appPath = process.cwd();
46
+ const appPath = process.cwd();
46
47
  const app = (0, _express.default)();
47
48
  app.use(_express.default.json());
48
49
  app.use(_express.default.urlencoded({
49
50
  extended: true
50
51
  }));
51
- let docsConfig = (0, _webpackDocs.default)(isSSTest);
52
- let compiler = (0, _webpack.default)(docsConfig);
53
- let wdm = (0, _webpackDevMiddleware.default)(compiler, {
52
+ const docsConfig = (0, _webpackDocs.default)(isSSTest);
53
+ const compiler = (0, _webpack.default)(docsConfig);
54
+ const wdm = (0, _webpackDevMiddleware.default)(compiler, {
54
55
  logLevel: 'error',
55
56
  publicPath: docsConfig.output.publicPath,
56
57
  headers: {
@@ -67,7 +68,7 @@ var _default = isSSTest => {
67
68
  res.sendFile(_path.default.join(__dirname, '..', '..', 'templates', 'docs', 'index.html'));
68
69
  });
69
70
  app.use('/author/get', (req, res) => {
70
- let {
71
+ const {
71
72
  query: {
72
73
  componentName = ''
73
74
  }
@@ -84,7 +85,7 @@ var _default = isSSTest => {
84
85
 
85
86
  if (branch) {
86
87
  app.post('/repo/merge', (req, res) => {
87
- let {
88
+ const {
88
89
  ref
89
90
  } = req.body;
90
91
 
@@ -98,7 +99,7 @@ var _default = isSSTest => {
98
99
  });
99
100
  }
100
101
 
101
- const httpsServer = _https.default.createServer(_httpsOptions.httpsOptions, app);
102
+ const httpsServer = _https.default.createServer(httpsOptions, app);
102
103
 
103
104
  if (!isSSTest) {
104
105
  httpsServer.listen(port, err => {
@@ -110,8 +111,8 @@ var _default = isSSTest => {
110
111
  });
111
112
  }
112
113
 
113
- let httpPort = Number(port) + 1;
114
- let http = app.listen(httpPort, err => {
114
+ const httpPort = Number(port) + 1;
115
+ const http = app.listen(httpPort, err => {
115
116
  if (err) {
116
117
  throw err;
117
118
  }
@@ -3,16 +3,47 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.httpsOptions = void 0;
6
+ exports.httpsOptions = httpsOptions;
7
+ exports.httpsOptionsWithUserFriendlyError = httpsOptionsWithUserFriendlyError;
7
8
 
8
- var _fs = _interopRequireDefault(require("fs"));
9
+ // import fs from 'fs';
10
+ // import path from 'path';
11
+ // export const httpsOptions = {
12
+ // key: fs.readFileSync(path.join(__dirname, './cert/Tsicsezwild-22-23.key')),
13
+ // cert: fs.readFileSync(path.join(__dirname, './cert/Tsicsezwild-22-23.crt'))
14
+ // };
15
+ function httpsOptions(options) {
16
+ const {
17
+ httpsCerts
18
+ } = options.app.server;
9
19
 
10
- var _path = _interopRequireDefault(require("path"));
20
+ const certificate = require(require.resolve(httpsCerts, {
21
+ paths: [process.cwd()]
22
+ })); // TODO: in future we may do some version based check. certificate.version
11
23
 
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
24
 
14
- const httpsOptions = {
15
- key: _fs.default.readFileSync(_path.default.join(__dirname, '../../cert/Tsicsezwild-22-23.key')),
16
- cert: _fs.default.readFileSync(_path.default.join(__dirname, '../../cert/Tsicsezwild-22-23.crt'))
17
- };
18
- exports.httpsOptions = httpsOptions;
25
+ return certificate.httpsOptions;
26
+ }
27
+
28
+ function httpsOptionsWithUserFriendlyError(options) {
29
+ const {
30
+ httpsCerts
31
+ } = options.app.server;
32
+
33
+ if (typeof httpsCerts === 'string' && httpsCerts) {
34
+ try {
35
+ const certificate = httpsOptions(options);
36
+ return certificate;
37
+ } catch (error) {
38
+ if (error.message.indexOf('Cannot find module') !== -1) {
39
+ console.error(`You have given react-cli.app.server.httpsCerts as "${httpsCerts}". \n But it seems that file path have some problem.\n we are unable to locate "${httpsCerts}" in "${process.cwd()}"`);
40
+ } else {
41
+ console.error(error);
42
+ }
43
+
44
+ process.exit(0);
45
+ }
46
+ } else {
47
+ return null;
48
+ }
49
+ }