@zohodesk/react-cli 1.0.2 → 1.0.3-beta.1
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +24 -0
- package/bin/cli.js +1 -1
- package/lib/common/testPattern.js +0 -2
- package/lib/common/valueReplacer.js +1 -3
- package/lib/configs/resolvers.js +14 -3
- package/lib/loaderUtils/getCSSLoaders.js +2 -7
- package/lib/loaders/selectorMappingLoader.js +9 -9
- package/lib/logger.js +20 -0
- package/lib/pluginUtils/getDevPlugins.js +5 -0
- package/lib/pluginUtils/getProdPlugins.js +4 -0
- package/lib/plugins/CustomAttributePlugin.js +82 -0
- package/lib/plugins/CustomAttributePlugin.md +35 -0
- package/lib/plugins/EFCPlugin.js +9 -9
- package/lib/plugins/EFCTemplatePlugin.js +10 -12
- package/lib/plugins/I18NInjectIntoIndexPlugin.js +8 -9
- package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +2 -3
- package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +2 -7
- package/lib/plugins/I18nSplitPlugin/index.js +1 -1
- package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +8 -8
- package/lib/plugins/SelectorPlugin.js +4 -10
- package/lib/plugins/VariableConversionCollector.js +0 -4
- package/lib/postcss-plugins/IncludePlugin.js +0 -1
- package/lib/postcss-plugins/RTLSplitPlugin.js +4 -10
- package/lib/postcss-plugins/ValueReplacer.js +2 -4
- package/lib/postcss-plugins/hoverActivePlugin.js +0 -6
- package/lib/postcss-plugins/variableModificationPlugin/index.js +1 -2
- package/lib/postcss-plugins/variableModifier.js +24 -58
- package/lib/schemas/index.js +8 -1
- package/lib/servers/devBuild.js +13 -11
- package/lib/servers/httpsOptions.js +12 -13
- package/lib/servers/nowatchserver.js +5 -3
- package/lib/servers/requireLocalOrGlobal.js +61 -0
- package/lib/servers/server.js +1 -3
- package/lib/utils/cssClassNameGenerate.js +11 -12
- package/npm-shrinkwrap.json +14407 -0
- package/package.json +3 -2
- package/result.json +0 -1
- package/unittest/index.html +0 -37
@@ -11,6 +11,8 @@ var _fs = require("fs");
|
|
11
11
|
|
12
12
|
var _path = require("path");
|
13
13
|
|
14
|
+
var _logger = require("../../../logger");
|
15
|
+
|
14
16
|
function isComment(line) {
|
15
17
|
return line[0] === '#';
|
16
18
|
}
|
@@ -18,7 +20,7 @@ function isComment(line) {
|
|
18
20
|
function getPropertiesAsJSON(filePath) {
|
19
21
|
try {
|
20
22
|
const data = (0, _fs.readFileSync)(filePath);
|
21
|
-
|
23
|
+
const source = data.toString();
|
22
24
|
const i18nObj = {};
|
23
25
|
source.split(/\r?\n\r?/).forEach(fline => {
|
24
26
|
const line = fline.trim();
|
@@ -42,7 +44,7 @@ function getPropertiesAsJSON(filePath) {
|
|
42
44
|
}
|
43
45
|
|
44
46
|
function getLang(file) {
|
45
|
-
|
47
|
+
const underScoreIndex = file.indexOf('_');
|
46
48
|
let language = 'en_US';
|
47
49
|
|
48
50
|
if (underScoreIndex !== -1) {
|
@@ -68,26 +70,24 @@ function getAllI18n({
|
|
68
70
|
const filePath = (0, _path.join)(context, file);
|
69
71
|
|
70
72
|
if (exclude.test(filePath) || !include.test(filePath)) {
|
71
|
-
// console.log('exclude', filePath);
|
72
73
|
return;
|
73
|
-
}
|
74
|
-
|
74
|
+
}
|
75
75
|
|
76
76
|
const i18n = getPropertiesAsJSON(filePath);
|
77
77
|
allLangI18n[getLang(file)] = disableDefault ? i18n : Object.assign({}, jsResourceI18nKeys, i18n);
|
78
78
|
});
|
79
79
|
return allLangI18n;
|
80
80
|
} catch (err) {
|
81
|
-
|
81
|
+
(0, _logger.errorLogger)(err);
|
82
82
|
return {};
|
83
83
|
}
|
84
84
|
}
|
85
85
|
|
86
86
|
function jsonToString(json, keySeperator) {
|
87
87
|
let str = '{';
|
88
|
-
|
88
|
+
const keys = Object.keys(json);
|
89
89
|
keys.forEach((key, i) => {
|
90
|
-
|
90
|
+
const value = json[key];
|
91
91
|
|
92
92
|
if (!value) {
|
93
93
|
return;
|
@@ -46,21 +46,16 @@ function rootConvertor(rootOriginal, defaultSelector, data, filename, excludeStr
|
|
46
46
|
if (singleSelectorStr.includes(']')) {
|
47
47
|
if (singleSelectorStr.slice(singleSelectorStr.lastIndexOf(']') + 2).trim() === '') {
|
48
48
|
return;
|
49
|
-
}
|
50
|
-
// rule.slice(rule.lastIndexOf(']') + 2).trim(),
|
51
|
-
// rule.slice(rule.lastIndexOf(']') + 2).trim() !== ''
|
52
|
-
// );
|
53
|
-
|
54
|
-
|
55
|
-
selectorArr[index] = `${singleSelectorStr.slice(0, singleSelectorStr.lastIndexOf(']') + 1).trim()} ${defaultSelector}${singleSelectorStr.slice(singleSelectorStr.lastIndexOf(']') + 2).trim()}`; // console.log(ruleArr[index]);
|
49
|
+
}
|
56
50
|
|
51
|
+
selectorArr[index] = `${singleSelectorStr.slice(0, singleSelectorStr.lastIndexOf(']') + 1).trim()} ${defaultSelector}${singleSelectorStr.slice(singleSelectorStr.lastIndexOf(']') + 2).trim()}`;
|
57
52
|
return;
|
58
53
|
}
|
59
54
|
|
60
55
|
const keyMatch = checkFilename(filename, data);
|
61
56
|
selectorArr[index] = data[keyMatch] ? `${data[keyMatch].defaultSelector}${singleSelectorStr}` : `${defaultSelector}${singleSelectorStr}`;
|
62
57
|
});
|
63
|
-
rule.selector = selectorArr.join(',\n');
|
58
|
+
rule.selector = selectorArr.join(',\n');
|
64
59
|
});
|
65
60
|
return rootOriginal;
|
66
61
|
}
|
@@ -103,8 +98,7 @@ class SelectorPlugin {
|
|
103
98
|
|
104
99
|
if (ignoreFile(this.exclude, filename)) {
|
105
100
|
return;
|
106
|
-
}
|
107
|
-
|
101
|
+
}
|
108
102
|
|
109
103
|
module.content = //new RawSource(
|
110
104
|
rootConvertor(rootOriginal, defaultSelector, data, filename, excludeStrings).toString(); // );
|
@@ -190,9 +190,6 @@ class VariableConversionCollector {
|
|
190
190
|
variables[extractedValue] = decl.prop;
|
191
191
|
} else {
|
192
192
|
if (new RegExp(supportedProps.join('|'), 'gi').test(decl.prop)) {
|
193
|
-
// console.log(
|
194
|
-
// `${extractedValue} : ${variables[extractedValue]} already exists please check!`
|
195
|
-
// );
|
196
193
|
if (errorsAllowed.MULTIPLE_OCCURANCES) {
|
197
194
|
const errObj = {
|
198
195
|
decl,
|
@@ -206,7 +203,6 @@ class VariableConversionCollector {
|
|
206
203
|
}
|
207
204
|
}
|
208
205
|
} else {
|
209
|
-
// console.log(decl.prop);
|
210
206
|
if (/^--/gi.test(decl.prop) && val.trim() !== '' && !variables[decl.prop]) {
|
211
207
|
if (!Object.keys(variablesRead.ignore).includes(decl.prop)) {
|
212
208
|
unassigned[decl.prop] = variables[decl.prop];
|
@@ -13,7 +13,6 @@ module.exports = _postcss.default.plugin('postcss-include-files', opts => {
|
|
13
13
|
const includeFile = opts.include.some(file => inputFile.indexOf(file) !== -1);
|
14
14
|
|
15
15
|
if (includeFile) {
|
16
|
-
// console.log(inputFile);
|
17
16
|
const handler = response => response.messages.forEach(msg => result.messages.push(msg));
|
18
17
|
|
19
18
|
return (0, _postcss.default)(plugins).process(root, {
|
@@ -18,7 +18,6 @@ const oppositeDir = {
|
|
18
18
|
};
|
19
19
|
|
20
20
|
function compareSelector(selector1, selector2) {
|
21
|
-
// console.log({ selector1, selector2 }, selector1 === selector2);
|
22
21
|
return selector1 === selector2;
|
23
22
|
}
|
24
23
|
|
@@ -66,7 +65,6 @@ function mergeIfSameSelector(rule) {
|
|
66
65
|
|
67
66
|
|
68
67
|
function removeIfOppsiteDirRule(rule, direction, rootOptions) {
|
69
|
-
// console.log({ rule, type: rule.type });
|
70
68
|
const selectors = rule.selector.split(/\s*,\s*/); // NOTE: if we use opposite dir selector as custom override reason,
|
71
69
|
// and compain normal selector with it, In this case
|
72
70
|
// we just a have to remove that selector only not full rule
|
@@ -87,11 +85,10 @@ function removeIfOppsiteDirRule(rule, direction, rootOptions) {
|
|
87
85
|
}
|
88
86
|
|
89
87
|
function removeIfOppsiteDirKeyframe(rule, direction) {
|
90
|
-
|
91
|
-
|
88
|
+
const name = rule.params;
|
89
|
+
const keyFrameDirName = name.slice(name.lastIndexOf('-') + 1);
|
92
90
|
|
93
91
|
if (keyFrameDirName === oppositeDir[direction]) {
|
94
|
-
// console.log({ m: 'removed', keyFrameName: rule.params });
|
95
92
|
rule.remove();
|
96
93
|
}
|
97
94
|
}
|
@@ -109,12 +106,10 @@ function separateSingleDir(root, direction, rootOptions) {
|
|
109
106
|
|
110
107
|
function separateRtlAndLtr(css, rootOptions) {
|
111
108
|
// let processor = postcss([]).process(css);
|
112
|
-
|
113
|
-
// console.log(processor, root);
|
109
|
+
const root = postcss.parse(css); // let { root } = processor;
|
114
110
|
// NOTE: I did first rtl then ltr , Because for ltr I use original root ref
|
115
111
|
|
116
|
-
const rtlRoot = separateSingleDir(root.clone(), 'rtl', rootOptions);
|
117
|
-
|
112
|
+
const rtlRoot = separateSingleDir(root.clone(), 'rtl', rootOptions);
|
118
113
|
const ltrRoot = separateSingleDir(root, 'ltr', rootOptions);
|
119
114
|
return {
|
120
115
|
ltrRoot,
|
@@ -132,7 +127,6 @@ function separateRtlAndLtr(css, rootOptions) {
|
|
132
127
|
// // root.append(postcss.comment({ text: 'comment' }));
|
133
128
|
// root.append(postcss.comment({ text: 'this is spliting part ' }));
|
134
129
|
// root.append(rtlRoot);
|
135
|
-
// //console.log({root, roots:root+""}, root+"")
|
136
130
|
// // Transform CSS AST here
|
137
131
|
// }
|
138
132
|
// );
|
@@ -24,13 +24,12 @@ root => {
|
|
24
24
|
root.walkDecls(decl => {
|
25
25
|
valueReplacer.forEach(obj => {
|
26
26
|
if (obj.props.indexOf(decl.prop) !== -1) {
|
27
|
-
|
27
|
+
const ks = Object.keys(obj.values).sort((a, b) => b.length - a.length);
|
28
28
|
ks.forEach(k => {
|
29
29
|
decl.value = decl.value.replace(k, obj.values[k]);
|
30
30
|
}); //decl.value = obj.values[decl.value];
|
31
31
|
}
|
32
|
-
}); //
|
33
|
-
// Transform CSS AST here
|
32
|
+
}); // Transform CSS AST here
|
34
33
|
}); // root.walkDecls(decl => {
|
35
34
|
// valueReplacer.forEach(obj => {
|
36
35
|
// if (
|
@@ -40,7 +39,6 @@ root => {
|
|
40
39
|
// decl.value = obj.values[decl.value];
|
41
40
|
// }
|
42
41
|
// });
|
43
|
-
// //console.log({root, roots:root+""}, root+"")
|
44
42
|
// // Transform CSS AST here
|
45
43
|
// });
|
46
44
|
});
|
@@ -158,7 +158,6 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', mediaQueryHover
|
|
158
158
|
|
159
159
|
function mediaCommaQuery(rule, index) {
|
160
160
|
if (rule.parent.params !== undefined && !rule.parent.params.includes('hover')) {
|
161
|
-
//console.log(hovMed, actMed);
|
162
161
|
let newSelector = '';
|
163
162
|
const {
|
164
163
|
hovMed,
|
@@ -232,7 +231,6 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', mediaQueryHover
|
|
232
231
|
}
|
233
232
|
|
234
233
|
function commaQuery(rule, index) {
|
235
|
-
//console.log("comma" , rule.selector.split('\n'));
|
236
234
|
let newSelector = '';
|
237
235
|
const hovQueries = [];
|
238
236
|
rule.selector.split(/\s*,\s*/).forEach(_subrule => {
|
@@ -288,13 +286,10 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', mediaQueryHover
|
|
288
286
|
});
|
289
287
|
rootOriginal.walkRules(/:hover/i, (rule, index) => {
|
290
288
|
// media hover query with ',' ' ' '+'
|
291
|
-
// console.log("media query" , rule.selector)
|
292
289
|
if (rule.parent.type === 'atrule' && rule.selector.includes(',')) {
|
293
|
-
//console.log("media comma", rule.selector)
|
294
290
|
mediaCommaQuery(rule, index);
|
295
291
|
} else {
|
296
292
|
// plus, space and other media queries
|
297
|
-
//console.log("media", rule.selector)
|
298
293
|
mediaQuery(rule, index);
|
299
294
|
} // usual hover query
|
300
295
|
|
@@ -311,7 +306,6 @@ module.exports = _postcss.default.plugin('postcss-mobile-hover', mediaQueryHover
|
|
311
306
|
if (rule.selector.includes(',')) {
|
312
307
|
commaQuery(rule, index);
|
313
308
|
} else if (rule.selector.match(/ +|\++/g)) {
|
314
|
-
//console.log("plus or space" , rule.selector);
|
315
309
|
if (rule.selector.includes('hover')) {
|
316
310
|
hoverRules.push({
|
317
311
|
rule,
|
@@ -206,8 +206,7 @@ module.exports = {
|
|
206
206
|
}
|
207
207
|
|
208
208
|
if (settingsObject[decl.prop] && !decl.value.includes('var(--')) {
|
209
|
-
const settings = settingsObject[decl.prop];
|
210
|
-
|
209
|
+
const settings = settingsObject[decl.prop];
|
211
210
|
const {
|
212
211
|
allowed,
|
213
212
|
range
|
@@ -7,19 +7,19 @@ const path = require('path');
|
|
7
7
|
const fs = require('fs');
|
8
8
|
|
9
9
|
function populateArray(start, end) {
|
10
|
-
|
10
|
+
const temp = [];
|
11
11
|
|
12
|
-
for (
|
12
|
+
for (let i = start; i < end; i++) {
|
13
13
|
temp.push(i);
|
14
14
|
}
|
15
15
|
|
16
16
|
return temp;
|
17
17
|
}
|
18
18
|
|
19
|
-
|
19
|
+
const allwdVars = {
|
20
20
|
'font-size': ['px', 'em']
|
21
21
|
};
|
22
|
-
|
22
|
+
const numberObject = {
|
23
23
|
'font-size': {
|
24
24
|
allowed: ['px', 'em'],
|
25
25
|
replacements: {
|
@@ -89,27 +89,21 @@ function hasIgnoreComment(node) {
|
|
89
89
|
return node ? node.type == 'comment' ? node.text == 'Variable:Ignore' ? true : false : false : false;
|
90
90
|
}
|
91
91
|
|
92
|
-
|
92
|
+
const errors = [];
|
93
93
|
module.exports = postcss.plugin('postcss-variable-report', () => rootOriginal => {
|
94
|
-
// console.log('inside postcss plugin')
|
95
|
-
// fs.writeFile('./css_error.log', '\r\nLog File: \r\n\r\n', (err) => {
|
96
|
-
// if(err)console.log(err);
|
97
|
-
// });
|
98
|
-
// console.log(rootOriginal.source.input.file);
|
99
94
|
if (!rootOriginal.source.input.file.includes('css_error')) {
|
100
95
|
rootOriginal.walkRules(rule => {
|
101
96
|
rule.walkDecls((decl, position) => {
|
102
97
|
// case font-size
|
103
98
|
if (!hasIgnoreComment(rule.nodes[position - 1])) {
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
let path = rootOriginal.source.input.from;
|
99
|
+
const unit = decl.value.replace(/[0-9]/g, '');
|
100
|
+
const settings = numberObject[decl.prop];
|
101
|
+
const path = rootOriginal.source.input.from;
|
108
102
|
let filename = path.split('\\');
|
109
103
|
filename = filename[filename.length - 1];
|
110
104
|
|
111
105
|
if (decl.prop === 'font-size' || decl.prop === 'margin-left' || decl.prop === 'margin-right' || decl.prop === 'margin-top' || decl.prop === 'margin-bottom') {
|
112
|
-
|
106
|
+
const {
|
113
107
|
allowed,
|
114
108
|
replacements,
|
115
109
|
available
|
@@ -118,12 +112,11 @@ module.exports = postcss.plugin('postcss-variable-report', () => rootOriginal =>
|
|
118
112
|
if (!rootOriginal.source.input.from.includes('node_modules')) {
|
119
113
|
if (unit != 0) {
|
120
114
|
if (allowed.includes(unit)) {
|
121
|
-
// console.log(available, parseInt(decl.value))
|
122
115
|
if (available.includes(parseInt(decl.value))) {
|
123
116
|
// replacementValues[unit].push({[decl.value] : replacements[unit].replace('$$', parseInt(decl.value))})
|
124
|
-
decl.value = replacements[unit].replace('$$', parseInt(decl.value));
|
117
|
+
decl.value = replacements[unit].replace('$$', parseInt(decl.value));
|
125
118
|
} else {
|
126
|
-
|
119
|
+
const err = {
|
127
120
|
prop: decl.prop,
|
128
121
|
value: decl.value,
|
129
122
|
filename,
|
@@ -135,7 +128,7 @@ module.exports = postcss.plugin('postcss-variable-report', () => rootOriginal =>
|
|
135
128
|
errors.push(err);
|
136
129
|
}
|
137
130
|
} else {
|
138
|
-
|
131
|
+
const err = {
|
139
132
|
prop: decl.prop,
|
140
133
|
value: decl.value,
|
141
134
|
filename,
|
@@ -149,36 +142,33 @@ module.exports = postcss.plugin('postcss-variable-report', () => rootOriginal =>
|
|
149
142
|
}
|
150
143
|
}
|
151
144
|
} else if (decl.prop === 'margin') {
|
152
|
-
|
145
|
+
const {
|
153
146
|
allowed,
|
154
147
|
replacements,
|
155
148
|
available
|
156
|
-
} = settings;
|
157
|
-
|
158
|
-
let valArr = decl.value.split(' '); //console.log(valArr)
|
159
|
-
//console.log(allowed, replacements, available)
|
160
|
-
|
149
|
+
} = settings;
|
150
|
+
const valArr = decl.value.split(' ');
|
161
151
|
let hasError = false;
|
162
152
|
let newVal = '';
|
163
153
|
valArr.forEach(val => {
|
164
|
-
|
165
|
-
|
154
|
+
const unit = val.replace(parseInt(val), '');
|
155
|
+
const numVal = parseInt(val);
|
166
156
|
|
167
157
|
if (unit != 0) {
|
168
158
|
if (allowed.includes(unit)) {
|
169
159
|
if (available.includes(numVal)) {
|
170
160
|
if (numVal >= 0) {
|
171
161
|
if (!hasError) {
|
172
|
-
newVal += replacements[unit].replace('$$', numVal)
|
162
|
+
newVal += `${replacements[unit].replace('$$', numVal)} `;
|
173
163
|
}
|
174
164
|
} else {
|
175
165
|
if (!hasError) {
|
176
|
-
newVal += `calc(${replacements[unit].replace('$$', numVal * -1)} * -1)` +
|
166
|
+
newVal += `calc(${replacements[unit].replace('$$', numVal * -1)} * -1)` + ' ';
|
177
167
|
}
|
178
168
|
}
|
179
169
|
} else {
|
180
170
|
hasError = true;
|
181
|
-
|
171
|
+
const err = {
|
182
172
|
prop: decl.prop,
|
183
173
|
value: numVal,
|
184
174
|
filename,
|
@@ -191,7 +181,7 @@ module.exports = postcss.plugin('postcss-variable-report', () => rootOriginal =>
|
|
191
181
|
}
|
192
182
|
} else {
|
193
183
|
hasError = true;
|
194
|
-
|
184
|
+
const err = {
|
195
185
|
prop: decl.prop,
|
196
186
|
value: decl.value,
|
197
187
|
filename,
|
@@ -211,34 +201,10 @@ module.exports = postcss.plugin('postcss-variable-report', () => rootOriginal =>
|
|
211
201
|
}
|
212
202
|
}
|
213
203
|
});
|
214
|
-
});
|
215
|
-
|
216
|
-
// else{
|
217
|
-
// console.log('updated successfully');
|
218
|
-
// }
|
219
|
-
// })
|
220
|
-
// console.log(errors)
|
221
|
-
|
222
|
-
let errorArr = [];
|
204
|
+
});
|
205
|
+
const errorArr = [];
|
223
206
|
errors.forEach(errStr => {
|
224
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`);
|
225
|
-
});
|
226
|
-
// if(err){
|
227
|
-
// console.log(err);
|
228
|
-
// }
|
229
|
-
//});
|
230
|
-
// errorArr.forEach(err => {
|
231
|
-
// let data = `\n{\n${err}\n},\n`;
|
232
|
-
// //fs.appendFile('./css_error.log',data,(err)=>{
|
233
|
-
// // if(err){
|
234
|
-
// // console.log(err);
|
235
|
-
// // }
|
236
|
-
// //})
|
237
|
-
// });
|
238
|
-
// fs.writeFileSync('./css_error.log','');
|
239
|
-
// errorArr.forEach(err => {
|
240
|
-
// let data = `\n{\n${err}\n},\n`;
|
241
|
-
// fs.appendFileSync('./css_error.log',data);
|
242
|
-
// });
|
208
|
+
});
|
243
209
|
}
|
244
210
|
});
|
package/lib/schemas/index.js
CHANGED
@@ -92,7 +92,7 @@ var _default = {
|
|
92
92
|
},
|
93
93
|
app: {
|
94
94
|
moduleResolvePath: {
|
95
|
-
value: '',
|
95
|
+
value: '@zohodesk/client_packages_group',
|
96
96
|
cli: 'module_resolve_path'
|
97
97
|
},
|
98
98
|
// this option only for impact testing
|
@@ -124,6 +124,13 @@ var _default = {
|
|
124
124
|
filenames: [],
|
125
125
|
packages: []
|
126
126
|
},
|
127
|
+
customAttributes: {
|
128
|
+
enable: false,
|
129
|
+
attributes: null,
|
130
|
+
jsAttributes: null,
|
131
|
+
cssAttributes: null,
|
132
|
+
i18nAttributes: null
|
133
|
+
},
|
127
134
|
server: {
|
128
135
|
host: {
|
129
136
|
value: (0, _os.hostname)(),
|
package/lib/servers/devBuild.js
CHANGED
@@ -15,6 +15,8 @@ var _utils = require("../utils");
|
|
15
15
|
|
16
16
|
var _getCliPath = require("./getCliPath");
|
17
17
|
|
18
|
+
var _logger = require("../logger");
|
19
|
+
|
18
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
19
21
|
|
20
22
|
const options = (0, _utils.getOptions)(); // const args = process.argv.slice(3);
|
@@ -35,28 +37,28 @@ const zipname = cssSelectorZipPath ? _path.default.parse(cssSelectorZipPath).nam
|
|
35
37
|
const outputFolderLocation = _path.default.join(process.cwd(), outputFolder);
|
36
38
|
|
37
39
|
function execSyncDefalut(command) {
|
38
|
-
|
40
|
+
(0, _logger.messageLogger)(' command running ==>', command);
|
39
41
|
return (0, _child_process.execSync)(command, {
|
40
42
|
stdio: 'inherit'
|
41
43
|
});
|
42
44
|
}
|
43
45
|
|
44
46
|
const isQuiet = 'q';
|
45
|
-
const webpack = (0, _getCliPath.getCliPath)('webpack'); //
|
47
|
+
const webpack = (0, _getCliPath.getCliPath)('webpack'); // messageLogger('webpack === > ', webpack, fs.existsSync(webpack));
|
46
48
|
|
47
49
|
if (_fs.default.existsSync(outputFolderLocation)) {
|
48
50
|
execSyncDefalut(`rm -rf ${outputFolder}`);
|
49
|
-
|
51
|
+
(0, _logger.messageLogger)(`previous ${outputFolder} removed`);
|
50
52
|
}
|
51
53
|
|
52
54
|
if (_fs.default.existsSync(_path.default.join(process.cwd(), 'build.zip'))) {
|
53
55
|
execSyncDefalut('rm build.zip');
|
54
|
-
|
56
|
+
(0, _logger.messageLogger)('previous build.zip removed');
|
55
57
|
} // execSyncDefalut(`${webpack } --version`);
|
56
58
|
// execSyncDefalut(`${webpack} --config ${require.resolve('../configs/webpack.dev.config.js')}`);
|
57
59
|
|
58
60
|
|
59
|
-
|
61
|
+
(0, _logger.messageLogger)('webpack compilation starts...');
|
60
62
|
const startTime = Date.now(); // const result = spawnSync(
|
61
63
|
// webpack,
|
62
64
|
// ['--config', require.resolve('../configs/webpack.dev.config.js')].concat(
|
@@ -67,31 +69,31 @@ const startTime = Date.now(); // const result = spawnSync(
|
|
67
69
|
// --disable_watch=true
|
68
70
|
|
69
71
|
const result = execSyncDefalut(`${webpack} --config ${require.resolve('../configs/webpack.dev.config.js')} ${process.argv.slice(2).map(o => o.replace(/(.*?)=(.*)/, '$1="$2"')).join(' ')} `);
|
70
|
-
result &&
|
72
|
+
result && (0, _logger.messageLogger)(result);
|
71
73
|
|
72
74
|
if (result && result.stderr) {
|
73
75
|
throw result.stderr;
|
74
76
|
}
|
75
77
|
|
76
|
-
|
78
|
+
(0, _logger.messageLogger)(`compailation done in ${Date.now() - startTime}ms`);
|
77
79
|
|
78
80
|
if (zipname) {
|
79
81
|
execSyncDefalut(`zip -r${isQuiet} build.zip ${outputFolder}/*`);
|
80
|
-
|
82
|
+
(0, _logger.messageLogger)('build.zip file created');
|
81
83
|
const result = execSyncDefalut(`zip -r${isQuiet} ${cssSelectorZipPath} ${zipname}/*`);
|
82
84
|
execSyncDefalut(`rm -rf ${zipname}`);
|
83
85
|
|
84
86
|
if (result && result.stderr) {
|
85
|
-
|
87
|
+
(0, _logger.messageLogger)('zip file not created', cssSelectorZipPath);
|
86
88
|
console.error(result.stderr);
|
87
89
|
} else {
|
88
|
-
|
90
|
+
(0, _logger.messageLogger)('zip file created', cssSelectorZipPath);
|
89
91
|
}
|
90
92
|
} // npm run start --app:domain=tsi --impact:cssbountry="{$@&&@$}" --disable-watch --dev-cache --cssselector_zip=css-source-map.zip
|
91
93
|
// npm run start --app_domain=tsi --impact_cssbountry="{$@&&@$}" --disable-watch --dev-cache --cssselector_zip=css-source-map.zip
|
92
94
|
|
93
95
|
|
94
|
-
|
96
|
+
(0, _logger.messageLogger)(`compailation done in ${Date.now() - startTime}ms`);
|
95
97
|
|
96
98
|
function getPaths() {
|
97
99
|
return {
|
@@ -6,21 +6,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
exports.httpsOptions = httpsOptions;
|
7
7
|
exports.httpsOptionsWithUserFriendlyError = httpsOptionsWithUserFriendlyError;
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
var _logger = require("../logger");
|
10
|
+
|
11
|
+
var _requireLocalOrGlobal = require("./requireLocalOrGlobal");
|
12
|
+
|
13
|
+
const globalCertificate = (0, _requireLocalOrGlobal.requireGlobal)('@zohodesk-private/client_dev_cert');
|
14
|
+
|
15
15
|
function httpsOptions(options) {
|
16
16
|
const {
|
17
17
|
httpsCerts
|
18
18
|
} = options.app.server;
|
19
|
-
|
20
|
-
const certificate = require(require.resolve(httpsCerts, {
|
21
|
-
paths: [process.cwd()]
|
22
|
-
})); // TODO: in future we may do some version based check. certificate.version
|
23
|
-
|
19
|
+
const certificate = (0, _requireLocalOrGlobal.requireLocalOrGlobal)(httpsCerts); // TODO: in future we may do some version based check. certificate.version
|
24
20
|
|
25
21
|
return certificate.httpsOptions;
|
26
22
|
}
|
@@ -36,13 +32,16 @@ function httpsOptionsWithUserFriendlyError(options) {
|
|
36
32
|
return certificate;
|
37
33
|
} catch (error) {
|
38
34
|
if (error.message.indexOf('Cannot find module') !== -1) {
|
39
|
-
|
35
|
+
(0, _logger.errorLogger)(`You have given react-cli.app.server.httpsCerts as "${httpsCerts}". \n But it seems that file path have some problem.\n we are unable to locate "${httpsCerts}" in "${process.cwd()}"`);
|
40
36
|
} else {
|
41
|
-
|
37
|
+
(0, _logger.errorLogger)(error);
|
42
38
|
}
|
43
39
|
|
44
40
|
process.exit(0);
|
45
41
|
}
|
42
|
+
} else if (globalCertificate) {
|
43
|
+
(0, _logger.messageLogger)('global `@zohodesk-private/client_dev_cert` package taken as https certificate');
|
44
|
+
return globalCertificate.httpsOptions;
|
46
45
|
} else {
|
47
46
|
return null;
|
48
47
|
}
|
@@ -16,6 +16,8 @@ var _httpsOptions = require("./httpsOptions");
|
|
16
16
|
|
17
17
|
var _devBuild = require("./devBuild");
|
18
18
|
|
19
|
+
var _logger = require("../logger");
|
20
|
+
|
19
21
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
20
22
|
|
21
23
|
// import webpack from 'webpack';
|
@@ -128,7 +130,7 @@ if (zipname) {
|
|
128
130
|
throw err;
|
129
131
|
}
|
130
132
|
|
131
|
-
|
133
|
+
(0, _logger.messageLogger)(`${zipname}.zip downloaded`);
|
132
134
|
});
|
133
135
|
});
|
134
136
|
app.use('/zips/build.zip', (req, res) => {
|
@@ -137,7 +139,7 @@ if (zipname) {
|
|
137
139
|
throw err;
|
138
140
|
}
|
139
141
|
|
140
|
-
|
142
|
+
(0, _logger.messageLogger)('build.zip downloaded');
|
141
143
|
});
|
142
144
|
});
|
143
145
|
}
|
@@ -188,7 +190,7 @@ if (httpsOptions) {
|
|
188
190
|
}, 'htt' + 'ps')}${contextURL}/`, 'http2 server');
|
189
191
|
});
|
190
192
|
} else {
|
191
|
-
(0, _utils.log)(
|
193
|
+
(0, _utils.log)('Your node version didn\'t adopted http2 support. Kindly update that to 8 LTS or above you can engage the http2');
|
192
194
|
}
|
193
195
|
}
|
194
196
|
|
@@ -0,0 +1,61 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.globalNodeModules = void 0;
|
7
|
+
exports.requireGlobal = requireGlobal;
|
8
|
+
exports.requireLocal = requireLocal;
|
9
|
+
exports.requireLocalOrGlobal = requireLocalOrGlobal;
|
10
|
+
|
11
|
+
var _child_process = require("child_process");
|
12
|
+
|
13
|
+
var _path = _interopRequireDefault(require("path"));
|
14
|
+
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
16
|
+
|
17
|
+
const globalNodeModules = _path.default.join(`${(0, _child_process.execSync)('npm config get prefix')}`.trim(), 'lib');
|
18
|
+
|
19
|
+
exports.globalNodeModules = globalNodeModules;
|
20
|
+
|
21
|
+
function requireLocalOrGlobal(moduleName, opts = {}) {
|
22
|
+
let {
|
23
|
+
global = true
|
24
|
+
} = opts;
|
25
|
+
const {
|
26
|
+
local = true
|
27
|
+
} = opts;
|
28
|
+
const isRelativePath = moduleName === '.'; // NOTE: if starts with . then it only mean local
|
29
|
+
|
30
|
+
if (isRelativePath) {
|
31
|
+
global = false;
|
32
|
+
}
|
33
|
+
|
34
|
+
try {
|
35
|
+
const paths = [local && process.cwd(), global && globalNodeModules].filter(Boolean); // x({ paths, globalNodeModules, global, local, opts });
|
36
|
+
|
37
|
+
const moduleResolvePath = require.resolve(moduleName, {
|
38
|
+
paths
|
39
|
+
});
|
40
|
+
|
41
|
+
return require(moduleResolvePath);
|
42
|
+
} catch (error) {
|
43
|
+
// NOTE: since we return null we can check out side
|
44
|
+
// console.log('Re validate: ', error);
|
45
|
+
return null;
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
function requireLocal(moduleName) {
|
50
|
+
return requireLocalOrGlobal(moduleName, {
|
51
|
+
global: false,
|
52
|
+
local: true
|
53
|
+
});
|
54
|
+
}
|
55
|
+
|
56
|
+
function requireGlobal(moduleName) {
|
57
|
+
return requireLocalOrGlobal(moduleName, {
|
58
|
+
global: true,
|
59
|
+
local: false
|
60
|
+
});
|
61
|
+
}
|