@zohodesk/react-cli 1.0.3-beta.1 → 1.0.3-exp.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. package/.eslintignore +7 -7
  2. package/.eslintrc.js +180 -180
  3. package/.prettierrc +6 -6
  4. package/Changelog.md +1019 -1019
  5. package/README.md +1209 -1189
  6. package/bin/cli.js +489 -483
  7. package/docs/ComposeMinification.md +14 -0
  8. package/docs/CustomChunks.md +26 -26
  9. package/docs/DevServerPort.md +39 -39
  10. package/docs/DevStart.md +18 -18
  11. package/docs/HoverActive.md +12 -12
  12. package/docs/InstallNode.md +28 -28
  13. package/docs/SelectorWeight.md +8 -8
  14. package/docs/TODOS.md +10 -10
  15. package/docs/ValueReplacer.md +60 -60
  16. package/docs/VariableConversion.md +729 -729
  17. package/docs/warnings_while_install.txt +35 -35
  18. package/files/eslintrc.js +62 -62
  19. package/files/prettierrc.js +3 -3
  20. package/lib/common/buildEs.js +12 -0
  21. package/lib/configs/webpack.css.umd.config.js +4 -4
  22. package/lib/configs/webpack.dev.config.js +6 -0
  23. package/lib/configs/webpack.docs.config.js +4 -0
  24. package/lib/configs/webpack.impact.config.js +4 -0
  25. package/lib/configs/webpack.prod.config.js +6 -0
  26. package/lib/loaderUtils/configsAssetsLoaders.js +33 -33
  27. package/lib/loaderUtils/getCSSLoaders.js +80 -46
  28. package/lib/loaderUtils/tests/windowsModification.test.js +10 -0
  29. package/lib/loaderUtils/windowsModification.js +6 -1
  30. package/lib/loaders/composeLoader.js +172 -0
  31. package/lib/loaders/workerLoader.js +9 -9
  32. package/lib/pluginUtils/getDevPlugins.js +18 -8
  33. package/lib/pluginUtils/getProdPlugins.js +16 -8
  34. package/lib/pluginUtils/getUMDCSSPlugins.js +1 -1
  35. package/lib/pluginUtils/getUMDComponentPlugins.js +1 -1
  36. package/lib/plugins/CustomAttributePlugin.md +35 -35
  37. package/lib/plugins/EFCPlugin.md +6 -6
  38. package/lib/plugins/I18NInjectIntoIndexPlugin.js +4 -4
  39. package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +38 -38
  40. package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +30 -30
  41. package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +8 -8
  42. package/lib/plugins/I18nSplitPlugin/I18nSplit.md +95 -95
  43. package/lib/plugins/I18nSplitPlugin/README.md +25 -25
  44. package/lib/plugins/I18nSplitPlugin/index.js +57 -57
  45. package/lib/plugins/{UglifyCSSPlugin.js → MinifyPlugin.js} +3 -3
  46. package/lib/plugins/ResourceHintsPlugin.js +17 -17
  47. package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +6 -6
  48. package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -30
  49. package/lib/plugins/SelectorPlugin.js +64 -40
  50. package/lib/plugins/ServiceWorkerPlugin.js +9 -9
  51. package/lib/plugins/TPHashMappingPlugin.js +4 -4
  52. package/lib/plugins/VariableConversionCollector.js +94 -84
  53. package/lib/plugins/index.js +7 -7
  54. package/lib/plugins/utils/classHandling.js +20 -0
  55. package/lib/plugins/utils/fileHandling.js +107 -0
  56. package/lib/plugins/utils/tests/fileHandling.test.js +30 -0
  57. package/lib/postcss-plugins/EmptyPlugin.js +8 -0
  58. package/lib/postcss-plugins/ExcludePlugin.js +1 -1
  59. package/lib/postcss-plugins/RTLSplitPlugin.js +10 -10
  60. package/lib/postcss-plugins/ValueReplacer.js +5 -14
  61. package/lib/postcss-plugins/__test__/test1Input.css +38 -38
  62. package/lib/postcss-plugins/__test__/test1Output.css +38 -38
  63. package/lib/postcss-plugins/hoverActivePlugin.js +3 -3
  64. package/lib/postcss-plugins/variableModificationPlugin/index.js +1 -19
  65. package/lib/schemas/index.js +31 -3
  66. package/lib/servers/server.js +2 -2
  67. package/lib/sh/pre-commit.sh +34 -34
  68. package/lib/sh/reportPublish.sh +45 -45
  69. package/lib/utils/buildstats.html +148 -148
  70. package/lib/utils/cssClassNameGenerate.js +40 -13
  71. package/lib/utils/getOptions.js +9 -0
  72. package/lib/utils/resultSchema.json +73 -73
  73. package/lib/utils/variableConvertor.js +159 -0
  74. package/npm8.md +9 -9
  75. package/{npm-shrinkwrap.json → package-lock.json} +14412 -14407
  76. package/package.json +121 -121
  77. package/postpublish.js +8 -8
  78. package/templates/app/.eslintrc.js +140 -140
  79. package/templates/app/README.md +12 -12
  80. package/templates/app/app/index.html +24 -24
  81. package/templates/app/app/properties/ApplicationResources_en_US.properties +1 -1
  82. package/templates/app/app/properties/i18nkeys.json +3 -3
  83. package/templates/app/docs/all.html +69 -69
  84. package/templates/app/mockapi/index.js +18 -18
  85. package/templates/app/package.json +37 -37
  86. package/templates/app/src/actions/SampleActions/index.js +37 -37
  87. package/templates/app/src/actions/index.js +65 -65
  88. package/templates/app/src/appUrls.js +19 -19
  89. package/templates/app/src/components/Alert/Alert.js +134 -134
  90. package/templates/app/src/components/Alert/Alert.module.css +79 -79
  91. package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -37
  92. package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -84
  93. package/templates/app/src/components/Sample/Sample.module.css +11 -11
  94. package/templates/app/src/components/Sample/SampleList.js +61 -61
  95. package/templates/app/src/components/Slider/Slider.css +41 -41
  96. package/templates/app/src/components/Slider/Slider.js +55 -55
  97. package/templates/app/src/containers/AlertContainer/index.js +15 -15
  98. package/templates/app/src/containers/AppContainer/index.js +96 -96
  99. package/templates/app/src/containers/AppContainer/index.module.css +27 -27
  100. package/templates/app/src/containers/CustomMatch/index.js +65 -65
  101. package/templates/app/src/containers/DevTools/index.js +10 -10
  102. package/templates/app/src/containers/Header/index.js +67 -67
  103. package/templates/app/src/containers/Header/index.module.css +43 -43
  104. package/templates/app/src/containers/Redirect/index.js +63 -63
  105. package/templates/app/src/containers/Redirector/index.js +47 -47
  106. package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -42
  107. package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -3
  108. package/templates/app/src/historyChange.js +5 -5
  109. package/templates/app/src/index.html +10 -10
  110. package/templates/app/src/index.js +24 -24
  111. package/templates/app/src/middleware/PromiseMiddleware.js +59 -59
  112. package/templates/app/src/reducers/alertData.js +11 -11
  113. package/templates/app/src/reducers/index.js +6 -6
  114. package/templates/app/src/reducers/samples.js +19 -19
  115. package/templates/app/src/store/configureStore.dev.js +51 -51
  116. package/templates/app/src/store/configureStore.js +5 -5
  117. package/templates/app/src/store/configureStore.prod.js +26 -26
  118. package/templates/app/src/util/Common.js +5 -5
  119. package/templates/app/src/util/RequestAPI.js +132 -132
  120. package/templates/docs/all.html +249 -249
  121. package/templates/docs/component.html +178 -178
  122. package/templates/docs/components.html +221 -221
  123. package/templates/docs/css/b.min.css +6 -6
  124. package/templates/docs/css/component.css +42 -42
  125. package/templates/docs/css/componentTest.css +6 -6
  126. package/templates/docs/css/hopscotch.css +585 -585
  127. package/templates/docs/css/style.css +1022 -1022
  128. package/templates/docs/impactReportTemplate.html +154 -154
  129. package/templates/docs/index.html +1501 -1501
  130. package/templates/docs/js/active-line.js +72 -72
  131. package/templates/docs/js/b.min.js +7 -7
  132. package/templates/docs/js/codemirror.js +9680 -9680
  133. package/templates/docs/js/designTokens.js +334 -334
  134. package/templates/docs/js/j.min.js +4 -4
  135. package/templates/docs/js/javascript.js +874 -874
  136. package/templates/docs/js/matchbrackets.js +145 -145
  137. package/lib/plugins/composeCommonPlugin.js +0 -30
  138. package/lib/postcss-plugins/variableModifier.js +0 -210
