@zohodesk/react-cli 1.1.11-exp.1 → 1.1.11-exp.3

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 (159) hide show
  1. package/README.md +13 -0
  2. package/lib/pluginUtils/getProdPlugins.js +11 -4
  3. package/lib/plugins/StatsPlugin.js +90 -20
  4. package/lib/schemas/index.js +4 -1
  5. package/npm-shrinkwrap.json +2 -2
  6. package/package.json +1 -1
  7. package/packages/client_build_tool/lib/allCommandsConfigs.js +23 -0
  8. package/packages/client_build_tool/lib/buildToolLoggers.js +32 -0
  9. package/packages/client_build_tool/lib/commands/build/commandExecutor.js +21 -0
  10. package/packages/client_build_tool/lib/commands/build/config.js +12 -0
  11. package/packages/client_build_tool/lib/commands/build/errorHander.js +10 -0
  12. package/packages/client_build_tool/lib/commands/build/index.js +35 -0
  13. package/packages/client_build_tool/lib/commands/build/optionsProcesser.js +40 -0
  14. package/packages/client_build_tool/lib/commands/buildEs/commandExecutor.js +17 -0
  15. package/packages/client_build_tool/lib/commands/buildEs/config.js +12 -0
  16. package/packages/client_build_tool/lib/commands/buildLib/commandExecutor.js +17 -0
  17. package/packages/client_build_tool/lib/commands/buildLib/config.js +12 -0
  18. package/packages/client_build_tool/lib/commands/start/commandExecutor.js +13 -0
  19. package/packages/client_build_tool/lib/commands/start/config.js +12 -0
  20. package/packages/client_build_tool/lib/commands/start/deprecationHandler.js +10 -0
  21. package/packages/client_build_tool/lib/commands/start/errorHander.js +10 -0
  22. package/packages/client_build_tool/lib/commands/start/optionsProcesser.js +36 -0
  23. package/packages/client_build_tool/lib/commands/start/postProcesser.js +10 -0
  24. package/packages/client_build_tool/lib/commands/start/preProcesser.js +10 -0
  25. package/packages/client_build_tool/lib/commandsRouter.js +71 -0
  26. package/packages/client_build_tool/lib/shared/bundler/webpack/common/decidePublicPath.js +44 -0
  27. package/packages/client_build_tool/lib/shared/bundler/webpack/common/libAlias.js +31 -0
  28. package/packages/client_build_tool/lib/shared/bundler/webpack/common/nameTemplates.js +51 -0
  29. package/packages/client_build_tool/lib/shared/bundler/webpack/common/resourceBasedPublicPath.js +21 -0
  30. package/packages/client_build_tool/lib/shared/bundler/webpack/cssLoaders.js +16 -0
  31. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/CdnChangePlugin.js +111 -0
  32. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/EFCPlugin.js +1 -0
  33. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/ContributionGuide.md +11 -0
  34. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nKeysIdentifer.js +136 -0
  35. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nSplit.md +95 -0
  36. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/README.md +25 -0
  37. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/constants.js +29 -0
  38. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/createHash.js +24 -0
  39. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/getI18nDependency.js +99 -0
  40. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/getI18nLoadingRuntimeModule.js +81 -0
  41. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/getI18nModule.js +201 -0
  42. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/index.js +401 -0
  43. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/optionsHandler.js +67 -0
  44. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/pathCreator.js +23 -0
  45. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/readI18nValues.js +29 -0
  46. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/templateFileName.js +49 -0
  47. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/templateHashHelpers.js +77 -0
  48. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/collectI18nKeys.js +63 -0
  49. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/hashUtils.js +19 -0
  50. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/index.js +31 -0
  51. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/propertiesUtils.js +127 -0
  52. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/RTLSplitPlugin.js +1 -0
  53. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +63 -0
  54. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/RtlCssPlugin.js +89 -0
  55. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/RtrSplit.md +34 -0
  56. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/replaceCssDirTemplate.js +15 -0
  57. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/ServiceWorkerPlugin.js +155 -0
  58. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/UglifyCSSPlugin.js +49 -0
  59. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_postcss_loaders/ExcludePlugin.js +58 -0
  60. package/packages/client_build_tool/lib/shared/bundler/webpack/custom_postcss_loaders/RTLSplitPlugin.js +139 -0
  61. package/packages/client_build_tool/lib/shared/bundler/webpack/devServerConfig.js +34 -0
  62. package/packages/client_build_tool/lib/shared/bundler/webpack/getCSSLoaders.js +30 -0
  63. package/packages/client_build_tool/lib/shared/bundler/webpack/jsLoaders.js +17 -0
  64. package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/assetLoaders.js +14 -0
  65. package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/babelLoaderConfig.js +24 -0
  66. package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/configHtmlTemplateLoader.js +18 -0
  67. package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/configWebWorkerLoader.js +21 -0
  68. package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/configsAssetsLoaders.js +138 -0
  69. package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/cssClassNameGenerate.js +83 -0
  70. package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/getCssLoaderOptions.js +23 -0
  71. package/packages/client_build_tool/lib/shared/bundler/webpack/loaders/workerLoader.js +133 -0
  72. package/packages/client_build_tool/lib/shared/bundler/webpack/optimizationConfig.js +39 -0
  73. package/packages/client_build_tool/lib/shared/bundler/webpack/outputConfig.js +28 -0
  74. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configCdnChangePlugin.js +18 -0
  75. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configCopyThirdpartyFile.js +38 -0
  76. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configEnvVariables.js +24 -0
  77. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configHtmlWebpackPlugin.js +28 -0
  78. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configI18nSplitPlugin.js +35 -0
  79. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configIgnorePlugin.js +16 -0
  80. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configMiniCSSExtractPlugin.js +23 -0
  81. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configProgressPlugin.js +19 -0
  82. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configRtlCssPlugin.js +27 -0
  83. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configServiceWorkerPlugin.js +18 -0
  84. package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configUglifyCSSPlugin.js +15 -0
  85. package/packages/client_build_tool/lib/shared/bundler/webpack/plugins.js +39 -0
  86. package/packages/client_build_tool/lib/shared/bundler/webpack/postcssPlugins.js +36 -0
  87. package/packages/client_build_tool/lib/shared/bundler/webpack/resolvers.js +42 -0
  88. package/packages/client_build_tool/lib/shared/bundler/webpack/splitChunksConfig.js +12 -0
  89. package/packages/client_build_tool/lib/shared/bundler/webpack/webpack.dev.config.js +17 -0
  90. package/packages/client_build_tool/lib/shared/bundler/webpack/webpackBuild.js +24 -0
  91. package/packages/client_build_tool/lib/shared/bundler/webpack/webpackConfig.js +50 -0
  92. package/packages/client_build_tool/lib/shared/commands-utlis/doBasicRequiermentCheck.js +16 -0
  93. package/packages/client_build_tool/lib/shared/commands-utlis/getCliPath.js +38 -0
  94. package/packages/client_build_tool/lib/shared/commands-utlis/index.js +29 -0
  95. package/packages/client_build_tool/lib/shared/commands-utlis/log.js +13 -0
  96. package/packages/client_build_tool/lib/shared/commands-utlis/readArgsFormCommandLine.js +11 -0
  97. package/packages/client_build_tool/lib/shared/commands-utlis/readOptionFormCommandLine.js +11 -0
  98. package/packages/client_build_tool/lib/shared/commands-utlis/spanSync.js +35 -0
  99. package/packages/client_build_tool/lib/shared/constants.js +33 -0
  100. package/packages/client_build_tool/lib/shared/schemas/applyValuesToShema.js +37 -0
  101. package/packages/client_build_tool/lib/shared/schemas/cliArgsToObject.js +37 -0
  102. package/packages/client_build_tool/lib/shared/schemas/defaultConfigValues.js +119 -0
  103. package/packages/client_build_tool/lib/shared/schemas/deprecatedOptionsHandler.js +65 -0
  104. package/packages/client_build_tool/lib/shared/schemas/getCWD.js +23 -0
  105. package/packages/client_build_tool/lib/shared/schemas/getNpmVersion.js +21 -0
  106. package/packages/client_build_tool/lib/shared/schemas/npmConfigToObject.js +32 -0
  107. package/packages/client_build_tool/lib/shared/schemas/oldDefaultConfigValues.js +480 -0
  108. package/packages/client_build_tool/lib/shared/schemas/readOptions.js +55 -0
  109. package/packages/client_build_tool/lib/shared/schemas/readOptionsForPackageJson.js +26 -0
  110. package/packages/client_build_tool/lib/shared/schemas/readOptionsOld.js +152 -0
  111. package/packages/client_build_tool/lib/shared/server/cert/Tsicsezwild-22-23.crt +37 -0
  112. package/packages/client_build_tool/lib/shared/server/cert/Tsicsezwild-22-23.key +27 -0
  113. package/packages/client_build_tool/lib/shared/server/configWebpackDevMiddleware.js +40 -0
  114. package/packages/client_build_tool/lib/shared/server/corsHandleing.js +28 -0
  115. package/packages/client_build_tool/lib/shared/server/getIp.js +30 -0
  116. package/packages/client_build_tool/lib/shared/server/getServerURL.js +29 -0
  117. package/packages/client_build_tool/lib/shared/server/httpsOptions.js +53 -0
  118. package/packages/client_build_tool/lib/shared/server/initExpressApp.js +19 -0
  119. package/packages/client_build_tool/lib/shared/server/initialHTMLHandling.js +66 -0
  120. package/packages/client_build_tool/lib/shared/server/serveContextFiles.js +24 -0
  121. package/packages/client_build_tool/lib/shared/server/serverBywebpackDevMiddleware.js +40 -0
  122. package/packages/client_build_tool/lib/shared/server/startHttpServer.js +26 -0
  123. package/packages/client_build_tool/lib/shared/server/startHttpsServer.js +34 -0
  124. package/packages/client_build_tool/lib/shared/server/unwanted/addHttp2Server.js +41 -0
  125. package/packages/client_build_tool/lib/shared/server/unwanted/configWebpackDevMiddleware.js +44 -0
  126. package/packages/client_build_tool/lib/shared/server/unwanted/devServerUtlis.js +1 -0
  127. package/packages/client_build_tool/lib/shared/server/unwanted/mockApiSupport.js +19 -0
  128. package/packages/client_build_tool/lib/shared/server/unwanted/webpackConfig.js +32 -0
  129. package/packages/client_build_tool/lib/shared/server/unwanted/websocketMockSetup.js +48 -0
  130. package/packages/client_build_tool/lib/shared/server/urlConcat.js +25 -0
  131. package/packages/client_build_tool/lib/shared/utils/utils.js +1 -0
  132. package/packages/client_build_tool/node_modules/history/CHANGES.md +395 -0
  133. package/packages/client_build_tool/node_modules/history/DOMUtils.js +3 -0
  134. package/packages/client_build_tool/node_modules/history/ExecutionEnvironment.js +3 -0
  135. package/packages/client_build_tool/node_modules/history/LICENSE +21 -0
  136. package/packages/client_build_tool/node_modules/history/LocationUtils.js +3 -0
  137. package/packages/client_build_tool/node_modules/history/PathUtils.js +3 -0
  138. package/packages/client_build_tool/node_modules/history/README.md +282 -0
  139. package/packages/client_build_tool/node_modules/history/cjs/history.js +933 -0
  140. package/packages/client_build_tool/node_modules/history/cjs/history.min.js +1 -0
  141. package/packages/client_build_tool/node_modules/history/createBrowserHistory.js +3 -0
  142. package/packages/client_build_tool/node_modules/history/createHashHistory.js +3 -0
  143. package/packages/client_build_tool/node_modules/history/createMemoryHistory.js +3 -0
  144. package/packages/client_build_tool/node_modules/history/createTransitionManager.js +3 -0
  145. package/packages/client_build_tool/node_modules/history/es/DOMUtils.js +7 -0
  146. package/packages/client_build_tool/node_modules/history/es/ExecutionEnvironment.js +7 -0
  147. package/packages/client_build_tool/node_modules/history/es/LocationUtils.js +7 -0
  148. package/packages/client_build_tool/node_modules/history/es/PathUtils.js +7 -0
  149. package/packages/client_build_tool/node_modules/history/es/createBrowserHistory.js +7 -0
  150. package/packages/client_build_tool/node_modules/history/es/createHashHistory.js +7 -0
  151. package/packages/client_build_tool/node_modules/history/es/createMemoryHistory.js +7 -0
  152. package/packages/client_build_tool/node_modules/history/es/createTransitionManager.js +7 -0
  153. package/packages/client_build_tool/node_modules/history/es/warnAboutDeprecatedESMImport.js +35 -0
  154. package/packages/client_build_tool/node_modules/history/esm/history.js +904 -0
  155. package/packages/client_build_tool/node_modules/history/index.js +7 -0
  156. package/packages/client_build_tool/node_modules/history/package.json +117 -0
  157. package/packages/client_build_tool/node_modules/history/umd/history.js +1059 -0
  158. package/packages/client_build_tool/node_modules/history/umd/history.min.js +1 -0
  159. package/packages/client_build_tool/node_modules/history/warnAboutDeprecatedCJSRequire.js +35 -0
