@zohodesk/react-cli 0.0.1-beta.17 → 0.0.1-beta.171

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 (292) hide show
  1. package/.eslintignore +1 -0
  2. package/.eslintrc.js +49 -10
  3. package/.prettierrc +6 -0
  4. package/CHANGELOG.md +5 -0
  5. package/README.md +859 -0
  6. package/bin/cli.js +215 -46
  7. package/cert/Tsicsezwild-22-23.crt +37 -0
  8. package/cert/Tsicsezwild-22-23.key +27 -0
  9. package/docs/CustomChunks.md +26 -0
  10. package/docs/DevStart.md +18 -0
  11. package/docs/HoverActive.md +12 -0
  12. package/docs/InstallNode.md +28 -0
  13. package/docs/TODOS.md +10 -0
  14. package/docs/ValueReplacer.md +60 -0
  15. package/docs/warnings_while_install.txt +35 -0
  16. package/files/eslintrc.js +62 -0
  17. package/files/prettierrc.js +3 -0
  18. package/lib/babel/cmjs-plugins-presets.js +24 -0
  19. package/lib/babel/es-plugins-presets.js +34 -0
  20. package/lib/common/getEntries.js +33 -46
  21. package/lib/common/getPublicPathConfig.js +40 -0
  22. package/lib/common/index.js +24 -19
  23. package/lib/common/splitChunks.js +110 -25
  24. package/lib/common/sslcertUpdater.js +59 -0
  25. package/lib/common/templateParameters.js +25 -0
  26. package/lib/common/testPattern.js +69 -0
  27. package/lib/common/valueReplacer.js +55 -0
  28. package/lib/configs/jest.config.js +31 -27
  29. package/lib/configs/libAlias.js +31 -0
  30. package/lib/configs/webpack.component.umd.config.js +46 -53
  31. package/lib/configs/webpack.css.umd.config.js +47 -46
  32. package/lib/configs/webpack.dev.config.js +99 -84
  33. package/lib/configs/webpack.docs.config.js +65 -57
  34. package/lib/configs/webpack.impact.config.js +109 -0
  35. package/lib/configs/webpack.prod.config.js +147 -104
  36. package/lib/hooks/docsProptypeHook.js +32 -38
  37. package/lib/jest/commitedFilesResult.js +144 -71
  38. package/lib/jest/coverageCollector.js +68 -35
  39. package/lib/jest/jsonMaker.js +54 -0
  40. package/lib/jest/preProcessors/cssPreprocessor.js +16 -18
  41. package/lib/jest/preProcessors/jsPreprocessor.js +5 -6
  42. package/lib/jest/preProcessors/otherFilesPreprocessor.js +5 -6
  43. package/lib/jest/result.js +92 -42
  44. package/lib/jest/run.js +75 -28
  45. package/lib/jest/setup.js +103 -102
  46. package/lib/loaderUtils/configsAssetsLoaders.js +117 -0
  47. package/lib/loaderUtils/getCSSLoaders.js +113 -0
  48. package/lib/loaderUtils/getDevJsLoaders.js +35 -23
  49. package/lib/loaderUtils/index.js +14 -7
  50. package/lib/loaders/docsLoader.js +15 -15
  51. package/lib/loaders/docsPropsLoader.js +14 -17
  52. package/lib/loaders/fileBountryLoader.js +17 -0
  53. package/lib/loaders/fileLoader.js +47 -38
  54. package/lib/loaders/scriptInstrumentLoader.js +23 -20
  55. package/lib/loaders/selectorMappingLoader.js +75 -0
  56. package/lib/loaders/workerLoader.js +136 -0
  57. package/lib/middlewares/HMRMiddleware.js +90 -72
  58. package/lib/middlewares/SSTMiddleware.js +21 -0
  59. package/lib/pluginUtils/getDevPlugins.js +177 -30
  60. package/lib/pluginUtils/getDocsPlugins.js +36 -15
  61. package/lib/pluginUtils/getLibraryImactPlugins.js +23 -0
  62. package/lib/pluginUtils/getLibraryPlugins.js +8 -10
  63. package/lib/pluginUtils/getProdPlugins.js +244 -37
  64. package/lib/pluginUtils/getServerPlugins.js +8 -11
  65. package/lib/pluginUtils/getUMDCSSPlugins.js +14 -18
  66. package/lib/pluginUtils/getUMDComponentPlugins.js +14 -9
  67. package/lib/pluginUtils/index.js +36 -43
  68. package/lib/plugins/CdnChangePlugin.js +77 -0
  69. package/lib/plugins/CleanupStatsPlugin.js +28 -0
  70. package/lib/plugins/EFCPlugin.js +241 -0
  71. package/lib/plugins/EFCPlugin.md +6 -0
  72. package/lib/plugins/EFCTemplatePlugin.js +151 -0
  73. package/lib/plugins/I18NInjectIntoIndexPlugin.js +141 -0
  74. package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +60 -0
  75. package/lib/plugins/I18nSplitPlugin/I18nDependency.js +44 -0
  76. package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +266 -0
  77. package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +183 -0
  78. package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +100 -0
  79. package/lib/plugins/I18nSplitPlugin/I18nSplit.md +95 -0
  80. package/lib/plugins/I18nSplitPlugin/README.md +25 -0
  81. package/lib/plugins/I18nSplitPlugin/index.js +185 -0
  82. package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +64 -0
  83. package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +13 -0
  84. package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +26 -0
  85. package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +40 -0
  86. package/lib/plugins/I18nSplitPlugin/utils/index.js +31 -0
  87. package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +112 -0
  88. package/lib/plugins/ManifestPlugin.js +86 -0
  89. package/lib/plugins/ModuleStatsPlugin.js +98 -97
  90. package/lib/plugins/OptimizeJSPlugin.js +41 -0
  91. package/lib/plugins/PublicPathCallbackPlugin.js +63 -0
  92. package/lib/plugins/PublicPathChangePlugin.js +226 -0
  93. package/lib/plugins/ReportGeneratePlugin.js +181 -0
  94. package/lib/plugins/RequireVariablePublicPlugin.js +30 -0
  95. package/lib/plugins/ResourceHintsPlugin.js +67 -0
  96. package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +80 -0
  97. package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +82 -0
  98. package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -0
  99. package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +26 -0
  100. package/lib/plugins/ScriptInstrumentPlugin.js +22 -37
  101. package/lib/plugins/ServiceWorkerPlugin.js +107 -0
  102. package/lib/plugins/ShadowDOMSupportPlugin.js +270 -0
  103. package/lib/plugins/SourceMapHookPlugin.js +25 -59
  104. package/lib/plugins/TPHashMappingPlugin.js +67 -0
  105. package/lib/plugins/UglifyCSSPlugin.js +39 -0
  106. package/lib/plugins/UnusedFilesFindPlugin.js +150 -97
  107. package/lib/plugins/index.js +127 -37
  108. package/lib/plugins/libraryImpactPlugin.js +190 -0
  109. package/lib/plugins/webpackwatchrunplugin.js +26 -0
  110. package/lib/postcss-plugins/ExcludePlugin.js +23 -0
  111. package/lib/postcss-plugins/RTLSplitPlugin.js +138 -0
  112. package/lib/postcss-plugins/ValueReplacer.js +46 -0
  113. package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +22 -0
  114. package/lib/postcss-plugins/__test__/test1Input.css +39 -0
  115. package/lib/postcss-plugins/__test__/test1Output.css +39 -0
  116. package/lib/postcss-plugins/hoverActivePlugin.js +368 -0
  117. package/lib/postcss-plugins/variableModifier.js +243 -0
  118. package/lib/schemas/index.js +541 -65
  119. package/lib/servers/clusterHubServer.js +22 -26
  120. package/lib/servers/devBuild.js +102 -0
  121. package/lib/servers/docsServer.js +3 -5
  122. package/lib/servers/docsServerCore.js +94 -79
  123. package/lib/servers/getCliPath.js +28 -0
  124. package/lib/servers/helpServer.js +19 -21
  125. package/lib/servers/httpsOptions.js +18 -0
  126. package/lib/servers/impactServer.js +123 -115
  127. package/lib/servers/mockserver.js +44 -0
  128. package/lib/servers/nowatchserver.js +200 -0
  129. package/lib/servers/scrServer.js +147 -0
  130. package/lib/servers/server.js +134 -132
  131. package/lib/servers/ssServer.js +106 -70
  132. package/lib/sh/reportPublish.sh +16 -10
  133. package/lib/templates/CoverageScriptTemplate.js +45 -18
  134. package/lib/templates/WMSTemplate.js +17 -18
  135. package/lib/templates/linterConstant.js +10 -0
  136. package/lib/utils/babelPresets.js +12 -4
  137. package/lib/utils/buildstats.html +148 -0
  138. package/lib/utils/clean.js +12 -11
  139. package/lib/utils/copy.js +16 -109
  140. package/lib/utils/copyTimezones.js +21 -0
  141. package/lib/utils/createEventStream.js +24 -19
  142. package/lib/utils/cssClassNameGenerate.js +77 -0
  143. package/lib/utils/cssURLReplacer.js +136 -0
  144. package/lib/utils/dependencyPostPublish.js +42 -0
  145. package/lib/utils/fileUtils.js +125 -0
  146. package/lib/utils/folderIterator.js +47 -0
  147. package/lib/utils/getComponents.js +126 -0
  148. package/lib/utils/getCurrentBranch.js +11 -17
  149. package/lib/utils/getDependenciesImpactList.js +151 -0
  150. package/lib/utils/getHash.js +26 -0
  151. package/lib/utils/getIp.js +20 -0
  152. package/lib/utils/getOptions.js +113 -28
  153. package/lib/utils/getServerURL.js +25 -8
  154. package/lib/utils/index.js +283 -68
  155. package/lib/utils/init.js +2 -2
  156. package/lib/utils/initPreCommitHook.js +47 -27
  157. package/lib/utils/jsonHelper.js +106 -0
  158. package/lib/utils/libraryImpactConfig.js +63 -0
  159. package/lib/utils/lint/addScripts.js +27 -0
  160. package/lib/utils/lint/checkExistingConfig.js +67 -0
  161. package/lib/utils/lint/copyConfigs.js +24 -0
  162. package/lib/utils/lint/index.js +54 -0
  163. package/lib/utils/lint/lintScripts.js +11 -0
  164. package/lib/utils/lint/lintSetup.js +31 -0
  165. package/lib/utils/lint/lintStagedPreCommitHook.js +7 -0
  166. package/lib/utils/lint/question.js +30 -0
  167. package/lib/utils/lintReporter.js +142 -0
  168. package/lib/utils/mailSender.js +16 -25
  169. package/lib/utils/pullOrigin.js +28 -0
  170. package/lib/utils/reinstallDependencies.js +133 -0
  171. package/lib/utils/removeAttributes.js +25 -23
  172. package/lib/utils/repoClone.js +59 -63
  173. package/lib/utils/request.js +64 -77
  174. package/lib/utils/resultSchema.json +73 -0
  175. package/lib/utils/rtl.js +59 -0
  176. package/lib/utils/setEnvVariables.js +13 -0
  177. package/lib/utils/ssTestHack.js +48 -0
  178. package/lib/utils/switchBranch.js +28 -0
  179. package/lib/utils/urlConcat.js +22 -0
  180. package/lib/utils/useExitCleanup.js +55 -0
  181. package/npm8.md +9 -0
  182. package/package.json +96 -64
  183. package/postpublish.js +6 -0
  184. package/templates/app/.eslintrc.js +140 -0
  185. package/templates/app/README.md +12 -12
  186. package/templates/app/app/index.html +24 -8
  187. package/templates/app/app/properties/ApplicationResources_en_US.properties +1 -1
  188. package/templates/app/app/properties/i18nkeys.json +3 -3
  189. package/templates/app/docs/all.html +69 -69
  190. package/templates/app/mockapi/index.js +18 -13
  191. package/templates/app/package.json +37 -17
  192. package/templates/app/src/actions/SampleActions/index.js +37 -0
  193. package/templates/app/src/actions/index.js +65 -0
  194. package/templates/app/src/appUrls.js +19 -0
  195. package/templates/app/src/components/Alert/Alert.js +134 -0
  196. package/templates/app/src/components/Alert/Alert.module.css +79 -0
  197. package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -0
  198. package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -0
  199. package/templates/app/src/components/Sample/Sample.module.css +11 -0
  200. package/templates/app/src/components/Sample/SampleList.js +61 -0
  201. package/templates/app/src/components/Slider/Slider.css +41 -0
  202. package/templates/app/src/components/Slider/Slider.js +55 -0
  203. package/templates/app/src/containers/AlertContainer/index.js +15 -0
  204. package/templates/app/src/containers/AppContainer/index.js +96 -0
  205. package/templates/app/src/containers/AppContainer/index.module.css +27 -0
  206. package/templates/app/src/containers/CustomMatch/index.js +65 -0
  207. package/templates/app/src/containers/DevTools/index.js +10 -0
  208. package/templates/app/src/containers/Header/index.js +67 -0
  209. package/templates/app/src/containers/Header/index.module.css +43 -0
  210. package/templates/app/src/containers/Redirect/index.js +63 -0
  211. package/templates/app/src/containers/Redirector/index.js +47 -0
  212. package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -0
  213. package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -0
  214. package/templates/app/src/historyChange.js +5 -0
  215. package/templates/app/src/index.html +10 -0
  216. package/templates/app/src/index.js +24 -0
  217. package/templates/app/src/middleware/PromiseMiddleware.js +59 -0
  218. package/templates/app/src/reducers/alertData.js +11 -0
  219. package/templates/app/src/reducers/index.js +6 -0
  220. package/templates/app/src/reducers/samples.js +19 -0
  221. package/templates/app/src/store/configureStore.dev.js +51 -0
  222. package/templates/app/src/store/configureStore.js +5 -0
  223. package/templates/app/src/store/configureStore.prod.js +26 -0
  224. package/templates/app/src/util/Common.js +5 -0
  225. package/templates/app/src/util/RequestAPI.js +132 -0
  226. package/templates/appold/README.md +12 -0
  227. package/templates/appold/app/index.html +8 -0
  228. package/templates/appold/app/properties/ApplicationResources_en_US.properties +1 -0
  229. package/templates/appold/app/properties/i18nkeys.json +3 -0
  230. package/templates/appold/docs/all.html +69 -0
  231. package/templates/appold/mockapi/index.js +13 -0
  232. package/templates/{app → appold}/mockapi/tickets.json +0 -0
  233. package/templates/appold/package.json +17 -0
  234. package/templates/appold/src/components/Text/Text.css +0 -0
  235. package/templates/appold/src/components/Text/Text.js +23 -0
  236. package/templates/appold/src/components/Text/__tests__/Text.spec.js +30 -0
  237. package/templates/appold/src/components/Text/docs/Text__default.docs.js +16 -0
  238. package/templates/appold/src/components/docs.js +1 -0
  239. package/templates/appold/src/components/index.js +5 -0
  240. package/templates/appold/src/index.js +13 -0
  241. package/templates/docs/all.html +1 -1
  242. package/templates/docs/component.html +110 -69
  243. package/templates/docs/components.html +221 -0
  244. package/templates/docs/css/component.css +12 -14
  245. package/templates/docs/css/componentTest.css +7 -0
  246. package/templates/docs/css/style.css +150 -206
  247. package/templates/docs/impactReportTemplate.html +154 -0
  248. package/templates/docs/index.html +1482 -1336
  249. package/templates/library/src/index.js +0 -0
  250. package/.npmignore +0 -3
  251. package/cert/cert.pem +0 -129
  252. package/cert/key.pem +0 -27
  253. package/lib/common/getInsertAt.js +0 -36
  254. package/lib/common/getInsertIntoFunction.js +0 -13
  255. package/lib/configs/webpack.server.config.js +0 -93
  256. package/lib/plugins/ChunkManifestReplacePlugin.js +0 -94
  257. package/lib/plugins/RuntimePublicPathPlugin.js +0 -46
  258. package/lib/rmcntrlm.sh +0 -14
  259. package/lib/servers/nodeServer.js +0 -238
  260. package/lib/templates/HMRTemplate.js +0 -256
  261. package/lib/templates/publicPathTemplate.js +0 -16
  262. package/lib/utils/setConfig.js +0 -14
  263. package/node_modules/history/CHANGES.md +0 -395
  264. package/node_modules/history/DOMUtils.js +0 -3
  265. package/node_modules/history/ExecutionEnvironment.js +0 -3
  266. package/node_modules/history/LICENSE +0 -21
  267. package/node_modules/history/LocationUtils.js +0 -3
  268. package/node_modules/history/PathUtils.js +0 -3
  269. package/node_modules/history/README.md +0 -282
  270. package/node_modules/history/cjs/history.js +0 -933
  271. package/node_modules/history/cjs/history.min.js +0 -1
  272. package/node_modules/history/createBrowserHistory.js +0 -3
  273. package/node_modules/history/createHashHistory.js +0 -3
  274. package/node_modules/history/createMemoryHistory.js +0 -3
  275. package/node_modules/history/createTransitionManager.js +0 -3
  276. package/node_modules/history/es/DOMUtils.js +0 -7
  277. package/node_modules/history/es/ExecutionEnvironment.js +0 -7
  278. package/node_modules/history/es/LocationUtils.js +0 -7
  279. package/node_modules/history/es/PathUtils.js +0 -7
  280. package/node_modules/history/es/createBrowserHistory.js +0 -7
  281. package/node_modules/history/es/createHashHistory.js +0 -7
  282. package/node_modules/history/es/createMemoryHistory.js +0 -7
  283. package/node_modules/history/es/createTransitionManager.js +0 -7
  284. package/node_modules/history/es/warnAboutDeprecatedESMImport.js +0 -35
  285. package/node_modules/history/esm/history.js +0 -904
  286. package/node_modules/history/index.js +0 -7
  287. package/node_modules/history/package.json +0 -134
  288. package/node_modules/history/umd/history.js +0 -1059
  289. package/node_modules/history/umd/history.min.js +0 -1
  290. package/node_modules/history/warnAboutDeprecatedCJSRequire.js +0 -35
  291. package/templates/app/.npmignore +0 -9
  292. package/templates/library/.npmignore +0 -9
