@redhat-cloud-services/frontend-components-config-utilities 2.0.0-beta.0 → 2.0.0-beta.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/package.json +2 -1
- package/search-ignored-styles.js +26 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redhat-cloud-services/frontend-components-config-utilities",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.1",
|
|
4
4
|
"description": "Utilities for shared config used in RedHat Cloud Services project.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"publishConfig": {
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"webpack": "^5.0.0"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
+
"chalk": "^4.1.2",
|
|
23
24
|
"@openshift/dynamic-plugin-sdk-webpack": "^3.0.0",
|
|
24
25
|
"node-fetch": "2.6.7"
|
|
25
26
|
}
|
package/search-ignored-styles.js
CHANGED
|
@@ -1,20 +1,37 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
const glob = require('glob');
|
|
3
|
+
const chalk = require('chalk');
|
|
4
|
+
|
|
5
|
+
function logWarning(message) {
|
|
6
|
+
console.log(chalk.blue('[fec]') + chalk.yellow(' WARNING: ') + message);
|
|
7
|
+
}
|
|
3
8
|
|
|
4
9
|
/**
|
|
5
10
|
* Function that searches for all patternfly styles in node_modules and outputs an webpack alias object to ignore found modules.
|
|
6
11
|
* @param {string} root absolute directory path to root folder containig package.json
|
|
12
|
+
* @param {string[]} ...paths node_modulesDirectories
|
|
7
13
|
* @returns {Object}
|
|
8
14
|
*/
|
|
9
|
-
const searchIgnoredStyles = (root) => {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
const searchIgnoredStyles = (root, ...paths) => {
|
|
16
|
+
const modulesPaths = [path.join(root, 'node_modules/@patternfly/react-styles'), ...paths.map((path) => `${path}/@patternfly/react-styles`)];
|
|
17
|
+
const result = modulesPaths
|
|
18
|
+
.map((modulesPath) => glob.sync(`${modulesPath}/**/*.css`))
|
|
19
|
+
.flat()
|
|
20
|
+
.reduce(
|
|
21
|
+
(acc, curr) => ({
|
|
22
|
+
...acc,
|
|
23
|
+
[curr]: false,
|
|
24
|
+
}),
|
|
25
|
+
{}
|
|
26
|
+
);
|
|
27
|
+
if (Object.keys(result).length === 0) {
|
|
28
|
+
logWarning(`No PF CSS assets found!
|
|
29
|
+
Your application can override PF styling in deployed environments!
|
|
30
|
+
Please check your build configuration.
|
|
31
|
+
If your node_modules directory is not located at application root, provide the "nodeModulesDirectories" configuration in your build config.
|
|
32
|
+
Make sure to use absolute path to your node_modules.\n`);
|
|
33
|
+
}
|
|
34
|
+
return result;
|
|
18
35
|
};
|
|
19
36
|
|
|
20
37
|
module.exports = searchIgnoredStyles;
|