@zohodesk/react-cli 1.1.10 → 1.1.11-exp.1
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/README.md +68 -10
- package/bin/cli.js +1 -1
- package/lib/common/runPreProcess.js +19 -14
- package/lib/configs/webpack.css.umd.config.js +3 -2
- package/lib/configs/webpack.dev.config.js +3 -0
- package/lib/configs/webpack.docs.config.js +2 -0
- package/lib/configs/webpack.impact.config.js +2 -0
- package/lib/configs/webpack.prod.config.js +3 -0
- package/lib/loaderUtils/getCSSLoaders.js +3 -2
- package/lib/logger.js +7 -0
- package/lib/pluginUtils/getProdPlugins.js +6 -0
- package/lib/plugins/StatsPlugin.js +44 -0
- package/lib/schemas/index.js +8 -1
- package/lib/utils/cssClassNameGenerate.js +38 -5
- package/lib/utils/getOptions.js +18 -2
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/templates/docs/css/style.css +136 -169
- package/templates/docs/index.html +795 -632
package/README.md
CHANGED
@@ -44,6 +44,60 @@ Now to run app
|
|
44
44
|
|
45
45
|
# Change Logs
|
46
46
|
|
47
|
+
# 1.1.11-exp.1 (8-8-2023)
|
48
|
+
|
49
|
+
**Changes**
|
50
|
+
|
51
|
+
- Added a new config `stats` to control stats file generation.
|
52
|
+
|
53
|
+
**Features:-**
|
54
|
+
|
55
|
+
- Generating stats.json file for the build assets only in production mode. To use this feature we need to add `stats > enable` or cli flags `enable_stats`.
|
56
|
+
|
57
|
+
# 1.1.11 (4-8-2023)
|
58
|
+
|
59
|
+
**Changes**
|
60
|
+
|
61
|
+
- we have renamed our default config file as `react-cli.config.js` instead of `build.config.js`. But we still support `build.config.js` we will remove it in later major version.
|
62
|
+
|
63
|
+
- Prop-type, Prop description, Default Props support for docs given.
|
64
|
+
- Docs and Docs_Code UI updated.
|
65
|
+
|
66
|
+
**Features:-**
|
67
|
+
|
68
|
+
- custom classname prefix for separate packages now supported.
|
69
|
+
- to use custom classnames for specific patterns, we use the following pattern in `app > customClassNamePrefix` or `docs > customClassNamePrefix` :
|
70
|
+
|
71
|
+
```
|
72
|
+
"customClassNamePrefix" : [
|
73
|
+
{
|
74
|
+
"enable": true,
|
75
|
+
"prefix": "[required-prefix]",
|
76
|
+
"patterns":[
|
77
|
+
"**/[path-name]/**/*.css"
|
78
|
+
]
|
79
|
+
}
|
80
|
+
]
|
81
|
+
```
|
82
|
+
|
83
|
+
For example,
|
84
|
+
|
85
|
+
```
|
86
|
+
"customClassNamePrefix": [
|
87
|
+
{
|
88
|
+
"enable": true,
|
89
|
+
"prefix": "zdSvg",
|
90
|
+
"patterns": [
|
91
|
+
"**/@zohodesk/svg/**/*.css"
|
92
|
+
]
|
93
|
+
},
|
94
|
+
],
|
95
|
+
```
|
96
|
+
|
97
|
+
**Issue Fix:**
|
98
|
+
|
99
|
+
- typo fix, (../src/common/runPreProcess.js) to (../lib/common/runPreProcess.js) in cli.js our code.
|
100
|
+
|
47
101
|
# 1.1.10 (2-8-2023)
|
48
102
|
|
49
103
|
**Issue Fix:**
|
@@ -213,8 +267,8 @@ Now to run app
|
|
213
267
|
|
214
268
|
**Breaking Changes:**
|
215
269
|
|
216
|
-
- We have remove ssl certificate for security reasons.
|
217
|
-
So default https server won't run.
|
270
|
+
- We have remove ssl certificate for security reasons.
|
271
|
+
So default https server won't run.
|
218
272
|
In order to make it work as before you need to specify two things
|
219
273
|
1. install `@zohodesk-private/client_dev_cert`
|
220
274
|
2. `react-cli.app.server.httpsCerts` option example `"httpsCerts": "@zohodesk-private/client_dev_cert"`
|
@@ -230,8 +284,8 @@ Now to run app
|
|
230
284
|
|
231
285
|
**Breaking Changes:**
|
232
286
|
|
233
|
-
- We have remove ssl certificate for security reasons.
|
234
|
-
So default https server won't run.
|
287
|
+
- We have remove ssl certificate for security reasons.
|
288
|
+
So default https server won't run.
|
235
289
|
In order to make it work as before you need to specify two things
|
236
290
|
1. install `@zohodesk-private/client_dev_cert`
|
237
291
|
2. `react-cli.app.server.httpsCerts` option example `"httpsCerts": "@zohodesk-private/client_dev_cert"`
|
@@ -248,8 +302,8 @@ Now to run app
|
|
248
302
|
|
249
303
|
**Breaking Changes:**
|
250
304
|
|
251
|
-
- We have remove ssl certificate for security reasons.
|
252
|
-
So default https server won't run.
|
305
|
+
- We have remove ssl certificate for security reasons.
|
306
|
+
So default https server won't run.
|
253
307
|
In order to make it work as before you need to specify two things
|
254
308
|
1. install `@zohodesk-private/client_dev_cert`
|
255
309
|
2. `react-cli.app.server.httpsCerts` option example `"httpsCerts": "@zohodesk-private/client_dev_cert"`
|
@@ -315,8 +369,8 @@ cli has been updated to fix compose issue faced when classname:hover exists and
|
|
315
369
|
|
316
370
|
**Feature:-**
|
317
371
|
|
318
|
-
- `react-cli.test.classnameFormat` option added to change CssModules (Ex: import style from "./a.module.css" ) className transform template unittest case.
|
319
|
-
|
372
|
+
- `react-cli.test.classnameFormat` option added to change CssModules (Ex: import style from "./a.module.css" ) className transform template unittest case.
|
373
|
+
`classnameFormat` default value `[classname]` you can customize it. Example: `[classname]-[hash]`
|
320
374
|
|
321
375
|
**Changes:-**
|
322
376
|
|
@@ -335,7 +389,7 @@ For an more information and reference, refer to `[details](https://zgit.csez.zoh
|
|
335
389
|
|
336
390
|
# 0.0.1-beta.172
|
337
391
|
|
338
|
-
We have renamed some options, For Our future features convenience.
|
392
|
+
We have renamed some options, For Our future features convenience.
|
339
393
|
We have given fallback support.
|
340
394
|
Deprecation Warnings:-
|
341
395
|
|
@@ -413,7 +467,7 @@ Features:-
|
|
413
467
|
|
414
468
|
# 0.0.1-beta.167.1
|
415
469
|
|
416
|
-
In this version we merged changes from [0.0.1-betaa.138.1](#0.0.1-betaa.138.1).
|
470
|
+
In this version we merged changes from [0.0.1-betaa.138.1](#0.0.1-betaa.138.1).
|
417
471
|
and with [0.0.1-beta.167](#0.0.1-beta.167) version changes.
|
418
472
|
|
419
473
|
# 0.0.1-beta.167
|
@@ -1321,3 +1375,7 @@ impact servise related changes:-
|
|
1321
1375
|
- prod string error fix
|
1322
1376
|
- efc build support
|
1323
1377
|
- single style tag support
|
1378
|
+
|
1379
|
+
```
|
1380
|
+
|
1381
|
+
```
|
package/bin/cli.js
CHANGED
@@ -6,7 +6,7 @@ const getOptions = require('../lib/utils/getOptions.js').default;
|
|
6
6
|
|
7
7
|
const { log } = require('../lib/utils/log.js');
|
8
8
|
const { getCliPath } = require('../lib/servers/getCliPath.js');
|
9
|
-
const { runPreProcess } = require('../
|
9
|
+
const { runPreProcess } = require('../lib/common/runPreProcess.js');
|
10
10
|
//initPreCommitHook();
|
11
11
|
|
12
12
|
const [, , option] = process.argv;
|
@@ -1,16 +1,21 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.runPreProcess = runPreProcess;
|
4
7
|
|
5
|
-
|
6
|
-
existsSync
|
7
|
-
} = require('fs');
|
8
|
+
var _path = _interopRequireWildcard(require("path"));
|
8
9
|
|
9
|
-
|
10
|
-
spawn
|
11
|
-
} = require('child_process');
|
10
|
+
var _fs = require("fs");
|
12
11
|
|
13
|
-
|
12
|
+
var _child_process = require("child_process");
|
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 runPreProcess({
|
14
19
|
options,
|
15
20
|
option,
|
16
21
|
nodemon,
|
@@ -19,17 +24,17 @@ exports.runPreProcess = function runPreProcess({
|
|
19
24
|
const {
|
20
25
|
preprocess
|
21
26
|
} = options;
|
22
|
-
const preprocessorPath = preprocess.runner ?
|
27
|
+
const preprocessorPath = preprocess.runner ? _path.default.join(process.cwd(), preprocess.runner) : '';
|
23
28
|
const preprocessCli = preprocess.stopNodemon ? 'node' : nodemon;
|
24
29
|
|
25
|
-
if (preprocessorPath && existsSync(preprocessorPath)) {
|
26
|
-
const preprocessorDirPath =
|
30
|
+
if (preprocessorPath && (0, _fs.existsSync)(preprocessorPath)) {
|
31
|
+
const preprocessorDirPath = (0, _path.dirname)(preprocessorPath);
|
27
32
|
const watchOptions = preprocessCli === nodemon ? ['--watch', preprocessorDirPath] : []; // eslint-disable-next-line default-case
|
28
33
|
|
29
34
|
switch (option) {
|
30
35
|
case 'start':
|
31
36
|
case 'docs':
|
32
|
-
spawn(preprocessCli, [preprocessorPath, ...watchOptions], {
|
37
|
+
(0, _child_process.spawn)(preprocessCli, [preprocessorPath, ...watchOptions], {
|
33
38
|
stdio: 'inherit',
|
34
39
|
cwd: preprocessorDirPath
|
35
40
|
}); // NOTE: it's ok if we not close this here
|
@@ -53,7 +58,7 @@ exports.runPreProcess = function runPreProcess({
|
|
53
58
|
{
|
54
59
|
const result = spawnSync(preprocessCli, [preprocessorPath, ...watchOptions], {
|
55
60
|
stdio: 'inherit',
|
56
|
-
cwd:
|
61
|
+
cwd: preprocessorDirPath
|
57
62
|
});
|
58
63
|
process.exit(result.status);
|
59
64
|
break;
|
@@ -63,4 +68,4 @@ exports.runPreProcess = function runPreProcess({
|
|
63
68
|
console.error(`preProcessor not exists ${preprocessorPath}`);
|
64
69
|
process.exit(0);
|
65
70
|
}
|
66
|
-
}
|
71
|
+
}
|
@@ -23,7 +23,8 @@ let {
|
|
23
23
|
folder,
|
24
24
|
publicPath,
|
25
25
|
cssHashSelectors,
|
26
|
-
classNamePrefix
|
26
|
+
classNamePrefix,
|
27
|
+
customClassNamePrefix
|
27
28
|
}
|
28
29
|
},
|
29
30
|
packageVersion
|
@@ -83,7 +84,7 @@ module.exports = {
|
|
83
84
|
loader: 'css-loader',
|
84
85
|
options: {
|
85
86
|
modules: {
|
86
|
-
getLocalIdent: (0, _cssClassNameGenerate.default)(cssUniqueness, cssHashSelectors, classNamePrefix)
|
87
|
+
getLocalIdent: (0, _cssClassNameGenerate.default)(cssUniqueness, cssHashSelectors, classNamePrefix, customClassNamePrefix)
|
87
88
|
}
|
88
89
|
}
|
89
90
|
}]
|
@@ -30,6 +30,7 @@ const {
|
|
30
30
|
cssVariableReplacementConfig,
|
31
31
|
selectorWeightConfig,
|
32
32
|
cssUniqueness,
|
33
|
+
customClassNamePrefix,
|
33
34
|
seperateCssModules,
|
34
35
|
changeRuntimeChunkChar,
|
35
36
|
// we are going to use this for fonts file name collide in issue in devmode
|
@@ -108,6 +109,7 @@ module.exports = {
|
|
108
109
|
mediaQueryHoverActiveString,
|
109
110
|
cssVariableReplacementConfig,
|
110
111
|
selectorWeightConfig,
|
112
|
+
customClassNamePrefix,
|
111
113
|
classNameBlob: '[local]',
|
112
114
|
cssUniqueness: false,
|
113
115
|
selectorReplace: null,
|
@@ -124,6 +126,7 @@ module.exports = {
|
|
124
126
|
selectorWeightConfig,
|
125
127
|
classNameBlob: null,
|
126
128
|
cssUniqueness,
|
129
|
+
customClassNamePrefix,
|
127
130
|
selectorReplace,
|
128
131
|
cssHashSelectors,
|
129
132
|
classNamePrefix,
|
@@ -20,6 +20,7 @@ const {
|
|
20
20
|
componentFolder,
|
21
21
|
enableChunkHash,
|
22
22
|
cssUniqueness,
|
23
|
+
customClassNamePrefix,
|
23
24
|
plugins,
|
24
25
|
exclude,
|
25
26
|
patterns,
|
@@ -86,6 +87,7 @@ module.exports = isSSTest => ({
|
|
86
87
|
selectorWeightConfig,
|
87
88
|
classNameBlob: false,
|
88
89
|
cssUniqueness,
|
90
|
+
customClassNamePrefix,
|
89
91
|
selectorReplace,
|
90
92
|
cssHashSelectors,
|
91
93
|
classNamePrefix,
|
@@ -19,6 +19,7 @@ const {
|
|
19
19
|
docs: {
|
20
20
|
componentFolder,
|
21
21
|
cssUniqueness,
|
22
|
+
customClassNamePrefix,
|
22
23
|
plugins,
|
23
24
|
exclude,
|
24
25
|
patterns,
|
@@ -85,6 +86,7 @@ module.exports = {
|
|
85
86
|
selectorWeightConfig,
|
86
87
|
classNameBlob: false,
|
87
88
|
cssUniqueness,
|
89
|
+
customClassNamePrefix,
|
88
90
|
selectorReplace: null,
|
89
91
|
cssHashSelectors,
|
90
92
|
classNamePrefix,
|
@@ -34,6 +34,7 @@ const {
|
|
34
34
|
cssVariableReplacementConfig,
|
35
35
|
selectorWeightConfig,
|
36
36
|
cssUniqueness,
|
37
|
+
customClassNamePrefix,
|
37
38
|
server: {
|
38
39
|
mode
|
39
40
|
},
|
@@ -161,6 +162,7 @@ module.exports = {
|
|
161
162
|
mediaQueryHoverActiveString,
|
162
163
|
classNameBlob: '[local]',
|
163
164
|
cssUniqueness: false,
|
165
|
+
customClassNamePrefix,
|
164
166
|
selectorReplace: null,
|
165
167
|
postCssPluginOrder
|
166
168
|
})
|
@@ -175,6 +177,7 @@ module.exports = {
|
|
175
177
|
selectorWeightConfig,
|
176
178
|
classNameBlob: false,
|
177
179
|
cssUniqueness,
|
180
|
+
customClassNamePrefix,
|
178
181
|
selectorReplace,
|
179
182
|
cssHashSelectors,
|
180
183
|
classNamePrefix,
|
@@ -44,7 +44,8 @@ const getCSSLoaders = optionsObj => {
|
|
44
44
|
selectorReplace,
|
45
45
|
cssHashSelectors,
|
46
46
|
classNamePrefix,
|
47
|
-
postCssPluginOrder
|
47
|
+
postCssPluginOrder,
|
48
|
+
customClassNamePrefix
|
48
49
|
} = optionsObj;
|
49
50
|
const {
|
50
51
|
devCssFileBountry
|
@@ -65,7 +66,7 @@ const getCSSLoaders = optionsObj => {
|
|
65
66
|
if (classNameBlob) {
|
66
67
|
cssLoaderOptions.modules.localIdentName = classNameBlob;
|
67
68
|
} else {
|
68
|
-
cssLoaderOptions.modules.getLocalIdent = (0, _cssClassNameGenerate.default)(cssUniqueness, cssHashSelectors, classNamePrefix, patterns);
|
69
|
+
cssLoaderOptions.modules.getLocalIdent = (0, _cssClassNameGenerate.default)(cssUniqueness, cssHashSelectors, classNamePrefix, customClassNamePrefix, patterns);
|
69
70
|
}
|
70
71
|
|
71
72
|
const pluginOrder = calculatePostCssPluginOrder(postCssPluginOrder, Object.keys(plugins).filter(x => plugins[x] === true)); // console.log('selector weight config : ', selectorWeightConfig);
|
package/lib/logger.js
CHANGED
@@ -5,8 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.errorLogger = errorLogger;
|
7
7
|
exports.messageLogger = messageLogger;
|
8
|
+
exports.verboseLogger = verboseLogger;
|
8
9
|
exports.warnLogger = warnLogger;
|
9
10
|
|
11
|
+
/* eslint-disable no-console */
|
10
12
|
function messageLogger(...args) {
|
11
13
|
console.log(...args);
|
12
14
|
}
|
@@ -17,4 +19,9 @@ function errorLogger(...args) {
|
|
17
19
|
|
18
20
|
function warnLogger(...args) {
|
19
21
|
console.warn(...args);
|
22
|
+
}
|
23
|
+
|
24
|
+
function verboseLogger(...args) {
|
25
|
+
// TODO: need to be remove when publish happens
|
26
|
+
process.env.VERBOSE === 'true' && console.log('\x1b[33m [verbose] \x1b[0m', ...args);
|
20
27
|
}
|
@@ -35,6 +35,8 @@ var _RtlCssPlugin = require("../plugins/RtlSplitPlugin/RtlCssPlugin");
|
|
35
35
|
|
36
36
|
var _configHtmlWebpackPlugins = require("./configHtmlWebpackPlugins");
|
37
37
|
|
38
|
+
var _StatsPlugin = _interopRequireDefault(require("../plugins/StatsPlugin"));
|
39
|
+
|
38
40
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
39
41
|
|
40
42
|
// eslint-disable-next-line no-unused-vars
|
@@ -88,6 +90,9 @@ const getProdPlugins = (options, publicPath = '') => {
|
|
88
90
|
templateFilePath,
|
89
91
|
localeAttr: efcLocaleAttr
|
90
92
|
} = options.efc;
|
93
|
+
const {
|
94
|
+
enable: enableStats
|
95
|
+
} = options.stats;
|
91
96
|
const hasEFC = newOptionForEnableEFC || prevOptionForEnableEFC;
|
92
97
|
const hashTempalate = enableChunkHash ? '.[chunkhash:20]_' : '';
|
93
98
|
const cssLTRFileNameTempalte = `css/[name]${hashTempalate}${enableRTLSplit ? '.ltr' : ''}.css`;
|
@@ -288,6 +293,7 @@ const getProdPlugins = (options, publicPath = '') => {
|
|
288
293
|
|
289
294
|
|
290
295
|
customAttributes.enable && pluginsArr.push(new _CustomAttributePlugin.CustomAttributePlugin(customAttributes));
|
296
|
+
enableStats && new _StatsPlugin.default();
|
291
297
|
return pluginsArr;
|
292
298
|
};
|
293
299
|
|
@@ -0,0 +1,44 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
const {
|
4
|
+
defaulter
|
5
|
+
} = require('../utils/getOptions');
|
6
|
+
|
7
|
+
const fs = require('fs');
|
8
|
+
|
9
|
+
const path = require('path');
|
10
|
+
|
11
|
+
const pluginName = 'stats-plugin';
|
12
|
+
const statsSchema = {
|
13
|
+
preset: 'normal',
|
14
|
+
moduleTrace: true // source: true
|
15
|
+
// errorDetails: true,
|
16
|
+
// chunkRelations: true
|
17
|
+
|
18
|
+
};
|
19
|
+
module.exports = class StatsPlugin {
|
20
|
+
constructor(options = {}) {
|
21
|
+
this.statsOptions = defaulter(statsSchema, options);
|
22
|
+
}
|
23
|
+
|
24
|
+
apply(compiler) {
|
25
|
+
compiler.hooks.done.tap(pluginName, stats => {
|
26
|
+
const statsJson = stats.toJson(this.statsOptions);
|
27
|
+
this.emitStats(statsJson);
|
28
|
+
});
|
29
|
+
}
|
30
|
+
|
31
|
+
emitStats(statsJson) {
|
32
|
+
const {
|
33
|
+
outputPath
|
34
|
+
} = statsJson;
|
35
|
+
const stringifiedJson = typeof statsJson === 'object' ? JSON.stringify(statsJson) : statsJson;
|
36
|
+
const bufferJson = Buffer.from(stringifiedJson);
|
37
|
+
fs.writeFile(path.join(outputPath, 'stats.json'), bufferJson, err => {
|
38
|
+
if (err) {
|
39
|
+
throw err;
|
40
|
+
}
|
41
|
+
});
|
42
|
+
}
|
43
|
+
|
44
|
+
};
|
package/lib/schemas/index.js
CHANGED
@@ -15,7 +15,6 @@ 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
|
-
cliRootPath: null,
|
19
18
|
unstableDepsInverse: {
|
20
19
|
value: false,
|
21
20
|
cli: 'unstable_deps_inverse'
|
@@ -130,6 +129,7 @@ var _default = {
|
|
130
129
|
value: '@zohodesk/client_packages_group',
|
131
130
|
cli: 'module_resolve_path'
|
132
131
|
},
|
132
|
+
customClassNamePrefix: [],
|
133
133
|
// this option only for impact testing
|
134
134
|
devCssFileBountry: {
|
135
135
|
value: '',
|
@@ -357,6 +357,7 @@ var _default = {
|
|
357
357
|
hover: 'all and (min--moz-device-pixel-ratio:0) and (hover: hover), (hover: hover)',
|
358
358
|
none: '(hover: none)'
|
359
359
|
},
|
360
|
+
customClassNamePrefix: [],
|
360
361
|
componentFolder: 'src',
|
361
362
|
cssUniqueness: {
|
362
363
|
value: true,
|
@@ -722,6 +723,12 @@ var _default = {
|
|
722
723
|
cli: 'module_mode'
|
723
724
|
},
|
724
725
|
disableES5Transpile: true
|
726
|
+
},
|
727
|
+
stats: {
|
728
|
+
enable: {
|
729
|
+
value: false,
|
730
|
+
cli: 'enable_stats'
|
731
|
+
}
|
725
732
|
}
|
726
733
|
};
|
727
734
|
exports.default = _default;
|
@@ -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) => (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,
|
@@ -86,7 +108,18 @@ var _default = (unique = true, {
|
|
86
108
|
if (unique) {
|
87
109
|
const h = (0, _getHash.default)(`${relativePath}-${localName}`, 10);
|
88
110
|
return `${classNamePrefix}${h}`;
|
89
|
-
}
|
111
|
+
}
|
112
|
+
|
113
|
+
const patternClass = patternBasedClass({
|
114
|
+
customClassNamePrefix,
|
115
|
+
context,
|
116
|
+
relativePath,
|
117
|
+
localName
|
118
|
+
});
|
119
|
+
|
120
|
+
if (patternClass) {
|
121
|
+
return patternClass;
|
122
|
+
} //css file has case sensitive selector issue so can't toLowerCase
|
90
123
|
//let local = localName.toLowerCase()
|
91
124
|
|
92
125
|
|
package/lib/utils/getOptions.js
CHANGED
@@ -3,7 +3,7 @@
|
|
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
|
|
@@ -15,6 +15,10 @@ var _schemas = _interopRequireDefault(require("../schemas"));
|
|
15
15
|
|
16
16
|
var _deprecationSupport = require("./deprecationSupport");
|
17
17
|
|
18
|
+
var _deprecationLogger = require("../deprecationLogger");
|
19
|
+
|
20
|
+
var _logger = require("../logger");
|
21
|
+
|
18
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
19
23
|
|
20
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); }
|
@@ -128,10 +132,15 @@ const defaulter = (target, source) => {
|
|
128
132
|
return defaultObject;
|
129
133
|
};
|
130
134
|
|
135
|
+
exports.defaulter = defaulter;
|
131
136
|
global.reactCLIOptions = null;
|
132
137
|
|
133
138
|
const getOptionsFromConfigFile = (appPath, configFileName) => {
|
134
|
-
const fileName = configFileName || '
|
139
|
+
const fileName = configFileName || 'react-cli.config.js';
|
140
|
+
|
141
|
+
if (!configFileName) {
|
142
|
+
(0, _logger.verboseLogger)('we have used default react-cli.config.js');
|
143
|
+
}
|
135
144
|
|
136
145
|
const packagePath = _path.default.join(appPath, fileName);
|
137
146
|
|
@@ -139,6 +148,13 @@ const getOptionsFromConfigFile = (appPath, configFileName) => {
|
|
139
148
|
return require(packagePath).config;
|
140
149
|
}
|
141
150
|
|
151
|
+
const oldDeprecatedConfigFilePath = _path.default.join(appPath, 'build.config.js');
|
152
|
+
|
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;
|
156
|
+
}
|
157
|
+
|
142
158
|
return null;
|
143
159
|
};
|
144
160
|
|
package/npm-shrinkwrap.json
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "@zohodesk/react-cli",
|
3
|
-
"version": "1.1.
|
3
|
+
"version": "1.1.11-exp.1",
|
4
4
|
"lockfileVersion": 2,
|
5
5
|
"requires": true,
|
6
6
|
"packages": {
|
7
7
|
"": {
|
8
8
|
"name": "@zohodesk/react-cli",
|
9
|
-
"version": "1.1.
|
9
|
+
"version": "1.1.11-exp.1",
|
10
10
|
"license": "ISC",
|
11
11
|
"dependencies": {
|
12
12
|
"@babel/cli": "7.10.5",
|