-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/prod-beta' into prod-stable
- Loading branch information
Showing
603 changed files
with
4,847 additions
and
45,825 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,6 +50,7 @@ node_modules/ | |
public/ | ||
dist/ | ||
.DS_Store | ||
.cache | ||
.idea | ||
/build/ | ||
report.*.json | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}`, | ||
}, | ||
}), | ||
}, | ||
}; |
Oops, something went wrong.