@@ -1,145 +1,145 @@
1
- // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
- // Distributed under an MIT license: http://codemirror.net/LICENSE
3
-
4
- (function(mod) {
5
- if (typeof exports == "object" && typeof module == "object") // CommonJS
6
- mod(require("../../lib/codemirror"));
7
- else if (typeof define == "function" && define.amd) // AMD
8
- define(["../../lib/codemirror"], mod);
9
- else // Plain browser env
10
- mod(CodeMirror);
11
- })(function(CodeMirror) {
12
- var ie_lt8 = /MSIE \d/.test(navigator.userAgent) &&
13
- (document.documentMode == null || document.documentMode < 8);
14
-
15
- var Pos = CodeMirror.Pos;
16
-
17
- var matching = {"(": ")>", ")": "(<", "[": "]>", "]": "[<", "{": "}>", "}": "{<"};
18
-
19
- function findMatchingBracket(cm, where, config) {
20
- var line = cm.getLineHandle(where.line), pos = where.ch - 1;
21
- var afterCursor = config && config.afterCursor
22
- if (afterCursor == null)
23
- afterCursor = /(^| )cm-fat-cursor($| )/.test(cm.getWrapperElement().className)
24
-
25
- // A cursor is defined as between two characters, but in in vim command mode
26
- // (i.e. not insert mode), the cursor is visually represented as a
27
- // highlighted box on top of the 2nd character. Otherwise, we allow matches
28
- // from before or after the cursor.
29
- var match = (!afterCursor && pos >= 0 && matching[line.text.charAt(pos)]) ||
30
- matching[line.text.charAt(++pos)];
31
- if (!match) return null;
32
- var dir = match.charAt(1) == ">" ? 1 : -1;
33
- if (config && config.strict && (dir > 0) != (pos == where.ch)) return null;
34
- var style = cm.getTokenTypeAt(Pos(where.line, pos + 1));
35
-
36
- var found = scanForBracket(cm, Pos(where.line, pos + (dir > 0 ? 1 : 0)), dir, style || null, config);
37
- if (found == null) return null;
38
- return {from: Pos(where.line, pos), to: found && found.pos,
39
- match: found && found.ch == match.charAt(0), forward: dir > 0};
40
- }
41
-
42
- // bracketRegex is used to specify which type of bracket to scan
43
- // should be a regexp, e.g. /[[\]]/
44
- //
45
- // Note: If "where" is on an open bracket, then this bracket is ignored.
46
- //
47
- // Returns false when no bracket was found, null when it reached
48
- // maxScanLines and gave up
49
- function scanForBracket(cm, where, dir, style, config) {
50
- var maxScanLen = (config && config.maxScanLineLength) || 10000;
51
- var maxScanLines = (config && config.maxScanLines) || 1000;
52
-
53
- var stack = [];
54
- var re = config && config.bracketRegex ? config.bracketRegex : /[(){}[\]]/;
55
- var lineEnd = dir > 0 ? Math.min(where.line + maxScanLines, cm.lastLine() + 1)
56
- : Math.max(cm.firstLine() - 1, where.line - maxScanLines);
57
- for (var lineNo = where.line; lineNo != lineEnd; lineNo += dir) {
58
- var line = cm.getLine(lineNo);
59
- if (!line) continue;
60
- var pos = dir > 0 ? 0 : line.length - 1, end = dir > 0 ? line.length : -1;
61
- if (line.length > maxScanLen) continue;
62
- if (lineNo == where.line) pos = where.ch - (dir < 0 ? 1 : 0);
63
- for (; pos != end; pos += dir) {
64
- var ch = line.charAt(pos);
65
- if (re.test(ch) && (style === undefined || cm.getTokenTypeAt(Pos(lineNo, pos + 1)) == style)) {
66
- var match = matching[ch];
67
- if ((match.charAt(1) == ">") == (dir > 0)) stack.push(ch);
68
- else if (!stack.length) return {pos: Pos(lineNo, pos), ch: ch};
69
- else stack.pop();
70
- }
71
- }
72
- }
73
- return lineNo - dir == (dir > 0 ? cm.lastLine() : cm.firstLine()) ? false : null;
74
- }
75
-
76
- function matchBrackets(cm, autoclear, config) {
77
- // Disable brace matching in long lines, since it'll cause hugely slow updates
78
- var maxHighlightLen = cm.state.matchBrackets.maxHighlightLineLength || 1000;
79
- var marks = [], ranges = cm.listSelections();
80
- for (var i = 0; i < ranges.length; i++) {
81
- var match = ranges[i].empty() && findMatchingBracket(cm, ranges[i].head, config);
82
- if (match && cm.getLine(match.from.line).length <= maxHighlightLen) {
83
- var style = match.match ? "CodeMirror-matchingbracket" : "CodeMirror-nonmatchingbracket";
84
- marks.push(cm.markText(match.from, Pos(match.from.line, match.from.ch + 1), {className: style}));
85
- if (match.to && cm.getLine(match.to.line).length <= maxHighlightLen)
86
- marks.push(cm.markText(match.to, Pos(match.to.line, match.to.ch + 1), {className: style}));
87
- }
88
- }
89
-
90
- if (marks.length) {
91
- // Kludge to work around the IE bug from issue #1193, where text
92
- // input stops going to the textare whever this fires.
93
- if (ie_lt8 && cm.state.focused) cm.focus();
94
-
95
- var clear = function() {
96
- cm.operation(function() {
97
- for (var i = 0; i < marks.length; i++) marks[i].clear();
98
- });
99
- };
100
- if (autoclear) setTimeout(clear, 800);
101
- else return clear;
102
- }
103
- }
104
-
105
- function doMatchBrackets(cm) {
106
- cm.operation(function() {
107
- if (cm.state.matchBrackets.currentlyHighlighted) {
108
- cm.state.matchBrackets.currentlyHighlighted();
109
- cm.state.matchBrackets.currentlyHighlighted = null;
110
- }
111
- cm.state.matchBrackets.currentlyHighlighted = matchBrackets(cm, false, cm.state.matchBrackets);
112
- });
113
- }
114
-
115
- CodeMirror.defineOption("matchBrackets", false, function(cm, val, old) {
116
- if (old && old != CodeMirror.Init) {
117
- cm.off("cursorActivity", doMatchBrackets);
118
- if (cm.state.matchBrackets && cm.state.matchBrackets.currentlyHighlighted) {
119
- cm.state.matchBrackets.currentlyHighlighted();
120
- cm.state.matchBrackets.currentlyHighlighted = null;
121
- }
122
- }
123
- if (val) {
124
- cm.state.matchBrackets = typeof val == "object" ? val : {};
125
- cm.on("cursorActivity", doMatchBrackets);
126
- }
127
- });
128
-
129
- CodeMirror.defineExtension("matchBrackets", function() {matchBrackets(this, true);});
130
- CodeMirror.defineExtension("findMatchingBracket", function(pos, config, oldConfig){
131
- // Backwards-compatibility kludge
132
- if (oldConfig || typeof config == "boolean") {
133
- if (!oldConfig) {
134
- config = config ? {strict: true} : null
135
- } else {
136
- oldConfig.strict = config
137
- config = oldConfig
138
- }
139
- }
140
- return findMatchingBracket(this, pos, config)
141
- });
142
- CodeMirror.defineExtension("scanForBracket", function(pos, dir, style, config){
143
- return scanForBracket(this, pos, dir, style, config);
144
- });
145
- });
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
4
+ (function(mod) {
5
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
6
+ mod(require("../../lib/codemirror"));
7
+ else if (typeof define == "function" && define.amd) // AMD
8
+ define(["../../lib/codemirror"], mod);
9
+ else // Plain browser env
10
+ mod(CodeMirror);
11
+ })(function(CodeMirror) {
12
+ var ie_lt8 = /MSIE \d/.test(navigator.userAgent) &&
13
+ (document.documentMode == null || document.documentMode < 8);
14
+
15
+ var Pos = CodeMirror.Pos;
16
+
17
+ var matching = {"(": ")>", ")": "(<", "[": "]>", "]": "[<", "{": "}>", "}": "{<"};
18
+
19
+ function findMatchingBracket(cm, where, config) {
20
+ var line = cm.getLineHandle(where.line), pos = where.ch - 1;
21
+ var afterCursor = config && config.afterCursor
22
+ if (afterCursor == null)
23
+ afterCursor = /(^| )cm-fat-cursor($| )/.test(cm.getWrapperElement().className)
24
+
25
+ // A cursor is defined as between two characters, but in in vim command mode
26
+ // (i.e. not insert mode), the cursor is visually represented as a
27
+ // highlighted box on top of the 2nd character. Otherwise, we allow matches
28
+ // from before or after the cursor.
29
+ var match = (!afterCursor && pos >= 0 && matching[line.text.charAt(pos)]) ||
30
+ matching[line.text.charAt(++pos)];
31
+ if (!match) return null;
32
+ var dir = match.charAt(1) == ">" ? 1 : -1;
33
+ if (config && config.strict && (dir > 0) != (pos == where.ch)) return null;
34
+ var style = cm.getTokenTypeAt(Pos(where.line, pos + 1));
35
+
36
+ var found = scanForBracket(cm, Pos(where.line, pos + (dir > 0 ? 1 : 0)), dir, style || null, config);
37
+ if (found == null) return null;
38
+ return {from: Pos(where.line, pos), to: found && found.pos,
39
+ match: found && found.ch == match.charAt(0), forward: dir > 0};
40
+ }
41
+
42
+ // bracketRegex is used to specify which type of bracket to scan
43
+ // should be a regexp, e.g. /[[\]]/
44
+ //
45
+ // Note: If "where" is on an open bracket, then this bracket is ignored.
46
+ //
47
+ // Returns false when no bracket was found, null when it reached
48
+ // maxScanLines and gave up
49
+ function scanForBracket(cm, where, dir, style, config) {
50
+ var maxScanLen = (config && config.maxScanLineLength) || 10000;
51
+ var maxScanLines = (config && config.maxScanLines) || 1000;
52
+
53
+ var stack = [];
54
+ var re = config && config.bracketRegex ? config.bracketRegex : /[(){}[\]]/;
55
+ var lineEnd = dir > 0 ? Math.min(where.line + maxScanLines, cm.lastLine() + 1)
56
+ : Math.max(cm.firstLine() - 1, where.line - maxScanLines);
57
+ for (var lineNo = where.line; lineNo != lineEnd; lineNo += dir) {
58
+ var line = cm.getLine(lineNo);
59
+ if (!line) continue;
60
+ var pos = dir > 0 ? 0 : line.length - 1, end = dir > 0 ? line.length : -1;
61
+ if (line.length > maxScanLen) continue;
62
+ if (lineNo == where.line) pos = where.ch - (dir < 0 ? 1 : 0);
63
+ for (; pos != end; pos += dir) {
64
+ var ch = line.charAt(pos);
65
+ if (re.test(ch) && (style === undefined || cm.getTokenTypeAt(Pos(lineNo, pos + 1)) == style)) {
66
+ var match = matching[ch];
67
+ if ((match.charAt(1) == ">") == (dir > 0)) stack.push(ch);
68
+ else if (!stack.length) return {pos: Pos(lineNo, pos), ch: ch};
69
+ else stack.pop();
70
+ }
71
+ }
72
+ }
73
+ return lineNo - dir == (dir > 0 ? cm.lastLine() : cm.firstLine()) ? false : null;
74
+ }
75
+
76
+ function matchBrackets(cm, autoclear, config) {
77
+ // Disable brace matching in long lines, since it'll cause hugely slow updates
78
+ var maxHighlightLen = cm.state.matchBrackets.maxHighlightLineLength || 1000;
79
+ var marks = [], ranges = cm.listSelections();
80
+ for (var i = 0; i < ranges.length; i++) {
81
+ var match = ranges[i].empty() && findMatchingBracket(cm, ranges[i].head, config);
82
+ if (match && cm.getLine(match.from.line).length <= maxHighlightLen) {
83
+ var style = match.match ? "CodeMirror-matchingbracket" : "CodeMirror-nonmatchingbracket";
84
+ marks.push(cm.markText(match.from, Pos(match.from.line, match.from.ch + 1), {className: style}));
85
+ if (match.to && cm.getLine(match.to.line).length <= maxHighlightLen)
86
+ marks.push(cm.markText(match.to, Pos(match.to.line, match.to.ch + 1), {className: style}));
87
+ }
88
+ }
89
+
90
+ if (marks.length) {
91
+ // Kludge to work around the IE bug from issue #1193, where text
92
+ // input stops going to the textare whever this fires.
93
+ if (ie_lt8 && cm.state.focused) cm.focus();
94
+
95
+ var clear = function() {
96
+ cm.operation(function() {
97
+ for (var i = 0; i < marks.length; i++) marks[i].clear();
98
+ });
99
+ };
100
+ if (autoclear) setTimeout(clear, 800);
101
+ else return clear;
102
+ }
103
+ }
104
+
105
+ function doMatchBrackets(cm) {
106
+ cm.operation(function() {
107
+ if (cm.state.matchBrackets.currentlyHighlighted) {
108
+ cm.state.matchBrackets.currentlyHighlighted();
109
+ cm.state.matchBrackets.currentlyHighlighted = null;
110
+ }
111
+ cm.state.matchBrackets.currentlyHighlighted = matchBrackets(cm, false, cm.state.matchBrackets);
112
+ });
113
+ }
114
+
115
+ CodeMirror.defineOption("matchBrackets", false, function(cm, val, old) {
116
+ if (old && old != CodeMirror.Init) {
117
+ cm.off("cursorActivity", doMatchBrackets);
118
+ if (cm.state.matchBrackets && cm.state.matchBrackets.currentlyHighlighted) {
119
+ cm.state.matchBrackets.currentlyHighlighted();
120
+ cm.state.matchBrackets.currentlyHighlighted = null;
121
+ }
122
+ }
123
+ if (val) {
124
+ cm.state.matchBrackets = typeof val == "object" ? val : {};
125
+ cm.on("cursorActivity", doMatchBrackets);
126
+ }
127
+ });
128
+
129
+ CodeMirror.defineExtension("matchBrackets", function() {matchBrackets(this, true);});
130
+ CodeMirror.defineExtension("findMatchingBracket", function(pos, config, oldConfig){
131
+ // Backwards-compatibility kludge
132
+ if (oldConfig || typeof config == "boolean") {
133
+ if (!oldConfig) {
134
+ config = config ? {strict: true} : null
135
+ } else {
136
+ oldConfig.strict = config
137
+ config = oldConfig
138
+ }
139
+ }
140
+ return findMatchingBracket(this, pos, config)
141
+ });
142
+ CodeMirror.defineExtension("scanForBracket", function(pos, dir, style, config){
143
+ return scanForBracket(this, pos, dir, style, config);
144
+ });
145
+ });
@@ -1,30 +0,0 @@
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;
@@ -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
- });