@zohodesk/react-cli 0.0.1-exp.175.1 → 0.0.1-exp.176.2
Sign up to get free protection for your applications and to get access to all the features.
- package/.eslintignore +7 -7
- package/.eslintrc.js +180 -180
- package/.prettierrc +6 -6
- package/README.md +1025 -1028
- package/bin/cli.js +482 -482
- package/cert/Tsicsezwild-22-23.crt +37 -37
- package/cert/Tsicsezwild-22-23.key +27 -27
- package/docs/CustomChunks.md +26 -26
- package/docs/DevStart.md +18 -18
- package/docs/HoverActive.md +12 -12
- package/docs/InstallNode.md +28 -28
- package/docs/SelectorWeight.md +6 -0
- package/docs/TODOS.md +10 -10
- package/docs/ValueReplacer.md +60 -60
- package/docs/VariableConversion.md +719 -678
- package/docs/warnings_while_install.txt +35 -35
- package/files/eslintrc.js +62 -62
- package/files/prettierrc.js +3 -3
- package/lib/babel/cmjs-plugins-presets.js +4 -0
- package/lib/babel/es-plugins-presets.js +4 -0
- package/lib/common/getEntries.js +10 -0
- package/lib/common/getPublicPathConfig.js +6 -0
- package/lib/common/index.js +5 -0
- package/lib/common/splitChunks.js +13 -2
- package/lib/common/sslcertUpdater.js +17 -6
- package/lib/common/templateParameters.js +2 -0
- package/lib/common/testPattern.js +21 -10
- package/lib/common/valueReplacer.js +15 -0
- package/lib/configs/jest.config.js +9 -0
- package/lib/configs/libAlias.js +2 -4
- package/lib/configs/webpack.component.umd.config.js +5 -0
- package/lib/configs/webpack.css.umd.config.js +13 -5
- package/lib/configs/webpack.dev.config.js +36 -2
- package/lib/configs/webpack.docs.config.js +21 -1
- package/lib/configs/webpack.impact.config.js +19 -1
- package/lib/configs/webpack.prod.config.js +37 -3
- package/lib/hooks/docsProptypeHook.js +7 -3
- package/lib/jest/commitedFilesResult.js +45 -3
- package/lib/jest/coverageCollector.js +11 -0
- package/lib/jest/jsonMaker.js +6 -0
- package/lib/jest/preProcessors/cssPreprocessor.js +8 -0
- package/lib/jest/preProcessors/jsPreprocessor.js +2 -0
- package/lib/jest/preProcessors/otherFilesPreprocessor.js +3 -0
- package/lib/jest/result.js +22 -0
- package/lib/jest/run.js +17 -6
- package/lib/jest/setup.js +57 -5
- package/lib/loaderUtils/configsAssetsLoaders.js +44 -34
- package/lib/loaderUtils/getCSSLoaders.js +35 -20
- package/lib/loaderUtils/getDevJsLoaders.js +8 -0
- package/lib/loaderUtils/index.js +3 -0
- package/lib/loaderUtils/windowsModification.js +11 -0
- package/lib/loaders/docsLoader.js +7 -0
- package/lib/loaders/docsPropsLoader.js +7 -3
- package/lib/loaders/fileBountryLoader.js +2 -0
- package/lib/loaders/fileLoader.js +22 -11
- package/lib/loaders/scriptInstrumentLoader.js +13 -5
- package/lib/loaders/selectorMappingLoader.js +25 -7
- package/lib/loaders/workerLoader.js +29 -13
- package/lib/middlewares/HMRMiddleware.js +26 -13
- package/lib/middlewares/SSTMiddleware.js +3 -0
- package/lib/pluginUtils/configHtmlWebpackPlugins.js +9 -3
- package/lib/pluginUtils/getDevPlugins.js +68 -22
- package/lib/pluginUtils/getDocsPlugins.js +10 -1
- package/lib/pluginUtils/getLibraryImactPlugins.js +5 -4
- package/lib/pluginUtils/getLibraryPlugins.js +5 -0
- package/lib/pluginUtils/getProdPlugins.js +77 -28
- package/lib/pluginUtils/getServerPlugins.js +5 -0
- package/lib/pluginUtils/getUMDCSSPlugins.js +7 -0
- package/lib/pluginUtils/getUMDComponentPlugins.js +7 -0
- package/lib/pluginUtils/index.js +8 -0
- package/lib/plugins/CdnChangePlugin.js +14 -0
- package/lib/plugins/CleanupStatsPlugin.js +5 -0
- package/lib/plugins/EFCPlugin.js +34 -23
- package/lib/plugins/EFCPlugin.md +6 -6
- package/lib/plugins/EFCTemplatePlugin.js +32 -23
- package/lib/plugins/I18NInjectIntoIndexPlugin.js +38 -12
- package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +17 -12
- package/lib/plugins/I18nSplitPlugin/I18nDependency.js +10 -4
- package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +77 -46
- package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +59 -44
- package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +30 -21
- package/lib/plugins/I18nSplitPlugin/I18nSplit.md +95 -95
- package/lib/plugins/I18nSplitPlugin/README.md +25 -25
- package/lib/plugins/I18nSplitPlugin/index.js +80 -70
- package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +12 -2
- package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +1 -0
- package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +5 -0
- package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +6 -0
- package/lib/plugins/I18nSplitPlugin/utils/index.js +4 -0
- package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +20 -2
- package/lib/plugins/ManifestPlugin.js +17 -0
- package/lib/plugins/ModuleStatsPlugin.js +23 -0
- package/lib/plugins/OptimizeJSPlugin.js +7 -0
- package/lib/plugins/PublicPathCallbackPlugin.js +10 -0
- package/lib/plugins/PublicPathChangePlugin.js +36 -4
- package/lib/plugins/ReportGeneratePlugin.js +30 -4
- package/lib/plugins/RequireVariablePublicPlugin.js +6 -0
- package/lib/plugins/ResourceHintsPlugin.js +27 -20
- package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +17 -12
- package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +22 -15
- package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -30
- package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +5 -2
- package/lib/plugins/ScriptInstrumentPlugin.js +7 -0
- package/lib/plugins/SelectorPlugin.js +97 -0
- package/lib/plugins/ServiceWorkerPlugin.js +29 -13
- package/lib/plugins/ShadowDOMSupportPlugin.js +40 -3
- package/lib/plugins/SourceMapHookPlugin.js +9 -0
- package/lib/plugins/TPHashMappingPlugin.js +19 -5
- package/lib/plugins/UglifyCSSPlugin.js +9 -0
- package/lib/plugins/UnusedFilesFindPlugin.js +35 -2
- package/lib/plugins/VariableConversionCollector.js +322 -0
- package/lib/plugins/composeCommonPlugin.js +30 -0
- package/lib/plugins/index.js +19 -0
- package/lib/plugins/libraryImpactPlugin.js +32 -0
- package/lib/plugins/webpackwatchrunplugin.js +5 -0
- package/lib/postcss-plugins/ExcludePlugin.js +4 -0
- package/lib/postcss-plugins/RTLSplitPlugin.js +37 -24
- package/lib/postcss-plugins/ValueReplacer.js +6 -9
- package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +3 -0
- package/lib/postcss-plugins/__test__/test1Input.css +38 -38
- package/lib/postcss-plugins/__test__/test1Output.css +38 -38
- package/lib/postcss-plugins/hoverActivePlugin.js +69 -33
- package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +42 -13
- package/lib/postcss-plugins/variableModificationPlugin/index.js +216 -141
- package/lib/postcss-plugins/variableModifier.js +20 -13
- package/lib/schemas/index.js +23 -4
- package/lib/servers/clusterHubServer.js +10 -0
- package/lib/servers/devBuild.js +24 -13
- package/lib/servers/docsServer.js +2 -0
- package/lib/servers/docsServerCore.js +21 -0
- package/lib/servers/getCliPath.js +9 -0
- package/lib/servers/helpServer.js +5 -0
- package/lib/servers/httpsOptions.js +4 -0
- package/lib/servers/impactServer.js +34 -2
- package/lib/servers/mockserver.js +9 -0
- package/lib/servers/nowatchserver.js +34 -12
- package/lib/servers/scrServer.js +20 -13
- package/lib/servers/server.js +35 -7
- package/lib/servers/ssServer.js +16 -0
- package/lib/sh/pre-commit.sh +34 -34
- package/lib/sh/reportPublish.sh +45 -45
- package/lib/templates/CoverageScriptTemplate.js +14 -0
- package/lib/templates/WMSTemplate.js +12 -6
- package/lib/utils/babelPresets.js +2 -0
- package/lib/utils/buildstats.html +148 -148
- package/lib/utils/clean.js +8 -2
- package/lib/utils/copy.js +6 -0
- package/lib/utils/copyTimezones.js +8 -0
- package/lib/utils/createEventStream.js +4 -0
- package/lib/utils/cssClassNameGenerate.js +19 -3
- package/lib/utils/cssURLReplacer.js +25 -0
- package/lib/utils/dependencyPostPublish.js +9 -0
- package/lib/utils/fileUtils.js +26 -0
- package/lib/utils/folderIterator.js +10 -0
- package/lib/utils/getComponents.js +21 -0
- package/lib/utils/getCurrentBranch.js +5 -0
- package/lib/utils/getDependenciesImpactList.js +21 -0
- package/lib/utils/getHash.js +7 -0
- package/lib/utils/getIp.js +2 -0
- package/lib/utils/getOptions.js +39 -14
- package/lib/utils/getServerURL.js +7 -0
- package/lib/utils/index.js +47 -2
- package/lib/utils/init.js +1 -0
- package/lib/utils/initPreCommitHook.js +29 -6
- package/lib/utils/jsonHelper.js +19 -2
- package/lib/utils/libraryImpactConfig.js +2 -0
- package/lib/utils/lint/addScripts.js +5 -2
- package/lib/utils/lint/checkExistingConfig.js +12 -3
- package/lib/utils/lint/copyConfigs.js +3 -0
- package/lib/utils/lint/index.js +9 -0
- package/lib/utils/lint/lintScripts.js +1 -0
- package/lib/utils/lint/lintSetup.js +4 -3
- package/lib/utils/lint/lintStagedPreCommitHook.js +1 -0
- package/lib/utils/lint/question.js +7 -0
- package/lib/utils/lintReporter.js +20 -0
- package/lib/utils/mailSender.js +7 -0
- package/lib/utils/pullOrigin.js +4 -0
- package/lib/utils/reinstallDependencies.js +28 -0
- package/lib/utils/removeAttributes.js +7 -0
- package/lib/utils/repoClone.js +27 -2
- package/lib/utils/request.js +12 -0
- package/lib/utils/resultSchema.json +73 -73
- package/lib/utils/rtl.js +16 -4
- package/lib/utils/setEnvVariables.js +2 -0
- package/lib/utils/ssTestHack.js +10 -0
- package/lib/utils/switchBranch.js +4 -0
- package/lib/utils/urlConcat.js +4 -0
- package/lib/utils/useExitCleanup.js +10 -9
- package/npm8.md +9 -9
- package/package.json +146 -146
- package/postpublish.js +6 -6
- 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/impactReportTemplate.html +154 -154
- package/templates/docs/index.html +1501 -1501
- package/templates/docs/js/active-line.js +72 -72
- package/templates/docs/js/b.min.js +7 -7
- package/templates/docs/js/codemirror.js +9680 -9680
- package/templates/docs/js/designTokens.js +334 -334
- package/templates/docs/js/j.min.js +4 -4
- package/templates/docs/js/javascript.js +874 -874
- package/templates/docs/js/matchbrackets.js +145 -145
@@ -0,0 +1,322 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
|
8
|
+
var _postcss = _interopRequireDefault(require("postcss"));
|
9
|
+
|
10
|
+
var _ErrorHandler = require("../postcss-plugins/variableModificationPlugin/ErrorHandler");
|
11
|
+
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
|
+
|
14
|
+
// import { RawSource } from 'webpack-sources';
|
15
|
+
const fs = require('fs');
|
16
|
+
|
17
|
+
const ignoreVals = ['--zd_size', '--zd_font_size', '--size', '--size_'];
|
18
|
+
|
19
|
+
const {
|
20
|
+
errors,
|
21
|
+
errTable,
|
22
|
+
errHandler
|
23
|
+
} = require('../postcss-plugins/variableModificationPlugin/index');
|
24
|
+
|
25
|
+
const supportedProps = ['font-size', 'margin', 'margin-top', 'margin-bottom', 'margin-left', 'margin-right', 'padding', 'padding-top', 'padding-bottom', 'padding-left', 'padding-right', '^top', '^right', '^bottom', '^left', '^width', 'min-width', 'max-width', '^height', 'min-height', 'max-height', 'text-indent', 'clip', 'flex-basis', 'row-gap', 'gap', 'column-gap', 'flex']; // const avoidProps = [];
|
26
|
+
// -- is issue IO --
|
27
|
+
|
28
|
+
/*
|
29
|
+
issues eg :
|
30
|
+
issues = ['--zd_size', '--zd_font_size', '--size', '--size_'];
|
31
|
+
input :
|
32
|
+
--zd_size
|
33
|
+
output :
|
34
|
+
true
|
35
|
+
comment :
|
36
|
+
do not execute when --zd_size comes as prop
|
37
|
+
*/
|
38
|
+
|
39
|
+
function isIgnoreValuePresent(ignoreVals, prop) {
|
40
|
+
let present = false;
|
41
|
+
ignoreVals.forEach(issue => {
|
42
|
+
if (prop && prop.includes(issue)) {
|
43
|
+
present = true;
|
44
|
+
}
|
45
|
+
});
|
46
|
+
return present;
|
47
|
+
} // -- to convert the hyphen values to values --
|
48
|
+
|
49
|
+
/*
|
50
|
+
input :
|
51
|
+
var(--zdt_uploadlist_default_width)
|
52
|
+
output :
|
53
|
+
--zdt_uploadlist_default_width
|
54
|
+
|
55
|
+
comment :
|
56
|
+
to make the variable object using the output as key and decl.prop such as font-size as value
|
57
|
+
*/
|
58
|
+
|
59
|
+
|
60
|
+
function extractVariableName(val) {
|
61
|
+
return val.replace(/calc\((.+)\)/gi, '$1').replace(/var\((.+)\)/gi, '$1').replace('-1', '').replace('*', '').replace('\n', '').trim();
|
62
|
+
}
|
63
|
+
|
64
|
+
function rootConvertor(rootOriginal, variables, settingsObject) {
|
65
|
+
rootOriginal.walkRules(rule => {
|
66
|
+
rule.nodes.forEach((decl, index) => {
|
67
|
+
let prevNode = rule.nodes[index - 1];
|
68
|
+
let currentNode = rule.nodes[index];
|
69
|
+
|
70
|
+
if (decl.prop && decl.prop.includes('--')) {
|
71
|
+
if (prevNode && prevNode.type === 'comment' && prevNode.text.toLowerCase() === 'variable:ignore') {
|
72
|
+
return;
|
73
|
+
}
|
74
|
+
|
75
|
+
if (isIgnoreValuePresent(ignoreVals, decl.prop)) {
|
76
|
+
return;
|
77
|
+
}
|
78
|
+
|
79
|
+
if (settingsObject[variables[decl.prop]]) {
|
80
|
+
/* if there is no value for property, set it to default so that undefined doesn't get called as key */
|
81
|
+
if (!variables[decl.prop]) {
|
82
|
+
variables[decl.prop] = 'default';
|
83
|
+
}
|
84
|
+
|
85
|
+
const pxReplacement = settingsObject[variables[decl.prop]].replacements.px;
|
86
|
+
let valArr = decl.value.split(' '); // single values are considered in the above array and converted below
|
87
|
+
|
88
|
+
valArr.forEach((value, index) => {
|
89
|
+
if (value.includes('px')) {
|
90
|
+
let num = value.replace('px', '');
|
91
|
+
valArr[index] = pxReplacement.replace('$$', num);
|
92
|
+
}
|
93
|
+
});
|
94
|
+
currentNode.value = valArr.join(' ');
|
95
|
+
}
|
96
|
+
}
|
97
|
+
});
|
98
|
+
});
|
99
|
+
return rootOriginal;
|
100
|
+
}
|
101
|
+
|
102
|
+
class VariableConversionCollector {
|
103
|
+
constructor(options = {}) {
|
104
|
+
this.optimize = options.optimize;
|
105
|
+
this.filename = options.cssVariableReplacementConfig;
|
106
|
+
}
|
107
|
+
|
108
|
+
apply(compiler) {
|
109
|
+
const variables = {};
|
110
|
+
const unassigned = {};
|
111
|
+
const rawdata = fs.readFileSync(this.filename);
|
112
|
+
const data = JSON.parse(rawdata);
|
113
|
+
const {
|
114
|
+
settings: settingsObject,
|
115
|
+
errorLog: errorLogStatus,
|
116
|
+
errorInConsole: errorConsoleStatus,
|
117
|
+
errorsAllowed
|
118
|
+
} = data; // If theres is no setting for default prop in settingsObject, set one.
|
119
|
+
|
120
|
+
if (!settingsObject.default) {
|
121
|
+
settingsObject.default = {
|
122
|
+
allowed: ['px', 'em', 'fit-content', 'auto', '%', 'inherit', '-moz-fit-content', 'vh', '0', 'initial', 'vw'],
|
123
|
+
replacements: {
|
124
|
+
px: 'var(--zd_size$$)'
|
125
|
+
},
|
126
|
+
range: {
|
127
|
+
start: -99999,
|
128
|
+
end: 99999
|
129
|
+
}
|
130
|
+
};
|
131
|
+
}
|
132
|
+
/*
|
133
|
+
purpose of tap : to create a variable object such as:
|
134
|
+
{
|
135
|
+
--zdt_uploadlist_default_width : width,
|
136
|
+
--zdt_uploadlist_default_height : height,
|
137
|
+
}
|
138
|
+
which will help in the conversion further
|
139
|
+
*/
|
140
|
+
|
141
|
+
|
142
|
+
if (fs.existsSync('./variableMapping.json')) {
|
143
|
+
const data = JSON.parse(fs.readFileSync('./variableMapping.json', 'utf-8'));
|
144
|
+
Object.keys(data).forEach(key => {
|
145
|
+
variables[key] = data[key];
|
146
|
+
});
|
147
|
+
}
|
148
|
+
|
149
|
+
compiler.hooks.compilation.tap('VariableConversionCollector', compilation => {
|
150
|
+
compilation.hooks.optimizeModules.tap('VariableConversionCollector', modules => {
|
151
|
+
const mods = modules.filter(x => x.type.includes('css'));
|
152
|
+
mods.forEach(module => {
|
153
|
+
const rootOriginal = _postcss.default.parse(module.content);
|
154
|
+
|
155
|
+
const filename = module.issuer.resource;
|
156
|
+
|
157
|
+
if (!filename.includes('node_modules')) {
|
158
|
+
rootOriginal.walkRules(rule => {
|
159
|
+
rule.walkDecls(decl => {
|
160
|
+
decl.value.split(' ').forEach(val => {
|
161
|
+
if (val && val.includes('--') && !new RegExp(ignoreVals.join('|'), 'gi').test(val) && decl.prop) {
|
162
|
+
const extractedValue = extractVariableName(val);
|
163
|
+
|
164
|
+
if (!variables[extractedValue]) {
|
165
|
+
variables[extractedValue] = decl.prop;
|
166
|
+
} else {
|
167
|
+
if (new RegExp(supportedProps.join('|'), 'gi').test(decl.prop)) {
|
168
|
+
// console.log(
|
169
|
+
// `${extractedValue} : ${variables[extractedValue]} already exists please check!`
|
170
|
+
// );
|
171
|
+
if (errorsAllowed.MULTIPLE_OCCURANCES) {
|
172
|
+
let errObj = {
|
173
|
+
decl,
|
174
|
+
type: 'MULTIPLE_OCCURANCES',
|
175
|
+
filename,
|
176
|
+
message: `${extractedValue} : ${variables[extractedValue]} already exists please check!`
|
177
|
+
};
|
178
|
+
errHandler.errorTable.push(errObj);
|
179
|
+
errHandler.errorFunction(errObj);
|
180
|
+
}
|
181
|
+
}
|
182
|
+
}
|
183
|
+
} else {
|
184
|
+
// console.log(decl.prop);
|
185
|
+
if (/^--/gi.test(decl.prop) && new RegExp(supportedProps.join('|'), 'gi').test(decl.prop) && val.trim() !== '' && !variables[decl.prop]) {
|
186
|
+
// console.log(
|
187
|
+
// `${decl.prop} : ${variables[decl.prop]},`
|
188
|
+
// );
|
189
|
+
unassigned[decl.prop] = variables[decl.prop];
|
190
|
+
}
|
191
|
+
}
|
192
|
+
});
|
193
|
+
});
|
194
|
+
});
|
195
|
+
/*
|
196
|
+
current value example:
|
197
|
+
{
|
198
|
+
--zdt_uploadlist_default_width : --zd_upload_width,
|
199
|
+
--zd_upload_width : width
|
200
|
+
}
|
201
|
+
expected value :
|
202
|
+
{
|
203
|
+
--zdt_uploadlist_default_width : width,
|
204
|
+
--zd_upload_width : width
|
205
|
+
}
|
206
|
+
|
207
|
+
conversion is done in the while loop below
|
208
|
+
*/
|
209
|
+
|
210
|
+
Object.keys(variables).forEach(key => {
|
211
|
+
while (variables[variables[key]]) {
|
212
|
+
variables[key] = variables[variables[key]];
|
213
|
+
}
|
214
|
+
});
|
215
|
+
}
|
216
|
+
});
|
217
|
+
}); // -- conversion for the root using rootConvertor --
|
218
|
+
|
219
|
+
/*
|
220
|
+
input :
|
221
|
+
.a{
|
222
|
+
padding : 20px
|
223
|
+
}
|
224
|
+
output :
|
225
|
+
// on settingObject file :
|
226
|
+
{ padding : { replacements : { px : 'zd_size$$' }}}
|
227
|
+
.a{
|
228
|
+
padding : zd_size20;
|
229
|
+
}
|
230
|
+
*/
|
231
|
+
|
232
|
+
compilation.hooks.optimizeModules.tap('VariableConversionCollector', modules => {
|
233
|
+
const mods = modules.filter(x => x.type.includes('css'));
|
234
|
+
mods.forEach(module => {
|
235
|
+
const rootOriginal = _postcss.default.parse(module.content);
|
236
|
+
|
237
|
+
module.content = rootConvertor(rootOriginal, variables, settingsObject).toString();
|
238
|
+
});
|
239
|
+
});
|
240
|
+
});
|
241
|
+
/*
|
242
|
+
purpose of tap : to display the errors encountered so far
|
243
|
+
input :
|
244
|
+
all css files
|
245
|
+
output :
|
246
|
+
all errors that are present in the errTable arr
|
247
|
+
*/
|
248
|
+
|
249
|
+
compiler.hooks.afterEmit.tap('error-display', () => {
|
250
|
+
if (Object.keys(unassigned).length > 0) {
|
251
|
+
console.log();
|
252
|
+
console.log(unassigned);
|
253
|
+
console.log();
|
254
|
+
throw new Error('^^^ Variables above have not been assigned! ^^^');
|
255
|
+
}
|
256
|
+
|
257
|
+
let avlTypes = new Set([]);
|
258
|
+
let srtArr = errTable.sort((a, b) => {
|
259
|
+
avlTypes.add(a.type);
|
260
|
+
avlTypes.add(b.type);
|
261
|
+
|
262
|
+
if (a.type < b.type) {
|
263
|
+
return -1;
|
264
|
+
}
|
265
|
+
}); // variable constructed now to be written in a json file
|
266
|
+
// const newVars = Object.keys(variables)
|
267
|
+
// //Filter Object with key contanis "NAME"
|
268
|
+
// .filter(key => variables[key].includes('--'))
|
269
|
+
// .reduce(
|
270
|
+
// (obj, key) =>
|
271
|
+
// Object.assign(obj, {
|
272
|
+
// [key]: variables[key]
|
273
|
+
// }),
|
274
|
+
// {}
|
275
|
+
// );
|
276
|
+
// console.log('new variables: ', newVars);
|
277
|
+
// try {
|
278
|
+
// fs.writeFileSync('./variableMapping.json', JSON.stringify(variables));
|
279
|
+
// } catch (err) {
|
280
|
+
// console.log(err);
|
281
|
+
// }
|
282
|
+
// fs.writeFile('./variableMapping.json', JSON.stringify(variables), err => {
|
283
|
+
// if (err) {
|
284
|
+
// throw err;
|
285
|
+
// }
|
286
|
+
// console.log('variable mapping file generated.');
|
287
|
+
// });
|
288
|
+
|
289
|
+
if (errorConsoleStatus) {
|
290
|
+
const errorHandler = new _ErrorHandler.ErrorHandler();
|
291
|
+
avlTypes.forEach(type => {
|
292
|
+
console.log('---------------------------------------------------------------------------------------------------------------------------');
|
293
|
+
console.log(`Error Type : ${type}`);
|
294
|
+
console.log('---------------------------------------------------------------------------------------------------------------------------');
|
295
|
+
srtArr.forEach(err => {
|
296
|
+
if (err.decl.prop && err.decl.value && err.type === type) {
|
297
|
+
errorHandler.printError(err);
|
298
|
+
}
|
299
|
+
});
|
300
|
+
console.log('---------------------------------------------------------------------------------------------------------------------------');
|
301
|
+
});
|
302
|
+
}
|
303
|
+
|
304
|
+
if (errorLogStatus) {
|
305
|
+
fs.writeFileSync('./css_error.log', '');
|
306
|
+
console.log('writing to logFile...');
|
307
|
+
|
308
|
+
if (errors.length > 0) {
|
309
|
+
errors.forEach((err, index) => {
|
310
|
+
if (errTable[index].decl.prop && errTable[index].decl.value) {
|
311
|
+
fs.appendFileSync('./css_error.log', err);
|
312
|
+
}
|
313
|
+
});
|
314
|
+
}
|
315
|
+
}
|
316
|
+
});
|
317
|
+
}
|
318
|
+
|
319
|
+
}
|
320
|
+
|
321
|
+
var _default = VariableConversionCollector;
|
322
|
+
exports.default = _default;
|
@@ -0,0 +1,30 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
|
8
|
+
var _postcss = _interopRequireDefault(require("postcss"));
|
9
|
+
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
11
|
+
|
12
|
+
class ComposeCommonPlugin {
|
13
|
+
constructor(options = {}) {
|
14
|
+
this.optimize = options.optimize;
|
15
|
+
}
|
16
|
+
|
17
|
+
apply(compiler) {
|
18
|
+
compiler.hooks.compilation.tap('OptimizeJSPlugin', compilation => {
|
19
|
+
compilation.hooks.optimizeModules.tap('OptimizeMods', modules => {
|
20
|
+
modules.forEach(module => {
|
21
|
+
console.log(module);
|
22
|
+
});
|
23
|
+
});
|
24
|
+
});
|
25
|
+
}
|
26
|
+
|
27
|
+
}
|
28
|
+
|
29
|
+
var _default = ComposeCommonPlugin;
|
30
|
+
exports.default = _default;
|
package/lib/plugins/index.js
CHANGED
@@ -111,22 +111,41 @@ Object.defineProperty(exports, "UnusedFilesFindPlugin", {
|
|
111
111
|
return _UnusedFilesFindPlugin.default;
|
112
112
|
}
|
113
113
|
});
|
114
|
+
|
114
115
|
var _ModuleStatsPlugin = _interopRequireDefault(require("./ModuleStatsPlugin"));
|
116
|
+
|
115
117
|
var _SourceMapHookPlugin = _interopRequireDefault(require("./SourceMapHookPlugin"));
|
118
|
+
|
116
119
|
var _UnusedFilesFindPlugin = _interopRequireDefault(require("./UnusedFilesFindPlugin"));
|
120
|
+
|
117
121
|
var _ScriptInstrumentPlugin = _interopRequireDefault(require("./ScriptInstrumentPlugin"));
|
122
|
+
|
118
123
|
var _PublicPathChangePlugin = _interopRequireDefault(require("./PublicPathChangePlugin"));
|
124
|
+
|
119
125
|
var _OptimizeJSPlugin = _interopRequireDefault(require("./OptimizeJSPlugin"));
|
126
|
+
|
120
127
|
var _ResourceHintsPlugin = _interopRequireDefault(require("./ResourceHintsPlugin"));
|
128
|
+
|
121
129
|
var _UglifyCSSPlugin = _interopRequireDefault(require("./UglifyCSSPlugin"));
|
130
|
+
|
122
131
|
var _ManifestPlugin = _interopRequireDefault(require("./ManifestPlugin"));
|
132
|
+
|
123
133
|
var _CleanupStatsPlugin = _interopRequireDefault(require("./CleanupStatsPlugin"));
|
134
|
+
|
124
135
|
var _EFCPlugin = _interopRequireDefault(require("./EFCPlugin"));
|
136
|
+
|
125
137
|
var _PublicPathCallbackPlugin = _interopRequireDefault(require("./PublicPathCallbackPlugin"));
|
138
|
+
|
126
139
|
var _I18NInjectIntoIndexPlugin = _interopRequireDefault(require("./I18NInjectIntoIndexPlugin"));
|
140
|
+
|
127
141
|
var _ReportGeneratePlugin = _interopRequireDefault(require("./ReportGeneratePlugin"));
|
142
|
+
|
128
143
|
var _ShadowDOMSupportPlugin = _interopRequireDefault(require("./ShadowDOMSupportPlugin"));
|
144
|
+
|
129
145
|
var _ServiceWorkerPlugin = _interopRequireDefault(require("./ServiceWorkerPlugin"));
|
146
|
+
|
130
147
|
var _TPHashMappingPlugin = _interopRequireDefault(require("./TPHashMappingPlugin"));
|
148
|
+
|
131
149
|
var _CdnChangePlugin = _interopRequireDefault(require("./CdnChangePlugin"));
|
150
|
+
|
132
151
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
@@ -4,12 +4,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.default = void 0;
|
7
|
+
|
7
8
|
var _path = _interopRequireDefault(require("path"));
|
9
|
+
|
8
10
|
var _fs = _interopRequireDefault(require("fs"));
|
11
|
+
|
9
12
|
var _webpackSources = require("webpack-sources");
|
13
|
+
|
10
14
|
var _jsonHelper = require("../utils/jsonHelper");
|
15
|
+
|
11
16
|
var _utils = require("../utils");
|
17
|
+
|
12
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
19
|
+
|
13
20
|
let resultFileName = `${process.cwd()}/result.json`;
|
14
21
|
let options = (0, _utils.getOptions)();
|
15
22
|
let {
|
@@ -24,21 +31,27 @@ let {
|
|
24
31
|
(0, _jsonHelper.jsonHelper)(resultFileName, 'tests.libraryImpactOnSource.compareBranch', referBranch);
|
25
32
|
(0, _jsonHelper.jsonHelper)(resultFileName, 'tests.libraryImpactOnSource.TestBranch', currentBranch);
|
26
33
|
(0, _jsonHelper.jsonHelper)(resultFileName, 'tests.libraryImpactOnSource.isExecuted', true);
|
34
|
+
|
27
35
|
let isValidModule = name => {
|
28
36
|
if (name.includes('node_modules') && (name.includes(`@zohodesk${_path.default.sep}components`) || name.includes(`@zohodesk${_path.default.sep}dot`) || name.includes(`@zohodesk${_path.default.sep}icons`) || name.includes(`@zohodesk${_path.default.sep}svg`)) && !name.endsWith('docs.js')) {
|
29
37
|
return true;
|
30
38
|
}
|
39
|
+
|
31
40
|
return !name.includes('index.js') && !name.endsWith('.css') && !name.endsWith('.png') && !name.includes('node_modules') && name.includes('src');
|
32
41
|
};
|
42
|
+
|
33
43
|
let getModuleName = modulePath => {
|
34
44
|
let [name] = _path.default.parse(modulePath).name.split('.');
|
45
|
+
|
35
46
|
if (modulePath.includes(`@zohodesk${_path.default.sep}components`)) {
|
36
47
|
name = `@zohodesk/components/${name}`;
|
37
48
|
} else if (modulePath.includes(`@zohodesk${_path.default.sep}dot`)) {
|
38
49
|
name = `@zohodesk/dot/${name}`;
|
39
50
|
}
|
51
|
+
|
40
52
|
return name;
|
41
53
|
};
|
54
|
+
|
42
55
|
class LibraryImpactPlugin {
|
43
56
|
constructor(options = {}) {
|
44
57
|
this.options = options;
|
@@ -47,10 +60,12 @@ class LibraryImpactPlugin {
|
|
47
60
|
this.bottomHtml = '</div> <script type="text/javascript"> const details = document.querySelectorAll("details"); details.forEach((targetDetail) => { targetDetail.addEventListener("click", () => { // Close all the details that are not targetDetail. details.forEach((detail) => { if (detail !== targetDetail) { detail.removeAttribute("open"); } }); }); }); </script></body></html>';
|
48
61
|
this.resultJson = {};
|
49
62
|
}
|
63
|
+
|
50
64
|
apply(compiler) {
|
51
65
|
let loggedInfo = false;
|
52
66
|
compiler.hooks.beforeCompile.tap('LibraryImpactPlugin', () => {
|
53
67
|
(0, _jsonHelper.jsonHelper)(resultFileName, 'tests.libraryImpactOnSource.startTime', Date.now());
|
68
|
+
|
54
69
|
if (!loggedInfo) {
|
55
70
|
(0, _utils.log)('\x1b[33m%s\x1b[0m', '************************************************************ \n ');
|
56
71
|
(0, _utils.log)('\x1b[5m\x1b[44m%s\x1b[0m', 'Finding Impacted Source Files Please Wait ...');
|
@@ -63,11 +78,13 @@ class LibraryImpactPlugin {
|
|
63
78
|
let {
|
64
79
|
modules
|
65
80
|
} = stats;
|
81
|
+
|
66
82
|
for (let module of modules) {
|
67
83
|
let {
|
68
84
|
name,
|
69
85
|
reasons
|
70
86
|
} = module;
|
87
|
+
|
71
88
|
if (isValidModule(name)) {
|
72
89
|
let references = new Set();
|
73
90
|
let referencedby = new Set();
|
@@ -76,6 +93,7 @@ class LibraryImpactPlugin {
|
|
76
93
|
compilation.modules.forEach(module => {
|
77
94
|
module.reasons.forEach(reason => {
|
78
95
|
let exportedValue = reason.dependency;
|
96
|
+
|
79
97
|
if (exportedValue.type === 'harmony export imported specifier') {
|
80
98
|
if (exportedValue.module.userRequest.includes(name.replace('.', ''))) {
|
81
99
|
docsName = exportedValue.name;
|
@@ -84,29 +102,35 @@ class LibraryImpactPlugin {
|
|
84
102
|
});
|
85
103
|
});
|
86
104
|
let currentModuleName = name;
|
105
|
+
|
87
106
|
if (Array.isArray(reasons)) {
|
88
107
|
for (let reason of reasons) {
|
89
108
|
let {
|
90
109
|
moduleName
|
91
110
|
} = reason;
|
111
|
+
|
92
112
|
if (isValidModule(moduleName)) {
|
93
113
|
let reasonedModuleName = moduleName;
|
94
114
|
referencedby.add(reasonedModuleName);
|
95
115
|
}
|
96
116
|
}
|
97
117
|
}
|
118
|
+
|
98
119
|
for (let subModule of modules) {
|
99
120
|
let {
|
100
121
|
name: subModuleName,
|
101
122
|
reasons
|
102
123
|
} = subModule;
|
124
|
+
|
103
125
|
if (isValidModule(subModuleName)) {
|
104
126
|
let currentModuleName = subModuleName;
|
127
|
+
|
105
128
|
if (Array.isArray(reasons)) {
|
106
129
|
for (let reason of reasons) {
|
107
130
|
let {
|
108
131
|
moduleName: reasonedModuleName
|
109
132
|
} = reason;
|
133
|
+
|
110
134
|
if (name === reasonedModuleName) {
|
111
135
|
references.add(currentModuleName);
|
112
136
|
}
|
@@ -114,6 +138,7 @@ class LibraryImpactPlugin {
|
|
114
138
|
}
|
115
139
|
}
|
116
140
|
}
|
141
|
+
|
117
142
|
results[currentModuleName] = {
|
118
143
|
name: currentModuleName,
|
119
144
|
references: Array.from(references),
|
@@ -123,9 +148,11 @@ class LibraryImpactPlugin {
|
|
123
148
|
};
|
124
149
|
}
|
125
150
|
}
|
151
|
+
|
126
152
|
(0, _utils.getDependenciesImpactList)(currentBranch, referBranch, tokenGit, serviceName).then(impactedList => {
|
127
153
|
this.resultJson = (0, _utils.getLibraryConflict)(JSON.stringify(results), impactedList, changesOnly);
|
128
154
|
(0, _jsonHelper.jsonHelper)(resultFileName, 'tests.libraryImpactOnSource.result', this.resultJson);
|
155
|
+
|
129
156
|
if (this.resultJson.result.status) {
|
130
157
|
(0, _utils.log)(this.resultJson.response);
|
131
158
|
this.resultJson.response.forEach(fileObject => {
|
@@ -140,12 +167,15 @@ class LibraryImpactPlugin {
|
|
140
167
|
(0, _utils.log)(this.resultJson.result.message);
|
141
168
|
this.topHtml = this.topHtml + '<div style="font-size: xxx-large; text-align: center; padding-top: 50px;"> ' + this.resultJson.result.message + '</div>';
|
142
169
|
}
|
170
|
+
|
143
171
|
if (!_fs.default.existsSync('./coverageTest')) {
|
144
172
|
_fs.default.mkdirSync('./coverageTest');
|
173
|
+
|
145
174
|
_fs.default.writeFileSync('./coverageTest/impactLibrary.html', this.topHtml + this.bottomHtml, 'utf8');
|
146
175
|
} else {
|
147
176
|
_fs.default.writeFileSync('./coverageTest/impactLibrary.html', this.topHtml + this.bottomHtml, 'utf8');
|
148
177
|
}
|
178
|
+
|
149
179
|
(0, _jsonHelper.jsonHelper)(resultFileName, 'tests.libraryImpactOnSource.endTime', Date.now());
|
150
180
|
});
|
151
181
|
});
|
@@ -154,5 +184,7 @@ class LibraryImpactPlugin {
|
|
154
184
|
(0, _utils.log)('Compilation finished!!!');
|
155
185
|
});
|
156
186
|
}
|
187
|
+
|
157
188
|
}
|
189
|
+
|
158
190
|
exports.default = LibraryImpactPlugin;
|
@@ -4,12 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.default = void 0;
|
7
|
+
|
7
8
|
var _utils = require("../utils");
|
9
|
+
|
8
10
|
class WebpackWatchRunPlugin {
|
9
11
|
apply(compiler) {
|
10
12
|
compiler.hooks.watchRun.tap('WatchRun', comp => {
|
11
13
|
const changedTimes = comp.watchFileSystem.watcher.mtimes;
|
12
14
|
const changedFiles = Object.keys(changedTimes).map(file => `\n ${file}`).join('');
|
15
|
+
|
13
16
|
if (changedFiles.length) {
|
14
17
|
(0, _utils.log)('====================================');
|
15
18
|
(0, _utils.log)('NEW BUILD FILES CHANGED:', changedFiles);
|
@@ -17,5 +20,7 @@ class WebpackWatchRunPlugin {
|
|
17
20
|
}
|
18
21
|
});
|
19
22
|
}
|
23
|
+
|
20
24
|
}
|
25
|
+
|
21
26
|
exports.default = WebpackWatchRunPlugin;
|
@@ -1,7 +1,9 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _postcss = _interopRequireDefault(require("postcss"));
|
4
|
+
|
4
5
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
6
|
+
|
5
7
|
module.exports = _postcss.default.plugin('postcss-exclude-files', opts => {
|
6
8
|
const {
|
7
9
|
plugins
|
@@ -9,8 +11,10 @@ module.exports = _postcss.default.plugin('postcss-exclude-files', opts => {
|
|
9
11
|
return (root, result) => {
|
10
12
|
const inputFile = root.source.input.file;
|
11
13
|
let isIgnoredFile = opts.ignore.some(file => inputFile.indexOf(file) !== -1);
|
14
|
+
|
12
15
|
if (!isIgnoredFile) {
|
13
16
|
const handler = response => response.messages.forEach(msg => result.messages.push(msg));
|
17
|
+
|
14
18
|
return (0, _postcss.default)(plugins).process(root, {
|
15
19
|
from: undefined
|
16
20
|
}).then(handler);
|