@zohodesk/react-cli 1.1.29-exp.1 → 1.1.29-exp.2

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 (221) hide show
  1. package/lib/babel/babel-option-utils/babel-preset-react-option.js +0 -3
  2. package/lib/babel/cmjs-plugins-presets.js +1 -8
  3. package/lib/babel/es-plugins-presets.js +1 -8
  4. package/lib/common/buildEs.js +1 -0
  5. package/lib/common/getEntries.js +2 -13
  6. package/lib/common/getPublicPathConfig.js +0 -6
  7. package/lib/common/index.js +1 -6
  8. package/lib/common/runPreProcess.js +6 -15
  9. package/lib/common/splitChunks.js +2 -21
  10. package/lib/common/sslcertUpdater.js +7 -18
  11. package/lib/common/templateParameters.js +0 -2
  12. package/lib/common/testPattern.js +10 -21
  13. package/lib/common/valueReplacer.js +1 -16
  14. package/lib/configs/jest.config.js +1 -10
  15. package/lib/configs/libAlias.js +8 -14
  16. package/lib/configs/resolvers.js +4 -14
  17. package/lib/configs/webpack.component.umd.config.js +1 -6
  18. package/lib/configs/webpack.css.umd.config.js +6 -14
  19. package/lib/configs/webpack.dev.config.js +1 -14
  20. package/lib/configs/webpack.docs.config.js +1 -9
  21. package/lib/configs/webpack.impact.config.js +1 -8
  22. package/lib/configs/webpack.prod.config.js +4 -17
  23. package/lib/constants.js +9 -18
  24. package/lib/deprecationLogger.js +0 -7
  25. package/lib/hooks/docsProptypeHook.js +4 -8
  26. package/lib/jest/commitedFilesResult.js +4 -46
  27. package/lib/jest/coverageCollector.js +1 -12
  28. package/lib/jest/jsonMaker.js +0 -6
  29. package/lib/jest/preProcessors/cssPreprocessor.js +1 -9
  30. package/lib/jest/preProcessors/jsPreprocessor.js +1 -6
  31. package/lib/jest/preProcessors/otherFilesPreprocessor.js +1 -4
  32. package/lib/jest/result.js +1 -23
  33. package/lib/jest/run.js +7 -18
  34. package/lib/jest/setup.js +8 -60
  35. package/lib/loaderUtils/configsAssetsLoaders.js +2 -12
  36. package/lib/loaderUtils/getCSSLoaders.js +10 -22
  37. package/lib/loaderUtils/getDevJsLoaders.js +4 -13
  38. package/lib/loaderUtils/index.js +1 -4
  39. package/lib/loaderUtils/tests/windowsModification.test.js +0 -1
  40. package/lib/loaderUtils/windowsModification.js +2 -3
  41. package/lib/loaders/__test__/markdownLoader.spec.js +0 -1
  42. package/lib/loaders/composeLoader.js +13 -37
  43. package/lib/loaders/docsLoader.js +1 -12
  44. package/lib/loaders/docsPropsLoader.js +4 -8
  45. package/lib/loaders/enhancedReactLiveConverter.js +2 -23
  46. package/lib/loaders/fileBountryLoader.js +1 -3
  47. package/lib/loaders/fileLoader.js +12 -23
  48. package/lib/loaders/markdownLoader.js +14 -19
  49. package/lib/loaders/reactLiveConvertor.js +5 -15
  50. package/lib/loaders/scriptInstrumentLoader.js +7 -16
  51. package/lib/loaders/selectorMappingLoader.js +7 -26
  52. package/lib/loaders/workerLoader.js +9 -24
  53. package/lib/logger.js +0 -4
  54. package/lib/middlewares/HMRMiddleware.js +13 -27
  55. package/lib/middlewares/SSTMiddleware.js +1 -5
  56. package/lib/pluginUtils/configHtmlWebpackPlugins.js +1 -24
  57. package/lib/pluginUtils/getDevPlugins.js +9 -42
  58. package/lib/pluginUtils/getDocsPlugins.js +3 -13
  59. package/lib/pluginUtils/getLibraryImactPlugins.js +5 -6
  60. package/lib/pluginUtils/getLibraryPlugins.js +2 -8
  61. package/lib/pluginUtils/getProdPlugins.js +8 -47
  62. package/lib/pluginUtils/getServerPlugins.js +2 -8
  63. package/lib/pluginUtils/getUMDCSSPlugins.js +2 -10
  64. package/lib/pluginUtils/getUMDComponentPlugins.js +2 -10
  65. package/lib/pluginUtils/index.js +1 -9
  66. package/lib/plugins/CdnChangePlugin.js +2 -18
  67. package/lib/plugins/CleanupStatsPlugin.js +0 -5
  68. package/lib/plugins/CssOrderControlPlugin.js +3 -6
  69. package/lib/plugins/CustomAttributePlugin.js +14 -19
  70. package/lib/plugins/CustomScriptLoadingStrategyPlugin.js +3 -23
  71. package/lib/plugins/EFCPlugin.js +20 -34
  72. package/lib/plugins/EFCTemplatePlugin.js +19 -30
  73. package/lib/plugins/EfcResourceCleanupPlugin.js +0 -3
  74. package/lib/plugins/EventsHandlingPlugin.js +2 -4
  75. package/lib/plugins/I18NInjectIntoIndexPlugin.js +11 -37
  76. package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +10 -15
  77. package/lib/plugins/I18nSplitPlugin/I18nDependency.js +4 -10
  78. package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +12 -25
  79. package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +55 -133
  80. package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +12 -23
  81. package/lib/plugins/I18nSplitPlugin/index.js +13 -24
  82. package/lib/plugins/I18nSplitPlugin/utils/applyMetaManifest.js +64 -58
  83. package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +2 -12
  84. package/lib/plugins/I18nSplitPlugin/utils/createMetaManifest.js +10 -29
  85. package/lib/plugins/I18nSplitPlugin/utils/createRegularManifest.js +8 -19
  86. package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +0 -1
  87. package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +0 -5
  88. package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +1 -8
  89. package/lib/plugins/I18nSplitPlugin/utils/index.js +0 -4
  90. package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +0 -20
  91. package/lib/plugins/I18nSplitPlugin/utils/unicodeConversion.js +0 -1
  92. package/lib/plugins/ManifestPlugin.js +1 -18
  93. package/lib/plugins/MinifyPlugin.js +1 -10
  94. package/lib/plugins/ModuleStatsPlugin.js +1 -24
  95. package/lib/plugins/OptimizeJSPlugin.js +2 -10
  96. package/lib/plugins/PublicPathCallbackPlugin.js +1 -12
  97. package/lib/plugins/PublicPathChangePlugin.js +6 -39
  98. package/lib/plugins/ReportGeneratePlugin.js +5 -32
  99. package/lib/plugins/RequireVariablePublicPlugin.js +1 -8
  100. package/lib/plugins/ResourceHintsPlugin.js +4 -13
  101. package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +12 -17
  102. package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +10 -17
  103. package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +2 -5
  104. package/lib/plugins/ScriptInstrumentPlugin.js +1 -8
  105. package/lib/plugins/SelectorPlugin.js +6 -32
  106. package/lib/plugins/ServiceWorkerPlugin.js +5 -22
  107. package/lib/plugins/ShadowDOMSupportPlugin.js +4 -41
  108. package/lib/plugins/SourceMapHookPlugin.js +2 -12
  109. package/lib/plugins/StatsPlugin.js +0 -14
  110. package/lib/plugins/TPHashMappingPlugin.js +3 -18
  111. package/lib/plugins/UnusedFilesFindPlugin.js +4 -39
  112. package/lib/plugins/VariableConversionCollector.js +15 -42
  113. package/lib/plugins/index.js +1 -20
  114. package/lib/plugins/libraryImpactPlugin.js +1 -33
  115. package/lib/plugins/newi18nsplitplugin/18nPlugin1.js +306 -0
  116. package/lib/plugins/newi18nsplitplugin/18nPlugin2.js +363 -0
  117. package/lib/plugins/newi18nsplitplugin/18nPlugin3.js +694 -0
  118. package/lib/plugins/newi18nsplitplugin/18nPlugin_hashed.js +1258 -0
  119. package/lib/plugins/newi18nsplitplugin/18nPlugin_working.js +542 -0
  120. package/lib/plugins/newi18nsplitplugin/18nplugin.js +974 -0
  121. package/lib/plugins/newi18nsplitplugin/ChunkManager.js +131 -0
  122. package/lib/plugins/newi18nsplitplugin/GenerateModuleIdToKeysMapPlugin.js +59 -0
  123. package/lib/plugins/newi18nsplitplugin/I18nDiffPlugin.js +262 -0
  124. package/lib/plugins/newi18nsplitplugin/I18nDownloadLogic.js +166 -0
  125. package/lib/plugins/newi18nsplitplugin/I18nPropertiesPlugin.js +111 -0
  126. package/lib/plugins/newi18nsplitplugin/KeyCollector.js +163 -0
  127. package/lib/plugins/newi18nsplitplugin/ManifestGenerator.js +88 -0
  128. package/lib/plugins/newi18nsplitplugin/UnicodeConversionPlugin.js +101 -0
  129. package/lib/plugins/newi18nsplitplugin/constants.js +162 -0
  130. package/lib/plugins/newi18nsplitplugin/utils/I18nKeyHasher.js +78 -0
  131. package/lib/plugins/newi18nsplitplugin/utils/getJsResourceKeys.js +22 -0
  132. package/lib/plugins/newi18nsplitplugin/utils/i18nChunkUtils.js +18 -0
  133. package/lib/plugins/newi18nsplitplugin/utils/manifestGenerator.js +580 -0
  134. package/lib/plugins/newi18nsplitplugin/utils/propertiesUtils.js +54 -0
  135. package/lib/plugins/utils/classHandling.js +0 -6
  136. package/lib/plugins/utils/fileHandling.js +6 -15
  137. package/lib/plugins/utils/tests/fileHandling.test.js +0 -4
  138. package/lib/plugins/variableConvertorUtils.js +14 -29
  139. package/lib/plugins/webpackwatchrunplugin.js +0 -5
  140. package/lib/postcss-plugins/EmptyPlugin.js +3 -4
  141. package/lib/postcss-plugins/ExcludePlugin.js +1 -5
  142. package/lib/postcss-plugins/IncludePlugin.js +1 -5
  143. package/lib/postcss-plugins/RTLSplitPlugin.js +14 -27
  144. package/lib/postcss-plugins/SelectorReplace.js +1 -16
  145. package/lib/postcss-plugins/ValueReplacer.js +7 -6
  146. package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +0 -3
  147. package/lib/postcss-plugins/__test__/selectorReplace.test.js +6 -3
  148. package/lib/postcss-plugins/__test__/valueReplacer.spec.js +2 -5
  149. package/lib/postcss-plugins/hoverActivePlugin.js +31 -67
  150. package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +0 -7
  151. package/lib/postcss-plugins/variableModificationPlugin/index.js +28 -49
  152. package/lib/schemas/index.js +3 -9
  153. package/lib/servers/clusterHubServer.js +1 -11
  154. package/lib/servers/devBuild.js +14 -26
  155. package/lib/servers/docsServer.js +1 -3
  156. package/lib/servers/docsServerCore.js +1 -22
  157. package/lib/servers/getCliPath.js +0 -9
  158. package/lib/servers/helpServer.js +1 -6
  159. package/lib/servers/httpsOptions.js +2 -8
  160. package/lib/servers/impactServer.js +3 -35
  161. package/lib/servers/mockserver.js +1 -10
  162. package/lib/servers/nowatchserver.js +12 -37
  163. package/lib/servers/requireLocalOrGlobal.js +6 -17
  164. package/lib/servers/scrServer.js +14 -21
  165. package/lib/servers/server.js +6 -36
  166. package/lib/servers/ssServer.js +1 -17
  167. package/lib/templates/CoverageScriptTemplate.js +0 -14
  168. package/lib/templates/WMSTemplate.js +7 -13
  169. package/lib/templates/linterConstant.js +2 -4
  170. package/lib/utils/babelPresets.js +3 -7
  171. package/lib/utils/clean.js +3 -9
  172. package/lib/utils/copy.js +1 -7
  173. package/lib/utils/copyTimezones.js +1 -9
  174. package/lib/utils/createEventStream.js +1 -6
  175. package/lib/utils/cssClassNameGenerate.js +10 -30
  176. package/lib/utils/cssURLReplacer.js +1 -22
  177. package/lib/utils/dependencyPostPublish.js +1 -10
  178. package/lib/utils/deprecationSupport.js +7 -32
  179. package/lib/utils/fileUtils.js +1 -28
  180. package/lib/utils/folderIterator.js +2 -13
  181. package/lib/utils/getComponents.js +0 -21
  182. package/lib/utils/getCurrentBranch.js +0 -5
  183. package/lib/utils/getDependenciesImpactList.js +1 -22
  184. package/lib/utils/getFileType.js +2 -10
  185. package/lib/utils/getHash.js +1 -8
  186. package/lib/utils/getIp.js +0 -2
  187. package/lib/utils/getOptions.js +16 -53
  188. package/lib/utils/getServerURL.js +1 -10
  189. package/lib/utils/index.js +4 -51
  190. package/lib/utils/init.js +0 -1
  191. package/lib/utils/initPreCommitHook.js +7 -30
  192. package/lib/utils/jsonHelper.js +3 -22
  193. package/lib/utils/libraryImpactConfig.js +2 -5
  194. package/lib/utils/lint/addScripts.js +2 -5
  195. package/lib/utils/lint/checkExistingConfig.js +3 -12
  196. package/lib/utils/lint/copyConfigs.js +0 -3
  197. package/lib/utils/lint/index.js +0 -9
  198. package/lib/utils/lint/lintScripts.js +0 -1
  199. package/lib/utils/lint/lintSetup.js +3 -4
  200. package/lib/utils/lint/lintStagedPreCommitHook.js +0 -1
  201. package/lib/utils/lint/question.js +0 -7
  202. package/lib/utils/lintReporter.js +0 -20
  203. package/lib/utils/log.js +0 -1
  204. package/lib/utils/mailSender.js +1 -8
  205. package/lib/utils/object-manipulation.js +1 -17
  206. package/lib/utils/pullOrigin.js +0 -4
  207. package/lib/utils/reinstallDependencies.js +1 -29
  208. package/lib/utils/removeAttributes.js +1 -8
  209. package/lib/utils/repoClone.js +3 -28
  210. package/lib/utils/request.js +0 -12
  211. package/lib/utils/rtl.js +5 -17
  212. package/lib/utils/selectorReplacer.js +10 -16
  213. package/lib/utils/setEnvVariables.js +0 -2
  214. package/lib/utils/ssTestHack.js +1 -11
  215. package/lib/utils/switchBranch.js +0 -5
  216. package/lib/utils/typeCheck.js +0 -1
  217. package/lib/utils/urlConcat.js +0 -4
  218. package/lib/utils/useExitCleanup.js +9 -10
  219. package/lib/utils/variableConverter.js +22 -31
  220. package/{npm-shrinkwrap.json → package-lock.json} +2098 -1999
  221. package/package.json +1 -1
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  const getServerURL = (serverInfo, protocol) => {
9
8
  // eslint-disable-next-line prefer-const
10
9
  let {
@@ -12,29 +11,21 @@ const getServerURL = (serverInfo, protocol) => {
12
11
  domain,
13
12
  port
14
13
  } = serverInfo;
15
-
16
14
  if (domain === 'kubernetes') {
17
15
  return `${protocol ? `${protocol}:` : ''}//${host}`;
18
16
  }
19
-
20
17
  if (protocol) {
21
18
  if (protocol === 'ht' + 'tp') {
22
19
  port = Number(port) + 1;
23
-
24
20
  if (domain) {
25
21
  return `${protocol ? `${protocol}:` : ''}//${host}.${domain}.zohocorpin.com:${Number(port) + 1}`;
26
22
  }
27
-
28
23
  return `${protocol ? `${protocol}:` : ''}//${host}:${Number(port) + 1}`;
29
24
  }
30
25
  }
31
-
32
26
  if (domain) {
33
27
  return `${protocol ? `${protocol}:` : ''}//${host}.${domain}.zohocorpin.com:${port}`;
34
28
  }
35
-
36
29
  return `${protocol ? `${protocol}:` : ''}//${host}:${port}`;
37
30
  };
38
-
39
- var _default = getServerURL;
40
- exports.default = _default;
31
+ var _default = exports.default = getServerURL;
@@ -96,31 +96,18 @@ Object.defineProperty(exports, "switchBranch", {
96
96
  }
97
97
  });
