@centreon/js-config 25.6.2 → 25.6.4

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,79 +1,74 @@
1
1
  /* eslint-disable @typescript-eslint/no-var-requires */
2
- const { devServer } = require("cypress-rspack-dev-server");
3
- const { defineConfig } = require("cypress");
2
+ const { devServer } = require('cypress-rspack-dev-server');
3
+ const { defineConfig } = require('cypress');
4
4
  const {
5
- addMatchImageSnapshotPlugin,
6
- } = require("@simonsmith/cypress-image-snapshot/plugin");
7
- const cypressCodeCoverageTask = require("@cypress/code-coverage/task");
5
+ addMatchImageSnapshotPlugin
6
+ } = require('@simonsmith/cypress-image-snapshot/plugin');
7
+ const cypressCodeCoverageTask = require('@cypress/code-coverage/task');
8
8
 
9
9
  module.exports = ({
10
10
  rspackConfig,
11
11
  cypressFolder,
12
12
  specPattern,
13
13
  env,
14
- excludeSpecPattern,
14
+ excludeSpecPattern
15
15
  }) => {
16
- const mainCypressFolder = cypressFolder || "cypress";
16
+ const mainCypressFolder = cypressFolder || 'cypress';
17
17
 
18
18
  return defineConfig({
19
19
  component: {
20
20
  devServer: (devServerConfig) =>
21
21
  devServer({
22
22
  ...devServerConfig,
23
- framework: "react",
24
- rspackConfig,
23
+ framework: 'react',
24
+ rspackConfig
25
25
  }),
26
26
  excludeSpecPattern,
27
27
  setupNodeEvents: (on, config) => {
28
28
  addMatchImageSnapshotPlugin(on, config);
29
29
 
30
30
  cypressCodeCoverageTask(on, config);
31
- on("task", {
32
- coverageReport: () => {
33
- return null;
34
- },
35
- });
36
31
 
37
- on("before:browser:launch", (browser, launchOptions) => {
32
+ on('before:browser:launch', (browser, launchOptions) => {
38
33
  if (
39
- ["chrome", "chromium"].includes(browser.name) &&
34
+ ['chrome', 'chromium'].includes(browser.name) &&
40
35
  browser.isHeadless
41
36
  ) {
42
- launchOptions.args.push("--headless=new");
43
- launchOptions.args.push("--force-color-profile=srgb");
44
- launchOptions.args.push("--window-size=1400,1200");
37
+ launchOptions.args.push('--headless=new');
38
+ launchOptions.args.push('--force-color-profile=srgb');
39
+ launchOptions.args.push('--window-size=1400,1200');
45
40
  }
46
41
 
47
42
  return launchOptions;
48
43
  });
49
44
  },
50
45
  specPattern,
51
- supportFile: `${mainCypressFolder}/support/component.tsx`,
46
+ supportFile: `${mainCypressFolder}/support/component.tsx`
52
47
  },
53
48
  env: {
54
- baseUrl: "http://localhost:9092",
49
+ baseUrl: 'http://localhost:9092',
55
50
  codeCoverage: {
56
51
  exclude: [
57
- "cypress/**/*.*",
58
- "packages/**",
59
- "node_modules",
60
- "**/*.js",
61
- "**/*.spec.tsx",
62
- ],
52
+ 'cypress/**/*.*',
53
+ 'packages/**',
54
+ 'node_modules',
55
+ '**/*.js',
56
+ '**/*.spec.tsx'
57
+ ]
63
58
  },
64
- ...env,
59
+ ...env
65
60
  },
66
- reporter: "mochawesome",
61
+ reporter: 'mochawesome',
67
62
  reporterOptions: {
68
63
  html: false,
69
64
  json: true,
70
65
  overwrite: true,
71
66
  reportDir: `${mainCypressFolder}/results`,
72
- reportFilename: "[name]-report.json",
67
+ reportFilename: '[name]-report.json'
73
68
  },
74
69
  video: true,
75
70
  videosFolder: `${mainCypressFolder}/results/videos`,
76
71
  viewportHeight: 590,
77
- viewportWidth: 1280,
72
+ viewportWidth: 1280
78
73
  });
79
74
  };
@@ -271,32 +271,11 @@ export default (on: Cypress.PluginEvents): void => {
271
271
  getExportedFile({ downloadsFolder }: { downloadsFolder: string }): string {
272
272
  const files = fs
273
273
  .readdirSync(downloadsFolder)
274
- .filter((name) => name.startsWith("ResourceStatusExport_all"))
275
- .map((name) => {
276
- const match = name.match(
277
- /ResourceStatusExport_all_(\d+)-(\d+)-(\d+)--(\d+)-(\d+)-(AM|PM)/
278
- );
279
- if (!match) return null;
280
-
281
- const [, month, day, year, hourStr, minuteStr, period] = match;
282
- let hour = parseInt(hourStr, 10);
283
- const minute = parseInt(minuteStr, 10);
284
-
285
- if (period === "PM" && hour < 12) hour += 12;
286
- if (period === "AM" && hour === 12) hour = 0;
287
-
288
- const date = new Date(
289
- `20${year}-${month}-${day}T${String(hour).padStart(2, "0")}:${String(
290
- minute
291
- ).padStart(2, "0")}:00`
292
- );
293
-
294
- return {
295
- name,
296
- time: date.getTime(),
297
- };
298
- })
299
- .filter((item): item is { name: string; time: number } => item !== null)
274
+ .filter((name) => name.startsWith("ResourceStatusExport_all") && name.endsWith(".csv"))
275
+ .map((name) => ({
276
+ name,
277
+ time: fs.statSync(path.join(downloadsFolder, name)).mtime.getTime()
278
+ }))
300
279
  .sort((a, b) => b.time - a.time);
301
280
 
302
281
  if (files.length === 0) {
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.6.2",
4
+ "version": "25.6.4",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/centreon/centreon-frontend.git"
@@ -1,36 +0,0 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
-
4
- const filePath = process.argv[2];
5
-
6
- const { error: logError } = console;
7
-
8
- try {
9
- const outFile = fs.readFileSync(path.resolve(filePath)).toString();
10
- const outFileJson = JSON.parse(outFile);
11
-
12
- const coveragesWithoutNodeModules = Object.entries(outFileJson)
13
- .map(([key, value]) => {
14
- if (key.includes('node_modules')) {
15
- return undefined;
16
- }
17
-
18
- return [key, value];
19
- })
20
- .filter((v) => v);
21
-
22
- const finalOutJson = coveragesWithoutNodeModules.reduce(
23
- (acc, [key, value]) => ({
24
- ...acc,
25
- [key]: value
26
- }),
27
- {}
28
- );
29
-
30
- fs.writeFileSync(
31
- path.resolve(filePath),
32
- JSON.stringify(finalOutJson, null, 2)
33
- );
34
- } catch (error) {
35
- logError(error.message);
36
- }