@zohodesk/react-cli 0.0.1-beta.176 → 0.0.1-beta.178
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/.eslintignore +7 -7
- package/.eslintrc.js +180 -180
- package/.prettierrc +6 -6
- package/{CHANGELOG.md → CHANGELOG-fz.md} +0 -0
- package/Changelog.md +1019 -0
- package/README.md +1137 -1018
- package/bin/cli.js +482 -482
- package/docs/CustomChunks.md +26 -26
- package/docs/DevServerPort.md +39 -0
- package/docs/DevStart.md +18 -18
- package/docs/HoverActive.md +12 -12
- package/docs/InstallNode.md +28 -28
- package/docs/SelectorWeight.md +6 -6
- package/docs/TODOS.md +10 -10
- package/docs/ValueReplacer.md +60 -60
- package/docs/VariableConversion.md +724 -710
- package/docs/warnings_while_install.txt +35 -35
- package/files/eslintrc.js +62 -62
- package/files/prettierrc.js +3 -3
- package/lib/configs/resolvers.js +40 -0
- package/lib/configs/webpack.css.umd.config.js +4 -4
- package/lib/configs/webpack.dev.config.js +4 -11
- package/lib/configs/webpack.docs.config.js +4 -11
- package/lib/configs/webpack.impact.config.js +5 -7
- package/lib/configs/webpack.prod.config.js +9 -13
- package/lib/constants.js +31 -0
- package/lib/loaderUtils/configsAssetsLoaders.js +36 -36
- package/lib/loaders/workerLoader.js +9 -9
- package/lib/pluginUtils/getDevPlugins.js +5 -5
- package/lib/pluginUtils/getProdPlugins.js +5 -5
- package/lib/plugins/EFCPlugin.md +6 -6
- package/lib/plugins/I18NInjectIntoIndexPlugin.js +4 -4
- package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +38 -38
- package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +30 -30
- package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +8 -8
- package/lib/plugins/I18nSplitPlugin/I18nSplit.md +95 -95
- package/lib/plugins/I18nSplitPlugin/README.md +25 -25
- package/lib/plugins/I18nSplitPlugin/index.js +57 -57
- package/lib/plugins/ResourceHintsPlugin.js +17 -17
- package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +6 -6
- package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -30
- package/lib/plugins/ServiceWorkerPlugin.js +9 -9
- package/lib/plugins/TPHashMappingPlugin.js +4 -4
- package/lib/plugins/VariableConversionCollector.js +198 -98
- package/lib/postcss-plugins/RTLSplitPlugin.js +10 -10
- package/lib/postcss-plugins/__test__/test1Input.css +38 -38
- package/lib/postcss-plugins/__test__/test1Output.css +38 -38
- package/lib/postcss-plugins/hoverActivePlugin.js +3 -3
- package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +4 -2
- package/lib/postcss-plugins/variableModificationPlugin/index.js +2 -1
- package/lib/schemas/index.js +8 -0
- package/lib/servers/docsServerCore.js +13 -12
- package/lib/servers/httpsOptions.js +40 -9
- package/lib/servers/nowatchserver.js +12 -11
- package/lib/servers/server.js +23 -20
- package/lib/sh/pre-commit.sh +34 -34
- package/lib/sh/reportPublish.sh +45 -45
- package/lib/utils/buildstats.html +148 -148
- package/lib/utils/cssURLReplacer.js +30 -43
- package/lib/utils/getFileType.js +49 -0
- package/lib/utils/getOptions.js +13 -13
- package/lib/utils/resultSchema.json +73 -73
- package/npm8.md +9 -9
- package/package.json +121 -146
- package/postpublish.js +8 -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
- package/cert/Tsicsezwild-22-23.crt +0 -37
- package/cert/Tsicsezwild-22-23.key +0 -27
|
@@ -1,148 +1,148 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
|
|
5
|
-
<style>
|
|
6
|
-
#file {
|
|
7
|
-
font-family: 'Trebuchet MS', Arial, Helvetica, sans-serif;
|
|
8
|
-
border-collapse: collapse;
|
|
9
|
-
width: 100%;
|
|
10
|
-
}
|
|
11
|
-
#redTd {
|
|
12
|
-
color: red;
|
|
13
|
-
}
|
|
14
|
-
#greenTD {
|
|
15
|
-
color: green;
|
|
16
|
-
}
|
|
17
|
-
#file td,
|
|
18
|
-
#file th {
|
|
19
|
-
border: 1px solid #ddd;
|
|
20
|
-
padding: 8px;
|
|
21
|
-
text-align: center;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
#file tr:nth-child(even) {
|
|
25
|
-
background-color: #f2f2f2;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
#file tr:hover {
|
|
29
|
-
background-color: #ddd;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
#file th {
|
|
33
|
-
padding-top: 12px;
|
|
34
|
-
padding-bottom: 12px;
|
|
35
|
-
background-color: #2a2d36;
|
|
36
|
-
color: white;
|
|
37
|
-
}
|
|
38
|
-
#sizeTable {
|
|
39
|
-
float: left;
|
|
40
|
-
width: 50%;
|
|
41
|
-
}
|
|
42
|
-
#hashTable {
|
|
43
|
-
display: inline-block;
|
|
44
|
-
width: 50%;
|
|
45
|
-
}
|
|
46
|
-
</style>
|
|
47
|
-
<script type="text/javascript" src="./buildtrack.js"></script>
|
|
48
|
-
</head>
|
|
49
|
-
<body>
|
|
50
|
-
<div>
|
|
51
|
-
<div style="float: left;margin-right: 10px;">Branch Name:</div>
|
|
52
|
-
<h4 id="h4" style="margin: 0px;"></h4>
|
|
53
|
-
</div>
|
|
54
|
-
<div id="sizeTable">
|
|
55
|
-
<div>
|
|
56
|
-
<h3>Size changes</h3>
|
|
57
|
-
<h3></h3>
|
|
58
|
-
</div>
|
|
59
|
-
<table id="file" class="table table-bordered table-hover table-condensed">
|
|
60
|
-
<thead>
|
|
61
|
-
<tr>
|
|
62
|
-
<th title="Field #1">Name</th>
|
|
63
|
-
<th title="Field #2">Size / Diff</th>
|
|
64
|
-
<th title="Field #3">Size / Old</th>
|
|
65
|
-
<th title="Field #4">Size / New</th>
|
|
66
|
-
</tr>
|
|
67
|
-
</thead>
|
|
68
|
-
<tbody id="sizeTbody"></tbody>
|
|
69
|
-
</table>
|
|
70
|
-
</div>
|
|
71
|
-
<div id="hashTable">
|
|
72
|
-
<div>
|
|
73
|
-
<h3>Hash changes</h3>
|
|
74
|
-
<h3></h3>
|
|
75
|
-
</div>
|
|
76
|
-
<table id="file" class="table table-bordered table-hover table-condensed">
|
|
77
|
-
<thead>
|
|
78
|
-
<tr>
|
|
79
|
-
<th style="background-color: #4CAF50;" title="Field #1">Name</th>
|
|
80
|
-
<th style="background-color: #4CAF50;" title="Field #2">
|
|
81
|
-
Hash / Old
|
|
82
|
-
</th>
|
|
83
|
-
<th style="background-color: #4CAF50;" title="Field #3">
|
|
84
|
-
Hash / New
|
|
85
|
-
</th>
|
|
86
|
-
</tr>
|
|
87
|
-
</thead>
|
|
88
|
-
<tbody id="hashTbody"></tbody>
|
|
89
|
-
</table>
|
|
90
|
-
</div>
|
|
91
|
-
|
|
92
|
-
<script type="text/javascript">
|
|
93
|
-
function load() {
|
|
94
|
-
if (statsJson) {
|
|
95
|
-
var tdStringSize = '';
|
|
96
|
-
var tdStringHash = '';
|
|
97
|
-
if (statsJson.increased.length > 0) {
|
|
98
|
-
statsJson.increased.forEach(fileObj => {
|
|
99
|
-
let colorTD = '</td><td>';
|
|
100
|
-
if (fileObj.size.diff.split(' ').length > 2) {
|
|
101
|
-
colorTD = '</td><td id="greenTd">';
|
|
102
|
-
} else {
|
|
103
|
-
colorTD = '</td><td id="redTd">';
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
tdStringSize =
|
|
107
|
-
tdStringSize +
|
|
108
|
-
'<tr><td>' +
|
|
109
|
-
fileObj.name +
|
|
110
|
-
colorTD +
|
|
111
|
-
fileObj.size.diff +
|
|
112
|
-
'</td><td>' +
|
|
113
|
-
fileObj.size.old +
|
|
114
|
-
'</td><td>' +
|
|
115
|
-
fileObj.size.new +
|
|
116
|
-
'</td><tr>';
|
|
117
|
-
});
|
|
118
|
-
} else {
|
|
119
|
-
tdStringSize = '<tr><td></td><td></td><td></td></tr>';
|
|
120
|
-
}
|
|
121
|
-
document.getElementById('sizeTbody').innerHTML = tdStringSize;
|
|
122
|
-
if (statsJson.hashChanged.length > 0) {
|
|
123
|
-
statsJson.hashChanged.forEach(fileObj => {
|
|
124
|
-
tdStringHash =
|
|
125
|
-
tdStringHash +
|
|
126
|
-
'<tr><td>' +
|
|
127
|
-
fileObj.name +
|
|
128
|
-
'</td><td>' +
|
|
129
|
-
fileObj.hash.old +
|
|
130
|
-
'</td><td>' +
|
|
131
|
-
fileObj.hash.new +
|
|
132
|
-
'</td><tr>';
|
|
133
|
-
});
|
|
134
|
-
} else {
|
|
135
|
-
tdStringHash = '<tr><td></td><td></td><td></td></tr>';
|
|
136
|
-
}
|
|
137
|
-
document.getElementById('hashTbody').innerHTML = tdStringHash;
|
|
138
|
-
if (statsJson.branchName) {
|
|
139
|
-
document.getElementById('h4').innerHTML = statsJson.branchName;
|
|
140
|
-
} else {
|
|
141
|
-
document.getElementById('h4').innerHTML = 'Not specified';
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
load();
|
|
146
|
-
</script>
|
|
147
|
-
</body>
|
|
148
|
-
</html>
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
|
|
5
|
+
<style>
|
|
6
|
+
#file {
|
|
7
|
+
font-family: 'Trebuchet MS', Arial, Helvetica, sans-serif;
|
|
8
|
+
border-collapse: collapse;
|
|
9
|
+
width: 100%;
|
|
10
|
+
}
|
|
11
|
+
#redTd {
|
|
12
|
+
color: red;
|
|
13
|
+
}
|
|
14
|
+
#greenTD {
|
|
15
|
+
color: green;
|
|
16
|
+
}
|
|
17
|
+
#file td,
|
|
18
|
+
#file th {
|
|
19
|
+
border: 1px solid #ddd;
|
|
20
|
+
padding: 8px;
|
|
21
|
+
text-align: center;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
#file tr:nth-child(even) {
|
|
25
|
+
background-color: #f2f2f2;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
#file tr:hover {
|
|
29
|
+
background-color: #ddd;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
#file th {
|
|
33
|
+
padding-top: 12px;
|
|
34
|
+
padding-bottom: 12px;
|
|
35
|
+
background-color: #2a2d36;
|
|
36
|
+
color: white;
|
|
37
|
+
}
|
|
38
|
+
#sizeTable {
|
|
39
|
+
float: left;
|
|
40
|
+
width: 50%;
|
|
41
|
+
}
|
|
42
|
+
#hashTable {
|
|
43
|
+
display: inline-block;
|
|
44
|
+
width: 50%;
|
|
45
|
+
}
|
|
46
|
+
</style>
|
|
47
|
+
<script type="text/javascript" src="./buildtrack.js"></script>
|
|
48
|
+
</head>
|
|
49
|
+
<body>
|
|
50
|
+
<div>
|
|
51
|
+
<div style="float: left;margin-right: 10px;">Branch Name:</div>
|
|
52
|
+
<h4 id="h4" style="margin: 0px;"></h4>
|
|
53
|
+
</div>
|
|
54
|
+
<div id="sizeTable">
|
|
55
|
+
<div>
|
|
56
|
+
<h3>Size changes</h3>
|
|
57
|
+
<h3></h3>
|
|
58
|
+
</div>
|
|
59
|
+
<table id="file" class="table table-bordered table-hover table-condensed">
|
|
60
|
+
<thead>
|
|
61
|
+
<tr>
|
|
62
|
+
<th title="Field #1">Name</th>
|
|
63
|
+
<th title="Field #2">Size / Diff</th>
|
|
64
|
+
<th title="Field #3">Size / Old</th>
|
|
65
|
+
<th title="Field #4">Size / New</th>
|
|
66
|
+
</tr>
|
|
67
|
+
</thead>
|
|
68
|
+
<tbody id="sizeTbody"></tbody>
|
|
69
|
+
</table>
|
|
70
|
+
</div>
|
|
71
|
+
<div id="hashTable">
|
|
72
|
+
<div>
|
|
73
|
+
<h3>Hash changes</h3>
|
|
74
|
+
<h3></h3>
|
|
75
|
+
</div>
|
|
76
|
+
<table id="file" class="table table-bordered table-hover table-condensed">
|
|
77
|
+
<thead>
|
|
78
|
+
<tr>
|
|
79
|
+
<th style="background-color: #4CAF50;" title="Field #1">Name</th>
|
|
80
|
+
<th style="background-color: #4CAF50;" title="Field #2">
|
|
81
|
+
Hash / Old
|
|
82
|
+
</th>
|
|
83
|
+
<th style="background-color: #4CAF50;" title="Field #3">
|
|
84
|
+
Hash / New
|
|
85
|
+
</th>
|
|
86
|
+
</tr>
|
|
87
|
+
</thead>
|
|
88
|
+
<tbody id="hashTbody"></tbody>
|
|
89
|
+
</table>
|
|
90
|
+
</div>
|
|
91
|
+
|
|
92
|
+
<script type="text/javascript">
|
|
93
|
+
function load() {
|
|
94
|
+
if (statsJson) {
|
|
95
|
+
var tdStringSize = '';
|
|
96
|
+
var tdStringHash = '';
|
|
97
|
+
if (statsJson.increased.length > 0) {
|
|
98
|
+
statsJson.increased.forEach(fileObj => {
|
|
99
|
+
let colorTD = '</td><td>';
|
|
100
|
+
if (fileObj.size.diff.split(' ').length > 2) {
|
|
101
|
+
colorTD = '</td><td id="greenTd">';
|
|
102
|
+
} else {
|
|
103
|
+
colorTD = '</td><td id="redTd">';
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
tdStringSize =
|
|
107
|
+
tdStringSize +
|
|
108
|
+
'<tr><td>' +
|
|
109
|
+
fileObj.name +
|
|
110
|
+
colorTD +
|
|
111
|
+
fileObj.size.diff +
|
|
112
|
+
'</td><td>' +
|
|
113
|
+
fileObj.size.old +
|
|
114
|
+
'</td><td>' +
|
|
115
|
+
fileObj.size.new +
|
|
116
|
+
'</td><tr>';
|
|
117
|
+
});
|
|
118
|
+
} else {
|
|
119
|
+
tdStringSize = '<tr><td></td><td></td><td></td></tr>';
|
|
120
|
+
}
|
|
121
|
+
document.getElementById('sizeTbody').innerHTML = tdStringSize;
|
|
122
|
+
if (statsJson.hashChanged.length > 0) {
|
|
123
|
+
statsJson.hashChanged.forEach(fileObj => {
|
|
124
|
+
tdStringHash =
|
|
125
|
+
tdStringHash +
|
|
126
|
+
'<tr><td>' +
|
|
127
|
+
fileObj.name +
|
|
128
|
+
'</td><td>' +
|
|
129
|
+
fileObj.hash.old +
|
|
130
|
+
'</td><td>' +
|
|
131
|
+
fileObj.hash.new +
|
|
132
|
+
'</td><tr>';
|
|
133
|
+
});
|
|
134
|
+
} else {
|
|
135
|
+
tdStringHash = '<tr><td></td><td></td><td></td></tr>';
|
|
136
|
+
}
|
|
137
|
+
document.getElementById('hashTbody').innerHTML = tdStringHash;
|
|
138
|
+
if (statsJson.branchName) {
|
|
139
|
+
document.getElementById('h4').innerHTML = statsJson.branchName;
|
|
140
|
+
} else {
|
|
141
|
+
document.getElementById('h4').innerHTML = 'Not specified';
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
load();
|
|
146
|
+
</script>
|
|
147
|
+
</body>
|
|
148
|
+
</html>
|
|
@@ -3,19 +3,26 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.cssUrlReplacer = void 0;
|
|
7
|
+
Object.defineProperty(exports, "getFileType", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return _getFileType.getFileType;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
exports.getUrls = void 0;
|
|
7
14
|
|
|
8
15
|
var _fs = _interopRequireDefault(require("fs"));
|
|
9
16
|
|
|
10
|
-
var _path = _interopRequireDefault(require("path"));
|
|
11
|
-
|
|
12
17
|
var _crypto = _interopRequireDefault(require("crypto"));
|
|
13
18
|
|
|
19
|
+
var _getFileType = require("./getFileType");
|
|
20
|
+
|
|
14
21
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
22
|
|
|
16
|
-
|
|
23
|
+
const urlRegex = /url\(.*?\)/g;
|
|
17
24
|
|
|
18
|
-
|
|
25
|
+
const getHash = (file, isPath = false, needSubStr = true) => {
|
|
19
26
|
let hash = _crypto.default.createHash('md5');
|
|
20
27
|
|
|
21
28
|
if (isPath) {
|
|
@@ -28,45 +35,25 @@ let getHash = (file, isPath = false, needSubStr = true) => {
|
|
|
28
35
|
return hash ? needSubStr ? hash.substring(0, 20) : hash : null;
|
|
29
36
|
};
|
|
30
37
|
|
|
31
|
-
|
|
32
|
-
let {
|
|
33
|
-
ext
|
|
34
|
-
} = _path.default.parse(file);
|
|
35
|
-
|
|
36
|
-
if (ext === '.gif' || ext === '.png' || ext === '.jpg' || ext === '.jpeg' || ext === '.ico') {
|
|
37
|
-
return 'image';
|
|
38
|
-
} else if (ext === '.svg' || ext === '.woff' || ext === '.eot' || ext === '.ttf' || ext === '.woff2') {
|
|
39
|
-
return 'font';
|
|
40
|
-
} else if (ext === '.js') {
|
|
41
|
-
return 'js';
|
|
42
|
-
} else if (ext === '.css') {
|
|
43
|
-
return 'css';
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return null;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
exports.getFileType = getFileType;
|
|
50
|
-
|
|
51
|
-
let formatUrl = str => {
|
|
38
|
+
const formatUrl = str => {
|
|
52
39
|
let char = str.includes('"') ? '"' : str.includes('\'') ? '\'' : '(';
|
|
53
|
-
|
|
54
|
-
|
|
40
|
+
const statingIdx = str.indexOf(char) + 1;
|
|
41
|
+
const substr = str.substring(statingIdx, str.length);
|
|
55
42
|
char = char === '(' ? ')' : char;
|
|
56
43
|
return substr.substring(0, substr.indexOf(char));
|
|
57
44
|
};
|
|
58
45
|
|
|
59
|
-
|
|
60
|
-
|
|
46
|
+
const getUrls = css => {
|
|
47
|
+
const urlMatches = css.match(urlRegex);
|
|
61
48
|
let src = css;
|
|
62
49
|
|
|
63
50
|
if (urlMatches) {
|
|
64
|
-
|
|
51
|
+
const patterns = {};
|
|
65
52
|
urlMatches.forEach(pattern => {
|
|
66
|
-
|
|
67
|
-
|
|
53
|
+
const url = formatUrl(pattern);
|
|
54
|
+
const hash = getHash(url);
|
|
68
55
|
patterns[url] = hash;
|
|
69
|
-
|
|
56
|
+
const regex = new RegExp(pattern.replace(/([<>*()?${}|])/g, '\\$1'), 'g');
|
|
70
57
|
src = src.replace(regex, hash);
|
|
71
58
|
});
|
|
72
59
|
return {
|
|
@@ -78,12 +65,12 @@ let getUrls = css => {
|
|
|
78
65
|
|
|
79
66
|
exports.getUrls = getUrls;
|
|
80
67
|
|
|
81
|
-
|
|
82
|
-
|
|
68
|
+
const cssUrlReplacer = (css, domains, chunkHash = {}) => {
|
|
69
|
+
const obj = getUrls(css);
|
|
83
70
|
let src = css;
|
|
84
71
|
|
|
85
72
|
if (obj) {
|
|
86
|
-
|
|
73
|
+
const patterns = obj.urls;
|
|
87
74
|
src = obj.css;
|
|
88
75
|
Object.keys(patterns).forEach(pattern => {
|
|
89
76
|
let urlParts = pattern.split('/');
|
|
@@ -97,20 +84,20 @@ let cssUrlReplacer = (css, domains, chunkHash = {}) => {
|
|
|
97
84
|
fileName = fileName.replace(/\?.*$/g, '');
|
|
98
85
|
}
|
|
99
86
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
87
|
+
const hash = patterns[pattern];
|
|
88
|
+
const filename = fileName.replace(/(\?|#).*?$/g, '');
|
|
89
|
+
const regex = new RegExp(hash, 'g');
|
|
103
90
|
let {
|
|
104
91
|
hashedName
|
|
105
92
|
} = chunkHash[filename] || fileName;
|
|
106
93
|
|
|
107
94
|
if (domains && typeof urlParts[0] === 'string' && !urlParts[0].includes('http')) {
|
|
108
|
-
|
|
95
|
+
const {
|
|
109
96
|
font,
|
|
110
97
|
image
|
|
111
98
|
} = domains;
|
|
112
|
-
|
|
113
|
-
|
|
99
|
+
const type = (0, _getFileType.getFileType)(filename);
|
|
100
|
+
const customPath = type === 'image' ? `${image}/images` : type === 'font' ? `${font}/fonts` : urlParts.join('/');
|
|
114
101
|
urlParts = customPath.split('/');
|
|
115
102
|
}
|
|
116
103
|
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getFileType = getFileType;
|
|
7
|
+
|
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
/* eslint-disable no-use-before-define */
|
|
13
|
+
function getFileType(file) {
|
|
14
|
+
const {
|
|
15
|
+
ext
|
|
16
|
+
} = _path.default.parse(file);
|
|
17
|
+
|
|
18
|
+
if (isImageFileExt(ext)) {
|
|
19
|
+
return 'image';
|
|
20
|
+
} else if (isFontFileExt(ext)) {
|
|
21
|
+
return 'font';
|
|
22
|
+
} else if (isVideoFileExt(ext)) {
|
|
23
|
+
return 'video';
|
|
24
|
+
} else if (isAudioFileExt(ext)) {
|
|
25
|
+
return 'audio';
|
|
26
|
+
} else if (ext === '.js') {
|
|
27
|
+
return 'js';
|
|
28
|
+
} else if (ext === '.css') {
|
|
29
|
+
return 'css';
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function isImageFileExt(ext) {
|
|
36
|
+
return ext === '.gif' || ext === '.png' || ext === '.jpg' || ext === '.jpeg' || ext === '.webp' || ext === '.ico';
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function isFontFileExt(ext) {
|
|
40
|
+
return ext === '.svg' || ext === '.woff' || ext === '.eot' || ext === '.ttf' || ext === '.woff2';
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function isVideoFileExt(ext) {
|
|
44
|
+
return ext === '.mp4' || ext === '.webm';
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function isAudioFileExt(ext) {
|
|
48
|
+
return ext === '.ogg';
|
|
49
|
+
}
|
package/lib/utils/getOptions.js
CHANGED
|
@@ -26,14 +26,14 @@ const NPM_CONFIG_PREFIX = 'npm_config_'; // TODO: we have to do option parse log
|
|
|
26
26
|
// // clone:type
|
|
27
27
|
|
|
28
28
|
const processEnv = {};
|
|
29
|
-
|
|
29
|
+
const keysWithColon = [];
|
|
30
30
|
Object.keys(process.env).filter(key => key.startsWith(NPM_CONFIG_PREFIX)).forEach(key => {
|
|
31
|
-
|
|
31
|
+
const nkey = key.slice(NPM_CONFIG_PREFIX.length);
|
|
32
32
|
processEnv[nkey] = process.env[key];
|
|
33
33
|
nkey.includes(':') && keysWithColon.push(nkey);
|
|
34
34
|
});
|
|
35
35
|
keysWithColon.forEach(key => {
|
|
36
|
-
|
|
36
|
+
const nkey = key.replace(/:/g, '_');
|
|
37
37
|
|
|
38
38
|
if (processEnv[nkey]) {
|
|
39
39
|
throw Error('there is some options conflict', key, nkey);
|
|
@@ -60,8 +60,8 @@ function getCWD() {
|
|
|
60
60
|
let cwd = process.cwd();
|
|
61
61
|
|
|
62
62
|
try {
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
const ress = (0, _child_process.execSync)('npm bin').toString();
|
|
64
|
+
const i = ress.lastIndexOf('node_modules');
|
|
65
65
|
cwd = i === -1 ? cwd : ress.slice(0, i);
|
|
66
66
|
} catch (error) {
|
|
67
67
|
console.log(error);
|
|
@@ -73,7 +73,7 @@ function getCWD() {
|
|
|
73
73
|
|
|
74
74
|
args.forEach(option => {
|
|
75
75
|
if (/^--./.test(option)) {
|
|
76
|
-
|
|
76
|
+
const equIndex = option.indexOf('='); // equIndex = equIndex === -1 ? option.length : equIndex;
|
|
77
77
|
|
|
78
78
|
let key = option.slice(2, equIndex);
|
|
79
79
|
let value = option.slice(equIndex + 1);
|
|
@@ -88,10 +88,10 @@ args.forEach(option => {
|
|
|
88
88
|
}
|
|
89
89
|
});
|
|
90
90
|
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
const defaulter = (target, source) => {
|
|
92
|
+
const defaultObject = {};
|
|
93
93
|
Object.keys(target).forEach(key => {
|
|
94
|
-
|
|
94
|
+
const data = target[key];
|
|
95
95
|
|
|
96
96
|
if (data && typeof data === 'object') {
|
|
97
97
|
if (Array.isArray(data)) {
|
|
@@ -151,21 +151,21 @@ function deprecationSupport(options) {
|
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
-
|
|
154
|
+
const getOptions = () => {
|
|
155
155
|
if (global.reactCLIOptions) {
|
|
156
156
|
return global.reactCLIOptions;
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
-
|
|
159
|
+
const appPath = process.cwd();
|
|
160
160
|
let userSchemas;
|
|
161
161
|
|
|
162
|
-
|
|
162
|
+
const packagePath = _path.default.join(appPath, 'package.json');
|
|
163
163
|
|
|
164
164
|
if (_fs.default.existsSync(packagePath)) {
|
|
165
165
|
userSchemas = require(packagePath)['react-cli'] || {};
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
-
|
|
168
|
+
const options = defaulter(_schemas.default, userSchemas || {}); // for future may be for npm 8 edge cases
|
|
169
169
|
|
|
170
170
|
options.npmVersion = getNpmVersion();
|
|
171
171
|
options.cwd = getCWD();
|