@centreon/js-config 25.5.1 → 25.6.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.
@@ -268,5 +268,74 @@ export default (on: Cypress.PluginEvents): void => {
268
268
  fileExists: async ( filePath ) => {
269
269
  return fs.existsSync(filePath);
270
270
  },
271
+ getExportedFile({ downloadsFolder }: { downloadsFolder: string }): string {
272
+ const files = fs
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)
300
+ .sort((a, b) => b.time - a.time);
301
+
302
+ if (files.length === 0) {
303
+ throw new Error("No exported file found");
304
+ }
305
+
306
+ return path.join(downloadsFolder, files[0].name);
307
+ },
308
+ readCsvFile({ filePath }: { filePath: string }): Promise<string> {
309
+ return new Promise((resolve, reject) => {
310
+ fs.readFile(filePath, "utf8", (err, data) => {
311
+ if (err) return reject(err);
312
+ resolve(data);
313
+ });
314
+ });
315
+ },
316
+ clearDownloadsFolder({ downloadsFolder }: { downloadsFolder: string }): null {
317
+ if (!fs.existsSync(downloadsFolder)) {
318
+ return null;
319
+ }
320
+
321
+ const files = fs.readdirSync(downloadsFolder);
322
+ for (const file of files) {
323
+ const filePath = path.join(downloadsFolder, file);
324
+ fs.unlinkSync(filePath);
325
+ }
326
+
327
+ return null;
328
+ },
329
+ isDownloadComplete({ downloadsFolder }: { downloadsFolder: string }): boolean {
330
+ if (!fs.existsSync(downloadsFolder)) return false;
331
+
332
+ const files = fs
333
+ .readdirSync(downloadsFolder)
334
+ .filter(
335
+ (name) => !name.endsWith(".crdownload") && !name.endsWith(".tmp")
336
+ );
337
+
338
+ return files.length > 0;
339
+ },
271
340
  });
272
341
  };
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.5.1",
4
+ "version": "25.6.1",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/centreon/centreon-frontend.git"
@@ -6,7 +6,7 @@ const excludeNodeModulesExceptCentreonUi =
6
6
  module.exports = {
7
7
  cache: false,
8
8
  excludeNodeModulesExceptCentreonUi,
9
- getModuleConfiguration: (enableCoverage) => ({
9
+ getModuleConfiguration: (enableCoverage, postCssBase = './') => ({
10
10
  rules: [
11
11
  {
12
12
  exclude: [excludeNodeModulesExceptCentreonUi],
@@ -51,8 +51,22 @@ module.exports = {
51
51
  type: 'asset/resource'
52
52
  },
53
53
  {
54
- test: /\.css$/i,
55
- use: ['style-loader', 'css-loader']
54
+ test: /\.css$/,
55
+ type: 'css/auto',
56
+ use: [
57
+ {
58
+ loader: 'postcss-loader',
59
+ options: {
60
+ postcssOptions: {
61
+ plugins: {
62
+ '@tailwindcss/postcss': {
63
+ base: postCssBase
64
+ }
65
+ }
66
+ }
67
+ }
68
+ }
69
+ ]
56
70
  }
57
71
  ]
58
72
  }),
@@ -12,10 +12,11 @@ const {
12
12
  const getBaseConfiguration = ({
13
13
  moduleName,
14
14
  moduleFederationConfig,
15
- enableCoverage
15
+ enableCoverage,
16
+ postCssBase
16
17
  }) => ({
17
18
  cache,
18
- module: getModuleConfiguration(enableCoverage),
19
+ module: getModuleConfiguration(enableCoverage, postCssBase),
19
20
  optimization,
20
21
  output: {
21
22
  ...output,
@@ -23,51 +24,55 @@ const getBaseConfiguration = ({
23
24
  library: moduleName,
24
25
  uniqueName: moduleName
25
26
  },
27
+ experiments: {
28
+ css: true
29
+ },
26
30
  plugins: [
27
31
  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: '19.x',
53
- singleton: true
54
- }
55
- },
56
- {
57
- 'react-i18next': {
58
- requiredVersion: '15.x',
59
- singleton: true
60
- }
61
- },
62
- {
63
- 'react-router': {
64
- requiredVersion: '7.x',
65
- singleton: true
66
- }
32
+ new rspack.container.ModuleFederationPlugin({
33
+ filename: 'remoteEntry.[chunkhash:8].js',
34
+ library: { name: moduleName, type: 'umd' },
35
+ name: moduleName,
36
+ shared: [
37
+ {
38
+ '@centreon/ui-context': {
39
+ requiredVersion: '1.x',
40
+ singleton: true
41
+ }
42
+ },
43
+ {
44
+ jotai: {
45
+ requiredVersion: '2.x',
46
+ singleton: true
47
+ }
48
+ },
49
+ {
50
+ 'jotai-suspense': {
51
+ singleton: true
52
+ }
53
+ },
54
+ {
55
+ react: {
56
+ requiredVersion: '19.x',
57
+ singleton: true
58
+ }
59
+ },
60
+ {
61
+ 'react-i18next': {
62
+ requiredVersion: '15.x',
63
+ singleton: true
64
+ }
65
+ },
66
+ {
67
+ 'react-router': {
68
+ requiredVersion: '7.x',
69
+ singleton: true
67
70
  }
68
- ],
69
- ...moduleFederationConfig
70
- })
71
+ },
72
+ { tailwindcss: { singleton: true, requiredVersion: '4.x' } }
73
+ ],
74
+ ...moduleFederationConfig
75
+ })
71
76
  ].filter(Boolean),
72
77
  resolve: {
73
78
  alias: {