@zohodesk/react-cli 1.1.14-kubernetes → 1.1.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. package/.vscode/settings.json +25 -0
  2. package/README.md +294 -16
  3. package/bin/cli.js +30 -55
  4. package/docs/ComposeMinification.md +13 -0
  5. package/docs/CustomChunks.md +12 -9
  6. package/docs/MarkdownParser.md +18 -0
  7. package/docs/ReactLive.md +14 -0
  8. package/docs/SelectorWeight.md +3 -0
  9. package/docs/ValueReplacer.md +27 -0
  10. package/docs/VariableConversion.md +6 -1
  11. package/docs/patternFiltering.md +57 -0
  12. package/lib/common/buildEs.js +12 -0
  13. package/lib/common/runPreProcess.js +71 -0
  14. package/lib/common/splitChunks.js +65 -45
  15. package/lib/common/testPattern.js +9 -11
  16. package/lib/common/valueReplacer.js +1 -3
  17. package/lib/configs/resolvers.js +16 -5
  18. package/lib/configs/webpack.css.umd.config.js +3 -2
  19. package/lib/configs/webpack.dev.config.js +15 -5
  20. package/lib/configs/webpack.docs.config.js +17 -5
  21. package/lib/configs/webpack.impact.config.js +11 -4
  22. package/lib/configs/webpack.prod.config.js +15 -5
  23. package/lib/constants.js +3 -3
  24. package/lib/deprecationLogger.js +40 -0
  25. package/lib/loaderUtils/getCSSLoaders.js +98 -49
  26. package/lib/loaderUtils/tests/windowsModification.test.js +10 -0
  27. package/lib/loaderUtils/windowsModification.js +6 -1
  28. package/lib/loaders/__test__/markdownLoader.spec.js +145 -0
  29. package/lib/loaders/composeLoader.js +298 -0
  30. package/lib/loaders/docsLoader.js +18 -7
  31. package/lib/loaders/markdownLoader.js +71 -0
  32. package/lib/loaders/reactLiveConvertor.js +105 -0
  33. package/lib/loaders/selectorMappingLoader.js +9 -9
  34. package/lib/logger.js +27 -0
  35. package/lib/pluginUtils/getDevPlugins.js +25 -6
  36. package/lib/pluginUtils/getProdPlugins.js +32 -5
  37. package/lib/pluginUtils/getUMDCSSPlugins.js +1 -1
  38. package/lib/pluginUtils/getUMDComponentPlugins.js +1 -1
  39. package/lib/plugins/CustomAttributePlugin.js +82 -0
  40. package/lib/plugins/CustomAttributePlugin.md +35 -0
  41. package/lib/plugins/EFCPlugin.js +9 -9
  42. package/lib/plugins/EFCTemplatePlugin.js +10 -12
  43. package/lib/plugins/EfcResourceCleanupPlugin.js +43 -0
  44. package/lib/plugins/I18NInjectIntoIndexPlugin.js +8 -9
  45. package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +2 -3
  46. package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +2 -7
  47. package/lib/plugins/I18nSplitPlugin/index.js +1 -1
  48. package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +8 -8
  49. package/lib/plugins/{UglifyCSSPlugin.js → MinifyPlugin.js} +3 -3
  50. package/lib/plugins/ReportGeneratePlugin.js +8 -6
  51. package/lib/plugins/ResourceHintsPlugin.js +13 -3
  52. package/lib/plugins/SelectorPlugin.js +77 -37
  53. package/lib/plugins/StatsPlugin.js +82 -0
  54. package/lib/plugins/UnusedFilesFindPlugin.js +7 -5
  55. package/lib/plugins/VariableConversionCollector.js +40 -101
  56. package/lib/plugins/index.js +7 -7
  57. package/lib/plugins/utils/classHandling.js +35 -0
  58. package/lib/plugins/utils/fileHandling.js +92 -0
  59. package/lib/plugins/utils/tests/fileHandling.test.js +30 -0
  60. package/lib/plugins/variableConvertorUtils.js +133 -0
  61. package/lib/postcss-plugins/EmptyPlugin.js +8 -0
  62. package/lib/postcss-plugins/ExcludePlugin.js +1 -1
  63. package/lib/postcss-plugins/IncludePlugin.js +23 -0
  64. package/lib/postcss-plugins/RTLSplitPlugin.js +4 -10
  65. package/lib/postcss-plugins/SelectorReplace.js +80 -0
  66. package/lib/postcss-plugins/ValueReplacer.js +8 -29
  67. package/lib/postcss-plugins/__test__/selectorReplace.test.js +28 -0
  68. package/lib/postcss-plugins/__test__/valueReplacer.spec.js +43 -0
  69. package/lib/postcss-plugins/hoverActivePlugin.js +0 -6
  70. package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +0 -1
  71. package/lib/postcss-plugins/variableModificationPlugin/index.js +94 -38
  72. package/lib/schemas/index.js +95 -18
  73. package/lib/servers/devBuild.js +13 -11
  74. package/lib/servers/getCliPath.js +3 -5
  75. package/lib/servers/httpsOptions.js +12 -13
  76. package/lib/servers/nowatchserver.js +62 -55
  77. package/lib/servers/requireLocalOrGlobal.js +61 -0
  78. package/lib/servers/server.js +53 -52
  79. package/lib/utils/cssClassNameGenerate.js +70 -13
  80. package/lib/utils/deprecationSupport.js +134 -0
  81. package/lib/utils/getOptions.js +35 -28
  82. package/lib/utils/getServerURL.js +1 -9
  83. package/lib/utils/index.js +14 -12
  84. package/lib/utils/initPreCommitHook.js +5 -5
  85. package/lib/utils/log.js +11 -0
  86. package/lib/utils/object-manipulation.js +88 -0
  87. package/lib/utils/pullOrigin.js +3 -3
  88. package/lib/utils/reinstallDependencies.js +3 -3
  89. package/lib/utils/selectorReplacer.js +47 -0
  90. package/lib/utils/switchBranch.js +4 -2
  91. package/lib/utils/variableConverter.js +104 -0
  92. package/npm-shrinkwrap.json +33485 -0
  93. package/package.json +5 -3
  94. package/templates/docs/all.html +1 -0
  95. package/templates/docs/component.html +1 -0
  96. package/templates/docs/components.html +1 -0
  97. package/templates/docs/css/markdown.css +202 -0
  98. package/templates/docs/css/style.css +136 -169
  99. package/templates/docs/index.html +796 -632
  100. package/lib/plugins/composeCommonPlugin.js +0 -30
  101. package/lib/postcss-plugins/variableModifier.js +0 -244
