@centreon/js-config 24.9.0 → 24.9.1

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.
Files changed (33) hide show
  1. package/cypress/component/commands.tsx +22 -82
  2. package/cypress/component/configuration.js +16 -39
  3. package/cypress/component/enableVisualTesting.ts +1 -1
  4. package/cypress/e2e/commands/configuration.ts +1 -330
  5. package/cypress/e2e/commands.ts +149 -629
  6. package/cypress/e2e/configuration.ts +40 -46
  7. package/cypress/e2e/plugins.ts +114 -52
  8. package/eslint/base.typescript.eslintrc.js +3 -15
  9. package/jest/index.js +2 -5
  10. package/package.json +45 -57
  11. package/tsconfig/index.json +4 -5
  12. package/webpack/base/index.js +130 -0
  13. package/webpack/patch/dev.js +24 -0
  14. package/{rspack → webpack}/patch/devServer.js +5 -3
  15. package/webpack/patch/module.js +46 -0
  16. package/biome/base.json +0 -224
  17. package/cypress/component/disableCssTransitions.ts +0 -19
  18. package/cypress/component/excludeNodeModulesFromCoverage.js +0 -36
  19. package/cypress/e2e/commands/monitoring.ts +0 -225
  20. package/cypress/e2e/esbuild-preprocessor.ts +0 -26
  21. package/cypress/e2e/reporter-config.js +0 -13
  22. package/cypress/e2e/tasks.ts +0 -259
  23. package/eslint/lambda/typescript.eslintrc.js +0 -48
  24. package/jest/lambda/typescript.js +0 -49
  25. package/rspack/base/globalConfig.js +0 -71
  26. package/rspack/base/index.js +0 -89
  27. package/rspack/patch/dev.js +0 -12
  28. package/rspack/patch/module.js +0 -13
  29. package/rspack/plugins/TransformPreloadScript.js +0 -37
  30. package/rspack/plugins/WriteRemoteEntryNameToModuleFederation.js +0 -30
  31. package/tsconfig/lambda/node20.tsconfig.json +0 -12
  32. package/tsconfig/lambda/tsconfig.json +0 -14
  33. package/tsconfig.json +0 -21
