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

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 (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
@@ -13,7 +13,29 @@ var _getCurrentBranch = _interopRequireDefault(require("../utils/getCurrentBranc
13
13
 
14
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
15
 
16
+ // TODO move deprecated options to separate file and manage seperately
16
17
  var _default = {
18
+ cliRootPath: null,
19
+ unstableDepsInverse: {
20
+ value: false,
21
+ cli: 'unstable_deps_inverse'
22
+ },
23
+ sslCertURL: {
24
+ value: null,
25
+ cli: 'ssl_cert_url'
26
+ },
27
+ preprocess: {
28
+ // This option is for tell the react-cli which in preprocessor js file path
29
+ runner: {
30
+ value: '',
31
+ cli: 'preprocessor'
32
+ },
33
+ // usally preprocessor run in nodemon for, start and docs , preprocessor
34
+ stopNodemon: {
35
+ value: false,
36
+ cli: 'stop_nodemon'
37
+ }
38
+ },
17
39
  i18n: {
18
40
  chunkSplitEnable: {
19
41
  value: false,
@@ -28,19 +50,76 @@ var _default = {
28
50
  },
29
51
  css: {
30
52
  enableRTLSplit: false,
53
+ valueReplacer: null,
54
+ //valueReplacer: [
55
+ // {
56
+ // props: ['font', 'font-family'],
57
+ // values: {
58
+ // 'zdfonts-rCallBar': 'zdfonts-rCallBar01',
59
+ // 'zdfonts-rCall': 'zdfonts-rCallBar02'
60
+ // }
61
+ // // ,suffix: '0'
62
+ // }
63
+ // ],
31
64
  templateLabel: '{{--dir}}',
32
65
  disableMiniFiySelector: false,
33
66
  dirVarName: 'document.dir'
34
67
  },
35
68
  efc: {
36
- hasEFC: false,
69
+ hasEFC: {
70
+ value: false,
71
+ cli: 'enable_efc'
72
+ },
37
73
  createSDkFile: false,
38
74
  nameScope: 'ZOHODESK',
39
- version: 'default',
40
- outputFile: 'zohodesk-efc-sdk-[version].js',
41
- localeAttr: 'data-efc-locale'
75
+ version: {
76
+ value: 'stable',
77
+ cli: 'efc_version'
78
+ },
79
+ outputFile: {
80
+ value: 'efc-sdk-[version].js',
81
+ cli: 'efc_output_file'
82
+ },
83
+ templateFilePath: '',
84
+ localeAttr: 'data-efc-locale',
85
+ localeDefaultValue: 'en_US',
86
+ localeStatement: null,
87
+ cssDirAttr: 'data-efc-dir',
88
+ cssDirDefaultValue: 'ltr',
89
+ cdnStatement: '',
90
+ // cdnStatement: "new URL(document.querySelector(\"script[src*='zohodesk-efc-sdk']\").src).origin",
91
+ cssDirStatement: null
42
92
  },
43
93
  app: {
94
+ mainEntryFile: {
95
+ value: 'index.js',
96
+ cli: 'entry_file'
97
+ },
98
+ mainEntryHtmlFile: {
99
+ value: 'index.html',
100
+ cli: 'entry_html_file'
101
+ },
102
+ moduleResolvePath: {
103
+ value: '',
104
+ cli: 'module_resolve_path'
105
+ },
106
+ // this option only for impact testing
107
+ devCssFileBountry: {
108
+ value: '',
109
+ cli: 'impact_cssbountry'
110
+ },
111
+ disableWatch: {
112
+ value: false,
113
+ cli: 'disable_watch'
114
+ },
115
+ enableDevCache: {
116
+ value: false,
117
+ cli: 'dev_cache'
118
+ },
119
+ crossorigin: {
120
+ value: false,
121
+ cli: 'enable_crossorigin'
122
+ },
44
123
  context: {
45
124
  value: 'app',
46
125
  cli: 'app_context'
@@ -48,6 +127,7 @@ var _default = {
48
127
  tpFolder: null,
49
128
  folder: 'src',
50
129
  vendorExclude: [],
130
+ vendorInclude: [],
51
131
  cssHashSelectors: {
52
132
  filenames: [],
53
133
  packages: []
@@ -69,6 +149,10 @@ var _default = {
69
149
  value: 'dev',
70
150
  cli: 'app_mode'
71
151
  },
152
+ httpsCerts: {
153
+ value: null,
154
+ cli: 'https_certs'
155
+ },
72
156
  branch: {
73
157
  value: 'master',
74
158
  cli: 'app_branch'
@@ -83,15 +167,26 @@ var _default = {
83
167
  },
84
168
  disableContextURL: false,
85
169
  hasMock: false,
170
+ mockPrefix: {
171
+ value: '/api',
172
+ cli: 'mock_prefix'
173
+ },
86
174
  mockPort: {
87
175
  value: 5000,
88
176
  cli: 'mock_port'
89
177
  }
90
178
  },
179
+ mediaQueryHoverActiveString: {
180
+ hover: 'all and (min--moz-device-pixel-ratio:0) and (hover: hover), (hover: hover)',
181
+ none: '(hover: none)'
182
+ },
91
183
  disableES5Transpile: false,
92
184
  isReactMig: false,
93
185
  hasWidget: false,
94
- hasEFC: false,
186
+ hasEFC: {
187
+ value: false,
188
+ cli: 'enable_efc'
189
+ },
95
190
  enableChunkHash: {
96
191
  value: false,
97
192
  cli: 'hash_enable'
@@ -119,6 +214,9 @@ var _default = {
119
214
  cli: 'attr_name'
120
215
  },
121
216
  publicPaths: false,
217
+ // TODO: Deprecated
218
+ hasRTL: false,
219
+ rtlExclude: [],
122
220
  instrumentScript: {
123
221
  value: false,
124
222
  cli: 'instru_script'
@@ -131,8 +229,26 @@ var _default = {
131
229
  value: true,
132
230
  cli: 'enable_smaphook'
133
231
  },
134
- hasRTL: false,
135
- rtlExclude: [],
232
+ plugins: {
233
+ hasRTL: false,
234
+ hoverActive: false,
235
+ combinerMediaQuery: false,
236
+ cssVariableReplacement: false,
237
+ selectorWeight: false
238
+ },
239
+ exclude: {
240
+ rtl: [],
241
+ hoverActive: [],
242
+ combinerMediaQuery: [],
243
+ cssVariableReplacement: [],
244
+ selectorWeight: []
245
+ },
246
+ cssVariableReplacementConfig: '',
247
+ selectorWeightConfig: {
248
+ defaultSelector: '',
249
+ customFileDetails: '',
250
+ excludeStrings: []
251
+ },
136
252
  seperateCssModules: {
137
253
  value: false,
138
254
  cli: 'sep_cssmodules'
@@ -160,6 +276,7 @@ var _default = {
160
276
  replaceText: '//<!--AssetsFromBuild -->'
161
277
  },
162
278
  htmlTemplate: {
279
+ minify: null,
163
280
  inject: true
164
281
  },
165
282
  removePropTypes: false,
@@ -174,6 +291,10 @@ var _default = {
174
291
  cssTemplate: '',
175
292
  jsTemplate: '',
176
293
  i18nTemplate: ''
294
+ },
295
+ sourcemap: {
296
+ cli: 'source_map',
297
+ value: 'cheap-eval-source-map'
177
298
  }
178
299
  },
179
300
  docs: {
@@ -190,14 +311,41 @@ var _default = {
190
311
  },
191
312
  branch: false
192
313
  },
314
+ mediaQueryHoverActiveString: {
315
+ hover: 'all and (min--moz-device-pixel-ratio:0) and (hover: hover), (hover: hover)',
316
+ none: '(hover: none)'
317
+ },
193
318
  componentFolder: 'src',
194
319
  cssUniqueness: {
195
320
  value: true,
196
321
  cli: 'css_unique'
197
322
  },
323
+ enableChunkHash: false,
198
324
  folder: 'src',
325
+ disableES5Transpile: false,
326
+ // TODO: Deprecated
199
327
  hasRTL: false,
200
328
  rtlExclude: [],
329
+ plugins: {
330
+ hasRTL: false,
331
+ hoverActive: false,
332
+ combinerMediaQuery: false,
333
+ cssVariableReplacement: false,
334
+ selectorWeight: false
335
+ },
336
+ exclude: {
337
+ rtl: [],
338
+ hoverActive: [],
339
+ combinerMediaQuery: [],
340
+ cssVariableReplacement: [],
341
+ selectorWeight: []
342
+ },
343
+ cssVariableReplacementConfig: '',
344
+ selectorWeightConfig: {
345
+ defaultSelector: '',
346
+ customFileDetails: '',
347
+ excludeStrings: []
348
+ },
201
349
  cssHashSelectors: {
202
350
  filenames: [],
203
351
  packages: []
@@ -208,6 +356,7 @@ var _default = {
208
356
  }
209
357
  },
210
358
  test: {
359
+ classnameFormat: '[classname]',
211
360
  srcBranch: {
212
361
  value: 'master',
213
362
  cli: 'src_branch'
@@ -225,7 +374,6 @@ var _default = {
225
374
  cli: 'branch_name'
226
375
  },
227
376
  impactServerDomain: {
228
- //value: 'ht' + 'tp://desk-qa-impact.tsi.zohocorpin.com:8080',
229
377
  value: 'ht' + 'tp://desk-automation.csez.zohocorpin.com:8080',
230
378
  cli: 'impact_server_domain'
231
379
  },
@@ -248,7 +396,6 @@ var _default = {
248
396
  cli: 'service_name'
249
397
  },
250
398
  impactServerDomain: {
251
- //value: 'ht' + 'tp://desk-qa-impact.tsi.zohocorpin.com:8080',
252
399
  value: 'ht' + 'tp://desk-automation.csez.zohocorpin.com:8080',
253
400
  cli: 'impact_server_domain'
254
401
  },
@@ -286,11 +433,23 @@ var _default = {
286
433
  cli: 'path_to_sub_projs'
287
434
  },
288
435
  tokenGit: {
289
- value: 'YbByNJ3yURAm92Lhx4vW',
436
+ value: '',
290
437
  cli: 'git_token'
438
+ },
439
+ changesOnly: {
440
+ value: false,
441
+ cli: 'changes_only'
291
442
  }
292
443
  },
293
444
  impactService: {
445
+ cssSelectorZipPath: {
446
+ value: '',
447
+ cli: 'cssselector_zip'
448
+ },
449
+ writeToDisk: {
450
+ value: false,
451
+ cli: 'write_disk'
452
+ },
294
453
  componentServiceName: {
295
454
  value: 'ZohoDeskLibrary',
296
455
  cli: 'impact_component_service'
@@ -455,7 +614,6 @@ var _default = {
455
614
  },
456
615
  impactServerDomain: {
457
616
  value: 'ht' + 'tp://desk-automation.csez.zohocorpin.com:8080',
458
- //value: 'ht' + 'tp://desk-qa-impact.tsi.zohocorpin.com:8080',
459
617
  cli: 'impact_server_domain'
460
618
  },
461
619
  impactRun: {
@@ -480,6 +638,10 @@ var _default = {
480
638
  value: null,
481
639
  cli: 'clone_revision'
482
640
  },
641
+ shallowClone: {
642
+ value: false,
643
+ cli: 'shallow_clone'
644
+ },
483
645
  projectName: {
484
646
  value: null,
485
647
  cli: 'clone_proj_name'
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getPaths = getPaths;
7
+
8
+ var _fs = _interopRequireDefault(require("fs"));
9
+
10
+ var _path = _interopRequireDefault(require("path"));
11
+
12
+ var _child_process = require("child_process");
13
+
14
+ var _utils = require("../utils");
15
+
16
+ var _getCliPath = require("./getCliPath");
17
+
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
+
20
+ const options = (0, _utils.getOptions)(); // const args = process.argv.slice(3);
21
+ // NOTE: need to discuss about in below codes,
22
+ // when we run webpack the usable options that comes for npm run not working as automatical
23
+ // we are use this option always --disable_watch=true reason for now no need for
24
+
25
+ const {
26
+ app: {
27
+ outputFolder
28
+ }
29
+ } = options;
30
+ const {
31
+ cssSelectorZipPath
32
+ } = options.impactService;
33
+ const zipname = cssSelectorZipPath ? _path.default.parse(cssSelectorZipPath).name : null;
34
+
35
+ const outputFolderLocation = _path.default.join(process.cwd(), outputFolder);
36
+
37
+ function execSyncDefalut(command) {
38
+ console.log(' command running ==>', command);
39
+ return (0, _child_process.execSync)(command, {
40
+ stdio: 'inherit'
41
+ });
42
+ }
43
+
44
+ const isQuiet = 'q';
45
+ const webpack = (0, _getCliPath.getCliPath)('webpack'); // console.log('webpack === > ', webpack, fs.existsSync(webpack));
46
+
47
+ if (_fs.default.existsSync(outputFolderLocation)) {
48
+ execSyncDefalut(`rm -rf ${outputFolder}`);
49
+ console.log(`previous ${outputFolder} removed`);
50
+ }
51
+
52
+ if (_fs.default.existsSync(_path.default.join(process.cwd(), 'build.zip'))) {
53
+ execSyncDefalut('rm build.zip');
54
+ console.log('previous build.zip removed');
55
+ } // execSyncDefalut(`${webpack } --version`);
56
+ // execSyncDefalut(`${webpack} --config ${require.resolve('../configs/webpack.dev.config.js')}`);
57
+
58
+
59
+ console.log('webpack compilation starts...');
60
+ const startTime = Date.now(); // const result = spawnSync(
61
+ // webpack,
62
+ // ['--config', require.resolve('../configs/webpack.dev.config.js')].concat(
63
+ // args
64
+ // ),
65
+ // { stdio: 'inherit' }
66
+ // );
67
+ // --disable_watch=true
68
+
69
+ const result = execSyncDefalut(`${webpack} --config ${require.resolve('../configs/webpack.dev.config.js')} ${process.argv.slice(2).map(o => o.replace(/(.*?)=(.*)/, '$1="$2"')).join(' ')} `);
70
+ result && console.log(result);
71
+
72
+ if (result && result.stderr) {
73
+ throw result.stderr;
74
+ }
75
+
76
+ console.log(`compailation done in ${Date.now() - startTime}ms`);
77
+
78
+ if (zipname) {
79
+ execSyncDefalut(`zip -r${isQuiet} build.zip ${outputFolder}/*`);
80
+ console.log('build.zip file created');
81
+ const result = execSyncDefalut(`zip -r${isQuiet} ${cssSelectorZipPath} ${zipname}/*`);
82
+ execSyncDefalut(`rm -rf ${zipname}`);
83
+
84
+ if (result && result.stderr) {
85
+ console.log('zip file not created', cssSelectorZipPath);
86
+ console.error(result.stderr);
87
+ } else {
88
+ console.log('zip file created', cssSelectorZipPath);
89
+ }
90
+ } // npm run start --app:domain=tsi --impact:cssbountry="{$@&&@$}" --disable-watch --dev-cache --cssselector_zip=css-source-map.zip
91
+ // npm run start --app_domain=tsi --impact_cssbountry="{$@&&@$}" --disable-watch --dev-cache --cssselector_zip=css-source-map.zip
92
+
93
+
94
+ console.log(`compailation done in ${Date.now() - startTime}ms`);
95
+
96
+ function getPaths() {
97
+ return {
98
+ zipname,
99
+ cssSelectorZipPath,
100
+ outputFolderLocation
101
+ };
102
+ }
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _fs = _interopRequireDefault(require("fs"));
9
-
10
8
  var _path = _interopRequireDefault(require("path"));
11
9
 
12
10
  var _https = _interopRequireDefault(require("https"));
@@ -25,31 +23,35 @@ var _utils = require("../utils");
25
23
 
26
24
  var _webpackDocs = _interopRequireDefault(require("../configs/webpack.docs.config"));
27
25
 
26
+ var _httpsOptions = require("./httpsOptions");
27
+
28
28
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
29
 
30
+ // import fs from 'fs';
30
31
  var _default = isSSTest => {
31
- let options = (0, _utils.getOptions)();
32
- let {
32
+ const options = (0, _utils.getOptions)();
33
+ const httpsOptions = (0, _httpsOptions.httpsOptionsWithUserFriendlyError)(options);
34
+ const {
33
35
  docs: {
34
36
  server
35
37
  }
36
38
  } = options;
37
- let {
39
+ const {
38
40
  port,
39
41
  branch,
40
42
  host,
41
43
  domain,
42
44
  iphost
43
45
  } = server;
44
- let appPath = process.cwd();
46
+ const appPath = process.cwd();
45
47
  const app = (0, _express.default)();
46
48
  app.use(_express.default.json());
47
49
  app.use(_express.default.urlencoded({
48
50
  extended: true
49
51
  }));
50
- let docsConfig = (0, _webpackDocs.default)(isSSTest);
51
- let compiler = (0, _webpack.default)(docsConfig);
52
- 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, {
53
55
  logLevel: 'error',
54
56
  publicPath: docsConfig.output.publicPath,
55
57
  headers: {
@@ -66,7 +68,7 @@ var _default = isSSTest => {
66
68
  res.sendFile(_path.default.join(__dirname, '..', '..', 'templates', 'docs', 'index.html'));
67
69
  });
68
70
  app.use('/author/get', (req, res) => {
69
- let {
71
+ const {
70
72
  query: {
71
73
  componentName = ''
72
74
  }
@@ -83,7 +85,7 @@ var _default = isSSTest => {
83
85
 
84
86
  if (branch) {
85
87
  app.post('/repo/merge', (req, res) => {
86
- let {
88
+ const {
87
89
  ref
88
90
  } = req.body;
89
91
 
@@ -97,11 +99,7 @@ var _default = isSSTest => {
97
99
  });
98
100
  }
99
101
 
100
- const httpsServer = _https.default.createServer({
101
- key: _fs.default.readFileSync(_path.default.join(__dirname, '../../cert/key.pem')),
102
- cert: _fs.default.readFileSync(_path.default.join(__dirname, '../../cert/cert.pem')),
103
- passphrase: '9i1pqink!k11'
104
- }, app);
102
+ const httpsServer = _https.default.createServer(httpsOptions, app);
105
103
 
106
104
  if (!isSSTest) {
107
105
  httpsServer.listen(port, err => {
@@ -113,8 +111,8 @@ var _default = isSSTest => {
113
111
  });
114
112
  }
115
113
 
116
- let httpPort = Number(port) + 1;
117
- let http = app.listen(httpPort, err => {
114
+ const httpPort = Number(port) + 1;
115
+ const http = app.listen(httpPort, err => {
118
116
  if (err) {
119
117
  throw err;
120
118
  }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getCliPath = getCliPath;
7
+
8
+ var _path = _interopRequireDefault(require("path"));
9
+
10
+ var _os = require("os");
11
+
12
+ var _fs = require("fs");
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+
16
+ const appPath = process.cwd();
17
+ const isNodeModuleUnderAppFolder = __dirname.indexOf(appPath) !== -1;
18
+ const isWindows = (0, _os.platform)().toLowerCase() === 'win32';
19
+
20
+ const _getCliPath = !isNodeModuleUnderAppFolder ? libName => _path.default.join(__dirname, '..', '..', 'node_modules', '.bin', libName) : libName => libName;
21
+
22
+ const suffixExt = isWindows ? '.cmd' : '';
23
+
24
+ function getCliPath(libName) {
25
+ const cliPath = _getCliPath(libName + suffixExt);
26
+
27
+ return (0, _fs.existsSync)(cliPath) ? cliPath : libName + suffixExt;
28
+ }
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.httpsOptions = httpsOptions;
7
+ exports.httpsOptionsWithUserFriendlyError = httpsOptionsWithUserFriendlyError;
8
+
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;
19
+
20
+ const certificate = require(require.resolve(httpsCerts, {
21
+ paths: [process.cwd()]
22
+ })); // TODO: in future we may do some version based check. certificate.version
23
+
24
+
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
+ }