Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/prod-beta' into prod-stable
Browse files Browse the repository at this point in the history
  • Loading branch information
dlabrecq committed Oct 27, 2022
2 parents 9f88f52 + 16c159f commit 58fca79
Show file tree
Hide file tree
Showing 603 changed files with 4,847 additions and 45,825 deletions.
100 changes: 100 additions & 0 deletions .archive/config/dev.webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
// Based on https://github.com/RedHatInsights/frontend-components/blob/master/packages/config/src/scripts/dev.webpack.config.js
const config = require('@redhat-cloud-services/frontend-components-config');
const federatedPlugin = require('@redhat-cloud-services/frontend-components-config-utilities/federated-modules');
const fecConfig = require(process.env.FEC_CONFIG_PATH);
const { GitRevisionPlugin } = require('git-revision-webpack-plugin');
const { dependencies, insights } = require('../package.json');
const path = require('path');

// See index.js from @redhat-cloud-services/frontend-components-config
const gitRevisionPlugin = new GitRevisionPlugin({
branch: true,
});

const betaBranches = ['main', 'master', 'stage-beta', 'prod-beta'];
const gitBranch = process.env.TRAVIS_BRANCH || process.env.BRANCH || gitRevisionPlugin.branch();
const isBeta = process.env.BETA === 'true';
const isProduction = process.env.NODE_ENV === 'production';
const moduleName = insights.appname.replace(/-(\w)/g, (_, match) => match.toUpperCase());
const rootDir = process.env.FEC_ROOT_DIR || process.cwd();

function parseRegexpURL(url) {
return new RegExp(`${isBeta ? '/beta' : ''}${url.toString()}`);
}

function createAppUrl(appUrl) {
if (Array.isArray(appUrl)) {
return appUrl.map(url => {
if (typeof url === 'object') {
return parseRegexpURL(url);
} else if (typeof url === 'string') {
return `${isBeta ? '/beta' : ''}${url}`;
} else {
// eslint-disable-next-line no-throw-literal
throw `Invalid appURL format! Expected string or regexp, got ${typeof url}. Check your fec.config.js:appUrl.`;
}
});
} else if (typeof appUrl === 'object') {
return parseRegexpURL(appUrl);
} else if (typeof appUrl === 'string') {
return `${isBeta ? '/beta' : ''}${appUrl}`;
} else {
// eslint-disable-next-line no-throw-literal
throw `Invalid appURL format! Expected string or regexp, got ${typeof appUrl}. Check your fec.config.js:appUrl.`;
}
}

const appUrl = createAppUrl(fecConfig.appUrl);

const { plugins: externalPlugins, routes, stats, ...externalConfig } = fecConfig;

const { config: webpackConfig, plugins } = config({
...externalConfig,
routes,
appUrl,
deployment: (isProduction && betaBranches.includes(gitBranch)) || isBeta ? 'beta/apps' : 'apps',
env: `${process.env.CLOUDOT_ENV}-${isBeta === 'true' ? 'beta' : 'stable'}`,
rootFolder: rootDir,
});

webpackConfig.resolve = {
...webpackConfig.resolve,
modules: [path.resolve(__dirname, '../node_modules'), path.resolve(__dirname, '../src')],
};

plugins.push(
federatedPlugin({
root: rootDir,
moduleName,
/**
* There is a know issue with apps using yarn to build their applications that the router package is not properly shared
* Same issue was encountered in application services
* Package can be re-enabled for sharing once chrome starts providing global routing package to all applications
*/
exclude: ['react-router-dom'],
exposes: {
'./RootApp': path.resolve(__dirname, '../src/appEntry.tsx'),
},
shared: [
{ 'react-redux': { requiredVersion: dependencies['react-redux'] } },
{ '@unleash/proxy-client-react': { requiredVersion: '*', singleton: true } },
],
}),
...externalPlugins
);

module.exports = {
...webpackConfig,
plugins,
stats,
};

