@zohodesk/react-cli 0.0.1-exp.169.2 → 0.0.1-exp.175.1
Sign up to get free protection for your applications and to get access to all the features.
- package/.eslintignore +7 -7
- package/.eslintrc.js +180 -179
- package/.prettierrc +6 -6
- package/README.md +1028 -951
- package/bin/cli.js +483 -483
- package/cert/Tsicsezwild-22-23.crt +37 -37
- package/cert/Tsicsezwild-22-23.key +27 -27
- package/docs/CustomChunks.md +26 -26
- package/docs/DevStart.md +18 -18
- package/docs/HoverActive.md +12 -12
- package/docs/InstallNode.md +28 -28
- package/docs/TODOS.md +10 -10
- package/docs/ValueReplacer.md +60 -60
- package/docs/VariableConversion.md +678 -0
- package/docs/warnings_while_install.txt +35 -35
- package/files/eslintrc.js +62 -62
- package/files/prettierrc.js +3 -3
- package/lib/babel/cmjs-plugins-presets.js +0 -4
- package/lib/babel/es-plugins-presets.js +0 -4
- package/lib/common/getEntries.js +0 -10
- package/lib/common/getPublicPathConfig.js +0 -6
- package/lib/common/index.js +0 -5
- package/lib/common/splitChunks.js +2 -13
- package/lib/common/sslcertUpdater.js +6 -17
- package/lib/common/templateParameters.js +0 -2
- package/lib/common/testPattern.js +10 -21
- package/lib/common/valueReplacer.js +0 -15
- package/lib/configs/jest.config.js +8 -21
- package/lib/configs/libAlias.js +11 -2
- package/lib/configs/webpack.component.umd.config.js +0 -5
- package/lib/configs/webpack.css.umd.config.js +5 -13
- package/lib/configs/webpack.dev.config.js +13 -24
- package/lib/configs/webpack.docs.config.js +6 -12
- package/lib/configs/webpack.impact.config.js +6 -10
- package/lib/configs/webpack.prod.config.js +15 -26
- package/lib/hooks/docsProptypeHook.js +3 -7
- package/lib/jest/commitedFilesResult.js +3 -45
- package/lib/jest/coverageCollector.js +0 -11
- package/lib/jest/jsonMaker.js +0 -6
- package/lib/jest/preProcessors/cssPreprocessor.js +14 -13
- package/lib/jest/preProcessors/jsPreprocessor.js +0 -2
- package/lib/jest/preProcessors/otherFilesPreprocessor.js +0 -3
- package/lib/jest/result.js +0 -22
- package/lib/jest/run.js +6 -17
- package/lib/jest/setup.js +5 -57
- package/lib/loaderUtils/configsAssetsLoaders.js +34 -44
- package/lib/loaderUtils/getCSSLoaders.js +41 -28
- package/lib/loaderUtils/getDevJsLoaders.js +0 -8
- package/lib/loaderUtils/index.js +0 -3
- package/lib/loaders/docsLoader.js +0 -7
- package/lib/loaders/docsPropsLoader.js +3 -7
- package/lib/loaders/fileBountryLoader.js +0 -2
- package/lib/loaders/fileLoader.js +11 -22
- package/lib/loaders/scriptInstrumentLoader.js +5 -13
- package/lib/loaders/selectorMappingLoader.js +7 -25
- package/lib/loaders/workerLoader.js +13 -29
- package/lib/middlewares/HMRMiddleware.js +13 -26
- package/lib/middlewares/SSTMiddleware.js +0 -3
- package/lib/pluginUtils/configHtmlWebpackPlugins.js +53 -0
- package/lib/pluginUtils/getDevPlugins.js +20 -64
- package/lib/pluginUtils/getDocsPlugins.js +1 -10
- package/lib/pluginUtils/getLibraryImactPlugins.js +4 -5
- package/lib/pluginUtils/getLibraryPlugins.js +0 -5
- package/lib/pluginUtils/getProdPlugins.js +32 -78
- package/lib/pluginUtils/getServerPlugins.js +0 -5
- package/lib/pluginUtils/getUMDCSSPlugins.js +0 -7
- package/lib/pluginUtils/getUMDComponentPlugins.js +0 -7
- package/lib/pluginUtils/index.js +0 -8
- package/lib/plugins/CdnChangePlugin.js +0 -14
- package/lib/plugins/CleanupStatsPlugin.js +0 -5
- package/lib/plugins/EFCPlugin.js +23 -34
- package/lib/plugins/EFCPlugin.md +6 -6
- package/lib/plugins/EFCTemplatePlugin.js +23 -32
- package/lib/plugins/I18NInjectIntoIndexPlugin.js +12 -38
- package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +12 -17
- package/lib/plugins/I18nSplitPlugin/I18nDependency.js +4 -10
- package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +46 -77
- package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +44 -59
- package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +21 -30
- package/lib/plugins/I18nSplitPlugin/I18nSplit.md +95 -95
- package/lib/plugins/I18nSplitPlugin/README.md +25 -25
- package/lib/plugins/I18nSplitPlugin/index.js +70 -80
- package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +2 -12
- package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +0 -1
- package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +0 -5
- package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +0 -6
- package/lib/plugins/I18nSplitPlugin/utils/index.js +0 -4
- package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +2 -20
- package/lib/plugins/ManifestPlugin.js +0 -17
- package/lib/plugins/ModuleStatsPlugin.js +0 -23
- package/lib/plugins/OptimizeJSPlugin.js +0 -7
- package/lib/plugins/PublicPathCallbackPlugin.js +0 -10
- package/lib/plugins/PublicPathChangePlugin.js +4 -36
- package/lib/plugins/ReportGeneratePlugin.js +4 -30
- package/lib/plugins/RequireVariablePublicPlugin.js +0 -6
- package/lib/plugins/ResourceHintsPlugin.js +20 -27
- package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +12 -17
- package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +23 -38
- package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -30
- package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +2 -5
- package/lib/plugins/ScriptInstrumentPlugin.js +0 -7
- package/lib/plugins/ServiceWorkerPlugin.js +13 -29
- package/lib/plugins/ShadowDOMSupportPlugin.js +3 -40
- package/lib/plugins/SourceMapHookPlugin.js +0 -9
- package/lib/plugins/TPHashMappingPlugin.js +5 -19
- package/lib/plugins/UglifyCSSPlugin.js +0 -9
- package/lib/plugins/UnusedFilesFindPlugin.js +2 -35
- package/lib/plugins/index.js +0 -19
- package/lib/plugins/libraryImpactPlugin.js +0 -32
- package/lib/plugins/webpackwatchrunplugin.js +0 -5
- package/lib/postcss-plugins/ExcludePlugin.js +0 -4
- package/lib/postcss-plugins/RTLSplitPlugin.js +24 -37
- package/lib/postcss-plugins/ValueReplacer.js +9 -6
- package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +0 -3
- package/lib/postcss-plugins/__test__/test1Input.css +38 -38
- package/lib/postcss-plugins/__test__/test1Output.css +38 -38
- package/lib/postcss-plugins/hoverActivePlugin.js +80 -92
- package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +31 -0
- package/lib/postcss-plugins/variableModificationPlugin/index.js +232 -0
- package/lib/postcss-plugins/variableModifier.js +14 -20
- package/lib/schemas/index.js +28 -13
- package/lib/servers/clusterHubServer.js +0 -10
- package/lib/servers/devBuild.js +13 -24
- package/lib/servers/docsServer.js +0 -2
- package/lib/servers/docsServerCore.js +0 -21
- package/lib/servers/getCliPath.js +1 -10
- package/lib/servers/helpServer.js +0 -5
- package/lib/servers/httpsOptions.js +0 -4
- package/lib/servers/impactServer.js +2 -34
- package/lib/servers/mockserver.js +0 -9
- package/lib/servers/nowatchserver.js +12 -34
- package/lib/servers/scrServer.js +13 -20
- package/lib/servers/server.js +7 -35
- package/lib/servers/ssServer.js +0 -16
- package/lib/sh/pre-commit.sh +34 -34
- package/lib/sh/reportPublish.sh +45 -45
- package/lib/templates/CoverageScriptTemplate.js +0 -14
- package/lib/templates/WMSTemplate.js +6 -12
- package/lib/utils/babelPresets.js +0 -2
- package/lib/utils/buildstats.html +148 -148
- package/lib/utils/clean.js +2 -8
- package/lib/utils/copy.js +0 -6
- package/lib/utils/copyTimezones.js +0 -8
- package/lib/utils/createEventStream.js +0 -4
- package/lib/utils/cssClassNameGenerate.js +3 -19
- package/lib/utils/cssURLReplacer.js +0 -25
- package/lib/utils/dependencyPostPublish.js +0 -9
- package/lib/utils/fileUtils.js +0 -26
- package/lib/utils/folderIterator.js +0 -10
- package/lib/utils/getComponents.js +0 -21
- package/lib/utils/getCurrentBranch.js +0 -5
- package/lib/utils/getDependenciesImpactList.js +0 -21
- package/lib/utils/getHash.js +0 -7
- package/lib/utils/getIp.js +0 -2
- package/lib/utils/getOptions.js +38 -35
- package/lib/utils/getServerURL.js +0 -7
- package/lib/utils/index.js +2 -47
- package/lib/utils/init.js +0 -1
- package/lib/utils/initPreCommitHook.js +6 -29
- package/lib/utils/jsonHelper.js +2 -19
- package/lib/utils/libraryImpactConfig.js +0 -2
- package/lib/utils/lint/addScripts.js +2 -5
- package/lib/utils/lint/checkExistingConfig.js +3 -12
- package/lib/utils/lint/copyConfigs.js +0 -3
- package/lib/utils/lint/index.js +0 -9
- package/lib/utils/lint/lintScripts.js +0 -1
- package/lib/utils/lint/lintSetup.js +3 -4
- package/lib/utils/lint/lintStagedPreCommitHook.js +0 -1
- package/lib/utils/lint/question.js +0 -7
- package/lib/utils/lintReporter.js +0 -20
- package/lib/utils/mailSender.js +0 -7
- package/lib/utils/pullOrigin.js +0 -4
- package/lib/utils/reinstallDependencies.js +0 -28
- package/lib/utils/removeAttributes.js +0 -7
- package/lib/utils/repoClone.js +2 -27
- package/lib/utils/request.js +0 -12
- package/lib/utils/resultSchema.json +73 -73
- package/lib/utils/rtl.js +4 -16
- package/lib/utils/setEnvVariables.js +0 -2
- package/lib/utils/ssTestHack.js +0 -10
- package/lib/utils/switchBranch.js +0 -4
- package/lib/utils/urlConcat.js +0 -4
- package/lib/utils/useExitCleanup.js +9 -10
- package/npm8.md +9 -9
- package/package.json +146 -148
- package/postpublish.js +6 -6
- 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/impactReportTemplate.html +154 -154
- package/templates/docs/index.html +1501 -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,16 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _path = _interopRequireDefault(require("path"));
|
4
|
-
|
5
4
|
var _utils = require("../utils");
|
6
|
-
|
7
5
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
8
|
-
|
9
6
|
function jsFileFilter(listOfObject) {
|
10
7
|
let fileNameList = [];
|
11
8
|
let curListName = process.cwd().split(_path.default.sep);
|
12
9
|
let currentDirName = curListName[curListName.length - 1];
|
13
10
|
listOfObject.forEach(fileObj => {
|
14
11
|
let fileName = fileObj.FILEPATH;
|
15
|
-
|
16
12
|
if (fileName.includes(currentDirName)) {
|
17
13
|
fileName = fileName.split(currentDirName + '/')[1]; //eslint-disable-line
|
18
|
-
|
19
14
|
if (fileName.includes('.js') && !fileName.includes('.json') && !fileName.includes('.docs.js') && !fileName.includes('.spec.js')) {
|
20
15
|
fileNameList.push(fileName);
|
21
16
|
}
|
@@ -23,7 +18,6 @@ function jsFileFilter(listOfObject) {
|
|
23
18
|
});
|
24
19
|
return fileNameList;
|
25
20
|
}
|
26
|
-
|
27
21
|
function coverage(devBranch, compareWith, serviceName, domain) {
|
28
22
|
return new Promise(resolve => {
|
29
23
|
(0, _utils.request)({
|
@@ -32,25 +26,21 @@ function coverage(devBranch, compareWith, serviceName, domain) {
|
|
32
26
|
body
|
33
27
|
}) => {
|
34
28
|
let res = JSON.parse(body);
|
35
|
-
|
36
29
|
if (Object.keys(res).length > 0) {
|
37
30
|
if (Object.prototype.hasOwnProperty.call(res, 'STATUS')) {
|
38
31
|
if (res.STATUS) {
|
39
32
|
let listOfFiles = [];
|
40
|
-
|
41
33
|
if (Object.keys(res.DIFF_FILES).length > 0) {
|
42
34
|
if (Object.prototype.hasOwnProperty.call(res.DIFF_FILES, 'ADDED')) {
|
43
35
|
if (res.DIFF_FILES.ADDED.length > 0) {
|
44
36
|
listOfFiles = listOfFiles.concat(jsFileFilter(res.DIFF_FILES.ADDED));
|
45
37
|
}
|
46
38
|
}
|
47
|
-
|
48
39
|
if (Object.prototype.hasOwnProperty.call(res.DIFF_FILES, 'UPDATED')) {
|
49
40
|
if (res.DIFF_FILES.UPDATED.length > 0) {
|
50
41
|
listOfFiles = listOfFiles.concat(jsFileFilter(res.DIFF_FILES.UPDATED));
|
51
42
|
}
|
52
43
|
}
|
53
|
-
|
54
44
|
if (listOfFiles.length > 0) {
|
55
45
|
resolve({
|
56
46
|
STATUS: true,
|
@@ -102,5 +92,4 @@ function coverage(devBranch, compareWith, serviceName, domain) {
|
|
102
92
|
});
|
103
93
|
});
|
104
94
|
}
|
105
|
-
|
106
95
|
module.exports = coverage;
|
package/lib/jest/jsonMaker.js
CHANGED
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.default = void 0;
|
7
|
-
|
8
7
|
var _jsonHelper = require("../utils/jsonHelper");
|
9
|
-
|
10
8
|
var _default = (resultObj, coverage, status = true, type = 'unitcase', filecoverage = 0) => {
|
11
9
|
let pathArray = [];
|
12
10
|
let resultJson = {};
|
@@ -34,21 +32,17 @@ var _default = (resultObj, coverage, status = true, type = 'unitcase', filecover
|
|
34
32
|
} else if (testCase.status === 'passed') {
|
35
33
|
fileObj.CaseList.passedCaseList.push(testCase.title);
|
36
34
|
}
|
37
|
-
|
38
35
|
return testCase;
|
39
36
|
});
|
40
37
|
fileDetailList.push(fileObj);
|
41
38
|
return testFile;
|
42
39
|
});
|
43
|
-
|
44
40
|
if (type !== 'unitcase') {
|
45
41
|
Array.prototype.push.apply(pathArray, ['tests', 'modifiedFileUnitCase']);
|
46
42
|
} else {
|
47
43
|
Array.prototype.push.apply(pathArray, ['tests', 'unitCase']);
|
48
44
|
}
|
49
|
-
|
50
45
|
resultJson.fileDetails = fileDetailList;
|
51
46
|
(0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, pathArray, resultJson);
|
52
47
|
};
|
53
|
-
|
54
48
|
exports.default = _default;
|
@@ -1,29 +1,30 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _postcss = _interopRequireDefault(require("postcss"));
|
4
|
-
|
5
4
|
var _postcssHashClassname = _interopRequireDefault(require("postcss-hash-classname"));
|
6
|
-
|
7
5
|
var _fs = _interopRequireDefault(require("fs"));
|
8
|
-
|
6
|
+
var _utils = require("../../utils");
|
9
7
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
10
|
-
|
11
8
|
let count = 0;
|
9
|
+
const options = (0, _utils.getOptions)();
|
10
|
+
const {
|
11
|
+
classnameFormat
|
12
|
+
} = options.test;
|
12
13
|
module.exports = {
|
13
14
|
process: function (src) {
|
14
15
|
count++;
|
15
|
-
|
16
|
+
const opts = {
|
16
17
|
hashType: 'md5',
|
17
|
-
digestType: 'base32'
|
18
|
+
digestType: 'base32',
|
19
|
+
maxLength: 6,
|
20
|
+
type: '.json',
|
21
|
+
classnameFormat: classnameFormat,
|
22
|
+
outputName: `jsonFile_test_${count}`
|
18
23
|
};
|
19
|
-
|
20
|
-
opts.type = '.json';
|
21
|
-
opts.outputName = `jsonFile_test_${count}`;
|
22
|
-
let processor = (0, _postcss.default)([(0, _postcssHashClassname.default)(opts)]);
|
24
|
+
const processor = (0, _postcss.default)([(0, _postcssHashClassname.default)(opts)]);
|
23
25
|
processor.process(src).css;
|
24
|
-
|
25
|
-
|
26
|
-
|
26
|
+
const jsonMap = _fs.default.readFileSync(`jsonFile_test_${count}.json`, 'UTF-8');
|
27
|
+
_fs.default.unlinkSync(`jsonFile_test_${count}.json`);
|
27
28
|
return `module.exports =${jsonMap}`;
|
28
29
|
}
|
29
30
|
};
|
@@ -1,9 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _babelJest = _interopRequireDefault(require("babel-jest"));
|
4
|
-
|
5
4
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
6
|
-
|
7
5
|
module.exports = _babelJest.default.createTransformer({
|
8
6
|
presets: [require.resolve('@babel/preset-env'), require.resolve('@babel/preset-react')],
|
9
7
|
plugins: [require.resolve('babel-plugin-transform-dynamic-import')]
|
@@ -1,12 +1,9 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _path = _interopRequireDefault(require("path"));
|
4
|
-
|
5
4
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
6
|
-
|
7
5
|
module.exports = {
|
8
6
|
process(src, filename) {
|
9
7
|
return `module.exports = ${JSON.stringify(_path.default.basename(filename))};`;
|
10
8
|
}
|
11
|
-
|
12
9
|
};
|
package/lib/jest/result.js
CHANGED
@@ -1,25 +1,18 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _fs = _interopRequireDefault(require("fs"));
|
4
|
-
|
5
4
|
var _utils = require("../utils");
|
6
|
-
|
7
5
|
var _jsonMaker = _interopRequireDefault(require("./jsonMaker"));
|
8
|
-
|
9
6
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
10
|
-
|
11
7
|
let unitTestReport = [];
|
12
|
-
|
13
8
|
const result = inp => {
|
14
9
|
inp.endTime = Date.now();
|
15
10
|
let testPathPattern = process.argv[process.argv.length - 1];
|
16
|
-
|
17
11
|
if (testPathPattern.indexOf('--') !== -1) {
|
18
12
|
testPathPattern = '';
|
19
13
|
} else {
|
20
14
|
testPathPattern = _fs.default.realpathSync(process.cwd());
|
21
15
|
}
|
22
|
-
|
23
16
|
let testPathRegex = new RegExp(testPathPattern);
|
24
17
|
let {
|
25
18
|
testResults
|
@@ -27,11 +20,9 @@ const result = inp => {
|
|
27
20
|
let testFilesArr = [];
|
28
21
|
testResults.forEach(testResult => {
|
29
22
|
let filePath = testResult.testFilePath;
|
30
|
-
|
31
23
|
if (!testPathRegex.test(filePath)) {
|
32
24
|
return;
|
33
25
|
}
|
34
|
-
|
35
26
|
filePath = filePath.replace('.spec', '');
|
36
27
|
filePath = filePath.replace('/__tests__', '');
|
37
28
|
filePath = filePath.replace('/__test__', '');
|
@@ -48,35 +39,28 @@ const result = inp => {
|
|
48
39
|
});
|
49
40
|
});
|
50
41
|
});
|
51
|
-
|
52
42
|
let coverageSummary = _fs.default.readFileSync('./coverage/coverage-summary.json').toString();
|
53
|
-
|
54
43
|
if (coverageSummary.indexOf('\\') !== -1) {
|
55
44
|
coverageSummary = coverageSummary.replace(/\\/g, '\\\\');
|
56
45
|
}
|
57
|
-
|
58
46
|
let coverageJson = JSON.parse(coverageSummary);
|
59
47
|
let linesPercent = 0;
|
60
48
|
let functionPercent = 0;
|
61
49
|
let statementPerment = 0;
|
62
50
|
let branchesPercent = 0;
|
63
51
|
let i = 0;
|
64
|
-
|
65
52
|
for (i; i < testFilesArr.length; i++) {
|
66
53
|
let curSourceFile = testFilesArr[i].sourcePath;
|
67
54
|
let coverageData = coverageJson[curSourceFile];
|
68
|
-
|
69
55
|
if (!coverageData) {
|
70
56
|
(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.`);
|
71
57
|
continue;
|
72
58
|
}
|
73
|
-
|
74
59
|
linesPercent += coverageData.lines.pct;
|
75
60
|
functionPercent += coverageData.functions.pct;
|
76
61
|
statementPerment += coverageData.statements.pct;
|
77
62
|
branchesPercent += coverageData.branches.pct;
|
78
63
|
}
|
79
|
-
|
80
64
|
let totalLinesPercent = linesPercent / (i * 100) * 100;
|
81
65
|
let totalFunctionPercent = functionPercent / (i * 100) * 100;
|
82
66
|
let totalStatementPercent = statementPerment / (i * 100) * 100;
|
@@ -85,14 +69,12 @@ const result = inp => {
|
|
85
69
|
let coverage = (totalPercentage / 4).toFixed(2);
|
86
70
|
coverage = Number(coverage);
|
87
71
|
(0, _jsonMaker.default)(inp, coverage, 'Yes', 'unitcase');
|
88
|
-
|
89
72
|
if (Number.isNaN(coverage)) {
|
90
73
|
(0, _utils.log)('This build does\'t have any JS changes!');
|
91
74
|
coverage = 0;
|
92
75
|
} else {
|
93
76
|
(0, _utils.log)(`COVERAGE ${coverage}%`);
|
94
77
|
}
|
95
|
-
|
96
78
|
let html = `<html>
|
97
79
|
<head>
|
98
80
|
<style>
|
@@ -134,14 +116,10 @@ const result = inp => {
|
|
134
116
|
</body>
|
135
117
|
</html>
|
136
118
|
`;
|
137
|
-
|
138
119
|
if (!_fs.default.existsSync('./unittest')) {
|
139
120
|
_fs.default.mkdirSync('./unittest');
|
140
121
|
}
|
141
|
-
|
142
122
|
_fs.default.writeFileSync('./unittest/index.html', html, 'utf8');
|
143
|
-
|
144
123
|
return inp;
|
145
124
|
};
|
146
|
-
|
147
125
|
module.exports = result;
|
package/lib/jest/run.js
CHANGED
@@ -1,17 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _jest = require("jest");
|
4
|
-
|
5
4
|
var _fs = _interopRequireDefault(require("fs"));
|
6
|
-
|
7
5
|
var _utils = require("../utils");
|
8
|
-
|
9
6
|
var _jsonHelper = require("../utils/jsonHelper");
|
10
|
-
|
11
7
|
var _coverageCollector = _interopRequireDefault(require("./coverageCollector"));
|
12
|
-
|
13
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
14
|
-
|
15
9
|
let options = (0, _utils.getOptions)();
|
16
10
|
let {
|
17
11
|
app: {
|
@@ -27,9 +21,7 @@ let {
|
|
27
21
|
}
|
28
22
|
} = options;
|
29
23
|
let argv = process.argv.slice(2);
|
30
|
-
|
31
24
|
let config = require('../configs/jest.config');
|
32
|
-
|
33
25
|
if (isCommitCoverage) {
|
34
26
|
(0, _coverageCollector.default)(srcBranch, targetBranch, serviceName, impactServerDomain).then((res = {}) => {
|
35
27
|
if (res.STATUS) {
|
@@ -37,15 +29,12 @@ if (isCommitCoverage) {
|
|
37
29
|
let content = {
|
38
30
|
FILES: res.LIST
|
39
31
|
};
|
40
|
-
|
41
32
|
if (!_fs.default.existsSync('./coverageTest')) {
|
42
33
|
_fs.default.mkdirSync('./coverageTest');
|
43
|
-
|
44
34
|
_fs.default.writeFileSync('./coverageTest/result.json', JSON.stringify(content), 'utf8');
|
45
35
|
} else {
|
46
36
|
_fs.default.writeFileSync('./coverageTest/result.json', JSON.stringify(content), 'utf8');
|
47
37
|
}
|
48
|
-
|
49
38
|
argv.push('--findRelatedTests');
|
50
39
|
argv = argv.concat(res.LIST);
|
51
40
|
argv = argv.concat(['--config', JSON.stringify(config(null, true))]);
|
@@ -53,12 +42,12 @@ if (isCommitCoverage) {
|
|
53
42
|
argv.push('--silent');
|
54
43
|
(0, _jest.run)(argv);
|
55
44
|
} else {
|
56
|
-
(0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, ['tests', 'modifiedFileUnitCase', 'hasChanges'], false);
|
45
|
+
(0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, ['tests', 'modifiedFileUnitCase', 'hasChanges'], false);
|
46
|
+
// jsonHelper(
|
57
47
|
// `${process.cwd()}/result.json`,
|
58
48
|
// 'testInfo.isBuildVerified',
|
59
49
|
// true
|
60
50
|
// );
|
61
|
-
|
62
51
|
(0, _jsonHelper.setTestInfoStatus)(`${process.cwd()}/result.json`, true);
|
63
52
|
(0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'testInfo.failures', [{
|
64
53
|
type: 'modifiedUnitcases',
|
@@ -67,17 +56,17 @@ if (isCommitCoverage) {
|
|
67
56
|
(0, _utils.log)('No JS changes with last changeset!');
|
68
57
|
}
|
69
58
|
} else {
|
70
|
-
(0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, ['tests', 'modifiedFileUnitCase', 'isExecuted'], res.STATUS);
|
59
|
+
(0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, ['tests', 'modifiedFileUnitCase', 'isExecuted'], res.STATUS);
|
60
|
+
// jsonHelper(
|
71
61
|
// `${process.cwd()}/result.json`,
|
72
62
|
// 'testInfo.isBuildVerified',
|
73
63
|
// true
|
74
64
|
// );
|
75
|
-
|
76
|
-
|
65
|
+
(0, _jsonHelper.setTestInfoStatus)(`${process.cwd()}/result.json`, true);
|
66
|
+
// jsonHelper(`${process.cwd()}/result.json`, 'testInfo.failures', [{
|
77
67
|
// type: 'modifiedUnitcases',
|
78
68
|
// message: res.REASON
|
79
69
|
// }]);
|
80
|
-
|
81
70
|
(0, _utils.log)(res.REASON);
|
82
71
|
}
|
83
72
|
});
|
package/lib/jest/setup.js
CHANGED
@@ -1,22 +1,15 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _jsdom = require("jsdom");
|
4
|
-
|
5
4
|
var _testUtils = _interopRequireDefault(require("react-dom/test-utils"));
|
6
|
-
|
7
5
|
var _react = _interopRequireDefault(require("react"));
|
8
|
-
|
9
6
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
10
|
-
|
11
7
|
var _reactDom = _interopRequireDefault(require("react-dom"));
|
12
|
-
|
13
8
|
var _xhr = _interopRequireDefault(require("xhr2"));
|
14
|
-
|
15
9
|
var _nock = _interopRequireDefault(require("nock"));
|
16
|
-
|
17
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
18
|
-
|
19
11
|
//$Id$//
|
12
|
+
|
20
13
|
let mockDomain = 'htt' + 'p://zoho.com';
|
21
14
|
const {
|
22
15
|
document
|
@@ -28,181 +21,136 @@ global.localStorage = global.sessionStorage = {
|
|
28
21
|
getItem(key) {
|
29
22
|
return this[key];
|
30
23
|
},
|
31
|
-
|
32
24
|
setItem(key, value) {
|
33
25
|
if (value.length > 100) {
|
34
26
|
throw new Error('Data size is too exceeded');
|
35
27
|
}
|
36
|
-
|
37
28
|
this[key] = value;
|
38
29
|
},
|
39
|
-
|
40
30
|
removeItem(key) {
|
41
31
|
delete this[key];
|
42
32
|
},
|
43
|
-
|
44
33
|
clear() {
|
45
34
|
let keys = ['getItem', 'setItem', 'removeItem', 'clear'];
|
46
|
-
|
47
35
|
for (let key in this) {
|
48
36
|
if (keys.indexOf(key) === -1) {
|
49
37
|
delete this[key];
|
50
38
|
}
|
51
39
|
}
|
52
40
|
}
|
53
|
-
|
54
41
|
};
|
55
42
|
global.ZE_Init = {};
|
56
|
-
|
57
43
|
global.String.prototype.contains = function (text) {
|
58
44
|
return this.indexOf(text) != -1;
|
59
45
|
};
|
60
|
-
|
61
46
|
global.TestUtils = _testUtils.default;
|
62
47
|
let xmlReq = _xhr.default;
|
63
|
-
|
64
48
|
window.XMLHttpRequest = function () {
|
65
49
|
let xmlReqCopy = new xmlReq();
|
66
50
|
let originalOpen = xmlReqCopy.open;
|
67
|
-
|
68
51
|
xmlReqCopy.open = function () {
|
69
52
|
if (arguments[1].indexOf('http') != 0) {
|
70
53
|
arguments[1] = mockDomain + arguments[1];
|
71
54
|
}
|
72
|
-
|
73
55
|
return originalOpen.apply(this, arguments);
|
74
56
|
};
|
75
|
-
|
76
57
|
return xmlReqCopy;
|
77
58
|
};
|
78
|
-
|
79
59
|
_testUtils.default.scryRenderedComponentsWithTestid = function (dom, name) {
|
80
60
|
let componentList = _testUtils.default.findAllInRenderedTree(dom, (i, j) => {
|
81
61
|
if (_testUtils.default.isDOMComponent(i)) {
|
82
62
|
let val = i.getAttribute('data-id');
|
83
|
-
|
84
63
|
if (typeof val !== 'undefined' && val == name) {
|
85
64
|
return true;
|
86
65
|
}
|
87
|
-
|
88
66
|
return false;
|
89
67
|
}
|
90
68
|
});
|
91
|
-
|
92
69
|
return componentList;
|
93
70
|
};
|
94
|
-
|
95
71
|
_testUtils.default.findRenderedComponentsWithTestid = function (dom, name) {
|
96
72
|
let list = _testUtils.default.scryRenderedComponentsWithTestid(dom, name);
|
97
|
-
|
98
73
|
if (list.length !== 1) {
|
99
74
|
throw new Error(`Did not find exactly one match (found: ${list.length}) ` + `for data-id:${name}`);
|
100
75
|
}
|
101
|
-
|
102
76
|
return list[0];
|
103
77
|
};
|
104
|
-
|
105
78
|
global.render = function (Component, props) {
|
106
79
|
const renderedDOM = _testUtils.default.renderIntoDocument( /*#__PURE__*/_react.default.createElement(Component, props));
|
107
|
-
|
108
80
|
return {
|
109
81
|
props,
|
110
82
|
renderedDOM
|
111
83
|
};
|
112
84
|
};
|
113
|
-
|
114
85
|
global.setup = function (Component, props, state) {
|
115
86
|
let router = {
|
116
87
|
router: {
|
117
88
|
push() {},
|
118
|
-
|
119
89
|
createHref(ob) {
|
120
90
|
return ob.pathname;
|
121
91
|
},
|
122
|
-
|
123
92
|
isActive() {
|
124
93
|
return true;
|
125
94
|
},
|
126
|
-
|
127
95
|
replace() {},
|
128
|
-
|
129
96
|
go() {},
|
130
|
-
|
131
97
|
goBack() {},
|
132
|
-
|
133
98
|
goForward() {},
|
134
|
-
|
135
99
|
setRouteLeaveHook() {},
|
136
|
-
|
137
100
|
getState() {}
|
138
|
-
|
139
101
|
},
|
140
102
|
store: {
|
141
103
|
getState() {
|
142
104
|
return state;
|
143
105
|
}
|
144
|
-
|
145
106
|
}
|
146
|
-
};
|
107
|
+
};
|
108
|
+
// var store = {
|
147
109
|
// store:{
|
148
110
|
// getState:function(){return state;}
|
149
111
|
// }
|
150
112
|
// }
|
151
|
-
|
152
113
|
var Component = higherComponent(Component, router);
|
153
|
-
|
154
114
|
const renderedDOM = _testUtils.default.renderIntoDocument( /*#__PURE__*/_react.default.createElement(Component, props), router);
|
155
|
-
|
156
115
|
return {
|
157
116
|
props,
|
158
117
|
renderedDOM
|
159
118
|
};
|
160
119
|
};
|
161
|
-
|
162
120
|
function higherComponent(ActualComponent, context) {
|
163
121
|
if (context) {
|
164
122
|
class HigherComponent extends _react.default.Component {
|
165
123
|
constructor() {
|
166
124
|
super();
|
167
125
|
}
|
168
|
-
|
169
126
|
getChildContext() {
|
170
127
|
return context;
|
171
128
|
}
|
172
|
-
|
173
129
|
render() {
|
174
130
|
return /*#__PURE__*/_react.default.createElement(ActualComponent, this.props);
|
175
131
|
}
|
176
|
-
|
177
132
|
}
|
178
|
-
|
179
133
|
HigherComponent.childContextTypes = {
|
180
134
|
router: _propTypes.default.any,
|
181
135
|
store: _propTypes.default.any
|
182
136
|
};
|
183
137
|
return HigherComponent;
|
184
138
|
}
|
185
|
-
|
186
139
|
return ActualComponent;
|
187
140
|
}
|
188
|
-
|
189
141
|
global.window.matchMedia = window.matchMedia || function () {
|
190
142
|
return {
|
191
143
|
matches: false,
|
192
|
-
|
193
144
|
addListener() {},
|
194
|
-
|
195
145
|
removeListener() {}
|
196
|
-
|
197
146
|
};
|
198
|
-
};
|
147
|
+
};
|
148
|
+
// global.renderHTML = function(comp) {
|
199
149
|
// return ReactDOM.findDOMNode(comp);
|
200
150
|
// };
|
201
151
|
|
202
|
-
|
203
152
|
global.TestUtils = _testUtils.default;
|
204
153
|
global.XMLHttpRequest = window.XMLHttpRequest;
|
205
|
-
|
206
154
|
global.getI18NValue = function (inp) {
|
207
155
|
return inp;
|
208
156
|
};
|
@@ -10,57 +10,47 @@ exports.configSVGLoader = configSVGLoader;
|
|
10
10
|
exports.configVideoLoader = configVideoLoader;
|
11
11
|
exports.configVideoLoaderObj = configVideoLoaderObj;
|
12
12
|
exports.createNameTemplate = createNameTemplate;
|
13
|
-
|
14
13
|
var _path = _interopRequireDefault(require("path"));
|
15
|
-
|
16
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
17
|
-
|
18
15
|
// function getLoaderOptionQueryString(params) {
|
19
16
|
const ImageExtRegex = /\.jpe?g$|\.gif$|\.png$/;
|
20
17
|
const FontExtRegex = /\.woff2|\.woff$|\.ttf$|\.eot$/;
|
21
18
|
const SVGExtRegex = /\.svg$/;
|
22
19
|
const AudioExtRegex = /\.ogg$/;
|
23
20
|
const VidioExtRegex = /\.mp4$/;
|
24
|
-
|
25
21
|
function createLoaderOptionQueryString(loaderName, nameTemplate, limit = 1000) {
|
26
22
|
return `${loaderName}?limit=${limit}&name=${nameTemplate}`;
|
27
23
|
}
|
28
|
-
|
29
24
|
function configImageLoader(nameTemplate) {
|
30
25
|
return {
|
31
26
|
test: ImageExtRegex,
|
32
27
|
use: createLoaderOptionQueryString('url-loader', `./images/${nameTemplate}`)
|
33
28
|
};
|
34
29
|
}
|
35
|
-
|
36
30
|
function configFontLoader(nameTemplate) {
|
37
31
|
return {
|
38
32
|
test: FontExtRegex,
|
39
33
|
use: createLoaderOptionQueryString('url-loader', `./fonts/${nameTemplate}`)
|
40
34
|
};
|
41
35
|
}
|
42
|
-
|
43
36
|
function configSVGLoader(nameTemplate) {
|
44
37
|
return {
|
45
38
|
test: SVGExtRegex,
|
46
39
|
use: createLoaderOptionQueryString('url-loader', `./fonts/${nameTemplate}`, 1)
|
47
40
|
};
|
48
41
|
}
|
49
|
-
|
50
42
|
function configAudioLoader(nameTemplate) {
|
51
43
|
return {
|
52
44
|
test: AudioExtRegex,
|
53
45
|
use: createLoaderOptionQueryString('file-loader', `./fonts/${nameTemplate}`, 1)
|
54
46
|
};
|
55
47
|
}
|
56
|
-
|
57
48
|
function configVideoLoader(nameTemplate) {
|
58
49
|
return {
|
59
50
|
test: VidioExtRegex,
|
60
51
|
use: createLoaderOptionQueryString('url-loader', `./images/${nameTemplate}`, 1)
|
61
52
|
};
|
62
53
|
}
|
63
|
-
|
64
54
|
function configVideoLoaderObj(nameTemplate) {
|
65
55
|
return {
|
66
56
|
test: VidioExtRegex,
|
@@ -74,44 +64,44 @@ function configVideoLoaderObj(nameTemplate) {
|
|
74
64
|
}
|
75
65
|
};
|
76
66
|
}
|
77
|
-
|
78
67
|
function createNameTemplate(enableChunkHash) {
|
79
68
|
const ext = `${enableChunkHash ? '.[hash:20]' : ''}.[ext]`;
|
80
69
|
return `[name]${ext}`;
|
81
70
|
}
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
71
|
+
|
72
|
+
/*
|
73
|
+
export function createImageAndFontsAndSVGLoaders(enableChunkHash) {
|
74
|
+
const nameTemplate = createNameTemplate(enableChunkHash);
|
75
|
+
return [
|
76
|
+
configImageLoader(nameTemplate),
|
77
|
+
configFontLoader(nameTemplate),
|
78
|
+
configSVGLoader(nameTemplate),
|
79
|
+
configAudioLoader(nameTemplate)
|
80
|
+
];
|
81
|
+
}
|
92
82
|
*/
|
93
83
|
|
94
|
-
/*
|
95
|
-
export function createLoaderOptionObject(
|
96
|
-
loaderName,
|
97
|
-
nameTemplate,
|
98
|
-
fallback,
|
99
|
-
limit = 1000
|
100
|
-
) {
|
101
|
-
return {
|
102
|
-
loader: loaderName,
|
103
|
-
options: {
|
104
|
-
limit,
|
105
|
-
name: nameTemplate,
|
106
|
-
fallback
|
107
|
-
}
|
108
|
-
};
|
109
|
-
}
|
110
|
-
|
111
|
-
function configLoaderObject(filter, loaderAndOptions) {
|
112
|
-
return {
|
113
|
-
test: filter,
|
114
|
-
use: loaderAndOptions
|
115
|
-
};
|
116
|
-
}
|
84
|
+
/*
|
85
|
+
export function createLoaderOptionObject(
|
86
|
+
loaderName,
|
87
|
+
nameTemplate,
|
88
|
+
fallback,
|
89
|
+
limit = 1000
|
90
|
+
) {
|
91
|
+
return {
|
92
|
+
loader: loaderName,
|
93
|
+
options: {
|
94
|
+
limit,
|
95
|
+
name: nameTemplate,
|
96
|
+
fallback
|
97
|
+
}
|
98
|
+
};
|
99
|
+
}
|
100
|
+
|
101
|
+
function configLoaderObject(filter, loaderAndOptions) {
|
102
|
+
return {
|
103
|
+
test: filter,
|
104
|
+
use: loaderAndOptions
|
105
|
+
};
|
106
|
+
}
|
117
107
|
*/
|