98
98
  exports.writeFile = void 0;
99
-
100
99
  var _stream = require("stream");
101
-
102
100
  var _fs = _interopRequireDefault(require("fs"));
103
-
104
101
  var _log = require("./log");
105
-
106
102
  var _getOptions = _interopRequireDefault(require("./getOptions"));
107
-
108
103
  var _createEventStream = _interopRequireDefault(require("./createEventStream"));
109
-
110
104
  var _getServerURL = _interopRequireDefault(require("./getServerURL"));
111
-
112
105
  var _getCurrentBranch = _interopRequireDefault(require("./getCurrentBranch"));
113
-
114
106
  var _switchBranch = _interopRequireDefault(require("./switchBranch"));
115
-
116
107
  var _pullOrigin = _interopRequireDefault(require("./pullOrigin"));
117
-
118
108
  var _request = _interopRequireDefault(require("./request"));
119
-
120
109
  var _jsonHelper = _interopRequireDefault(require("./jsonHelper"));
121
-
122
110
  var _reinstallDependencies = require("./reinstallDependencies");
123
-
124
111
  Object.keys(_reinstallDependencies).forEach(function (key) {
125
112
  if (key === "default" || key === "__esModule") return;
126
113
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -132,9 +119,7 @@ Object.keys(_reinstallDependencies).forEach(function (key) {
132
119
  }
133
120
  });
134
121
  });