/* eslint-disable no-console */
console.log('~~~Custom webpack variables~~~');
console.log(`isProduction: ${isProduction}`);
console.log(`isBeta: ${isBeta}`);
console.log(`Clouddot ENV: ${process.env.CLOUDOT_ENV}`);
console.log(`Using ephemeral API routes: ${process.env.EPHEMERAL_PORT !== undefined}`);
console.log(`Using local API routes: ${process.env.LOCAL_API_PORT !== undefined}`);
console.log(`Using Cloud Services Config routes: ${process.env.CLOUD_SERVICES_CONFIG_PORT !== undefined}`);
console.log('~~~~~~~~~~~~~~~~~~~~~');
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"plugin:react/recommended"
],
"parserOptions": {
// "project": ["./tsconfig.json"],
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
Expand Down Expand Up @@ -54,6 +55,8 @@
// "@typescript-eslint/class-name-casing": "error",
"@typescript-eslint/consistent-type-assertions": "error",
"@typescript-eslint/consistent-type-definitions": "error",
// "@typescript-eslint/consistent-type-exports": "error",
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/explicit-member-accessibility": "off",
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ node_modules/
public/
dist/
.DS_Store
.cache
.idea
/build/
report.*.json
Expand Down
100 changes: 100 additions & 0 deletions fec.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
const CopyWebpackPlugin = require('copy-webpack-plugin');
const path = require('path');
const webpack = require('webpack');
const { dependencies, insights } = require('./package.json');

const moduleName = insights.appname.replace(/-(\w)/g, (_, match) => match.toUpperCase());
const srcDir = path.resolve(__dirname, './src');
const distDir = path.resolve(__dirname, './dist/');
const fileRegEx = /\.(png|woff|woff2|eot|ttf|svg|gif|jpe?g|png)(\?[a-z0-9=.]+)?$/;
const stats = {
excludeAssets: fileRegEx,
colors: true,
modules: false,
};

// Show what files changed since last compilation
class WatchRunPlugin {
apply(compiler) {
compiler.hooks.watchRun.tap('WatchRun', comp => {
if (comp.modifiedFiles) {
const changedFiles = Array.from(comp.modifiedFiles, file => `\n ${file}`).join('');
const logger = compiler.getInfrastructureLogger('cost-management');
logger.info(' ');
logger.info('===============================');
logger.info('FILES CHANGED:', changedFiles);
logger.info('===============================');
}
});
}
}

module.exports = {
appUrl: '/openshift/cost-management',
debug: true,
interceptChromeConfig: false, // Change to false after your app is registered in configuration files
proxyVerbose: true,
stats,
standalone: process.env.LOCAL_API_PORT ? true : false,
useProxy: process.env.LOCAL_API_PORT ? false : true,
/**
* Config for federated modules
*/
moduleFederation: {
moduleName,
/**
* There is a know issue with apps using yarn to build their applications that the router package is not properly shared
* Same issue was encountered in application services
* Package can be re-enabled for sharing once chrome starts providing global routing package to all applications
*/
exclude: ['react-router-dom'],
exposes: {
'./RootApp': path.resolve(__dirname, './src/appEntry.tsx'),
},
shared: [
{ 'react-redux': { requiredVersion: dependencies['react-redux'] } },
{ '@unleash/proxy-client-react': { requiredVersion: '*', singleton: true } },
],
},
/**
* Add additional webpack plugins
*/
plugins: [
new WatchRunPlugin(),
new webpack.ProgressPlugin(),
new CopyWebpackPlugin({
patterns: [
{
from: path.join(srcDir, 'locales'),
to: path.join(distDir, 'locales'),
},
],
}),
],
resolve: {
modules: [srcDir, path.resolve(__dirname, './node_modules')],
},
routes: {
/**
* Cloud services config routes, typically localhost:8889
*/
...(process.env.CLOUD_SERVICES_CONFIG_PORT && {
'/config': { host: `http://localhost:${process.env.CLOUD_SERVICES_CONFIG_PORT}` },
'/beta/config': { host: `http://localhost:${process.env.CLOUD_SERVICES_CONFIG_PORT}` },
}),
/**
* Ephemeral routes, typically localhost:8000
*/
...(process.env.EPHEMERAL_PORT && {
'/api/cost-management/v1/': { host: `http://localhost:${process.env.EPHEMERAL_PORT}` },
}),
/**
* Local API routes, typically localhost:8000
*/
...(process.env.LOCAL_API_PORT && {
'/api/cost-management/v1/': {
host: `http://${process.env.LOCAL_API_HOST || 'localhost'}:${process.env.LOCAL_API_PORT}`,
},
}),
},
};
Loading

0 comments on commit 58fca79

Please sign in to comment.