@zohodesk/react-cli 0.0.1-exp.169.2 → 0.0.1-exp.175.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 (245) hide show
  1. package/.eslintignore +7 -7
  2. package/.eslintrc.js +180 -179
  3. package/.prettierrc +6 -6
  4. package/README.md +1028 -951
  5. package/bin/cli.js +483 -483
  6. package/cert/Tsicsezwild-22-23.crt +37 -37
  7. package/cert/Tsicsezwild-22-23.key +27 -27
  8. package/docs/CustomChunks.md +26 -26
  9. package/docs/DevStart.md +18 -18
  10. package/docs/HoverActive.md +12 -12
  11. package/docs/InstallNode.md +28 -28
  12. package/docs/TODOS.md +10 -10
  13. package/docs/ValueReplacer.md +60 -60
  14. package/docs/VariableConversion.md +678 -0
  15. package/docs/warnings_while_install.txt +35 -35
  16. package/files/eslintrc.js +62 -62
  17. package/files/prettierrc.js +3 -3
  18. package/lib/babel/cmjs-plugins-presets.js +0 -4
  19. package/lib/babel/es-plugins-presets.js +0 -4
  20. package/lib/common/getEntries.js +0 -10
  21. package/lib/common/getPublicPathConfig.js +0 -6
  22. package/lib/common/index.js +0 -5
  23. package/lib/common/splitChunks.js +2 -13
  24. package/lib/common/sslcertUpdater.js +6 -17
  25. package/lib/common/templateParameters.js +0 -2
  26. package/lib/common/testPattern.js +10 -21
  27. package/lib/common/valueReplacer.js +0 -15
  28. package/lib/configs/jest.config.js +8 -21
  29. package/lib/configs/libAlias.js +11 -2
  30. package/lib/configs/webpack.component.umd.config.js +0 -5
  31. package/lib/configs/webpack.css.umd.config.js +5 -13
  32. package/lib/configs/webpack.dev.config.js +13 -24
  33. package/lib/configs/webpack.docs.config.js +6 -12
  34. package/lib/configs/webpack.impact.config.js +6 -10
  35. package/lib/configs/webpack.prod.config.js +15 -26
  36. package/lib/hooks/docsProptypeHook.js +3 -7
  37. package/lib/jest/commitedFilesResult.js +3 -45
  38. package/lib/jest/coverageCollector.js +0 -11
  39. package/lib/jest/jsonMaker.js +0 -6
  40. package/lib/jest/preProcessors/cssPreprocessor.js +14 -13
  41. package/lib/jest/preProcessors/jsPreprocessor.js +0 -2
  42. package/lib/jest/preProcessors/otherFilesPreprocessor.js +0 -3
  43. package/lib/jest/result.js +0 -22
  44. package/lib/jest/run.js +6 -17
  45. package/lib/jest/setup.js +5 -57
  46. package/lib/loaderUtils/configsAssetsLoaders.js +34 -44
  47. package/lib/loaderUtils/getCSSLoaders.js +41 -28
  48. package/lib/loaderUtils/getDevJsLoaders.js +0 -8
  49. package/lib/loaderUtils/index.js +0 -3
  50. package/lib/loaders/docsLoader.js +0 -7
  51. package/lib/loaders/docsPropsLoader.js +3 -7
  52. package/lib/loaders/fileBountryLoader.js +0 -2
  53. package/lib/loaders/fileLoader.js +11 -22
  54. package/lib/loaders/scriptInstrumentLoader.js +5 -13
  55. package/lib/loaders/selectorMappingLoader.js +7 -25
  56. package/lib/loaders/workerLoader.js +13 -29
  57. package/lib/middlewares/HMRMiddleware.js +13 -26
  58. package/lib/middlewares/SSTMiddleware.js +0 -3
  59. package/lib/pluginUtils/configHtmlWebpackPlugins.js +53 -0
  60. package/lib/pluginUtils/getDevPlugins.js +20 -64
  61. package/lib/pluginUtils/getDocsPlugins.js +1 -10
  62. package/lib/pluginUtils/getLibraryImactPlugins.js +4 -5
  63. package/lib/pluginUtils/getLibraryPlugins.js +0 -5
  64. package/lib/pluginUtils/getProdPlugins.js +32 -78
  65. package/lib/pluginUtils/getServerPlugins.js +0 -5
  66. package/lib/pluginUtils/getUMDCSSPlugins.js +0 -7
  67. package/lib/pluginUtils/getUMDComponentPlugins.js +0 -7
  68. package/lib/pluginUtils/index.js +0 -8
  69. package/lib/plugins/CdnChangePlugin.js +0 -14
  70. package/lib/plugins/CleanupStatsPlugin.js +0 -5
  71. package/lib/plugins/EFCPlugin.js +23 -34
  72. package/lib/plugins/EFCPlugin.md +6 -6
  73. package/lib/plugins/EFCTemplatePlugin.js +23 -32
  74. package/lib/plugins/I18NInjectIntoIndexPlugin.js +12 -38
  75. package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +12 -17
  76. package/lib/plugins/I18nSplitPlugin/I18nDependency.js +4 -10
  77. package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +46 -77
  78. package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +44 -59
  79. package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +21 -30
  80. package/lib/plugins/I18nSplitPlugin/I18nSplit.md +95 -95
  81. package/lib/plugins/I18nSplitPlugin/README.md +25 -25
  82. package/lib/plugins/I18nSplitPlugin/index.js +70 -80
  83. package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +2 -12
  84. package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +0 -1
  85. package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +0 -5
  86. package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +0 -6
  87. package/lib/plugins/I18nSplitPlugin/utils/index.js +0 -4
  88. package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +2 -20
  89. package/lib/plugins/ManifestPlugin.js +0 -17
  90. package/lib/plugins/ModuleStatsPlugin.js +0 -23
  91. package/lib/plugins/OptimizeJSPlugin.js +0 -7
  92. package/lib/plugins/PublicPathCallbackPlugin.js +0 -10
  93. package/lib/plugins/PublicPathChangePlugin.js +4 -36
  94. package/lib/plugins/ReportGeneratePlugin.js +4 -30
  95. package/lib/plugins/RequireVariablePublicPlugin.js +0 -6
  96. package/lib/plugins/ResourceHintsPlugin.js +20 -27
  97. package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +12 -17
  98. package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +23 -38
  99. package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -30
  100. package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +2 -5
  101. package/lib/plugins/ScriptInstrumentPlugin.js +0 -7
  102. package/lib/plugins/ServiceWorkerPlugin.js +13 -29
  103. package/lib/plugins/ShadowDOMSupportPlugin.js +3 -40
  104. package/lib/plugins/SourceMapHookPlugin.js +0 -9
  105. package/lib/plugins/TPHashMappingPlugin.js +5 -19
  106. package/lib/plugins/UglifyCSSPlugin.js +0 -9
  107. package/lib/plugins/UnusedFilesFindPlugin.js +2 -35
  108. package/lib/plugins/index.js +0 -19
  109. package/lib/plugins/libraryImpactPlugin.js +0 -32
  110. package/lib/plugins/webpackwatchrunplugin.js +0 -5
  111. package/lib/postcss-plugins/ExcludePlugin.js +0 -4
  112. package/lib/postcss-plugins/RTLSplitPlugin.js +24 -37
  113. package/lib/postcss-plugins/ValueReplacer.js +9 -6
  114. package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +0 -3
  115. package/lib/postcss-plugins/__test__/test1Input.css +38 -38
  116. package/lib/postcss-plugins/__test__/test1Output.css +38 -38
  117. package/lib/postcss-plugins/hoverActivePlugin.js +80 -92
  118. package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +31 -0
  119. package/lib/postcss-plugins/variableModificationPlugin/index.js +232 -0
  120. package/lib/postcss-plugins/variableModifier.js +14 -20
  121. package/lib/schemas/index.js +28 -13
  122. package/lib/servers/clusterHubServer.js +0 -10
  123. package/lib/servers/devBuild.js +13 -24
  124. package/lib/servers/docsServer.js +0 -2
  125. package/lib/servers/docsServerCore.js +0 -21
  126. package/lib/servers/getCliPath.js +1 -10
  127. package/lib/servers/helpServer.js +0 -5
  128. package/lib/servers/httpsOptions.js +0 -4
  129. package/lib/servers/impactServer.js +2 -34
  130. package/lib/servers/mockserver.js +0 -9
  131. package/lib/servers/nowatchserver.js +12 -34
  132. package/lib/servers/scrServer.js +13 -20
  133. package/lib/servers/server.js +7 -35
  134. package/lib/servers/ssServer.js +0 -16
  135. package/lib/sh/pre-commit.sh +34 -34
  136. package/lib/sh/reportPublish.sh +45 -45
  137. package/lib/templates/CoverageScriptTemplate.js +0 -14
  138. package/lib/templates/WMSTemplate.js +6 -12
  139. package/lib/utils/babelPresets.js +0 -2
  140. package/lib/utils/buildstats.html +148 -148
  141. package/lib/utils/clean.js +2 -8
  142. package/lib/utils/copy.js +0 -6
  143. package/lib/utils/copyTimezones.js +0 -8
  144. package/lib/utils/createEventStream.js +0 -4
  145. package/lib/utils/cssClassNameGenerate.js +3 -19
  146. package/lib/utils/cssURLReplacer.js +0 -25
  147. package/lib/utils/dependencyPostPublish.js +0 -9
  148. package/lib/utils/fileUtils.js +0 -26
  149. package/lib/utils/folderIterator.js +0 -10
  150. package/lib/utils/getComponents.js +0 -21
  151. package/lib/utils/getCurrentBranch.js +0 -5
  152. package/lib/utils/getDependenciesImpactList.js +0 -21
  153. package/lib/utils/getHash.js +0 -7
  154. package/lib/utils/getIp.js +0 -2
  155. package/lib/utils/getOptions.js +38 -35
  156. package/lib/utils/getServerURL.js +0 -7
  157. package/lib/utils/index.js +2 -47
  158. package/lib/utils/init.js +0 -1
  159. package/lib/utils/initPreCommitHook.js +6 -29
  160. package/lib/utils/jsonHelper.js +2 -19
  161. package/lib/utils/libraryImpactConfig.js +0 -2
  162. package/lib/utils/lint/addScripts.js +2 -5
  163. package/lib/utils/lint/checkExistingConfig.js +3 -12
  164. package/lib/utils/lint/copyConfigs.js +0 -3
  165. package/lib/utils/lint/index.js +0 -9
  166. package/lib/utils/lint/lintScripts.js +0 -1
  167. package/lib/utils/lint/lintSetup.js +3 -4
  168. package/lib/utils/lint/lintStagedPreCommitHook.js +0 -1
  169. package/lib/utils/lint/question.js +0 -7
  170. package/lib/utils/lintReporter.js +0 -20
  171. package/lib/utils/mailSender.js +0 -7
  172. package/lib/utils/pullOrigin.js +0 -4
  173. package/lib/utils/reinstallDependencies.js +0 -28
  174. package/lib/utils/removeAttributes.js +0 -7
  175. package/lib/utils/repoClone.js +2 -27
  176. package/lib/utils/request.js +0 -12
  177. package/lib/utils/resultSchema.json +73 -73
  178. package/lib/utils/rtl.js +4 -16
  179. package/lib/utils/setEnvVariables.js +0 -2
  180. package/lib/utils/ssTestHack.js +0 -10
  181. package/lib/utils/switchBranch.js +0 -4
  182. package/lib/utils/urlConcat.js +0 -4
  183. package/lib/utils/useExitCleanup.js +9 -10
  184. package/npm8.md +9 -9
  185. package/package.json +146 -148
  186. package/postpublish.js +6 -6
  187. package/templates/app/.eslintrc.js +140 -140
  188. package/templates/app/README.md +12 -12
  189. package/templates/app/app/index.html +24 -24
  190. package/templates/app/app/properties/ApplicationResources_en_US.properties +1 -1
  191. package/templates/app/app/properties/i18nkeys.json +3 -3
  192. package/templates/app/docs/all.html +69 -69
  193. package/templates/app/mockapi/index.js +18 -18
  194. package/templates/app/package.json +37 -37
  195. package/templates/app/src/actions/SampleActions/index.js +37 -37
  196. package/templates/app/src/actions/index.js +65 -65
  197. package/templates/app/src/appUrls.js +19 -19
  198. package/templates/app/src/components/Alert/Alert.js +134 -134
  199. package/templates/app/src/components/Alert/Alert.module.css +79 -79
  200. package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -37
  201. package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -84
  202. package/templates/app/src/components/Sample/Sample.module.css +11 -11
  203. package/templates/app/src/components/Sample/SampleList.js +61 -61
  204. package/templates/app/src/components/Slider/Slider.css +41 -41
  205. package/templates/app/src/components/Slider/Slider.js +55 -55
  206. package/templates/app/src/containers/AlertContainer/index.js +15 -15
  207. package/templates/app/src/containers/AppContainer/index.js +96 -96
  208. package/templates/app/src/containers/AppContainer/index.module.css +27 -27
  209. package/templates/app/src/containers/CustomMatch/index.js +65 -65
  210. package/templates/app/src/containers/DevTools/index.js +10 -10
  211. package/templates/app/src/containers/Header/index.js +67 -67
  212. package/templates/app/src/containers/Header/index.module.css +43 -43
  213. package/templates/app/src/containers/Redirect/index.js +63 -63
  214. package/templates/app/src/containers/Redirector/index.js +47 -47
  215. package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -42
  216. package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -3
  217. package/templates/app/src/historyChange.js +5 -5
  218. package/templates/app/src/index.html +10 -10
  219. package/templates/app/src/index.js +24 -24
  220. package/templates/app/src/middleware/PromiseMiddleware.js +59 -59
  221. package/templates/app/src/reducers/alertData.js +11 -11
  222. package/templates/app/src/reducers/index.js +6 -6
  223. package/templates/app/src/reducers/samples.js +19 -19
  224. package/templates/app/src/store/configureStore.dev.js +51 -51
  225. package/templates/app/src/store/configureStore.js +5 -5
  226. package/templates/app/src/store/configureStore.prod.js +26 -26
  227. package/templates/app/src/util/Common.js +5 -5
  228. package/templates/app/src/util/RequestAPI.js +132 -132
  229. package/templates/docs/all.html +249 -249
  230. package/templates/docs/component.html +178 -178
  231. package/templates/docs/components.html +221 -221
  232. package/templates/docs/css/b.min.css +6 -6
  233. package/templates/docs/css/component.css +42 -42
  234. package/templates/docs/css/componentTest.css +6 -6
  235. package/templates/docs/css/hopscotch.css +585 -585
  236. package/templates/docs/css/style.css +1022 -1022
  237. package/templates/docs/impactReportTemplate.html +154 -154
  238. package/templates/docs/index.html +1501 -1493
  239. package/templates/docs/js/active-line.js +72 -72
  240. package/templates/docs/js/b.min.js +7 -7
  241. package/templates/docs/js/codemirror.js +9680 -9680
  242. package/templates/docs/js/designTokens.js +334 -334
  243. package/templates/docs/js/j.min.js +4 -4
  244. package/templates/docs/js/javascript.js +874 -874
  245. package/templates/docs/js/matchbrackets.js +145 -145
