@zohodesk/react-cli 0.0.1-beta.16 → 0.0.1-beta.162
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/.eslintignore +1 -0
- package/.eslintrc.js +46 -3
- package/CHANGELOG.md +5 -0
- package/README.md +708 -0
- package/bin/cli.js +134 -27
- package/cert/cert.pem +37 -129
- package/cert/key.pem +27 -27
- package/cert/passphrase.pem +1 -0
- package/files/eslintrc.js +62 -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 +33 -24
- package/lib/common/getPublicPathConfig.js +40 -0
- package/lib/common/index.js +27 -13
- package/lib/common/splitChunks.js +64 -26
- package/lib/common/sslcertUpdater.js +59 -0
- package/lib/common/templateParameters.js +25 -0
- package/lib/configs/jest.config.js +26 -27
- package/lib/configs/libAlias.js +31 -0
- package/lib/configs/webpack.component.umd.config.js +31 -37
- package/lib/configs/webpack.css.umd.config.js +44 -44
- package/lib/configs/webpack.dev.config.js +96 -56
- package/lib/configs/webpack.docs.config.js +104 -98
- package/lib/configs/webpack.impact.config.js +116 -0
- package/lib/configs/webpack.prod.config.js +137 -85
- package/lib/hooks/docsProptypeHook.js +32 -38
- package/lib/jest/commitedFilesResult.js +144 -71
- package/lib/jest/coverageCollector.js +62 -29
- package/lib/jest/jsonMaker.js +54 -0
- package/lib/jest/preProcessors/cssPreprocessor.js +16 -18
- package/lib/jest/preProcessors/jsPreprocessor.js +5 -6
- package/lib/jest/preProcessors/otherFilesPreprocessor.js +5 -6
- package/lib/jest/result.js +91 -41
- package/lib/jest/run.js +74 -27
- package/lib/jest/setup.js +103 -102
- package/lib/loaderUtils/getCSSLoaders.js +77 -0
- package/lib/loaderUtils/getDevJsLoaders.js +30 -23
- package/lib/loaderUtils/index.js +14 -7
- package/lib/loaders/docsLoader.js +15 -15
- package/lib/loaders/docsPropsLoader.js +14 -17
- package/lib/loaders/fileBountryLoader.js +17 -0
- package/lib/loaders/fileLoader.js +47 -38
- package/lib/loaders/scriptInstrumentLoader.js +21 -20
- package/lib/loaders/selectorMappingLoader.js +75 -0
- package/lib/loaders/workerLoader.js +136 -0
- package/lib/middlewares/HMRMiddleware.js +59 -41
- package/lib/middlewares/SSTMiddleware.js +21 -0
- package/lib/pluginUtils/getDevPlugins.js +175 -26
- package/lib/pluginUtils/getDocsPlugins.js +32 -17
- package/lib/pluginUtils/getLibraryImactPlugins.js +23 -0
- package/lib/pluginUtils/getLibraryPlugins.js +8 -10
- package/lib/pluginUtils/getProdPlugins.js +240 -37
- 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 +77 -0
- package/lib/plugins/CleanupStatsPlugin.js +28 -0
- package/lib/plugins/EFCPlugin.js +241 -0
- package/lib/plugins/EFCPlugin.md +6 -0
- package/lib/plugins/EFCTemplatePlugin.js +151 -0
- package/lib/plugins/I18NInjectIntoIndexPlugin.js +141 -0
- 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 +59 -62
- package/lib/plugins/ModuleStatsPlugin.js +98 -97
- package/lib/plugins/OptimizeJSPlugin.js +24 -41
- package/lib/plugins/PublicPathCallbackPlugin.js +63 -0
- package/lib/plugins/PublicPathChangePlugin.js +187 -174
- package/lib/plugins/ReportGeneratePlugin.js +181 -0
- package/lib/plugins/RequireVariablePublicPlugin.js +30 -0
- package/lib/plugins/ResourceHintsPlugin.js +53 -35
- package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +80 -0
- package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +82 -0
- package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -0
- package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +26 -0
- package/lib/plugins/ScriptInstrumentPlugin.js +22 -37
- package/lib/plugins/ServiceWorkerPlugin.js +107 -0
- package/lib/plugins/ShadowDOMSupportPlugin.js +270 -0
- package/lib/plugins/SourceMapHookPlugin.js +25 -31
- package/lib/plugins/TPHashMappingPlugin.js +67 -0
- package/lib/plugins/UglifyCSSPlugin.js +23 -30
- package/lib/plugins/UnusedFilesFindPlugin.js +150 -97
- package/lib/plugins/index.js +118 -55
- package/lib/plugins/libraryImpactPlugin.js +190 -0
- package/lib/plugins/webpackwatchrunplugin.js +26 -0
- package/lib/postcss-plugins/ExcludeRTLPlugin.js +23 -0
- package/lib/postcss-plugins/RTLSplitPlugin.js +138 -0
- package/lib/schemas/index.js +466 -52
- package/lib/servers/clusterHubServer.js +22 -26
- package/lib/servers/docsServer.js +3 -5
- package/lib/servers/docsServerCore.js +93 -85
- package/lib/servers/helpServer.js +19 -21
- package/lib/servers/httpsOptions.js +19 -0
- package/lib/servers/impactServer.js +99 -92
- package/lib/servers/mockserver.js +44 -0
- package/lib/servers/nowatchserver.js +275 -0
- package/lib/servers/scrServer.js +147 -0
- package/lib/servers/server.js +118 -124
- package/lib/servers/ssServer.js +107 -65
- package/lib/sh/reportPublish.sh +16 -10
- package/lib/templates/CoverageScriptTemplate.js +45 -18
- package/lib/templates/WMSTemplate.js +17 -18
- package/lib/templates/linterConstant.js +10 -0
- package/lib/utils/babelPresets.js +12 -5
- package/lib/utils/buildstats.html +148 -0
- package/lib/utils/clean.js +12 -11
- package/lib/utils/copy.js +13 -127
- package/lib/utils/copyTimezones.js +21 -0
- package/lib/utils/createEventStream.js +24 -19
- package/lib/utils/cssClassNameGenerate.js +77 -0
- package/lib/utils/cssURLReplacer.js +67 -54
- package/lib/utils/dependencyPostPublish.js +42 -0
- package/lib/utils/fileUtils.js +125 -0
- package/lib/utils/folderIterator.js +47 -0
- package/lib/utils/getComponents.js +126 -0
- package/lib/utils/getCurrentBranch.js +11 -17
- package/lib/utils/getDependenciesImpactList.js +151 -0
- package/lib/utils/getHash.js +26 -0
- package/lib/utils/getIp.js +20 -0
- package/lib/utils/getOptions.js +55 -30
- package/lib/utils/getServerURL.js +25 -8
- package/lib/utils/index.js +259 -82
- package/lib/utils/init.js +2 -2
- package/lib/utils/initPreCommitHook.js +40 -31
- package/lib/utils/jsonHelper.js +97 -0
- package/lib/utils/libraryImpactConfig.js +63 -0
- 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 +142 -0
- package/lib/utils/mailSender.js +16 -25
- package/lib/utils/pullOrigin.js +28 -0
- package/lib/utils/reinstallDependencies.js +133 -0
- package/lib/utils/removeAttributes.js +25 -23
- package/lib/utils/repoClone.js +56 -63
- package/lib/utils/request.js +64 -77
- package/lib/utils/resultSchema.json +73 -0
- package/lib/utils/rtl.js +42 -0
- package/lib/utils/setEnvVariables.js +5 -6
- package/lib/utils/ssTestHack.js +48 -0
- package/lib/utils/switchBranch.js +28 -0
- package/lib/utils/urlConcat.js +22 -0
- package/package.json +92 -64
- package/templates/app/.eslintrc.js +140 -0
- package/templates/app/README.md +12 -12
- package/templates/app/app/index.html +24 -8
- 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 -13
- package/templates/app/package.json +37 -17
- package/templates/app/src/actions/SampleActions/index.js +37 -0
- package/templates/app/src/actions/index.js +65 -0
- package/templates/app/src/appUrls.js +19 -0
- package/templates/app/src/components/Alert/Alert.js +134 -0
- package/templates/app/src/components/Alert/Alert.module.css +79 -0
- package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -0
- package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -0
- package/templates/app/src/components/Sample/Sample.module.css +11 -0
- package/templates/app/src/components/Sample/SampleList.js +61 -0
- package/templates/app/src/components/Slider/Slider.css +41 -0
- package/templates/app/src/components/Slider/Slider.js +55 -0
- package/templates/app/src/containers/AlertContainer/index.js +15 -0
- package/templates/app/src/containers/AppContainer/index.js +96 -0
- package/templates/app/src/containers/AppContainer/index.module.css +27 -0
- package/templates/app/src/containers/CustomMatch/index.js +65 -0
- package/templates/app/src/containers/DevTools/index.js +10 -0
- package/templates/app/src/containers/Header/index.js +67 -0
- package/templates/app/src/containers/Header/index.module.css +43 -0
- package/templates/app/src/containers/Redirect/index.js +63 -0
- package/templates/app/src/containers/Redirector/index.js +47 -0
- package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -0
- package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -0
- package/templates/app/src/historyChange.js +5 -0
- package/templates/app/src/index.html +10 -0
- package/templates/app/src/index.js +24 -0
- package/templates/app/src/middleware/PromiseMiddleware.js +59 -0
- package/templates/app/src/reducers/alertData.js +11 -0
- package/templates/app/src/reducers/index.js +6 -0
- package/templates/app/src/reducers/samples.js +19 -0
- package/templates/app/src/store/configureStore.dev.js +51 -0
- package/templates/app/src/store/configureStore.js +5 -0
- package/templates/app/src/store/configureStore.prod.js +26 -0
- package/templates/app/src/util/Common.js +5 -0
- package/templates/app/src/util/RequestAPI.js +132 -0
- package/templates/appold/README.md +12 -0
- package/templates/appold/app/index.html +8 -0
- package/templates/appold/app/properties/ApplicationResources_en_US.properties +1 -0
- package/templates/appold/app/properties/i18nkeys.json +3 -0
- package/templates/appold/docs/all.html +69 -0
- package/templates/appold/mockapi/index.js +13 -0
- package/templates/{app → appold}/mockapi/tickets.json +0 -0
- package/templates/appold/package.json +17 -0
- package/templates/appold/src/components/Text/Text.css +0 -0
- package/templates/appold/src/components/Text/Text.js +23 -0
- package/templates/appold/src/components/Text/__tests__/Text.spec.js +30 -0
- package/templates/appold/src/components/Text/docs/Text__default.docs.js +16 -0
- package/templates/appold/src/components/docs.js +1 -0
- package/templates/appold/src/components/index.js +5 -0
- package/templates/appold/src/index.js +13 -0
- package/templates/docs/all.html +1 -1
- package/templates/docs/component.html +110 -69
- package/templates/docs/components.html +221 -0
- package/templates/docs/css/component.css +12 -14
- package/templates/docs/css/componentTest.css +7 -0
- package/templates/docs/css/style.css +150 -206
- package/templates/docs/impactReportTemplate.html +154 -0
- package/templates/docs/index.html +1482 -1336
- package/templates/library/src/index.js +0 -0
@@ -1,69 +1,92 @@
|
|
1
|
-
|
1
|
+
"use strict";
|
2
2
|
|
3
|
-
var _path = require(
|
3
|
+
var _path = _interopRequireDefault(require("path"));
|
4
4
|
|
5
|
-
var
|
5
|
+
var _utils = require("../utils");
|
6
6
|
|
7
|
-
var
|
7
|
+
var _common = require("../common");
|
8
8
|
|
9
|
-
var
|
9
|
+
var _pluginUtils = require("../pluginUtils");
|
10
10
|
|
11
|
-
var
|
11
|
+
var _loaderUtils = require("../loaderUtils");
|
12
12
|
|
13
|
-
var
|
14
|
-
|
15
|
-
var _pluginUtils = require('../pluginUtils');
|
13
|
+
var _libAlias = require("./libAlias");
|
16
14
|
|
17
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
18
16
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
folder
|
23
|
-
context
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
17
|
+
let options = (0, _utils.getOptions)();
|
18
|
+
let {
|
19
|
+
app: {
|
20
|
+
folder,
|
21
|
+
context,
|
22
|
+
enableChunkHash,
|
23
|
+
outputFolder,
|
24
|
+
disableES5Transpile,
|
25
|
+
removeAttribute,
|
26
|
+
enableSMap,
|
27
|
+
server,
|
28
|
+
hasRTL,
|
29
|
+
rtlExclude,
|
30
|
+
cssUniqueness,
|
31
|
+
server: {
|
32
|
+
mode
|
33
|
+
},
|
34
|
+
seperateCssModules,
|
35
|
+
changeRuntimeChunkChar,
|
36
|
+
cssHashSelectors,
|
37
|
+
classNamePrefix,
|
38
|
+
selectorReplace,
|
39
|
+
removePropTypes,
|
40
|
+
devConsoleExculde,
|
41
|
+
crossorigin
|
42
|
+
}
|
43
|
+
} = options;
|
44
|
+
let appPath = process.cwd();
|
45
|
+
let isDevelopment = mode === 'prod' || mode === 'dev' || mode === 'dev-no-warn';
|
39
46
|
enableChunkHash = !isDevelopment && enableChunkHash;
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
47
|
+
let output = {
|
48
|
+
path: _path.default.resolve(appPath, outputFolder),
|
49
|
+
filename: enableChunkHash ? 'js/[name].[chunkhash:20]_.js' : 'js/[name]_.js',
|
50
|
+
chunkFilename: enableChunkHash ? 'js/[name].[chunkhash:20]_.js' : 'js/[name]_.js',
|
51
|
+
jsonpFunction: `${context}Jsonp`,
|
52
|
+
sourceMapFilename: enableChunkHash ? 'js/[name].[chunkhash:20]_.js.map' : 'js/[name]_.js.map'
|
53
|
+
};
|
54
|
+
|
55
|
+
if (crossorigin) {
|
56
|
+
output.crossOriginLoading = 'anonymous';
|
57
|
+
}
|
58
|
+
|
59
|
+
if (isDevelopment) {
|
60
|
+
let {
|
61
|
+
disableContextURL
|
62
|
+
} = server;
|
63
|
+
let contextURL = disableContextURL ? '' : context;
|
64
|
+
let serverUrl = (0, _utils.getServerURL)(server, 'https');
|
65
|
+
output.publicPath = `${[serverUrl, contextURL].filter(a => a).join('/')}/`;
|
66
|
+
}
|
67
|
+
|
68
|
+
let shouldRemovePropTypes = !isDevelopment && removePropTypes;
|
44
69
|
module.exports = {
|
45
70
|
entry: (0, _common.getEntries)(options, 'production'),
|
46
|
-
devtool: isDevelopment ? 'cheap-module-source-map' : 'hidden-source-map',
|
71
|
+
devtool: isDevelopment ? 'cheap-module-source-map' : enableSMap ? 'hidden-source-map' : 'none',
|
47
72
|
mode: 'production',
|
48
|
-
output
|
49
|
-
path: _path2.default.resolve(appPath, outputFolder),
|
50
|
-
filename: enableChunkHash ? rootFolder + 'js/[name].[chunkhash:20].js' : rootFolder + 'js/[name].js',
|
51
|
-
chunkFilename: enableChunkHash ? rootFolder + 'js/[name].[chunkhash:20].js' : rootFolder + 'js/[name].js',
|
52
|
-
jsonpFunction: context + 'Jsonp',
|
53
|
-
sourceMapFilename: enableChunkHash ? rootFolder + 'smap/[name].[chunkhash:20].map' : rootFolder + 'smap/[name].map'
|
54
|
-
},
|
73
|
+
output,
|
55
74
|
optimization: {
|
56
75
|
splitChunks: _common.splitChunks,
|
57
|
-
minimize: true,
|
58
76
|
runtimeChunk: {
|
59
|
-
name:
|
60
|
-
return 'runtime~' + entrypoint.name;
|
61
|
-
}
|
77
|
+
name: entrypoint => changeRuntimeChunkChar ? `./runtime-${entrypoint.name}` : `./runtime~${entrypoint.name}`
|
62
78
|
},
|
63
|
-
concatenateModules: true
|
79
|
+
concatenateModules: true,
|
80
|
+
minimize: true,
|
81
|
+
moduleIds: 'named'
|
64
82
|
},
|
65
|
-
stats: {
|
66
|
-
|
83
|
+
stats: {
|
84
|
+
children: false,
|
85
|
+
colors: true,
|
86
|
+
// excludeAssets: /i18n/,
|
87
|
+
warningsFilter: /\[mini-css-extract-plugin\]/
|
88
|
+
},
|
89
|
+
plugins: (0, _pluginUtils.getProdPlugins)(options, output.publicPath),
|
67
90
|
module: {
|
68
91
|
/* strictExportPresence for break the build when imported module not present in respective file */
|
69
92
|
strictExportPresence: true,
|
@@ -72,50 +95,53 @@ module.exports = {
|
|
72
95
|
use: [{
|
73
96
|
loader: 'babel-loader',
|
74
97
|
options: {
|
75
|
-
presets: [[require.resolve('babel
|
98
|
+
presets: [[require.resolve('@babel/preset-env'), disableES5Transpile ? {
|
76
99
|
modules: false,
|
77
|
-
useBuiltIns:
|
100
|
+
useBuiltIns: 'usage',
|
101
|
+
corejs: 3,
|
78
102
|
targets: {
|
79
|
-
browsers: ['Chrome
|
103
|
+
browsers: ['last 3 Chrome versions', 'last 3 Firefox versions', 'last 3 Edge versions', 'last 3 Safari versions']
|
80
104
|
}
|
81
|
-
} : {
|
82
|
-
|
105
|
+
} : {
|
106
|
+
modules: false
|
107
|
+
}], require.resolve('@babel/preset-react')],
|
108
|
+
plugins: disableES5Transpile ? [removeAttribute ? require.resolve('../utils/removeAttributes') : false, require.resolve('@babel/plugin-syntax-dynamic-import'), require.resolve('babel-plugin-lodash'), require.resolve('@babel/plugin-proposal-object-rest-spread'), devConsoleExculde ? [require.resolve('babel-plugin-transform-remove-console'), {
|
109
|
+
exclude: ['error', 'log']
|
110
|
+
}] : null].filter(Boolean) : [removeAttribute ? require.resolve('../utils/removeAttributes') : false, shouldRemovePropTypes ? [require.resolve('babel-plugin-transform-react-remove-prop-types'), removePropTypes] : false, [require.resolve('@babel/plugin-transform-runtime'), {
|
83
111
|
helpers: true,
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
}]
|
112
|
+
regenerator: false
|
113
|
+
}], require.resolve('@babel/plugin-proposal-object-rest-spread'), require.resolve('@babel/plugin-syntax-dynamic-import'), require.resolve('babel-plugin-lodash'), devConsoleExculde ? [require.resolve('babel-plugin-transform-remove-console'), {
|
114
|
+
exclude: ['error', 'log']
|
115
|
+
}] : null].filter(Boolean),
|
88
116
|
cacheDirectory: true
|
89
117
|
}
|
90
118
|
}],
|
91
|
-
include:
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
test: /(\.module)?\.css$/,
|
99
|
-
use: [{
|
100
|
-
loader: _miniCssExtractPlugin2.default.loader,
|
101
|
-
options: {
|
102
|
-
publicPath: '../'
|
103
|
-
}
|
104
|
-
}, {
|
105
|
-
loader: 'css-loader',
|
106
|
-
options: {
|
107
|
-
modules: true,
|
108
|
-
localIdentName: className
|
119
|
+
include: module => {
|
120
|
+
let srcPath = _path.default.join(appPath, folder);
|
121
|
+
|
122
|
+
let depsPath = _path.default.join(appPath, 'node_modules', '@zohodesk');
|
123
|
+
|
124
|
+
if (module.includes(srcPath) || devConsoleExculde && module.includes(depsPath)) {
|
125
|
+
return true;
|
109
126
|
}
|
110
|
-
|
127
|
+
|
128
|
+
return false;
|
129
|
+
}
|
130
|
+
}, seperateCssModules ? {
|
131
|
+
test: /\.css$/,
|
132
|
+
exclude: /\.module\.css$/,
|
133
|
+
use: (0, _loaderUtils.getCSSLoaders)(hasRTL, rtlExclude, '[local]', false, null)
|
134
|
+
} : null, {
|
135
|
+
test: seperateCssModules ? /\.module\.css$/ : /(\.module)?\.css$/,
|
136
|
+
use: (0, _loaderUtils.getCSSLoaders)(hasRTL, rtlExclude, false, cssUniqueness, selectorReplace, cssHashSelectors, classNamePrefix)
|
111
137
|
}, {
|
112
138
|
test: /\.jpe?g$|\.gif$|\.png$/,
|
113
139
|
use: [{
|
114
140
|
loader: 'url-loader',
|
115
141
|
options: {
|
116
142
|
limit: 1000,
|
117
|
-
name: enableChunkHash ?
|
118
|
-
fallback:
|
143
|
+
name: enableChunkHash ? './images/[name].[hash:20].[ext]' : './images/[name].[ext]',
|
144
|
+
fallback: _path.default.join(__dirname, '..', 'loaders', 'fileLoader.js')
|
119
145
|
}
|
120
146
|
}]
|
121
147
|
}, {
|
@@ -124,8 +150,8 @@ module.exports = {
|
|
124
150
|
loader: 'url-loader',
|
125
151
|
options: {
|
126
152
|
limit: 1000,
|
127
|
-
name: enableChunkHash ?
|
128
|
-
fallback:
|
153
|
+
name: enableChunkHash ? './fonts/[name].[hash:20].[ext]' : './fonts/[name].[ext]',
|
154
|
+
fallback: _path.default.join(__dirname, '..', 'loaders', 'fileLoader.js')
|
129
155
|
}
|
130
156
|
}]
|
131
157
|
}, {
|
@@ -134,19 +160,45 @@ module.exports = {
|
|
134
160
|
loader: 'url-loader',
|
135
161
|
options: {
|
136
162
|
limit: 1,
|
137
|
-
name: enableChunkHash ?
|
138
|
-
fallback:
|
163
|
+
name: enableChunkHash ? './fonts/[name].[hash:20].[ext]' : './fonts/[name].[ext]',
|
164
|
+
fallback: _path.default.join(__dirname, '..', 'loaders', 'fileLoader.js')
|
165
|
+
}
|
166
|
+
}]
|
167
|
+
}, {
|
168
|
+
test: /\.ogg$/,
|
169
|
+
use: [{
|
170
|
+
loader: 'file-loader',
|
171
|
+
options: {
|
172
|
+
name: enableChunkHash ? './fonts/[name].[hash:20].[ext]' : './fonts/[name].[ext]'
|
173
|
+
}
|
174
|
+
}]
|
175
|
+
}, {
|
176
|
+
test: /\.tmpl$/,
|
177
|
+
use: [{
|
178
|
+
loader: 'html-loader',
|
179
|
+
options: {
|
180
|
+
minimize: false
|
139
181
|
}
|
140
182
|
}]
|
141
|
-
}
|
183
|
+
}, {
|
184
|
+
test: /\.worker.js$/,
|
185
|
+
use: {
|
186
|
+
loader: require.resolve('../loaders/workerLoader.js'),
|
187
|
+
options: {
|
188
|
+
esModule: true,
|
189
|
+
filename: 'js/[name].[chunkhash:20].js'
|
190
|
+
}
|
191
|
+
}
|
192
|
+
}].filter(Boolean)
|
142
193
|
},
|
143
194
|
externals: {
|
144
195
|
ZC: '$ZC'
|
145
196
|
},
|
146
197
|
resolve: {
|
147
|
-
modules: [
|
198
|
+
modules: [_path.default.resolve(__dirname, '..', '..', 'node_modules'), 'node_modules'],
|
199
|
+
alias: disableES5Transpile ? _libAlias.libAlias : {}
|
148
200
|
},
|
149
201
|
resolveLoader: {
|
150
|
-
modules: [
|
202
|
+
modules: [_path.default.resolve(__dirname, '..', '..', 'node_modules'), 'node_modules']
|
151
203
|
}
|
152
204
|
};
|
@@ -1,51 +1,45 @@
|
|
1
|
-
|
1
|
+
"use strict";
|
2
2
|
|
3
|
-
var _propTypes = require(
|
4
|
-
|
5
|
-
var _propTypes2 = _interopRequireDefault(_propTypes);
|
3
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
6
4
|
|
7
5
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
8
6
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
function proxy(fn, type) {
|
28
|
-
var oneOf = fn;
|
29
|
-
return function () {
|
30
|
-
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
31
|
-
args[_key] = arguments[_key];
|
32
|
-
}
|
7
|
+
_propTypes.default.array.hookType = 'array';
|
8
|
+
_propTypes.default.bool.hookType = 'bool';
|
9
|
+
_propTypes.default.func.hookType = 'func';
|
10
|
+
_propTypes.default.number.hookType = 'number';
|
11
|
+
_propTypes.default.object.hookType = 'object';
|
12
|
+
_propTypes.default.string.hookType = 'string';
|
13
|
+
_propTypes.default.symbol.hookType = 'symbol';
|
14
|
+
_propTypes.default.element.hookType = 'element';
|
15
|
+
_propTypes.default.node.hookType = 'element';
|
16
|
+
_propTypes.default.array.isRequired.hookType = 'array';
|
17
|
+
_propTypes.default.bool.isRequired.hookType = 'bool';
|
18
|
+
_propTypes.default.func.isRequired.hookType = 'func';
|
19
|
+
_propTypes.default.number.isRequired.hookType = 'number';
|
20
|
+
_propTypes.default.object.isRequired.hookType = 'object';
|
21
|
+
_propTypes.default.string.isRequired.hookType = 'string';
|
22
|
+
_propTypes.default.symbol.isRequired.hookType = 'symbol';
|
23
|
+
_propTypes.default.element.isRequired.hookType = 'element';
|
24
|
+
_propTypes.default.node.isRequired.hookType = 'element';
|
33
25
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
26
|
+
function proxy(fn, type) {
|
27
|
+
let oneOf = fn;
|
28
|
+
return (...args) => {
|
29
|
+
let a = oneOf(...args);
|
30
|
+
let type1 = Array.isArray(args) && Array.isArray(args[0]) ? `${type}[${args[0].map(data => typeof data === 'function' ? data.hookType //arrayOf shape complex type not mention
|
31
|
+
: JSON.stringify(data))}]` : type;
|
39
32
|
a.hookType = type1;
|
33
|
+
|
40
34
|
if (a.isRequired) {
|
41
35
|
a.isRequired.hookType = type1;
|
42
36
|
}
|
37
|
+
|
43
38
|
return a;
|
44
39
|
};
|
45
40
|
}
|
46
|
-
_propTypes2.default.oneOf = proxy(_propTypes2.default.oneOf, 'enum');
|
47
|
-
_propTypes2.default.oneOfType = proxy(_propTypes2.default.oneOfType, 'union');
|
48
|
-
_propTypes2.default.arrayOf = proxy(_propTypes2.default.arrayOf, 'arrayOf');
|
49
|
-
_propTypes2.default.shape = proxy(_propTypes2.default.shape, 'shape');
|
50
41
|
|
51
|
-
|
42
|
+
_propTypes.default.oneOf = proxy(_propTypes.default.oneOf, 'enum');
|
43
|
+
_propTypes.default.oneOfType = proxy(_propTypes.default.oneOfType, 'union');
|
44
|
+
_propTypes.default.arrayOf = proxy(_propTypes.default.arrayOf, 'arrayOf');
|
45
|
+
_propTypes.default.shape = proxy(_propTypes.default.shape, 'shape'); // export default PropTypes;
|
@@ -1,127 +1,200 @@
|
|
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
|
7
|
+
var _jsonMaker = _interopRequireDefault(require("./jsonMaker"));
|
8
|
+
|
9
|
+
var _jsonHelper = require("../utils/jsonHelper");
|
8
10
|
|
9
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
-
|
13
|
+
let result = inp => {
|
14
|
+
inp.endTime = Date.now();
|
15
|
+
let testPathPattern = process.argv[process.argv.length - 1];
|
14
16
|
|
15
17
|
if (testPathPattern.indexOf('--') !== -1) {
|
16
18
|
testPathPattern = '';
|
17
19
|
} else {
|
18
|
-
testPathPattern =
|
20
|
+
testPathPattern = _fs.default.realpathSync(process.cwd());
|
19
21
|
}
|
20
|
-
var testPathRegex = new RegExp(testPathPattern);
|
21
|
-
var testResults = inp.testResults;
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
let testPathRegex = new RegExp(testPathPattern);
|
24
|
+
let {
|
25
|
+
testResults
|
26
|
+
} = inp;
|
27
|
+
let testFilesArr = [];
|
28
|
+
let testCaseFiles = [];
|
29
|
+
let jsonData;
|
26
30
|
|
27
|
-
if (
|
28
|
-
jsonData = JSON.parse(
|
31
|
+
if (_fs.default.existsSync('./coverageTest/result.json')) {
|
32
|
+
jsonData = JSON.parse(_fs.default.readFileSync('./coverageTest/result.json', 'utf8'));
|
29
33
|
}
|
30
|
-
|
31
|
-
|
34
|
+
|
35
|
+
testResults.forEach(testResult => {
|
36
|
+
let filePath = testResult.testFilePath;
|
32
37
|
|
33
38
|
if (!testPathRegex.test(filePath)) {
|
34
39
|
return;
|
35
40
|
}
|
41
|
+
|
36
42
|
filePath = filePath.replace('.spec', '');
|
37
43
|
filePath = filePath.replace('/__tests__', '');
|
38
44
|
filePath = filePath.replace('/__test__', '');
|
39
|
-
|
45
|
+
let relatPath = filePath.replace(process.cwd(), '').substring(1);
|
46
|
+
let fileJson = {};
|
47
|
+
fileJson.testPath = testResult.testFilePath;
|
48
|
+
fileJson.sourcePath = filePath;
|
49
|
+
fileJson.data = testResult;
|
50
|
+
testFilesArr.push(fileJson);
|
40
51
|
|
41
52
|
if (jsonData.FILES.includes(relatPath) || jsonData.FILES.includes(testResult.testFilePath.replace(process.cwd(), ''))) {
|
42
|
-
|
43
|
-
fileJson.testPath = testResult.testFilePath;
|
44
|
-
fileJson.sourcePath = filePath;
|
45
|
-
fileJson.data = testResult;
|
46
|
-
testFilesArr.push(fileJson);
|
47
|
-
jsonData.FILES.includes(relatPath) ? testCaseFiles.push(jsonData.FILES[relatPath]) : jsonData.FILES.includes(testResult.testFilePath.replace(process.cwd(), '')) ? testCaseFiles.push(testResult.testFilePath.replace(process.cwd(), '')) : '';
|
53
|
+
jsonData.FILES.includes(relatPath) ? testCaseFiles.push(relatPath) : jsonData.FILES.includes(testResult.testFilePath.replace(process.cwd(), '')) ? testCaseFiles.push(testResult.testFilePath.replace(process.cwd(), '')) : '';
|
48
54
|
}
|
49
|
-
testResult.testResults && testResult.testResults.filter(function (t) {
|
50
|
-
return t.status === 'failed';
|
51
|
-
}).forEach(function (t) {
|
52
|
-
unitTestReport.push({
|
53
|
-
title: t.title,
|
54
|
-
fullName: t.fullName,
|
55
|
-
filePath: testResult.testFilePath
|
56
|
-
});
|
57
|
-
});
|
58
55
|
});
|
59
|
-
|
60
|
-
|
61
|
-
|
56
|
+
let coverageSummary = {};
|
57
|
+
|
58
|
+
if (_fs.default.existsSync('./commitCoverage/coverage-summary.json')) {
|
59
|
+
coverageSummary = _fs.default.readFileSync('./commitCoverage/coverage-summary.json').toString();
|
60
|
+
|
62
61
|
if (coverageSummary.indexOf('\\') !== -1) {
|
63
62
|
coverageSummary = coverageSummary.replace(/\\/g, '\\\\');
|
64
63
|
}
|
65
64
|
}
|
66
65
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
var branchesPercent = 0;
|
66
|
+
let excludeTestArray = '{}';
|
67
|
+
|
68
|
+
if (_fs.default.existsSync('./__testUtils__/conf/excludeTest.json')) {
|
69
|
+
excludeTestArray = _fs.default.readFileSync('./__testUtils__/conf/excludeTest.json').toString();
|
72
70
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
71
|
+
if (excludeTestArray.indexOf('\\') !== -1) {
|
72
|
+
excludeTestArray = excludeTestArray.replace(/\\/g, '\\\\');
|
73
|
+
}
|
74
|
+
}
|
75
|
+
|
76
|
+
let coverageJson = JSON.parse(coverageSummary);
|
77
|
+
let linesPercent = 0;
|
78
|
+
let functionPercent = 0;
|
79
|
+
let statementPerment = 0;
|
80
|
+
let branchesPercent = 0;
|
81
|
+
let fileList = '<h4>Changed files in last code check-in</h4><ul>';
|
82
|
+
let i = 0;
|
83
|
+
let excludeTestJSON = JSON.parse(excludeTestArray);
|
84
|
+
|
85
|
+
if (Object.keys(excludeTestArray).length > 0) {
|
86
|
+
jsonData.FILES = jsonData.FILES.filter(function (value) {
|
87
|
+
if (!excludeTestJSON.test.exclude.includes(value)) {
|
88
|
+
let excludeDir = excludeTestJSON.test.exclude.filter(function (excludeFile) {
|
89
|
+
if (value.indexOf(excludeFile) > -1) {
|
90
|
+
return value;
|
91
|
+
}
|
92
|
+
});
|
93
|
+
|
94
|
+
if (excludeDir.length > 0) {
|
95
|
+
return null;
|
96
|
+
}
|
97
|
+
|
98
|
+
return value;
|
99
|
+
}
|
100
|
+
|
101
|
+
return null;
|
102
|
+
});
|
103
|
+
}
|
104
|
+
|
105
|
+
for (i; i < jsonData.FILES.length; i++) {
|
106
|
+
let coverageData;
|
107
|
+
let curSourceFile = jsonData.FILES[i];
|
77
108
|
curSourceFile.replace(process.cwd(), '').substring(1);
|
78
|
-
fileList = fileList
|
79
|
-
|
109
|
+
fileList = `${fileList}<li>${curSourceFile}</li>`;
|
110
|
+
Object.keys(coverageJson).forEach(coverageFile => {
|
111
|
+
if (coverageFile.includes(curSourceFile) || coverageFile === 'total') {
|
112
|
+
coverageData = coverageJson[coverageFile];
|
113
|
+
}
|
114
|
+
});
|
115
|
+
|
80
116
|
if (!coverageData) {
|
81
|
-
(0, _utils.log)(
|
117
|
+
(0, _utils.log)(`Can't able to find source for ${testFilesArr[i].testPath}\n Please check the file name and the path is correct for test file`);
|
82
118
|
continue;
|
83
119
|
}
|
120
|
+
|
84
121
|
linesPercent += coverageData.lines.pct;
|
85
122
|
functionPercent += coverageData.functions.pct;
|
86
123
|
statementPerment += coverageData.statements.pct;
|
87
124
|
branchesPercent += coverageData.branches.pct;
|
88
125
|
}
|
89
|
-
|
90
|
-
|
126
|
+
|
127
|
+
fileList = `${fileList}</ul>`;
|
128
|
+
|
129
|
+
if (!jsonData.FILES.length) {
|
91
130
|
fileList = '<div></div>';
|
92
131
|
}
|
93
132
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
}
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
133
|
+
let uncoveredList = '<h4>Uncovered files :- </h4><ul>';
|
134
|
+
let fileCoverage = 0;
|
135
|
+
|
136
|
+
if (jsonData.FILES.length > 0) {
|
137
|
+
fileCoverage = testCaseFiles.length / jsonData.FILES.length * 100;
|
138
|
+
}
|
139
|
+
|
140
|
+
fileCoverage = fileCoverage.toFixed(2);
|
141
|
+
fileCoverage = Number(fileCoverage);
|
142
|
+
|
143
|
+
if (Number.isNaN(fileCoverage)) {
|
144
|
+
(0, _utils.log)('This build does\'t have any JS changes!');
|
145
|
+
fileCoverage = 0;
|
146
|
+
} else {
|
147
|
+
(0, _utils.log)(`FileCoverage ${fileCoverage}%`);
|
148
|
+
}
|
149
|
+
|
150
|
+
let totalLinesPercent = linesPercent / (i * 100) * 100;
|
151
|
+
let totalFunctionPercent = functionPercent / (i * 100) * 100;
|
152
|
+
let totalStatementPercent = statementPerment / (i * 100) * 100;
|
153
|
+
let totalBranchesPercent = branchesPercent / (i * 100) * 100;
|
154
|
+
let totalPercentage = totalLinesPercent + totalFunctionPercent + totalStatementPercent + totalBranchesPercent;
|
155
|
+
let coverage = (totalPercentage / 4).toFixed(2);
|
108
156
|
coverage = Number(coverage);
|
109
157
|
|
110
158
|
if (Number.isNaN(coverage)) {
|
111
|
-
(0,
|
159
|
+
(0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'tests.modifiedFileUnitCase.testInfo', 'can\'t get coverage for this test');
|
112
160
|
coverage = 0;
|
161
|
+
uncoveredList = uncoveredList + 'No Component changes with this build, You can proceed this build </ul>';
|
113
162
|
} else {
|
114
|
-
(0,
|
163
|
+
(0, _jsonMaker.default)(inp, coverage, true, 'modifiedFileUnitCase', fileCoverage);
|
164
|
+
(0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'tests.modifiedFileUnitCase.isBuildVerified', coverage > 60);
|
165
|
+
(0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'tests.modifiedFileUnitCase.testInfo', 'Test coverage value generated'); // jsonHelper(
|
166
|
+
// `${process.cwd()}/result.json`,
|
167
|
+
// 'testInfo.isBuildVerified',
|
168
|
+
// coverage > 60
|
169
|
+
// );
|
170
|
+
|
171
|
+
(0, _jsonHelper.setTestInfoStatus)(`${process.cwd()}/result.json`, true
|
172
|
+
/*coverage > 60*/
|
173
|
+
);
|
174
|
+
|
175
|
+
if (coverage < 60) {
|
176
|
+
(0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'testInfo.failures', [{
|
177
|
+
type: 'modifiedUnitcases',
|
178
|
+
message: 'Need to cover 60% above for changed files'
|
179
|
+
}]);
|
180
|
+
uncoveredList = uncoveredList + 'Ask developer to cover 60% above for changed files </ul>';
|
181
|
+
} else {
|
182
|
+
uncoveredList = uncoveredList + 'You can proceed this build </ul>';
|
183
|
+
}
|
184
|
+
|
185
|
+
(0, _utils.log)(`COVERAGE ${coverage}%`);
|
115
186
|
}
|
116
187
|
|
117
|
-
|
188
|
+
let html = `<html><head><style>.red{font-weight:bold;color:red;}.green{font-weight:bold;color:green;}</style></head><body><br/>CODE COVERAGE <span class="${coverage < 60 ? 'red' : 'green'}">${coverage}%</span> <br/> less than 60% consider failure<br/><br/> FILE COVERAGE:<span class="${fileCoverage < 60 ? 'red' : 'green'}">${fileCoverage}%</span> <br/> less than 60% consider failure${fileList}${uncoveredList}</body></html>`;
|
118
189
|
|
119
|
-
if (!
|
120
|
-
|
121
|
-
|
190
|
+
if (!_fs.default.existsSync('./coverageTest')) {
|
191
|
+
_fs.default.mkdirSync('./coverageTest');
|
192
|
+
|
193
|
+
_fs.default.writeFileSync('./coverageTest/index.html', html, 'utf8');
|
122
194
|
} else {
|
123
|
-
|
195
|
+
_fs.default.writeFileSync('./coverageTest/index.html', html, 'utf8');
|
124
196
|
}
|
197
|
+
|
125
198
|
return inp;
|
126
199
|
};
|
127
200
|
|