@zohodesk/react-cli 0.0.1-beta.99 → 0.0.1-betaa.138.2
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 +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
package/lib/utils/jsonHelper.js
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
|
-
var os = require('os');
|
|
6
|
+
exports.setTestInfoStatus = exports.jsonHelper = exports.jsonConcate = exports.getRunnerDetail = exports.fileHandler = void 0;
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
getCurrentBranch = _require.getCurrentBranch;
|
|
8
|
+
let fs = require('fs');
|
|
11
9
|
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
let os = require('os');
|
|
11
|
+
|
|
12
|
+
let {
|
|
13
|
+
getCurrentBranch
|
|
14
|
+
} = require('./');
|
|
15
|
+
|
|
16
|
+
let getRunnerDetail = () => {
|
|
17
|
+
let defaultObj = {
|
|
14
18
|
jobDetails: {
|
|
15
19
|
isRunByLocal: true,
|
|
16
20
|
hostName: os.hostname(),
|
|
@@ -21,27 +25,28 @@ var getRunnerDetail = exports.getRunnerDetail = function getRunnerDetail() {
|
|
|
21
25
|
return defaultObj;
|
|
22
26
|
};
|
|
23
27
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
exports.getRunnerDetail = getRunnerDetail;
|
|
29
|
+
let fileHandler = {
|
|
30
|
+
readFile: (path, callback = null) => {
|
|
28
31
|
if (fs.existsSync(path)) {
|
|
29
32
|
if (callback === null) {
|
|
30
33
|
return fs.readFileSync(path);
|
|
31
34
|
}
|
|
35
|
+
|
|
32
36
|
callback(fs.readFileSync(path));
|
|
33
37
|
} else {
|
|
34
38
|
return fileHandler.writeFile(path, getRunnerDetail());
|
|
35
39
|
}
|
|
36
40
|
},
|
|
37
|
-
writeFile:
|
|
41
|
+
writeFile: (path, data) => {
|
|
38
42
|
fs.writeFileSync(path, JSON.stringify(data));
|
|
39
43
|
return JSON.stringify(data);
|
|
40
44
|
}
|
|
41
45
|
};
|
|
46
|
+
exports.fileHandler = fileHandler;
|
|
42
47
|
|
|
43
|
-
|
|
44
|
-
Object.keys(senterObj).map(
|
|
48
|
+
let jsonConcate = (receiverObj, senterObj) => {
|
|
49
|
+
Object.keys(senterObj).map(key => {
|
|
45
50
|
if (Object.prototype.hasOwnProperty.call(receiverObj, key)) {
|
|
46
51
|
if (receiverObj[key].constructor === {}.constructor && senterObj[key].constructor === {}.constructor) {
|
|
47
52
|
jsonConcate(receiverObj[key], senterObj[key]);
|
|
@@ -53,29 +58,40 @@ var jsonConcate = exports.jsonConcate = function jsonConcate(receiverObj, senter
|
|
|
53
58
|
} else {
|
|
54
59
|
receiverObj[key] = senterObj[key];
|
|
55
60
|
}
|
|
61
|
+
|
|
56
62
|
return key;
|
|
57
63
|
});
|
|
58
64
|
return receiverObj;
|
|
59
65
|
};
|
|
60
66
|
|
|
61
|
-
|
|
62
|
-
|
|
67
|
+
exports.jsonConcate = jsonConcate;
|
|
68
|
+
|
|
69
|
+
let jsonHelper = (path, pathArray, value) => {
|
|
70
|
+
let tempObj = {};
|
|
71
|
+
|
|
63
72
|
if (typeof pathArray === 'string') {
|
|
64
73
|
pathArray = pathArray.split('.'); //eslint-disable-line no-param-reassign
|
|
65
74
|
}
|
|
66
|
-
|
|
75
|
+
|
|
76
|
+
pathArray.slice(0).reverse().map(key => {
|
|
67
77
|
tempObj = {};
|
|
68
78
|
tempObj[key] = value;
|
|
69
79
|
value = tempObj; // eslint-disable-line no-param-reassign
|
|
80
|
+
|
|
70
81
|
return key;
|
|
71
82
|
});
|
|
72
|
-
|
|
83
|
+
let overAllObj = jsonConcate(JSON.parse(fileHandler.readFile(path)), tempObj);
|
|
73
84
|
fileHandler.writeFile(path, overAllObj);
|
|
74
85
|
};
|
|
75
86
|
|
|
76
|
-
|
|
77
|
-
|
|
87
|
+
exports.jsonHelper = jsonHelper;
|
|
88
|
+
|
|
89
|
+
let setTestInfoStatus = (filepath, status) => {
|
|
90
|
+
let buildObject = JSON.parse(fileHandler.readFile(filepath));
|
|
91
|
+
|
|
78
92
|
if (!buildObject.testInfo || buildObject.testInfo.isBuildVerified !== false) {
|
|
79
93
|
jsonHelper(filepath, 'testInfo.isBuildVerified', status);
|
|
80
94
|
}
|
|
81
|
-
};
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
exports.setTestInfoStatus = setTestInfoStatus;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
|
|
5
|
+
const {
|
|
6
|
+
log
|
|
7
|
+
} = require('..');
|
|
8
|
+
|
|
9
|
+
function addScripts(scripts) {
|
|
10
|
+
fs.readFile('./package.json', 'utf8', (err, configFileString) => {
|
|
11
|
+
if (err) log('[LINT SETUP] No package.json in the current directory');else {
|
|
12
|
+
const configFile = JSON.parse(configFileString); // Still Object destructuring causes issue. 😐
|
|
13
|
+
// configFile.scripts = {
|
|
14
|
+
// ...configFile.scripts,
|
|
15
|
+
// ...scripts,
|
|
16
|
+
// };
|
|
17
|
+
|
|
18
|
+
configFile.scripts = Object.assign(configFile.scripts || {}, scripts);
|
|
19
|
+
const data = JSON.stringify(configFile, undefined, 2);
|
|
20
|
+
fs.writeFileSync('./package.json', data);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
module.exports = {
|
|
26
|
+
addScripts
|
|
27
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/* eslint-disable operator-linebreak */
|
|
4
|
+
|
|
5
|
+
/* eslint-disable implicit-arrow-linebreak */
|
|
6
|
+
const fs = require('fs');
|
|
7
|
+
|
|
8
|
+
const {
|
|
9
|
+
log
|
|
10
|
+
} = require('../../../lib/utils');
|
|
11
|
+
|
|
12
|
+
const {
|
|
13
|
+
question,
|
|
14
|
+
rl
|
|
15
|
+
} = require('./question');
|
|
16
|
+
|
|
17
|
+
const eslintConfigFiles = ['.eslintrc.js', '.eslintrc.cjs', '.eslintrc.yaml', '.eslintrc.yml', '.eslintrc.json', '.eslintrc'];
|
|
18
|
+
const prettierConfigFiles = ['.prettierrc.js', '.prettierrc.json', '.prettierrc', '.prettierrc.yml', '.prettierrc.yaml', '.prettierrc.json5', '.prettierrc.toml', '.prettierrc.cjs', '.prettier.config.js', '.prettier.config.cjs'];
|
|
19
|
+
|
|
20
|
+
function isConfigExists(fileNames) {
|
|
21
|
+
return fileNames.find(file => {
|
|
22
|
+
if (fs.existsSync(file)) return true;
|
|
23
|
+
return false;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async function checkConflicts(files) {
|
|
28
|
+
const conflictFile = isConfigExists(files);
|
|
29
|
+
|
|
30
|
+
if (conflictFile) {
|
|
31
|
+
log(`[LINT SETUP] There's already a config exists as named ${conflictFile}`);
|
|
32
|
+
const res = await question('[LINT SETUP] Do you want to overwrite? (y/n): '); // TODO: Next cycle: Need to delete the current config file.
|
|
33
|
+
// if (res === 'y') {
|
|
34
|
+
// exec(`rm ${conflictFile}`, (err) => {
|
|
35
|
+
// if (err) log(err);
|
|
36
|
+
// else {
|
|
37
|
+
// log('Deleted ', conflictFile);
|
|
38
|
+
// }
|
|
39
|
+
// });
|
|
40
|
+
// }
|
|
41
|
+
|
|
42
|
+
return res;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async function promptForPreCommitHook() {
|
|
49
|
+
const res = await question('[LINT SETUP] Do you need a pre-commit hook for formatting and check lint errors in cached files (newly changed)? (y/n): ');
|
|
50
|
+
return res;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const getChoices = async () => {
|
|
54
|
+
const eslint = await checkConflicts(eslintConfigFiles);
|
|
55
|
+
const prettier = await checkConflicts(prettierConfigFiles);
|
|
56
|
+
const isESLintAllowed = eslint === false || eslint === 'y';
|
|
57
|
+
const isPrettierAllowed = prettier === false || prettier === 'y';
|
|
58
|
+
const isHookInstallEnabled = (await promptForPreCommitHook()) === 'y';
|
|
59
|
+
rl.close();
|
|
60
|
+
return [isESLintAllowed, isPrettierAllowed, isHookInstallEnabled];
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
module.exports = {
|
|
64
|
+
eslintConfigFiles,
|
|
65
|
+
prettierConfigFiles,
|
|
66
|
+
getChoices
|
|
67
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
|
|
5
|
+
const {
|
|
6
|
+
log
|
|
7
|
+
} = require('../../../lib/utils');
|
|
8
|
+
|
|
9
|
+
async function copyConfigs(file) {
|
|
10
|
+
// copy the file in react-cli to current working directory
|
|
11
|
+
fs.readFile(require.resolve(`../../../files/${file}.js`), (err, data) => {
|
|
12
|
+
if (err) log("[LINT SETUP] There's error in reading the config file", file);else {
|
|
13
|
+
fs.writeFile(`.${file}.js`, data, writeError => {
|
|
14
|
+
if (writeError) {
|
|
15
|
+
log("[LINT SETUP] There's error in writing the config file: ", file, writeError);
|
|
16
|
+
} else {
|
|
17
|
+
log('[LINT SETUP] Added config file', file);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = copyConfigs;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
eslintPackages,
|
|
5
|
+
prettierPackages,
|
|
6
|
+
eslintPrettierConfig,
|
|
7
|
+
runInstall,
|
|
8
|
+
installLintStaged
|
|
9
|
+
} = require('./lintSetup');
|
|
10
|
+
|
|
11
|
+
const {
|
|
12
|
+
log
|
|
13
|
+
} = require('../../../lib/utils');
|
|
14
|
+
|
|
15
|
+
const {
|
|
16
|
+
eslintConfigFiles,
|
|
17
|
+
prettierConfigFiles,
|
|
18
|
+
getChoices
|
|
19
|
+
} = require('./checkExistingConfig');
|
|
20
|
+
|
|
21
|
+
const copyConfigs = require('./copyConfigs');
|
|
22
|
+
|
|
23
|
+
async function main() {
|
|
24
|
+
const packages = [];
|
|
25
|
+
const [isESLintAllowed, isPrettierAllowed, isHookInstallEnabled] = await getChoices();
|
|
26
|
+
|
|
27
|
+
if (isESLintAllowed) {
|
|
28
|
+
copyConfigs('eslintrc', eslintConfigFiles);
|
|
29
|
+
packages.push(...eslintPackages);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (isPrettierAllowed) {
|
|
33
|
+
copyConfigs('prettierrc', prettierConfigFiles);
|
|
34
|
+
packages.push(...prettierPackages);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (isESLintAllowed && isPrettierAllowed) {
|
|
38
|
+
packages.push(...eslintPrettierConfig);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (packages.length) {
|
|
42
|
+
const process = runInstall(packages);
|
|
43
|
+
process.on('close', () => {
|
|
44
|
+
if (isHookInstallEnabled) {
|
|
45
|
+
installLintStaged();
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
} else if (isHookInstallEnabled) {
|
|
49
|
+
installLintStaged();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
log('[LINT SETUP] Beginning configuration...');
|
|
54
|
+
main();
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
addScripts
|
|
5
|
+
} = require('./addScripts');
|
|
6
|
+
|
|
7
|
+
const scripts = {
|
|
8
|
+
lintSetup: 'react-cli lint-setup && npm run lintExtInstall && echo "If changes not reflected kindly restart your VSCode."',
|
|
9
|
+
lintExtInstall: 'code --install-extension dbaeumer.vscode-eslint && code --install-extension esbenp.prettier-vscode'
|
|
10
|
+
};
|
|
11
|
+
addScripts(scripts);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
spawn
|
|
5
|
+
} = require('child_process');
|
|
6
|
+
|
|
7
|
+
const eslintPackages = ['eslint', 'eslint-config-airbnb', 'eslint-plugin-import', 'eslint-plugin-jsx-a11y', 'eslint-plugin-react', 'eslint-plugin-react-hooks', 'eslint-plugin-css-modules', '@zohodesk/eslint-plugin-react-performance', '@zohodesk/eslint-plugin-zsecurity'];
|
|
8
|
+
const prettierPackages = ['prettier'];
|
|
9
|
+
const eslintPrettierConfig = ['eslint-config-prettier']; // const npmInstall = `npm i --save-dev ${devDependencies.join(' ')}`;
|
|
10
|
+
|
|
11
|
+
function runInstall(packages) {
|
|
12
|
+
return spawn('npm', ['i', ...packages, '--save-dev'], {
|
|
13
|
+
detached: true,
|
|
14
|
+
stdio: 'inherit'
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function installLintStaged() {
|
|
19
|
+
spawn('npx', ['mrm', 'lint-staged'], {
|
|
20
|
+
detached: true,
|
|
21
|
+
stdio: 'inherit'
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
module.exports = {
|
|
26
|
+
eslintPackages,
|
|
27
|
+
prettierPackages,
|
|
28
|
+
eslintPrettierConfig,
|
|
29
|
+
installLintStaged,
|
|
30
|
+
runInstall
|
|
31
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/* eslint-disable no-await-in-loop */
|
|
4
|
+
|
|
5
|
+
/* eslint-disable implicit-arrow-linebreak */
|
|
6
|
+
const readline = require('readline');
|
|
7
|
+
|
|
8
|
+
const rl = readline.createInterface({
|
|
9
|
+
input: process.stdin,
|
|
10
|
+
output: process.stdout
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const question = qn => new Promise(res => {
|
|
14
|
+
rl.question(qn, ans => res(ans));
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
async function main(qn) {
|
|
18
|
+
let answer;
|
|
19
|
+
|
|
20
|
+
while (!['n', 'y'].includes(answer)) {
|
|
21
|
+
answer = (await question(qn)).toLowerCase();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return answer;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
module.exports = {
|
|
28
|
+
question: main,
|
|
29
|
+
rl
|
|
30
|
+
};
|
|
@@ -1,27 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
let getOptions = require('./getOptions').default;
|
|
4
|
+
|
|
5
|
+
let fs = require('fs');
|
|
6
|
+
|
|
7
|
+
let coverageCollector = require('../jest/coverageCollector');
|
|
8
|
+
|
|
9
|
+
let path = require('path');
|
|
10
|
+
|
|
11
|
+
let {
|
|
12
|
+
htmlTemplate,
|
|
13
|
+
endTag
|
|
14
|
+
} = require('../templates/linterConstant');
|
|
15
|
+
|
|
16
|
+
let {
|
|
17
|
+
esLint: {
|
|
18
|
+
srcBranch,
|
|
19
|
+
targetBranch,
|
|
20
|
+
serviceName,
|
|
21
|
+
impactServerDomain,
|
|
22
|
+
impactRun,
|
|
23
|
+
reportType,
|
|
24
|
+
reportPath
|
|
25
|
+
}
|
|
26
|
+
} = getOptions();
|
|
21
27
|
|
|
22
28
|
function writeFile(filePath, data) {
|
|
23
29
|
filePath = path.join(process.cwd(), filePath); //eslint-disable-line
|
|
24
|
-
|
|
30
|
+
|
|
31
|
+
let dirName = path.dirname(filePath);
|
|
32
|
+
|
|
25
33
|
if (!fs.existsSync(dirName)) {
|
|
26
34
|
fs.mkdirSync(dirName);
|
|
27
35
|
fs.writeFileSync(filePath, data);
|
|
@@ -30,51 +38,55 @@ function writeFile(filePath, data) {
|
|
|
30
38
|
}
|
|
31
39
|
}
|
|
32
40
|
|
|
33
|
-
|
|
34
|
-
jsonFormatter:
|
|
35
|
-
|
|
36
|
-
data.forEach(
|
|
37
|
-
|
|
38
|
-
errorFileObj.messages.forEach(
|
|
41
|
+
let formatter = {
|
|
42
|
+
jsonFormatter: data => {
|
|
43
|
+
let finalList = [];
|
|
44
|
+
data.forEach(errorFileObj => {
|
|
45
|
+
let tempMessageList = [];
|
|
46
|
+
errorFileObj.messages.forEach(messageObj => {
|
|
39
47
|
if (messageObj.ruleId === '@zohodesk/zsecurity/no-protocol-check' || messageObj.ruleId === '@zohodesk/zsecurity/no-unsecure-html') {
|
|
40
48
|
tempMessageList.push(messageObj);
|
|
41
49
|
}
|
|
42
50
|
});
|
|
51
|
+
|
|
43
52
|
if (tempMessageList.length > 0) {
|
|
44
53
|
finalList.push(errorFileObj);
|
|
45
54
|
}
|
|
46
55
|
});
|
|
47
56
|
return finalList;
|
|
48
57
|
},
|
|
49
|
-
htmlFormatter:
|
|
58
|
+
htmlFormatter: data => {
|
|
50
59
|
data = formatter.jsonFormatter(data); //eslint-disable-line
|
|
60
|
+
|
|
51
61
|
if (data.length > 0) {
|
|
52
|
-
|
|
53
|
-
data.forEach(
|
|
54
|
-
liTag = liTag
|
|
55
|
-
|
|
56
|
-
errorFileObj.messages.forEach(
|
|
57
|
-
|
|
58
|
-
|
|
62
|
+
let liTag = '';
|
|
63
|
+
data.forEach(errorFileObj => {
|
|
64
|
+
liTag = `${liTag}<li class="pkLi"><div class="pkRow"> <div class="pkArrowCont" onclick="toggleWrapper(this)"> <div class="pkArrow"></div></div><div class="pkFileName">File Name :</div><div class="pkUrl">${errorFileObj.filePath}</div></div><div class="pkDetails"><div class="pkDetailsHead"> <div class="pkDetailsCol">Line No</div><div class="pkDetailsCol">Type</div><div class="pkDetailsCol">Message</div><div class="pkDetailsCol">Name</div></div><div class="pkDetailsBody">`;
|
|
65
|
+
let messageTag = '';
|
|
66
|
+
errorFileObj.messages.forEach(messageObj => {
|
|
67
|
+
let errorType = messageObj.severity == 2 ? 'Error' : 'Warning'; //eslint-disable-line
|
|
68
|
+
|
|
69
|
+
messageTag = `${messageTag}<div class="pkDetailsRow"><div class="pkDetailsCol">${messageObj.line}</div><div class="pkDetailsCol pkError">${errorType}</div><div class="pkDetailsCol">${messageObj.message}</div><div class="pkDetailsCol">${messageObj.ruleId}</div></div>`;
|
|
59
70
|
});
|
|
60
|
-
liTag = liTag + messageTag
|
|
71
|
+
liTag = `${liTag + messageTag}</div></div></li>`;
|
|
61
72
|
});
|
|
62
|
-
|
|
63
|
-
return htmlTemplate + '<ul class="pkUl">' + liTag + '</ul>' + endTag;
|
|
73
|
+
return `${htmlTemplate}<ul class="pkUl">${liTag}</ul>${endTag}`;
|
|
64
74
|
}
|
|
65
|
-
|
|
75
|
+
|
|
76
|
+
return `${htmlTemplate}<div class="pkEmpty"><div>No test results with found</div></div>${endTag}`;
|
|
66
77
|
},
|
|
67
|
-
xmlFormatter:
|
|
78
|
+
xmlFormatter: data => {
|
|
68
79
|
data = formatter.jsonFormatter(data); //eslint-disable-line
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
80
|
+
|
|
81
|
+
let startTag = '<jscheck>';
|
|
82
|
+
let engTag = '</jscheck>';
|
|
83
|
+
let bodyContent = '';
|
|
84
|
+
data.forEach(errorFileObj => {
|
|
85
|
+
let startOfFile = `<file name="${errorFileObj.filePath}">`;
|
|
86
|
+
let endOfFile = '</file>';
|
|
87
|
+
let messageContent = '';
|
|
88
|
+
errorFileObj.messages.forEach(messageObj => {
|
|
89
|
+
messageContent = `${messageContent}<violation fromLine = "${messageObj.line}" type ="${messageObj.ruleId}" message ="${messageObj.message}" ></violation>`;
|
|
78
90
|
});
|
|
79
91
|
bodyContent = bodyContent + startOfFile + messageContent + endOfFile;
|
|
80
92
|
});
|
|
@@ -83,7 +95,8 @@ var formatter = {
|
|
|
83
95
|
};
|
|
84
96
|
|
|
85
97
|
function formatSplitter(inputJson) {
|
|
86
|
-
|
|
98
|
+
let outputData;
|
|
99
|
+
|
|
87
100
|
if (reportType === 'json') {
|
|
88
101
|
outputData = JSON.stringify(formatter.jsonFormatter(inputJson));
|
|
89
102
|
} else if (reportType === 'html') {
|
|
@@ -91,12 +104,13 @@ function formatSplitter(inputJson) {
|
|
|
91
104
|
} else if (reportType === 'xml') {
|
|
92
105
|
outputData = formatter.xmlFormatter(inputJson);
|
|
93
106
|
}
|
|
107
|
+
|
|
94
108
|
writeFile(reportPath, outputData);
|
|
95
109
|
}
|
|
96
110
|
|
|
97
111
|
module.exports = function (results) {
|
|
98
|
-
|
|
99
|
-
results.forEach(
|
|
112
|
+
let erroredFileObjectList = [];
|
|
113
|
+
results.forEach(fileObject => {
|
|
100
114
|
if (fileObject.errorCount > 0) {
|
|
101
115
|
erroredFileObjectList.push({
|
|
102
116
|
filePath: fileObject.filePath,
|
|
@@ -106,14 +120,14 @@ module.exports = function (results) {
|
|
|
106
120
|
});
|
|
107
121
|
}
|
|
108
122
|
});
|
|
123
|
+
|
|
109
124
|
if (impactRun) {
|
|
110
|
-
coverageCollector(srcBranch, targetBranch, serviceName, impactServerDomain).then(
|
|
111
|
-
|
|
125
|
+
coverageCollector(srcBranch, targetBranch, serviceName, impactServerDomain).then((res = {}) => {
|
|
126
|
+
let impactList = [];
|
|
112
127
|
|
|
113
|
-
var impactList = [];
|
|
114
128
|
if (res.STATUS) {
|
|
115
129
|
if (res.LIST.length > 0) {
|
|
116
|
-
erroredFileObjectList.forEach(
|
|
130
|
+
erroredFileObjectList.forEach(errFileObj => {
|
|
117
131
|
if (res.LIST.indexOf(errFileObj.shortPath) > -1) {
|
|
118
132
|
impactList.push(errFileObj);
|
|
119
133
|
}
|
package/lib/utils/mailSender.js
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _nodemailer = _interopRequireDefault(require("nodemailer"));
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _index = require("./index");
|
|
6
6
|
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
var _index = require('./index');
|
|
10
|
-
|
|
11
|
-
var _jsonHelper = require('./jsonHelper');
|
|
7
|
+
var _jsonHelper = require("./jsonHelper");
|
|
12
8
|
|
|
13
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
10
|
|
|
@@ -17,41 +13,30 @@ if (process.argv.length <= 6) {
|
|
|
17
13
|
process.exit(-1);
|
|
18
14
|
}
|
|
19
15
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
from = _process$argv$slice2[0],
|
|
23
|
-
pass = _process$argv$slice2[1],
|
|
24
|
-
to = _process$argv$slice2[2],
|
|
25
|
-
subject = _process$argv$slice2[3],
|
|
26
|
-
html = _process$argv$slice2[4],
|
|
27
|
-
cc = _process$argv$slice2[5],
|
|
28
|
-
user = _process$argv$slice2[6],
|
|
29
|
-
reportURL = _process$argv$slice2[7];
|
|
16
|
+
let [from, pass, to, subject, html, cc, user, reportURL] = process.argv.slice(2);
|
|
17
|
+
(0, _jsonHelper.jsonHelper)(`${process.cwd()}/result.json`, 'Report_URL', reportURL);
|
|
30
18
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
var transporter = _nodemailer2.default.createTransport({
|
|
19
|
+
let transporter = _nodemailer.default.createTransport({
|
|
34
20
|
host: 'smtp.tsi.zohocorpin.com',
|
|
35
21
|
port: 25,
|
|
36
22
|
secure: false,
|
|
37
23
|
auth: {
|
|
38
|
-
user
|
|
39
|
-
pass
|
|
24
|
+
user,
|
|
25
|
+
pass
|
|
40
26
|
}
|
|
41
27
|
});
|
|
42
28
|
|
|
43
|
-
|
|
29
|
+
let mailOptions = {
|
|
44
30
|
from: from,
|
|
45
31
|
to: to,
|
|
46
32
|
cc: cc,
|
|
47
33
|
subject: subject,
|
|
48
34
|
html: html
|
|
49
35
|
};
|
|
50
|
-
|
|
51
|
-
transporter.sendMail(mailOptions, function (error, info) {
|
|
36
|
+
transporter.sendMail(mailOptions, (error, info) => {
|
|
52
37
|
if (error) {
|
|
53
38
|
(0, _index.log)(error);
|
|
54
39
|
} else {
|
|
55
|
-
(0, _index.log)(
|
|
40
|
+
(0, _index.log)(`Email sent: ${info.response}`);
|
|
56
41
|
}
|
|
57
42
|
});
|