@@ -90,29 +90,17 @@ Object.defineProperty(exports, "switchBranch", {
90
90
  }
91
91
  });
92
92
  exports.writeFile = void 0;
93
-
94
93
  var _stream = require("stream");
95
-
96
94
  var _fs = _interopRequireDefault(require("fs"));
97
-
98
95
  var _getOptions = _interopRequireDefault(require("./getOptions"));
99
-
100
96
  var _createEventStream = _interopRequireDefault(require("./createEventStream"));
101
-
102
97
  var _getServerURL = _interopRequireDefault(require("./getServerURL"));
103
-
104
98
  var _getCurrentBranch = _interopRequireDefault(require("./getCurrentBranch"));
105
-
106
99
  var _switchBranch = _interopRequireDefault(require("./switchBranch"));
107
-
108
100
  var _pullOrigin = _interopRequireDefault(require("./pullOrigin"));
109
-
110
101
  var _request = _interopRequireDefault(require("./request"));
111
-
112
102
  var _jsonHelper = _interopRequireDefault(require("./jsonHelper"));
113
-
114
103
  var _reinstallDependencies = require("./reinstallDependencies");
115
-
116
104
  Object.keys(_reinstallDependencies).forEach(function (key) {
117
105
  if (key === "default" || key === "__esModule") return;
118
106
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -124,9 +112,7 @@ Object.keys(_reinstallDependencies).forEach(function (key) {
124
112
  }
125
113
  });
126
114
  });
