@redhat-cloud-services/frontend-components-config 4.6.6 → 4.6.9

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/README.md CHANGED
@@ -7,22 +7,36 @@
7
7
  - [Removed features with webpack 5](#removed-features-with-webpack-5)
8
8
  - [useProxy](#useproxy)
9
9
  - [Attributes](#attributes)
10
- - [useChromeTemplate](#useChromeTemplate)
10
+ - [useChromeTemplate](#usechrometemplate)
11
11
  - [localChrome](#localchrome)
12
- - [registry](#registry)
12
+ - [keycloakUri](#keycloakuri)
13
+ - [Registry](#registry)
13
14
  - [Custom routes](#custom-routes)
14
15
  - [routes](#routes)
15
16
  - [routesPath](#routespath)
16
- - [Custom proxy settings](#custom-proxy-settings)
17
+ - [Custom proxy settings](#custom-proxy-settings)
18
+ - [Env](#env)
19
+ - [Use cloud](#use-cloud)
20
+ - [Target](#target)
21
+ - [useAgent](#useagent)
22
+ - [bounceProd](#bounceprod)
23
+ - [Running PROD proxy without VPN](#running-prod-proxy-without-vpn)
17
24
  - [standalone](#standalone)
18
25
  - [Usage](#usage)
19
26
  - [Simple](#simple)
20
27
  - [Advanced](#advanced)
21
- - [Using provided services](#Using-provided-services)
22
- - [Writing services](#Writing-services)
23
- - [Customizing default services](#Customizing-default-services)
24
- - [fec node scripts](#fec-node-scripts)
25
- - [include PF css modules in your bundle](#include-PF-css-modules-in-your-bundle)
28
+ - [Using provided services](#using-provided-services)
29
+ - [Writing services](#writing-services)
30
+ - [Customizing default services](#customizing-default-services)
31
+ - [fec node scripts](#fec-node-scripts)
32
+ - [Usage](#usage-1)
33
+ - [Patch etc hosts](#patch-etc-hosts)
34
+ - [Static](#static)
35
+ - [Inventory example](#inventory-example)
36
+ - [In inventory UI repository changes](#in-inventory-ui-repository-changes)
37
+ - [Compliance frontend setup](#compliance-frontend-setup)
38
+ - [Run servers](#run-servers)
39
+ - [include PF css modules in your bundle](#include-pf-css-modules-in-your-bundle)
26
40
 
27
41
  ## Webpack 5
28
42
 
@@ -65,6 +79,8 @@ const { config: webpackConfig, plugins } = config({
65
79
  |[env](#env)|`string`|Environment to proxy against such as ci-beta.|
66
80
  |[useCloud](#use-cloud)|`boolean`|Toggle to use old fallback to cloud.redhat.com paths instead of console.redhat.com.|
67
81
  |[target](#target)|`string`|Override `env` and `useCloud` to use a custom URI.|
82
+ |[useAgent](#useAgent)|`boolean` = `true`|Enforce using the agent to proxy requests via `proxyUrl`.|
83
+ |[bounceProd](#bounceProd)|`boolean` = `false`|Bounce all non-GET requests via server requests.|
68
84
 
69
85
 
70
86
  #### useChromeTemplate
@@ -102,6 +118,9 @@ You can also easily run you application with a local build of Chrome by adding `
102
118
  INSIGHTS_CHROME=/Users/rvsiansk/insights-project/insights-chrome/build/
103
119
  ```
104
120
 
121
+ **The path must end with a slash character / !!**
122
+
123
+
105
124
  To check what the proxy is doing with your local chrome settings you can set `proxyVerbose: true`.
106
125
 
107
126
  #### keycloakUri
@@ -207,6 +226,33 @@ If you want to run in legacy mode pass `useCloud: true` in your config, this way
207
226
  #### Target
208
227
  Override for the target `env` and `useCloud` build. Useful for cross-environment testing.
209
228
 
229
+ #### useAgent
230
+
231
+ `boolean` = `true`
232
+
233
+ Enforces using the agent to proxy requests via `proxyUrl`. Setting this to `true` will enforce using agent for PROD environemnt too (use when you are using Red Hat VPN and you do not want to bounce PROD requests). STAGE is using the agent automatically and it cannot be turned off.
234
+
235
+ #### bounceProd
236
+
237
+ `boolean` = `false`
238
+
239
+ Bounce all non-GET PROD requests via server. This option removes all headers except `cookie` and `body` so Akamai won't have issues with different origins/hosts. This behavior allows to access PROD environment without using Red Hat VPN.
240
+
241
+ ##### Running PROD proxy without VPN
242
+
243
+ Set following attributes in your dev webpack proxy:
244
+
245
+ ```jsx
246
+ const config = {
247
+ ...options,
248
+ env: 'prod-stable', // or 'prod-beta'
249
+ useAgent: false,
250
+ bounceProd: true
251
+ }
252
+ ```
253
+
254
+ Now, you can access PROD env without being connected to Red Hat VPN.
255
+
210
256
  ## standalone
211
257
  A way to run cloud.redhat.com apps from `localhost` offline.
212
258
 
@@ -446,4 +492,4 @@ const { config: webpackConfig, plugins } = config({
446
492
  ...
447
493
  });
448
494
 
449
- ```
495
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redhat-cloud-services/frontend-components-config",
3
- "version": "4.6.6",
3
+ "version": "4.6.9",
4
4
  "description": "Config plugins and settings for RedHat Cloud Services project.",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -53,7 +53,7 @@
53
53
  "util": "^0.12.4",
54
54
  "webpack": "^5.55.1",
55
55
  "webpack-cli": "^4.8.0",
56
- "webpack-dev-server": "4.3.1",
56
+ "webpack-dev-server": "4.8.1",
57
57
  "write-file-webpack-plugin": "^4.5.1",
58
58
  "yargs": "^17.2.1"
59
59
  }
package/src/config.js CHANGED
@@ -35,7 +35,9 @@ module.exports = ({
35
35
  registry,
36
36
  client = {},
37
37
  bundlePfModules = false,
38
- useChromeTemplate = false,
38
+ useChromeTemplate = true,
39
+ bounceProd,
40
+ useAgent,
39
41
  } = {}) => {
40
42
  const filenameMask = `js/[name]${useFileHash ? `.${Date.now()}.[fullhash]` : ''}.js`;
41
43
  if (betaEnv) {
@@ -197,6 +199,8 @@ module.exports = ({
197
199
  copyTemplate(chromePath);
198
200
  }
199
201
  },
202
+ bounceProd,
203
+ useAgent,
200
204
  }),
201
205
  },
202
206
  };
package/src/plugins.js CHANGED
@@ -1,5 +1,5 @@
1
1
  const { SourceMapDevToolPlugin } = require('webpack');
2
- const { ProvidePlugin } = require('webpack');
2
+ const { ProvidePlugin, DefinePlugin } = require('webpack');
3
3
  const MiniCssExtractPlugin = require('mini-css-extract-plugin');
4
4
  const { CleanWebpackPlugin } = require('clean-webpack-plugin');
5
5
  const HtmlWebpackPlugin = require('html-webpack-plugin');
@@ -17,6 +17,7 @@ module.exports = ({
17
17
  generateSourceMaps,
18
18
  plugins,
19
19
  useChromeTemplate = false,
20
+ definePlugin = {},
20
21
  } = {}) => [
21
22
  ...(generateSourceMaps
22
23
  ? [
@@ -53,6 +54,11 @@ module.exports = ({
53
54
  },
54
55
  ...(replacePlugin || []),
55
56
  ]),
57
+ new DefinePlugin({
58
+ // we have to wrap the appname string in another string because of how define plugin explodes strings
59
+ CRC_APP_NAME: JSON.stringify(insights?.appname),
60
+ ...(definePlugin || {}),
61
+ }),
56
62
  ]),
57
63
  new ProvidePlugin({
58
64
  process: 'process/browser.js',
@@ -2,17 +2,18 @@ import plugins from './plugins';
2
2
 
3
3
  const HTML_WEBPACK = 2;
4
4
  const REPLACE = 3;
5
+ const DEFINE_PLUGIN = 4;
5
6
 
6
7
  describe('plugins generations, no option', () => {
7
8
  const enabledPlugins = plugins();
8
9
 
9
10
  it('should generate plugins', () => {
10
- expect(enabledPlugins.length).toBe(6);
11
+ expect(enabledPlugins.length).toBe(7);
11
12
  });
12
13
 
13
14
  it('should generate plugins with sourceMaps', () => {
14
15
  const enabledPlugins = plugins({ generateSourceMaps: true });
15
- expect(enabledPlugins.length).toBe(7);
16
+ expect(enabledPlugins.length).toBe(8);
16
17
  });
17
18
 
18
19
  it('should generate correct template path for HtmlWebpackPlugin', () => {
@@ -52,3 +53,19 @@ it('replacePlugin should update', () => {
52
53
  });
53
54
  enabledPlugins[REPLACE].replace({ html: '@@another string @@env' }, (_, { html }) => expect(html).toBe('test-string string '));
54
55
  });
56
+
57
+ it('definePlugin should have default replace of CRC_APP_NAME', () => {
58
+ const enabledPlugins = plugins({
59
+ insights: { appname: 'test_app' },
60
+ });
61
+ expect(enabledPlugins[DEFINE_PLUGIN].definitions.CRC_APP_NAME).toBe('"test_app"');
62
+ });
63
+
64
+ it('definePlugin should update', () => {
65
+ const enabledPlugins = plugins({
66
+ definePlugin: {
67
+ SOME_VAR: JSON.stringify('test_val'),
68
+ },
69
+ });
70
+ expect(enabledPlugins[DEFINE_PLUGIN].definitions.SOME_VAR).toBe('"test_val"');
71
+ });