135
-
136
122
  var _cssURLReplacer = require("./cssURLReplacer");
137
-
138
123
  Object.keys(_cssURLReplacer).forEach(function (key) {
139
124
  if (key === "default" || key === "__esModule") return;
140
125
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -146,9 +131,7 @@ Object.keys(_cssURLReplacer).forEach(function (key) {
146
131
  }
147
132
  });
148
133
  });
149
-
150
134
  var _initPreCommitHook = require("./initPreCommitHook");
151
-
152
135
  Object.keys(_initPreCommitHook).forEach(function (key) {
153
136
  if (key === "default" || key === "__esModule") return;
154
137
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -160,15 +143,10 @@ Object.keys(_initPreCommitHook).forEach(function (key) {
160
143
  }
161
144
  });
162
145
  });
163
-
164
146
  var _getDependenciesImpactList = _interopRequireDefault(require("./getDependenciesImpactList"));
165
-
166
147
  var _getComponents = _interopRequireDefault(require("./getComponents"));
167
-
168
148
  var _ssTestHack = _interopRequireDefault(require("./ssTestHack"));
169
-
170
149
  var _typeCheck = require("./typeCheck");
171
-
172
150
  Object.keys(_typeCheck).forEach(function (key) {
173
151
  if (key === "default" || key === "__esModule") return;
174
152
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -180,26 +158,20 @@ Object.keys(_typeCheck).forEach(function (key) {
180
158
  }
181
159
  });
182
160
  });
