@zohodesk/react-cli 0.0.1-exp.175.1 → 0.0.1-exp.176.11
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/README.md +35 -40
- package/docs/SelectorWeight.md +6 -0
- package/docs/VariableConversion.md +33 -1
- 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 +11 -1
- 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 +20 -4
- 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 +63 -17
- 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 +72 -23
- 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/EFCTemplatePlugin.js +32 -23
- package/lib/plugins/I18NInjectIntoIndexPlugin.js +34 -8
- package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +17 -12
- package/lib/plugins/I18nSplitPlugin/I18nDependency.js +10 -4
- package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +39 -8
- package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +29 -14
- package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +22 -13
- package/lib/plugins/I18nSplitPlugin/index.js +23 -13
- 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 +10 -3
- package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +17 -12
- package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +16 -9
- 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 +20 -4
- package/lib/plugins/ShadowDOMSupportPlugin.js +40 -3
- package/lib/plugins/SourceMapHookPlugin.js +9 -0
- package/lib/plugins/TPHashMappingPlugin.js +15 -1
- package/lib/plugins/UglifyCSSPlugin.js +9 -0
- package/lib/plugins/UnusedFilesFindPlugin.js +35 -2
- package/lib/plugins/VariableConversionCollector.js +252 -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 +27 -14
- package/lib/postcss-plugins/ValueReplacer.js +6 -9
- package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +3 -0
- package/lib/postcss-plugins/hoverActivePlugin.js +66 -30
- package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +40 -13
- package/lib/postcss-plugins/variableModificationPlugin/index.js +215 -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/templates/CoverageScriptTemplate.js +14 -0
- package/lib/templates/WMSTemplate.js +12 -6
- package/lib/utils/babelPresets.js +2 -0
- 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 +50 -38
- 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/getFileType.js +49 -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/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/package.json +10 -9
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
const postcss = require('postcss');
|
|
4
|
+
|
|
4
5
|
const fs = require('fs');
|
|
6
|
+
|
|
5
7
|
const path = require('path');
|
|
8
|
+
|
|
9
|
+
const {
|
|
10
|
+
ErrorHandler
|
|
11
|
+
} = require('./ErrorHandler');
|
|
12
|
+
|
|
6
13
|
const errors = [];
|
|
7
|
-
|
|
14
|
+
const errorTable = [];
|
|
15
|
+
const errHandler = new ErrorHandler();
|
|
8
16
|
const convertableProps = {
|
|
9
17
|
'font-size': true,
|
|
10
18
|
margin: true,
|
|
@@ -26,37 +34,58 @@ const convertableProps = {
|
|
|
26
34
|
top: true,
|
|
27
35
|
bottom: true,
|
|
28
36
|
left: true,
|
|
29
|
-
right: true
|
|
37
|
+
right: true,
|
|
38
|
+
'text-indent': true,
|
|
39
|
+
clip: true,
|
|
40
|
+
'flex-basis': true,
|
|
41
|
+
'row-gap': true,
|
|
42
|
+
gap: true,
|
|
43
|
+
'column-gap': true,
|
|
44
|
+
flex: true
|
|
30
45
|
};
|
|
31
46
|
const constantValues = {
|
|
32
47
|
inherit: true,
|
|
33
48
|
initial: true,
|
|
34
49
|
auto: true,
|
|
35
50
|
'fit-content': true,
|
|
36
|
-
unset: true
|
|
51
|
+
unset: true,
|
|
52
|
+
cover: true,
|
|
53
|
+
contain: true,
|
|
54
|
+
top: true,
|
|
55
|
+
bottom: true,
|
|
56
|
+
left: true,
|
|
57
|
+
center: true,
|
|
58
|
+
right: true
|
|
37
59
|
};
|
|
60
|
+
|
|
38
61
|
function getNumericValue(value) {
|
|
39
62
|
if (value.includes('var')) {
|
|
40
63
|
return parseInt(value.replace(/var\(--zd_size(\d+)\)/gi, '$1').replace(/var\(--zd_font_size(\d+)\)/gi, '$1'));
|
|
41
64
|
}
|
|
42
65
|
|
|
43
|
-
|
|
66
|
+
if (value.includes('rect')) {
|
|
67
|
+
return parseInt(value.replace('rect(', '').replace(')', '').replace(',', ''));
|
|
68
|
+
} // Not need for this dum loop
|
|
44
69
|
// allowed.forEach(alwdUnit => {
|
|
45
70
|
// if (value.includes(alwdUnit)) {
|
|
46
71
|
// return parseInt(value);
|
|
47
72
|
// }
|
|
48
73
|
// });
|
|
49
74
|
|
|
75
|
+
|
|
50
76
|
if (constantValues[value.toLowerCase()]) {
|
|
51
77
|
return 1;
|
|
52
78
|
}
|
|
79
|
+
|
|
53
80
|
return parseInt(value);
|
|
54
81
|
}
|
|
82
|
+
|
|
55
83
|
function pxToCalc(value) {
|
|
56
84
|
const arr = value.split(' ');
|
|
57
85
|
arr.forEach((val, index) => {
|
|
58
86
|
['px'].forEach(unit => {
|
|
59
87
|
const valWithUnit = new RegExp(`(\\d+)${unit}`, 'gi');
|
|
88
|
+
|
|
60
89
|
if (valWithUnit.test(val)) {
|
|
61
90
|
arr[index] = val.replace(valWithUnit, '(var(--zd_size$1))');
|
|
62
91
|
}
|
|
@@ -64,169 +93,214 @@ function pxToCalc(value) {
|
|
|
64
93
|
});
|
|
65
94
|
return arr.join(' ');
|
|
66
95
|
}
|
|
67
|
-
|
|
68
|
-
errors.push(`{\n${errstr}\n}\n`);
|
|
69
|
-
};
|
|
70
|
-
const errorFunction = (errStr, type) => {
|
|
71
|
-
if (type === 'DECLARATION_IGNORED' && allowedErrs.DECLARATION_IGNORED) {
|
|
72
|
-
addError(errStr);
|
|
73
|
-
} else if (type === 'UNIT_ERROR' && allowedErrs.UNIT_ERROR) {
|
|
74
|
-
addError(errStr);
|
|
75
|
-
} else if (type === 'RANGE_ERROR' && allowedErrs.RANGE_ERROR) {
|
|
76
|
-
addError(errStr);
|
|
77
|
-
} else if (type === 'VARIABLE_PRESENT' && allowedErrs.VARIABLE_PRESENT) {
|
|
78
|
-
addError(errStr);
|
|
79
|
-
}
|
|
80
|
-
};
|
|
96
|
+
|
|
81
97
|
const singleConvertor = (value, changeVal, details, range) => {
|
|
82
98
|
const {
|
|
83
99
|
path,
|
|
84
100
|
filename,
|
|
85
101
|
decl
|
|
86
102
|
} = details;
|
|
103
|
+
|
|
104
|
+
if (decl.prop === 'background-position') {
|
|
105
|
+
if (isNaN(parseInt(value))) {
|
|
106
|
+
// console.log(`${value} skipped`);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
87
111
|
if (getNumericValue(value) >= range.start && getNumericValue(value) <= range.end || getNumericValue(value) === 0) {
|
|
88
112
|
let retVal = value.replace(/(\d+)px/gi, changeVal.replace('$$', '$1'));
|
|
113
|
+
|
|
89
114
|
if (/^-var/.test(retVal)) {
|
|
90
115
|
retVal = `calc( ${retVal.substring(1)} * -1 )`;
|
|
91
116
|
}
|
|
117
|
+
|
|
92
118
|
return retVal;
|
|
93
|
-
}
|
|
119
|
+
} // if (!value.includes('rect')) {
|
|
94
120
|
// if(unitErrorVal && unitErrorVal != '0' ){
|
|
95
121
|
// console.log(value, 'not within range')
|
|
96
|
-
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
let errObj = {
|
|
125
|
+
decl,
|
|
126
|
+
type: 'RANGE_ERROR',
|
|
127
|
+
filename,
|
|
128
|
+
message: `value (${value}) (${typeof value}) not within range (${range.start},${range.end})\r`,
|
|
129
|
+
path: path
|
|
130
|
+
};
|
|
131
|
+
errHandler.errorTable.push(errObj);
|
|
132
|
+
errHandler.errorFunction(errObj); // errorFunction(
|
|
133
|
+
// {
|
|
134
|
+
// decl,
|
|
135
|
+
// type: 'RANGE_ERROR',
|
|
136
|
+
// filename,
|
|
137
|
+
// message: `value (${value}) (${typeof value}) not within range (${
|
|
138
|
+
// range.start
|
|
139
|
+
// },${range.end})\r`,
|
|
140
|
+
// path: path
|
|
141
|
+
// },
|
|
142
|
+
// 'RANGE_ERROR'
|
|
143
|
+
// );
|
|
97
144
|
// }
|
|
98
145
|
// addError(` prop: ${decl.prop} ,\n value : ${decl.value} ,\n filename : ${filename} ,\n filepath : ${path} ,\n line : ${decl.source.start.line} ,\n message : value (${value}) not within range (${range.start},${range.end})\r`)
|
|
99
|
-
return value;
|
|
146
|
+
// return value;
|
|
147
|
+
// } else {
|
|
148
|
+
// console.log('++++++++++++++++++++++rect val!', value);
|
|
149
|
+
// }
|
|
100
150
|
};
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
151
|
+
|
|
152
|
+
module.exports = {
|
|
153
|
+
plugin: postcss.plugin('postcss-variable-report', cssVariableReplacementConfig => {
|
|
154
|
+
const rawdata = fs.readFileSync(cssVariableReplacementConfig);
|
|
155
|
+
const data = JSON.parse(rawdata);
|
|
156
|
+
const {
|
|
157
|
+
errorsAllowed,
|
|
158
|
+
settings: settingsObject // errorLog: errorLogStatus,
|
|
159
|
+
// errorInConsole: errorConsoleStatus
|
|
160
|
+
|
|
161
|
+
} = data; // const keys = Object.keys(settingsObject);
|
|
162
|
+
|
|
163
|
+
errHandler.setAllowedErrs(errorsAllowed);
|
|
164
|
+
const replacementArray = [];
|
|
165
|
+
Object.keys(settingsObject).forEach(key => {
|
|
166
|
+
Object.values(settingsObject[key].replacements).forEach(val => {
|
|
167
|
+
if (!replacementArray.includes(val)) {
|
|
168
|
+
replacementArray.push(val);
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
let regValStr = '';
|
|
173
|
+
replacementArray.forEach((val, index) => {
|
|
174
|
+
if (index !== replacementArray.length - 1) {
|
|
175
|
+
regValStr += `${val.replace('$$', '\\d+').replace('(', '\\(').replace(')', '\\)')}|`;
|
|
176
|
+
} else {
|
|
177
|
+
regValStr += `${val.replace('$$', '\\d+').replace('(', '\\(').replace(')', '\\)')}`;
|
|
117
178
|
}
|
|
118
179
|
});
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
180
|
+
const valRegex = new RegExp(regValStr, 'gi');
|
|
181
|
+
return rootOriginal => {
|
|
182
|
+
rootOriginal.walkRules(rule => {
|
|
183
|
+
// rule.nodes[-1] = {}
|
|
184
|
+
// need map, forEach fine less memory
|
|
185
|
+
rule.nodes.forEach((decl, position) => {
|
|
186
|
+
// case font-size
|
|
187
|
+
const commentStr = 'variable:ignore';
|
|
188
|
+
const prevNode = rule.nodes[position - 1];
|
|
189
|
+
const fromPath = rootOriginal.source.input.from; // this will be problem for linux and mac use require('path').sep
|
|
190
|
+
// split not need use slice and lastIndexOf less memory
|
|
191
|
+
|
|
192
|
+
const filename = fromPath.split(path.sep).pop();
|
|
193
|
+
|
|
194
|
+
if (prevNode && prevNode.type === 'comment' && prevNode.text.toLowerCase().includes(commentStr)) {
|
|
195
|
+
let errObj = {
|
|
196
|
+
decl,
|
|
197
|
+
type: 'DECLARATION_IGNORED',
|
|
198
|
+
filename,
|
|
199
|
+
message: 'Declaration Ignored',
|
|
200
|
+
path: fromPath
|
|
201
|
+
};
|
|
202
|
+
errHandler.errorTable.push(errObj);
|
|
203
|
+
errHandler.DECLARATION_IGNORED(errObj);
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (settingsObject[decl.prop] && !decl.value.includes('var(--')) {
|
|
208
|
+
const settings = settingsObject[decl.prop]; // console.log(settings)
|
|
209
|
+
|
|
210
|
+
const {
|
|
211
|
+
allowed,
|
|
212
|
+
range
|
|
213
|
+
} = settings; // suggestion filter !decl.value.includes('calc')
|
|
214
|
+
// Reason below some of logic happen based on this
|
|
215
|
+
|
|
216
|
+
const unit = decl.value.toString() // no need round braket since you do not need group for less memory
|
|
217
|
+
.replace(/\d+/gi, '').replace('var(--zd_size)', 'px').replace('var(--zd_font_size)', 'px').replace('rect(', '').replace(')', '').replace('px,', 'px').replace(',', '').split(' ').filter(x => x !== ''); // unit = unit.replace(unit, unit.replace('-',''))
|
|
218
|
+
// console.log('unit : ');
|
|
219
|
+
// console.log(unit);
|
|
220
|
+
|
|
221
|
+
unit.forEach((val, index) => {
|
|
222
|
+
allowed.forEach(alwdVal => {
|
|
223
|
+
if (val.includes(alwdVal)) {
|
|
224
|
+
// ## for what purpose
|
|
225
|
+
unit[index] = val // .replace(new RegExp('(\\d+).(\\d+)(\\w+)', 'gi'), '$3')
|
|
226
|
+
.replace(`-${alwdVal}`, `${alwdVal}`).replace(`-.${alwdVal}`, `${alwdVal}`).replace(`${alwdVal},`, `${alwdVal}`);
|
|
227
|
+
}
|
|
228
|
+
});
|
|
167
229
|
});
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
230
|
+
let unitError = false;
|
|
231
|
+
let unitErrorVal = '';
|
|
232
|
+
unit.forEach(val => {
|
|
233
|
+
if (!val.includes('calc') && decl.prop !== 'clip') {
|
|
234
|
+
if (!allowed.includes(val.toString())) {
|
|
235
|
+
unitError = true;
|
|
236
|
+
unitErrorVal = val;
|
|
237
|
+
}
|
|
176
238
|
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
239
|
+
}); // console.log(allowed, replacements, range)
|
|
240
|
+
|
|
241
|
+
if (!unitError) {
|
|
242
|
+
// use variable decl.value.split(' ')
|
|
243
|
+
if (range) {
|
|
244
|
+
// console.log('multiple :', decl.value)
|
|
245
|
+
let newVal = '';
|
|
246
|
+
decl.value.split(' ').forEach(singleVal => {
|
|
247
|
+
newVal += `${singleConvertor(singleVal, settings.replacements.px, {
|
|
248
|
+
decl,
|
|
249
|
+
filename,
|
|
250
|
+
path: fromPath
|
|
251
|
+
}, range)} `;
|
|
252
|
+
});
|
|
253
|
+
decl.value = newVal;
|
|
254
|
+
}
|
|
255
|
+
} else {
|
|
256
|
+
if (!decl.value.includes('calc')) {
|
|
257
|
+
// addError(` prop: ${decl.prop} ,\n value : ${decl.value} ,\n filename : ${filename} ,\n filepath : ${path} ,\n line : ${decl.source.start.line} ,\n unit : ${unitErrorVal} ,\n message : ${unitErrorVal} (Unit) Not Allowed \r`);
|
|
258
|
+
let errObj = {
|
|
187
259
|
decl,
|
|
188
260
|
filename,
|
|
261
|
+
unitErrorVal: unitErrorVal,
|
|
189
262
|
path: fromPath
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
if (unitErrorVal.trim() === '.') {
|
|
266
|
+
errObj.type = 'DECIMAL_CHECK';
|
|
267
|
+
errObj.message = `${unitErrorVal} (Decimal Value) Please check`;
|
|
268
|
+
errHandler.errorTable.push(errObj);
|
|
269
|
+
errHandler.DECIMAL_CHECK(errObj);
|
|
270
|
+
} else if (unitErrorVal.includes('.') && !unitErrorVal.includes('%')) {
|
|
271
|
+
errObj.type = 'DECIMAL_REJECT';
|
|
272
|
+
errObj.message = `${unitErrorVal} (Decimal Value) Not Allowed \r`;
|
|
273
|
+
errHandler.errorTable.push(errObj);
|
|
274
|
+
errHandler.DECIMAL_REJECT(errObj);
|
|
275
|
+
} else {
|
|
276
|
+
if (!unitErrorVal.includes('%')) {
|
|
277
|
+
errObj.type = 'UNIT_ERROR';
|
|
278
|
+
errObj.message = `${unitErrorVal} (Unit) Not Allowed`;
|
|
279
|
+
errHandler.errorTable.push(errObj);
|
|
280
|
+
errHandler.UNIT_ERROR(errObj);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
} else {
|
|
284
|
+
decl.value = pxToCalc(decl.value);
|
|
285
|
+
}
|
|
193
286
|
}
|
|
194
287
|
} else {
|
|
195
|
-
if (!decl.value.includes('calc')) {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
288
|
+
if (decl.prop && decl.value && !decl.prop.includes('--') && valRegex.test(decl.value) && (settingsObject[decl.prop] || convertableProps[decl.prop]) && decl.value.includes('var') && !decl.value.includes('calc')) {
|
|
289
|
+
let errObj = {
|
|
290
|
+
decl,
|
|
291
|
+
type: 'VARIABLE_PRESENT',
|
|
292
|
+
filename,
|
|
293
|
+
message: `value (${decl.value}) has var in it, kindly check`,
|
|
294
|
+
path: fromPath
|
|
295
|
+
};
|
|
296
|
+
errHandler.errorTable.push(errObj);
|
|
297
|
+
errHandler.VARIABLE_PRESENT(errObj);
|
|
200
298
|
}
|
|
201
299
|
}
|
|
202
|
-
} else {
|
|
203
|
-
if (decl.prop && decl.value && !decl.prop.includes('--') && valRegex.test(decl.value) && (settingsObject[decl.prop] || convertableProps[decl.prop]) && decl.value.includes('var') && !decl.value.includes('calc')) {
|
|
204
|
-
errorFunction(` prop: ${decl.prop} ,\n value : ${decl.value} ,\n filename : ${filename} ,\n filepath : ${fromPath} ,\n line : ${decl.source.start.line} ,\n message : value (${decl.value}) has var in it, kindly check`, 'VARIABLE_PRESENT');
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
});
|
|
208
|
-
});
|
|
209
|
-
// console.log(filename)
|
|
210
|
-
// console.log('Done!')
|
|
211
|
-
// console.log('----------------------------------------------------------------------------------------------------------------------')
|
|
212
|
-
if (errorLogStatus) {
|
|
213
|
-
fs.writeFileSync('./css_error.log', '');
|
|
214
|
-
if (errors.length > 0) {
|
|
215
|
-
errors.forEach(err => {
|
|
216
|
-
fs.appendFileSync('./css_error.log', err);
|
|
217
300
|
});
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
errors.forEach(err => {
|
|
225
|
-
// fs.appendFileSync('./css_error.log', err);
|
|
226
|
-
console.log(err);
|
|
227
|
-
});
|
|
228
|
-
console.log('----------------------------------------------------------------------------------------------------------------------');
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
};
|
|
232
|
-
});
|
|
301
|
+
});
|
|
302
|
+
};
|
|
303
|
+
}),
|
|
304
|
+
errors: errHandler.errors,
|
|
305
|
+
errTable: errHandler.errorTable
|
|
306
|
+
};
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
const postcss = require('postcss');
|
|
4
|
+
|
|
4
5
|
const path = require('path');
|
|
6
|
+
|
|
5
7
|
const fs = require('fs');
|
|
8
|
+
|
|
6
9
|
function populateArray(start, end) {
|
|
7
10
|
let temp = [];
|
|
11
|
+
|
|
8
12
|
for (var i = start; i < end; i++) {
|
|
9
13
|
temp.push(i);
|
|
10
14
|
}
|
|
15
|
+
|
|
11
16
|
return temp;
|
|
12
17
|
}
|
|
18
|
+
|
|
13
19
|
let allwdVars = {
|
|
14
20
|
'font-size': ['px', 'em']
|
|
15
21
|
};
|
|
@@ -78,9 +84,11 @@ let numberObject = {
|
|
|
78
84
|
}
|
|
79
85
|
}
|
|
80
86
|
};
|
|
87
|
+
|
|
81
88
|
function hasIgnoreComment(node) {
|
|
82
89
|
return node ? node.type == 'comment' ? node.text == 'Variable:Ignore' ? true : false : false : false;
|
|
83
90
|
}
|
|
91
|
+
|
|
84
92
|
let errors = [];
|
|
85
93
|
module.exports = postcss.plugin('postcss-variable-report', () => rootOriginal => {
|
|
86
94
|
// console.log('inside postcss plugin')
|
|
@@ -99,20 +107,21 @@ module.exports = postcss.plugin('postcss-variable-report', () => rootOriginal =>
|
|
|
99
107
|
let path = rootOriginal.source.input.from;
|
|
100
108
|
let filename = path.split('\\');
|
|
101
109
|
filename = filename[filename.length - 1];
|
|
110
|
+
|
|
102
111
|
if (decl.prop === 'font-size' || decl.prop === 'margin-left' || decl.prop === 'margin-right' || decl.prop === 'margin-top' || decl.prop === 'margin-bottom') {
|
|
103
112
|
let {
|
|
104
113
|
allowed,
|
|
105
114
|
replacements,
|
|
106
115
|
available
|
|
107
116
|
} = settings;
|
|
117
|
+
|
|
108
118
|
if (!rootOriginal.source.input.from.includes('node_modules')) {
|
|
109
119
|
if (unit != 0) {
|
|
110
120
|
if (allowed.includes(unit)) {
|
|
111
121
|
// console.log(available, parseInt(decl.value))
|
|
112
122
|
if (available.includes(parseInt(decl.value))) {
|
|
113
123
|
// replacementValues[unit].push({[decl.value] : replacements[unit].replace('$$', parseInt(decl.value))})
|
|
114
|
-
decl.value = replacements[unit].replace('$$', parseInt(decl.value));
|
|
115
|
-
//console.log("replacements:")
|
|
124
|
+
decl.value = replacements[unit].replace('$$', parseInt(decl.value)); //console.log("replacements:")
|
|
116
125
|
} else {
|
|
117
126
|
let err = {
|
|
118
127
|
prop: decl.prop,
|
|
@@ -144,16 +153,17 @@ module.exports = postcss.plugin('postcss-variable-report', () => rootOriginal =>
|
|
|
144
153
|
allowed,
|
|
145
154
|
replacements,
|
|
146
155
|
available
|
|
147
|
-
} = settings;
|
|
148
|
-
|
|
149
|
-
let valArr = decl.value.split(' ');
|
|
150
|
-
//console.log(valArr)
|
|
156
|
+
} = settings; //console.log(decl.prop + " " + decl.value)
|
|
157
|
+
|
|
158
|
+
let valArr = decl.value.split(' '); //console.log(valArr)
|
|
151
159
|
//console.log(allowed, replacements, available)
|
|
160
|
+
|
|
152
161
|
let hasError = false;
|
|
153
162
|
let newVal = '';
|
|
154
163
|
valArr.forEach(val => {
|
|
155
164
|
let unit = val.replace(parseInt(val), '');
|
|
156
165
|
let numVal = parseInt(val);
|
|
166
|
+
|
|
157
167
|
if (unit != 0) {
|
|
158
168
|
if (allowed.includes(unit)) {
|
|
159
169
|
if (available.includes(numVal)) {
|
|
@@ -194,31 +204,29 @@ module.exports = postcss.plugin('postcss-variable-report', () => rootOriginal =>
|
|
|
194
204
|
}
|
|
195
205
|
}
|
|
196
206
|
});
|
|
207
|
+
|
|
197
208
|
if (!hasError) {
|
|
198
209
|
decl.value = newVal;
|
|
199
210
|
}
|
|
200
211
|
}
|
|
201
212
|
}
|
|
202
213
|
});
|
|
203
|
-
});
|
|
204
|
-
//fs.writeFile('./src/trial.json', JSON.stringify(variables) ,(err) =>{
|
|
214
|
+
}); //fs.writeFile('./src/trial.json', JSON.stringify(variables) ,(err) =>{
|
|
205
215
|
// if(err)console.log(err);
|
|
206
216
|
// else{
|
|
207
217
|
// console.log('updated successfully');
|
|
208
218
|
// }
|
|
209
219
|
// })
|
|
210
220
|
// console.log(errors)
|
|
221
|
+
|
|
211
222
|
let errorArr = [];
|
|
212
223
|
errors.forEach(errStr => {
|
|
213
224
|
errorArr.push(` prop: ${errStr.prop} ,\n value : ${errStr.value} ,\n filename : ${errStr.filename} ,\n filepath : ${errStr.filepath} ,\n line : ${errStr.line} ,\n unit : ${errStr.unit} ,\n message : ${errStr.message} \r`);
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
//fs.writeFile('./css_error.log','', (err) =>{
|
|
225
|
+
}); //fs.writeFile('./css_error.log','', (err) =>{
|
|
217
226
|
// if(err){
|
|
218
227
|
// console.log(err);
|
|
219
228
|
// }
|
|
220
229
|
//});
|
|
221
|
-
|
|
222
230
|
// errorArr.forEach(err => {
|
|
223
231
|
// let data = `\n{\n${err}\n},\n`;
|
|
224
232
|
// //fs.appendFile('./css_error.log',data,(err)=>{
|
|
@@ -228,7 +236,6 @@ module.exports = postcss.plugin('postcss-variable-report', () => rootOriginal =>
|
|
|
228
236
|
// //})
|
|
229
237
|
// });
|
|
230
238
|
// fs.writeFileSync('./css_error.log','');
|
|
231
|
-
|
|
232
239
|
// errorArr.forEach(err => {
|
|
233
240
|
// let data = `\n{\n${err}\n},\n`;
|
|
234
241
|
// fs.appendFileSync('./css_error.log',data);
|
package/lib/schemas/index.js
CHANGED
|
@@ -4,10 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
|
|
7
8
|
var _os = require("os");
|
|
9
|
+
|
|
8
10
|
var _getIp = _interopRequireDefault(require("../utils/getIp"));
|
|
11
|
+
|
|
9
12
|
var _getCurrentBranch = _interopRequireDefault(require("../utils/getCurrentBranch"));
|
|
13
|
+
|
|
10
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
11
16
|
// TODO move deprecated options to separate file and manage seperately
|
|
12
17
|
var _default = {
|
|
13
18
|
cliRootPath: null,
|
|
@@ -212,15 +217,22 @@ var _default = {
|
|
|
212
217
|
hasRTL: false,
|
|
213
218
|
hoverActive: false,
|
|
214
219
|
combinerMediaQuery: false,
|
|
215
|
-
cssVariableReplacement: false
|
|
220
|
+
cssVariableReplacement: false,
|
|
221
|
+
selectorWeight: false
|
|
216
222
|
},
|
|
217
223
|
exclude: {
|
|
218
224
|
rtl: [],
|
|
219
225
|
hoverActive: [],
|
|
220
226
|
combinerMediaQuery: [],
|
|
221
|
-
cssVariableReplacement: []
|
|
227
|
+
cssVariableReplacement: [],
|
|
228
|
+
selectorWeight: []
|
|
222
229
|
},
|
|
223
230
|
cssVariableReplacementConfig: '',
|
|
231
|
+
selectorWeightConfig: {
|
|
232
|
+
defaultSelector: '',
|
|
233
|
+
customFileDetails: '',
|
|
234
|
+
excludeStrings: []
|
|
235
|
+
},
|
|
224
236
|
seperateCssModules: {
|
|
225
237
|
value: false,
|
|
226
238
|
cli: 'sep_cssmodules'
|
|
@@ -302,15 +314,22 @@ var _default = {
|
|
|
302
314
|
hasRTL: false,
|
|
303
315
|
hoverActive: false,
|
|
304
316
|
combinerMediaQuery: false,
|
|
305
|
-
cssVariableReplacement: false
|
|
317
|
+
cssVariableReplacement: false,
|
|
318
|
+
selectorWeight: false
|
|
306
319
|
},
|
|
307
320
|
exclude: {
|
|
308
321
|
rtl: [],
|
|
309
322
|
hoverActive: [],
|
|
310
323
|
combinerMediaQuery: [],
|
|
311
|
-
cssVariableReplacement: []
|
|
324
|
+
cssVariableReplacement: [],
|
|
325
|
+
selectorWeight: []
|
|
312
326
|
},
|
|
313
327
|
cssVariableReplacementConfig: '',
|
|
328
|
+
selectorWeightConfig: {
|
|
329
|
+
defaultSelector: '',
|
|
330
|
+
customFileDetails: '',
|
|
331
|
+
excludeStrings: []
|
|
332
|
+
},
|
|
314
333
|
cssHashSelectors: {
|
|
315
334
|
filenames: [],
|
|
316
335
|
packages: []
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _path = _interopRequireDefault(require("path"));
|
|
4
|
+
|
|
4
5
|
var _fs = _interopRequireDefault(require("fs"));
|
|
6
|
+
|
|
5
7
|
var _express = _interopRequireDefault(require("express"));
|
|
8
|
+
|
|
6
9
|
var _utils = require("../utils");
|
|
10
|
+
|
|
7
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
|
|
8
13
|
let options = (0, _utils.getOptions)();
|
|
9
14
|
let {
|
|
10
15
|
cluster: {
|
|
@@ -13,13 +18,17 @@ let {
|
|
|
13
18
|
} = options;
|
|
14
19
|
let app = (0, _express.default)();
|
|
15
20
|
let appPath = process.cwd();
|
|
21
|
+
|
|
16
22
|
let clusterConfigPath = _path.default.join(appPath, 'clusterConfig.js');
|
|
23
|
+
|
|
17
24
|
let config;
|
|
25
|
+
|
|
18
26
|
if (_fs.default.existsSync(clusterConfigPath)) {
|
|
19
27
|
config = require(clusterConfigPath);
|
|
20
28
|
} else {
|
|
21
29
|
throw new Error(`clusterConfig.js doen't exist under following path - ${clusterConfigPath}`);
|
|
22
30
|
}
|
|
31
|
+
|
|
23
32
|
app.get('/clusterhub/nodes', (req, res) => {
|
|
24
33
|
res.send(JSON.stringify(config.cluster));
|
|
25
34
|
});
|
|
@@ -28,5 +37,6 @@ app.listen(server.port, err => {
|
|
|
28
37
|
if (err) {
|
|
29
38
|
throw err;
|
|
30
39
|
}
|
|
40
|
+
|
|
31
41
|
(0, _utils.log)(`Listening at ${(0, _utils.getServerURL)(server, 'ht' + 'tp')}/clusterhub/`);
|
|
32
42
|
});
|