@@ -1,259 +0,0 @@
1
- /* eslint-disable no-console */
2
- import { execSync } from 'child_process';
3
- import { existsSync, mkdirSync } from 'fs';
4
- import path from 'path';
5
-
6
- import tar from 'tar-fs';
7
- import {
8
- DockerComposeEnvironment,
9
- GenericContainer,
10
- StartedDockerComposeEnvironment,
11
- StartedTestContainer,
12
- Wait,
13
- getContainerRuntimeClient
14
- } from 'testcontainers';
15
- import { createConnection } from 'mysql2/promise';
16
-
17
- interface Containers {
18
- [key: string]: StartedTestContainer;
19
- }
20
-
21
- export default (on: Cypress.PluginEvents): void => {
22
- let dockerEnvironment: StartedDockerComposeEnvironment | null = null;
23
- const containers: Containers = {};
24
-
25
- const getContainer = (containerName): StartedTestContainer => {
26
- let container;
27
-
28
- if (dockerEnvironment !== null) {
29
- container = dockerEnvironment.getContainer(`${containerName}-1`);
30
- } else if (containers[containerName]) {
31
- container = containers[containerName];
32
- } else {
33
- throw new Error(`Cannot get container ${containerName}`);
34
- }
35
-
36
- return container;
37
- };
38
-
39
- interface PortBinding {
40
- destination: number;
41
- source: number;
42
- }
43
-
44
- interface StartContainerProps {
45
- command?: string;
46
- image: string;
47
- name: string;
48
- portBindings: Array<PortBinding>;
49
- }
50
-
51
- interface StopContainerProps {
52
- name: string;
53
- }
54
-
55
- on('task', {
56
- copyFromContainer: async ({ destination, serviceName, source }) => {
57
- try {
58
- if (dockerEnvironment !== null) {
59
- const container = dockerEnvironment.getContainer(`${serviceName}-1`);
60
-
61
- await container
62
- .copyArchiveFromContainer(source)
63
- .then((archiveStream) => {
64
- return new Promise<void>((resolve) => {
65
- const dest = tar.extract(destination);
66
- archiveStream.pipe(dest);
67
- dest.on('finish', resolve);
68
- });
69
- });
70
- }
71
- } catch (error) {
72
- console.error(error);
73
- }
74
-
75
- return null;
76
- },
77
- copyToContainer: async ({ destination, serviceName, source, type }) => {
78
- const container = getContainer(serviceName);
79
-
80
- if (type === 'directory') {
81
- await container.copyDirectoriesToContainer([
82
- {
83
- source,
84
- target: destination
85
- }
86
- ]);
87
- } else if (type === 'file') {
88
- await container.copyFilesToContainer([
89
- {
90
- source,
91
- target: destination
92
- }
93
- ]);
94
- }
95
-
96
- return null;
97
- },
98
- createDirectory: async (directoryPath: string) => {
99
- if (!existsSync(directoryPath)) {
100
- mkdirSync(directoryPath, { recursive: true });
101
- }
102
-
103
- return null;
104
- },
105
- execInContainer: async ({ command, name }) => {
106
- const { exitCode, output } = await getContainer(name).exec([
107
- 'bash',
108
- '-c',
109
- `${command}${command.match(/[\n\r]/) ? '' : ' 2>&1'}`
110
- ]);
111
-
112
- return { exitCode, output };
113
- },
114
- getContainerId: (containerName: string) =>
115
- getContainer(containerName).getId(),
116
- getContainerIpAddress: (containerName: string) => {
117
- const container = getContainer(containerName);
118
-
119
- const networkNames = container.getNetworkNames();
120
-
121
- return container.getIpAddress(networkNames[0]);
122
- },
123
- getContainersLogs: async () => {
124
- try {
125
- const { dockerode } = (await getContainerRuntimeClient()).container;
126
- const loggedContainers = await dockerode.listContainers();
127
-
128
- return loggedContainers.reduce((acc, container) => {
129
- const containerName = container.Names[0].replace('/', '');
130
- acc[containerName] = execSync(`docker logs -t ${container.Id}`, {
131
- stdio: 'pipe'
132
- }).toString('utf8');
133
-
134
- return acc;
135
- }, {});
136
- } catch (error) {
137
- console.warn('Cannot get containers logs');
138
- console.warn(error);
139
-
140
- return null;
141
- }
142
- },
143
- requestOnDatabase: async ({ database, query }) => {
144
- let container: StartedTestContainer | null = null;
145
-
146
- if (dockerEnvironment !== null) {
147
- container = dockerEnvironment.getContainer('db-1');
148
- } else {
149
- container = getContainer('web');
150
- }
151
-
152
- const client = await createConnection({
153
- database,
154
- host: container.getHost(),
155
- password: 'centreon',
156
- port: container.getMappedPort(3306),
157
- user: 'centreon'
158
- });
159
-
160
- const [rows, fields] = await client.query(query);
161
-
162
- await client.end();
163
-
164
- return [rows, fields];
165
- },
166
- startContainer: async ({
167
- command,
168
- image,
169
- name,
170
- portBindings = []
171
- }: StartContainerProps) => {
172
- let container = await new GenericContainer(image).withName(name);
173
-
174
- portBindings.forEach(({ source, destination }) => {
175
- container = container.withExposedPorts({
176
- container: source,
177
- host: destination
178
- });
179
- });
180
-
181
- if (command) {
182
- container
183
- .withCommand(['bash', '-c', command])
184
- .withWaitStrategy(Wait.forSuccessfulCommand('ls'));
185
- }
186
-
187
- containers[name] = await container.start();
188
-
189
- return container;
190
- },
191
- startContainers: async ({
192
- composeFile,
193
- databaseImage,
194
- openidImage,
195
- profiles,
196
- samlImage,
197
- webImage
198
- }) => {
199
- try {
200
- const composeFileDir = path.dirname(composeFile);
201
- const composeFileName = path.basename(composeFile);
202
-
203
- dockerEnvironment = await new DockerComposeEnvironment(
204
- composeFileDir,
205
- composeFileName
206
- )
207
- .withEnvironment({
208
- MYSQL_IMAGE: databaseImage,
209
- OPENID_IMAGE: openidImage,
210
- SAML_IMAGE: samlImage,
211
- WEB_IMAGE: webImage
212
- })
213
- .withProfiles(...profiles)
214
- .withStartupTimeout(120000)
215
- .withWaitStrategy(
216
- 'web-1',
217
- Wait.forAll([
218
- Wait.forHealthCheck(),
219
- Wait.forLogMessage('Centreon is ready')
220
- ])
221
- )
222
- .up();
223
-
224
- return null;
225
- } catch (error) {
226
- if (error instanceof Error) {
227
- console.error(error.message);
228
- }
229
-
230
- throw error;
231
- }
232
- },
233
- stopContainer: async ({ name }: StopContainerProps) => {
234
- if (containers[name]) {
235
- const container = containers[name];
236
-
237
- await container.stop();
238
-
239
- delete containers[name];
240
- }
241
-
242
- return null;
243
- },
244
- stopContainers: async () => {
245
- if (dockerEnvironment !== null) {
246
- await dockerEnvironment.down();
247
-
248
- dockerEnvironment = null;
249
- }
250
-
251
- return null;
252
- },
253
- waitOn: async (url: string) => {
254
- execSync(`npx wait-on ${url}`);
255
-
256
- return null;
257
- }
258
- });
259
- };
@@ -1,48 +0,0 @@
1
- module.exports = {
2
- extends: [ '../node/typescript.eslintrc.js'],
3
- overrides: [
4
- {
5
- files: ["*.spec.js", "*.test.ts", "*.tests.ts"],
6
- rules: {
7
- "import/first": 0,
8
- "import/order": 0,
9
- "@typescript-eslint/ban-ts-comment": 0,
10
- "@typescript-eslint/no-explicit-any": 0
11
- }
12
- }
13
- ],
14
- rules: {
15
- "import/extensions": ["off"],
16
- "no-console": "off",
17
- "no-underscore-dangle": "off",
18
- "class-methods-use-this": "off",
19
- "@typescript-eslint/naming-convention": [
20
- "error",
21
- {
22
- format: ["camelCase", "PascalCase", "UPPER_CASE"],
23
- selector: "variable"
24
- },
25
- {
26
- filter: {
27
- match: false,
28
- regex: "(__esModule|.+-.+)"
29
- },
30
- format: ["snake_case", "camelCase", "PascalCase", "UPPER_CASE"],
31
- selector: "property",
32
- leadingUnderscore: "allow"
33
- },
34
- {
35
- filter: {
36
- match: false,
37
- regex: "^_$"
38
- },
39
- format: ["snake_case", "camelCase", "PascalCase"],
40
- selector: "parameter"
41
- }
42
- ],
43
- "@typescript-eslint/require-array-sort-compare": "error"
44
- },
45
- parserOptions: {
46
- project: ["./tsconfig.json"]
47
- }
48
- }
@@ -1,49 +0,0 @@
1
- /*
2
- * Copyright 2023 Centreon Team
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
-
17
- // For a detailed explanation regarding each configuration property, visit:
18
- // https://jestjs.io/docs/en/configuration.html
19
- const path = require('path');
20
-
21
- const rootPath = path.join(__dirname);
22
-
23
-
24
-
25
- module.exports = {
26
- rootDir: rootPath,
27
- // Automatically clear mock calls and instances between every test
28
- clearMocks: true,
29
- // The directory where Jest should output its coverage files
30
- coverageDirectory: '<rootDir>/coverage',
31
- // An array of regexp pattern strings used to skip coverage collection
32
- coveragePathIgnorePatterns: ['\\\\node_modules\\\\', 'tests'],
33
-
34
- // An array of file extensions your modules use
35
- moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
36
-
37
- // Automatically reset mock state between every test
38
- // resetMocks: true,
39
-
40
- testMatch: ['**/*.(test|tests|spec|specs).+(ts|tsx|js)'],
41
-
42
- // This option allows the use of a custom results processor
43
- // testResultsProcessor: 'jest-sonar-reporter',
44
-
45
- // A map from regular expressions to paths to transformers
46
- transform: {
47
- '^.+\\.(ts|tsx)$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.json' }],
48
- },
49
- };
@@ -1,71 +0,0 @@
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,89 +0,0 @@
1
- const path = require('path');
2
-
3
- const rspack = require('@rspack/core');
4
-
5
- const {
6
- getModuleConfiguration,
7
- optimization,
8
- output,
9
- cache
10
- } = require('./globalConfig');
11
-
12
- const getBaseConfiguration = ({
13
- moduleName,
14
- moduleFederationConfig,
15
- enableCoverage
16
- }) => ({
17
- cache,
18
- module: getModuleConfiguration(enableCoverage),
19
- optimization,
20
- output: {
21
- ...output,
22
- clean: true,
23
- library: moduleName,
24
- uniqueName: moduleName
25
- },
26
- plugins: [
27
- moduleName &&
28
- new rspack.container.ModuleFederationPlugin({
29
- filename: 'remoteEntry.[chunkhash:8].js',
30
- library: { name: moduleName, type: 'umd' },
31
- name: moduleName,
32
- shared: [
33
- {
34
- '@centreon/ui-context': {
35
- requiredVersion: '1.x',
36
- singleton: true
37
- }
38
- },
39
- {
40
- jotai: {
41
- requiredVersion: '2.x',
42
- singleton: true
43
- }
44
- },
45
- {
46
- 'jotai-suspense': {
47
- singleton: true
48
- }
49
- },
50
- {
51
- react: {
52
- requiredVersion: '18.x',
53
- singleton: true
54
- }
55
- },
56
- {
57
- 'react-dom': {
58
- requiredVersion: '18.x',
59
- singleton: true
60
- }
61
- },
62
- {
63
- 'react-i18next': {
64
- requiredVersion: '14.x',
65
- singleton: true
66
- }
67
- },
68
- {
69
- 'react-router-dom': {
70
- requiredVersion: '6.x',
71
- singleton: true
72
- }
73
- }
74
- ],
75
- ...moduleFederationConfig
76
- })
77
- ].filter(Boolean),
78
- resolve: {
79
- alias: {
80
- '@centreon/ui/fonts': path.resolve(
81
- './node_modules/@centreon/ui/public/fonts'
82
- ),
83
- react: path.resolve('./node_modules/react')
84
- },
85
- extensions: ['.js', '.jsx', '.ts', '.tsx']
86
- }
87
- });
88
-
89
- module.exports = getBaseConfiguration;
@@ -1,12 +0,0 @@
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,13 +0,0 @@
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
- });
@@ -1,37 +0,0 @@
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
- };
@@ -1,30 +0,0 @@
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
- };
@@ -1,12 +0,0 @@
1
- {
2
- "extends": "@tsconfig/node20/tsconfig.json",
3
- "compilerOptions": {
4
- "sourceMap": true,
5
- "allowJs": true,
6
- "strictNullChecks": false,
7
- "declaration": false,
8
- "esModuleInterop": true,
9
- "strict": true,
10
- "types": ["@types/jest", "node"]
11
- }
12
- }
@@ -1,14 +0,0 @@
1
- {
2
- "extends": "@tsconfig/node16/tsconfig.json",
3
- "compilerOptions": {
4
- "sourceMap": true,
5
- "allowJs": true,
6
- "strictNullChecks": false,
7
- "declaration": false,
8
- "esModuleInterop": true,
9
- "types": [
10
- "@types/jest",
11
- "node"
12
- ]
13
- }
14
- }
package/tsconfig.json DELETED
@@ -1,21 +0,0 @@
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
- }