@zohodesk/react-cli 0.0.1-beta.99 → 0.0.1-betaa.138.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 +183 -183
- package/CHANGELOG.md +5 -0
- package/README.md +636 -491
- package/bin/cli.js +372 -367
- package/files/eslintrc.js +57 -0
- package/files/prettierrc.js +3 -0
- package/lib/babel/cmjs-plugins-presets.js +16 -9
- package/lib/babel/es-plugins-presets.js +26 -14
- package/lib/common/getEntries.js +31 -22
- package/lib/common/getPublicPathConfig.js +27 -13
- package/lib/common/index.js +21 -25
- package/lib/common/splitChunks.js +62 -53
- package/lib/common/templateParameters.js +10 -8
- package/lib/configs/jest.config.js +15 -25
- package/lib/configs/webpack.component.umd.config.js +31 -37
- package/lib/configs/webpack.css.umd.config.js +44 -47
- package/lib/configs/webpack.dev.config.js +70 -52
- package/lib/configs/webpack.docs.config.js +106 -106
- package/lib/configs/webpack.prod.config.js +95 -75
- package/lib/hooks/docsProptypeHook.js +32 -38
- package/lib/jest/commitedFilesResult.js +103 -74
- package/lib/jest/coverageCollector.js +41 -21
- package/lib/jest/jsonMaker.js +15 -16
- package/lib/jest/preProcessors/cssPreprocessor.js +16 -18
- package/lib/jest/preProcessors/jsPreprocessor.js +3 -5
- package/lib/jest/preProcessors/otherFilesPreprocessor.js +5 -6
- package/lib/jest/result.js +90 -45
- package/lib/jest/run.js +43 -43
- package/lib/jest/setup.js +102 -95
- package/lib/loaderUtils/getCSSLoaders.js +21 -22
- package/lib/loaderUtils/getDevJsLoaders.js +25 -23
- package/lib/loaderUtils/index.js +11 -13
- package/lib/loaders/docsLoader.js +15 -15
- package/lib/loaders/docsPropsLoader.js +14 -17
- package/lib/loaders/fileLoader.js +33 -35
- package/lib/loaders/scriptInstrumentLoader.js +21 -20
- package/lib/loaders/workerLoader.js +136 -0
- package/lib/middlewares/HMRMiddleware.js +54 -45
- package/lib/middlewares/SSTMiddleware.js +8 -5
- package/lib/pluginUtils/getDevPlugins.js +114 -52
- package/lib/pluginUtils/getDocsPlugins.js +25 -29
- package/lib/pluginUtils/getLibraryPlugins.js +8 -10
- package/lib/pluginUtils/getProdPlugins.js +163 -74
- package/lib/pluginUtils/getServerPlugins.js +8 -11
- package/lib/pluginUtils/getUMDCSSPlugins.js +11 -15
- package/lib/pluginUtils/getUMDComponentPlugins.js +11 -15
- package/lib/pluginUtils/index.js +36 -43
- package/lib/plugins/CdnChangePlugin.js +63 -0
- package/lib/plugins/CleanupStatsPlugin.js +18 -32
- package/lib/plugins/CustomAttributePlugin.js +79 -0
- package/lib/plugins/CustomAttributePlugin.md +35 -0
- package/lib/plugins/EFCPlugin.js +185 -0
- package/lib/plugins/I18NInjectIntoIndexPlugin.js +118 -52
- package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +60 -0
- package/lib/plugins/I18nSplitPlugin/I18nDependency.js +44 -0
- package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +266 -0
- package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +183 -0
- package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +100 -0
- package/lib/plugins/I18nSplitPlugin/I18nSplit.md +86 -0
- package/lib/plugins/I18nSplitPlugin/README.md +25 -0
- package/lib/plugins/I18nSplitPlugin/index.js +185 -0
- package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +64 -0
- package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +13 -0
- package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +26 -0
- package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +40 -0
- package/lib/plugins/I18nSplitPlugin/utils/index.js +31 -0
- package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +112 -0
- package/lib/plugins/ManifestPlugin.js +52 -63
- package/lib/plugins/ModuleStatsPlugin.js +83 -173
- package/lib/plugins/OptimizeJSPlugin.js +24 -41
- package/lib/plugins/PublicPathCallbackPlugin.js +42 -116
- package/lib/plugins/PublicPathChangePlugin.js +175 -284
- package/lib/plugins/ReportGeneratePlugin.js +150 -151
- package/lib/plugins/ResourceHintsPlugin.js +53 -35
- package/lib/plugins/ScriptInstrumentPlugin.js +22 -37
- package/lib/plugins/ServiceWorkerPlugin.js +81 -57
- package/lib/plugins/ShadowDOMSupportPlugin.js +153 -234
- package/lib/plugins/SourceMapHookPlugin.js +21 -33
- package/lib/plugins/TPHashMappingPlugin.js +67 -0
- package/lib/plugins/UglifyCSSPlugin.js +23 -30
- package/lib/plugins/UnusedFilesFindPlugin.js +137 -152
- package/lib/plugins/index.js +100 -91
- package/lib/plugins/webpackwatchrunplugin.js +18 -30
- package/lib/postcss-plugins/ExcludeRTLPlugin.js +14 -17
- package/lib/schemas/index.js +336 -81
- package/lib/servers/clusterHubServer.js +22 -26
- package/lib/servers/docsServer.js +3 -5
- package/lib/servers/docsServerCore.js +84 -91
- package/lib/servers/helpServer.js +19 -21
- package/lib/servers/impactServer.js +99 -92
- package/lib/servers/mockserver.js +24 -24
- package/lib/servers/scrServer.js +78 -98
- package/lib/servers/server.js +101 -122
- package/lib/servers/ssServer.js +63 -61
- package/lib/sh/pre-commit.sh +34 -34
- package/lib/sh/reportPublish.sh +45 -46
- package/lib/templates/CoverageScriptTemplate.js +45 -18
- package/lib/templates/WMSTemplate.js +17 -18
- package/lib/templates/linterConstant.js +6 -4
- package/lib/utils/babelPresets.js +12 -5
- package/lib/utils/buildstats.html +148 -148
- package/lib/utils/clean.js +12 -11
- package/lib/utils/copy.js +12 -34
- package/lib/utils/copyTimezones.js +9 -16
- package/lib/utils/createEventStream.js +24 -19
- package/lib/utils/cssClassNameGenerate.js +44 -73
- package/lib/utils/cssURLReplacer.js +60 -54
- package/lib/utils/dependencyPostPublish.js +20 -19
- package/lib/utils/fileUtils.js +66 -54
- package/lib/utils/folderIterator.js +20 -21
- package/lib/utils/getComponents.js +70 -27
- package/lib/utils/getCurrentBranch.js +11 -17
- package/lib/utils/getDependenciesImpactList.js +114 -187
- package/lib/utils/getHash.js +9 -13
- package/lib/utils/getIp.js +9 -9
- package/lib/utils/getOptions.js +26 -29
- package/lib/utils/getServerURL.js +19 -10
- package/lib/utils/index.js +147 -126
- package/lib/utils/init.js +2 -2
- package/lib/utils/initPreCommitHook.js +40 -32
- package/lib/utils/jsonHelper.js +37 -21
- package/lib/utils/lint/addScripts.js +27 -0
- package/lib/utils/lint/checkExistingConfig.js +67 -0
- package/lib/utils/lint/copyConfigs.js +24 -0
- package/lib/utils/lint/index.js +54 -0
- package/lib/utils/lint/lintScripts.js +11 -0
- package/lib/utils/lint/lintSetup.js +31 -0
- package/lib/utils/lint/lintStagedPreCommitHook.js +7 -0
- package/lib/utils/lint/question.js +30 -0
- package/lib/utils/lintReporter.js +70 -56
- package/lib/utils/mailSender.js +12 -27
- package/lib/utils/pullOrigin.js +21 -18
- package/lib/utils/reinstallDependencies.js +76 -85
- package/lib/utils/removeAttributes.js +25 -23
- package/lib/utils/repoClone.js +47 -45
- package/lib/utils/request.js +64 -77
- package/lib/utils/resultSchema.json +73 -73
- package/lib/utils/rtl.js +22 -29
- package/lib/utils/setEnvVariables.js +5 -6
- package/lib/utils/ssTestHack.js +21 -19
- package/lib/utils/switchBranch.js +21 -20
- package/lib/utils/urlConcat.js +22 -0
- package/package.json +141 -136
- package/templates/app/.eslintrc.js +140 -140
- package/templates/app/README.md +12 -12
- package/templates/app/app/index.html +24 -24
- package/templates/app/app/properties/ApplicationResources_en_US.properties +1 -1
- package/templates/app/app/properties/i18nkeys.json +3 -3
- package/templates/app/docs/all.html +69 -69
- package/templates/app/mockapi/index.js +18 -18
- package/templates/app/package.json +37 -37
- package/templates/app/src/actions/SampleActions/index.js +37 -37
- package/templates/app/src/actions/index.js +65 -65
- package/templates/app/src/appUrls.js +19 -19
- package/templates/app/src/components/Alert/Alert.js +134 -134
- package/templates/app/src/components/Alert/Alert.module.css +79 -79
- package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -37
- package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -84
- package/templates/app/src/components/Sample/Sample.module.css +11 -11
- package/templates/app/src/components/Sample/SampleList.js +61 -61
- package/templates/app/src/components/Slider/Slider.css +41 -41
- package/templates/app/src/components/Slider/Slider.js +55 -55
- package/templates/app/src/containers/AlertContainer/index.js +15 -15
- package/templates/app/src/containers/AppContainer/index.js +96 -96
- package/templates/app/src/containers/AppContainer/index.module.css +27 -27
- package/templates/app/src/containers/CustomMatch/index.js +65 -65
- package/templates/app/src/containers/DevTools/index.js +10 -10
- package/templates/app/src/containers/Header/index.js +67 -67
- package/templates/app/src/containers/Header/index.module.css +43 -43
- package/templates/app/src/containers/Redirect/index.js +63 -63
- package/templates/app/src/containers/Redirector/index.js +47 -47
- package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -42
- package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -3
- package/templates/app/src/historyChange.js +5 -5
- package/templates/app/src/index.html +10 -10
- package/templates/app/src/index.js +24 -24
- package/templates/app/src/middleware/PromiseMiddleware.js +59 -59
- package/templates/app/src/reducers/alertData.js +11 -11
- package/templates/app/src/reducers/index.js +6 -6
- package/templates/app/src/reducers/samples.js +19 -19
- package/templates/app/src/store/configureStore.dev.js +51 -51
- package/templates/app/src/store/configureStore.js +5 -5
- package/templates/app/src/store/configureStore.prod.js +26 -26
- package/templates/app/src/util/Common.js +5 -5
- package/templates/app/src/util/RequestAPI.js +132 -132
- package/templates/docs/all.html +249 -249
- package/templates/docs/component.html +178 -178
- package/templates/docs/components.html +221 -221
- package/templates/docs/css/b.min.css +6 -6
- package/templates/docs/css/component.css +42 -42
- package/templates/docs/css/componentTest.css +6 -6
- package/templates/docs/css/hopscotch.css +585 -585
- package/templates/docs/css/style.css +1022 -1022
- package/templates/docs/index.html +1493 -1493
- package/templates/docs/js/active-line.js +72 -72
- package/templates/docs/js/b.min.js +7 -7
- package/templates/docs/js/codemirror.js +9680 -9680
- package/templates/docs/js/designTokens.js +334 -334
- package/templates/docs/js/j.min.js +4 -4
- package/templates/docs/js/javascript.js +874 -874
- package/templates/docs/js/matchbrackets.js +145 -145
@@ -0,0 +1,67 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
|
8
|
+
var _webpack = require("webpack");
|
9
|
+
|
10
|
+
var _fs = _interopRequireDefault(require("fs"));
|
11
|
+
|
12
|
+
var _path = _interopRequireDefault(require("path"));
|
13
|
+
|
14
|
+
var _crypto = _interopRequireDefault(require("crypto"));
|
15
|
+
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
17
|
+
|
18
|
+
/**
|
19
|
+
* Plugin that generates hash for the provided list of third party files
|
20
|
+
* Map the provided key with the file hash and add it to the list of exisiting global constants.
|
21
|
+
* Plugin in turn uses the defineplugin to generate global constants.
|
22
|
+
*/
|
23
|
+
class TPHashMappingPlugin {
|
24
|
+
constructor(options) {
|
25
|
+
this.fileMappings = options.fileMappings;
|
26
|
+
this.tpFolder = options.tpFolder;
|
27
|
+
return new _webpack.DefinePlugin(this.getFiles());
|
28
|
+
}
|
29
|
+
|
30
|
+
getHash(content) {
|
31
|
+
let hash = _crypto.default.createHash('md5');
|
32
|
+
|
33
|
+
let data = hash.update(content, 'utf-8');
|
34
|
+
let gen_hash = data.digest('hex');
|
35
|
+
return gen_hash;
|
36
|
+
}
|
37
|
+
|
38
|
+
getFiles() {
|
39
|
+
let hashMapping = {};
|
40
|
+
this.fileMappings.forEach(fileInfo => {
|
41
|
+
let filePath = `${_path.default.join(this.tpFolder, fileInfo.filePath, fileInfo.fileName)}`;
|
42
|
+
|
43
|
+
if (_fs.default.existsSync(filePath)) {
|
44
|
+
let fileContent = _fs.default.readFileSync(filePath, {
|
45
|
+
encoding: 'utf-8'
|
46
|
+
});
|
47
|
+
|
48
|
+
let generatedHash = this.getHash(fileContent);
|
49
|
+
let outputFileSplit = fileInfo.fileName.split('.');
|
50
|
+
outputFileSplit.splice(outputFileSplit.length - 1, 0, generatedHash);
|
51
|
+
let outputFileName = outputFileSplit.join('.');
|
52
|
+
let outputFilePath = `${_path.default.join(this.tpFolder, fileInfo.filePath, outputFileName)}`;
|
53
|
+
|
54
|
+
_fs.default.writeFileSync(outputFilePath, fileContent);
|
55
|
+
|
56
|
+
hashMapping[fileInfo.key] = JSON.stringify(generatedHash);
|
57
|
+
} else {
|
58
|
+
throw new Error(`Third party file ${fileInfo.fileName} does not exist`);
|
59
|
+
}
|
60
|
+
});
|
61
|
+
return hashMapping;
|
62
|
+
}
|
63
|
+
|
64
|
+
}
|
65
|
+
|
66
|
+
var _default = TPHashMappingPlugin;
|
67
|
+
exports.default = _default;
|
@@ -1,46 +1,39 @@
|
|
1
|
-
|
1
|
+
"use strict";
|
2
2
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
+
exports.default = void 0;
|
6
7
|
|
7
|
-
var
|
8
|
+
var _webpackSources = require("webpack-sources");
|
8
9
|
|
9
|
-
var
|
10
|
-
|
11
|
-
var _uglifycss = require('uglifycss');
|
12
|
-
|
13
|
-
var _uglifycss2 = _interopRequireDefault(_uglifycss);
|
10
|
+
var _uglifycss = _interopRequireDefault(require("uglifycss"));
|
14
11
|
|
15
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
16
13
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
14
|
+
class UglifyCSSPlugin {
|
15
|
+
apply(compiler) {
|
16
|
+
compiler.hooks.emit.tap('UglifyCSSPlugin', compilation => {
|
17
|
+
Object.keys(compilation.assets).forEach(filename => {
|
18
|
+
if (/\.css$/.test(filename)) {
|
19
|
+
try {
|
20
|
+
let asset = compilation.assets[filename].source();
|
23
21
|
|
24
|
-
|
25
|
-
|
26
|
-
value: function apply(compiler) {
|
27
|
-
compiler.hooks.emit.tap('UglifyCSSPlugin', function (compilation) {
|
28
|
-
Object.keys(compilation.assets).forEach(function (filename) {
|
29
|
-
if (/\.css$/.test(filename)) {
|
30
|
-
try {
|
31
|
-
var asset = compilation.assets[filename].source();
|
32
|
-
var result = _uglifycss2.default.processString(asset);
|
33
|
-
compilation.assets[filename] = new _webpackSources.RawSource(result);
|
34
|
-
} catch (e) {
|
35
|
-
compilation.errors.push(e);
|
22
|
+
if (typeof asset !== 'string') {
|
23
|
+
asset = asset.toString();
|
36
24
|
}
|
25
|
+
|
26
|
+
const result = _uglifycss.default.processString(asset);
|
27
|
+
|
28
|
+
compilation.assets[filename] = new _webpackSources.RawSource(result);
|
29
|
+
} catch (e) {
|
30
|
+
compilation.errors.push(e);
|
37
31
|
}
|
38
|
-
}
|
32
|
+
}
|
39
33
|
});
|
40
|
-
}
|
41
|
-
}
|
34
|
+
});
|
35
|
+
}
|
42
36
|
|
43
|
-
|
44
|
-
}();
|
37
|
+
}
|
45
38
|
|
46
39
|
exports.default = UglifyCSSPlugin;
|
@@ -1,48 +1,35 @@
|
|
1
|
-
|
1
|
+
"use strict";
|
2
2
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
+
exports.default = void 0;
|
6
7
|
|
7
|
-
var
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
8
9
|
|
9
|
-
var
|
10
|
+
var _fs = _interopRequireDefault(require("fs"));
|
10
11
|
|
11
|
-
var
|
12
|
-
|
13
|
-
var _fs = require('fs');
|
14
|
-
|
15
|
-
var _fs2 = _interopRequireDefault(_fs);
|
16
|
-
|
17
|
-
var _utils = require('../utils');
|
12
|
+
var _utils = require("../utils");
|
18
13
|
|
19
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
20
15
|
|
21
|
-
|
16
|
+
let excludeDocsJSON = '{}';
|
17
|
+
|
18
|
+
if (_fs.default.existsSync('./__testUtils__/conf/excludeDocs.json')) {
|
19
|
+
excludeDocsJSON = _fs.default.readFileSync('./__testUtils__/conf/excludeDocs.json').toString();
|
22
20
|
|
23
|
-
var excludeDocsJSON = '{}';
|
24
|
-
if (_fs2.default.existsSync('./__testUtils__/conf/excludeDocs.json')) {
|
25
|
-
excludeDocsJSON = _fs2.default.readFileSync('./__testUtils__/conf/excludeDocs.json').toString();
|
26
21
|
if (excludeDocsJSON.indexOf('\\') !== -1) {
|
27
22
|
excludeDocsJSON = excludeDocsJSON.replace(/\\/g, '\\\\');
|
28
23
|
}
|
29
24
|
}
|
30
|
-
var excludeDocsArray = JSON.parse(excludeDocsJSON);
|
31
|
-
// if (Object.keys(excludeDocsArray).length > 0) {
|
32
|
-
// }
|
33
|
-
|
34
|
-
var getRegex = function getRegex(regexString) {
|
35
|
-
return regexString.map(function (str) {
|
36
|
-
return new RegExp(str);
|
37
|
-
});
|
38
|
-
};
|
39
25
|
|
40
|
-
|
41
|
-
|
42
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
26
|
+
let excludeDocsArray = JSON.parse(excludeDocsJSON); // if (Object.keys(excludeDocsArray).length > 0) {
|
27
|
+
// }
|
43
28
|
|
44
|
-
|
29
|
+
let getRegex = regexString => regexString.map(str => new RegExp(str));
|
45
30
|
|
31
|
+
class UnusedFilesFindPlugin {
|
32
|
+
constructor(options = {}) {
|
46
33
|
this.usedFilesExcludes = getRegex(options.usedFilesExcludes);
|
47
34
|
this.appFilesExcludes = getRegex(options.appFilesExcludes);
|
48
35
|
this.origin = options.origin;
|
@@ -50,157 +37,155 @@ var UnusedFilesFindPlugin = function () {
|
|
50
37
|
this.sstest = options.ssTest || false;
|
51
38
|
this.outputFileName = options.outputFileName;
|
52
39
|
this.docsFilename = options.docsFilename || 'Undocsfiles.json';
|
40
|
+
|
53
41
|
if (!this.origin) {
|
54
42
|
throw new Error('You must provide origin point of the app');
|
55
43
|
}
|
56
44
|
}
|
57
45
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
}
|
46
|
+
isIgnoredUsedFile(file) {
|
47
|
+
let result;
|
48
|
+
|
49
|
+
for (let i = 0; i < this.usedFilesExcludes.length; i++) {
|
50
|
+
let exclude = this.usedFilesExcludes[i];
|
51
|
+
result = exclude.test(file);
|
52
|
+
|
53
|
+
if (result) {
|
54
|
+
break;
|
68
55
|
}
|
69
|
-
return result;
|
70
56
|
}
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
57
|
+
|
58
|
+
return result;
|
59
|
+
}
|
60
|
+
|
61
|
+
unDocumentedFiles(outputPath) {
|
62
|
+
let status = _fs.default.existsSync(_path.default.join(outputPath, this.outputFileName));
|
63
|
+
|
64
|
+
let unDocsCompObj = {};
|
65
|
+
|
66
|
+
if (status) {
|
67
|
+
let data = _fs.default.readFileSync(_path.default.join(outputPath, this.outputFileName)).toString();
|
68
|
+
|
69
|
+
let walkSync = (dir, filelist = [], undocList = []) => {
|
70
|
+
let files = _fs.default.readdirSync(dir);
|
71
|
+
|
72
|
+
files.forEach(file => {
|
73
|
+
if (_fs.default.statSync(`${dir}/${file}`).isDirectory()) {
|
74
|
+
filelist = walkSync(`${dir}/${file}`, filelist, undocList); //eslint-disable-line
|
75
|
+
} else {
|
76
|
+
if (file.includes('.docs')) {
|
77
|
+
if (!(`${dir}/${file}` in JSON.parse(data))) {
|
78
|
+
filelist.push(`${dir.replace(_path.default.join(process.cwd(), 'src', 'components'), '')}/${file}`);
|
79
|
+
}
|
86
80
|
} else {
|
87
|
-
if (file.includes('.
|
88
|
-
if (!(
|
89
|
-
|
90
|
-
|
91
|
-
} else {
|
92
|
-
if (file.includes('.js') && !file.includes('.spec') && !file.includes('.json')) {
|
93
|
-
if (!files.includes('docs')) {
|
94
|
-
if (!excludeDocsArray.docs.exclude.includes(dir.replace(_path2.default.join(process.cwd(), 'src', 'components'), '') + '/' + file)) {
|
95
|
-
undocList.push(dir.replace(_path2.default.join(process.cwd(), 'src', 'components'), '') + '/' + file);
|
96
|
-
}
|
81
|
+
if (file.includes('.js') && !file.includes('.spec') && !file.includes('.json')) {
|
82
|
+
if (!files.includes('docs')) {
|
83
|
+
if (!excludeDocsArray.docs.exclude.includes(`${dir.replace(_path.default.join(process.cwd(), 'src', 'components'), '')}/${file}`)) {
|
84
|
+
undocList.push(`${dir.replace(_path.default.join(process.cwd(), 'src', 'components'), '')}/${file}`);
|
97
85
|
}
|
98
86
|
}
|
99
87
|
}
|
100
88
|
}
|
101
|
-
});
|
102
|
-
unDocsCompObj.withoutDocs = undocList;
|
103
|
-
return filelist;
|
104
|
-
};
|
105
|
-
unDocsCompObj.noEnteredComp = walkSync(_path2.default.join(process.cwd(), 'src', 'components'), [], []);
|
106
|
-
|
107
|
-
(0, _utils.writeFile)(_path2.default.join(outputPath, this.docsFilename), JSON.stringify(unDocsCompObj));
|
108
|
-
Object.keys(unDocsCompObj).forEach(function (key) {
|
109
|
-
if (unDocsCompObj[key].length > 0) {
|
110
|
-
if (key === 'withoutDocs') {
|
111
|
-
(0, _utils.log)('\x1b[36m%s\x1b[0m', '\nPlease write docs file for below componenst :- \n');
|
112
|
-
unDocsCompObj[key].forEach(function (value) {
|
113
|
-
if (!excludeDocsArray.docs.exclude.includes(value)) {
|
114
|
-
(0, _utils.log)('\x1b[33m%s\x1b[0m', '' + value);
|
115
|
-
}
|
116
|
-
});
|
117
|
-
}
|
118
89
|
}
|
119
90
|
});
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
}, {
|
136
|
-
key: 'getAllFiles',
|
137
|
-
value: function getAllFiles(rootPath) {
|
138
|
-
var _this = this;
|
139
|
-
|
140
|
-
var allFiles = [];
|
141
|
-
var files = _fs2.default.readdirSync(rootPath).map(function (file) {
|
142
|
-
return _path2.default.join(rootPath, file);
|
143
|
-
});
|
144
|
-
files.forEach(function (file) {
|
145
|
-
if (_fs2.default.statSync(file).isDirectory()) {
|
146
|
-
allFiles = allFiles.concat(_this.getAllFiles(file));
|
147
|
-
} else {
|
148
|
-
if (!_this.isIgnoredAllFile(file)) {
|
149
|
-
allFiles.push(file);
|
91
|
+
unDocsCompObj.withoutDocs = undocList;
|
92
|
+
return filelist;
|
93
|
+
};
|
94
|
+
|
95
|
+
unDocsCompObj.noEnteredComp = walkSync(_path.default.join(process.cwd(), 'src', 'components'), [], []);
|
96
|
+
(0, _utils.writeFile)(_path.default.join(outputPath, this.docsFilename), JSON.stringify(unDocsCompObj));
|
97
|
+
Object.keys(unDocsCompObj).forEach(key => {
|
98
|
+
if (unDocsCompObj[key].length > 0) {
|
99
|
+
if (key === 'withoutDocs') {
|
100
|
+
(0, _utils.log)('\x1b[36m%s\x1b[0m', '\nPlease write docs file for below componenst :- \n');
|
101
|
+
unDocsCompObj[key].forEach(value => {
|
102
|
+
if (!excludeDocsArray.docs.exclude.includes(value)) {
|
103
|
+
(0, _utils.log)('\x1b[33m%s\x1b[0m', `${value}`);
|
104
|
+
}
|
105
|
+
});
|
150
106
|
}
|
151
107
|
}
|
152
108
|
});
|
153
|
-
return allFiles;
|
154
109
|
}
|
155
|
-
}
|
156
|
-
key: 'apply',
|
157
|
-
value: function apply(compiler) {
|
158
|
-
var _this2 = this;
|
110
|
+
}
|
159
111
|
|
160
|
-
|
161
|
-
|
112
|
+
isIgnoredAllFile(file) {
|
113
|
+
let result;
|
162
114
|
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
}
|
167
|
-
return files;
|
168
|
-
}, {});
|
115
|
+
for (let i = 0; i < this.appFilesExcludes.length; i++) {
|
116
|
+
let exclude = this.appFilesExcludes[i];
|
117
|
+
result = exclude.test(file);
|
169
118
|
|
170
|
-
|
119
|
+
if (result) {
|
120
|
+
break;
|
121
|
+
}
|
122
|
+
}
|
171
123
|
|
172
|
-
|
173
|
-
|
174
|
-
if (!usedFiles[file]) {
|
175
|
-
unusedFiles.push(file);
|
176
|
-
}
|
177
|
-
});
|
124
|
+
return result;
|
125
|
+
}
|
178
126
|
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
127
|
+
getAllFiles(rootPath) {
|
128
|
+
let allFiles = [];
|
129
|
+
|
130
|
+
let files = _fs.default.readdirSync(rootPath).map(file => _path.default.join(rootPath, file));
|
131
|
+
|
132
|
+
files.forEach(file => {
|
133
|
+
if (_fs.default.statSync(file).isDirectory()) {
|
134
|
+
allFiles = allFiles.concat(this.getAllFiles(file));
|
135
|
+
} else {
|
136
|
+
if (!this.isIgnoredAllFile(file)) {
|
137
|
+
allFiles.push(file);
|
138
|
+
}
|
139
|
+
}
|
140
|
+
});
|
141
|
+
return allFiles;
|
142
|
+
}
|
143
|
+
|
144
|
+
apply(compiler) {
|
145
|
+
compiler.hooks.afterEmit.tap('UnusedFilesShowPlugin', compilation => {
|
146
|
+
let {
|
147
|
+
path: outputPath
|
148
|
+
} = compilation.compiler.options.output;
|
149
|
+
let usedFiles = Array.from(compilation.fileDependencies).reduce((files, usedFile) => {
|
150
|
+
if (!this.isIgnoredUsedFile(usedFile)) {
|
151
|
+
files[usedFile] = true;
|
191
152
|
}
|
192
153
|
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
154
|
+
return files;
|
155
|
+
}, {});
|
156
|
+
let allFiles = this.getAllFiles(this.origin);
|
157
|
+
let unusedFiles = [];
|
158
|
+
allFiles.forEach(file => {
|
159
|
+
if (!usedFiles[file]) {
|
160
|
+
unusedFiles.push(file);
|
198
161
|
}
|
199
162
|
});
|
200
|
-
}
|
201
|
-
}]);
|
202
163
|
|
203
|
-
|
204
|
-
|
164
|
+
if (!unusedFiles.length) {
|
165
|
+
(0, _utils.log)('There is no unused files');
|
166
|
+
} else {
|
167
|
+
if (this.outputFileName) {
|
168
|
+
(0, _utils.log)(`You can see unused files info from ${_path.default.join(outputPath, this.outputFileName)} path`);
|
169
|
+
(0, _utils.makeDir)(outputPath);
|
170
|
+
(0, _utils.writeFile)(_path.default.join(outputPath, this.outputFileName), JSON.stringify(unusedFiles)).then(() => {
|
171
|
+
if (this.sstest) {
|
172
|
+
this.unDocumentedFiles(outputPath);
|
173
|
+
}
|
174
|
+
});
|
175
|
+
}
|
176
|
+
}
|
177
|
+
|
178
|
+
if (this.delete) {
|
179
|
+
unusedFiles.forEach(file => {
|
180
|
+
_fs.default.unlinkSync(file);
|
181
|
+
|
182
|
+
(0, _utils.log)(`Deleted - ${file}`);
|
183
|
+
});
|
184
|
+
}
|
185
|
+
});
|
186
|
+
}
|
187
|
+
|
188
|
+
}
|
205
189
|
|
206
|
-
|
190
|
+
var _default = UnusedFilesFindPlugin;
|
191
|
+
exports.default = _default;
|