@zohodesk/react-cli 0.0.1-beta.17 → 0.0.1-beta.171
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 +49 -10
- package/.prettierrc +6 -0
- package/CHANGELOG.md +5 -0
- package/README.md +859 -0
- package/bin/cli.js +215 -46
- package/cert/Tsicsezwild-22-23.crt +37 -0
- package/cert/Tsicsezwild-22-23.key +27 -0
- package/docs/CustomChunks.md +26 -0
- package/docs/DevStart.md +18 -0
- package/docs/HoverActive.md +12 -0
- package/docs/InstallNode.md +28 -0
- package/docs/TODOS.md +10 -0
- package/docs/ValueReplacer.md +60 -0
- package/docs/warnings_while_install.txt +35 -0
- package/files/eslintrc.js +62 -0
- package/files/prettierrc.js +3 -0
- package/lib/babel/cmjs-plugins-presets.js +24 -0
- package/lib/babel/es-plugins-presets.js +34 -0
- package/lib/common/getEntries.js +33 -46
- package/lib/common/getPublicPathConfig.js +40 -0
- package/lib/common/index.js +24 -19
- package/lib/common/splitChunks.js +110 -25
- package/lib/common/sslcertUpdater.js +59 -0
- package/lib/common/templateParameters.js +25 -0
- package/lib/common/testPattern.js +69 -0
- package/lib/common/valueReplacer.js +55 -0
- package/lib/configs/jest.config.js +31 -27
- package/lib/configs/libAlias.js +31 -0
- package/lib/configs/webpack.component.umd.config.js +46 -53
- package/lib/configs/webpack.css.umd.config.js +47 -46
- package/lib/configs/webpack.dev.config.js +99 -84
- package/lib/configs/webpack.docs.config.js +65 -57
- package/lib/configs/webpack.impact.config.js +109 -0
- package/lib/configs/webpack.prod.config.js +147 -104
- package/lib/hooks/docsProptypeHook.js +32 -38
- package/lib/jest/commitedFilesResult.js +144 -71
- package/lib/jest/coverageCollector.js +68 -35
- 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 +92 -42
- package/lib/jest/run.js +75 -28
- package/lib/jest/setup.js +103 -102
- package/lib/loaderUtils/configsAssetsLoaders.js +117 -0
- package/lib/loaderUtils/getCSSLoaders.js +113 -0
- package/lib/loaderUtils/getDevJsLoaders.js +35 -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 +23 -20
- package/lib/loaders/selectorMappingLoader.js +75 -0
- package/lib/loaders/workerLoader.js +136 -0
- package/lib/middlewares/HMRMiddleware.js +90 -72
- package/lib/middlewares/SSTMiddleware.js +21 -0
- package/lib/pluginUtils/getDevPlugins.js +177 -30
- package/lib/pluginUtils/getDocsPlugins.js +36 -15
- package/lib/pluginUtils/getLibraryImactPlugins.js +23 -0
- package/lib/pluginUtils/getLibraryPlugins.js +8 -10
- package/lib/pluginUtils/getProdPlugins.js +244 -37
- package/lib/pluginUtils/getServerPlugins.js +8 -11
- package/lib/pluginUtils/getUMDCSSPlugins.js +14 -18
- package/lib/pluginUtils/getUMDComponentPlugins.js +14 -9
- 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 +95 -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 +86 -0
- package/lib/plugins/ModuleStatsPlugin.js +98 -97
- package/lib/plugins/OptimizeJSPlugin.js +41 -0
- package/lib/plugins/PublicPathCallbackPlugin.js +63 -0
- package/lib/plugins/PublicPathChangePlugin.js +226 -0
- package/lib/plugins/ReportGeneratePlugin.js +181 -0
- package/lib/plugins/RequireVariablePublicPlugin.js +30 -0
- package/lib/plugins/ResourceHintsPlugin.js +67 -0
- 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 -59
- package/lib/plugins/TPHashMappingPlugin.js +67 -0
- package/lib/plugins/UglifyCSSPlugin.js +39 -0
- package/lib/plugins/UnusedFilesFindPlugin.js +150 -97
- package/lib/plugins/index.js +127 -37
- package/lib/plugins/libraryImpactPlugin.js +190 -0
- package/lib/plugins/webpackwatchrunplugin.js +26 -0
- package/lib/postcss-plugins/ExcludePlugin.js +23 -0
- package/lib/postcss-plugins/RTLSplitPlugin.js +138 -0
- package/lib/postcss-plugins/ValueReplacer.js +46 -0
- package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +22 -0
- package/lib/postcss-plugins/__test__/test1Input.css +39 -0
- package/lib/postcss-plugins/__test__/test1Output.css +39 -0
- package/lib/postcss-plugins/hoverActivePlugin.js +368 -0
- package/lib/postcss-plugins/variableModifier.js +243 -0
- package/lib/schemas/index.js +541 -65
- package/lib/servers/clusterHubServer.js +22 -26
- package/lib/servers/devBuild.js +102 -0
- package/lib/servers/docsServer.js +3 -5
- package/lib/servers/docsServerCore.js +94 -79
- package/lib/servers/getCliPath.js +28 -0
- package/lib/servers/helpServer.js +19 -21
- package/lib/servers/httpsOptions.js +18 -0
- package/lib/servers/impactServer.js +123 -115
- package/lib/servers/mockserver.js +44 -0
- package/lib/servers/nowatchserver.js +200 -0
- package/lib/servers/scrServer.js +147 -0
- package/lib/servers/server.js +134 -132
- package/lib/servers/ssServer.js +106 -70
- 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 -4
- package/lib/utils/buildstats.html +148 -0
- package/lib/utils/clean.js +12 -11
- package/lib/utils/copy.js +16 -109
- 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 +136 -0
- 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 +113 -28
- package/lib/utils/getServerURL.js +25 -8
- package/lib/utils/index.js +283 -68
- package/lib/utils/init.js +2 -2
- package/lib/utils/initPreCommitHook.js +47 -27
- package/lib/utils/jsonHelper.js +106 -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 +59 -63
- package/lib/utils/request.js +64 -77
- package/lib/utils/resultSchema.json +73 -0
- package/lib/utils/rtl.js +59 -0
- package/lib/utils/setEnvVariables.js +13 -0
- package/lib/utils/ssTestHack.js +48 -0
- package/lib/utils/switchBranch.js +28 -0
- package/lib/utils/urlConcat.js +22 -0
- package/lib/utils/useExitCleanup.js +55 -0
- package/npm8.md +9 -0
- package/package.json +96 -64
- package/postpublish.js +6 -0
- 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
- package/.npmignore +0 -3
- package/cert/cert.pem +0 -129
- package/cert/key.pem +0 -27
- package/lib/common/getInsertAt.js +0 -36
- package/lib/common/getInsertIntoFunction.js +0 -13
- package/lib/configs/webpack.server.config.js +0 -93
- package/lib/plugins/ChunkManifestReplacePlugin.js +0 -94
- package/lib/plugins/RuntimePublicPathPlugin.js +0 -46
- package/lib/rmcntrlm.sh +0 -14
- package/lib/servers/nodeServer.js +0 -238
- package/lib/templates/HMRTemplate.js +0 -256
- package/lib/templates/publicPathTemplate.js +0 -16
- package/lib/utils/setConfig.js +0 -14
- package/node_modules/history/CHANGES.md +0 -395
- package/node_modules/history/DOMUtils.js +0 -3
- package/node_modules/history/ExecutionEnvironment.js +0 -3
- package/node_modules/history/LICENSE +0 -21
- package/node_modules/history/LocationUtils.js +0 -3
- package/node_modules/history/PathUtils.js +0 -3
- package/node_modules/history/README.md +0 -282
- package/node_modules/history/cjs/history.js +0 -933
- package/node_modules/history/cjs/history.min.js +0 -1
- package/node_modules/history/createBrowserHistory.js +0 -3
- package/node_modules/history/createHashHistory.js +0 -3
- package/node_modules/history/createMemoryHistory.js +0 -3
- package/node_modules/history/createTransitionManager.js +0 -3
- package/node_modules/history/es/DOMUtils.js +0 -7
- package/node_modules/history/es/ExecutionEnvironment.js +0 -7
- package/node_modules/history/es/LocationUtils.js +0 -7
- package/node_modules/history/es/PathUtils.js +0 -7
- package/node_modules/history/es/createBrowserHistory.js +0 -7
- package/node_modules/history/es/createHashHistory.js +0 -7
- package/node_modules/history/es/createMemoryHistory.js +0 -7
- package/node_modules/history/es/createTransitionManager.js +0 -7
- package/node_modules/history/es/warnAboutDeprecatedESMImport.js +0 -35
- package/node_modules/history/esm/history.js +0 -904
- package/node_modules/history/index.js +0 -7
- package/node_modules/history/package.json +0 -134
- package/node_modules/history/umd/history.js +0 -1059
- package/node_modules/history/umd/history.min.js +0 -1
- package/node_modules/history/warnAboutDeprecatedCJSRequire.js +0 -35
- package/templates/app/.npmignore +0 -9
- package/templates/library/.npmignore +0 -9
@@ -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;
|
@@ -0,0 +1,133 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.reinstallDependencies1 = exports.reinstallDependencies = exports.collectPackageDiff = void 0;
|
7
|
+
|
8
|
+
var _fs = _interopRequireDefault(require("fs"));
|
9
|
+
|
10
|
+
var _path = _interopRequireDefault(require("path"));
|
11
|
+
|
12
|
+
var _child_process = require("child_process");
|
13
|
+
|
14
|
+
var _gitRootDir = _interopRequireDefault(require("git-root-dir"));
|
15
|
+
|
16
|
+
var _index = require("./index");
|
17
|
+
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
19
|
+
|
20
|
+
let packageJsons = {};
|
21
|
+
|
22
|
+
let packageDiffChecker = (pre, current) => {
|
23
|
+
let {
|
24
|
+
dependencies = {},
|
25
|
+
devDependencies = {}
|
26
|
+
} = current;
|
27
|
+
let diffs = {};
|
28
|
+
Object.keys(dependencies).forEach(pack => {
|
29
|
+
let version = dependencies[pack];
|
30
|
+
|
31
|
+
if (version !== pre.dependencies && pre.dependencies[pack]) {
|
32
|
+
diffs[pack] = version;
|
33
|
+
}
|
34
|
+
});
|
35
|
+
Object.keys(devDependencies).forEach(pack => {
|
36
|
+
let version = devDependencies[pack];
|
37
|
+
|
38
|
+
if (version !== pre.devDependencies && pre.devDependencies[pack]) {
|
39
|
+
diffs[pack] = version;
|
40
|
+
}
|
41
|
+
});
|
42
|
+
return diffs;
|
43
|
+
};
|
44
|
+
|
45
|
+
let collectPackageDiff = pathToSubProjects => new Promise(resolve => {
|
46
|
+
(0, _gitRootDir.default)(process.cwd()).then(rootDir => {
|
47
|
+
let projects = _fs.default.readdirSync(_path.default.join(rootDir, pathToSubProjects));
|
48
|
+
|
49
|
+
projects.forEach(project => {
|
50
|
+
let packageJson = _path.default.join(_path.default.join(rootDir, pathToSubProjects), project, 'package.json');
|
51
|
+
|
52
|
+
if (_fs.default.existsSync(packageJson)) {
|
53
|
+
packageJsons[project] = require(packageJson);
|
54
|
+
}
|
55
|
+
});
|
56
|
+
resolve();
|
57
|
+
});
|
58
|
+
});
|
59
|
+
|
60
|
+
exports.collectPackageDiff = collectPackageDiff;
|
61
|
+
|
62
|
+
let reinstallDependencies1 = pathToSubProjects => {
|
63
|
+
(0, _gitRootDir.default)(process.cwd()).then(rootDir => {
|
64
|
+
let projects = _fs.default.readdirSync(_path.default.join(rootDir, pathToSubProjects));
|
65
|
+
|
66
|
+
projects.forEach(project => {
|
67
|
+
let prePackageJson = packageJsons[project];
|
68
|
+
let currentPackageJson;
|
69
|
+
|
70
|
+
if (prePackageJson) {
|
71
|
+
currentPackageJson = _path.default.join(_path.default.join(rootDir, pathToSubProjects), project, 'package.json');
|
72
|
+
|
73
|
+
if (_fs.default.existsSync(currentPackageJson)) {
|
74
|
+
currentPackageJson = require(currentPackageJson);
|
75
|
+
}
|
76
|
+
}
|
77
|
+
|
78
|
+
let projPath = _path.default.join(_path.default.join(rootDir, pathToSubProjects), project);
|
79
|
+
|
80
|
+
let diffs = packageDiffChecker(prePackageJson, currentPackageJson);
|
81
|
+
|
82
|
+
if (Object.keys(diffs).length) {
|
83
|
+
(0, _index.log)(diffs, `package diffs between branches for ${project} project`);
|
84
|
+
(0, _child_process.spawnSync)('rm', ['-rf', 'package-lock.json'], {
|
85
|
+
cwd: projPath,
|
86
|
+
stdio: 'inherit'
|
87
|
+
});
|
88
|
+
let packages = Object.keys(diffs);
|
89
|
+
let dummy = [];
|
90
|
+
|
91
|
+
for (let name of packages) {
|
92
|
+
let version = diffs[name];
|
93
|
+
dummy.push(`${name}@${version}`);
|
94
|
+
}
|
95
|
+
|
96
|
+
(0, _index.log)(`npm ${['install'].concat(dummy).join(' ')}`);
|
97
|
+
(0, _child_process.spawnSync)('npm', ['install'].concat(dummy), {
|
98
|
+
cwd: projPath,
|
99
|
+
stdio: 'inherit'
|
100
|
+
});
|
101
|
+
} else {
|
102
|
+
(0, _child_process.spawnSync)('rm', ['-rf', 'node_modules', 'package-lock.json'], {
|
103
|
+
cwd: projPath,
|
104
|
+
stdio: 'inherit'
|
105
|
+
});
|
106
|
+
(0, _child_process.spawnSync)('npm', ['install'], {
|
107
|
+
cwd: projPath,
|
108
|
+
stdio: 'inherit'
|
109
|
+
});
|
110
|
+
}
|
111
|
+
});
|
112
|
+
});
|
113
|
+
};
|
114
|
+
|
115
|
+
exports.reinstallDependencies1 = reinstallDependencies1;
|
116
|
+
|
117
|
+
let reinstallDependencies = pathToSubProjects => new Promise(resolve => {
|
118
|
+
(0, _gitRootDir.default)(process.cwd()).then(rootDir => {
|
119
|
+
let projects = _fs.default.readdirSync(_path.default.join(rootDir, pathToSubProjects));
|
120
|
+
|
121
|
+
projects.forEach(project => {
|
122
|
+
let projPath = _path.default.join(_path.default.join(rootDir, pathToSubProjects), project);
|
123
|
+
|
124
|
+
(0, _child_process.spawnSync)('npm', ['install'], {
|
125
|
+
cwd: projPath,
|
126
|
+
stdio: 'inherit'
|
127
|
+
});
|
128
|
+
resolve();
|
129
|
+
});
|
130
|
+
});
|
131
|
+
});
|
132
|
+
|
133
|
+
exports.reinstallDependencies = reinstallDependencies;
|
@@ -1,32 +1,34 @@
|
|
1
|
-
|
1
|
+
"use strict";
|
2
2
|
|
3
|
-
var _getOptions = require(
|
4
|
-
|
5
|
-
var _getOptions2 = _interopRequireDefault(_getOptions);
|
3
|
+
var _getOptions = _interopRequireDefault(require("./getOptions"));
|
6
4
|
|
7
5
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
8
6
|
|
9
|
-
|
7
|
+
let options = (0, _getOptions.default)();
|
8
|
+
let {
|
9
|
+
app: {
|
10
|
+
attrbuteNames
|
11
|
+
}
|
12
|
+
} = options;
|
10
13
|
|
11
|
-
|
14
|
+
module.exports = () => ({
|
15
|
+
visitor: {
|
16
|
+
Program(path, state) {
|
17
|
+
let properties = state.opts.properties || [];
|
12
18
|
|
19
|
+
if (properties.length === 0) {
|
20
|
+
properties = properties.concat(attrbuteNames);
|
21
|
+
}
|
13
22
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
var properties = state.opts.properties || [];
|
19
|
-
if (properties.length === 0) {
|
20
|
-
properties = properties.concat(attrbuteNames);
|
21
|
-
}
|
22
|
-
path.traverse({
|
23
|
-
JSXIdentifier: function JSXIdentifier(path2) {
|
24
|
-
if (properties.indexOf(path2.node.name.toLowerCase()) > -1) {
|
25
|
-
path2.parentPath.remove();
|
26
|
-
}
|
23
|
+
path.traverse({
|
24
|
+
JSXIdentifier(path2) {
|
25
|
+
if (properties.indexOf(path2.node.name.toLowerCase()) > -1) {
|
26
|
+
path2.parentPath.remove();
|
27
27
|
}
|
28
|
-
}
|
29
|
-
|
28
|
+
}
|
29
|
+
|
30
|
+
});
|
30
31
|
}
|
31
|
-
|
32
|
-
}
|
32
|
+
|
33
|
+
}
|
34
|
+
});
|