@centreon/js-config 23.10.21 → 23.10.23
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 +185 -21
- package/cypress/e2e/configuration.ts +1 -1
- 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 +3 -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,41 @@ 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
|
+
{
|
|
108
|
+
name = Cypress.env('dockerName'),
|
|
109
|
+
source,
|
|
110
|
+
destination
|
|
111
|
+
}: CopyFromContainerProps,
|
|
112
|
+
options
|
|
113
|
+
) => {
|
|
114
|
+
return cy.exec(`docker cp ${name}:${source} "${destination}"`, options);
|
|
95
115
|
}
|
|
96
116
|
);
|
|
97
117
|
|
|
98
118
|
interface CopyToContainerProps {
|
|
99
119
|
destination: string;
|
|
120
|
+
name?: string;
|
|
100
121
|
source: string;
|
|
101
122
|
}
|
|
102
123
|
|
|
103
124
|
Cypress.Commands.add(
|
|
104
125
|
'copyToContainer',
|
|
105
|
-
(
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
126
|
+
(
|
|
127
|
+
{
|
|
128
|
+
name = Cypress.env('dockerName'),
|
|
129
|
+
source,
|
|
130
|
+
destination
|
|
131
|
+
}: CopyToContainerProps,
|
|
132
|
+
options
|
|
133
|
+
) => {
|
|
134
|
+
return cy.exec(`docker cp ${source} ${name}:${destination}`, options);
|
|
109
135
|
}
|
|
110
136
|
);
|
|
111
137
|
|
|
@@ -196,8 +222,28 @@ Cypress.Commands.add(
|
|
|
196
222
|
'startContainer',
|
|
197
223
|
({ name, image, portBindings }: StartContainerProps): Cypress.Chainable => {
|
|
198
224
|
return cy
|
|
199
|
-
.exec(
|
|
200
|
-
.
|
|
225
|
+
.exec('docker image list --format "{{.Repository}}:{{.Tag}}"')
|
|
226
|
+
.then(({ stdout }) => {
|
|
227
|
+
if (
|
|
228
|
+
stdout.match(
|
|
229
|
+
new RegExp(
|
|
230
|
+
`^${image.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&')}`,
|
|
231
|
+
'm'
|
|
232
|
+
)
|
|
233
|
+
)
|
|
234
|
+
) {
|
|
235
|
+
cy.log(`Local docker image found : ${image}`);
|
|
236
|
+
|
|
237
|
+
return cy.wrap(image);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
cy.log(`Pulling remote docker image : ${image}`);
|
|
241
|
+
|
|
242
|
+
return cy.exec(`docker pull ${image}`).then(() => cy.wrap(image));
|
|
243
|
+
})
|
|
244
|
+
.then((imageName) =>
|
|
245
|
+
cy.task('startContainer', { image: imageName, name, portBindings })
|
|
246
|
+
);
|
|
201
247
|
}
|
|
202
248
|
);
|
|
203
249
|
|
|
@@ -212,7 +258,7 @@ Cypress.Commands.add(
|
|
|
212
258
|
'startWebContainer',
|
|
213
259
|
({
|
|
214
260
|
name = Cypress.env('dockerName'),
|
|
215
|
-
os = '
|
|
261
|
+
os = Cypress.env('WEB_IMAGE_OS'),
|
|
216
262
|
useSlim = true,
|
|
217
263
|
version = Cypress.env('WEB_IMAGE_VERSION')
|
|
218
264
|
}: StartWebContainerProps = {}): Cypress.Chainable => {
|
|
@@ -249,25 +295,51 @@ Cypress.Commands.add(
|
|
|
249
295
|
({
|
|
250
296
|
name = Cypress.env('dockerName')
|
|
251
297
|
}: StopWebContainerProps = {}): Cypress.Chainable => {
|
|
252
|
-
const logDirectory = `cypress/results/logs/${
|
|
253
|
-
|
|
254
|
-
|
|
298
|
+
const logDirectory = `cypress/results/logs/${Cypress.spec.name.replace(
|
|
299
|
+
artifactIllegalCharactersMatcher,
|
|
300
|
+
'_'
|
|
301
|
+
)}/${Cypress.currentTest.title.replace(
|
|
302
|
+
artifactIllegalCharactersMatcher,
|
|
303
|
+
'_'
|
|
304
|
+
)}`;
|
|
255
305
|
|
|
256
306
|
return cy
|
|
257
307
|
.visitEmptyPage()
|
|
258
308
|
.exec(`mkdir -p "${logDirectory}"`)
|
|
259
309
|
.copyFromContainer({
|
|
260
310
|
destination: `${logDirectory}/broker`,
|
|
311
|
+
name,
|
|
261
312
|
source: '/var/log/centreon-broker'
|
|
262
313
|
})
|
|
263
314
|
.copyFromContainer({
|
|
264
315
|
destination: `${logDirectory}/engine`,
|
|
316
|
+
name,
|
|
265
317
|
source: '/var/log/centreon-engine'
|
|
266
318
|
})
|
|
267
319
|
.copyFromContainer({
|
|
268
320
|
destination: `${logDirectory}/centreon`,
|
|
321
|
+
name,
|
|
269
322
|
source: '/var/log/centreon'
|
|
270
323
|
})
|
|
324
|
+
.then(() => {
|
|
325
|
+
if (Cypress.env('WEB_IMAGE_OS').includes('alma')) {
|
|
326
|
+
return cy.copyFromContainer({
|
|
327
|
+
destination: `${logDirectory}/php`,
|
|
328
|
+
name,
|
|
329
|
+
source: '/var/log/php-fpm'
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
return cy.copyFromContainer(
|
|
334
|
+
{
|
|
335
|
+
destination: `${logDirectory}/php8.1-fpm-centreon-error.log`,
|
|
336
|
+
name,
|
|
337
|
+
source: '/var/log/php8.1-fpm-centreon-error.log'
|
|
338
|
+
},
|
|
339
|
+
{ failOnNonZeroExit: false }
|
|
340
|
+
);
|
|
341
|
+
})
|
|
342
|
+
.exec(`chmod -R 755 "${logDirectory}"`)
|
|
271
343
|
.stopContainer({ name });
|
|
272
344
|
}
|
|
273
345
|
);
|
|
@@ -281,10 +353,11 @@ Cypress.Commands.add(
|
|
|
281
353
|
({ name }: StopContainerProps): Cypress.Chainable => {
|
|
282
354
|
cy.exec(`docker logs ${name}`).then(({ stdout }) => {
|
|
283
355
|
cy.writeFile(
|
|
284
|
-
`cypress/results/logs/${
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
356
|
+
`cypress/results/logs/${Cypress.spec.name.replace(
|
|
357
|
+
artifactIllegalCharactersMatcher,
|
|
358
|
+
'_'
|
|
359
|
+
)}/${Cypress.currentTest.title.replace(
|
|
360
|
+
artifactIllegalCharactersMatcher,
|
|
288
361
|
'_'
|
|
289
362
|
)}/container-${name}.log`,
|
|
290
363
|
stdout
|
|
@@ -295,9 +368,92 @@ Cypress.Commands.add(
|
|
|
295
368
|
}
|
|
296
369
|
);
|
|
297
370
|
|
|
371
|
+
interface Dashboard {
|
|
372
|
+
description?: string;
|
|
373
|
+
name: string;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
Cypress.Commands.add(
|
|
377
|
+
'insertDashboardList',
|
|
378
|
+
(fixtureFile: string): Cypress.Chainable => {
|
|
379
|
+
return cy.fixture(fixtureFile).then((dashboardList) => {
|
|
380
|
+
cy.wrap(
|
|
381
|
+
Promise.all(
|
|
382
|
+
dashboardList.map((dashboardBody: Dashboard) =>
|
|
383
|
+
cy.insertDashboard({ ...dashboardBody })
|
|
384
|
+
)
|
|
385
|
+
)
|
|
386
|
+
);
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
);
|
|
390
|
+
|
|
391
|
+
Cypress.Commands.add(
|
|
392
|
+
'insertDashboard',
|
|
393
|
+
(dashboardBody: Dashboard): Cypress.Chainable => {
|
|
394
|
+
return cy.request({
|
|
395
|
+
body: {
|
|
396
|
+
...dashboardBody
|
|
397
|
+
},
|
|
398
|
+
method: 'POST',
|
|
399
|
+
url: '/centreon/api/latest/configuration/dashboards'
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
);
|
|
403
|
+
|
|
404
|
+
interface ShareDashboardToUserProps {
|
|
405
|
+
dashboardName: string;
|
|
406
|
+
role: string;
|
|
407
|
+
userName: string;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
Cypress.Commands.add(
|
|
411
|
+
'shareDashboardToUser',
|
|
412
|
+
({ dashboardName, userName, role }: ShareDashboardToUserProps): void => {
|
|
413
|
+
Promise.all([
|
|
414
|
+
cy.request({
|
|
415
|
+
method: 'GET',
|
|
416
|
+
url: `/centreon/api/latest/configuration/users?search={"name":"${userName}"}`
|
|
417
|
+
}),
|
|
418
|
+
cy.request({
|
|
419
|
+
method: 'GET',
|
|
420
|
+
url: `/centreon/api/latest/configuration/dashboards?search={"name":"${dashboardName}"}`
|
|
421
|
+
})
|
|
422
|
+
])
|
|
423
|
+
.then(([retrievedUser, retrievedDashboard]) => {
|
|
424
|
+
const userId = retrievedUser.body.result[0].id;
|
|
425
|
+
const dashboardId = retrievedDashboard.body.result[0].id;
|
|
426
|
+
|
|
427
|
+
cy.request({
|
|
428
|
+
body: {
|
|
429
|
+
id: userId,
|
|
430
|
+
role: `${role}`
|
|
431
|
+
},
|
|
432
|
+
method: 'POST',
|
|
433
|
+
url: `/centreon/api/latest/configuration/dashboards/${dashboardId}/access_rights/contacts`
|
|
434
|
+
});
|
|
435
|
+
})
|
|
436
|
+
.catch((error) => console.log(error));
|
|
437
|
+
}
|
|
438
|
+
);
|
|
439
|
+
|
|
440
|
+
Cypress.Commands.add('getTimeFromHeader', (): Cypress.Chainable => {
|
|
441
|
+
return cy.waitUntil(() => {
|
|
442
|
+
return cy.get('header div[data-cy="clock"]').then(($time) => {
|
|
443
|
+
const headerTime = $time.children()[1].textContent;
|
|
444
|
+
if (headerTime?.match(/\d+:\d+/)) {
|
|
445
|
+
return headerTime;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
return false;
|
|
449
|
+
});
|
|
450
|
+
});
|
|
451
|
+
});
|
|
452
|
+
|
|
298
453
|
declare global {
|
|
299
454
|
namespace Cypress {
|
|
300
455
|
interface Chainable {
|
|
456
|
+
clickSubRootMenuItem: (page: string) => Cypress.Chainable;
|
|
301
457
|
copyFromContainer: (props: CopyFromContainerProps) => Cypress.Chainable;
|
|
302
458
|
copyToContainer: (props: CopyToContainerProps) => Cypress.Chainable;
|
|
303
459
|
execInContainer: ({
|
|
@@ -305,8 +461,11 @@ declare global {
|
|
|
305
461
|
name
|
|
306
462
|
}: ExecInContainerProps) => Cypress.Chainable;
|
|
307
463
|
getIframeBody: () => Cypress.Chainable;
|
|
464
|
+
getTimeFromHeader: () => Cypress.Chainable;
|
|
308
465
|
getWebVersion: () => Cypress.Chainable;
|
|
309
466
|
hoverRootMenuItem: (rootItemNumber: number) => Cypress.Chainable;
|
|
467
|
+
insertDashboard: (dashboard: Dashboard) => Cypress.Chainable;
|
|
468
|
+
insertDashboardList: (fixtureFile: string) => Cypress.Chainable;
|
|
310
469
|
loginByTypeOfUser: ({
|
|
311
470
|
jsonName = 'admin',
|
|
312
471
|
loginViaApi = false
|
|
@@ -317,6 +476,11 @@ declare global {
|
|
|
317
476
|
rootItemNumber,
|
|
318
477
|
subMenu
|
|
319
478
|
}: NavigateToProps) => Cypress.Chainable;
|
|
479
|
+
shareDashboardToUser: ({
|
|
480
|
+
dashboardName,
|
|
481
|
+
userName,
|
|
482
|
+
role
|
|
483
|
+
}: ShareDashboardToUserProps) => Cypress.Chainable;
|
|
320
484
|
startContainer: ({
|
|
321
485
|
name,
|
|
322
486
|
image
|
|
@@ -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.23",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/centreon/centreon-frontend.git"
|
|
@@ -17,12 +17,14 @@
|
|
|
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",
|
|
21
22
|
"dockerode": "^3.3.5",
|
|
22
23
|
"eslint": "^8.17.0",
|
|
23
24
|
"eslint-config-airbnb": "19.0.4",
|
|
24
25
|
"eslint-config-prettier": "^8.5.0",
|
|
25
26
|
"eslint-import-resolver-alias": "^1.1.2",
|
|
27
|
+
"eslint-import-resolver-typescript": "^3.5.5",
|
|
26
28
|
"eslint-plugin-babel": "^5.3.1",
|
|
27
29
|
"eslint-plugin-hooks": "^0.4.3",
|
|
28
30
|
"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
|
}
|