@zohodesk/react-cli 1.0.3 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +18 -1
- package/bin/cli.js +10 -4
- package/docs/ComposeMinification.md +13 -0
- package/docs/ReactLive.md +10 -0
- package/docs/patternFiltering.md +57 -0
- package/lib/common/buildEs.js +12 -0
- package/lib/configs/webpack.dev.config.js +3 -0
- package/lib/configs/webpack.docs.config.js +6 -0
- package/lib/configs/webpack.impact.config.js +2 -0
- package/lib/configs/webpack.prod.config.js +3 -0
- package/lib/loaderUtils/getCSSLoaders.js +77 -46
- package/lib/loaderUtils/tests/windowsModification.test.js +10 -0
- package/lib/loaderUtils/windowsModification.js +6 -1
- package/lib/loaders/composeLoader.js +172 -0
- package/lib/loaders/docsLoader.js +15 -7
- package/lib/loaders/reactLiveConvertor.js +107 -0
- package/lib/pluginUtils/getDevPlugins.js +10 -3
- package/lib/pluginUtils/getProdPlugins.js +8 -3
- package/lib/pluginUtils/getUMDCSSPlugins.js +1 -1
- package/lib/pluginUtils/getUMDComponentPlugins.js +1 -1
- package/lib/plugins/{UglifyCSSPlugin.js → MinifyPlugin.js} +3 -3
- package/lib/plugins/SelectorPlugin.js +63 -40
- package/lib/plugins/VariableConversionCollector.js +40 -97
- package/lib/plugins/index.js +7 -7
- package/lib/plugins/utils/classHandling.js +35 -0
- package/lib/plugins/utils/fileHandling.js +107 -0
- package/lib/plugins/utils/tests/fileHandling.test.js +30 -0
- package/lib/plugins/variableConvertorUtils.js +131 -0
- package/lib/postcss-plugins/EmptyPlugin.js +8 -0
- package/lib/postcss-plugins/ExcludePlugin.js +1 -1
- package/lib/postcss-plugins/ValueReplacer.js +5 -14
- package/lib/postcss-plugins/variableModificationPlugin/index.js +2 -19
- package/lib/schemas/index.js +33 -3
- package/lib/servers/server.js +2 -2
- package/lib/utils/cssClassNameGenerate.js +34 -9
- package/lib/utils/getOptions.js +16 -0
- package/lib/utils/variableConverter.js +89 -0
- package/{package-lock.json → npm-shrinkwrap.json} +1 -1
- package/package.json +3 -1
- package/lib/plugins/composeCommonPlugin.js +0 -30
- package/lib/postcss-plugins/variableModifier.js +0 -210
@@ -1,210 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
const postcss = require('postcss');
|
4
|
-
|
5
|
-
const path = require('path');
|
6
|
-
|
7
|
-
const fs = require('fs');
|
8
|
-
|
9
|
-
function populateArray(start, end) {
|
10
|
-
const temp = [];
|
11
|
-
|
12
|
-
for (let i = start; i < end; i++) {
|
13
|
-
temp.push(i);
|
14
|
-
}
|
15
|
-
|
16
|
-
return temp;
|
17
|
-
}
|
18
|
-
|
19
|
-
const allwdVars = {
|
20
|
-
'font-size': ['px', 'em']
|
21
|
-
};
|
22
|
-
const numberObject = {
|
23
|
-
'font-size': {
|
24
|
-
allowed: ['px', 'em'],
|
25
|
-
replacements: {
|
26
|
-
px: 'var(--zd_font_size$$)',
|
27
|
-
em: 'var(--zd_font_size$$em)'
|
28
|
-
},
|
29
|
-
//[5,10,15,20,25],
|
30
|
-
available: populateArray(0, 251),
|
31
|
-
replacementValues: {
|
32
|
-
px: [],
|
33
|
-
em: []
|
34
|
-
}
|
35
|
-
},
|
36
|
-
'margin': {
|
37
|
-
allowed: ['px'],
|
38
|
-
replacements: {
|
39
|
-
px: 'var(--zd_size$$)'
|
40
|
-
},
|
41
|
-
available: populateArray(-250, 251),
|
42
|
-
replacementValues: {
|
43
|
-
px: []
|
44
|
-
}
|
45
|
-
},
|
46
|
-
'margin-left': {
|
47
|
-
allowed: ['px'],
|
48
|
-
replacements: {
|
49
|
-
px: 'var(--zd_size$$)'
|
50
|
-
},
|
51
|
-
available: populateArray(-250, 251),
|
52
|
-
replacementValues: {
|
53
|
-
px: []
|
54
|
-
}
|
55
|
-
},
|
56
|
-
'margin-right': {
|
57
|
-
allowed: ['px'],
|
58
|
-
replacements: {
|
59
|
-
px: 'var(--zd_size$$)'
|
60
|
-
},
|
61
|
-
available: populateArray(-250, 251),
|
62
|
-
replacementValues: {
|
63
|
-
px: []
|
64
|
-
}
|
65
|
-
},
|
66
|
-
'margin-top': {
|
67
|
-
allowed: ['px'],
|
68
|
-
replacements: {
|
69
|
-
px: 'var(--zd_size$$)'
|
70
|
-
},
|
71
|
-
available: populateArray(-250, 251),
|
72
|
-
replacementValues: {
|
73
|
-
px: []
|
74
|
-
}
|
75
|
-
},
|
76
|
-
'margin-bottom': {
|
77
|
-
allowed: ['px'],
|
78
|
-
replacements: {
|
79
|
-
px: 'var(--zd_size$$)'
|
80
|
-
},
|
81
|
-
available: populateArray(-250, 251),
|
82
|
-
replacementValues: {
|
83
|
-
px: []
|
84
|
-
}
|
85
|
-
}
|
86
|
-
};
|
87
|
-
|
88
|
-
function hasIgnoreComment(node) {
|
89
|
-
return node ? node.type == 'comment' ? node.text == 'Variable:Ignore' ? true : false : false : false;
|
90
|
-
}
|
91
|
-
|
92
|
-
const errors = [];
|
93
|
-
module.exports = postcss.plugin('postcss-variable-report', () => rootOriginal => {
|
94
|
-
if (!rootOriginal.source.input.file.includes('css_error')) {
|
95
|
-
rootOriginal.walkRules(rule => {
|
96
|
-
rule.walkDecls((decl, position) => {
|
97
|
-
// case font-size
|
98
|
-
if (!hasIgnoreComment(rule.nodes[position - 1])) {
|
99
|
-
const unit = decl.value.replace(/[0-9]/g, '');
|
100
|
-
const settings = numberObject[decl.prop];
|
101
|
-
const path = rootOriginal.source.input.from;
|
102
|
-
let filename = path.split('\\');
|
103
|
-
filename = filename[filename.length - 1];
|
104
|
-
|
105
|
-
if (decl.prop === 'font-size' || decl.prop === 'margin-left' || decl.prop === 'margin-right' || decl.prop === 'margin-top' || decl.prop === 'margin-bottom') {
|
106
|
-
const {
|
107
|
-
allowed,
|
108
|
-
replacements,
|
109
|
-
available
|
110
|
-
} = settings;
|
111
|
-
|
112
|
-
if (!rootOriginal.source.input.from.includes('node_modules')) {
|
113
|
-
if (unit != 0) {
|
114
|
-
if (allowed.includes(unit)) {
|
115
|
-
if (available.includes(parseInt(decl.value))) {
|
116
|
-
// replacementValues[unit].push({[decl.value] : replacements[unit].replace('$$', parseInt(decl.value))})
|
117
|
-
decl.value = replacements[unit].replace('$$', parseInt(decl.value));
|
118
|
-
} else {
|
119
|
-
const err = {
|
120
|
-
prop: decl.prop,
|
121
|
-
value: decl.value,
|
122
|
-
filename,
|
123
|
-
filepath: rootOriginal.source.input.from,
|
124
|
-
line: decl.source.start.line,
|
125
|
-
unit,
|
126
|
-
message: 'value not available consider others'
|
127
|
-
};
|
128
|
-
errors.push(err);
|
129
|
-
}
|
130
|
-
} else {
|
131
|
-
const err = {
|
132
|
-
prop: decl.prop,
|
133
|
-
value: decl.value,
|
134
|
-
filename,
|
135
|
-
filepath: rootOriginal.source.input.from,
|
136
|
-
line: decl.source.start.line,
|
137
|
-
unit,
|
138
|
-
message: 'Unit not supported'
|
139
|
-
};
|
140
|
-
errors.push(err);
|
141
|
-
}
|
142
|
-
}
|
143
|
-
}
|
144
|
-
} else if (decl.prop === 'margin') {
|
145
|
-
const {
|
146
|
-
allowed,
|
147
|
-
replacements,
|
148
|
-
available
|
149
|
-
} = settings;
|
150
|
-
const valArr = decl.value.split(' ');
|
151
|
-
let hasError = false;
|
152
|
-
let newVal = '';
|
153
|
-
valArr.forEach(val => {
|
154
|
-
const unit = val.replace(parseInt(val), '');
|
155
|
-
const numVal = parseInt(val);
|
156
|
-
|
157
|
-
if (unit != 0) {
|
158
|
-
if (allowed.includes(unit)) {
|
159
|
-
if (available.includes(numVal)) {
|
160
|
-
if (numVal >= 0) {
|
161
|
-
if (!hasError) {
|
162
|
-
newVal += `${replacements[unit].replace('$$', numVal)} `;
|
163
|
-
}
|
164
|
-
} else {
|
165
|
-
if (!hasError) {
|
166
|
-
newVal += `calc(${replacements[unit].replace('$$', numVal * -1)} * -1)` + ' ';
|
167
|
-
}
|
168
|
-
}
|
169
|
-
} else {
|
170
|
-
hasError = true;
|
171
|
-
const err = {
|
172
|
-
prop: decl.prop,
|
173
|
-
value: numVal,
|
174
|
-
filename,
|
175
|
-
filepath: rootOriginal.source.input.from,
|
176
|
-
line: decl.source.start.line,
|
177
|
-
unit,
|
178
|
-
message: 'value not available consider others'
|
179
|
-
};
|
180
|
-
errors.push(err);
|
181
|
-
}
|
182
|
-
} else {
|
183
|
-
hasError = true;
|
184
|
-
const err = {
|
185
|
-
prop: decl.prop,
|
186
|
-
value: decl.value,
|
187
|
-
filename,
|
188
|
-
filepath: rootOriginal.source.input.from,
|
189
|
-
line: decl.source.start.line,
|
190
|
-
unit,
|
191
|
-
message: 'Unit not supported'
|
192
|
-
};
|
193
|
-
errors.push(err);
|
194
|
-
}
|
195
|
-
}
|
196
|
-
});
|
197
|
-
|
198
|
-
if (!hasError) {
|
199
|
-
decl.value = newVal;
|
200
|
-
}
|
201
|
-
}
|
202
|
-
}
|
203
|
-
});
|
204
|
-
});
|
205
|
-
const errorArr = [];
|
206
|
-
errors.forEach(errStr => {
|
207
|
-
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`);
|
208
|
-
});
|
209
|
-
}
|
210
|
-
});
|