@zohodesk/react-cli 1.0.3 → 1.1.0

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.
Files changed (41) hide show
  1. package/README.md +18 -1
  2. package/bin/cli.js +10 -4
  3. package/docs/ComposeMinification.md +13 -0
  4. package/docs/ReactLive.md +10 -0
  5. package/docs/patternFiltering.md +57 -0
  6. package/lib/common/buildEs.js +12 -0
  7. package/lib/configs/webpack.dev.config.js +3 -0
  8. package/lib/configs/webpack.docs.config.js +6 -0
  9. package/lib/configs/webpack.impact.config.js +2 -0
  10. package/lib/configs/webpack.prod.config.js +3 -0
  11. package/lib/loaderUtils/getCSSLoaders.js +77 -46
  12. package/lib/loaderUtils/tests/windowsModification.test.js +10 -0
  13. package/lib/loaderUtils/windowsModification.js +6 -1
  14. package/lib/loaders/composeLoader.js +172 -0
  15. package/lib/loaders/docsLoader.js +15 -7
  16. package/lib/loaders/reactLiveConvertor.js +107 -0
  17. package/lib/pluginUtils/getDevPlugins.js +10 -3
  18. package/lib/pluginUtils/getProdPlugins.js +8 -3
  19. package/lib/pluginUtils/getUMDCSSPlugins.js +1 -1
  20. package/lib/pluginUtils/getUMDComponentPlugins.js +1 -1
  21. package/lib/plugins/{UglifyCSSPlugin.js → MinifyPlugin.js} +3 -3
  22. package/lib/plugins/SelectorPlugin.js +63 -40
  23. package/lib/plugins/VariableConversionCollector.js +40 -97
  24. package/lib/plugins/index.js +7 -7
  25. package/lib/plugins/utils/classHandling.js +35 -0
  26. package/lib/plugins/utils/fileHandling.js +107 -0
  27. package/lib/plugins/utils/tests/fileHandling.test.js +30 -0
  28. package/lib/plugins/variableConvertorUtils.js +131 -0
  29. package/lib/postcss-plugins/EmptyPlugin.js +8 -0
  30. package/lib/postcss-plugins/ExcludePlugin.js +1 -1
  31. package/lib/postcss-plugins/ValueReplacer.js +5 -14
  32. package/lib/postcss-plugins/variableModificationPlugin/index.js +2 -19
  33. package/lib/schemas/index.js +33 -3
  34. package/lib/servers/server.js +2 -2
  35. package/lib/utils/cssClassNameGenerate.js +34 -9
  36. package/lib/utils/getOptions.js +16 -0
  37. package/lib/utils/variableConverter.js +89 -0
  38. package/{package-lock.json → npm-shrinkwrap.json} +1 -1
  39. package/package.json +3 -1
  40. package/lib/plugins/composeCommonPlugin.js +0 -30
  41. 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
- });