183
-
184
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
185
-
161
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
186
162
  // eslint-disable-next-line no-duplicate-imports
163
+
187
164
  let writeFile = (outputPath, src, isPath = false) => new Promise((resolve, reject) => {
188
165
  let inStr;
189
-
190
166
  if (isPath) {
191
167
  inStr = _fs.default.createReadStream(src);
192
168
  } else {
193
169
  inStr = new _stream.Readable();
194
-
195
170
  inStr._read = () => true;
196
-
197
171
  inStr.push(src);
198
172
  inStr.push(null);
199
173
  }
200
-
201
174
  let outStr = _fs.default.createWriteStream(outputPath);
202
-
203
175
  outStr.on('error', err => {
204
176
  reject(err);
205
177
  });
@@ -208,51 +180,40 @@ let writeFile = (outputPath, src, isPath = false) => new Promise((resolve, rejec
208
180
  });
209
181
  inStr.pipe(outStr);
210
182
  });
211
-
212
183
  exports.writeFile = writeFile;
213
-
214
184
  let makeDir = paths => {
215
185
  if (typeof paths === 'string') {
216
186
  //eslint-disable-next-line
217
187
  paths = [paths];
218
188
  }
219
-
220
189
  paths.forEach(path => {
221
190
  if (!_fs.default.existsSync(path)) {
222
191
  _fs.default.mkdirSync(path);
223
192
  }
224
193
  });
225
194
  };
226
-
227
195
  exports.makeDir = makeDir;
