@centreon/js-config 24.5.7 → 24.5.8

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.
@@ -1,4 +1,5 @@
1
1
  /* eslint-disable @typescript-eslint/no-var-requires */
2
+ const { devServer } = require('cypress-rspack-dev-server');
2
3
  const { defineConfig } = require('cypress');
3
4
  const {
4
5
  addMatchImageSnapshotPlugin
@@ -6,22 +7,22 @@ const {
6
7
  const cypressCodeCoverageTask = require('@cypress/code-coverage/task');
7
8
 
8
9
  module.exports = ({
9
- webpackConfig,
10
+ rspackConfig,
10
11
  cypressFolder,
11
12
  specPattern,
12
13
  env,
13
- useVite = false,
14
14
  excludeSpecPattern
15
15
  }) => {
16
16
  const mainCypressFolder = cypressFolder || 'cypress';
17
17
 
18
18
  return defineConfig({
19
19
  component: {
20
- devServer: {
21
- bundler: useVite ? 'vite' : 'webpack',
22
- framework: 'react',
23
- webpackConfig
24
- },
20
+ devServer: (devServerConfig) =>
21
+ devServer({
22
+ ...devServerConfig,
23
+ framework: 'react',
24
+ rspackConfig
25
+ }),
25
26
  excludeSpecPattern,
26
27
  setupNodeEvents: (on, config) => {
27
28
  addMatchImageSnapshotPlugin(on, config);
@@ -13,7 +13,7 @@ const enableVisualTesting = (cypressFolder = 'cypress'): void => {
13
13
  capture: 'viewport',
14
14
  customDiffConfig: { threshold: 0.01 },
15
15
  customSnapshotsDir: `${cypressFolder}/visual-testing-snapshots`,
16
- failureThreshold: 0.07,
16
+ failureThreshold: Cypress.env('updateSnapshots') === true ? 0 : 0.07,
17
17
  failureThresholdType: 'percent'
18
18
  });
19
19
  };
@@ -518,6 +518,10 @@ Cypress.Commands.add('stopContainers', (): Cypress.Chainable => {
518
518
  .createDirectory(logDirectory)
519
519
  .getContainersLogs()
520
520
  .then((containersLogs: Array<Array<string>>) => {
521
+ if (!containersLogs) {
522
+ return;
523
+ }
524
+
521
525
  Object.entries(containersLogs).forEach(([containerName, logs]) => {
522
526
  cy.writeFile(
523
527
  `results/logs/${Cypress.spec.name.replace(
@@ -743,7 +747,7 @@ Cypress.Commands.add(
743
747
 
744
748
  Cypress.Commands.add('getTimeFromHeader', (): Cypress.Chainable => {
745
749
  return cy
746
- .get('header div[data-cy="clock"]', { timeout: 10000 })
750
+ .get('header div[data-cy="clock"]', { timeout: 20000 })
747
751
  .should('be.visible')
748
752
  .then(($time) => {
749
753
  const headerTime = $time.children()[1].textContent;
@@ -1,3 +1,4 @@
1
+ /* eslint-disable @typescript-eslint/no-unused-vars */
1
2
  /* eslint-disable import/extensions */
2
3
  /* eslint-disable import/no-unresolved */
3
4
 
@@ -38,7 +39,7 @@ export default ({
38
39
 
39
40
  return defineConfig({
40
41
  chromeWebSecurity: false,
41
- defaultCommandTimeout: 6000,
42
+ defaultCommandTimeout: 20000,
42
43
  downloadsFolder: `${resultsFolder}/downloads`,
43
44
  e2e: {
44
45
  excludeSpecPattern: ['*.js', '*.ts', '*.md'],
@@ -66,10 +67,10 @@ export default ({
66
67
  WEB_IMAGE_VERSION: webImageVersion
67
68
  },
68
69
  execTimeout: 60000,
69
- requestTimeout: 10000,
70
+ requestTimeout: 20000,
70
71
  retries: 0,
71
72
  screenshotsFolder: `${resultsFolder}/screenshots`,
72
- video: isDevelopment,
73
+ video: true,
73
74
  videoCompression: 0,
74
75
  videosFolder: `${resultsFolder}/videos`
75
76
  });
@@ -23,11 +23,10 @@ export default (
23
23
  launchOptions.args.push('--hide-scrollbars');
24
24
  launchOptions.args.push('--mute-audio');
25
25
 
26
- launchOptions.args.push(`--window-size=${width},${height}`);
27
-
28
26
  // force screen to be non-retina and just use our given resolution
29
27
  launchOptions.args.push('--force-device-scale-factor=1');
30
28
  }
29
+
31
30
  launchOptions.args.push(`--window-size=${width},${height}`);
32
31
 
33
32
  return launchOptions;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@centreon/js-config",
3
3
  "description": "Centreon Frontend shared build configuration",
4
- "version": "24.5.7",
4
+ "version": "24.5.8",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/centreon/centreon-frontend.git"
@@ -16,13 +16,6 @@
16
16
  "url": "https://github.com/centreon/centreon-frontend/issues"
17
17
  },
18
18
  "homepage": "https://github.com/centreon/centreon-frontend#readme",
19
- "files": [
20
- "eslint",
21
- "jest",
22
- "tsconfig",
23
- "webpack",
24
- "cypress"
25
- ],
26
19
  "peerDependencies": {
27
20
  "eslint": "^8.53.0",
28
21
  "prettier": "^3.0.0"
@@ -1,76 +1,71 @@
1
- const excludeNodeModulesExceptCentreonUi =
2
- /node_modules(\\|\/)\.pnpm(\\|\/)(?!(@centreon|file\+packages\+ui-context))/;
3
-
4
- module.exports = {
5
- cache: false,
6
- excludeNodeModulesExceptCentreonUi,
7
- getModuleConfiguration: (jscTransformConfiguration, enableCoverage) => ({
8
- rules: [
9
- {
10
- parser: { system: false },
11
- test: /\.[cm]?(j|t)sx?$/
12
- },
13
- {
14
- exclude: [excludeNodeModulesExceptCentreonUi],
15
- test: /\.[jt]sx?$/,
16
- use: {
17
- loader: 'swc-loader',
18
- options: {
19
- jsc: {
20
- experimental: {
21
- plugins: [
22
- enableCoverage && ['swc-plugin-coverage-instrument', {}]
23
- ].filter(Boolean)
24
- },
25
- parser: {
26
- syntax: 'typescript',
27
- tsx: true
28
- },
29
- transform: jscTransformConfiguration
30
- }
31
- }
32
- }
33
- },
34
- {
35
- test: /\.icon.svg$/,
36
- use: ['@svgr/webpack']
37
- },
38
- {
39
- exclude: excludeNodeModulesExceptCentreonUi,
40
- test: /\.(bmp|png|jpg|jpeg|gif|svg)$/,
41
- use: [
42
- {
43
- loader: 'url-loader',
44
- options: {
45
- limit: 10000,
46
- name: '[name].[hash:8].[ext]'
47
- }
48
- }
49
- ]
50
- },
51
- {
52
- generator: {
53
- filename: '[name][ext]'
54
- },
55
- test: /\.(woff|woff2|eot|ttf|otf)$/i,
56
- type: 'asset/resource'
57
- },
58
- {
59
- test: /\.css$/i,
60
- use: ['style-loader', 'css-loader']
61
- }
62
- ]
63
- }),
64
- optimization: {
65
- splitChunks: {
66
- chunks: 'all',
67
- maxSize: 400 * 1024
68
- }
69
- },
70
- output: {
71
- chunkFilename: '[name].[chunkhash:8].chunk.js',
72
- filename: '[name].[chunkhash:8].js',
73
- libraryTarget: 'umd',
74
- umdNamedDefine: true
75
- }
76
- };
1
+ const isDev = process.env.NODE_ENV !== 'production';
2
+
3
+ const excludeNodeModulesExceptCentreonUi =
4
+ /node_modules(\\|\/)\.pnpm(\\|\/)(?!(@centreon|file\+packages\+ui-context))/;
5
+
6
+ module.exports = {
7
+ cache: false,
8
+ excludeNodeModulesExceptCentreonUi,
9
+ getModuleConfiguration: (enableCoverage) => ({
10
+ rules: [
11
+ {
12
+ exclude: [excludeNodeModulesExceptCentreonUi],
13
+ test: /\.[jt]sx?$/,
14
+ use: {
15
+ loader: 'swc-loader',
16
+ options: {
17
+ jsc: {
18
+ experimental: {
19
+ plugins: [
20
+ enableCoverage && ['swc-plugin-coverage-instrument', {}]
21
+ ].filter(Boolean)
22
+ },
23
+ parser: {
24
+ syntax: 'typescript',
25
+ tsx: true
26
+ },
27
+ transform: {
28
+ react: {
29
+ development: isDev,
30
+ refresh: isDev
31
+ }
32
+ }
33
+ }
34
+ }
35
+ }
36
+ },
37
+ {
38
+ test: /\.icon.svg$/,
39
+ use: ['@svgr/webpack']
40
+ },
41
+ {
42
+ exclude: excludeNodeModulesExceptCentreonUi,
43
+ test: /\.(bmp|png|jpg|jpeg|gif|svg)$/,
44
+ type: 'asset/inline'
45
+ },
46
+ {
47
+ generator: {
48
+ filename: '[name][ext]'
49
+ },
50
+ test: /\.(woff|woff2|eot|ttf|otf)$/i,
51
+ type: 'asset/resource'
52
+ },
53
+ {
54
+ test: /\.css$/i,
55
+ use: ['style-loader', 'css-loader']
56
+ }
57
+ ]
58
+ }),
59
+ optimization: {
60
+ splitChunks: {
61
+ chunks: 'all',
62
+ maxSize: 400 * 1024
63
+ }
64
+ },
65
+ output: {
66
+ chunkFilename: '[name].[chunkhash:8].chunk.js',
67
+ filename: '[name].[chunkhash:8].js',
68
+ libraryTarget: 'umd',
69
+ umdNamedDefine: true
70
+ }
71
+ };
@@ -1,7 +1,6 @@
1
1
  const path = require('path');
2
2
 
3
- const { CleanWebpackPlugin } = require('clean-webpack-plugin');
4
- const { ModuleFederationPlugin } = require('webpack').container;
3
+ const rspack = require('@rspack/core');
5
4
 
6
5
  const {
7
6
  getModuleConfiguration,
@@ -13,28 +12,27 @@ const {
13
12
  const getBaseConfiguration = ({
14
13
  moduleName,
15
14
  moduleFederationConfig,
16
- jscTransformConfiguration,
17
15
  enableCoverage
18
16
  }) => ({
19
17
  cache,
20
- module: getModuleConfiguration(jscTransformConfiguration, enableCoverage),
18
+ module: getModuleConfiguration(enableCoverage),
21
19
  optimization,
22
20
  output: {
23
21
  ...output,
22
+ clean: true,
24
23
  library: moduleName,
25
24
  uniqueName: moduleName
26
25
  },
27
26
  plugins: [
28
- new CleanWebpackPlugin(),
29
27
  moduleName &&
30
- new ModuleFederationPlugin({
28
+ new rspack.container.ModuleFederationPlugin({
31
29
  filename: 'remoteEntry.[chunkhash:8].js',
32
30
  library: { name: moduleName, type: 'umd' },
33
31
  name: moduleName,
34
32
  shared: [
35
33
  {
36
34
  '@centreon/ui-context': {
37
- requiredVersion: '24.x',
35
+ requiredVersion: '1.x',
38
36
  singleton: true
39
37
  }
40
38
  },
@@ -0,0 +1,12 @@
1
+ module.exports = {
2
+ getDevConfiguration: () => ({
3
+ cache: true,
4
+ devtool: 'eval-cheap-module-source-map',
5
+ optimization: {
6
+ splitChunks: false
7
+ },
8
+ output: {
9
+ filename: '[name].js'
10
+ }
11
+ })
12
+ };
@@ -1,6 +1,6 @@
1
1
  const os = require('os');
2
2
 
3
- const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
3
+ const ReactRefreshPlugin = require('@rspack/plugin-react-refresh');
4
4
 
5
5
  const devServerPort = 9090;
6
6
 
@@ -19,10 +19,9 @@ const devServerAddress = externalInterface
19
19
 
20
20
  const publicPath = `http://${devServerAddress}:${devServerPort}/static/`;
21
21
 
22
- const isServeMode = process.env.WEBPACK_ENV === 'serve';
23
- const isDevelopmentMode = process.env.WEBPACK_ENV === 'development';
22
+ const isDevelopmentMode = process.env.NODE_ENV !== 'production';
24
23
 
25
- const devServerPlugins = isServeMode ? [new ReactRefreshWebpackPlugin()] : [];
24
+ const devServerPlugins = isDevelopmentMode ? [new ReactRefreshPlugin()] : [];
26
25
 
27
26
  module.exports = {
28
27
  devServer: {
@@ -32,6 +31,5 @@ module.exports = {
32
31
  },
33
32
  devServerPlugins,
34
33
  isDevelopmentMode,
35
- isServeMode,
36
34
  publicPath
37
35
  };
@@ -0,0 +1,13 @@
1
+ const WriteRemoteEntryNameToModuleFederation = require('../plugins/WriteRemoteEntryNameToModuleFederation');
2
+ const TransformPreloadScript = require('../plugins/TransformPreloadScript');
3
+
4
+ module.exports = ({ outputPath, federatedComponentConfiguration }) => ({
5
+ output: {
6
+ library: '[chunkhash:8]',
7
+ path: outputPath
8
+ },
9
+ plugins: [
10
+ new WriteRemoteEntryNameToModuleFederation(federatedComponentConfiguration),
11
+ new TransformPreloadScript(federatedComponentConfiguration)
12
+ ]
13
+ });
@@ -0,0 +1,37 @@
1
+ const fs = require('fs');
2
+
3
+ const swc = require('@swc/core');
4
+
5
+ module.exports = class TransformPreloadScript {
6
+ constructor(federatedComponentConfiguration) {
7
+ this.federatedComponentConfiguration = federatedComponentConfiguration;
8
+ }
9
+
10
+ apply(compiler) {
11
+ compiler.hooks.done.tap('TransformPreloadScript', () => {
12
+ if (!fs.existsSync(compiler.options.output.path)) {
13
+ fs.mkdirSync(compiler.options.output.path, { recursive: true });
14
+ }
15
+
16
+ if (this.federatedComponentConfiguration.preloadScript) {
17
+ const { code } = swc.transformFileSync(
18
+ `./${this.federatedComponentConfiguration.preloadScript}.ts`,
19
+ {
20
+ filename: `${this.federatedComponentConfiguration.preloadScript}.ts`,
21
+ jsc: {
22
+ parser: {
23
+ syntax: 'typescript'
24
+ }
25
+ },
26
+ minify: true
27
+ }
28
+ );
29
+
30
+ fs.writeFileSync(
31
+ `${compiler.options.output.path}/${this.federatedComponentConfiguration.preloadScript}.js`,
32
+ code
33
+ );
34
+ }
35
+ });
36
+ }
37
+ };
@@ -0,0 +1,30 @@
1
+ const fs = require('fs');
2
+
3
+ module.exports = class WriteRemoteEntryNameToModuleFederation {
4
+ constructor(federatedComponentConfiguration) {
5
+ this.federatedComponentConfiguration = federatedComponentConfiguration;
6
+ }
7
+
8
+ apply(compiler) {
9
+ compiler.hooks.done.tap(
10
+ 'WriteRemoteEntryNameToModuleFederation',
11
+ (stats) => {
12
+ const newFederatedComponentConfiguration = {
13
+ ...this.federatedComponentConfiguration,
14
+ remoteEntry: Object.keys(stats.compilation.assets).find((assetName) =>
15
+ assetName.match(/(^remoteEntry)\S+.js$/)
16
+ )
17
+ };
18
+
19
+ if (!fs.existsSync(compiler.options.output.path)) {
20
+ fs.mkdirSync(compiler.options.output.path, { recursive: true });
21
+ }
22
+
23
+ fs.writeFileSync(
24
+ `${compiler.options.output.path}/moduleFederation.json`,
25
+ JSON.stringify(newFederatedComponentConfiguration, null, 2)
26
+ );
27
+ }
28
+ );
29
+ }
30
+ };
package/tsconfig.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "extends": "./tsconfig/index.json",
3
+ "compilerOptions": {
4
+ "baseUrl": "./",
5
+ "outDir": "./dist",
6
+ "declaration": true,
7
+ "skipLibCheck": true,
8
+ "pretty": true,
9
+ "emitDeclarationOnly": true,
10
+ "types": ["cypress", "cypress-wait-until"],
11
+ "esModuleInterop": true,
12
+ "paths": {
13
+ "@badeball/cypress-cucumber-preprocessor/*": ["./node_modules/@badeball/cypress-cucumber-preprocessor/dist/subpath-entrypoints/*"]
14
+ }
15
+ },
16
+ "exclude": [
17
+ "./node_modules",
18
+ "./dist",
19
+ "../../node_modules"
20
+ ],
21
+ }
@@ -1,24 +0,0 @@
1
- module.exports = {
2
- devJscTransformConfiguration: {
3
- react: {
4
- development: true,
5
- refresh: false,
6
- },
7
- },
8
- devRefreshJscTransformConfiguration: {
9
- react: {
10
- development: true,
11
- refresh: true,
12
- },
13
- },
14
- getDevConfiguration: () => ({
15
- cache: true,
16
- devtool: 'eval-cheap-module-source-map',
17
- optimization: {
18
- splitChunks: false,
19
- },
20
- output: {
21
- filename: '[name].js',
22
- },
23
- }),
24
- };
@@ -1,46 +0,0 @@
1
- const fs = require('fs');
2
- const { CleanWebpackPlugin } = require('clean-webpack-plugin');
3
-
4
- class CentreonModulePlugin {
5
- constructor(federatedComponentConfiguration) {
6
- this.federatedComponentConfiguration = federatedComponentConfiguration;
7
- }
8
-
9
- apply(compiler) {
10
- compiler.hooks.done.tap('CentreonModulePlugin', (stats) => {
11
- const newFederatedComponentConfiguration = {
12
- ...this.federatedComponentConfiguration,
13
- remoteEntry: Object.keys(stats.compilation.assets).find((assetName) =>
14
- assetName.match(/(^remoteEntry)\S+.js$/),
15
- ),
16
- };
17
-
18
- if (!fs.existsSync(compiler.options.output.path)) {
19
- fs.mkdirSync(compiler.options.output.path, { recursive: true });
20
- }
21
-
22
- fs.writeFileSync(
23
- `${compiler.options.output.path}/moduleFederation.json`,
24
- JSON.stringify(newFederatedComponentConfiguration, null, 2),
25
- );
26
- });
27
- }
28
- }
29
-
30
- module.exports = ({
31
- outputPath,
32
- federatedComponentConfiguration,
33
- }) => ({
34
- output: {
35
- library: '[chunkhash:8]',
36
- path: outputPath,
37
- },
38
- plugins: [
39
- new CleanWebpackPlugin({
40
- cleanOnceBeforeBuildPatterns: [`${outputPath}/**/*.js`],
41
- dangerouslyAllowCleanPatternsOutsideProject: true,
42
- dry: false,
43
- }),
44
- new CentreonModulePlugin(federatedComponentConfiguration),
45
- ],
46
- });