@zohodesk/react-cli 0.0.1-beta.99 → 0.0.1-betaa.138.2
Sign up to get free protection for your applications and to get access to all the features.
- package/.eslintignore +7 -7
- package/.eslintrc.js +183 -183
- package/CHANGELOG.md +5 -0
- package/README.md +636 -491
- package/bin/cli.js +372 -367
- package/files/eslintrc.js +57 -0
- package/files/prettierrc.js +3 -0
- package/lib/babel/cmjs-plugins-presets.js +16 -9
- package/lib/babel/es-plugins-presets.js +26 -14
- package/lib/common/getEntries.js +31 -22
- package/lib/common/getPublicPathConfig.js +27 -13
- package/lib/common/index.js +21 -25
- package/lib/common/splitChunks.js +62 -53
- package/lib/common/templateParameters.js +10 -8
- package/lib/configs/jest.config.js +15 -25
- package/lib/configs/webpack.component.umd.config.js +31 -37
- package/lib/configs/webpack.css.umd.config.js +44 -47
- package/lib/configs/webpack.dev.config.js +70 -52
- package/lib/configs/webpack.docs.config.js +106 -106
- package/lib/configs/webpack.prod.config.js +95 -75
- package/lib/hooks/docsProptypeHook.js +32 -38
- package/lib/jest/commitedFilesResult.js +103 -74
- package/lib/jest/coverageCollector.js +41 -21
- package/lib/jest/jsonMaker.js +15 -16
- package/lib/jest/preProcessors/cssPreprocessor.js +16 -18
- package/lib/jest/preProcessors/jsPreprocessor.js +3 -5
- package/lib/jest/preProcessors/otherFilesPreprocessor.js +5 -6
- package/lib/jest/result.js +90 -45
- package/lib/jest/run.js +43 -43
- package/lib/jest/setup.js +102 -95
- package/lib/loaderUtils/getCSSLoaders.js +21 -22
- package/lib/loaderUtils/getDevJsLoaders.js +25 -23
- package/lib/loaderUtils/index.js +11 -13
- package/lib/loaders/docsLoader.js +15 -15
- package/lib/loaders/docsPropsLoader.js +14 -17
- package/lib/loaders/fileLoader.js +33 -35
- package/lib/loaders/scriptInstrumentLoader.js +21 -20
- package/lib/loaders/workerLoader.js +136 -0
- package/lib/middlewares/HMRMiddleware.js +54 -45
- package/lib/middlewares/SSTMiddleware.js +8 -5
- package/lib/pluginUtils/getDevPlugins.js +114 -52
- package/lib/pluginUtils/getDocsPlugins.js +25 -29
- package/lib/pluginUtils/getLibraryPlugins.js +8 -10
- package/lib/pluginUtils/getProdPlugins.js +163 -74
- package/lib/pluginUtils/getServerPlugins.js +8 -11
- package/lib/pluginUtils/getUMDCSSPlugins.js +11 -15
- package/lib/pluginUtils/getUMDComponentPlugins.js +11 -15
- package/lib/pluginUtils/index.js +36 -43
- package/lib/plugins/CdnChangePlugin.js +63 -0
- package/lib/plugins/CleanupStatsPlugin.js +18 -32
- package/lib/plugins/CustomAttributePlugin.js +79 -0
- package/lib/plugins/CustomAttributePlugin.md +35 -0
- package/lib/plugins/EFCPlugin.js +185 -0
- package/lib/plugins/I18NInjectIntoIndexPlugin.js +118 -52
- package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +60 -0
- package/lib/plugins/I18nSplitPlugin/I18nDependency.js +44 -0
- package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +266 -0
- package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +183 -0
- package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +100 -0
- package/lib/plugins/I18nSplitPlugin/I18nSplit.md +86 -0
- package/lib/plugins/I18nSplitPlugin/README.md +25 -0
- package/lib/plugins/I18nSplitPlugin/index.js +185 -0
- package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +64 -0
- package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +13 -0
- package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +26 -0
- package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +40 -0
- package/lib/plugins/I18nSplitPlugin/utils/index.js +31 -0
- package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +112 -0
- package/lib/plugins/ManifestPlugin.js +52 -63
- package/lib/plugins/ModuleStatsPlugin.js +83 -173
- package/lib/plugins/OptimizeJSPlugin.js +24 -41
- package/lib/plugins/PublicPathCallbackPlugin.js +42 -116
- package/lib/plugins/PublicPathChangePlugin.js +175 -284
- package/lib/plugins/ReportGeneratePlugin.js +150 -151
- package/lib/plugins/ResourceHintsPlugin.js +53 -35
- package/lib/plugins/ScriptInstrumentPlugin.js +22 -37
- package/lib/plugins/ServiceWorkerPlugin.js +81 -57
- package/lib/plugins/ShadowDOMSupportPlugin.js +153 -234
- package/lib/plugins/SourceMapHookPlugin.js +21 -33
- package/lib/plugins/TPHashMappingPlugin.js +67 -0
- package/lib/plugins/UglifyCSSPlugin.js +23 -30
- package/lib/plugins/UnusedFilesFindPlugin.js +137 -152
- package/lib/plugins/index.js +100 -91
- package/lib/plugins/webpackwatchrunplugin.js +18 -30
- package/lib/postcss-plugins/ExcludeRTLPlugin.js +14 -17
- package/lib/schemas/index.js +336 -81
- package/lib/servers/clusterHubServer.js +22 -26
- package/lib/servers/docsServer.js +3 -5
- package/lib/servers/docsServerCore.js +84 -91
- package/lib/servers/helpServer.js +19 -21
- package/lib/servers/impactServer.js +99 -92
- package/lib/servers/mockserver.js +24 -24
- package/lib/servers/scrServer.js +78 -98
- package/lib/servers/server.js +101 -122
- package/lib/servers/ssServer.js +63 -61
- package/lib/sh/pre-commit.sh +34 -34
- package/lib/sh/reportPublish.sh +45 -46
- package/lib/templates/CoverageScriptTemplate.js +45 -18
- package/lib/templates/WMSTemplate.js +17 -18
- package/lib/templates/linterConstant.js +6 -4
- package/lib/utils/babelPresets.js +12 -5
- package/lib/utils/buildstats.html +148 -148
- package/lib/utils/clean.js +12 -11
- package/lib/utils/copy.js +12 -34
- package/lib/utils/copyTimezones.js +9 -16
- package/lib/utils/createEventStream.js +24 -19
- package/lib/utils/cssClassNameGenerate.js +44 -73
- package/lib/utils/cssURLReplacer.js +60 -54
- package/lib/utils/dependencyPostPublish.js +20 -19
- package/lib/utils/fileUtils.js +66 -54
- package/lib/utils/folderIterator.js +20 -21
- package/lib/utils/getComponents.js +70 -27
- package/lib/utils/getCurrentBranch.js +11 -17
- package/lib/utils/getDependenciesImpactList.js +114 -187
- package/lib/utils/getHash.js +9 -13
- package/lib/utils/getIp.js +9 -9
- package/lib/utils/getOptions.js +26 -29
- package/lib/utils/getServerURL.js +19 -10
- package/lib/utils/index.js +147 -126
- package/lib/utils/init.js +2 -2
- package/lib/utils/initPreCommitHook.js +40 -32
- package/lib/utils/jsonHelper.js +37 -21
- package/lib/utils/lint/addScripts.js +27 -0
- package/lib/utils/lint/checkExistingConfig.js +67 -0
- package/lib/utils/lint/copyConfigs.js +24 -0
- package/lib/utils/lint/index.js +54 -0
- package/lib/utils/lint/lintScripts.js +11 -0
- package/lib/utils/lint/lintSetup.js +31 -0
- package/lib/utils/lint/lintStagedPreCommitHook.js +7 -0
- package/lib/utils/lint/question.js +30 -0
- package/lib/utils/lintReporter.js +70 -56
- package/lib/utils/mailSender.js +12 -27
- package/lib/utils/pullOrigin.js +21 -18
- package/lib/utils/reinstallDependencies.js +76 -85
- package/lib/utils/removeAttributes.js +25 -23
- package/lib/utils/repoClone.js +47 -45
- package/lib/utils/request.js +64 -77
- package/lib/utils/resultSchema.json +73 -73
- package/lib/utils/rtl.js +22 -29
- package/lib/utils/setEnvVariables.js +5 -6
- package/lib/utils/ssTestHack.js +21 -19
- package/lib/utils/switchBranch.js +21 -20
- package/lib/utils/urlConcat.js +22 -0
- package/package.json +141 -136
- package/templates/app/.eslintrc.js +140 -140
- package/templates/app/README.md +12 -12
- package/templates/app/app/index.html +24 -24
- package/templates/app/app/properties/ApplicationResources_en_US.properties +1 -1
- package/templates/app/app/properties/i18nkeys.json +3 -3
- package/templates/app/docs/all.html +69 -69
- package/templates/app/mockapi/index.js +18 -18
- package/templates/app/package.json +37 -37
- package/templates/app/src/actions/SampleActions/index.js +37 -37
- package/templates/app/src/actions/index.js +65 -65
- package/templates/app/src/appUrls.js +19 -19
- package/templates/app/src/components/Alert/Alert.js +134 -134
- package/templates/app/src/components/Alert/Alert.module.css +79 -79
- package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -37
- package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -84
- package/templates/app/src/components/Sample/Sample.module.css +11 -11
- package/templates/app/src/components/Sample/SampleList.js +61 -61
- package/templates/app/src/components/Slider/Slider.css +41 -41
- package/templates/app/src/components/Slider/Slider.js +55 -55
- package/templates/app/src/containers/AlertContainer/index.js +15 -15
- package/templates/app/src/containers/AppContainer/index.js +96 -96
- package/templates/app/src/containers/AppContainer/index.module.css +27 -27
- package/templates/app/src/containers/CustomMatch/index.js +65 -65
- package/templates/app/src/containers/DevTools/index.js +10 -10
- package/templates/app/src/containers/Header/index.js +67 -67
- package/templates/app/src/containers/Header/index.module.css +43 -43
- package/templates/app/src/containers/Redirect/index.js +63 -63
- package/templates/app/src/containers/Redirector/index.js +47 -47
- package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -42
- package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -3
- package/templates/app/src/historyChange.js +5 -5
- package/templates/app/src/index.html +10 -10
- package/templates/app/src/index.js +24 -24
- package/templates/app/src/middleware/PromiseMiddleware.js +59 -59
- package/templates/app/src/reducers/alertData.js +11 -11
- package/templates/app/src/reducers/index.js +6 -6
- package/templates/app/src/reducers/samples.js +19 -19
- package/templates/app/src/store/configureStore.dev.js +51 -51
- package/templates/app/src/store/configureStore.js +5 -5
- package/templates/app/src/store/configureStore.prod.js +26 -26
- package/templates/app/src/util/Common.js +5 -5
- package/templates/app/src/util/RequestAPI.js +132 -132
- package/templates/docs/all.html +249 -249
- package/templates/docs/component.html +178 -178
- package/templates/docs/components.html +221 -221
- package/templates/docs/css/b.min.css +6 -6
- package/templates/docs/css/component.css +42 -42
- package/templates/docs/css/componentTest.css +6 -6
- package/templates/docs/css/hopscotch.css +585 -585
- package/templates/docs/css/style.css +1022 -1022
- package/templates/docs/index.html +1493 -1493
- package/templates/docs/js/active-line.js +72 -72
- package/templates/docs/js/b.min.js +7 -7
- package/templates/docs/js/codemirror.js +9680 -9680
- package/templates/docs/js/designTokens.js +334 -334
- package/templates/docs/js/j.min.js +4 -4
- package/templates/docs/js/javascript.js +874 -874
- package/templates/docs/js/matchbrackets.js +145 -145
@@ -1,21 +1,21 @@
|
|
1
|
-
|
1
|
+
"use strict";
|
2
2
|
|
3
|
-
var _path = require(
|
3
|
+
var _path = _interopRequireDefault(require("path"));
|
4
4
|
|
5
|
-
var
|
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
|
-
|
13
|
-
|
14
|
-
|
15
|
-
listOfObject.forEach(
|
16
|
-
|
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(
|
28
|
+
return new Promise(resolve => {
|
29
29
|
(0, _utils.request)({
|
30
|
-
url: domain
|
31
|
-
}).then(
|
32
|
-
|
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
|
-
|
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({
|
75
|
+
resolve({
|
76
|
+
STATUS: false,
|
77
|
+
LIST: [],
|
78
|
+
REASON: 'Internal Error'
|
79
|
+
});
|
72
80
|
}
|
73
81
|
} else {
|
74
|
-
resolve({
|
82
|
+
resolve({
|
83
|
+
STATUS: false,
|
84
|
+
LIST: [],
|
85
|
+
REASON: 'Internal Error'
|
86
|
+
});
|
75
87
|
}
|
76
88
|
} else {
|
77
|
-
resolve({
|
89
|
+
resolve({
|
90
|
+
STATUS: false,
|
91
|
+
LIST: [],
|
92
|
+
REASON: 'Internal Error'
|
93
|
+
});
|
78
94
|
}
|
79
|
-
}).catch(
|
95
|
+
}).catch(err => {
|
80
96
|
(0, _utils.log)(err);
|
81
|
-
resolve({
|
97
|
+
resolve({
|
98
|
+
STATUS: false,
|
99
|
+
LIST: [],
|
100
|
+
REASON: 'Service Down'
|
101
|
+
});
|
82
102
|
});
|
83
103
|
});
|
84
104
|
}
|
package/lib/jest/jsonMaker.js
CHANGED
@@ -1,18 +1,15 @@
|
|
1
|
-
|
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(
|
8
|
+
var _jsonHelper = require("../utils/jsonHelper");
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
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
|
-
|
29
|
-
|
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(
|
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()
|
55
|
-
};
|
51
|
+
(0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, pathArray, resultJson);
|
52
|
+
};
|
53
|
+
|
54
|
+
exports.default = _default;
|
@@ -1,31 +1,29 @@
|
|
1
|
-
|
1
|
+
"use strict";
|
2
2
|
|
3
|
-
var _postcss = require(
|
3
|
+
var _postcss = _interopRequireDefault(require("postcss"));
|
4
4
|
|
5
|
-
var
|
5
|
+
var _postcssHashClassname = _interopRequireDefault(require("postcss-hash-classname"));
|
6
6
|
|
7
|
-
var
|
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
|
-
|
18
|
-
|
11
|
+
let count = 0;
|
19
12
|
module.exports = {
|
20
|
-
process: function
|
13
|
+
process: function (src) {
|
21
14
|
count++;
|
22
|
-
|
15
|
+
let opts = {
|
16
|
+
hashType: 'md5',
|
17
|
+
digestType: 'base32'
|
18
|
+
};
|
23
19
|
opts.maxLength = 6;
|
24
20
|
opts.type = '.json';
|
25
|
-
opts.outputName =
|
26
|
-
|
21
|
+
opts.outputName = `jsonFile_test_${count}`;
|
22
|
+
let processor = (0, _postcss.default)([(0, _postcssHashClassname.default)(opts)]);
|
27
23
|
processor.process(src).css;
|
28
|
-
|
29
|
-
|
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
|
-
|
1
|
+
"use strict";
|
2
2
|
|
3
|
-
var _babelJest = require(
|
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 =
|
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
|
-
|
1
|
+
"use strict";
|
2
2
|
|
3
|
-
var _path = require(
|
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
|
11
|
-
return
|
8
|
+
process(src, filename) {
|
9
|
+
return `module.exports = ${JSON.stringify(_path.default.basename(filename))};`;
|
12
10
|
}
|
11
|
+
|
13
12
|
};
|
package/lib/jest/result.js
CHANGED
@@ -1,46 +1,46 @@
|
|
1
|
-
|
1
|
+
"use strict";
|
2
2
|
|
3
|
-
var _fs = require(
|
3
|
+
var _fs = _interopRequireDefault(require("fs"));
|
4
4
|
|
5
|
-
var
|
5
|
+
var _utils = require("../utils");
|
6
6
|
|
7
|
-
var
|
8
|
-
|
9
|
-
var _jsonMaker = require('./jsonMaker');
|
10
|
-
|
11
|
-
var _jsonMaker2 = _interopRequireDefault(_jsonMaker);
|
7
|
+
var _jsonMaker = _interopRequireDefault(require("./jsonMaker"));
|
12
8
|
|
13
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
14
10
|
|
15
|
-
|
16
|
-
|
11
|
+
let unitTestReport = [];
|
12
|
+
|
13
|
+
const result = inp => {
|
17
14
|
inp.endTime = Date.now();
|
18
|
-
|
15
|
+
let testPathPattern = process.argv[process.argv.length - 1];
|
16
|
+
|
19
17
|
if (testPathPattern.indexOf('--') !== -1) {
|
20
18
|
testPathPattern = '';
|
21
19
|
} else {
|
22
|
-
testPathPattern =
|
20
|
+
testPathPattern = _fs.default.realpathSync(process.cwd());
|
23
21
|
}
|
24
|
-
var testPathRegex = new RegExp(testPathPattern);
|
25
|
-
var testResults = inp.testResults;
|
26
22
|
|
27
|
-
|
28
|
-
|
29
|
-
|
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
|
+
|
30
31
|
if (!testPathRegex.test(filePath)) {
|
31
32
|
return;
|
32
33
|
}
|
34
|
+
|
33
35
|
filePath = filePath.replace('.spec', '');
|
34
36
|
filePath = filePath.replace('/__tests__', '');
|
35
37
|
filePath = filePath.replace('/__test__', '');
|
36
|
-
|
38
|
+
let fileJson = {};
|
37
39
|
fileJson.testPath = testResult.testFilePath;
|
38
40
|
fileJson.sourcePath = filePath;
|
39
41
|
fileJson.data = testResult;
|
40
42
|
testFilesArr.push(fileJson);
|
41
|
-
testResult.testResults && testResult.testResults.filter(
|
42
|
-
return t.status === 'failed';
|
43
|
-
}).forEach(function (t) {
|
43
|
+
testResult.testResults && testResult.testResults.filter(t => t.status === 'failed').forEach(t => {
|
44
44
|
unitTestReport.push({
|
45
45
|
title: t.title,
|
46
46
|
fullName: t.fullName,
|
@@ -49,52 +49,97 @@ var result = function result(inp) {
|
|
49
49
|
});
|
50
50
|
});
|
51
51
|
|
52
|
-
|
52
|
+
let coverageSummary = _fs.default.readFileSync('./coverage/coverage-summary.json').toString();
|
53
|
+
|
53
54
|
if (coverageSummary.indexOf('\\') !== -1) {
|
54
55
|
coverageSummary = coverageSummary.replace(/\\/g, '\\\\');
|
55
56
|
}
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
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
|
+
|
62
65
|
for (i; i < testFilesArr.length; i++) {
|
63
|
-
|
64
|
-
|
66
|
+
let curSourceFile = testFilesArr[i].sourcePath;
|
67
|
+
let coverageData = coverageJson[curSourceFile];
|
68
|
+
|
65
69
|
if (!coverageData) {
|
66
|
-
(0, _utils.log)(
|
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.`);
|
67
71
|
continue;
|
68
72
|
}
|
73
|
+
|
69
74
|
linesPercent += coverageData.lines.pct;
|
70
75
|
functionPercent += coverageData.functions.pct;
|
71
76
|
statementPerment += coverageData.statements.pct;
|
72
77
|
branchesPercent += coverageData.branches.pct;
|
73
78
|
}
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
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);
|
80
86
|
coverage = Number(coverage);
|
81
|
-
(0,
|
87
|
+
(0, _jsonMaker.default)(inp, coverage, 'Yes', 'unitcase');
|
82
88
|
|
83
89
|
if (Number.isNaN(coverage)) {
|
84
90
|
(0, _utils.log)('This build does\'t have any JS changes!');
|
85
91
|
coverage = 0;
|
86
92
|
} else {
|
87
|
-
(0, _utils.log)(
|
93
|
+
(0, _utils.log)(`COVERAGE ${coverage}%`);
|
88
94
|
}
|
89
95
|
|
90
|
-
|
91
|
-
|
92
|
-
|
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
|
+
`;
|
93
137
|
|
94
|
-
if (!
|
95
|
-
|
138
|
+
if (!_fs.default.existsSync('./unittest')) {
|
139
|
+
_fs.default.mkdirSync('./unittest');
|
96
140
|
}
|
97
|
-
|
141
|
+
|
142
|
+
_fs.default.writeFileSync('./unittest/index.html', html, 'utf8');
|
98
143
|
|
99
144
|
return inp;
|
100
145
|
};
|
package/lib/jest/run.js
CHANGED
@@ -1,51 +1,49 @@
|
|
1
|
-
|
1
|
+
"use strict";
|
2
2
|
|
3
|
-
var _jest = require(
|
3
|
+
var _jest = _interopRequireDefault(require("jest"));
|
4
4
|
|
5
|
-
var
|
5
|
+
var _fs = _interopRequireDefault(require("fs"));
|
6
6
|
|
7
|
-
var
|
7
|
+
var _utils = require("../utils");
|
8
8
|
|
9
|
-
var
|
9
|
+
var _jsonHelper = require("../utils/jsonHelper");
|
10
10
|
|
11
|
-
var
|
12
|
-
|
13
|
-
var _jsonHelper = require('../utils/jsonHelper');
|
14
|
-
|
15
|
-
var _coverageCollector = require('./coverageCollector');
|
16
|
-
|
17
|
-
var _coverageCollector2 = _interopRequireDefault(_coverageCollector);
|
11
|
+
var _coverageCollector = _interopRequireDefault(require("./coverageCollector"));
|
18
12
|
|
19
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
20
14
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
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);
|
31
30
|
|
32
|
-
|
31
|
+
let config = require('../configs/jest.config');
|
33
32
|
|
34
|
-
var config = require('../configs/jest.config');
|
35
33
|
if (isCommitCoverage) {
|
36
|
-
(0,
|
37
|
-
var res = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
38
|
-
|
34
|
+
(0, _coverageCollector.default)(srcBranch, targetBranch, serviceName, impactServerDomain).then((res = {}) => {
|
39
35
|
if (res.STATUS) {
|
40
36
|
if (res.LIST.length > 0) {
|
41
|
-
|
37
|
+
let content = {
|
42
38
|
FILES: res.LIST
|
43
39
|
};
|
44
|
-
|
45
|
-
|
46
|
-
|
40
|
+
|
41
|
+
if (!_fs.default.existsSync('./coverageTest')) {
|
42
|
+
_fs.default.mkdirSync('./coverageTest');
|
43
|
+
|
44
|
+
_fs.default.writeFileSync('./coverageTest/result.json', JSON.stringify(content), 'utf8');
|
47
45
|
} else {
|
48
|
-
|
46
|
+
_fs.default.writeFileSync('./coverageTest/result.json', JSON.stringify(content), 'utf8');
|
49
47
|
}
|
50
48
|
|
51
49
|
argv.push('--findRelatedTests');
|
@@ -53,42 +51,44 @@ if (isCommitCoverage) {
|
|
53
51
|
argv = argv.concat(['--config', JSON.stringify(config(null, true))]);
|
54
52
|
argv.push('--no-cache');
|
55
53
|
argv.push('--silent');
|
56
|
-
|
54
|
+
|
55
|
+
_jest.default.run(argv);
|
57
56
|
} else {
|
58
|
-
(0, _jsonHelper.jsonHelper)(process.cwd()
|
59
|
-
// jsonHelper(
|
57
|
+
(0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, ['tests', 'modifiedFileUnitCase', 'hasChanges'], false); // jsonHelper(
|
60
58
|
// `${process.cwd()}/result.json`,
|
61
59
|
// 'testInfo.isBuildVerified',
|
62
60
|
// true
|
63
61
|
// );
|
64
|
-
|
65
|
-
(0, _jsonHelper.
|
62
|
+
|
63
|
+
(0, _jsonHelper.setTestInfoStatus)(`${process.cwd()}/result.json`, true);
|
64
|
+
(0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'testInfo.failures', [{
|
66
65
|
type: 'modifiedUnitcases',
|
67
66
|
message: res.REASON
|
68
67
|
}]);
|
69
68
|
(0, _utils.log)('No JS changes with last changeset!');
|
70
69
|
}
|
71
70
|
} else {
|
72
|
-
(0, _jsonHelper.jsonHelper)(process.cwd()
|
73
|
-
// jsonHelper(
|
71
|
+
(0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, ['tests', 'modifiedFileUnitCase', 'isExecuted'], res.STATUS); // jsonHelper(
|
74
72
|
// `${process.cwd()}/result.json`,
|
75
73
|
// 'testInfo.isBuildVerified',
|
76
74
|
// true
|
77
75
|
// );
|
78
|
-
|
79
|
-
// jsonHelper(`${process.cwd()}/result.json`, 'testInfo.failures', [{
|
76
|
+
|
77
|
+
(0, _jsonHelper.setTestInfoStatus)(`${process.cwd()}/result.json`, true); // jsonHelper(`${process.cwd()}/result.json`, 'testInfo.failures', [{
|
80
78
|
// type: 'modifiedUnitcases',
|
81
79
|
// message: res.REASON
|
82
80
|
// }]);
|
81
|
+
|
83
82
|
(0, _utils.log)(res.REASON);
|
84
83
|
}
|
85
84
|
});
|
86
85
|
} else {
|
87
86
|
if (branchName === 'master' || branchName === null) {
|
88
87
|
argv.push('--config', JSON.stringify(config(folder)), '--no-cache');
|
89
|
-
|
88
|
+
|
89
|
+
_jest.default.run(argv);
|
90
90
|
} else {
|
91
|
-
(0, _jsonHelper.jsonHelper)(process.cwd()
|
91
|
+
(0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, ['tests', 'unitCase', 'isExecuted'], 'onlyMaster');
|
92
92
|
(0, _utils.log)('Only runs with master branch');
|
93
93
|
}
|
94
94
|
}
|