228
-
229
196
  let getInfoFromPublicPaths = publicPaths => {
230
197
  let rootFolder = '',
231
- image = '',
232
- font = '';
233
-
198
+ image = '',
199
+ font = '';
234
200
  if (publicPaths && !Array.isArray(publicPaths) && typeof publicPaths === 'object' && !publicPaths.callback) {
235
201
  let [cdn] = Object.keys(publicPaths);
236
202
  rootFolder = `${cdn}/`;
237
-
238
203
  if (publicPaths[cdn].font) {
239
204
  font = publicPaths[cdn].font; //eslint-disable-line
240
205
  }
241
-
242
206
  if (publicPaths[cdn].image) {
243
207
  image = publicPaths[cdn].image; //eslint-disable-line
244
208
  }
245
209
  }
246
-
247
210
  return {
248
211
  rootFolder,
249
212
  image,
250
213
  font
251
214
  };
252
215
  };
253
-
254
216
  exports.getInfoFromPublicPaths = getInfoFromPublicPaths;
255
-
256
217
  let getLibraryConflict = (moduleObject, impactObj, changesOnly) => {
257
218
  let srcChanges = [];
258
219
  let libraryChanges = [];
@@ -266,7 +227,6 @@ let getLibraryConflict = (moduleObject, impactObj, changesOnly) => {
266
227
  if (action !== 'REMOVED') {
267
228
  impactObj[library][action].forEach(srcObject => {
268
229
  let fileName = srcObject["FILEPATH"];
269
-
270
230
  if (library == "AppSource") {
271
231
  fileName = fileName.replace("jsapps/supportapp", ".");
272
232
  srcChanges.push(fileName);
@@ -278,10 +238,8 @@ let getLibraryConflict = (moduleObject, impactObj, changesOnly) => {
278
238
  }
279
239
  });
280
240
  });
281
-
282
241
  if (!changesOnly) {
283
242
  srcChanges = [];
284
-
285
243
  if (libraryChanges.length > 0) {
286
244
  libraryChanges.forEach(mdataLibKey => {
287
245
  if (moduleObject[mdataLibKey]) {
@@ -296,13 +254,11 @@ let getLibraryConflict = (moduleObject, impactObj, changesOnly) => {
296
254
  });
297
255
  } else {}
298
256
  }
299
-
300
257
  if (srcChanges.length > 0) {
301
258
  srcChanges.forEach(srcFile => {
302
259
  let cacheObject = {};
303
260
  cacheObject.sourceName = srcFile;
304
261
  let cacheLibraryList = [];
305
-
306
262
  if (libraryChanges.length > 0) {
307
263
  libraryChanges.forEach(mdataKey => {
308
264
  if (moduleObject[mdataKey]) {
@@ -316,7 +272,6 @@ let getLibraryConflict = (moduleObject, impactObj, changesOnly) => {
316
272
  impactThere = false;
317
273
  whichLibrary = 'No library file changes between target branch!';
318
274
  }
319
-
320
275
  if (cacheLibraryList.length > 0) {
321
276
  cacheObject.impactedBy = cacheLibraryList;
322
277
  allImpactArray.push(cacheObject);
@@ -329,7 +284,6 @@ let getLibraryConflict = (moduleObject, impactObj, changesOnly) => {
329
284
  impactThere = false;
330
285
  whichLibrary = "No component file changes!";
331
286
  }
332
-
333
287
  (0, _log.log)('\n');
334
288
  (0, _log.log)('You can see the HTML out at coverageTest/impactLibrary.html!');
335
289
  (0, _log.log)('\x1b[33m%s\x1b[0m', '************************************************************ \n ');
@@ -341,5 +295,4 @@ let getLibraryConflict = (moduleObject, impactObj, changesOnly) => {
341
295
  }
342
296
  };
343
297
  };
344
-
345
298
  exports.getLibraryConflict = getLibraryConflict;
package/lib/utils/init.js CHANGED
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
2
 
3
3
  var _initPreCommitHook = require("./initPreCommitHook");
4
-
5
4
  (0, _initPreCommitHook.initPreCommitHook)(true);
@@ -4,73 +4,51 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.initPreCommitHook = exports.getGitRootDir = void 0;
7
-
8
7
  var _fs = _interopRequireDefault(require("fs"));
9
-
10
8
  var _path = _interopRequireDefault(require("path"));
11
-
12
9
  var _child_process = require("child_process");
13
-
14
10
  var _log = require("./log");
15
-
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
18
12
  let getGitRootDir = () => {
19
13
  try {
20
14
  return (0, _child_process.execSync)('git rev-parse --show-toplevel').toString();
21
15
  } catch (e) {
22
16
  return false;
23
17
  }
24
- }; //eslint-disable-next-line
25
-
18
+ };
26
19
 
20
+ //eslint-disable-next-line
27
21
  exports.getGitRootDir = getGitRootDir;
28
-
29
22
  let copyEslintConfig = rootDir => {
30
23
  rootDir = rootDir.replace(/\r?\n|\r/g, ''); //eslint-disable-line
31
-
32
24
  let srcPath = _path.default.join(__dirname, '..', '..', '.eslintrc.js');
33
-
34
25
  let targetPath = _path.default.join(rootDir, '.eslintrc.js');
35
-
36
26
  if (!_fs.default.existsSync(targetPath)) {
37
27
  let src = _fs.default.readFileSync(srcPath).toString();
38
-
39
28
  _fs.default.writeFileSync(targetPath, src);
40
-
41
29
  (0, _log.log)('Eslint config added in project root path');
42
30
  }
43
31
  };
44
-
45
32
  let initPreCommitHook = (forReactCLI = false) => {
46
- let gitRootDir = getGitRootDir(); //copyEslintConfig(gitRootDir || process.cwd());
47
-
33
+ let gitRootDir = getGitRootDir();
34
+ //copyEslintConfig(gitRootDir || process.cwd());
48
35
  if (gitRootDir) {
49
36
  let precommit = _fs.default.readFileSync(_path.default.join(__dirname, '../sh/pre-commit.sh')).toString();
50
-
51
37
  let targetPath = _path.default.join(gitRootDir, '.git', 'hooks', 'pre-commit').replace(/\s/g, '');
52
-
53
38
  if (_fs.default.existsSync(`${targetPath}.sample`)) {
54
- precommit = precommit.replace('${PREFIX_PATH}', //eslint-disable-line
39
+ precommit = precommit.replace('${PREFIX_PATH}',
40
+ //eslint-disable-line
55
41
  process.cwd().replace(/\\/g, '/'));
56
-
57
42
  _fs.default.renameSync(`${targetPath}.sample`, targetPath);
58
-
59
43
  _fs.default.writeFileSync(targetPath, precommit);
60
-
61
44
  (0, _log.log)('pre-commit hook added');
62
45
  }
63
-
64
46
  let packagePath = _path.default.join(process.cwd(), 'package.json');
65
-
66
47
  try {
67
48
  let packageJson = require(packagePath);
68
-
69
49
  if (packageJson.scripts.lint !== 'react-cli lint') {
70
50
  packageJson.scripts.lint = forReactCLI ? 'eslint ./src' : 'react-cli lint';
71
-
72
51
  _fs.default.writeFileSync(packagePath, JSON.stringify(packageJson, null, 2));
73
-
74
52
  (0, _log.log)('lint script added in your package.json');
75
53
  }
76
54
  } catch (e) {
@@ -78,5 +56,4 @@ let initPreCommitHook = (forReactCLI = false) => {
78
56
  }
79
57
  }
80
58
  };
81
-
82
59
  exports.initPreCommitHook = initPreCommitHook;
@@ -4,15 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.setTestInfoStatus = exports.jsonHelper = exports.jsonConcate = exports.getRunnerDetail = exports.fileHandler = void 0;
7
-
8
7
  let fs = require('fs');
9
-
10
8
  let os = require('os');
11
-
12
9
  let {
13
10
  getCurrentBranch
14
11
  } = require('./');
15
-
16
12
  let getRunnerDetail = () => {
17
13
  let defaultObj = {
18
14
  jobDetails: {
@@ -24,15 +20,13 @@ let getRunnerDetail = () => {
24
20
  };
25
21
  return defaultObj;
26
22
  };
27
-
28
23
  exports.getRunnerDetail = getRunnerDetail;
29
- let fileHandler = {
24
+ let fileHandler = exports.fileHandler = {
30
25
  readFile: (path, callback = null) => {
31
26
  if (fs.existsSync(path)) {
32
27
  if (callback === null) {
33
28
  return fs.readFileSync(path);
34
29
  }
35
-
36
30
  callback(fs.readFileSync(path));
37
31
  } else {
38
32
  return fileHandler.writeFile(path, getRunnerDetail());
@@ -43,17 +37,14 @@ let fileHandler = {
43
37
  return JSON.stringify(data);
44
38
  }
45
39
  };
46
- exports.fileHandler = fileHandler;
47
-
48
40
  const isObject = obj => obj && obj.constructor === {}.constructor;
41
+ const isArray = obj => obj && obj.constructor === [].constructor;
49
42
 
50
- const isArray = obj => obj && obj.constructor === [].constructor; // In below funtion
43
+ // In below funtion
51
44
  // this function is for concat two json object like _.extend,
52
45
  // if botha array we concat them
53
46
  // if both object we use call this function recurcively
54
47
  // if both differend data type we will just assign it
55
-
56
-
57
48
  let jsonConcate = (receiverObj, senterObj) => {
58
49
  Object.keys(senterObj).map(key => {
59
50
  if (Object.prototype.hasOwnProperty.call(receiverObj, key)) {
@@ -67,40 +58,30 @@ let jsonConcate = (receiverObj, senterObj) => {
67
58
  } else {
68
59
  receiverObj[key] = senterObj[key];
69
60
  }
70
-
71
61
  return key;
72
62
  });
73
63
  return receiverObj;
74
64
  };
75
-
76
65
  exports.jsonConcate = jsonConcate;
77
-
78
66
  let jsonHelper = (path, pathArray, value) => {
79
67
  let tempObj = {};
80
-
81
68
  if (typeof pathArray === 'string') {
82
69
  pathArray = pathArray.split('.'); //eslint-disable-line no-param-reassign
83
70
  }
84
-
85
71
  pathArray.slice(0).reverse().map(key => {
86
72
  tempObj = {};
87
73
  tempObj[key] = value;
88
74
  value = tempObj; // eslint-disable-line no-param-reassign
89
-
90
75
  return key;
91
76
  });
92
77
  let overAllObj = jsonConcate(JSON.parse(fileHandler.readFile(path)), tempObj);
93
78
  fileHandler.writeFile(path, overAllObj);
94
79
  };
95
-
96
80
  exports.jsonHelper = jsonHelper;
97
-
98
81
  let setTestInfoStatus = (filepath, status) => {
99
82
  let buildObject = JSON.parse(fileHandler.readFile(filepath));
100
-
101
83
  if (!buildObject.testInfo || buildObject.testInfo.isBuildVerified !== false) {
102
84
  jsonHelper(filepath, 'testInfo.isBuildVerified', status);
103
85
  }
104
86
  };
105
-
106
87
  exports.setTestInfoStatus = setTestInfoStatus;
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _utils = require("../utils");
9
-
10
8
  let options = (0, _utils.getOptions)();
11
9
  let {
12
10
  impactService: {
@@ -18,7 +16,7 @@ let {
18
16
  sourceServiceName
19
17
  }
20
18
  } = options;
21
- var _default = {
19
+ var _default = exports.default = {
22
20
  AppSource: {
23
21
  impactService: sourceServiceName,
24
22
  gitDomain: "ht" + "tps://zgit.csez.zohocorpin.com",
@@ -59,5 +57,4 @@ var _default = {
59
57
  impactDomain: "ht" + "tp://desk-automation.csez.zohocorpin.com:8080",
60
58
  name: "@zohodesk/variables"
61
59
  }
62
- };
63
- exports.default = _default;
60
+ };
@@ -1,27 +1,24 @@
1
1
  "use strict";
2
2
 
3
3
  const fs = require('fs');
4
-
5
4
  const {
6
5
  log
7
6
  } = require('..');
8
-
9
7
  function addScripts(scripts) {
10
8
  fs.readFile('./package.json', 'utf8', (err, configFileString) => {
11
9
  if (err) log('[LINT SETUP] No package.json in the current directory');else {
12
- const configFile = JSON.parse(configFileString); // Still Object destructuring causes issue. 😐
10
+ const configFile = JSON.parse(configFileString);
11
+ // Still Object destructuring causes issue. 😐
13
12
  // configFile.scripts = {
14
13
  // ...configFile.scripts,
15
14
  // ...scripts,
16
15
  // };
17
-
18
16
  configFile.scripts = Object.assign(configFile.scripts || {}, scripts);
19
17
  const data = JSON.stringify(configFile, undefined, 2);
20
18
  fs.writeFileSync('./package.json', data);
21
19
  }
22
20
  });
23
21
  }
24
-
25
22
  module.exports = {
26
23
  addScripts
27
24
  };
@@ -1,35 +1,30 @@
1
1
  "use strict";
2
2
 
3
3
  /* eslint-disable operator-linebreak */
4
-
5
4
  /* eslint-disable implicit-arrow-linebreak */
6
5
  const fs = require('fs');
7
-
8
6
  const {
9
7
  log
10
8
  } = require('..');
11
-
12
9
  const {
13
10
  question,
14
11
  rl
15
12
  } = require('./question');
16
-
17
13
  const eslintConfigFiles = ['.eslintrc.js', '.eslintrc.cjs', '.eslintrc.yaml', '.eslintrc.yml', '.eslintrc.json', '.eslintrc'];
18
14
  const prettierConfigFiles = ['.prettierrc.js', '.prettierrc.json', '.prettierrc', '.prettierrc.yml', '.prettierrc.yaml', '.prettierrc.json5', '.prettierrc.toml', '.prettierrc.cjs', '.prettier.config.js', '.prettier.config.cjs'];
19
-
20
15
  function isConfigExists(fileNames) {
21
16
  return fileNames.find(file => {
22
17
  if (fs.existsSync(file)) return true;
23
18
  return false;
24
19
  });
25
20
  }
26
-
27
21
  async function checkConflicts(files) {
28
22
  const conflictFile = isConfigExists(files);
29
-
30
23
  if (conflictFile) {
31
24
  log(`[LINT SETUP] There's already a config exists as named ${conflictFile}`);
32
- const res = await question('[LINT SETUP] Do you want to overwrite? (y/n): '); // TODO: Next cycle: Need to delete the current config file.
25
+ const res = await question('[LINT SETUP] Do you want to overwrite? (y/n): ');
26
+
27
+ // TODO: Next cycle: Need to delete the current config file.
33
28
  // if (res === 'y') {
34
29
  // exec(`rm ${conflictFile}`, (err) => {
35
30
  // if (err) log(err);
@@ -41,15 +36,12 @@ async function checkConflicts(files) {
41
36
 
42
37
  return res;
43
38
  }
44
-
45
39
  return false;
46
40
  }
47
-
48
41
  async function promptForPreCommitHook() {
49
42
  const res = await question('[LINT SETUP] Do you need a pre-commit hook for formatting and check lint errors in cached files (newly changed)? (y/n): ');
50
43
  return res;
51
44
  }
52
-
53
45
  const getChoices = async () => {
54
46
  const eslint = await checkConflicts(eslintConfigFiles);
55
47
  const prettier = await checkConflicts(prettierConfigFiles);
@@ -59,7 +51,6 @@ const getChoices = async () => {
59
51
  rl.close();
60
52
  return [isESLintAllowed, isPrettierAllowed, isHookInstallEnabled];
61
53
  };
62
-
63
54
  module.exports = {
64
55
  eslintConfigFiles,
65
56
  prettierConfigFiles,
@@ -1,11 +1,9 @@
1
1
  "use strict";
2
2
 
3
3
  const fs = require('fs');
4
-
5
4
  const {
6
5
  log
7
6
  } = require('..');
8
-
9
7
  async function copyConfigs(file) {
10
8
  // copy the file in react-cli to current working directory
11
9
  fs.readFile(require.resolve(`../../../files/${file}.js`), (err, data) => {
@@ -20,5 +18,4 @@ async function copyConfigs(file) {
20
18
  }
21
19
  });
22
20
  }
23
-
24
21
  module.exports = copyConfigs;
@@ -7,37 +7,29 @@ const {
7
7
  runInstall,
8
8
  installLintStaged
9
9
  } = require('./lintSetup');
10
-
11
10
  const {
12
11
  log
13
12
  } = require('..');
14
-
15
13
  const {
16
14
  eslintConfigFiles,
17
15
  prettierConfigFiles,
18
16
  getChoices
19
17
  } = require('./checkExistingConfig');
20
-
21
18
  const copyConfigs = require('./copyConfigs');
22
-
23
19
  async function main() {
24
20
  const packages = [];
25
21
  const [isESLintAllowed, isPrettierAllowed, isHookInstallEnabled] = await getChoices();
26
-
27
22
  if (isESLintAllowed) {
28
23
  copyConfigs('eslintrc', eslintConfigFiles);
29
24
  packages.push(...eslintPackages);
30
25
  }
31
-
32
26
  if (isPrettierAllowed) {
33
27
  copyConfigs('prettierrc', prettierConfigFiles);
34
28
  packages.push(...prettierPackages);
35
29
  }
36
-
37
30
  if (isESLintAllowed && isPrettierAllowed) {
38
31
  packages.push(...eslintPrettierConfig);
39
32
  }
40
-
41
33
  if (packages.length) {
42
34
  const process = runInstall(packages);
43
35
  process.on('close', () => {
@@ -49,6 +41,5 @@ async function main() {
49
41
  installLintStaged();
50
42
  }
51
43
  }
52
-
53
44
  log('[LINT SETUP] Beginning configuration...');
54
45
  main();
@@ -3,7 +3,6 @@
3
3
  const {
4
4
  addScripts
5
5
  } = require('./addScripts');
6
-
7
6
  const scripts = {
8
7
  lintSetup: 'react-cli lint-setup && npm run lintExtInstall && echo "If changes not reflected kindly restart your VSCode."',
9
8
  lintExtInstall: 'code --install-extension dbaeumer.vscode-eslint && code --install-extension esbenp.prettier-vscode'
@@ -3,10 +3,11 @@
3
3
  const {
4
4
  spawn
5
5
  } = require('child_process');
6
-
7
6
  const eslintPackages = ['eslint@7.18.0', 'eslint-config-airbnb@18.2.1', 'eslint-plugin-import@2.22.1', 'eslint-plugin-jsx-a11y@6.4.1', 'eslint-plugin-react@7.22.0', 'eslint-plugin-css-modules@2.11.0', '@zohodesk/eslint-plugin-react-performance@1.0.3', '@zohodesk/eslint-plugin-zsecurity@0.0.1-beta.4', 'eslint-plugin-react-hooks@4.2.0'];
8
7
  const prettierPackages = ['prettier@2.2.1'];
9
- const eslintPrettierConfig = ['eslint-config-prettier@7.2.0']; // const npmInstall = `npm i --save-dev ${devDependencies.join(' ')}`;
8
+ const eslintPrettierConfig = ['eslint-config-prettier@7.2.0'];
9
+
10
+ // const npmInstall = `npm i --save-dev ${devDependencies.join(' ')}`;
10
11
 
11
12
  function runInstall(packages) {
12
13
  return spawn('npm', ['i', ...packages, '--save-dev'], {
@@ -14,14 +15,12 @@ function runInstall(packages) {
14
15
  stdio: 'inherit'
15
16
  });
16
17
  }
17
-
18
18
  function installLintStaged() {
19
19
  spawn('npx', ['mrm', 'lint-staged'], {
20
20
  detached: true,
21
21
  stdio: 'inherit'
22
22
  });
23
23
  }
24
-
25
24
  module.exports = {
26
25
  eslintPackages,
27
26
  prettierPackages,
@@ -3,5 +3,4 @@
3
3
  const {
4
4
  installLintStaged
5
5
  } = require('./lintSetup');
6
-
7
6
  installLintStaged();
@@ -1,29 +1,22 @@
1
1
  "use strict";
2
2
 
3
3
  /* eslint-disable no-await-in-loop */
4
-
5
4
  /* eslint-disable implicit-arrow-linebreak */
6
5
  const readline = require('readline');
7
-
8
6
  const rl = readline.createInterface({
9
7
  input: process.stdin,
10
8
  output: process.stdout
11
9
  });
12
-
13
10
  const question = qn => new Promise(res => {
14
11
  rl.question(qn, ans => res(ans));
15
12
  });
16
-
17
13
  async function main(qn) {
18
14
  let answer;
19
-
20
15
  while (!['n', 'y'].includes(answer)) {
21
16
  answer = (await question(qn)).toLowerCase();
22
17
  }
23
-
24
18
  return answer;
25
19
  }
26
-
27
20
  module.exports = {
28
21
  question: main,
29
22
  rl