@zohodesk/react-cli 0.0.1-beta.98 → 0.0.1-betaa.138.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 (139) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/README.md +149 -0
  3. package/bin/cli.js +34 -29
  4. package/files/eslintrc.js +57 -0
  5. package/files/prettierrc.js +3 -0
  6. package/lib/babel/cmjs-plugins-presets.js +16 -9
  7. package/lib/babel/es-plugins-presets.js +26 -14
  8. package/lib/common/getEntries.js +31 -22
  9. package/lib/common/getPublicPathConfig.js +27 -13
  10. package/lib/common/index.js +21 -25
  11. package/lib/common/splitChunks.js +62 -53
  12. package/lib/common/templateParameters.js +10 -8
  13. package/lib/configs/jest.config.js +15 -25
  14. package/lib/configs/webpack.component.umd.config.js +31 -37
  15. package/lib/configs/webpack.css.umd.config.js +44 -47
  16. package/lib/configs/webpack.dev.config.js +70 -52
  17. package/lib/configs/webpack.docs.config.js +106 -106
  18. package/lib/configs/webpack.prod.config.js +95 -75
  19. package/lib/hooks/docsProptypeHook.js +32 -38
  20. package/lib/jest/commitedFilesResult.js +103 -74
  21. package/lib/jest/coverageCollector.js +41 -21
  22. package/lib/jest/jsonMaker.js +15 -16
  23. package/lib/jest/preProcessors/cssPreprocessor.js +16 -18
  24. package/lib/jest/preProcessors/jsPreprocessor.js +3 -5
  25. package/lib/jest/preProcessors/otherFilesPreprocessor.js +5 -6
  26. package/lib/jest/result.js +90 -45
  27. package/lib/jest/run.js +43 -43
  28. package/lib/jest/setup.js +102 -95
  29. package/lib/loaderUtils/getCSSLoaders.js +21 -22
  30. package/lib/loaderUtils/getDevJsLoaders.js +25 -23
  31. package/lib/loaderUtils/index.js +11 -13
  32. package/lib/loaders/docsLoader.js +15 -15
  33. package/lib/loaders/docsPropsLoader.js +14 -17
  34. package/lib/loaders/fileLoader.js +33 -35
  35. package/lib/loaders/scriptInstrumentLoader.js +21 -20
  36. package/lib/loaders/workerLoader.js +136 -0
  37. package/lib/middlewares/HMRMiddleware.js +54 -45
  38. package/lib/middlewares/SSTMiddleware.js +8 -5
  39. package/lib/pluginUtils/getDevPlugins.js +114 -52
  40. package/lib/pluginUtils/getDocsPlugins.js +25 -29
  41. package/lib/pluginUtils/getLibraryPlugins.js +8 -10
  42. package/lib/pluginUtils/getProdPlugins.js +163 -74
  43. package/lib/pluginUtils/getServerPlugins.js +8 -11
  44. package/lib/pluginUtils/getUMDCSSPlugins.js +11 -15
  45. package/lib/pluginUtils/getUMDComponentPlugins.js +11 -15
  46. package/lib/pluginUtils/index.js +36 -43
  47. package/lib/plugins/CdnChangePlugin.js +63 -0
  48. package/lib/plugins/CleanupStatsPlugin.js +18 -32
  49. package/lib/plugins/CustomAttributePlugin.js +79 -0
  50. package/lib/plugins/CustomAttributePlugin.md +35 -0
  51. package/lib/plugins/EFCPlugin.js +185 -0
  52. package/lib/plugins/I18NInjectIntoIndexPlugin.js +118 -52
  53. package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +60 -0
  54. package/lib/plugins/I18nSplitPlugin/I18nDependency.js +44 -0
  55. package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +266 -0
  56. package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +183 -0
  57. package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +100 -0
  58. package/lib/plugins/I18nSplitPlugin/I18nSplit.md +86 -0
  59. package/lib/plugins/I18nSplitPlugin/README.md +25 -0
  60. package/lib/plugins/I18nSplitPlugin/index.js +185 -0
  61. package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +64 -0
  62. package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +13 -0
  63. package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +26 -0
  64. package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +40 -0
  65. package/lib/plugins/I18nSplitPlugin/utils/index.js +31 -0
  66. package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +112 -0
  67. package/lib/plugins/ManifestPlugin.js +52 -63
  68. package/lib/plugins/ModuleStatsPlugin.js +83 -173
  69. package/lib/plugins/OptimizeJSPlugin.js +24 -41
  70. package/lib/plugins/PublicPathCallbackPlugin.js +42 -116
  71. package/lib/plugins/PublicPathChangePlugin.js +175 -284
  72. package/lib/plugins/ReportGeneratePlugin.js +150 -151
  73. package/lib/plugins/ResourceHintsPlugin.js +53 -35
  74. package/lib/plugins/ScriptInstrumentPlugin.js +22 -37
  75. package/lib/plugins/ServiceWorkerPlugin.js +81 -57
  76. package/lib/plugins/ShadowDOMSupportPlugin.js +153 -234
  77. package/lib/plugins/SourceMapHookPlugin.js +21 -33
  78. package/lib/plugins/TPHashMappingPlugin.js +67 -0
  79. package/lib/plugins/UglifyCSSPlugin.js +23 -30
  80. package/lib/plugins/UnusedFilesFindPlugin.js +137 -152
  81. package/lib/plugins/index.js +100 -91
  82. package/lib/plugins/webpackwatchrunplugin.js +18 -30
  83. package/lib/postcss-plugins/ExcludeRTLPlugin.js +14 -17
  84. package/lib/schemas/index.js +336 -81
  85. package/lib/servers/clusterHubServer.js +22 -26
  86. package/lib/servers/docsServer.js +3 -5
  87. package/lib/servers/docsServerCore.js +84 -91
  88. package/lib/servers/helpServer.js +19 -21
  89. package/lib/servers/impactServer.js +99 -92
  90. package/lib/servers/mockserver.js +24 -24
  91. package/lib/servers/scrServer.js +78 -98
  92. package/lib/servers/server.js +101 -122
  93. package/lib/servers/ssServer.js +63 -61
  94. package/lib/sh/reportPublish.sh +1 -2
  95. package/lib/templates/CoverageScriptTemplate.js +45 -18
  96. package/lib/templates/WMSTemplate.js +17 -18
  97. package/lib/templates/linterConstant.js +6 -4
  98. package/lib/utils/babelPresets.js +12 -5
  99. package/lib/utils/clean.js +12 -11
  100. package/lib/utils/copy.js +12 -34
  101. package/lib/utils/copyTimezones.js +9 -16
  102. package/lib/utils/createEventStream.js +24 -19
  103. package/lib/utils/cssClassNameGenerate.js +44 -73
  104. package/lib/utils/cssURLReplacer.js +62 -56
  105. package/lib/utils/dependencyPostPublish.js +20 -19
  106. package/lib/utils/fileUtils.js +66 -54
  107. package/lib/utils/folderIterator.js +20 -21
  108. package/lib/utils/getComponents.js +70 -27
  109. package/lib/utils/getCurrentBranch.js +11 -17
  110. package/lib/utils/getDependenciesImpactList.js +114 -187
  111. package/lib/utils/getHash.js +9 -13
  112. package/lib/utils/getIp.js +9 -9
  113. package/lib/utils/getOptions.js +26 -29
  114. package/lib/utils/getServerURL.js +19 -10
  115. package/lib/utils/index.js +147 -126
  116. package/lib/utils/init.js +2 -2
  117. package/lib/utils/initPreCommitHook.js +40 -32
  118. package/lib/utils/jsonHelper.js +37 -21
  119. package/lib/utils/lint/addScripts.js +27 -0
  120. package/lib/utils/lint/checkExistingConfig.js +67 -0
  121. package/lib/utils/lint/copyConfigs.js +24 -0
  122. package/lib/utils/lint/index.js +54 -0
  123. package/lib/utils/lint/lintScripts.js +11 -0
  124. package/lib/utils/lint/lintSetup.js +31 -0
  125. package/lib/utils/lint/lintStagedPreCommitHook.js +7 -0
  126. package/lib/utils/lint/question.js +30 -0
  127. package/lib/utils/lintReporter.js +70 -56
  128. package/lib/utils/mailSender.js +12 -27
  129. package/lib/utils/pullOrigin.js +21 -18
  130. package/lib/utils/reinstallDependencies.js +76 -85
  131. package/lib/utils/removeAttributes.js +25 -23
  132. package/lib/utils/repoClone.js +47 -45
  133. package/lib/utils/request.js +64 -77
  134. package/lib/utils/rtl.js +22 -29
  135. package/lib/utils/setEnvVariables.js +5 -6
  136. package/lib/utils/ssTestHack.js +21 -19
  137. package/lib/utils/switchBranch.js +21 -20
  138. package/lib/utils/urlConcat.js +22 -0
  139. package/package.json +72 -67