@@ -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';
@@ -86,38 +88,41 @@ app.use('/wms/*', (req, res) => {
86
88
 
87
89
  const httpsServer = _https.default.createServer(httpsOptions, app);
88
90
 
89
- const wss = new _ws.default.Server({
90
- server: httpsServer
91
- });
92
- let wsPool = [];
93
- wss.on('connection', ws => {
94
- wsPool.push(ws);
95
- ws.on('close', () => {
96
- wsPool = wsPool.filter(ws1 => ws1 !== ws);
91
+ if (httpsOptions) {
92
+ const wss = new _ws.default.Server({
93
+ server: httpsServer
97
94
  });
98
- ws.on('message', message => {
99
- (0, _utils.log)('received: %s', message);
95
+ let wsPool = [];
96
+ wss.on('connection', ws => {
97
+ wsPool.push(ws);
98
+ ws.on('close', () => {
99
+ wsPool = wsPool.filter(ws1 => ws1 !== ws);
100
+ });
101
+ ws.on('message', message => {
102
+ (0, _utils.log)('received: %s', message);
103
+ });
104
+ ws.send('something');
100
105
  });
101
- ws.send('something');
102
- });
103
- app.post('/wmsmockapi', (req, res) => {
104
- wsPool.forEach(ws => {
105
- const {
106
- body
107
- } = req;
108
-
109
- try {
110
- ws.send(JSON.stringify(body));
111
- } catch (e) {
112
- (0, _utils.log)(e, body);
113
- }
106
+ app.post('/wmsmockapi', (req, res) => {
107
+ wsPool.forEach(ws => {
108
+ const {
109
+ body
110
+ } = req;
111
+
112
+ try {
113
+ ws.send(JSON.stringify(body));
114
+ } catch (e) {
115
+ (0, _utils.log)(e, body);
116
+ }
117
+ });
118
+ res.send('success');
114
119
  });
115
- res.send('success');
116
- }); // let webpackCompilation;
120
+ } // let webpackCompilation;
117
121
  // compiler.hooks.afterCompile.tap('ReactCLI', compilation => {
118
122
  // webpackCompilation = compilation;
119
123
  // });
120
124
 
125
+
121
126
  if (zipname) {
122
127
  app.use(`/zips/${zipname}.zip`, (req, res) => {
123
128
  res.download(_path.default.join(process.cwd(), cssSelectorZipPath), err => {
@@ -125,7 +130,7 @@ if (zipname) {
125
130
  throw err;
126
131
  }
127
132
 
128
- console.log(`${zipname}.zip downloaded`);
133
+ (0, _logger.messageLogger)(`${zipname}.zip downloaded`);
129
134
  });
130
135
  });
131
136
  app.use('/zips/build.zip', (req, res) => {
@@ -134,7 +139,7 @@ if (zipname) {
134
139
  throw err;
135
140
  }
136
141
 
137
- console.log('build.zip downloaded');
142
+ (0, _logger.messageLogger)('build.zip downloaded');
138
143
  });
139
144
  });
140
145
  }
@@ -151,40 +156,42 @@ if (contextURL) {
151
156
  app.use('/*', _express.default.static(context));
152
157
  }
153
158
 
154
- httpsServer.listen(port, err => {
155
- if (err) {
156
- throw err;
157
- }
159
+ if (httpsOptions) {
160
+ httpsServer.listen(port, err => {
161
+ if (err) {
162
+ throw err;
163
+ }
158
164
 
159
- (0, _utils.log)(`Listening at ${serverUrl}${contextURL}/`);
160
- });
165
+ (0, _utils.log)(`Listening at ${serverUrl}${contextURL}/`);
166
+ });
161
167
 
162
- if (isCompatableHttp2) {
163
- const http2 = require('http2');
168
+ if (isCompatableHttp2) {
169
+ const http2 = require('http2');
164
170
 
165
- const http2Server = http2.createSecureServer(httpsOptions); // eslint-disable-next-line no-unused-vars
171
+ const http2Server = http2.createSecureServer(httpsOptions); // eslint-disable-next-line no-unused-vars
166
172
 
167
- http2Server.on('stream', (stream, headers) => {
168
- stream.respond({
169
- 'content-type': 'text/html',
170
- ':status': 200
173
+ http2Server.on('stream', (stream, headers) => {
174
+ stream.respond({
175
+ 'content-type': 'text/html',
176
+ ':status': 200
177
+ });
178
+ stream.end('<h1>Hello World! <br>Working with http2</h1>');
171
179
  });
172
- stream.end('<h1>Hello World! <br>Working with http2</h1>');
173
- });
174
- const http2Port = Number(port) + 1;
175
- http2Server.listen(http2Port, err => {
176
- if (err) {
177
- throw err;
178
- }
180
+ const http2Port = Number(port) + 1;
181
+ http2Server.listen(http2Port, err => {
182
+ if (err) {
183
+ throw err;
184
+ }
179
185
 
180
- (0, _utils.log)(`Listening at ${(0, _utils.getServerURL)({
181
- host,
182
- domain,
183
- port: http2Port
184
- }, 'htt' + 'ps')}${contextURL}/`, 'http2 server');
185
- });
186
- } else {
187
- (0, _utils.log)('Your node version didn\'t adopted http2 support. Kindly update that to 8 LTS or above you can engage the http2');
186
+ (0, _utils.log)(`Listening at ${(0, _utils.getServerURL)({
187
+ host,
188
+ domain,
189
+ port: http2Port
190
+ }, 'htt' + 'ps')}${contextURL}/`, 'http2 server');
191
+ });
192
+ } else {
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');
194
+ }
188
195
  }
189
196
 
190
197
  const httpPort = Number(port) + (isCompatableHttp2 ? 2 : 1);
@@ -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[0] === '.'; // 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
+ }
@@ -70,8 +70,7 @@ if (mode === 'prod') {
70
70
  config = require('../configs/webpack.dev.config');
71
71
  } else {
72
72
  throw new Error('You must configure valid option in mode');
73
- } // console.log({ contextURL });
74
-
73
+ }
75
74
 
76
75
  const compiler = (0, _webpack.default)(config);
77
76
  const webpackServerOptions = {
@@ -101,7 +100,6 @@ app.use((0, _HMRMiddleware.default)(compiler, {
101
100
  path: '/sockjs-node/info'
102
101
  }));
103
102
  app.use((req, res, next) => {
104
- //console.log('origin', req.get('origin'));
105
103
  res.setHeader('Access-Control-Allow-Origin', req.get('origin') || '*'); // res.setHeader('Access-Control-Allow-Origin', req.get('origin'));
106
104
 
107
105
  res.setHeader('Access-Control-Allow-Private-Network', true);
@@ -117,34 +115,37 @@ app.use('/wms/*', (req, res) => {
117
115
 
118
116
  const httpsServer = _https.default.createServer(httpsOptions, app);
119
117
 
120
- const wss = new _ws.default.Server({
121
- server: httpsServer
122
- });
123
- let wsPool = [];
124
- wss.on('connection', ws => {
125
- wsPool.push(ws);
126
- ws.on('close', () => {
127
- wsPool = wsPool.filter(ws1 => ws1 !== ws);
118
+ if (httpsOptions) {
119
+ const wss = new _ws.default.Server({
120
+ server: httpsServer
128
121
  });
129
- ws.on('message', message => {
130
- (0, _utils.log)('received: %s', message);
122
+ let wsPool = [];
123
+ wss.on('connection', ws => {
124
+ wsPool.push(ws);
125
+ ws.on('close', () => {
126
+ wsPool = wsPool.filter(ws1 => ws1 !== ws);
127
+ });
128
+ ws.on('message', message => {
129
+ (0, _utils.log)('received: %s', message);
130
+ });
131
+ ws.send('something');
131
132
  });
132
- ws.send('something');
133
- });
134
- app.post('/wmsmockapi', (req, res) => {
135
- wsPool.forEach(ws => {
136
- const {
137
- body
138
- } = req;
139
-
140
- try {
141
- ws.send(JSON.stringify(body));
142
- } catch (e) {
143
- (0, _utils.log)(e, body);
144
- }
133
+ app.post('/wmsmockapi', (req, res) => {
134
+ wsPool.forEach(ws => {
135
+ const {
136
+ body
137
+ } = req;
138
+
139
+ try {
140
+ ws.send(JSON.stringify(body));
141
+ } catch (e) {
142
+ (0, _utils.log)(e, body);
143
+ }
144
+ });
145
+ res.send('success');
145
146
  });
146
- res.send('success');
147
- });
147
+ }
148
+
148
149
  let webpackCompilation;
149
150
  let initalHTML;
150
151
  compiler.hooks.afterCompile.tap('ReactCLI', compilation => {
@@ -176,34 +177,34 @@ if (httpsOptions) {
176
177
 
177
178
  (0, _utils.log)(`Listening at ${serverUrl}${contextURL}/`);
178
179
  });
179
- }
180
180
 
181
- if (isCompatableHttp2 && httpsOptions) {
182
- const http2 = require('http2');
181
+ if (isCompatableHttp2) {
182
+ const http2 = require('http2');
183
183
 
184
- const http2Server = http2.createSecureServer(httpsOptions); // eslint-disable-next-line no-unused-vars
184
+ const http2Server = http2.createSecureServer(httpsOptions); // eslint-disable-next-line no-unused-vars
185
185
 
186
- http2Server.on('stream', (stream, headers) => {
187
- stream.respond({
188
- 'content-type': 'text/html',
189
- ':status': 200
186
+ http2Server.on('stream', (stream, headers) => {
187
+ stream.respond({
188
+ 'content-type': 'text/html',
189
+ ':status': 200
190
+ });
191
+ stream.end('<h1>Hello World! <br>Working with http2</h1>');
190
192
  });
191
- stream.end('<h1>Hello World! <br>Working with http2</h1>');
192
- });
193
- const http2Port = Number(port) + 1;
194
- http2Server.listen(http2Port, err => {
195
- if (err) {
196
- throw err;
197
- }
198
-
199
- (0, _utils.log)(`Listening at ${(0, _utils.getServerURL)({
200
- host,
201
- domain,
202
- port: http2Port
203
- }, 'htt' + 'ps')}${contextURL}/`, 'http2 server');
204
- });
205
- } else {
206
- (0, _utils.log)('Your node version didn\'t adopted http2 support. Kindly update that to 8 LTS or above you can engage the http2');
193
+ const http2Port = Number(port) + 1;
194
+ http2Server.listen(http2Port, err => {
195
+ if (err) {
196
+ throw err;
197
+ }
198
+
199
+ (0, _utils.log)(`Listening at ${(0, _utils.getServerURL)({
200
+ host,
201
+ domain,
202
+ port: http2Port
203
+ }, 'htt' + 'ps')}${contextURL}/`, 'http2 server');
204
+ });
205
+ } else if (httpsOptions) {
206
+ (0, _utils.log)('Your node version didn\'t adopted http2 support. Kindly update that to 8 LTS or above you can engage the http2');
207
+ }
207
208
  }
208
209
 
209
210
  const httpPort = Number(port) + (isCompatableHttp2 ? 2 : 1);
@@ -9,13 +9,15 @@ var _os = _interopRequireDefault(require("os"));
9
9
 
10
10
  var _path = _interopRequireDefault(require("path"));
11
11
 
12
+ var _fileHandling = require("../plugins/utils/fileHandling");
13
+
12
14
  var _getHash = _interopRequireDefault(require("./getHash"));
13
15
 
14
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
17
 
16
- let isWindows = _os.default.platform().toLowerCase() === 'win32';
18
+ const isWindows = _os.default.platform().toLowerCase() === 'win32';
17
19
 
18
- let isSelectorPackage = (resourcePath, packages) => {
20
+ const isSelectorPackage = (resourcePath, packages) => {
19
21
  if (!resourcePath.includes('node_modules')) {
20
22
  return false;
21
23
  }
@@ -36,38 +38,93 @@ let isSelectorPackage = (resourcePath, packages) => {
36
38
  return isValid;
37
39
  };
38
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
+
39
62
  var _default = (unique = true, {
40
63
  filenames,
41
64
  packages
42
- }, classNamePrefix) => (context, localIdentName, localName) => {
43
- // NOTE: in build macine we use date as folder path.
65
+ }, classNamePrefix, customClassNamePrefix, patterns) => (context, localIdentName, localName) => {
66
+ // console.log(patterns, context.resourcePath);
67
+ // NOTE: in build machine we use date as folder path.
44
68
  // So every time we create new build there is path will alway different
45
- // in order to minmaze that problem we try in relative path;
69
+ // in order to minimize that problem we try in relative path;
46
70
  // console.log('context.resourcePath', context.resourcePath, context);
47
71
  // let contextResourcePath = context.resourcePath;
48
- let relativePath = _path.default.relative(context.rootContext, context.resourcePath);
72
+ const filePaths = context.resourcePath.split(_path.default.sep);
73
+ const fileName = filePaths[filePaths.length - 1];
74
+ const [fileNameWithoutExt] = fileName.split('.');
75
+ const cleanFileName = fileNameWithoutExt.replace(/-/g, '_').toLowerCase();
76
+
77
+ const relativePath = _path.default.relative(context.rootContext, context.resourcePath); // console.log('customClassNamePrefix', customClassNamePrefix);
78
+
79
+ /*
80
+ input :
81
+ context.resourcePath : 'D:/MyWork/..../desk_client_app/supportapp/src/components/Avatar/Avatar.module.css,
82
+
83
+ patterns.cssVariableReplacement:
84
+ // include src folder, include deskapp folder, exclude node modules
85
+ "cssUniqueness": [
86
+ "src",
87
+ "deskapp",
88
+ "!node_modules"
89
+ ]
90
+ output :
91
+ true or false
92
+ */
93
+
49
94
 
50
95
  if (context.resourcePath.endsWith('.plain.css')) {
51
96
  return localName;
52
97
  }
98
+
99
+ if (!(0, _fileHandling.isFileNameMatchingPluginPattern)({
100
+ filename: context.resourcePath,
101
+ filterArr: patterns.cssUniqueness
102
+ })) {
103
+ return `${classNamePrefix}-${cleanFileName}-${localName}`;
104
+ }
53
105
  /* old production mode start without breaking so added. may be removed in future*/
54
106
 
55
107
 
56
108
  if (unique) {
57
- let h = (0, _getHash.default)(`${relativePath}-${localName}`, 10);
109
+ const h = (0, _getHash.default)(`${relativePath}-${localName}`, 10);
58
110
  return `${classNamePrefix}${h}`;
59
111
  }
60
- /* old production mode end*/
61
112
 
113
+ const patternClass = patternBasedClass({
114
+ customClassNamePrefix,
115
+ context,
116
+ relativePath,
117
+ localName
118
+ });
62
119
 
63
- let filePaths = context.resourcePath.split(_path.default.sep);
64
- let fileName = filePaths[filePaths.length - 1];
65
- let [fileNameWithoutExt] = fileName.split('.');
66
- let cleanFileName = fileNameWithoutExt.replace(/-/g, '_').toLowerCase(); //css file has casesensitive selector issue so can't toLowerCase
120
+ if (patternClass) {
121
+ return patternClass;
122
+ } //css file has case sensitive selector issue so can't toLowerCase
67
123
  //let local = localName.toLowerCase()
68
124
 
125
+
69
126
  if (isSelectorPackage(context.resourcePath, packages) || filenames.indexOf(cleanFileName) !== -1) {
70
- let h = (0, _getHash.default)(`${relativePath}-${localName}`, 10);
127
+ const h = (0, _getHash.default)(`${relativePath}-${localName}`, 10);
71
128
  return `${classNamePrefix}${h}`;
72
129
  }
73
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
+ }