@zohodesk/react-cli 0.0.1-beta.16 → 0.0.1-beta.160
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 +650 -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 +18 -28
- 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 +113 -57
- 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 +154 -86
- 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 +173 -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 +238 -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 +211 -0
- package/lib/plugins/EFCPlugin.md +6 -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 +52 -63
- 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 +463 -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 +70 -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
@@ -0,0 +1,63 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
|
8
|
+
var _utils = require("../utils");
|
9
|
+
|
10
|
+
let options = (0, _utils.getOptions)();
|
11
|
+
let {
|
12
|
+
impactService: {
|
13
|
+
componentServiceName,
|
14
|
+
svgServiceName,
|
15
|
+
iconServiceName,
|
16
|
+
variableServiceName,
|
17
|
+
dotServiceName,
|
18
|
+
sourceServiceName
|
19
|
+
}
|
20
|
+
} = options;
|
21
|
+
var _default = {
|
22
|
+
AppSource: {
|
23
|
+
impactService: sourceServiceName,
|
24
|
+
gitDomain: "ht" + "tps://zgit.csez.zohocorpin.com",
|
25
|
+
impactDomain: "ht" + "tp://desk-automation.csez.zohocorpin.com:8080"
|
26
|
+
},
|
27
|
+
"components": {
|
28
|
+
projectId: "5515",
|
29
|
+
impactService: componentServiceName,
|
30
|
+
gitDomain: "ht" + "tps://zgit.csez.zohocorpin.com",
|
31
|
+
impactDomain: "ht" + "tp://desk-automation.csez.zohocorpin.com:8080",
|
32
|
+
name: "@zohodesk/components"
|
33
|
+
},
|
34
|
+
"dot": {
|
35
|
+
projectId: "5515",
|
36
|
+
impactService: dotServiceName,
|
37
|
+
gitDomain: "ht" + "tps://zgit.csez.zohocorpin.com",
|
38
|
+
impactDomain: "ht" + "tp://desk-automation.csez.zohocorpin.com:8080",
|
39
|
+
name: "@zohodesk/dot"
|
40
|
+
},
|
41
|
+
"svg": {
|
42
|
+
projectId: "5515",
|
43
|
+
impactService: svgServiceName,
|
44
|
+
gitDomain: "ht" + "tps://zgit.csez.zohocorpin.com",
|
45
|
+
impactDomain: "ht" + "tp://desk-automation.csez.zohocorpin.com:8080",
|
46
|
+
name: "@zohodesk/svg"
|
47
|
+
},
|
48
|
+
"icons": {
|
49
|
+
projectId: "5515",
|
50
|
+
impactService: iconServiceName,
|
51
|
+
gitDomain: "ht" + "tps://zgit.csez.zohocorpin.com",
|
52
|
+
impactDomain: "ht" + "tp://desk-automation.csez.zohocorpin.com:8080",
|
53
|
+
name: "@zohodesk/icons"
|
54
|
+
},
|
55
|
+
"variables": {
|
56
|
+
projectId: "5515",
|
57
|
+
impactService: variableServiceName,
|
58
|
+
gitDomain: "ht" + "tps://zgit.csez.zohocorpin.com",
|
59
|
+
impactDomain: "ht" + "tp://desk-automation.csez.zohocorpin.com:8080",
|
60
|
+
name: "@zohodesk/variables"
|
61
|
+
}
|
62
|
+
};
|
63
|
+
exports.default = _default;
|
@@ -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('..');
|
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('..');
|
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('..');
|
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@7.18.0', 'eslint-config-airbnb@18.2.1', 'eslint-plugin-import@2.22.1', 'eslint-plugin-jsx-a11y@6.4.1', 'eslint-plugin-react@7.22.0', 'eslint-plugin-css-modules@2.11.0', '@zohodesk/eslint-plugin-react-performance@1.0.3', '@zohodesk/eslint-plugin-zsecurity@0.0.1-beta.4', 'eslint-plugin-react-hooks@4.2.0'];
|
8
|
+
const prettierPackages = ['prettier@2.2.1'];
|
9
|
+
const eslintPrettierConfig = ['eslint-config-prettier@7.2.0']; // 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
|
+
};
|
@@ -0,0 +1,142 @@
|
|
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();
|
27
|
+
|
28
|
+
function writeFile(filePath, data) {
|
29
|
+
filePath = path.join(process.cwd(), filePath); //eslint-disable-line
|
30
|
+
|
31
|
+
let dirName = path.dirname(filePath);
|
32
|
+
|
33
|
+
if (!fs.existsSync(dirName)) {
|
34
|
+
fs.mkdirSync(dirName);
|
35
|
+
fs.writeFileSync(filePath, data);
|
36
|
+
} else {
|
37
|
+
fs.writeFileSync(filePath, data);
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
41
|
+
let formatter = {
|
42
|
+
jsonFormatter: data => {
|
43
|
+
let finalList = [];
|
44
|
+
data.forEach(errorFileObj => {
|
45
|
+
let tempMessageList = [];
|
46
|
+
errorFileObj.messages.forEach(messageObj => {
|
47
|
+
if (messageObj.ruleId === '@zohodesk/zsecurity/no-protocol-check' || messageObj.ruleId === '@zohodesk/zsecurity/no-unsecure-html') {
|
48
|
+
tempMessageList.push(messageObj);
|
49
|
+
}
|
50
|
+
});
|
51
|
+
|
52
|
+
if (tempMessageList.length > 0) {
|
53
|
+
finalList.push(errorFileObj);
|
54
|
+
}
|
55
|
+
});
|
56
|
+
return finalList;
|
57
|
+
},
|
58
|
+
htmlFormatter: data => {
|
59
|
+
data = formatter.jsonFormatter(data); //eslint-disable-line
|
60
|
+
|
61
|
+
if (data.length > 0) {
|
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>`;
|
70
|
+
});
|
71
|
+
liTag = `${liTag + messageTag}</div></div></li>`;
|
72
|
+
});
|
73
|
+
return `${htmlTemplate}<ul class="pkUl">${liTag}</ul>${endTag}`;
|
74
|
+
}
|
75
|
+
|
76
|
+
return `${htmlTemplate}<div class="pkEmpty"><div>No test results with found</div></div>${endTag}`;
|
77
|
+
},
|
78
|
+
xmlFormatter: data => {
|
79
|
+
data = formatter.jsonFormatter(data); //eslint-disable-line
|
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>`;
|
90
|
+
});
|
91
|
+
bodyContent = bodyContent + startOfFile + messageContent + endOfFile;
|
92
|
+
});
|
93
|
+
return startTag + bodyContent + engTag;
|
94
|
+
}
|
95
|
+
};
|
96
|
+
|
97
|
+
function formatSplitter(inputJson) {
|
98
|
+
let outputData;
|
99
|
+
|
100
|
+
if (reportType === 'json') {
|
101
|
+
outputData = JSON.stringify(formatter.jsonFormatter(inputJson));
|
102
|
+
} else if (reportType === 'html') {
|
103
|
+
outputData = formatter.htmlFormatter(inputJson);
|
104
|
+
} else if (reportType === 'xml') {
|
105
|
+
outputData = formatter.xmlFormatter(inputJson);
|
106
|
+
}
|
107
|
+
|
108
|
+
writeFile(reportPath, outputData);
|
109
|
+
}
|
110
|
+
|
111
|
+
module.exports = function (results) {
|
112
|
+
let erroredFileObjectList = [];
|
113
|
+
results.forEach(fileObject => {
|
114
|
+
if (fileObject.errorCount > 0) {
|
115
|
+
erroredFileObjectList.push({
|
116
|
+
filePath: fileObject.filePath,
|
117
|
+
messages: fileObject.messages,
|
118
|
+
errorCount: fileObject.errorCount,
|
119
|
+
shortPath: fileObject.filePath.split('/supportapp/')[1]
|
120
|
+
});
|
121
|
+
}
|
122
|
+
});
|
123
|
+
|
124
|
+
if (impactRun) {
|
125
|
+
coverageCollector(srcBranch, targetBranch, serviceName, impactServerDomain).then((res = {}) => {
|
126
|
+
let impactList = [];
|
127
|
+
|
128
|
+
if (res.STATUS) {
|
129
|
+
if (res.LIST.length > 0) {
|
130
|
+
erroredFileObjectList.forEach(errFileObj => {
|
131
|
+
if (res.LIST.indexOf(errFileObj.shortPath) > -1) {
|
132
|
+
impactList.push(errFileObj);
|
133
|
+
}
|
134
|
+
});
|
135
|
+
formatSplitter(impactList);
|
136
|
+
}
|
137
|
+
}
|
138
|
+
});
|
139
|
+
} else {
|
140
|
+
formatSplitter(erroredFileObjectList);
|
141
|
+
}
|
142
|
+
};
|
package/lib/utils/mailSender.js
CHANGED
@@ -1,12 +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');
|
7
|
+
var _jsonHelper = require("./jsonHelper");
|
10
8
|
|
11
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
12
10
|
|
@@ -15,37 +13,30 @@ if (process.argv.length <= 6) {
|
|
15
13
|
process.exit(-1);
|
16
14
|
}
|
17
15
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
cc = _process$argv$slice2[5];
|
26
|
-
|
27
|
-
var transporter = _nodemailer2.default.createTransport({
|
28
|
-
host: 'smtp.zoho.com',
|
29
|
-
port: 465,
|
30
|
-
secure: true,
|
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);
|
18
|
+
|
19
|
+
let transporter = _nodemailer.default.createTransport({
|
20
|
+
host: 'smtp.tsi.zohocorpin.com',
|
21
|
+
port: 25,
|
22
|
+
secure: false,
|
31
23
|
auth: {
|
32
|
-
user
|
33
|
-
pass
|
24
|
+
user,
|
25
|
+
pass
|
34
26
|
}
|
35
27
|
});
|
36
28
|
|
37
|
-
|
29
|
+
let mailOptions = {
|
38
30
|
from: from,
|
39
31
|
to: to,
|
40
32
|
cc: cc,
|
41
33
|
subject: subject,
|
42
34
|
html: html
|
43
35
|
};
|
44
|
-
|
45
|
-
transporter.sendMail(mailOptions, function (error, info) {
|
36
|
+
transporter.sendMail(mailOptions, (error, info) => {
|
46
37
|
if (error) {
|
47
38
|
(0, _index.log)(error);
|
48
39
|
} else {
|
49
|
-
(0, _index.log)(
|
40
|
+
(0, _index.log)(`Email sent: ${info.response}`);
|
50
41
|
}
|
51
42
|
});
|
@@ -0,0 +1,28 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
|
8
|
+
var _child_process = require("child_process");
|
9
|
+
|
10
|
+
var _utils = require("../utils");
|
11
|
+
|
12
|
+
var _default = (type = 'git', branchName) => new Promise(resolve => {
|
13
|
+
if (type === 'git') {
|
14
|
+
(0, _child_process.spawnSync)('git', ['pull', 'origin', branchName], {
|
15
|
+
encoding: 'utf8'
|
16
|
+
});
|
17
|
+
(0, _utils.log)(branchName, 'Branch Pulled!');
|
18
|
+
resolve();
|
19
|
+
} else if (type === 'hg') {
|
20
|
+
(0, _child_process.spawnSync)('hg', ['pull'], {
|
21
|
+
encoding: 'utf8'
|
22
|
+
});
|
23
|
+
(0, _utils.log)(branchName, 'Branch Pulled!');
|
24
|
+
resolve();
|
25
|
+
}
|
26
|
+
});
|
27
|
+
|
28
|
+
exports.default = _default;
|