127
-
128
115
  var _cssURLReplacer = require("./cssURLReplacer");
129
-
130
116
  Object.keys(_cssURLReplacer).forEach(function (key) {
131
117
  if (key === "default" || key === "__esModule") return;
132
118
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -138,9 +124,7 @@ Object.keys(_cssURLReplacer).forEach(function (key) {
138
124
  }
139
125
  });
140
126
  });
141
-
142
127
  var _initPreCommitHook = require("./initPreCommitHook");
143
-
144
128
  Object.keys(_initPreCommitHook).forEach(function (key) {
145
129
  if (key === "default" || key === "__esModule") return;
146
130
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -152,38 +136,26 @@ Object.keys(_initPreCommitHook).forEach(function (key) {
152
136
  }
153
137
  });
154
138
  });
155
-
156
139
  var _getDependenciesImpactList = _interopRequireDefault(require("./getDependenciesImpactList"));
157
-
158
140
  var _getComponents = _interopRequireDefault(require("./getComponents"));
159
-
160
141
  var _ssTestHack = _interopRequireDefault(require("./ssTestHack"));
161
-
162
142
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
163
-
164
143
  let log = (...info) => {
165
144
  let print = console;
166
145
  print.log(...info);
167
146
  };
168
-
169
147
  exports.log = log;
