@centreon/js-config 23.10.16 → 23.10.18
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/cypress/component/configuration.js +10 -2
- package/cypress/component/enableVisualTesting.ts +1 -1
- package/cypress/e2e/commands.ts +115 -20
- package/cypress/e2e/configuration.ts +1 -1
- package/cypress/e2e/plugins.ts +3 -0
- package/eslint/base.typescript.eslintrc.js +15 -3
- package/eslint/lambda/typescript.eslintrc.js +48 -0
- package/jest/index.js +5 -1
- package/jest/lambda/typescript.js +49 -0
- package/package.json +4 -1
- package/tsconfig/index.json +5 -4
- package/tsconfig/lambda/tsconfig.json +14 -0
- package/webpack/base/globalConfig.js +71 -0
- package/webpack/base/index.js +14 -57
|
@@ -4,16 +4,24 @@ const {
|
|
|
4
4
|
addMatchImageSnapshotPlugin
|
|
5
5
|
} = require('@simonsmith/cypress-image-snapshot/plugin');
|
|
6
6
|
|
|
7
|
-
module.exports = ({
|
|
7
|
+
module.exports = ({
|
|
8
|
+
webpackConfig,
|
|
9
|
+
cypressFolder,
|
|
10
|
+
specPattern,
|
|
11
|
+
env,
|
|
12
|
+
useVite = false,
|
|
13
|
+
excludeSpecPattern
|
|
14
|
+
}) => {
|
|
8
15
|
const mainCypressFolder = cypressFolder || 'cypress';
|
|
9
16
|
|
|
10
17
|
return defineConfig({
|
|
11
18
|
component: {
|
|
12
19
|
devServer: {
|
|
13
|
-
bundler: 'webpack',
|
|
20
|
+
bundler: useVite ? 'vite' : 'webpack',
|
|
14
21
|
framework: 'react',
|
|
15
22
|
webpackConfig
|
|
16
23
|
},
|
|
24
|
+
excludeSpecPattern,
|
|
17
25
|
setupNodeEvents: (on, config) => {
|
|
18
26
|
addMatchImageSnapshotPlugin(on, config);
|
|
19
27
|
},
|
|
@@ -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.
|
|
16
|
+
failureThreshold: 0.07,
|
|
17
17
|
failureThresholdType: 'percent'
|
|
18
18
|
});
|
|
19
19
|
};
|
package/cypress/e2e/commands.ts
CHANGED
|
@@ -4,6 +4,8 @@ import './commands/configuration';
|
|
|
4
4
|
|
|
5
5
|
const apiLoginV2 = '/centreon/authentication/providers/configurations/local';
|
|
6
6
|
|
|
7
|
+
const artifactIllegalCharactersMatcher = /[,\s/|<>*?:"]/g;
|
|
8
|
+
|
|
7
9
|
Cypress.Commands.add('getWebVersion', (): Cypress.Chainable => {
|
|
8
10
|
return cy
|
|
9
11
|
.exec(
|
|
@@ -21,7 +23,7 @@ Cypress.Commands.add('getWebVersion', (): Cypress.Chainable => {
|
|
|
21
23
|
|
|
22
24
|
Cypress.Commands.add('getIframeBody', (): Cypress.Chainable => {
|
|
23
25
|
return cy
|
|
24
|
-
.get('iframe#main-content')
|
|
26
|
+
.get('iframe#main-content', { timeout: 10000 })
|
|
25
27
|
.its('0.contentDocument.body')
|
|
26
28
|
.should('not.be.empty')
|
|
27
29
|
.then(cy.wrap);
|
|
@@ -37,6 +39,13 @@ Cypress.Commands.add(
|
|
|
37
39
|
}
|
|
38
40
|
);
|
|
39
41
|
|
|
42
|
+
Cypress.Commands.add(
|
|
43
|
+
'clickSubRootMenuItem',
|
|
44
|
+
(page: string): Cypress.Chainable => {
|
|
45
|
+
return cy.get('div[data-cy="collapse"]').eq(1).contains(page).click();
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
|
|
40
49
|
interface NavigateToProps {
|
|
41
50
|
page: string;
|
|
42
51
|
rootItemNumber: number;
|
|
@@ -49,8 +58,13 @@ Cypress.Commands.add(
|
|
|
49
58
|
if (subMenu) {
|
|
50
59
|
cy.hoverRootMenuItem(rootItemNumber)
|
|
51
60
|
.contains(subMenu)
|
|
52
|
-
.trigger('mouseover'
|
|
53
|
-
|
|
61
|
+
.trigger('mouseover')
|
|
62
|
+
.get('.MuiCollapse-wrapper')
|
|
63
|
+
.find('div[data-cy="collapse"]')
|
|
64
|
+
.should('be.visible')
|
|
65
|
+
.and('contain', page);
|
|
66
|
+
|
|
67
|
+
cy.clickSubRootMenuItem(page);
|
|
54
68
|
|
|
55
69
|
return;
|
|
56
70
|
}
|
|
@@ -83,29 +97,35 @@ Cypress.Commands.add(
|
|
|
83
97
|
|
|
84
98
|
interface CopyFromContainerProps {
|
|
85
99
|
destination: string;
|
|
100
|
+
name?: string;
|
|
86
101
|
source: string;
|
|
87
102
|
}
|
|
88
103
|
|
|
89
104
|
Cypress.Commands.add(
|
|
90
105
|
'copyFromContainer',
|
|
91
|
-
({
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
106
|
+
({
|
|
107
|
+
name = Cypress.env('dockerName'),
|
|
108
|
+
source,
|
|
109
|
+
destination
|
|
110
|
+
}: CopyFromContainerProps) => {
|
|
111
|
+
return cy.exec(`docker cp ${name}:${source} "${destination}"`);
|
|
95
112
|
}
|
|
96
113
|
);
|
|
97
114
|
|
|
98
115
|
interface CopyToContainerProps {
|
|
99
116
|
destination: string;
|
|
117
|
+
name?: string;
|
|
100
118
|
source: string;
|
|
101
119
|
}
|
|
102
120
|
|
|
103
121
|
Cypress.Commands.add(
|
|
104
122
|
'copyToContainer',
|
|
105
|
-
({
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
123
|
+
({
|
|
124
|
+
name = Cypress.env('dockerName'),
|
|
125
|
+
source,
|
|
126
|
+
destination
|
|
127
|
+
}: CopyToContainerProps) => {
|
|
128
|
+
return cy.exec(`docker cp ${source} ${name}:${destination}`);
|
|
109
129
|
}
|
|
110
130
|
);
|
|
111
131
|
|
|
@@ -196,7 +216,9 @@ Cypress.Commands.add(
|
|
|
196
216
|
'startContainer',
|
|
197
217
|
({ name, image, portBindings }: StartContainerProps): Cypress.Chainable => {
|
|
198
218
|
return cy
|
|
199
|
-
.exec(`docker image inspect ${image} || docker pull ${image}
|
|
219
|
+
.exec(`docker image inspect ${image} || docker pull ${image}`, {
|
|
220
|
+
timeout: 120000
|
|
221
|
+
})
|
|
200
222
|
.task('startContainer', { image, name, portBindings });
|
|
201
223
|
}
|
|
202
224
|
);
|
|
@@ -212,7 +234,7 @@ Cypress.Commands.add(
|
|
|
212
234
|
'startWebContainer',
|
|
213
235
|
({
|
|
214
236
|
name = Cypress.env('dockerName'),
|
|
215
|
-
os = '
|
|
237
|
+
os = Cypress.env('WEB_IMAGE_OS'),
|
|
216
238
|
useSlim = true,
|
|
217
239
|
version = Cypress.env('WEB_IMAGE_VERSION')
|
|
218
240
|
}: StartWebContainerProps = {}): Cypress.Chainable => {
|
|
@@ -249,25 +271,47 @@ Cypress.Commands.add(
|
|
|
249
271
|
({
|
|
250
272
|
name = Cypress.env('dockerName')
|
|
251
273
|
}: StopWebContainerProps = {}): Cypress.Chainable => {
|
|
252
|
-
const logDirectory = `cypress/results/logs/${
|
|
253
|
-
|
|
254
|
-
|
|
274
|
+
const logDirectory = `cypress/results/logs/${Cypress.spec.name.replace(
|
|
275
|
+
artifactIllegalCharactersMatcher,
|
|
276
|
+
'_'
|
|
277
|
+
)}/${Cypress.currentTest.title.replace(
|
|
278
|
+
artifactIllegalCharactersMatcher,
|
|
279
|
+
'_'
|
|
280
|
+
)}`;
|
|
255
281
|
|
|
256
282
|
return cy
|
|
257
283
|
.visitEmptyPage()
|
|
258
284
|
.exec(`mkdir -p "${logDirectory}"`)
|
|
259
285
|
.copyFromContainer({
|
|
260
286
|
destination: `${logDirectory}/broker`,
|
|
287
|
+
name,
|
|
261
288
|
source: '/var/log/centreon-broker'
|
|
262
289
|
})
|
|
263
290
|
.copyFromContainer({
|
|
264
291
|
destination: `${logDirectory}/engine`,
|
|
292
|
+
name,
|
|
265
293
|
source: '/var/log/centreon-engine'
|
|
266
294
|
})
|
|
267
295
|
.copyFromContainer({
|
|
268
296
|
destination: `${logDirectory}/centreon`,
|
|
297
|
+
name,
|
|
269
298
|
source: '/var/log/centreon'
|
|
270
299
|
})
|
|
300
|
+
.then(() => {
|
|
301
|
+
if (Cypress.env('WEB_IMAGE_OS').includes('alma')) {
|
|
302
|
+
return cy.copyFromContainer({
|
|
303
|
+
destination: `${logDirectory}/php`,
|
|
304
|
+
name,
|
|
305
|
+
source: '/var/log/php-fpm'
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
return cy.copyFromContainer({
|
|
310
|
+
destination: `${logDirectory}/php8.1-fpm-centreon-error.log`,
|
|
311
|
+
name,
|
|
312
|
+
source: '/var/log/php8.1-fpm-centreon-error.log'
|
|
313
|
+
});
|
|
314
|
+
})
|
|
271
315
|
.stopContainer({ name });
|
|
272
316
|
}
|
|
273
317
|
);
|
|
@@ -281,10 +325,11 @@ Cypress.Commands.add(
|
|
|
281
325
|
({ name }: StopContainerProps): Cypress.Chainable => {
|
|
282
326
|
cy.exec(`docker logs ${name}`).then(({ stdout }) => {
|
|
283
327
|
cy.writeFile(
|
|
284
|
-
`cypress/results/logs/${
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
328
|
+
`cypress/results/logs/${Cypress.spec.name.replace(
|
|
329
|
+
artifactIllegalCharactersMatcher,
|
|
330
|
+
'_'
|
|
331
|
+
)}/${Cypress.currentTest.title.replace(
|
|
332
|
+
artifactIllegalCharactersMatcher,
|
|
288
333
|
'_'
|
|
289
334
|
)}/container-${name}.log`,
|
|
290
335
|
stdout
|
|
@@ -295,9 +340,56 @@ Cypress.Commands.add(
|
|
|
295
340
|
}
|
|
296
341
|
);
|
|
297
342
|
|
|
343
|
+
interface Dashboard {
|
|
344
|
+
description?: string;
|
|
345
|
+
name: string;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
Cypress.Commands.add(
|
|
349
|
+
'insertDashboardList',
|
|
350
|
+
(fixtureFile: string): Cypress.Chainable => {
|
|
351
|
+
return cy.fixture(fixtureFile).then((dashboardList) => {
|
|
352
|
+
cy.wrap(
|
|
353
|
+
Promise.all(
|
|
354
|
+
dashboardList.map((dashboardBody: Dashboard) =>
|
|
355
|
+
cy.insertDashboard({ ...dashboardBody })
|
|
356
|
+
)
|
|
357
|
+
)
|
|
358
|
+
);
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
);
|
|
362
|
+
|
|
363
|
+
Cypress.Commands.add(
|
|
364
|
+
'insertDashboard',
|
|
365
|
+
(dashboardBody: Dashboard): Cypress.Chainable => {
|
|
366
|
+
return cy.request({
|
|
367
|
+
body: {
|
|
368
|
+
...dashboardBody
|
|
369
|
+
},
|
|
370
|
+
method: 'POST',
|
|
371
|
+
url: '/centreon/api/latest/configuration/dashboards'
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
);
|
|
375
|
+
|
|
376
|
+
Cypress.Commands.add('getTimeFromHeader', (): Cypress.Chainable => {
|
|
377
|
+
return cy.waitUntil(() => {
|
|
378
|
+
return cy.get('header div[data-cy="clock"]').then(($time) => {
|
|
379
|
+
const headerTime = $time.children()[1].textContent;
|
|
380
|
+
if (headerTime?.match(/\d+:\d+/)) {
|
|
381
|
+
return headerTime;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
return false;
|
|
385
|
+
});
|
|
386
|
+
});
|
|
387
|
+
});
|
|
388
|
+
|
|
298
389
|
declare global {
|
|
299
390
|
namespace Cypress {
|
|
300
391
|
interface Chainable {
|
|
392
|
+
clickSubRootMenuItem: (page: string) => Cypress.Chainable;
|
|
301
393
|
copyFromContainer: (props: CopyFromContainerProps) => Cypress.Chainable;
|
|
302
394
|
copyToContainer: (props: CopyToContainerProps) => Cypress.Chainable;
|
|
303
395
|
execInContainer: ({
|
|
@@ -305,8 +397,11 @@ declare global {
|
|
|
305
397
|
name
|
|
306
398
|
}: ExecInContainerProps) => Cypress.Chainable;
|
|
307
399
|
getIframeBody: () => Cypress.Chainable;
|
|
400
|
+
getTimeFromHeader: () => Cypress.Chainable;
|
|
308
401
|
getWebVersion: () => Cypress.Chainable;
|
|
309
402
|
hoverRootMenuItem: (rootItemNumber: number) => Cypress.Chainable;
|
|
403
|
+
insertDashboard: (dashboard: Dashboard) => Cypress.Chainable;
|
|
404
|
+
insertDashboardList: (fixtureFile: string) => Cypress.Chainable;
|
|
310
405
|
loginByTypeOfUser: ({
|
|
311
406
|
jsonName = 'admin',
|
|
312
407
|
loginViaApi = false
|
package/cypress/e2e/plugins.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import Docker from 'dockerode';
|
|
7
7
|
import { addCucumberPreprocessorPlugin } from '@badeball/cypress-cucumber-preprocessor';
|
|
8
8
|
import webpackPreprocessor from '@cypress/webpack-preprocessor';
|
|
9
|
+
import cypressFailFast from 'cypress-fail-fast/plugin';
|
|
9
10
|
|
|
10
11
|
const docker = new Docker();
|
|
11
12
|
|
|
@@ -42,6 +43,8 @@ const getWebpackOptions = (config): object => {
|
|
|
42
43
|
export default async (on, config): Promise<void> => {
|
|
43
44
|
await addCucumberPreprocessorPlugin(on, config);
|
|
44
45
|
|
|
46
|
+
await cypressFailFast(on, config);
|
|
47
|
+
|
|
45
48
|
const webpackOptions = await getWebpackOptions(config);
|
|
46
49
|
const options = {
|
|
47
50
|
webpackOptions
|
|
@@ -21,11 +21,15 @@ module.exports = {
|
|
|
21
21
|
}
|
|
22
22
|
],
|
|
23
23
|
'@typescript-eslint/camelcase': 'off',
|
|
24
|
-
'@typescript-eslint/consistent-type-definitions': [
|
|
24
|
+
'@typescript-eslint/consistent-type-definitions': ['off', 'interface'],
|
|
25
|
+
'@typescript-eslint/explicit-function-return-type': [
|
|
25
26
|
'error',
|
|
26
|
-
|
|
27
|
+
{
|
|
28
|
+
allowExpressions: true,
|
|
29
|
+
allowHigherOrderFunctions: true,
|
|
30
|
+
allowTypedFunctionExpressions: true
|
|
31
|
+
}
|
|
27
32
|
],
|
|
28
|
-
'@typescript-eslint/explicit-function-return-type': ['error'],
|
|
29
33
|
'@typescript-eslint/explicit-member-accessibility': [
|
|
30
34
|
'error',
|
|
31
35
|
{
|
|
@@ -76,13 +80,21 @@ module.exports = {
|
|
|
76
80
|
}
|
|
77
81
|
],
|
|
78
82
|
camelcase: 'off',
|
|
83
|
+
'import/no-cycle': 'off',
|
|
84
|
+
'import/no-named-as-default': 'warn',
|
|
79
85
|
'no-shadow': 'off',
|
|
80
86
|
'no-unused-expressions': 'off'
|
|
81
87
|
},
|
|
82
88
|
settings: {
|
|
89
|
+
'import/parsers': {
|
|
90
|
+
'@typescript-eslint/parser': ['.ts', '.tsx']
|
|
91
|
+
},
|
|
83
92
|
'import/resolver': {
|
|
84
93
|
alias: {
|
|
85
94
|
extensions: ['.ts', '.tsx', '.js', '.jsx']
|
|
95
|
+
},
|
|
96
|
+
typescript: {
|
|
97
|
+
alwaysTryTypes: true
|
|
86
98
|
}
|
|
87
99
|
}
|
|
88
100
|
}
|
|
@@ -0,0 +1,48 @@
|
|
|
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
|
+
}
|
package/jest/index.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
moduleNameMapper: {
|
|
3
3
|
'\\.(s?css|png|svg|jpg)$': 'identity-obj-proxy',
|
|
4
|
+
'^.+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$':
|
|
5
|
+
'jest-transform-stub',
|
|
4
6
|
'^react($|/.+)': '<rootDir>/node_modules/react$1'
|
|
5
7
|
},
|
|
6
8
|
setupFilesAfterEnv: ['@testing-library/jest-dom/extend-expect'],
|
|
7
9
|
testEnvironment: 'jsdom',
|
|
8
|
-
testPathIgnorePatterns: ['/node_modules/'],
|
|
10
|
+
testPathIgnorePatterns: ['/node_modules/', '!*.cypress.spec.tsx'],
|
|
9
11
|
transform: {
|
|
12
|
+
'.+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$':
|
|
13
|
+
'jest-transform-stub',
|
|
10
14
|
'^.+\\.[jt]sx?$': [
|
|
11
15
|
'@swc/jest',
|
|
12
16
|
{
|
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
};
|
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": "23.10.
|
|
4
|
+
"version": "23.10.18",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/centreon/centreon-frontend.git"
|
|
@@ -17,12 +17,15 @@
|
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@badeball/cypress-cucumber-preprocessor": "^14.0.0",
|
|
20
|
+
"@tsconfig/node16": "^1.0.4",
|
|
20
21
|
"@types/dockerode": "^3.3.16",
|
|
22
|
+
"cypress-fail-fast": "^7.0.1",
|
|
21
23
|
"dockerode": "^3.3.5",
|
|
22
24
|
"eslint": "^8.17.0",
|
|
23
25
|
"eslint-config-airbnb": "19.0.4",
|
|
24
26
|
"eslint-config-prettier": "^8.5.0",
|
|
25
27
|
"eslint-import-resolver-alias": "^1.1.2",
|
|
28
|
+
"eslint-import-resolver-typescript": "^3.5.5",
|
|
26
29
|
"eslint-plugin-babel": "^5.3.1",
|
|
27
30
|
"eslint-plugin-hooks": "^0.4.3",
|
|
28
31
|
"eslint-plugin-import": "^2.26.0",
|
package/tsconfig/index.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"moduleResolution": "
|
|
3
|
+
"moduleResolution": "nodenext",
|
|
4
4
|
"downlevelIteration": true,
|
|
5
|
-
"module": "
|
|
6
|
-
"target": "
|
|
5
|
+
"module": "esnext",
|
|
6
|
+
"target": "es2018",
|
|
7
7
|
"jsx": "react-jsx",
|
|
8
8
|
"strict": true,
|
|
9
9
|
"noImplicitAny": false,
|
|
10
10
|
"skipLibCheck": true,
|
|
11
|
-
"esModuleInterop": true
|
|
11
|
+
"esModuleInterop": true,
|
|
12
|
+
"resolveJsonModule": true
|
|
12
13
|
}
|
|
13
14
|
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
const excludeNodeModulesExceptCentreonUi =
|
|
2
|
+
/node_modules(\\|\/)\.pnpm(\\|\/)(?!(@centreon))/;
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
cache: false,
|
|
6
|
+
excludeNodeModulesExceptCentreonUi,
|
|
7
|
+
getModuleConfiguration: (jscTransformConfiguration) => ({
|
|
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
|
+
parser: {
|
|
21
|
+
syntax: 'typescript',
|
|
22
|
+
tsx: true
|
|
23
|
+
},
|
|
24
|
+
transform: jscTransformConfiguration
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
test: /\.icon.svg$/,
|
|
31
|
+
use: ['@svgr/webpack']
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
exclude: excludeNodeModulesExceptCentreonUi,
|
|
35
|
+
test: /\.(bmp|png|jpg|jpeg|gif|svg)$/,
|
|
36
|
+
use: [
|
|
37
|
+
{
|
|
38
|
+
loader: 'url-loader',
|
|
39
|
+
options: {
|
|
40
|
+
limit: 10000,
|
|
41
|
+
name: '[name].[hash:8].[ext]'
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
]
|
|
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
|
+
};
|
package/webpack/base/index.js
CHANGED
|
@@ -3,68 +3,22 @@ const path = require('path');
|
|
|
3
3
|
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
|
4
4
|
const { ModuleFederationPlugin } = require('webpack').container;
|
|
5
5
|
|
|
6
|
-
const
|
|
7
|
-
|
|
6
|
+
const {
|
|
7
|
+
getModuleConfiguration,
|
|
8
|
+
optimization,
|
|
9
|
+
output,
|
|
10
|
+
cache
|
|
11
|
+
} = require('./globalConfig');
|
|
8
12
|
|
|
9
13
|
const getBaseConfiguration = ({
|
|
10
14
|
moduleName,
|
|
11
15
|
moduleFederationConfig,
|
|
12
16
|
jscTransformConfiguration
|
|
13
17
|
}) => ({
|
|
14
|
-
cache
|
|
15
|
-
module:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
parser: { system: false },
|
|
19
|
-
test: /\.[cm]?(j|t)sx?$/
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
exclude: excludeNodeModulesExceptCentreonUi,
|
|
23
|
-
test: /\.[jt]sx?$/,
|
|
24
|
-
use: {
|
|
25
|
-
loader: 'swc-loader',
|
|
26
|
-
options: {
|
|
27
|
-
jsc: {
|
|
28
|
-
parser: {
|
|
29
|
-
syntax: 'typescript',
|
|
30
|
-
tsx: true
|
|
31
|
-
},
|
|
32
|
-
transform: jscTransformConfiguration
|
|
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
|
-
use: [
|
|
45
|
-
{
|
|
46
|
-
loader: 'url-loader',
|
|
47
|
-
options: {
|
|
48
|
-
limit: 10000,
|
|
49
|
-
name: '[name].[hash:8].[ext]'
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
]
|
|
53
|
-
}
|
|
54
|
-
]
|
|
55
|
-
},
|
|
56
|
-
optimization: {
|
|
57
|
-
splitChunks: {
|
|
58
|
-
chunks: 'all',
|
|
59
|
-
maxSize: 400 * 1024
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
output: {
|
|
63
|
-
chunkFilename: '[name].[chunkhash:8].chunk.js',
|
|
64
|
-
filename: '[name].[chunkhash:8].js',
|
|
65
|
-
libraryTarget: 'umd',
|
|
66
|
-
umdNamedDefine: true
|
|
67
|
-
},
|
|
18
|
+
cache,
|
|
19
|
+
module: getModuleConfiguration(jscTransformConfiguration),
|
|
20
|
+
optimization,
|
|
21
|
+
output,
|
|
68
22
|
plugins: [
|
|
69
23
|
new CleanWebpackPlugin(),
|
|
70
24
|
moduleName &&
|
|
@@ -121,7 +75,10 @@ const getBaseConfiguration = ({
|
|
|
121
75
|
].filter(Boolean),
|
|
122
76
|
resolve: {
|
|
123
77
|
alias: {
|
|
124
|
-
react: path.resolve('./node_modules/react')
|
|
78
|
+
react: path.resolve('./node_modules/react'),
|
|
79
|
+
'@centreon/ui/fonts': path.resolve(
|
|
80
|
+
'./node_modules/@centreon/ui/public/fonts'
|
|
81
|
+
)
|
|
125
82
|
},
|
|
126
83
|
extensions: ['.js', '.jsx', '.ts', '.tsx']
|
|
127
84
|
}
|