@@ -1,42 +1,46 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
- var _fs = require('fs');
3
+ var _fs = _interopRequireDefault(require("fs"));
4
4
 
5
- var _fs2 = _interopRequireDefault(_fs);
5
+ var _utils = require("../utils");
6
6
 
7
- var _utils = require('../utils');
7
+ var _jsonMaker = _interopRequireDefault(require("./jsonMaker"));
8
8
 
9
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
10
 
11
- var unitTestReport = [];
12
- var result = function result(inp) {
13
- var testPathPattern = process.argv[process.argv.length - 1];
11
+ let unitTestReport = [];
12
+
13
+ const result = inp => {
14
+ inp.endTime = Date.now();
15
+ let testPathPattern = process.argv[process.argv.length - 1];
16
+
14
17
  if (testPathPattern.indexOf('--') !== -1) {
15
18
  testPathPattern = '';
16
19
  } else {
17
- testPathPattern = _fs2.default.realpathSync(process.cwd());
20
+ testPathPattern = _fs.default.realpathSync(process.cwd());
18
21
  }
19
- var testPathRegex = new RegExp(testPathPattern);
20
- var testResults = inp.testResults;
21
22
 
22
- var testFilesArr = [];
23
- // for (var i = 0; i < testResults.length; i++) {
24
- testResults.forEach(function (testResult) {
25
- var filePath = testResult.testFilePath;
23
+ let testPathRegex = new RegExp(testPathPattern);
24
+ let {
25
+ testResults
26
+ } = inp;
27
+ let testFilesArr = [];
28
+ testResults.forEach(testResult => {
29
+ let filePath = testResult.testFilePath;
30
+
26
31
  if (!testPathRegex.test(filePath)) {
27
32
  return;
28
33
  }
34
+
29
35
  filePath = filePath.replace('.spec', '');
30
36
  filePath = filePath.replace('/__tests__', '');
31
37
  filePath = filePath.replace('/__test__', '');
32
- var fileJson = {};
38
+ let fileJson = {};
33
39
  fileJson.testPath = testResult.testFilePath;
34
40
  fileJson.sourcePath = filePath;
35
41
  fileJson.data = testResult;
36
42
  testFilesArr.push(fileJson);
37
- testResult.testResults && testResult.testResults.filter(function (t) {
38
- return t.status === 'failed';
39
- }).forEach(function (t) {
43
+ testResult.testResults && testResult.testResults.filter(t => t.status === 'failed').forEach(t => {
40
44
  unitTestReport.push({
41
45
  title: t.title,
42
46
  fullName: t.fullName,
@@ -45,51 +49,97 @@ var result = function result(inp) {
45
49
  });
46
50
  });
47
51
 
48
- var coverageSummary = _fs2.default.readFileSync('./coverage/coverage-summary.json').toString();
52
+ let coverageSummary = _fs.default.readFileSync('./coverage/coverage-summary.json').toString();
53
+
49
54
  if (coverageSummary.indexOf('\\') !== -1) {
50
55
  coverageSummary = coverageSummary.replace(/\\/g, '\\\\');
51
56
  }
52
- var coverageJson = JSON.parse(coverageSummary);
53
- var linesPercent = 0;
54
- var functionPercent = 0;
55
- var statementPerment = 0;
56
- var branchesPercent = 0;
57
- var i = 0;
57
+
58
+ let coverageJson = JSON.parse(coverageSummary);
59
+ let linesPercent = 0;
60
+ let functionPercent = 0;
61
+ let statementPerment = 0;
62
+ let branchesPercent = 0;
63
+ let i = 0;
64
+
58
65
  for (i; i < testFilesArr.length; i++) {
59
- var curSourceFile = testFilesArr[i].sourcePath;
60
- var coverageData = coverageJson[curSourceFile];
66
+ let curSourceFile = testFilesArr[i].sourcePath;
67
+ let coverageData = coverageJson[curSourceFile];
68
+
61
69
  if (!coverageData) {
62
- (0, _utils.log)('Can\'t able to find source for ' + testFilesArr[i].testPath + '\n Or The spec file getting failed during test. Please check the file name and the path is correct for test file or Make them pass.');
70
+ (0, _utils.log)(`Can't able to find source for ${testFilesArr[i].testPath}\n Or The spec file getting failed during test. Please check the file name and the path is correct for test file or Make them pass.`);
63
71
  continue;
64
72
  }
73
+
65
74
  linesPercent += coverageData.lines.pct;
66
75
  functionPercent += coverageData.functions.pct;
67
76
  statementPerment += coverageData.statements.pct;
68
77
  branchesPercent += coverageData.branches.pct;
69
78
  }
70
- var totalLinesPercent = linesPercent / (i * 100) * 100;
71
- var totalFunctionPercent = functionPercent / (i * 100) * 100;
72
- var totalStatementPercent = statementPerment / (i * 100) * 100;
73
- var totalBranchesPercent = branchesPercent / (i * 100) * 100;
74
- var totalPercentage = totalLinesPercent + totalFunctionPercent + totalStatementPercent + totalBranchesPercent;
75
- var coverage = (totalPercentage / 4).toFixed(2);
79
+
80
+ let totalLinesPercent = linesPercent / (i * 100) * 100;
81
+ let totalFunctionPercent = functionPercent / (i * 100) * 100;
82
+ let totalStatementPercent = statementPerment / (i * 100) * 100;
83
+ let totalBranchesPercent = branchesPercent / (i * 100) * 100;
84
+ let totalPercentage = totalLinesPercent + totalFunctionPercent + totalStatementPercent + totalBranchesPercent;
85
+ let coverage = (totalPercentage / 4).toFixed(2);
76
86
  coverage = Number(coverage);
87
+ (0, _jsonMaker.default)(inp, coverage, 'Yes', 'unitcase');
77
88
 
78
89
  if (Number.isNaN(coverage)) {
79
- (0, _utils.log)("This build does't have any JS changes!");
90
+ (0, _utils.log)('This build does\'t have any JS changes!');
80
91
  coverage = 0;
81
92
  } else {
82
- (0, _utils.log)('COVERAGE ' + coverage + '%');
93
+ (0, _utils.log)(`COVERAGE ${coverage}%`);
83
94
  }
84
95
 
85
- var html = '<html>\n\t<head>\n\t<style>\n\t.red{\n\t\tfont-weight:bold;\n\t\tcolor:red;\n\t}\n\t.green{\n\t\tfont-weight:bold;\n\t\tcolor:green;\n\t}\n\ttable\n\t\t{\n font-family: arial, sans-serif;\n border-collapse: collapse;\n\t\t}\n\n\t\ttd, th\n\t\t{\n border: 1px solid #dddddd;\n padding: 8px;\n\t\t}\n\t</style>\n\t</head>\n\t\t<body>\n\t\t\t<table>\n\t\t\t<tr>\n\t\t\t\t<th>Title</th>\n\t\t\t\t<th>FullName</th>\n\t\t\t\t<th>Test Case Path</th>\n\t\t\t</tr>\n\t\t\t' + unitTestReport.map(function (t) {
86
- return '<tr>\n\t\t\t\t\t<td>' + t.title + '</td>\n\t\t\t\t\t<td>' + t.fullName + '</td>\n\t\t\t\t\t<td>' + t.filePath + '</td>\n\t\t\t\t</tr>';
87
- }) + '\n\t\t\t</table>\n\t\t\t<br/>COVERAGE <span class="' + (coverage < 60 ? 'red' : 'green') + '">' + coverage + '%</span> <br/> less than 60% consider failure\n\t\t</body>\n\t</html>\n\t\t';
96
+ let html = `<html>
97
+ <head>
98
+ <style>
99
+ .red{
100
+ font-weight:bold;
101
+ color:red;
102
+ }
103
+ .green{
104
+ font-weight:bold;
105
+ color:green;
106
+ }
107
+ table
108
+ {
109
+ font-family: arial, sans-serif;
110
+ border-collapse: collapse;
111
+ }
112
+
113
+ td, th
114
+ {
115
+ border: 1px solid #dddddd;
116
+ padding: 8px;
117
+ }
118
+ </style>
119
+ </head>
120
+ <body>
121
+ <table>
122
+ <tr>
123
+ <th>Title</th>
124
+ <th>FullName</th>
125
+ <th>Test Case Path</th>
126
+ </tr>
127
+ ${unitTestReport.map(t => `<tr>
128
+ <td>${t.title}</td>
129
+ <td>${t.fullName}</td>
130
+ <td>${t.filePath}</td>
131
+ </tr>`)}
132
+ </table>
133
+ <br/>COVERAGE <span class="${coverage < 60 ? 'red' : 'green'}">${coverage}%</span> <br/> less than 60% consider failure
134
+ </body>
135
+ </html>
136
+ `;
88
137
 
89
- if (!_fs2.default.existsSync('./unittest')) {
90
- _fs2.default.mkdirSync('./unittest');
138
+ if (!_fs.default.existsSync('./unittest')) {
139
+ _fs.default.mkdirSync('./unittest');
91
140
  }
92
- _fs2.default.writeFileSync('./unittest/index.html', html, 'utf8');
141
+
142
+ _fs.default.writeFileSync('./unittest/index.html', html, 'utf8');
93
143
 
94
144
  return inp;
95
145
  };
package/lib/jest/run.js CHANGED
@@ -1,45 +1,92 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
- var _jest = require('jest');
3
+ var _jest = require("jest");
4
4
 
5
- var _jest2 = _interopRequireDefault(_jest);
5
+ var _fs = _interopRequireDefault(require("fs"));
6
6
 
7
- var _utils = require('../utils');
7
+ var _utils = require("../utils");
8
8
 
9
- var _coverageCollector = require('./coverageCollector');
9
+ var _jsonHelper = require("../utils/jsonHelper");
10
10
 
11
- var _coverageCollector2 = _interopRequireDefault(_coverageCollector);
11
+ var _coverageCollector = _interopRequireDefault(require("./coverageCollector"));
12
12
 
13
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
14
 
15
- var options = (0, _utils.getOptions)();
16
- var folder = options.app.folder,
17
- _options$test = options.test,
18
- srcBranch = _options$test.srcBranch,
19
- targetBranch = _options$test.targetBranch,
20
- serviceName = _options$test.serviceName,
21
- impactServerDomain = _options$test.impactServerDomain,
22
- isCommitCoverage = _options$test.isCommitCoverage;
15
+ let options = (0, _utils.getOptions)();
16
+ let {
17
+ app: {
18
+ folder
19
+ },
20
+ test: {
21
+ branchName,
22
+ srcBranch,
23
+ targetBranch,
24
+ serviceName,
25
+ impactServerDomain,
26
+ isCommitCoverage
27
+ }
28
+ } = options;
29
+ let argv = process.argv.slice(2);
23
30
 
31
+ let config = require('../configs/jest.config');
24
32
 
25
- var argv = process.argv.slice(2);
26
-
27
- var config = require('../configs/jest.config');
28
33
  if (isCommitCoverage) {
29
- (0, _coverageCollector2.default)(srcBranch, targetBranch, serviceName, impactServerDomain).then(function () {
30
- var res = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
31
-
34
+ (0, _coverageCollector.default)(srcBranch, targetBranch, serviceName, impactServerDomain).then((res = {}) => {
32
35
  if (res.STATUS) {
33
- argv.push('--findRelatedTests');
34
- argv = argv.concat(res.LIST);
35
- argv = argv.concat(['--config', JSON.stringify(config(null, true))]);
36
- argv.push('--no-cache');
36
+ if (res.LIST.length > 0) {
37
+ let content = {
38
+ FILES: res.LIST
39
+ };
40
+
41
+ if (!_fs.default.existsSync('./coverageTest')) {
42
+ _fs.default.mkdirSync('./coverageTest');
43
+
44
+ _fs.default.writeFileSync('./coverageTest/result.json', JSON.stringify(content), 'utf8');
45
+ } else {
46
+ _fs.default.writeFileSync('./coverageTest/result.json', JSON.stringify(content), 'utf8');
47
+ }
48
+
49
+ argv.push('--findRelatedTests');
50
+ argv = argv.concat(res.LIST);
51
+ argv = argv.concat(['--config', JSON.stringify(config(null, true))]);
52
+ argv.push('--no-cache');
53
+ argv.push('--silent');
54
+ (0, _jest.run)(argv);
55
+ } else {
56
+ (0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, ['tests', 'modifiedFileUnitCase', 'hasChanges'], false); // jsonHelper(
57
+ // `${process.cwd()}/result.json`,
58
+ // 'testInfo.isBuildVerified',
59
+ // true
60
+ // );
61
+
62
+ (0, _jsonHelper.setTestInfoStatus)(`${process.cwd()}/result.json`, true);
63
+ (0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'testInfo.failures', [{
64
+ type: 'modifiedUnitcases',
65
+ message: res.REASON
66
+ }]);
67
+ (0, _utils.log)('No JS changes with last changeset!');
68
+ }
37
69
  } else {
70
+ (0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, ['tests', 'modifiedFileUnitCase', 'isExecuted'], res.STATUS); // jsonHelper(
71
+ // `${process.cwd()}/result.json`,
72
+ // 'testInfo.isBuildVerified',
73
+ // true
74
+ // );
75
+
76
+ (0, _jsonHelper.setTestInfoStatus)(`${process.cwd()}/result.json`, true); // jsonHelper(`${process.cwd()}/result.json`, 'testInfo.failures', [{
77
+ // type: 'modifiedUnitcases',
78
+ // message: res.REASON
79
+ // }]);
80
+
38
81
  (0, _utils.log)(res.REASON);
39
82
  }
40
83
  });
41
84
  } else {
42
- argv.push('--config', JSON.stringify(config(folder)), '--no-cache');
43
- }
44
-
45
- _jest2.default.run(argv);
85
+ if (branchName === 'master' || branchName === null) {
86
+ argv.push('--config', JSON.stringify(config(folder)), '--no-cache');
87
+ (0, _jest.run)(argv);
88
+ } else {
89
+ (0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, ['tests', 'unitCase', 'isExecuted'], 'onlyMaster');
90
+ (0, _utils.log)('Only runs with master branch');
91
+ }
92
+ }
package/lib/jest/setup.js CHANGED
@@ -1,207 +1,208 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
3
+ var _jsdom = require("jsdom");
4
4
 
5
- var _jsdom = require('jsdom');
5
+ var _testUtils = _interopRequireDefault(require("react-dom/test-utils"));
6
6
 
7
- var _testUtils = require('react-dom/test-utils');
7
+ var _react = _interopRequireDefault(require("react"));
8
8
 
9
- var _testUtils2 = _interopRequireDefault(_testUtils);
9
+ var _propTypes = _interopRequireDefault(require("prop-types"));
10
10
 
11
- var _react = require('react');
11
+ var _reactDom = _interopRequireDefault(require("react-dom"));
12
12
 
13
- var _react2 = _interopRequireDefault(_react);
13
+ var _xhr = _interopRequireDefault(require("xhr2"));
14
14
 
15
- var _propTypes = require('prop-types');
16
-
17
- var _propTypes2 = _interopRequireDefault(_propTypes);
18
-
19
- var _reactDom = require('react-dom');
20
-
21
- var _reactDom2 = _interopRequireDefault(_reactDom);
22
-
23
- var _xhr = require('xhr2');
24
-
25
- var _xhr2 = _interopRequireDefault(_xhr);
26
-
27
- var _nock = require('nock');
28
-
29
- var _nock2 = _interopRequireDefault(_nock);
15
+ var _nock = _interopRequireDefault(require("nock"));
30
16
 
31
17
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
32
18
 
33
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
34
-
35
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
36
-
37
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } //$Id$//
38
-
39
-
40
- var mockDomain = 'htt' + 'p://zoho.com';
41
- var document = new _jsdom.JSDOM('').window.document;
42
-
19
+ //$Id$//
20
+ let mockDomain = 'htt' + 'p://zoho.com';
21
+ const {
22
+ document
23
+ } = new _jsdom.JSDOM('').window;
43
24
  global.document = document;
44
25
  global.window = document.defaultView;
45
26
  global.navigator = global.window.navigator;
46
27
  global.localStorage = global.sessionStorage = {
47
- getItem: function getItem(key) {
28
+ getItem(key) {
48
29
  return this[key];
49
30
  },
50
- setItem: function setItem(key, value) {
31
+
32
+ setItem(key, value) {
51
33
  if (value.length > 100) {
52
34
  throw new Error('Data size is too exceeded');
53
35
  }
36
+
54
37
  this[key] = value;
55
38
  },
56
- removeItem: function removeItem(key) {
39
+
40
+ removeItem(key) {
57
41
  delete this[key];
58
42
  },
59
- clear: function clear() {
60
- var keys = ['getItem', 'setItem', 'removeItem', 'clear'];
61
- for (var key in this) {
43
+
44
+ clear() {
45
+ let keys = ['getItem', 'setItem', 'removeItem', 'clear'];
46
+
47
+ for (let key in this) {
62
48
  if (keys.indexOf(key) === -1) {
63
49
  delete this[key];
64
50
  }
65
51
  }
66
52
  }
53
+
67
54
  };
68
55
  global.ZE_Init = {};
56
+
69
57
  global.String.prototype.contains = function (text) {
70
58
  return this.indexOf(text) != -1;
71
59
  };
72
- global.TestUtils = _testUtils2.default;
73
- var xmlReq = _xhr2.default;
60
+
61
+ global.TestUtils = _testUtils.default;
62
+ let xmlReq = _xhr.default;
63
+
74
64
  window.XMLHttpRequest = function () {
75
- var xmlReqCopy = new xmlReq();
76
- var originalOpen = xmlReqCopy.open;
65
+ let xmlReqCopy = new xmlReq();
66
+ let originalOpen = xmlReqCopy.open;
67
+
77
68
  xmlReqCopy.open = function () {
78
69
  if (arguments[1].indexOf('http') != 0) {
79
70
  arguments[1] = mockDomain + arguments[1];
80
71
  }
72
+
81
73
  return originalOpen.apply(this, arguments);
82
74
  };
75
+
83
76
  return xmlReqCopy;
84
77
  };
85
78
 
86
- _testUtils2.default.scryRenderedComponentsWithTestid = function (dom, name) {
87
- var componentList = _testUtils2.default.findAllInRenderedTree(dom, function (i, j) {
88
- if (_testUtils2.default.isDOMComponent(i)) {
89
- var val = i.getAttribute('data-id');
79
+ _testUtils.default.scryRenderedComponentsWithTestid = function (dom, name) {
80
+ let componentList = _testUtils.default.findAllInRenderedTree(dom, (i, j) => {
81
+ if (_testUtils.default.isDOMComponent(i)) {
82
+ let val = i.getAttribute('data-id');
83
+
90
84
  if (typeof val !== 'undefined' && val == name) {
91
85
  return true;
92
86
  }
87
+
93
88
  return false;
94
89
  }
95
90
  });
91
+
96
92
  return componentList;
97
93
  };
98
94
 
99
- _testUtils2.default.findRenderedComponentsWithTestid = function (dom, name) {
100
- var list = _testUtils2.default.scryRenderedComponentsWithTestid(dom, name);
95
+ _testUtils.default.findRenderedComponentsWithTestid = function (dom, name) {
96
+ let list = _testUtils.default.scryRenderedComponentsWithTestid(dom, name);
97
+
101
98
  if (list.length !== 1) {
102
- throw new Error('Did not find exactly one match (found: ' + list.length + ') ' + ('for data-id:' + name));
99
+ throw new Error(`Did not find exactly one match (found: ${list.length}) ` + `for data-id:${name}`);
103
100
  }
101
+
104
102
  return list[0];
105
103
  };
106
104
 
107
105
  global.render = function (Component, props) {
108
- var renderedDOM = _testUtils2.default.renderIntoDocument(_react2.default.createElement(Component, props));
106
+ const renderedDOM = _testUtils.default.renderIntoDocument( /*#__PURE__*/_react.default.createElement(Component, props));
107
+
109
108
  return {
110
- props: props,
111
- renderedDOM: renderedDOM
109
+ props,
110
+ renderedDOM
112
111
  };
113
112
  };
114
113
 
115
114
  global.setup = function (Component, props, state) {
116
- var router = {
115
+ let router = {
117
116
  router: {
118
- push: function push() {},
119
- createHref: function createHref(ob) {
117
+ push() {},
118
+
119
+ createHref(ob) {
120
120
  return ob.pathname;
121
121
  },
122
- isActive: function isActive() {
122
+
123
+ isActive() {
123
124
  return true;
124
125
  },
125
- replace: function replace() {},
126
- go: function go() {},
127
- goBack: function goBack() {},
128
- goForward: function goForward() {},
129
- setRouteLeaveHook: function setRouteLeaveHook() {},
130
- getState: function getState() {}
126
+
127
+ replace() {},
128
+
129
+ go() {},
130
+
131
+ goBack() {},
132
+
133
+ goForward() {},
134
+
135
+ setRouteLeaveHook() {},
136
+
137
+ getState() {}
138
+
131
139
  },
132
140
  store: {
133
- getState: function getState() {
141
+ getState() {
134
142
  return state;
135
143
  }
144
+
136
145
  }
137
- };
138
- // var store = {
146
+ }; // var store = {
139
147
  // store:{
140
148
  // getState:function(){return state;}
141
149
  // }
142
150
  // }
151
+
143
152
  var Component = higherComponent(Component, router);
144
- var renderedDOM = _testUtils2.default.renderIntoDocument(_react2.default.createElement(Component, props), router);
153
+
154
+ const renderedDOM = _testUtils.default.renderIntoDocument( /*#__PURE__*/_react.default.createElement(Component, props), router);
155
+
145
156
  return {
146
- props: props,
147
- renderedDOM: renderedDOM
157
+ props,
158
+ renderedDOM
148
159
  };
149
160
  };
150
161
 
151
162
  function higherComponent(ActualComponent, context) {
152
163
  if (context) {
153
- var HigherComponent = function (_React$Component) {
154
- _inherits(HigherComponent, _React$Component);
164
+ class HigherComponent extends _react.default.Component {
165
+ constructor() {
166
+ super();
167
+ }
155
168
 
156
- function HigherComponent() {
157
- _classCallCheck(this, HigherComponent);
169
+ getChildContext() {
170
+ return context;
171
+ }
158
172
 
159
- return _possibleConstructorReturn(this, (HigherComponent.__proto__ || Object.getPrototypeOf(HigherComponent)).call(this));
173
+ render() {
174
+ return /*#__PURE__*/_react.default.createElement(ActualComponent, this.props);
160
175
  }
161
176
 
162
- _createClass(HigherComponent, [{
163
- key: 'getChildContext',
164
- value: function getChildContext() {
165
- return context;
166
- }
167
- }, {
168
- key: 'render',
169
- value: function render() {
170
- return _react2.default.createElement(ActualComponent, this.props);
171
- }
172
- }]);
173
-
174
- return HigherComponent;
175
- }(_react2.default.Component);
177
+ }
176
178
 
177
179
  HigherComponent.childContextTypes = {
178
- router: _propTypes2.default.any,
179
- store: _propTypes2.default.any
180
+ router: _propTypes.default.any,
181
+ store: _propTypes.default.any
180
182
  };
181
-
182
183
  return HigherComponent;
183
184
  }
185
+
184
186
  return ActualComponent;
185
187
  }
188
+
186
189
  global.window.matchMedia = window.matchMedia || function () {
187
190
  return {
188
191
  matches: false,
189
- addListener: function addListener() {},
190
- removeListener: function removeListener() {}
192
+
193
+ addListener() {},
194
+
195
+ removeListener() {}
196
+
191
197
  };
192
- };
193
- // global.renderHTML = function(comp) {
198
+ }; // global.renderHTML = function(comp) {
194
199
  // return ReactDOM.findDOMNode(comp);
195
200
  // };
196
201
 
197
- global.TestUtils = _testUtils2.default;
202
+
203
+ global.TestUtils = _testUtils.default;
198
204
  global.XMLHttpRequest = window.XMLHttpRequest;
205
+
199
206
  global.getI18NValue = function (inp) {
200
207
  return inp;
201
- };
202
-
203
- var hook = require('css-modules-require-hook');
204
-
205
- hook({
206
- generateScopedName: '[name]__[local]___[hash:base64:5]'
207
- });
208
+ };