170
-
171
148
  let writeFile = (outputPath, src, isPath = false) => new Promise((resolve, reject) => {
172
149
  let inStr;
173
-
174
150
  if (isPath) {
175
151
  inStr = _fs.default.createReadStream(src);
176
152
  } else {
177
153
  inStr = new _stream.Readable();
178
-
179
154
  inStr._read = () => true;
180
-
181
155
  inStr.push(src);
182
156
  inStr.push(null);
183
157
  }
184
-
185
158
  let outStr = _fs.default.createWriteStream(outputPath);
186
-
187
159
  outStr.on('error', err => {
188
160
  reject(err);
189
161
  });
@@ -192,33 +164,26 @@ let writeFile = (outputPath, src, isPath = false) => new Promise((resolve, rejec
192
164
  });
193
165
  inStr.pipe(outStr);
194
166
  });
195
-
196
167
  exports.writeFile = writeFile;
197
-
198
168
  let makeDir = paths => {
199
169
  if (typeof paths === 'string') {
200
170
  //eslint-disable-next-line
201
171
  paths = [paths];
202
172
  }
203
-
204
173
  paths.forEach(path => {
205
174
  if (!_fs.default.existsSync(path)) {
206
175
  _fs.default.mkdirSync(path);
207
176
  }
208
177
  });
209
178
  };
