Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable] Update build #2618

Merged
merged 65 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
5f83e7b
PF5 testing.
Hyperkid123 Jun 14, 2023
32cb978
Migrate chrome UI to use PF4@5 dependency.
Hyperkid123 Jun 16, 2023
599a524
Split PF assets into separate webpack compilation.
Hyperkid123 Jun 16, 2023
084fb25
Use contenthash instead of fullhash
Hyperkid123 Jun 19, 2023
3a42f50
Use dynamic PF imports
Hyperkid123 Jun 19, 2023
42eddf0
Add dynamic modules plugin script.
Hyperkid123 Jun 20, 2023
0a205d5
Use icons dynamic imports.
Hyperkid123 Jul 3, 2023
c3a78bd
Use stable version of PF5 release.
Hyperkid123 Aug 14, 2023
008dd76
Add cache interceptor to services and rbac API.
Hyperkid123 Aug 14, 2023
d260e25
Fix tests after dependency updates.
Hyperkid123 Aug 14, 2023
03b2c3b
Fix cypress tests after PF upgrades.
Hyperkid123 Aug 14, 2023
0c9526e
Final PR check touches.
Hyperkid123 Aug 14, 2023
c71f7d3
Add missing chunk mapper hot reload options.
Hyperkid123 Aug 15, 2023
2cbddd7
Update header toolbar dropdowns.
Hyperkid123 Aug 15, 2023
1e208bf
Fix masthead toggle styling fix
epwinchell Aug 15, 2023
faf633e
Fix services dropdown mobile styling (#5)
epwinchell Aug 16, 2023
5c817b2
Fix search text color (#4)
epwinchell Aug 16, 2023
b7e30a0
Replace missing PF4 variables
epwinchell Aug 16, 2023
ec08a4d
Fix bundle Nav styling
epwinchell Aug 16, 2023
d1c9b03
Left-align search icon in mobile
epwinchell Aug 16, 2023
4872032
Add unnecessary cy service waits for landing page test.
Hyperkid123 Aug 21, 2023
7151c73
fix(pendo): no error on missing pendo
vkrizan Aug 21, 2023
2d209c6
Merge pull request #2551 from Hyperkid123/pf5-testing
Hyperkid123 Aug 21, 2023
eda1b13
Do not use chrome link in favorited nav shared module.
Hyperkid123 Aug 21, 2023
a19737f
Merge pull request #2616 from Hyperkid123/use-normal-link
Hyperkid123 Aug 21, 2023
474d79c
Bump FEC package.
Hyperkid123 Aug 22, 2023
8671549
Hotfix for inventory JS client issues.
Hyperkid123 Aug 22, 2023
33af007
Merge pull request #2620 from Hyperkid123/global-filter
Hyperkid123 Aug 22, 2023
2108dca
Fix PF assets public path config.
Hyperkid123 Aug 23, 2023
3ec0bd1
Merge pull request #2622 from Hyperkid123/fix-pf-assets-public-path
Hyperkid123 Aug 23, 2023
c47c845
Enable legacy styling inheritance for the Page layout.
Hyperkid123 Aug 23, 2023
8c6766c
Merge pull request #2623 from Hyperkid123/legacy-page-root
Hyperkid123 Aug 23, 2023
d9d1a68
Merge branch 'master' into fix-error-on-missing-pendo
karelhala Aug 23, 2023
315eae6
Adding aliases for new pipeline pr check
maknop Aug 23, 2023
4200dcd
Merge pull request #2617 from vkrizan/fix-error-on-missing-pendo
Hyperkid123 Aug 24, 2023
996dc6f
Merge pull request #2625 from maknop/mknop/add-aliases
Hyperkid123 Aug 24, 2023
768b6ff
Add dynamic partner title to product selection screen.
Hyperkid123 Aug 14, 2023
ac40259
Do not show product links for azure partner page.
Hyperkid123 Aug 14, 2023
7670f8a
Merge pull request #2611 from Hyperkid123/azure-glow-dynamic-param
Hyperkid123 Aug 24, 2023
d031fd6
Open new tabs for all URLs in PF5 dropdown
karelhala Aug 24, 2023
0653b33
Merge pull request #2626 from karelhala/external-urls
Hyperkid123 Aug 24, 2023
9c404c9
Update Azure Notification to Notify Customer of 48hr Delay for Suppor…
radekkaluzik Aug 24, 2023
f354657
Merge branch 'master' into RHCLOUD-26604
radekkaluzik Aug 24, 2023
eaad7cb
Merge pull request #2627 from radekkaluzik/RHCLOUD-26604
Hyperkid123 Aug 24, 2023
478ad14
Update WSS docs
BlakeHolifield Aug 22, 2023
3f5495c
Add search e2e test with screenshot
florkbr Aug 24, 2023
cb26bf9
Merge remote-tracking branch 'upstream/master' into add-search-e2e
florkbr Aug 24, 2023
6f1e68c
Fix selector
florkbr Aug 24, 2023
f83e40b
Merge pull request #2621 from RedHatInsights/wss-dev-docs-update
Hyperkid123 Aug 25, 2023
e0252dc
Integrate Keycloak in int and scr env (#2609)
aneelac22 Aug 28, 2023
e4434f3
Merge branch 'master' into add-search-e2e
karelhala Aug 28, 2023
1b01a03
Merge pull request #2628 from florkbr/add-search-e2e
Hyperkid123 Aug 29, 2023
169ef23
Use automatic public path for PF assets.
Hyperkid123 Aug 31, 2023
5e7fd98
Merge pull request #2630 from Hyperkid123/use-auto-font-path
Hyperkid123 Aug 31, 2023
5e31031
Update fetch wrapper in iqeEnablement
lucasgarfield Aug 18, 2023
a288fa2
Update fetch wrapper in iqeEnablement
lavocatt Aug 31, 2023
35e56e6
Merge pull request #2615 from lucasgarfield/update-fetch-wrapper
Hyperkid123 Sep 1, 2023
f1de4eb
Add check not to append Auth header if already present
karelhala Sep 4, 2023
a289593
Merge pull request #2631 from karelhala/no-double-auth
Hyperkid123 Sep 5, 2023
4899162
Use newest stable node version
karelhala Sep 5, 2023
441c3d5
Merge pull request #2632 from karelhala/use-latest-node-stable
Hyperkid123 Sep 5, 2023
7a2a11c
Force click on all services link.
Hyperkid123 Sep 6, 2023
0b9357a
Merge pull request #2633 from Hyperkid123/force-click
Hyperkid123 Sep 7, 2023
392b9dd
Notification Drawer Update (#2571)
arivepr Sep 7, 2023
0f4b7af
Merge branch 'master-stable' into stable-merge
Hyperkid123 Sep 11, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
build/
node_modules/
public/

#emacs
*[#]*[#]
Expand Down Expand Up @@ -31,6 +32,7 @@ cypress/screenshots
.cache
.webpack-cache
.cypress-cache
.sass-cache

#swc
.swc
Expand Down
76 changes: 52 additions & 24 deletions config/chunk-mapper.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,64 @@
/* global require, module */
const { resolve } = require('path');
const { writeFileSync, mkdirSync } = require('fs');

const hotChunkRegex = RegExp('\\.hot-update\\.js$');
class ChunkMapper {
config = {};
constructor(options) {
this.options = options || {};
const { _unstableHotReload, ...rest } = options;
this.config = {};
this.options = rest || {};
this._unstableHotReload = _unstableHotReload;
}

apply(compiler) {
compiler.hooks.emit.tap('ChunkMapper', (compilation) => {
const prefix = this.options.prefix || RegExp('^/.*/$').test(compiler.options.output.publicPath) ? compiler.options.output.publicPath : '/';
compilation.chunks.forEach(({ id, files, runtime }) => {
const prefix = this.options.prefix || (RegExp('^/.*/$').test(compiler.options.output.publicPath) ? compiler.options.output.publicPath : '/');
if (this._unstableHotReload) {
const modules = Array.isArray(this.options.modules) ? this.options.modules : [this.options.modules];
if (modules.find((oneEntry) => RegExp(`${oneEntry}$`).test(runtime))) {
this.config[runtime] = {
...(this.config[runtime] || {}),
...(id === runtime
? { entry: Array.from(files).map((item) => `${prefix}${item}`) }
: {
modules: [
...((this.config[runtime] && this.config[runtime].modules) || []),
...Array.from(files).map((item) => `${prefix}${item}`),
],
}),
// TODO: Investigate if it is possible we could use the same script for normal builds
const hotEntries = Array.from(compilation.chunks)
.filter(({ name, runtime }) => !!modules.find((moduleName) => moduleName === name) || name === runtime)
.map(({ files }) =>
Array.from(files)
.filter((file) => !hotChunkRegex.test(file))
.map((file) => `${prefix}${file}`)
)
.flat();

modules.forEach((name) => {
this.config = {
[name]: {
entry: hotEntries,
},
};
}
});
});
} else {
compilation.chunks.forEach(({ name, files, runtime }) => {
const modules = Array.isArray(this.options.modules) ? this.options.modules : [this.options.modules];
if (modules.find((oneEntry) => RegExp(`${oneEntry}$`).test(runtime))) {
this.config[runtime] = {
...(this.config[runtime] || {}),
...(name === runtime
? {
entry: Array.from(files)
.map((item) => `${prefix}${item}`)
.filter((file, _index, array) => {
if (array.find((item) => !hotChunkRegex.test(item))) {
return !hotChunkRegex.test(file);
}

return true;
}),
}
: {
modules: [...(this.config[runtime].modules || []), ...Array.from(files).map((item) => `${prefix}${item}`)],
}),
};
}
});
}

const outputPath = this.options.output || compiler.options.output.path;
mkdirSync(resolve(outputPath), { recursive: true });
writeFileSync(`${resolve(outputPath, 'fed-mods.json')}`, JSON.stringify(this.config, null, 4));
compilation.assets['fed-mods.json'] = {
source: () => JSON.stringify(this.config, null, 4),
size: () => JSON.stringify(this.config, null, 4).length,
};
});
}
}
Expand Down
49 changes: 49 additions & 0 deletions config/get-dynamic-modules.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require('path');
const glob = require('glob');
const fs = require('fs');

const getDynamicModules = (root) => {
if (!root) {
throw new Error('Provide a directory of your node_modules to find dynamic modules');
}

const package = fs.readFileSync(path.resolve(root, 'package.json'), { encoding: 'utf-8' });
const packageJSON = JSON.parse(package);
const coreVersion = packageJSON.dependencies['@patternfly/react-core'];
const iconsVersion = packageJSON.dependencies['@patternfly/react-icons'];

const componentsGlob = path.resolve(root, 'node_modules/@patternfly/react-core/dist/dynamic/*/**/package.json');
const iconsGlob = path.resolve(root, 'node_modules/@patternfly/react-icons/dist/dynamic/*/**/package.json');

const files = [
{ requiredVersion: coreVersion, files: glob.sync(componentsGlob) },
{ requiredVersion: iconsVersion, files: glob.sync(iconsGlob) },
];
const modules = files
.map(({ files, requiredVersion }) =>
files.reduce((acc, curr) => {
const moduleName = curr
.replace(/\/package.json$/, '')
.split('/node_modules/')
.pop();
return {
...acc,
[moduleName]: {
version: requiredVersion,
},
};
}, {})
)
.reduce(
(acc, curr) => ({
...acc,
...curr,
}),
{}
);

return modules;
};

module.exports = getDynamicModules;
72 changes: 66 additions & 6 deletions config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ const proxy = require('@redhat-cloud-services/frontend-components-config-utiliti
const imageNullLoader = require('./image-null-loader');

// call default generator then pair different variations of uri with each base
const myGenerator = asGenerator((item, ...rest) => {
const PFGenerator = asGenerator((item, ...rest) => {
const defaultTuples = [...defaultJoinGenerator(item, ...rest)];
if (item.uri.includes('./assets')) {
return defaultTuples.map(([base]) => {
if (base.includes('pf-4-styles')) {
return [base, path.relative(base, path.resolve(__dirname, '../node_modules/pf-4-styles', item.uri))];
}
if (base.includes('@patternfly/patternfly')) {
return [base, path.relative(base, path.resolve(__dirname, '../node_modules/@patternfly/patternfly', item.uri))];
}
Expand All @@ -22,8 +25,9 @@ const myGenerator = asGenerator((item, ...rest) => {
return defaultTuples;
});

const publicPath = process.env.BETA === 'true' ? '/beta/apps/chrome/js/' : '/apps/chrome/js/';
const commonConfig = ({ dev }) => {
const publicPath = process.env.BETA === 'true' ? '/beta/apps/chrome/js/' : '/apps/chrome/js/';
/** @type { import("webpack").Configuration } */
return {
entry: dev
? // HMR request react, react-dom and react-refresh/runtime to be in the same chunk
Expand All @@ -35,10 +39,10 @@ const commonConfig = ({ dev }) => {
output: {
path: path.resolve(__dirname, '../build/js'),
// the HMR needs dynamic entry filename to remove name conflicts
filename: dev ? '[name].js' : 'chrome-root.[fullhash].js',
filename: dev ? '[name].js' : 'chrome-root.[contenthash].js',
hashFunction: 'xxhash64',
publicPath,
chunkFilename: dev ? '[name].js' : '[name].[fullhash].js',
chunkFilename: dev ? '[name].js' : '[name].[contenthash].js',
},
...(dev
? {
Expand Down Expand Up @@ -112,7 +116,7 @@ const commonConfig = ({ dev }) => {
{
loader: 'resolve-url-loader',
options: {
join: createJoinFunction('myJoinFn', createJoinImplementation(myGenerator)),
join: createJoinFunction('myJoinFn', createJoinImplementation(PFGenerator)),
},
},
{
Expand Down Expand Up @@ -183,12 +187,68 @@ const commonConfig = ({ dev }) => {
};
};

// PF node module asset compilation config, no need to compile PF assets more than once during a run
/** @type { import("webpack").Configuration } */
const pfConfig = {
entry: {
'pf4-v4': path.resolve(__dirname, '../src/sass/pf-4-assets.scss'),
'pf4-v5': path.resolve(__dirname, '../src/sass/pf-5-assets.scss'),
},
output: {
path: path.resolve(__dirname, '../build/js/pf'),
// the HMR needs dynamic entry filename to remove name conflicts
filename: '[name].js',
publicPath: `auto`,
},
plugins: [new MiniCssExtractPlugin()],
stats: {
errorDetails: true,
},
cache: {
type: 'filesystem',
buildDependencies: {
config: [__filename],
},
cacheDirectory: path.resolve(__dirname, '../.sass-cache'),
},
module: {
rules: [
{
test: /\.s?[ac]ss$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
{
loader: 'resolve-url-loader',
options: {
join: createJoinFunction('myJoinFn', createJoinImplementation(PFGenerator)),
},
},
{
loader: 'sass-loader',
options: {
sassOptions: {
outputStyle: 'compressed',
},
sourceMap: true,
},
},
],
},
{
test: /\.(jpe?g|svg|png|gif|ico|eot|ttf|woff2?)(\?v=\d+\.\d+\.\d+)?$/i,
type: 'asset/resource',
},
],
},
};

module.exports = function (env) {
const dev = process.env.DEV_SERVER;
const config = commonConfig({ dev, publicPath: env.publicPath });
if (env.analyze === 'true') {
config.plugins.push(new BundleAnalyzerPlugin());
}

return config;
return [pfConfig, config];
};
14 changes: 10 additions & 4 deletions config/webpack.cy.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ const { ModuleFederationPlugin } = require('webpack').container;
const searchIgnoredStyles = require('@redhat-cloud-services/frontend-components-config-utilities/search-ignored-styles');

// call default generator then pair different variations of uri with each base
const myGenerator = asGenerator((item, ...rest) => {
const PFGenerator = asGenerator((item, ...rest) => {
const defaultTuples = [...defaultJoinGenerator(item, ...rest)];
if (item.uri.includes('./assets')) {
return defaultTuples.map(([base]) => {
if (base.includes('pf-4-styles')) {
return [base, path.relative(base, path.resolve(__dirname, '../node_modules/pf-4-styles', item.uri))];
}
if (base.includes('@patternfly/patternfly')) {
return [base, path.relative(base, path.resolve(__dirname, '../node_modules/@patternfly/patternfly', item.uri))];
}
Expand All @@ -18,7 +21,8 @@ const myGenerator = asGenerator((item, ...rest) => {
return defaultTuples;
});

module.exports = {
/** @type { import("webpack").Configuration } */
const JSConfig = {
module: {
rules: [
{
Expand All @@ -44,7 +48,7 @@ module.exports = {
{
loader: 'resolve-url-loader',
options: {
join: createJoinFunction('myJoinFn', createJoinImplementation(myGenerator)),
join: createJoinFunction('myJoinFn', createJoinImplementation(PFGenerator)),
},
},
{
Expand Down Expand Up @@ -84,7 +88,7 @@ module.exports = {
},
plugins: [
new MiniCssExtractPlugin({
filename: '[name].[fullhash].css',
filename: '[name].[contenthash].css',
}),
new ModuleFederationPlugin({
name: 'chrome',
Expand All @@ -102,3 +106,5 @@ module.exports = {
}),
],
};

module.exports = JSConfig;
16 changes: 11 additions & 5 deletions config/webpack.plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ const { ProvidePlugin } = require('webpack');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
const getDynamicModules = require('./get-dynamic-modules');

const deps = require('../package.json').dependencies;

const plugins = (dev = false, beta = false) => {
const ChunkMapper = new (require('@redhat-cloud-services/frontend-components-config-utilities/chunk-mapper'))({
const ChunkMapper = new (require('./chunk-mapper'))({
modules: 'chrome',
_unstableHotReload: dev,
});
Expand All @@ -26,11 +27,12 @@ const plugins = (dev = false, beta = false) => {
]
: []),
new MiniCssExtractPlugin({
filename: dev ? '[name].css' : '[name].[fullhash].css',
filename: dev ? '[name].css' : '[name].[contenthash].css',
ignoreOrder: true,
}),
new ModuleFederationPlugin({
name: 'chrome',
filename: dev ? 'chrome.js' : 'chrome.[fullhash].js',
filename: dev ? 'chrome.js' : 'chrome.[contenthash].js',
exposes: {
'./DownloadButton': resolve(__dirname, '../src/pdf/DownloadButton.tsx'),
'./LandingNavFavorites': resolve(__dirname, '../src/components/FavoriteServices/LandingNavFavorites.tsx'),
Expand All @@ -42,21 +44,25 @@ const plugins = (dev = false, beta = false) => {
{ 'react-router-dom': { singleton: true, requiredVersion: deps['react-router-dom'] } },
{ 'react-redux': { requiredVersion: deps['react-redux'] } },
{ '@openshift/dynamic-plugin-sdk': { singleton: true, requiredVersion: deps['@openshift/dynamic-plugin-sdk'] } },
{ '@patternfly/react-core': { requiredVersion: deps['@patternfly/react-core'] } },
{ '@patternfly/quickstarts': { singleton: true, requiredVersion: deps['@patternfly/quickstarts'] } },
{ '@redhat-cloud-services/chrome': { singleton: true, requiredVersion: deps['@redhat-cloud-services/chrome'] } },
{ '@scalprum/react-core': { singleton: true, requiredVersion: deps['@scalprum/react-core'] } },
{ '@unleash/proxy-client-react': { singleton: true, requiredVersion: deps['@unleash/proxy-client-react'] } },
getDynamicModules(process.cwd()),
],
}),
ChunkMapper,
new HtmlWebpackPlugin({
template: path.resolve(__dirname, '../src/index.html'),
template: path.resolve(__dirname, '../src/index.ejs'),
inject: 'body',
minify: false,
filename: dev ? 'index.html' : '../index.html',
// FIXME: Change to /preview on May
base: beta ? '/beta/' : '/',
templateParameters: {
pf4styles: `/${beta ? 'beta/' : ''}apps/chrome/js/pf/pf4-v4.css`,
pf5styles: `/${beta ? 'beta/' : ''}apps/chrome/js/pf/pf4-v5.css`,
},
}),
new HtmlWebpackPlugin({
title: 'Authenticating - Hybrid Cloud Console',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

it('should close all services dropdown in link matches current pathname', () => {
function checkMenuClosed() {
cy.get('.pf-c-menu-toggle__text').click();
cy.get('.pf-v5-c-menu-toggle__text').click();
cy.contains('Browse all services').should('exist');
cy.contains('Favorites').click();
cy.contains('Test section').click();
Expand All @@ -45,7 +45,7 @@
},
]);
cy.window().then((win) => {
(win as any).foo = {

Check warning on line 48 in cypress/component/AllServicesDropdown/AllServicesDropdown.cy.tsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
init: () => undefined,
get: () => () => ({
default: () => <div>Foo</div>,
Expand Down
Loading
Loading