@centreon/js-config 25.2.0 → 25.2.2

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.
@@ -511,103 +511,111 @@ Cypress.Commands.add(
511
511
  }
512
512
  );
513
513
 
514
- Cypress.Commands.add('stopContainers', (): Cypress.Chainable => {
515
- cy.log('Stopping containers ...');
516
-
517
- const logDirectory = `results/logs/${Cypress.spec.name.replace(
518
- artifactIllegalCharactersMatcher,
519
- '_'
520
- )}/${Cypress.currentTest.title.replace(
521
- artifactIllegalCharactersMatcher,
522
- '_'
523
- )}`;
514
+ Cypress.Commands.add(
515
+ 'getLogDirectory',
516
+ (): Cypress.Chainable => {
517
+ const logDirectory = `results/logs/${Cypress.spec.name.replace(
518
+ artifactIllegalCharactersMatcher,
519
+ '_'
520
+ )}/${Cypress.currentTest.title.replace(
521
+ artifactIllegalCharactersMatcher,
522
+ '_'
523
+ )}`;
524
524
 
525
- const name = 'web';
525
+ return cy
526
+ .createDirectory(logDirectory)
527
+ .exec(`chmod -R 755 "${logDirectory}"`)
528
+ .wrap(logDirectory);
529
+ }
530
+ );
526
531
 
527
- return cy
528
- .visitEmptyPage()
529
- .createDirectory(logDirectory)
530
- .getContainersLogs()
531
- .then((containersLogs: Array<Array<string>>) => {
532
- if (!containersLogs) {
533
- return;
534
- }
532
+ interface CopyWebContainerLogsProps {
533
+ name: string;
534
+ }
535
535
 
536
- Object.entries(containersLogs).forEach(([containerName, logs]) => {
537
- cy.writeFile(
538
- `results/logs/${Cypress.spec.name.replace(
539
- artifactIllegalCharactersMatcher,
540
- '_'
541
- )}/${Cypress.currentTest.title.replace(
542
- artifactIllegalCharactersMatcher,
543
- '_'
544
- )}/container-${containerName}.log`,
545
- logs
546
- );
547
- });
548
- })
549
- .copyFromContainer({
550
- destination: `${logDirectory}/broker`,
551
- name,
552
- source: '/var/log/centreon-broker'
553
- })
554
- .copyFromContainer({
555
- destination: `${logDirectory}/engine`,
556
- name,
557
- source: '/var/log/centreon-engine'
558
- })
559
- .copyFromContainer({
560
- destination: `${logDirectory}/centreon`,
561
- name,
562
- source: '/var/log/centreon'
563
- })
564
- .copyFromContainer({
565
- destination: `${logDirectory}/centreon-gorgone`,
566
- name,
567
- source: '/var/log/centreon-gorgone'
568
- })
569
- .then(() => {
536
+ Cypress.Commands.add(
537
+ 'copyWebContainerLogs',
538
+ ({ name }: CopyWebContainerLogsProps): Cypress.Chainable => {
539
+ cy.log(`Getting logs from container ${name} ...`);
540
+
541
+ return cy.getLogDirectory().then((logDirectory) => {
542
+ let sourcePhpLogs = '/var/log/php8.1-fpm-centreon-error.log';
543
+ let targetPhpLogs = `${logDirectory}/php8.1-fpm-centreon-error.log`;
544
+ let sourceApacheLogs = '/var/log/apache2';
545
+ let targetApacheLogs = `${logDirectory}/apache2`;
570
546
  if (Cypress.env('WEB_IMAGE_OS').includes('alma')) {
571
- return cy.copyFromContainer({
572
- destination: `${logDirectory}/php`,
573
- name,
574
- source: '/var/log/php-fpm'
575
- });
547
+ sourcePhpLogs = '/var/log/php-fpm';
548
+ targetPhpLogs = `${logDirectory}/php`;
549
+ sourceApacheLogs = '/var/log/httpd';
550
+ targetApacheLogs = `${logDirectory}/httpd`;
576
551
  }
577
552
 
578
- return cy.copyFromContainer(
579
- {
580
- destination: `${logDirectory}/php8.1-fpm-centreon-error.log`,
553
+ return cy
554
+ .copyFromContainer({
555
+ destination: `${logDirectory}/broker`,
581
556
  name,
582
- source: '/var/log/php8.1-fpm-centreon-error.log'
583
- },
584
- { failOnNonZeroExit: false }
585
- );
586
- })
587
- .then(() => {
588
- if (Cypress.env('WEB_IMAGE_OS').includes('alma')) {
589
- return cy.copyFromContainer({
590
- destination: `${logDirectory}/httpd`,
557
+ source: '/var/log/centreon-broker'
558
+ })
559
+ .copyFromContainer({
560
+ destination: `${logDirectory}/engine`,
591
561
  name,
592
- source: '/var/log/httpd'
593
- });
594
- }
595
-
596
- return cy.copyFromContainer(
597
- {
598
- destination: `${logDirectory}/apache2`,
562
+ source: '/var/log/centreon-engine'
563
+ })
564
+ .copyFromContainer({
565
+ destination: `${logDirectory}/centreon`,
599
566
  name,
600
- source: '/var/log/apache2'
601
- },
602
- { failOnNonZeroExit: false }
603
- );
604
- })
605
- .exec(`chmod -R 755 "${logDirectory}"`)
606
- .task(
607
- 'stopContainers',
608
- {},
609
- { timeout: 600000 } // 10 minutes because docker pull can be very slow
610
- );
567
+ source: '/var/log/centreon'
568
+ })
569
+ .copyFromContainer({
570
+ destination: `${logDirectory}/centreon-gorgone`,
571
+ name,
572
+ source: '/var/log/centreon-gorgone'
573
+ })
574
+ .copyFromContainer({
575
+ destination: targetPhpLogs,
576
+ name,
577
+ source: sourcePhpLogs,
578
+ })
579
+ .copyFromContainer({
580
+ destination: targetApacheLogs,
581
+ name,
582
+ source: sourceApacheLogs,
583
+ })
584
+ .exec(`chmod -R 755 "${logDirectory}"`);
585
+ });
586
+ });
587
+
588
+ Cypress.Commands.add('stopContainers', (): Cypress.Chainable => {
589
+ cy.log('Stopping containers ...');
590
+
591
+ const name = 'web';
592
+
593
+ return cy
594
+ .visitEmptyPage()
595
+ .getLogDirectory()
596
+ .then((logDirectory) => {
597
+ return cy
598
+ .getContainersLogs()
599
+ .then((containersLogs: Array<Array<string>>) => {
600
+ if (!containersLogs) {
601
+ return;
602
+ }
603
+
604
+ Object.entries(containersLogs).forEach(([containerName, logs]) => {
605
+ cy.writeFile(
606
+ `${logDirectory}/container-${containerName}.log`,
607
+ logs
608
+ );
609
+ });
610
+ })
611
+ .copyWebContainerLogs({ name })
612
+ .exec(`chmod -R 755 "${logDirectory}"`)
613
+ .task(
614
+ 'stopContainers',
615
+ {},
616
+ { timeout: 600000 } // 10 minutes because docker pull can be very slow
617
+ );
618
+ });
611
619
  });
612
620
 
613
621
  Cypress.Commands.add(
@@ -880,6 +888,7 @@ declare global {
880
888
  props: CopyToContainerProps,
881
889
  options?: Partial<Cypress.ExecOptions>
882
890
  ) => Cypress.Chainable;
891
+ copyWebContainerLogs: (props: CopyWebContainerLogsProps) => Cypress.Chainable;
883
892
  createDirectory: (directoryPath: string) => Cypress.Chainable;
884
893
  execInContainer: (
885
894
  props: ExecInContainerProps,
@@ -899,6 +908,7 @@ declare global {
899
908
  getContainerIpAddress: (containerName: string) => Cypress.Chainable;
900
909
  getContainersLogs: () => Cypress.Chainable;
901
910
  getIframeBody: () => Cypress.Chainable;
911
+ getLogDirectory: () => Cypress.Chainable;
902
912
  getTimeFromHeader: () => Cypress.Chainable;
903
913
  getWebVersion: () => Cypress.Chainable;
904
914
  hoverRootMenuItem: (rootItemNumber: number) => Cypress.Chainable;
@@ -50,14 +50,21 @@ export default ({
50
50
  },
51
51
  setupNodeEvents: async (cypressOn, config) => {
52
52
  const on = require('cypress-on-fix')(cypressOn)
53
- installLogsPrinter(on);
53
+ installLogsPrinter(
54
+ on,
55
+ {
56
+ commandTrimLength: 5000,
57
+ defaultTrimLength: 5000,
58
+ }
59
+ );
54
60
  await esbuildPreprocessor(on, config);
55
61
  tasks(on);
56
62
 
57
63
  return plugins(on, config);
58
64
  },
59
65
  specPattern,
60
- supportFile: 'support/e2e.{js,jsx,ts,tsx}'
66
+ supportFile: 'support/e2e.{js,jsx,ts,tsx}',
67
+ testIsolation: true,
61
68
  },
62
69
  env: {
63
70
  ...env,
@@ -55,19 +55,17 @@ export default (on: Cypress.PluginEvents): void => {
55
55
  on('task', {
56
56
  copyFromContainer: async ({ destination, serviceName, source }) => {
57
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
- });
58
+ const container = getContainer(serviceName);
59
+
60
+ await container
61
+ .copyArchiveFromContainer(source)
62
+ .then((archiveStream) => {
63
+ return new Promise<void>((resolve) => {
64
+ const dest = tar.extract(destination);
65
+ archiveStream.pipe(dest);
66
+ dest.on('finish', resolve);
69
67
  });
70
- }
68
+ });
71
69
  } catch (error) {
72
70
  console.error(error);
73
71
  }
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": "25.2.0",
4
+ "version": "25.2.2",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/centreon/centreon-frontend.git"
@@ -63,8 +63,12 @@ module.exports = {
63
63
  }
64
64
  },
65
65
  output: {
66
- chunkFilename: '[name].[chunkhash:8].chunk.js',
67
- filename: '[name].[chunkhash:8].js',
66
+ chunkFilename: isDev
67
+ ? '[name].[chunkhash:8].chunk.js'
68
+ : '[name].[contenthash].[chunkhash].[hash].js',
69
+ filename: isDev
70
+ ? '[name].[chunkhash:8].js'
71
+ : '[name].[contenthash].[hash].js',
68
72
  libraryTarget: 'umd',
69
73
  umdNamedDefine: true
70
74
  }