210
-
211
179
  exports.makeDir = makeDir;
212
-
213
180
  let getInfoFromPublicPaths = publicPaths => {
214
181
  let rootFolder = '',
215
- image = '',
216
- font = '';
217
-
182
+ image = '',
183
+ font = '';
218
184
  if (publicPaths && !Array.isArray(publicPaths) && typeof publicPaths === 'object' && !publicPaths.callback) {
219
185
  let [cdn] = Object.keys(publicPaths);
220
186
  rootFolder = `${cdn}/`;
221
-
222
187
  if (publicPaths[cdn].font) {
223
188
  font = publicPaths[cdn].font; //eslint-disable-line
224
189
  }
@@ -234,9 +199,7 @@ let getInfoFromPublicPaths = publicPaths => {
234
199
  font
235
200
  };
236
201
  };
237
-
238
202
  exports.getInfoFromPublicPaths = getInfoFromPublicPaths;
239
-
240
203
  let getLibraryConflict = (moduleObject, impactObj, changesOnly) => {
241
204
  let srcChanges = [];
242
205
  let libraryChanges = [];
@@ -250,7 +213,6 @@ let getLibraryConflict = (moduleObject, impactObj, changesOnly) => {
250
213
  if (action !== 'REMOVED') {
251
214
  impactObj[library][action].forEach(srcObject => {
252
215
  let fileName = srcObject["FILEPATH"];
253
-
254
216
  if (library == "AppSource") {
255
217
  fileName = fileName.replace("jsapps/supportapp", ".");
256
218
  srcChanges.push(fileName);
@@ -262,10 +224,8 @@ let getLibraryConflict = (moduleObject, impactObj, changesOnly) => {
262
224
  }
263
225
  });
264
226
  });
265
-
266
227
  if (!changesOnly) {
267
228
  srcChanges = [];
268
-
269
229
  if (libraryChanges.length > 0) {
270
230
  libraryChanges.forEach(mdataLibKey => {
271
231
  if (moduleObject[mdataLibKey]) {
@@ -280,13 +240,11 @@ let getLibraryConflict = (moduleObject, impactObj, changesOnly) => {
280
240
  });
281
241
  } else {}
282
242
  }
283
-
284
243
  if (srcChanges.length > 0) {
285
244
  srcChanges.forEach(srcFile => {
286
245
  let cacheObject = {};
287
246
  cacheObject.sourceName = srcFile;
288
247
  let cacheLibraryList = [];
289
-
290
248
  if (libraryChanges.length > 0) {
291
249
  libraryChanges.forEach(mdataKey => {
292
250
  if (moduleObject[mdataKey]) {
@@ -300,7 +258,6 @@ let getLibraryConflict = (moduleObject, impactObj, changesOnly) => {
300
258
  impactThere = false;
301
259
  whichLibrary = 'No library file changes between target branch!';
302
260
  }
303
-
304
261
  if (cacheLibraryList.length > 0) {
305
262
  cacheObject.impactedBy = cacheLibraryList;
306
263
  allImpactArray.push(cacheObject);
@@ -313,7 +270,6 @@ let getLibraryConflict = (moduleObject, impactObj, changesOnly) => {
313
270
  impactThere = false;
314
271
  whichLibrary = "No component file changes!";
315
272
  }
316
-
317
273
  log('\n');
318
274
  log('You can see the HTML out at coverageTest/impactLibrary.html!');
319
275
  log('\x1b[33m%s\x1b[0m', '************************************************************ \n ');
@@ -325,5 +281,4 @@ let getLibraryConflict = (moduleObject, impactObj, changesOnly) => {
325
281
  }
326
282
  };
327
283
  };
328
-
329
284
  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 _index = require("./index");
15
-
16
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
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, _index.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, _index.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, _index.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,7 +20,6 @@ let getRunnerDetail = () => {
24
20
  };
25
21
  return defaultObj;
26
22
  };
27
-
28
23
  exports.getRunnerDetail = getRunnerDetail;
29
24
  let fileHandler = {
30
25
  readFile: (path, callback = null) => {
@@ -32,7 +27,6 @@ let fileHandler = {
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());
@@ -44,16 +38,14 @@ let fileHandler = {
44
38
  }
45
39
  };
46
40
  exports.fileHandler = fileHandler;
47
-
48
41
  const isObject = obj => obj && obj.constructor === {}.constructor;
42
+ const isArray = obj => obj && obj.constructor === [].constructor;
49
43
 
50
- const isArray = obj => obj && obj.constructor === [].constructor; // In below funtion
44
+ // In below funtion
51
45
  // this function is for concat two json object like _.extend,
52
46
  // if botha array we concat them
53
47
  // if both object we use call this function recurcively
54
48
  // if both differend data type we will just assign it
55
-
56
-
57
49
  let jsonConcate = (receiverObj, senterObj) => {
58
50
  Object.keys(senterObj).map(key => {
59
51
  if (Object.prototype.hasOwnProperty.call(receiverObj, key)) {
@@ -67,17 +59,13 @@ let jsonConcate = (receiverObj, senterObj) => {
67
59
  } else {
68
60
  receiverObj[key] = senterObj[key];
69
61
  }
70
-
71
62
  return key;
72
63
  });
73
64
  return receiverObj;
74
65
  };
75
-
76
66
  exports.jsonConcate = jsonConcate;
77
-
78
67
  let jsonHelper = (path, pathArray, value) => {
79
68
  let tempObj = {};
80
-
81
69
  if (typeof pathArray === 'string') {
82
70
  pathArray = pathArray.split('.'); //eslint-disable-line no-param-reassign
83
71
  }
@@ -86,21 +74,16 @@ let jsonHelper = (path, pathArray, value) => {
86
74
  tempObj = {};
87
75
  tempObj[key] = value;
88
76
  value = tempObj; // eslint-disable-line no-param-reassign
89
-
90
77
  return key;
91
78
  });
92
79
  let overAllObj = jsonConcate(JSON.parse(fileHandler.readFile(path)), tempObj);
93
80
  fileHandler.writeFile(path, overAllObj);
94
81
  };
95
-
96
82
  exports.jsonHelper = jsonHelper;
97
-
98
83
  let setTestInfoStatus = (filepath, status) => {
99
84
  let buildObject = JSON.parse(fileHandler.readFile(filepath));
100
-
101
85
  if (!buildObject.testInfo || buildObject.testInfo.isBuildVerified !== false) {
102
86
  jsonHelper(filepath, 'testInfo.isBuildVerified', status);
103
87
  }
104
88
  };
105
-
106
89
  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: {
@@ -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