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