package/README.md CHANGED
@@ -44,6 +44,19 @@ Now to run app
44
44
 
45
45
  # Change Logs
46
46
 
47
+ # 1.1.11-exp.3 (22-8-2023)
48
+
49
+ **Changes**
50
+ - Changed the default name of stats file to `build-report-integrity.json`
51
+ - Added optimization to reduce the stats file creation time. like streaming.
52
+ - Added support to exclude keys suggested
53
+
54
+ # 1.1.11-exp.2 (11-8-2023)
55
+
56
+ **Changes**
57
+ - Added more customization support for `stats.json` output.
58
+ - Disabling `bundle-analyser` stats report for our customized stats output based on a flag.
59
+
47
60
  # 1.1.11-exp.1 (8-8-2023)
48
61
 
49
62
  **Changes**
@@ -91,7 +91,10 @@ const getProdPlugins = (options, publicPath = '') => {
91
91
  localeAttr: efcLocaleAttr
92
92
  } = options.efc;
93
93
  const {
94
- enable: enableStats
94
+ enable: enableStats,
95
+ options: statsOptions,
96
+ excludeKeys: statsOutputExcludeKeys,
97
+ fileName: statsFileName
95
98
  } = options.stats;
96
99
  const hasEFC = newOptionForEnableEFC || prevOptionForEnableEFC;