@@ -1,171 +1,200 @@
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
- var _jsonMaker = require('./jsonMaker');
10
-
11
- var _jsonMaker2 = _interopRequireDefault(_jsonMaker);
12
-
13
- var _jsonHelper = require('../utils/jsonHelper');
9
+ var _jsonHelper = require("../utils/jsonHelper");
14
10
 
15
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
12
 
17
- var result = function result(inp) {
13
+ let result = inp => {
18
14
  inp.endTime = Date.now();
19
- var testPathPattern = process.argv[process.argv.length - 1];
15
+ let testPathPattern = process.argv[process.argv.length - 1];
20
16
 
21
17
  if (testPathPattern.indexOf('--') !== -1) {
22
18
  testPathPattern = '';
23
19
  } else {
24
- testPathPattern = _fs2.default.realpathSync(process.cwd());
20
+ testPathPattern = _fs.default.realpathSync(process.cwd());
25
21
  }
26
- var testPathRegex = new RegExp(testPathPattern);
27
- var testResults = inp.testResults;
28
22
 
29
- var testFilesArr = [];
30
- var testCaseFiles = [];
31
- var jsonData = void 0;
23
+ let testPathRegex = new RegExp(testPathPattern);
24
+ let {
25
+ testResults
26
+ } = inp;
27
+ let testFilesArr = [];
28
+ let testCaseFiles = [];
29
+ let jsonData;
32
30
 
33
- if (_fs2.default.existsSync('./coverageTest/result.json')) {
34
- jsonData = JSON.parse(_fs2.default.readFileSync('./coverageTest/result.json', 'utf8'));
31
+ if (_fs.default.existsSync('./coverageTest/result.json')) {
32
+ jsonData = JSON.parse(_fs.default.readFileSync('./coverageTest/result.json', 'utf8'));
35
33
  }
36
- testResults.forEach(function (testResult) {
37
- var filePath = testResult.testFilePath;
34
+
35
+ testResults.forEach(testResult => {
36
+ let filePath = testResult.testFilePath;
38
37
 
39
38
  if (!testPathRegex.test(filePath)) {
40
39
  return;
41
40
  }
41
+
42
42
  filePath = filePath.replace('.spec', '');
43
43
  filePath = filePath.replace('/__tests__', '');
44
44
  filePath = filePath.replace('/__test__', '');
45
- var relatPath = filePath.replace(process.cwd(), '').substring(1);
46
- var fileJson = {};
45
+ let relatPath = filePath.replace(process.cwd(), '').substring(1);
46
+ let fileJson = {};
47
47
  fileJson.testPath = testResult.testFilePath;
48
48
  fileJson.sourcePath = filePath;
49
49
  fileJson.data = testResult;
50
50
  testFilesArr.push(fileJson);
51
+
51
52
  if (jsonData.FILES.includes(relatPath) || jsonData.FILES.includes(testResult.testFilePath.replace(process.cwd(), ''))) {
52
53
  jsonData.FILES.includes(relatPath) ? testCaseFiles.push(relatPath) : jsonData.FILES.includes(testResult.testFilePath.replace(process.cwd(), '')) ? testCaseFiles.push(testResult.testFilePath.replace(process.cwd(), '')) : '';
53
54
  }
54
55
  });
55
- var coverageSummary = {};
56
- if (_fs2.default.existsSync('./commitCoverage/coverage-summary.json')) {
57
- coverageSummary = _fs2.default.readFileSync('./commitCoverage/coverage-summary.json').toString();
56
+ let coverageSummary = {};
57
+
58
+ if (_fs.default.existsSync('./commitCoverage/coverage-summary.json')) {
59
+ coverageSummary = _fs.default.readFileSync('./commitCoverage/coverage-summary.json').toString();
60
+
58
61
  if (coverageSummary.indexOf('\\') !== -1) {
59
62
  coverageSummary = coverageSummary.replace(/\\/g, '\\\\');
60
63
  }
61
64
  }
62
65
 
63
- var excludeTestArray = '{}';
64
- if (_fs2.default.existsSync('./__testUtils__/conf/excludeTest.json')) {
65
- excludeTestArray = _fs2.default.readFileSync('./__testUtils__/conf/excludeTest.json').toString();
66
+ let excludeTestArray = '{}';
67
+
68
+ if (_fs.default.existsSync('./__testUtils__/conf/excludeTest.json')) {
69
+ excludeTestArray = _fs.default.readFileSync('./__testUtils__/conf/excludeTest.json').toString();
70
+
66
71
  if (excludeTestArray.indexOf('\\') !== -1) {
67
72
  excludeTestArray = excludeTestArray.replace(/\\/g, '\\\\');
68
73
  }
69
74
  }
70
75
 
71
- var coverageJson = JSON.parse(coverageSummary);
72
- var linesPercent = 0;
73
- var functionPercent = 0;
74
- var statementPerment = 0;
75
- var branchesPercent = 0;
76
+ let coverageJson = JSON.parse(coverageSummary);
77
+ let linesPercent = 0;
78
+ let functionPercent = 0;
79
+ let statementPerment = 0;
80
+ let branchesPercent = 0;
81
+ let fileList = '<h4>Changed files in last code check-in</h4><ul>';
82
+ let i = 0;
83
+ let excludeTestJSON = JSON.parse(excludeTestArray);
76
84
 
77
- var fileList = '<h4>Changed files in last code check-in</h4><ul>';
78
- var i = 0;
79
- var excludeTestJSON = JSON.parse(excludeTestArray);
80
85
  if (Object.keys(excludeTestArray).length > 0) {
81
86
  jsonData.FILES = jsonData.FILES.filter(function (value) {
82
87
  if (!excludeTestJSON.test.exclude.includes(value)) {
88
+ let excludeDir = excludeTestJSON.test.exclude.filter(function (excludeFile) {
89
+ if (value.indexOf(excludeFile) > -1) {
90
+ return value;
91
+ }
92
+ });
93
+
94
+ if (excludeDir.length > 0) {
95
+ return null;
96
+ }
97
+
83
98
  return value;
84
99
  }
100
+
85
101
  return null;
86
102
  });
87
103
  }
88
104
 
89
- var _loop = function _loop() {
90
- var coverageData = void 0;
91
- var curSourceFile = jsonData.FILES[i];
105
+ for (i; i < jsonData.FILES.length; i++) {
106
+ let coverageData;
107
+ let curSourceFile = jsonData.FILES[i];
92
108
  curSourceFile.replace(process.cwd(), '').substring(1);
93
- fileList = fileList + '<li>' + curSourceFile + '</li>';
94
- Object.keys(coverageJson).forEach(function (coverageFile) {
109
+ fileList = `${fileList}<li>${curSourceFile}</li>`;
110
+ Object.keys(coverageJson).forEach(coverageFile => {
95
111
  if (coverageFile.includes(curSourceFile) || coverageFile === 'total') {
96
112
  coverageData = coverageJson[coverageFile];
97
113
  }
98
114
  });
99
115
 
100
116
  if (!coverageData) {
101
- (0, _utils.log)('Can\'t able to find source for ' + testFilesArr[i].testPath + '\n Please check the file name and the path is correct for test file');
102
- return 'continue';
117
+ (0, _utils.log)(`Can't able to find source for ${testFilesArr[i].testPath}\n Please check the file name and the path is correct for test file`);
118
+ continue;
103
119
  }
120
+
104
121
  linesPercent += coverageData.lines.pct;
105
122
  functionPercent += coverageData.functions.pct;
106
123
  statementPerment += coverageData.statements.pct;
107
124
  branchesPercent += coverageData.branches.pct;
108
- };
125
+ }
109
126
 
110
- for (i; i < jsonData.FILES.length; i++) {
111
- var _ret = _loop();
127
+ fileList = `${fileList}</ul>`;
112
128
 
113
- if (_ret === 'continue') continue;
114
- }
115
- fileList = fileList + '</ul>';
116
- if (!testFilesArr.length) {
129
+ if (!jsonData.FILES.length) {
117
130
  fileList = '<div></div>';
118
131
  }
119
- var uncoveredList = '<h4>Uncovered files :- </h4><ul>';
120
- uncoveredList = uncoveredList + '</ul>';
121
- var fileCoverage = testCaseFiles.length / jsonData.FILES.length * 100;
132
+
133
+ let uncoveredList = '<h4>Uncovered files :- </h4><ul>';
134
+ let fileCoverage = 0;
135
+
136
+ if (jsonData.FILES.length > 0) {
137
+ fileCoverage = testCaseFiles.length / jsonData.FILES.length * 100;
138
+ }
139
+
122
140
  fileCoverage = fileCoverage.toFixed(2);
123
141
  fileCoverage = Number(fileCoverage);
142
+
124
143
  if (Number.isNaN(fileCoverage)) {
125
144
  (0, _utils.log)('This build does\'t have any JS changes!');
126
145
  fileCoverage = 0;
127
146
  } else {
128
- (0, _utils.log)('FileCoverage ' + fileCoverage + '%');
147
+ (0, _utils.log)(`FileCoverage ${fileCoverage}%`);
129
148
  }
130
149
 
131
- var totalLinesPercent = linesPercent / (i * 100) * 100;
132
- var totalFunctionPercent = functionPercent / (i * 100) * 100;
133
- var totalStatementPercent = statementPerment / (i * 100) * 100;
134
- var totalBranchesPercent = branchesPercent / (i * 100) * 100;
135
- var totalPercentage = totalLinesPercent + totalFunctionPercent + totalStatementPercent + totalBranchesPercent;
136
- var coverage = (totalPercentage / 4).toFixed(2);
150
+ let totalLinesPercent = linesPercent / (i * 100) * 100;
151
+ let totalFunctionPercent = functionPercent / (i * 100) * 100;
152
+ let totalStatementPercent = statementPerment / (i * 100) * 100;
153
+ let totalBranchesPercent = branchesPercent / (i * 100) * 100;
154
+ let totalPercentage = totalLinesPercent + totalFunctionPercent + totalStatementPercent + totalBranchesPercent;
155
+ let coverage = (totalPercentage / 4).toFixed(2);
137
156
  coverage = Number(coverage);
157
+
138
158
  if (Number.isNaN(coverage)) {
139
- (0, _jsonHelper.jsonHelper)(process.cwd() + '/result.json', 'tests.modifiedFileUnitCase.testInfo', 'can\'t get coverage for this test');
159
+ (0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'tests.modifiedFileUnitCase.testInfo', 'can\'t get coverage for this test');
140
160
  coverage = 0;
161
+ uncoveredList = uncoveredList + 'No Component changes with this build, You can proceed this build </ul>';
141
162
  } else {
142
- (0, _jsonMaker2.default)(inp, coverage, true, 'modifiedFileUnitCase', fileCoverage);
143
- (0, _jsonHelper.jsonHelper)(process.cwd() + '/result.json', 'tests.modifiedFileUnitCase.isBuildVerified', coverage > 60);
144
- (0, _jsonHelper.jsonHelper)(process.cwd() + '/result.json', 'tests.modifiedFileUnitCase.testInfo', 'Test coverage value generated');
145
- // jsonHelper(
163
+ (0, _jsonMaker.default)(inp, coverage, true, 'modifiedFileUnitCase', fileCoverage);
164
+ (0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'tests.modifiedFileUnitCase.isBuildVerified', coverage > 60);
165
+ (0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'tests.modifiedFileUnitCase.testInfo', 'Test coverage value generated'); // jsonHelper(
146
166
  // `${process.cwd()}/result.json`,
147
167
  // 'testInfo.isBuildVerified',
148
168
  // coverage > 60
149
169
  // );
150
- (0, _jsonHelper.setTestInfoStatus)(process.cwd() + '/result.json', true /*coverage > 60*/);
170
+
171
+ (0, _jsonHelper.setTestInfoStatus)(`${process.cwd()}/result.json`, true
172
+ /*coverage > 60*/
173
+ );
174
+
151
175
  if (coverage < 60) {
152
- (0, _jsonHelper.jsonHelper)(process.cwd() + '/result.json', 'testInfo.failures', [{
176
+ (0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'testInfo.failures', [{
153
177
  type: 'modifiedUnitcases',
154
178
  message: 'Need to cover 60% above for changed files'
155
179
  }]);
180
+ uncoveredList = uncoveredList + 'Ask developer to cover 60% above for changed files </ul>';
181
+ } else {
182
+ uncoveredList = uncoveredList + 'You can proceed this build </ul>';
156
183
  }
157
184
 
158
- (0, _utils.log)('COVERAGE ' + coverage + '%');
185
+ (0, _utils.log)(`COVERAGE ${coverage}%`);
159
186
  }
160
187
 
161
- var html = '<html><head><style>.red{font-weight:bold;color:red;}.green{font-weight:bold;color:green;}</style></head><body><br/>CODE COVERAGE <span class="' + (coverage < 60 ? 'red' : 'green') + '">' + coverage + '%</span> <br/> less than 60% consider failure<br/><br/> FILE COVERAGE:<span class="' + (fileCoverage < 60 ? 'red' : 'green') + '">' + fileCoverage + '%</span> <br/> less than 60% consider failure' + fileList + uncoveredList + '</body></html>';
188
+ let html = `<html><head><style>.red{font-weight:bold;color:red;}.green{font-weight:bold;color:green;}</style></head><body><br/>CODE COVERAGE <span class="${coverage < 60 ? 'red' : 'green'}">${coverage}%</span> <br/> less than 60% consider failure<br/><br/> FILE COVERAGE:<span class="${fileCoverage < 60 ? 'red' : 'green'}">${fileCoverage}%</span> <br/> less than 60% consider failure${fileList}${uncoveredList}</body></html>`;
189
+
190
+ if (!_fs.default.existsSync('./coverageTest')) {
191
+ _fs.default.mkdirSync('./coverageTest');
162
192
 
163
- if (!_fs2.default.existsSync('./coverageTest')) {
164
- _fs2.default.mkdirSync('./coverageTest');
165
- _fs2.default.writeFileSync('./coverageTest/index.html', html, 'utf8');
193
+ _fs.default.writeFileSync('./coverageTest/index.html', html, 'utf8');
166
194
  } else {
167
- _fs2.default.writeFileSync('./coverageTest/index.html', html, 'utf8');
195
+ _fs.default.writeFileSync('./coverageTest/index.html', html, 'utf8');
168
196
  }
197
+
169
198
  return inp;
170
199
  };
171
200
 
@@ -1,21 +1,21 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
- var _path = require('path');
3
+ var _path = _interopRequireDefault(require("path"));
4
4
 
5
- var _path2 = _interopRequireDefault(_path);
6
-
7
- var _utils = require('../utils');
5
+ var _utils = require("../utils");
8
6
 
9
7
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
8
 
11
9
  function jsFileFilter(listOfObject) {
12
- var fileNameList = [];
13
- var curListName = process.cwd().split(_path2.default.sep);
14
- var currentDirName = curListName[curListName.length - 1];
15
- listOfObject.forEach(function (fileObj) {
16
- var fileName = fileObj.FILEPATH;
10
+ let fileNameList = [];
11
+ let curListName = process.cwd().split(_path.default.sep);
12
+ let currentDirName = curListName[curListName.length - 1];
13
+ listOfObject.forEach(fileObj => {
14
+ let fileName = fileObj.FILEPATH;
15
+
17
16
  if (fileName.includes(currentDirName)) {
18
17
  fileName = fileName.split(currentDirName + '/')[1]; //eslint-disable-line
18
+
19
19
  if (fileName.includes('.js') && !fileName.includes('.json') && !fileName.includes('.docs.js') && !fileName.includes('.spec.js')) {
20
20
  fileNameList.push(fileName);
21
21
  }
@@ -25,28 +25,32 @@ function jsFileFilter(listOfObject) {
25
25
  }
26
26
 
27
27
  function coverage(devBranch, compareWith, serviceName, domain) {
28
- return new Promise(function (resolve) {
28
+ return new Promise(resolve => {
29
29
  (0, _utils.request)({
30
- url: domain + '/impact/ImpactModuleAction.do?action=getCommitDiffFileDetail&serviceName=' + serviceName + '&masterBranchCommitHash=' + compareWith + '&buildCommitHash=' + devBranch
31
- }).then(function (_ref) {
32
- var body = _ref.body;
30
+ url: `${domain}/impact/ImpactModuleAction.do?action=getCommitDiffFileDetail&serviceName=${serviceName}&masterBranchCommitHash=${compareWith}&buildCommitHash=${devBranch}`
31
+ }).then(({
32
+ body
33
+ }) => {
34
+ let res = JSON.parse(body);
33
35
 
34
- var res = JSON.parse(body);
35
36
  if (Object.keys(res).length > 0) {
36
37
  if (Object.prototype.hasOwnProperty.call(res, 'STATUS')) {
37
38
  if (res.STATUS) {
38
- var listOfFiles = [];
39
+ let listOfFiles = [];
40
+
39
41
  if (Object.keys(res.DIFF_FILES).length > 0) {
40
42
  if (Object.prototype.hasOwnProperty.call(res.DIFF_FILES, 'ADDED')) {
41
43
  if (res.DIFF_FILES.ADDED.length > 0) {
42
44
  listOfFiles = listOfFiles.concat(jsFileFilter(res.DIFF_FILES.ADDED));
43
45
  }
44
46
  }
47
+
45
48
  if (Object.prototype.hasOwnProperty.call(res.DIFF_FILES, 'UPDATED')) {
46
49
  if (res.DIFF_FILES.UPDATED.length > 0) {
47
50
  listOfFiles = listOfFiles.concat(jsFileFilter(res.DIFF_FILES.UPDATED));
48
51
  }
49
52
  }
53
+
50
54
  if (listOfFiles.length > 0) {
51
55
  resolve({
52
56
  STATUS: true,
@@ -68,17 +72,33 @@ function coverage(devBranch, compareWith, serviceName, domain) {
68
72
  });
69
73
  }
70
74
  } else {
71
- resolve({ STATUS: false, LIST: [], REASON: 'Internal Error' });
75
+ resolve({
76
+ STATUS: false,
77
+ LIST: [],
78
+ REASON: 'Internal Error'
79
+ });
72
80
  }
73
81
  } else {
74
- resolve({ STATUS: false, LIST: [], REASON: 'Internal Error' });
82
+ resolve({
83
+ STATUS: false,
84
+ LIST: [],
85
+ REASON: 'Internal Error'
86
+ });
75
87
  }
76
88
  } else {
77
- resolve({ STATUS: false, LIST: [], REASON: 'Internal Error' });
89
+ resolve({
90
+ STATUS: false,
91
+ LIST: [],
92
+ REASON: 'Internal Error'
93
+ });
78
94
  }
79
- }).catch(function (err) {
95
+ }).catch(err => {
80
96
  (0, _utils.log)(err);
81
- resolve({ STATUS: false, LIST: [], REASON: 'Service Down' });
97
+ resolve({
98
+ STATUS: false,
99
+ LIST: [],
100
+ REASON: 'Service Down'
101
+ });
82
102
  });
83
103
  });
84
104
  }
@@ -1,18 +1,15 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.default = void 0;
6
7
 
7
- var _jsonHelper = require('../utils/jsonHelper');
8
+ var _jsonHelper = require("../utils/jsonHelper");
8
9
 
9
- exports.default = function (resultObj, coverage) {
10
- var status = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
11
- var type = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'unitcase';
12
- var filecoverage = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
13
-
14
- var pathArray = [];
15
- var resultJson = {};
10
+ var _default = (resultObj, coverage, status = true, type = 'unitcase', filecoverage = 0) => {
11
+ let pathArray = [];
12
+ let resultJson = {};
16
13
  resultJson.isExecuted = status;
17
14
  resultJson.numberOfSuccess = resultObj.numPassedTests;
18
15
  resultJson.numberOfFails = resultObj.numFailedTests;
@@ -24,20 +21,20 @@ exports.default = function (resultObj, coverage) {
24
21
  codeCoveragePercentage: coverage,
25
22
  fileCoveragePercentage: filecoverage
26
23
  };
27
-
28
- var fileDetailList = [];
29
- resultObj.testResults.map(function (testFile) {
30
- var fileObj = {};
24
+ let fileDetailList = [];
25
+ resultObj.testResults.map(testFile => {
26
+ let fileObj = {};
31
27
  fileObj.fileName = testFile.testFilePath;
32
28
  fileObj.CaseList = {};
33
29
  fileObj.CaseList.passedCaseList = [];
34
30
  fileObj.CaseList.failedCaseList = [];
35
- testFile.testResults.map(function (testCase) {
31
+ testFile.testResults.map(testCase => {
36
32
  if (testCase.status === 'failed') {
37
33
  fileObj.CaseList.failedCaseList.push(testCase.title);
38
34
  } else if (testCase.status === 'passed') {
39
35
  fileObj.CaseList.passedCaseList.push(testCase.title);
40
36
  }
37
+
41
38
  return testCase;
42
39
  });
43
40
  fileDetailList.push(fileObj);
@@ -51,5 +48,7 @@ exports.default = function (resultObj, coverage) {
51
48
  }
52
49
 
53
50
  resultJson.fileDetails = fileDetailList;
54
- (0, _jsonHelper.jsonHelper)(process.cwd() + '/result.json', pathArray, resultJson);
55
- };
51
+ (0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, pathArray, resultJson);
52
+ };
53
+
54
+ exports.default = _default;
@@ -1,31 +1,29 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
- var _postcss = require('postcss');
3
+ var _postcss = _interopRequireDefault(require("postcss"));
4
4
 
5
- var _postcss2 = _interopRequireDefault(_postcss);
5
+ var _postcssHashClassname = _interopRequireDefault(require("postcss-hash-classname"));
6
6
 
7
- var _postcssHashClassname = require('postcss-hash-classname');
8
-
9
- var _postcssHashClassname2 = _interopRequireDefault(_postcssHashClassname);
10
-
11
- var _fs = require('fs');
12
-
13
- var _fs2 = _interopRequireDefault(_fs);
7
+ var _fs = _interopRequireDefault(require("fs"));
14
8
 
15
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
10
 
17
- var count = 0;
18
-
11
+ let count = 0;
19
12
  module.exports = {
20
- process: function process(src) {
13
+ process: function (src) {
21
14
  count++;
22
- var opts = { hashType: 'md5', digestType: 'base32' };
15
+ let opts = {
16
+ hashType: 'md5',
17
+ digestType: 'base32'
18
+ };
23
19
  opts.maxLength = 6;
24
20
  opts.type = '.json';
25
- opts.outputName = 'jsonFile_test_' + count;
26
- var processor = (0, _postcss2.default)([(0, _postcssHashClassname2.default)(opts)]);
21
+ opts.outputName = `jsonFile_test_${count}`;
22
+ let processor = (0, _postcss.default)([(0, _postcssHashClassname.default)(opts)]);
27
23
  processor.process(src).css;
28
- var jsonMap = _fs2.default.readFileSync('jsonFile_test_' + count + '.json', 'UTF-8');
29
- return 'module.exports =' + jsonMap;
24
+
25
+ let jsonMap = _fs.default.readFileSync(`jsonFile_test_${count}.json`, 'UTF-8');
26
+
27
+ return `module.exports =${jsonMap}`;
30
28
  }
31
29
  };
@@ -1,12 +1,10 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
- var _babelJest = require('babel-jest');
4
-
5
- var _babelJest2 = _interopRequireDefault(_babelJest);
3
+ var _babelJest = _interopRequireDefault(require("babel-jest"));
6
4
 
7
5
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
6
 
9
- module.exports = _babelJest2.default.createTransformer({
7
+ module.exports = _babelJest.default.createTransformer({
10
8
  presets: [require.resolve('@babel/preset-env'), require.resolve('@babel/preset-react')],
11
9
  plugins: [require.resolve('babel-plugin-transform-dynamic-import')]
12
10
  });
@@ -1,13 +1,12 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
- var _path = require('path');
4
-
5
- var _path2 = _interopRequireDefault(_path);
3
+ var _path = _interopRequireDefault(require("path"));
6
4
 
7
5
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
6
 
9
7
  module.exports = {
10
- process: function process(src, filename) {
11
- return 'module.exports = ' + JSON.stringify(_path2.default.basename(filename)) + ';';
8
+ process(src, filename) {
9
+ return `module.exports = ${JSON.stringify(_path.default.basename(filename))};`;
12
10
  }
11
+
13
12
  };