@zohodesk/react-cli 1.1.1 → 1.1.2-9.exp.3
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/.vscode/settings.json +25 -0
- package/README.md +446 -35
- package/bin/cli.js +17 -52
- package/docs/CustomChunks.md +12 -9
- package/docs/MarkdownParser.md +18 -0
- package/docs/ReactLive.md +8 -0
- package/docs/ValueReplacer.md +27 -0
- package/lib/babel/babel-option-utils/babel-preset-react-option.js +22 -0
- package/lib/babel/cmjs-plugins-presets.js +36 -7
- package/lib/babel/es-plugins-presets.js +45 -16
- package/lib/common/runPreProcess.js +71 -0
- package/lib/common/splitChunks.js +65 -45
- package/lib/common/testPattern.js +9 -9
- package/lib/configs/jest.config.js +4 -4
- package/lib/configs/libAlias.js +36 -2
- package/lib/configs/resolvers.js +7 -4
- package/lib/configs/webpack.css.umd.config.js +3 -2
- package/lib/configs/webpack.dev.config.js +28 -8
- package/lib/configs/webpack.docs.config.js +10 -5
- package/lib/configs/webpack.impact.config.js +9 -4
- package/lib/configs/webpack.prod.config.js +32 -10
- package/lib/constants.js +3 -3
- package/lib/deprecationLogger.js +40 -0
- package/lib/jest/preProcessors/jsPreprocessor.js +27 -2
- package/lib/loaderUtils/configsAssetsLoaders.js +1 -1
- package/lib/loaderUtils/getCSSLoaders.js +32 -8
- package/lib/loaderUtils/getDevJsLoaders.js +8 -2
- package/lib/loaders/__test__/markdownLoader.spec.js +145 -0
- package/lib/loaders/composeLoader.js +140 -14
- package/lib/loaders/docsLoader.js +5 -2
- package/lib/loaders/enhancedReactLiveConverter.js +151 -0
- package/lib/loaders/markdownLoader.js +71 -0
- package/lib/loaders/workerLoader.js +37 -22
- package/lib/logger.js +7 -0
- package/lib/pluginUtils/configHtmlWebpackPlugins.js +62 -2
- package/lib/pluginUtils/getDevPlugins.js +24 -8
- package/lib/pluginUtils/getProdPlugins.js +34 -6
- package/lib/plugins/CssOrderControlPlugin.js +36 -0
- package/lib/plugins/CustomScriptLoadingStrategyPlugin.js +109 -0
- package/lib/plugins/EfcResourceCleanupPlugin.js +43 -0
- package/lib/plugins/EventsHandlingPlugin.js +34 -0
- package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +5 -1
- package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +4 -1
- package/lib/plugins/I18nSplitPlugin/utils/unicodeConversion.js +14 -0
- package/lib/plugins/ReportGeneratePlugin.js +8 -6
- package/lib/plugins/ResourceHintsPlugin.js +13 -3
- package/lib/plugins/StatsPlugin.js +82 -0
- package/lib/plugins/UnusedFilesFindPlugin.js +7 -5
- package/lib/plugins/utils/fileHandling.js +36 -51
- package/lib/plugins/variableConvertorUtils.js +4 -2
- package/lib/postcss-plugins/ValueReplacer.js +7 -17
- package/lib/postcss-plugins/__test__/valueReplacer.spec.js +43 -0
- package/lib/postcss-plugins/variableModificationPlugin/index.js +70 -18
- package/lib/schemas/index.js +67 -39
- package/lib/servers/getCliPath.js +3 -5
- package/lib/servers/requireLocalOrGlobal.js +1 -1
- package/lib/utils/cssClassNameGenerate.js +43 -5
- package/lib/utils/deprecationSupport.js +134 -0
- package/lib/utils/getFileType.js +1 -1
- package/lib/utils/getOptions.js +31 -69
- package/lib/utils/getServerURL.js +7 -2
- package/lib/utils/index.js +27 -11
- package/lib/utils/initPreCommitHook.js +5 -5
- package/lib/utils/log.js +11 -0
- package/lib/utils/object-manipulation.js +88 -0
- package/lib/utils/pullOrigin.js +3 -3
- package/lib/utils/reinstallDependencies.js +3 -3
- package/lib/utils/switchBranch.js +4 -2
- package/lib/utils/typeCheck.js +10 -0
- package/lib/utils/variableConverter.js +26 -11
- package/npm-shrinkwrap.json +929 -39
- package/package.json +12 -4
- package/templates/docs/all.html +1 -0
- package/templates/docs/component.html +1 -0
- package/templates/docs/components.html +1 -0
- package/templates/docs/css/markdown.css +202 -0
- package/templates/docs/css/style.css +136 -169
- package/templates/docs/index.html +796 -632
package/lib/schemas/index.js
CHANGED
@@ -15,7 +15,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
15
15
|
|
16
16
|
// TODO move deprecated options to separate file and manage seperately
|
17
17
|
var _default = {
|
18
|
-
|
18
|
+
alias: null,
|
19
19
|
unstableDepsInverse: {
|
20
20
|
value: false,
|
21
21
|
cli: 'unstable_deps_inverse'
|
@@ -36,6 +36,9 @@ var _default = {
|
|
36
36
|
cli: 'stop_nodemon'
|
37
37
|
}
|
38
38
|
},
|
39
|
+
resourceHints: {
|
40
|
+
allowPrefetchingMultipleChunks: false
|
41
|
+
},
|
39
42
|
i18n: {
|
40
43
|
chunkSplitEnable: {
|
41
44
|
value: false,
|
@@ -49,6 +52,10 @@ var _default = {
|
|
49
52
|
propertiesFolder: null
|
50
53
|
},
|
51
54
|
css: {
|
55
|
+
cssOrderControler: {
|
56
|
+
enable: false,
|
57
|
+
className: 'customCss'
|
58
|
+
},
|
52
59
|
enableRTLSplit: false,
|
53
60
|
valueReplacer: null,
|
54
61
|
//valueReplacer: [
|
@@ -68,17 +75,9 @@ var _default = {
|
|
68
75
|
before: [],
|
69
76
|
after: []
|
70
77
|
},
|
71
|
-
plugins:
|
72
|
-
|
73
|
-
|
74
|
-
hasRTL: false,
|
75
|
-
hoverActive: false,
|
76
|
-
combinerMediaQuery: false,
|
77
|
-
cssVariableReplacement: false,
|
78
|
-
selectorWeight: false,
|
79
|
-
minifier: false,
|
80
|
-
composeMinification: false
|
81
|
-
},
|
78
|
+
plugins: null,
|
79
|
+
// @type {Boolean | Array}
|
80
|
+
postCssPluginOrder: null,
|
82
81
|
patterns: {
|
83
82
|
valueReplacer: [],
|
84
83
|
selectorReplace: [],
|
@@ -95,7 +94,8 @@ var _default = {
|
|
95
94
|
hoverActive: [],
|
96
95
|
combinerMediaQuery: [],
|
97
96
|
cssVariableReplacement: [],
|
98
|
-
selectorWeight: []
|
97
|
+
selectorWeight: [],
|
98
|
+
hasRTL: []
|
99
99
|
},
|
100
100
|
cssVariableReplacementConfig: '',
|
101
101
|
selectorWeightConfig: {
|
@@ -130,10 +130,23 @@ var _default = {
|
|
130
130
|
cssDirStatement: null
|
131
131
|
},
|
132
132
|
app: {
|
133
|
+
generateHtml: {
|
134
|
+
value: true,
|
135
|
+
cli: 'generate_html'
|
136
|
+
},
|
137
|
+
displayClassName: {
|
138
|
+
value: false,
|
139
|
+
cli: 'display_class_name'
|
140
|
+
},
|
133
141
|
moduleResolvePath: {
|
134
142
|
value: '@zohodesk/client_packages_group',
|
135
143
|
cli: 'module_resolve_path'
|
136
144
|
},
|
145
|
+
enableMjsLoader: {
|
146
|
+
value: false,
|
147
|
+
cli: 'enableMjsLoader'
|
148
|
+
},
|
149
|
+
customClassNamePrefix: [],
|
137
150
|
// this option only for impact testing
|
138
151
|
devCssFileBountry: {
|
139
152
|
value: '',
|
@@ -219,6 +232,7 @@ var _default = {
|
|
219
232
|
none: '(hover: none)'
|
220
233
|
},
|
221
234
|
disableES5Transpile: false,
|
235
|
+
disableES5Import: false,
|
222
236
|
isReactMig: false,
|
223
237
|
hasWidget: false,
|
224
238
|
hasEFC: {
|
@@ -267,17 +281,8 @@ var _default = {
|
|
267
281
|
value: true,
|
268
282
|
cli: 'enable_smaphook'
|
269
283
|
},
|
270
|
-
plugins:
|
271
|
-
|
272
|
-
selectorReplace: false,
|
273
|
-
hasRTL: false,
|
274
|
-
hoverActive: false,
|
275
|
-
combinerMediaQuery: false,
|
276
|
-
cssVariableReplacement: false,
|
277
|
-
selectorWeight: false,
|
278
|
-
minifier: false,
|
279
|
-
composeMinification: false
|
280
|
-
},
|
284
|
+
plugins: null,
|
285
|
+
postCssPluginOrder: null,
|
281
286
|
patterns: {
|
282
287
|
valueReplacer: [],
|
283
288
|
selectorReplace: [],
|
@@ -294,7 +299,8 @@ var _default = {
|
|
294
299
|
hoverActive: [],
|
295
300
|
combinerMediaQuery: [],
|
296
301
|
cssVariableReplacement: [],
|
297
|
-
selectorWeight: []
|
302
|
+
selectorWeight: [],
|
303
|
+
hasRTL: []
|
298
304
|
},
|
299
305
|
cssVariableReplacementConfig: '',
|
300
306
|
selectorWeightConfig: {
|
@@ -330,9 +336,14 @@ var _default = {
|
|
330
336
|
},
|
331
337
|
htmlTemplate: {
|
332
338
|
minify: null,
|
333
|
-
inject: true
|
339
|
+
inject: true,
|
340
|
+
customScriptLoadingStrategey: {
|
341
|
+
enable: false,
|
342
|
+
options: null
|
343
|
+
}
|
334
344
|
},
|
335
345
|
removePropTypes: false,
|
346
|
+
customChunksBaseConfig: null,
|
336
347
|
customChunks: [{
|
337
348
|
name: 'styles',
|
338
349
|
pattern: '\\.css$'
|
@@ -348,9 +359,11 @@ var _default = {
|
|
348
359
|
sourcemap: {
|
349
360
|
cli: 'source_map',
|
350
361
|
value: 'cheap-eval-source-map'
|
351
|
-
}
|
362
|
+
},
|
363
|
+
externals: null
|
352
364
|
},
|
353
365
|
docs: {
|
366
|
+
externals: null,
|
354
367
|
server: {
|
355
368
|
iphost: (0, _getIp.default)(),
|
356
369
|
host: (0, _os.hostname)(),
|
@@ -368,6 +381,7 @@ var _default = {
|
|
368
381
|
hover: 'all and (min--moz-device-pixel-ratio:0) and (hover: hover), (hover: hover)',
|
369
382
|
none: '(hover: none)'
|
370
383
|
},
|
384
|
+
customClassNamePrefix: [],
|
371
385
|
componentFolder: 'src',
|
372
386
|
cssUniqueness: {
|
373
387
|
value: true,
|
@@ -382,18 +396,14 @@ var _default = {
|
|
382
396
|
value: true,
|
383
397
|
cli: 'react_live'
|
384
398
|
},
|
399
|
+
enableMDParser: {
|
400
|
+
value: true,
|
401
|
+
cli: 'markdown_parser'
|
402
|
+
},
|
385
403
|
rtlExclude: [],
|
386
404
|
selectorReplace: null,
|
387
|
-
plugins:
|
388
|
-
|
389
|
-
hoverActive: false,
|
390
|
-
combinerMediaQuery: false,
|
391
|
-
cssVariableReplacement: false,
|
392
|
-
selectorWeight: false,
|
393
|
-
minifier: false,
|
394
|
-
composeMinification: false,
|
395
|
-
selectorReplace: false
|
396
|
-
},
|
405
|
+
plugins: null,
|
406
|
+
postCssPluginOrder: null,
|
397
407
|
patterns: {
|
398
408
|
valueReplacer: [],
|
399
409
|
selectorReplace: [],
|
@@ -401,14 +411,16 @@ var _default = {
|
|
401
411
|
combinerMediaQuery: [],
|
402
412
|
hasRTL: [],
|
403
413
|
cssVariableReplacement: [],
|
404
|
-
selectorWeight: []
|
414
|
+
selectorWeight: [],
|
415
|
+
cssUniqueness: []
|
405
416
|
},
|
406
417
|
exclude: {
|
407
418
|
rtl: [],
|
408
419
|
hoverActive: [],
|
409
420
|
combinerMediaQuery: [],
|
410
421
|
cssVariableReplacement: [],
|
411
|
-
selectorWeight: []
|
422
|
+
selectorWeight: [],
|
423
|
+
hasRTL: []
|
412
424
|
},
|
413
425
|
cssVariableReplacementConfig: '',
|
414
426
|
selectorWeightConfig: {
|
@@ -735,6 +747,22 @@ var _default = {
|
|
735
747
|
cli: 'module_mode'
|
736
748
|
},
|
737
749
|
disableES5Transpile: true
|
750
|
+
},
|
751
|
+
stats: {
|
752
|
+
enable: {
|
753
|
+
value: false,
|
754
|
+
cli: 'enable_stats'
|
755
|
+
},
|
756
|
+
fileName: null,
|
757
|
+
options: null,
|
758
|
+
excludeKeys: null
|
759
|
+
},
|
760
|
+
babelCustomizationForLibrary: {
|
761
|
+
babelPlugins: []
|
762
|
+
},
|
763
|
+
enableTypeScript: {
|
764
|
+
value: false,
|
765
|
+
cli: 'enable_typescript'
|
738
766
|
}
|
739
767
|
};
|
740
768
|
exports.default = _default;
|
@@ -5,19 +5,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.getCliPath = getCliPath;
|
7
7
|
|
8
|
-
var _path =
|
8
|
+
var _path = require("path");
|
9
9
|
|
10
10
|
var _os = require("os");
|
11
11
|
|
12
12
|
var _fs = require("fs");
|
13
13
|
|
14
|
-
|
14
|
+
var _constants = require("../constants");
|
15
15
|
|
16
|
-
const appPath = process.cwd();
|
17
|
-
const isNodeModuleUnderAppFolder = __dirname.indexOf(appPath) !== -1;
|
18
16
|
const isWindows = (0, _os.platform)().toLowerCase() === 'win32';
|
19
17
|
|
20
|
-
const _getCliPath =
|
18
|
+
const _getCliPath = libName => (0, _path.join)(_constants.cliNodeModulesPath, '.bin', libName);
|
21
19
|
|
22
20
|
const suffixExt = isWindows ? '.cmd' : '';
|
23
21
|
|
@@ -25,7 +25,7 @@ function requireLocalOrGlobal(moduleName, opts = {}) {
|
|
25
25
|
const {
|
26
26
|
local = true
|
27
27
|
} = opts;
|
28
|
-
const isRelativePath = moduleName === '.'; // NOTE: if starts with . then it only mean local
|
28
|
+
const isRelativePath = moduleName[0] === '.'; // NOTE: if starts with . then it only mean local
|
29
29
|
|
30
30
|
if (isRelativePath) {
|
31
31
|
global = false;
|
@@ -38,14 +38,35 @@ const isSelectorPackage = (resourcePath, packages) => {
|
|
38
38
|
return isValid;
|
39
39
|
};
|
40
40
|
|
41
|
+
function patternBasedClass({
|
42
|
+
customClassNamePrefix,
|
43
|
+
context,
|
44
|
+
relativePath,
|
45
|
+
localName
|
46
|
+
}) {
|
47
|
+
let newName = null;
|
48
|
+
customClassNamePrefix.forEach(obj => {
|
49
|
+
if (obj.enable) {
|
50
|
+
if (obj.patterns && obj.prefix && (0, _fileHandling.isFileNameMatchingPluginPattern)({
|
51
|
+
filename: context.resourcePath,
|
52
|
+
filterArr: obj.patterns
|
53
|
+
})) {
|
54
|
+
const h = (0, _getHash.default)(`${relativePath}-${localName}`, 10);
|
55
|
+
newName = `${obj.prefix}${h}`;
|
56
|
+
}
|
57
|
+
}
|
58
|
+
});
|
59
|
+
return newName;
|
60
|
+
}
|
61
|
+
|
41
62
|
var _default = (unique = true, {
|
42
63
|
filenames,
|
43
64
|
packages
|
44
|
-
}, classNamePrefix, patterns) => (context, localIdentName, localName) => {
|
65
|
+
}, classNamePrefix, customClassNamePrefix, patterns, displayClassName) => (context, localIdentName, localName) => {
|
45
66
|
// console.log(patterns, context.resourcePath);
|
46
|
-
// NOTE: in build
|
67
|
+
// NOTE: in build machine we use date as folder path.
|
47
68
|
// So every time we create new build there is path will alway different
|
48
|
-
// in order to
|
69
|
+
// in order to minimize that problem we try in relative path;
|
49
70
|
// console.log('context.resourcePath', context.resourcePath, context);
|
50
71
|
// let contextResourcePath = context.resourcePath;
|
51
72
|
const filePaths = context.resourcePath.split(_path.default.sep);
|
@@ -53,7 +74,8 @@ var _default = (unique = true, {
|
|
53
74
|
const [fileNameWithoutExt] = fileName.split('.');
|
54
75
|
const cleanFileName = fileNameWithoutExt.replace(/-/g, '_').toLowerCase();
|
55
76
|
|
56
|
-
const relativePath = _path.default.relative(context.rootContext, context.resourcePath);
|
77
|
+
const relativePath = _path.default.relative(context.rootContext, context.resourcePath); // console.log('customClassNamePrefix', customClassNamePrefix);
|
78
|
+
|
57
79
|
/*
|
58
80
|
input :
|
59
81
|
context.resourcePath : 'D:/MyWork/..../desk_client_app/supportapp/src/components/Avatar/Avatar.module.css,
|
@@ -70,6 +92,11 @@ var _default = (unique = true, {
|
|
70
92
|
*/
|
71
93
|
|
72
94
|
|
95
|
+
if (displayClassName) {
|
96
|
+
return `${fileNameWithoutExt}__${localName}`;
|
97
|
+
} // return cleanFileName
|
98
|
+
|
99
|
+
|
73
100
|
if (context.resourcePath.endsWith('.plain.css')) {
|
74
101
|
return localName;
|
75
102
|
}
|
@@ -86,7 +113,18 @@ var _default = (unique = true, {
|
|
86
113
|
if (unique) {
|
87
114
|
const h = (0, _getHash.default)(`${relativePath}-${localName}`, 10);
|
88
115
|
return `${classNamePrefix}${h}`;
|
89
|
-
}
|
116
|
+
}
|
117
|
+
|
118
|
+
const patternClass = patternBasedClass({
|
119
|
+
customClassNamePrefix,
|
120
|
+
context,
|
121
|
+
relativePath,
|
122
|
+
localName
|
123
|
+
});
|
124
|
+
|
125
|
+
if (patternClass) {
|
126
|
+
return patternClass;
|
127
|
+
} //css file has case sensitive selector issue so can't toLowerCase
|
90
128
|
//let local = localName.toLowerCase()
|
91
129
|
|
92
130
|
|
@@ -0,0 +1,134 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.deprecationSupport = deprecationSupport;
|
7
|
+
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
9
|
+
|
10
|
+
var deprecationHandlers = _interopRequireWildcard(require("../deprecationLogger"));
|
11
|
+
|
12
|
+
var _windowsModification = require("../loaderUtils/windowsModification");
|
13
|
+
|
14
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
15
|
+
|
16
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
17
|
+
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
19
|
+
|
20
|
+
let {
|
21
|
+
deprecateMessage,
|
22
|
+
deprecateOption,
|
23
|
+
deprecationLoggerEnd
|
24
|
+
} = deprecationHandlers;
|
25
|
+
|
26
|
+
function modifyCssArr(arr) {
|
27
|
+
return arr.map(x => {
|
28
|
+
const includeCss = !x.startsWith('!');
|
29
|
+
const modifier = includeCss ? '/*.css' : '';
|
30
|
+
const filePath = x.replace(/^!/, ''); // Remove the "!" symbol if present
|
31
|
+
|
32
|
+
return (0, _windowsModification.windowsModificationFile)(_path.default.join(includeCss ? '**' : '!**', filePath, '**', modifier));
|
33
|
+
});
|
34
|
+
}
|
35
|
+
|
36
|
+
const defaultPostCssPluginOptions = {
|
37
|
+
valueReplacer: null,
|
38
|
+
hasRTL: false,
|
39
|
+
selectorReplace: null,
|
40
|
+
hoverActive: false,
|
41
|
+
combinerMediaQuery: false,
|
42
|
+
cssVariableReplacement: false,
|
43
|
+
selectorWeight: false,
|
44
|
+
minifier: false,
|
45
|
+
composeMinification: false
|
46
|
+
};
|
47
|
+
|
48
|
+
function deprecationSupport(options, disableDeprecationWarning) {
|
49
|
+
if (disableDeprecationWarning) {
|
50
|
+
/* eslint-disable no-empty-function */
|
51
|
+
deprecateMessage = () => {};
|
52
|
+
|
53
|
+
deprecateOption = () => {};
|
54
|
+
|
55
|
+
deprecationLoggerEnd = () => {};
|
56
|
+
/* eslint-enable no-empty-function */
|
57
|
+
|
58
|
+
}
|
59
|
+
|
60
|
+
options.app.plugins = options.app.plugins || defaultPostCssPluginOptions;
|
61
|
+
options.docs.plugins = options.docs.plugins || defaultPostCssPluginOptions;
|
62
|
+
options.css.plugins = options.css.plugins || defaultPostCssPluginOptions; // if (selectn(options, ".app.hasRTL") === true) {
|
63
|
+
|
64
|
+
if (options.app.hasRTL === true) {
|
65
|
+
deprecateOption('app.hasRTL', 'app.plugins.hasRTL');
|
66
|
+
options.app.plugins.hasRTL = true;
|
67
|
+
}
|
68
|
+
|
69
|
+
if (options.docs.hasRTL === true) {
|
70
|
+
deprecateOption('docs.hasRTL', 'docs.plugins.hasRTL');
|
71
|
+
options.docs.plugins.hasRTL = true;
|
72
|
+
}
|
73
|
+
|
74
|
+
if (options.app.selectorReplace !== null && options.app.plugins && (options.app.plugins.selectorReplace === null || options.app.plugins.selectorReplace === undefined)) {
|
75
|
+
deprecateMessage('when you use app.selectorReplace mention enable or disable app.plugins.selectorReplace by setting value to true or false');
|
76
|
+
options.app.plugins.selectorReplace = true;
|
77
|
+
}
|
78
|
+
|
79
|
+
if (options.docs.selectorReplace !== null && options.docs.plugins && (options.docs.plugins.selectorReplace === null || options.docs.plugins.selectorReplace === undefined)) {
|
80
|
+
deprecateMessage('when you use docs.selectorReplace mention enable or disable docs.plugins.selectorReplace by setting value to true or false');
|
81
|
+
options.docs.plugins.selectorReplace = true;
|
82
|
+
}
|
83
|
+
|
84
|
+
if (options.css.valueReplacer !== null && options.css.plugins && (options.app.plugins.valueReplacer === null || options.app.plugins.valueReplacer === undefined)) {
|
85
|
+
deprecateMessage('when you use app.valueReplacer mention enable or disable app.plugins.valueReplacer by setting value to true or false');
|
86
|
+
options.app.plugins.valueReplacer = true;
|
87
|
+
}
|
88
|
+
|
89
|
+
if (!options.app.patterns) {
|
90
|
+
options.app.patterns = {};
|
91
|
+
}
|
92
|
+
|
93
|
+
function handleRTL(rtlExclude, rtl, hasRTL, type) {
|
94
|
+
if (rtlExclude && rtlExclude.length > 0) {
|
95
|
+
options[type].patterns.hasRTL = modifyCssArr(rtlExclude);
|
96
|
+
deprecateOption(`${type}.rtlExclude`, `${type}.patterns.hasRTL`);
|
97
|
+
}
|
98
|
+
|
99
|
+
if (rtl && rtl.length > 0) {
|
100
|
+
options[type].patterns.hasRTL = modifyCssArr(rtl);
|
101
|
+
deprecateOption(`${type}.exclude.rtl`, `${type}.patterns.hasRTL`);
|
102
|
+
}
|
103
|
+
|
104
|
+
if (hasRTL && hasRTL.length > 0) {
|
105
|
+
options[type].patterns.hasRTL = modifyCssArr(hasRTL);
|
106
|
+
deprecateOption(`${type}.exclude.hasRTL`, `${type}.patterns.hasRTL`);
|
107
|
+
}
|
108
|
+
}
|
109
|
+
|
110
|
+
function addExcludesToPattern(patterns, exclude, type) {
|
111
|
+
Object.keys(defaultPostCssPluginOptions).forEach(key => {
|
112
|
+
if (!exclude[key] || exclude[key].length === 0) {
|
113
|
+
return;
|
114
|
+
}
|
115
|
+
|
116
|
+
if (patterns[key].length === 0) {
|
117
|
+
deprecateOption(`${type}.exclude.${key}`, `${type}.patterns.${key}`);
|
118
|
+
let tempArr = exclude[key];
|
119
|
+
tempArr = tempArr.map(x => _path.default.join('!**', x, '**')); // Since patterns[key] is empty we need to wildcard for allow all others.
|
120
|
+
|
121
|
+
tempArr.unshift('*');
|
122
|
+
patterns[key] = tempArr;
|
123
|
+
} else if (exclude[key].length > 0 && patterns[key].length > 0) {
|
124
|
+
deprecateOption(`${type}.exclude.${key}`, `${type}.patterns.${key}`, ` And Since you have used ${type}.patterns.${key} we won't use ${type}.exclude.${key}. So please make appropriate changes`);
|
125
|
+
}
|
126
|
+
});
|
127
|
+
}
|
128
|
+
|
129
|
+
handleRTL(options.app.rtlExclude, options.app.exclude.rtl, options.app.exclude.hasRTL, 'app');
|
130
|
+
handleRTL(options.docs.rtlExclude, options.docs.exclude.rtl, options.docs.exclude.hasRTL, 'docs');
|
131
|
+
addExcludesToPattern(options.app.patterns, options.app.exclude, 'app');
|
132
|
+
addExcludesToPattern(options.docs.patterns, options.docs.exclude, 'docs');
|
133
|
+
deprecationLoggerEnd();
|
134
|
+
}
|
package/lib/utils/getFileType.js
CHANGED
package/lib/utils/getOptions.js
CHANGED
@@ -3,18 +3,28 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.default = void 0;
|
6
|
+
exports.defaulter = exports.default = void 0;
|
7
7
|
|
8
8
|
var _child_process = require("child_process");
|
9
9
|
|
10
|
-
var _fs =
|
10
|
+
var _fs = _interopRequireWildcard(require("fs"));
|
11
11
|
|
12
12
|
var _path = _interopRequireDefault(require("path"));
|
13
13
|
|
14
14
|
var _schemas = _interopRequireDefault(require("../schemas"));
|
15
15
|
|
16
|
+
var _deprecationSupport = require("./deprecationSupport");
|
17
|
+
|
18
|
+
var _deprecationLogger = require("../deprecationLogger");
|
19
|
+
|
20
|
+
var _logger = require("../logger");
|
21
|
+
|
16
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
17
23
|
|
24
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
25
|
+
|
26
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
27
|
+
|
18
28
|
// import { argv } from 'process';
|
19
29
|
const args = process.argv.slice(2); // console.log('argv', argv);
|
20
30
|
|
@@ -122,99 +132,51 @@ const defaulter = (target, source) => {
|
|
122
132
|
return defaultObject;
|
123
133
|
};
|
124
134
|
|
125
|
-
|
126
|
-
|
127
|
-
// let keys = key.split('.');
|
128
|
-
// for (let i = 0; i < keys.length; i++) {
|
129
|
-
// const element = keys[i];
|
130
|
-
// temp = temp && temp[element];
|
131
|
-
// }
|
132
|
-
// return temp;
|
133
|
-
// }
|
134
|
-
|
135
|
-
function deprecationSupport(options) {
|
136
|
-
// if (selectn(options, ".app.hasRTL") === true) {
|
137
|
-
if (options.app.hasRTL === true) {
|
138
|
-
options.app.plugins.hasRTL = true;
|
139
|
-
}
|
140
|
-
|
141
|
-
if (options.docs.hasRTL === true) {
|
142
|
-
options.docs.plugins.hasRTL = true;
|
143
|
-
}
|
144
|
-
|
145
|
-
if (options.app.rtlExclude.length > 0) {
|
146
|
-
options.app.exclude.rtl = options.app.rtlExclude;
|
147
|
-
}
|
148
|
-
|
149
|
-
if (options.docs.rtlExclude.length > 0) {
|
150
|
-
options.docs.exclude.rtl = options.docs.rtlExclude;
|
151
|
-
}
|
152
|
-
|
153
|
-
if (options.app.selectorReplace !== null) {
|
154
|
-
options.app.plugins.selectorReplace = true;
|
155
|
-
}
|
135
|
+
exports.defaulter = defaulter;
|
136
|
+
global.reactCLIOptions = null;
|
156
137
|
|
157
|
-
|
158
|
-
|
159
|
-
}
|
138
|
+
const getOptionsFromConfigFile = (appPath, configFileName) => {
|
139
|
+
const fileName = configFileName || 'react-cli.config.js';
|
160
140
|
|
161
|
-
if (
|
162
|
-
|
141
|
+
if (!configFileName) {
|
142
|
+
(0, _logger.verboseLogger)('we have used default react-cli.config.js');
|
163
143
|
}
|
164
144
|
|
165
|
-
|
145
|
+
const packagePath = _path.default.join(appPath, fileName);
|
166
146
|
|
167
|
-
if (
|
168
|
-
|
147
|
+
if ((0, _fs.existsSync)(packagePath)) {
|
148
|
+
return require(packagePath).config;
|
169
149
|
}
|
170
150
|
|
171
|
-
|
172
|
-
options.app.patterns.valueReplacer = ['*'];
|
173
|
-
}
|
174
|
-
|
175
|
-
if (options.app.patterns.selectorReplace.length === 0) {
|
176
|
-
options.app.patterns.selectorReplace = ['*'];
|
177
|
-
}
|
151
|
+
const oldDeprecatedConfigFilePath = _path.default.join(appPath, 'build.config.js');
|
178
152
|
|
179
|
-
if (
|
180
|
-
|
153
|
+
if ((0, _fs.existsSync)(oldDeprecatedConfigFilePath)) {
|
154
|
+
(0, _deprecationLogger.deprecateMessage)('"build.config.js" file was deprecated. So Kindly rename it as "react-cli.config.js"');
|
155
|
+
return require(oldDeprecatedConfigFilePath).config;
|
181
156
|
}
|
182
157
|
|
183
|
-
|
184
|
-
|
185
|
-
let tempArr = options.app.exclude[key];
|
186
|
-
tempArr = tempArr.map(x => `!${x}`);
|
187
|
-
options.app.patterns[key] = tempArr;
|
188
|
-
}
|
189
|
-
});
|
190
|
-
Object.keys(options.docs.patterns).forEach(key => {
|
191
|
-
if (options.docs.exclude[key] && options.docs.patterns[key].length === 0) {
|
192
|
-
let tempArr = options.docs.exclude[key];
|
193
|
-
tempArr = tempArr.map(x => `!${x}`);
|
194
|
-
options.docs.patterns[key] = tempArr;
|
195
|
-
}
|
196
|
-
});
|
197
|
-
}
|
158
|
+
return null;
|
159
|
+
};
|
198
160
|
|
199
|
-
const getOptions =
|
161
|
+
const getOptions = fromRoot => {
|
200
162
|
if (global.reactCLIOptions) {
|
201
163
|
return global.reactCLIOptions;
|
202
164
|
}
|
203
165
|
|
204
166
|
const appPath = process.cwd();
|
205
|
-
let userSchemas;
|
167
|
+
let userSchemas = getOptionsFromConfigFile(appPath, processEnv.config_file);
|
206
168
|
|
207
169
|
const packagePath = _path.default.join(appPath, 'package.json');
|
208
170
|
|
209
171
|
if (_fs.default.existsSync(packagePath)) {
|
210
|
-
userSchemas = require(packagePath)['react-cli'] || {};
|
172
|
+
userSchemas = userSchemas || require(packagePath)['react-cli'] || {};
|
211
173
|
}
|
212
174
|
|
213
175
|
const options = defaulter(_schemas.default, userSchemas || {}); // for future may be for npm 8 edge cases
|
214
176
|
|
215
177
|
options.npmVersion = getNpmVersion();
|
216
178
|
options.cwd = getCWD();
|
217
|
-
deprecationSupport(options);
|
179
|
+
(0, _deprecationSupport.deprecationSupport)(options, options.disableDeprecationWarning || !fromRoot);
|
218
180
|
options.packageVersion = process.env.npm_package_version;
|
219
181
|
global.reactCLIOptions = options;
|
220
182
|
return options;
|
@@ -5,13 +5,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.default = void 0;
|
7
7
|
|
8
|
-
|
8
|
+
const getServerURL = (serverInfo, protocol) => {
|
9
|
+
// eslint-disable-next-line prefer-const
|
9
10
|
let {
|
10
11
|
host,
|
11
12
|
domain,
|
12
13
|
port
|
13
14
|
} = serverInfo;
|
14
15
|
|
16
|
+
if (domain === 'kubernetes') {
|
17
|
+
return `${protocol ? `${protocol}:` : ''}//${host}`;
|
18
|
+
}
|
19
|
+
|
15
20
|
if (protocol) {
|
16
21
|
if (protocol === 'ht' + 'tp') {
|
17
22
|
port = Number(port) + 1;
|
@@ -20,7 +25,7 @@ let getServerURL = (serverInfo, protocol) => {
|
|
20
25
|
return `${protocol ? `${protocol}:` : ''}//${host}.${domain}.zohocorpin.com:${Number(port) + 1}`;
|
21
26
|
}
|
22
27
|
|
23
|
-
return `${protocol ? `${protocol}:` : ''}//${host}:${port}`;
|
28
|
+
return `${protocol ? `${protocol}:` : ''}//${host}:${Number(port) + 1}`;
|
24
29
|
}
|
25
30
|
}
|
26
31
|
|