97
100
  const hashTempalate = enableChunkHash ? '.[chunkhash:20]_' : '';
@@ -232,9 +235,9 @@ const getProdPlugins = (options, publicPath = '') => {
232
235
  if (bundleAnalyze) {
233
236
  pluginsArr.push(new _webpackBundleAnalyzer.BundleAnalyzerPlugin({
234
237
  analyzerMode: 'static',
235
- generateStatsFile: true,
238
+ generateStatsFile: !enableStats,
236
239
  openAnalyzer: false,
237
- statsOptions: {
240
+ statsOptions: enableStats ? null : {
238
241
  source: false,
239
242
  normal: true,
240
243
  chunks: false,
@@ -293,7 +296,11 @@ const getProdPlugins = (options, publicPath = '') => {
293
296
 
294
297
 
295
298
  customAttributes.enable && pluginsArr.push(new _CustomAttributePlugin.CustomAttributePlugin(customAttributes));
296
- enableStats && new _StatsPlugin.default();
299
+ enableStats && pluginsArr.push(new _StatsPlugin.default({
300
+ statsOptions,
301
+ statsOutputExcludeKeys,
302
+ statsFileName
303
+ }));
297
304
  return pluginsArr;
298
305
  };
299
306
 
@@ -1,24 +1,64 @@
1
1
  "use strict";
2
2
 
3
- const {
4
- defaulter
5
- } = require('../utils/getOptions');
6
-
7
3
  const fs = require('fs');
8
4
 
9
5
  const path = require('path');
10
6
 
7
+ const {
8
+ Readable
9
+ } = require('stream');
10
+
11
11
  const pluginName = 'stats-plugin';
12
12
  const statsSchema = {
13
- preset: 'normal',
14
- moduleTrace: true // source: true
15
- // errorDetails: true,
16
- // chunkRelations: true
17
-
13
+ all: true
18
14
  };
19
- module.exports = class StatsPlugin {
20
- constructor(options = {}) {
21
- this.statsOptions = defaulter(statsSchema, options);
15
+
16
+ function* convertObjectToStringGen(obj, excludeKeys = []) {
17
+ if (typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean' || obj === null) {
18
+ yield JSON.stringify(obj);
19
+ } else if (Array.isArray(obj)) {
20
+ yield '[';
21
+ let isFirst = true;
22
+
23
+ for (let item of obj) {
24
+ if (item === undefined) {
25
+ item = null;
26
+ }
27
+
28
+ yield `${isFirst ? '' : ','}`;
29
+ yield* convertObjectToStringGen(item, excludeKeys);
30
+ isFirst = false;
31
+ }
32
+
33
+ yield obj.length ? ']' : ']';
34
+ } else {
35
+ yield '{';
36
+ let isFirst = true;
37
+ const entries = Object.entries(obj);
38
+
39
+ for (const [itemKey, itemValue] of entries) {
40
+ if (itemValue === undefined || excludeKeys.includes(itemKey)) {
41
+ continue;
42
+ }
43
+
44
+ yield `${isFirst ? '' : ','}${JSON.stringify(itemKey)}: `;
45
+ yield* convertObjectToStringGen(itemValue, excludeKeys);
46
+ isFirst = false;
47
+ }
48
+
49
+ yield entries.length ? '}' : '}';
50
+ }
51
+ }
52
+
53
+ class StatsPlugin {
54
+ constructor({
55
+ statsOptions = {},
56
+ statsOutputExcludeKeys = [],
57
+ statsFileName = 'bundle-report-integrity.json'
58
+ }) {
59
+ this.excludeKeysInStat = statsOutputExcludeKeys;
60
+ this.statsOptions = Object.assign({}, statsSchema, statsOptions);
61
+ this.statsFileName = statsFileName;
22
62
  }
23
63
 
24
64
  apply(compiler) {
@@ -28,17 +68,47 @@ module.exports = class StatsPlugin {
28
68
  });
29
69
  }
30
70
 
31
- emitStats(statsJson) {
71
+ writeStatsFileInAStream(statsObj) {
32
72
  const {
33
73
  outputPath
34
- } = statsJson;
35
- const stringifiedJson = typeof statsJson === 'object' ? JSON.stringify(statsJson) : statsJson;
36
- const bufferJson = Buffer.from(stringifiedJson);
37
- fs.writeFile(path.join(outputPath, 'stats.json'), bufferJson, err => {
38
- if (err) {
39
- throw err;
74
+ } = statsObj;
75
+ const ouputFileName = path.join(outputPath, this.statsFileName);
76
+ this.createReadStream(statsObj).pipe(fs.createWriteStream(ouputFileName)).on('end', () => {
77
+ console.log(`${this.statsFileName} generated successfully`);
78
+ }).on('error', e => {
79
+ console.error('error in stats generation', e);
80
+ });
81
+ }
82
+
83
+ createReadStream(statsObj) {
84
+ const excludeKeys = this.excludeKeysInStat;
85
+ return new Readable({
86
+ read() {
87
+ let isDone = false;
88
+ const objToStringGen = convertObjectToStringGen(statsObj, excludeKeys);
89
+
90
+ while (!isDone) {
91
+ const {
92
+ done,
93
+ value
94
+ } = objToStringGen.next();
95
+
96
+ if (done) {
97
+ isDone = true;
98
+ this.push(null);
99
+ } else {
100
+ this.push(value);
101
+ }
102
+ }
40
103
  }
104
+
41
105
  });
42
106
  }
43
107
 
44
- };
108
+ emitStats(statsJson) {
109
+ return this.writeStatsFileInAStream(statsJson);
110
+ }
111
+
112
+ }
113
+
114
+ module.exports = StatsPlugin;
@@ -728,7 +728,10 @@ var _default = {
728
728
  enable: {
729
729
  value: false,
730
730
  cli: 'enable_stats'
731
- }
731
+ },
732
+ fileName: undefined,
733
+ options: undefined,
734
+ excludeKeys: undefined
732
735
  }
733
736
  };
734
737
  exports.default = _default;
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@zohodesk/react-cli",
3
- "version": "1.1.11-exp.1",
3
+ "version": "1.1.10",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@zohodesk/react-cli",
9
- "version": "1.1.11-exp.1",
9
+ "version": "1.1.10",
10
10
  "license": "ISC",
11
11
  "dependencies": {
12
12
  "@babel/cli": "7.10.5",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/react-cli",
3
- "version": "1.1.11-exp.1",
3
+ "version": "1.1.11-exp.3",
4
4
  "description": "A CLI tool for build modern web application and libraries",
5
5
  "scripts": {
6
6
  "init": "node ./lib/utils/init.js",
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _fs = require("fs");
9
+
10
+ var _path = require("path");
11
+
12
+ const allConfigs = [];
13
+ (0, _fs.readdirSync)((0, _path.join)(__dirname, 'commands')).forEach(folderName => {
14
+ const modulePath = (0, _path.join)(__dirname, './commands/' + folderName + '/config.js');
15
+
16
+ if ((0, _fs.existsSync)(modulePath)) {
17
+ const config = require(modulePath).default;
18
+
19
+ allConfigs.push(config);
20
+ }
21
+ });
22
+ var _default = allConfigs;
23
+ exports.default = _default;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.debugLogger = debugLogger;
7
+ exports.errorLogger = errorLogger;
8
+ exports.messageLogger = messageLogger;
9
+ exports.verboseLogger = verboseLogger;
10
+ exports.warnLogger = warnLogger;
11
+
12
+ /* eslint-disable no-console */
13
+ function verboseLogger(...args) {// TODO: need to be remove when publish happens
14
+ // console.log(...args);
15
+ console.log(...args);
16
+ }
17
+
18
+ function warnLogger(...args) {
19
+ console.warn(...args);
20
+ }
21
+
22
+ function messageLogger(...args) {
23
+ console.log(...args);
24
+ }
25
+
26
+ function debugLogger(...args) {// TODO: need to be remove when publish happens
27
+ // console.log(...args);
28
+ }
29
+
30
+ function errorLogger(...args) {
31
+ console.error(...args);
32
+ }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.commandExecutor = commandExecutor;
7
+
8
+ var _buildToolLoggers = require("../../buildToolLoggers");
9
+
10
+ var _webpackBuild = _interopRequireDefault(require("../../shared/bundler/webpack/webpackBuild"));
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ // import { spawnSyncIO } from '../../shared/commands-utlis/spanSync';
15
+ function commandExecutor(options) {
16
+ (0, _buildToolLoggers.messageLogger)('Build is runnning');
17
+ (0, _webpackBuild.default)(options); // spawnSyncIO('webpack', [
18
+ // '--config',
19
+ // require.resolve('../../shared/bundler/webpack/webpack.dev.config.js')
20
+ // ]);
21
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _default = {
8
+ name: "build",
9
+ alias: ["devbuild"],
10
+ dirname: __dirname
11
+ };
12
+ exports.default = _default;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.errorHander = errorHander;
7
+
8
+ function errorHander(e) {
9
+ console.error(e);
10
+ }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.configs = void 0;
7
+
8
+ var _commandExecutor = require("./commandExecutor");
9
+
10
+ var _errorHander = require("./errorHander");
11
+
12
+ var _optionsProcesser = require("./optionsProcesser");
13
+
14
+ // import { spawnSyncIO } from '../commands-utlis/spanSync.js';
15
+ function run(options) {
16
+ // const { disableWatch } = options.app;
17
+ // spawnSyncIO('node', [
18
+ // require.resolve(
19
+ // disableWatch ? '../servers/nowatchserver' : '../servers/server'
20
+ // ),
21
+ // '--expose-http2',
22
+ // ...args
23
+ // ]);
24
+ (0, _commandExecutor.commandExecutor)(options).then(console.log).catch(e => {
25
+ (0, _errorHander.errorHander)(e);
26
+ });
27
+ }
28
+
29
+ const configs = {
30
+ name: 'devSeverStart',
31
+ alias: ['start'],
32
+ optionsProcesser: _optionsProcesser.optionsProcesser,
33
+ run
34
+ };
35
+ exports.configs = configs;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.optionsProcesser = optionsProcesser;
7
+
8
+ var _path = require("path");
9
+
10
+ var _decidePublicPath = require("../../shared/bundler/webpack/common/decidePublicPath");
11
+
12
+ var _urlConcat = require("../../shared/server/urlConcat");
13
+
14
+ function optionsProcesser(options) {
15
+ const {
16
+ server,
17
+ context
18
+ } = options;
19
+ const {
20
+ disableContextURL
21
+ } = server;
22
+ const serverExtras = (0, _decidePublicPath.modifiedServerOptions)(options);
23
+ const publicPath = (0, _decidePublicPath.decidePublicPath)(serverExtras);
24
+ const contextURL = disableContextURL ? '' : `/${context}`;
25
+ const serverURL = (0, _urlConcat.urlConcat)(publicPath, contextURL);
26
+ const contextFolderPath = (0, _path.join)(process.cwd(), context);
27
+ console.log({
28
+ serverURL,
29
+ publicPath
30
+ });
31
+ const defaultApplyedOptions = { ...options,
32
+ serverExtras,
33
+ publicPath,
34
+ contextURL,
35
+ serverURL,
36
+ contextFolderPath,
37
+ httpsOptions: serverExtras.httpsOptions
38
+ };
39
+ return defaultApplyedOptions;
40
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.commandExecutor = commandExecutor;
7
+
8
+ var _spanSync = require("../../shared/commands-utlis/spanSync");
9
+
10
+ var _constants = require("../../shared/constants");
11
+
12
+ function commandExecutor(options) {
13
+ const {
14
+ extraArgs
15
+ } = options;
16
+ (0, _spanSync.spawnSyncIO)("babel", ["src", "--out-dir", "es", "--copy-files", "--config-file=" + _constants.babelrcPath, ...extraArgs]);
17
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _default = {
8
+ name: "build:es",
9
+ alias: ["build_es", "build:es"],
10
+ dirname: __dirname
11
+ };
12
+ exports.default = _default;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.commandExecutor = commandExecutor;
7
+
8
+ var _spanSync = require("../../shared/commands-utlis/spanSync");
9
+
10
+ var _constants = require("../../shared/constants");
11
+
12
+ function commandExecutor(options) {
13
+ const {
14
+ extraArgs
15
+ } = options;
16
+ (0, _spanSync.spawnSyncIO)("babel", ["src", "--out-dir", "lib", "--copy-files", "--config-file=" + _constants.babelrcPath, ...extraArgs]);
17
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _default = {
8
+ name: "build:lib",
9
+ alias: ["build_lib"],
10
+ dirname: __dirname
11
+ };
12
+ exports.default = _default;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.commandExecutor = commandExecutor;
7
+
8
+ var _serverBywebpackDevMiddleware = require("../../shared/server/serverBywebpackDevMiddleware");
9
+
10
+ function commandExecutor(options) {
11
+ // require("../../shared/server/devServer").run(options);
12
+ (0, _serverBywebpackDevMiddleware.run)(options);
13
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _default = {
8
+ name: "start",
9
+ alias: ["dstart", "devSeverStart"],
10
+ dirname: __dirname
11
+ };
12
+ exports.default = _default;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.deprecationHandler = deprecationHandler;
7
+
8
+ function deprecationHandler(options) {// options.app.deprecated &&
9
+ // console.log('options.app.deprecated this option was deprecated since V1.3.1' );
10
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.errorHander = errorHander;
7
+
8
+ function errorHander(e) {
9
+ console.error(e);
10
+ }
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.optionsProcesser = optionsProcesser;
7
+
8
+ var _path = require("path");
9
+
10
+ var _decidePublicPath = require("../../shared/bundler/webpack/common/decidePublicPath");
11
+
12
+ var _urlConcat = require("../../shared/server/urlConcat");
13
+
14
+ function optionsProcesser(options) {
15
+ const {
16
+ server,
17
+ context
18
+ } = options;
19
+ const {
20
+ disableContextURL
21
+ } = server;
22
+ const serverExtras = (0, _decidePublicPath.modifiedServerOptions)(options);
23
+ const publicPath = (0, _decidePublicPath.decidePublicPath)(serverExtras);
24
+ const contextURL = disableContextURL ? '' : `/${context}`;
25
+ const serverURL = (0, _urlConcat.urlConcat)(publicPath, contextURL);
26
+ const contextFolderPath = (0, _path.join)(process.cwd(), context);
27
+ const defaultApplyedOptions = { ...options,
28
+ serverExtras,
29
+ publicPath,
30
+ contextURL,
31
+ serverURL,
32
+ contextFolderPath,
33
+ httpsOptions: serverExtras.httpsOptions
34
+ };
35
+ return defaultApplyedOptions;
36
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.postProcesser = postProcesser;
7
+
8
+ function postProcesser(options) {
9
+ console.log('postProcesser');
10
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.preProcesser = preProcesser;
7
+
8
+ function preProcesser(options) {
9
+ console.log('preProcesser');
10
+ }
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.route = route;
7
+
8
+ var _fs = require("fs");
9
+
10
+ var _path = require("path");
11
+
12
+ var _allCommandsConfigs = _interopRequireDefault(require("./allCommandsConfigs"));
13
+
14
+ var _buildToolLoggers = require("./buildToolLoggers");
15
+
16
+ var _readOptions = require("./shared/schemas/readOptions");
17
+
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
+
20
+ function runCommand(commandConfig) {
21
+ const options = (0, _readOptions.getOptions)();
22
+ const {
23
+ dirname
24
+ } = commandConfig;
25
+
26
+ function runRespectiveFile(name, data) {
27
+ const commandExecutorPath = (0, _path.join)(dirname, name + ".js");
28
+
29
+ if ((0, _fs.existsSync)(commandExecutorPath)) {
30
+ const commandExecutor = require(commandExecutorPath);
31
+
32
+ return (commandExecutor[name] || commandExecutor.default)(data);
33
+ } else {
34
+ (0, _buildToolLoggers.debugLogger)("file not found", commandExecutorPath);
35
+ }
36
+ }
37
+
38
+ const processedOption = runRespectiveFile("optionsProcesser", options) || options;
39
+ runRespectiveFile("deprecationHandler", processedOption); // runRespectiveFile("errorHandler", () => {
40
+
41
+ runRespectiveFile("preProcesser", processedOption);
42
+ runRespectiveFile("commandExecutor", processedOption);
43
+ runRespectiveFile("postProcesser", processedOption); // });
44
+ }
45
+
46
+ function route(option, args) {
47
+ // TODO: need to modify this log
48
+ (0, _buildToolLoggers.debugLogger)("the command was " + option, args);
49
+ const commandConfig = findCommandConfig(option);
50
+
51
+ if (commandConfig) {
52
+ try {
53
+ runCommand(commandConfig);
54
+ } catch (error) {
55
+ console.error(error);
56
+ }
57
+ } else {
58
+ // TODO: need to write proper error message
59
+ (0, _buildToolLoggers.warnLogger)("Un known command", option, "please check the document");
60
+ }
61
+ }
62
+
63
+ function findCommandConfig(option) {
64
+ for (const commandConfig of _allCommandsConfigs.default) {
65
+ if (commandConfig.name === option || commandConfig.alias.includes(option)) {
66
+ return commandConfig;
67
+ }
68
+ }
69
+
70
+ return null;
71
+ }