@centreon/js-config 24.8.2 → 24.9.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.
Files changed (33) hide show
  1. package/cypress/component/commands.tsx +22 -82
  2. package/cypress/component/configuration.js +16 -39
  3. package/cypress/component/enableVisualTesting.ts +1 -1
  4. package/cypress/e2e/commands/configuration.ts +1 -330
  5. package/cypress/e2e/commands.ts +149 -629
  6. package/cypress/e2e/configuration.ts +40 -46
  7. package/cypress/e2e/plugins.ts +114 -52
  8. package/eslint/base.typescript.eslintrc.js +3 -15
  9. package/jest/index.js +2 -5
  10. package/package.json +45 -57
  11. package/tsconfig/index.json +4 -5
  12. package/webpack/base/index.js +130 -0
  13. package/webpack/patch/dev.js +24 -0
  14. package/{rspack → webpack}/patch/devServer.js +5 -3
  15. package/webpack/patch/module.js +46 -0
  16. package/biome/base.json +0 -224
  17. package/cypress/component/disableCssTransitions.ts +0 -19
  18. package/cypress/component/excludeNodeModulesFromCoverage.js +0 -36
  19. package/cypress/e2e/commands/monitoring.ts +0 -117
  20. package/cypress/e2e/esbuild-preprocessor.ts +0 -26
  21. package/cypress/e2e/reporter-config.js +0 -13
  22. package/cypress/e2e/tasks.ts +0 -259
  23. package/eslint/lambda/typescript.eslintrc.js +0 -48
  24. package/jest/lambda/typescript.js +0 -49
  25. package/rspack/base/globalConfig.js +0 -71
  26. package/rspack/base/index.js +0 -89
  27. package/rspack/patch/dev.js +0 -12
  28. package/rspack/patch/module.js +0 -13
  29. package/rspack/plugins/TransformPreloadScript.js +0 -37
  30. package/rspack/plugins/WriteRemoteEntryNameToModuleFederation.js +0 -30
  31. package/tsconfig/lambda/node20.tsconfig.json +0 -12
  32. package/tsconfig/lambda/tsconfig.json +0 -14
  33. package/tsconfig.json +0 -21
@@ -0,0 +1,46 @@
1
+ const fs = require('fs');
2
+ const { CleanWebpackPlugin } = require('clean-webpack-plugin');
3
+
4
+ class CentreonModulePlugin {
5
+ constructor(federatedComponentConfiguration) {
6
+ this.federatedComponentConfiguration = federatedComponentConfiguration;
7
+ }
8
+
9
+ apply(compiler) {
10
+ compiler.hooks.done.tap('CentreonModulePlugin', (stats) => {
11
+ const newFederatedComponentConfiguration = {
12
+ ...this.federatedComponentConfiguration,
13
+ remoteEntry: Object.keys(stats.compilation.assets).find((assetName) =>
14
+ assetName.match(/(^remoteEntry)\S+.js$/),
15
+ ),
16
+ };
17
+
18
+ if (!fs.existsSync(compiler.options.output.path)) {
19
+ fs.mkdirSync(compiler.options.output.path, { recursive: true });
20
+ }
21
+
22
+ fs.writeFileSync(
23
+ `${compiler.options.output.path}/moduleFederation.json`,
24
+ JSON.stringify(newFederatedComponentConfiguration, null, 2),
25
+ );
26
+ });
27
+ }
28
+ }
29
+
30
+ module.exports = ({
31
+ outputPath,
32
+ federatedComponentConfiguration,
33
+ }) => ({
34
+ output: {
35
+ library: '[chunkhash:8]',
36
+ path: outputPath,
37
+ },
38
+ plugins: [
39
+ new CleanWebpackPlugin({
40
+ cleanOnceBeforeBuildPatterns: [`${outputPath}/**/*.js`],
41
+ dangerouslyAllowCleanPatternsOutsideProject: true,
42
+ dry: false,
43
+ }),
44
+ new CentreonModulePlugin(federatedComponentConfiguration),
45
+ ],
46
+ });
package/biome/base.json DELETED
@@ -1,224 +0,0 @@
1
- {
2
- "formatter": {
3
- "enabled": true,
4
- "indentStyle": "space",
5
- "formatWithErrors": false
6
- },
7
- "organizeImports": {
8
- "enabled": true
9
- },
10
- "linter": {
11
- "enabled": true,
12
- "rules": {
13
- "recommended": true,
14
- "a11y": {
15
- "noSvgWithoutTitle": "off"
16
- },
17
- "complexity": {
18
- "noBannedTypes": "off",
19
- "noForEach": "off"
20
- },
21
- "correctness": {
22
- "noUnusedImports": "error",
23
- "noUnusedVariables": "error",
24
- "useExhaustiveDependencies": "off"
25
- },
26
- "nursery": {
27
- "noConsole": "error",
28
- "noRestrictedImports": {
29
- "level": "error",
30
- "options": {
31
- "paths": {
32
- "lodash": "Using lodash is not encouraged.",
33
- "moment": "Using moment is not encouraged."
34
- }
35
- }
36
- },
37
- "noUnknownFunction": "error",
38
- "noUnknownProperty": "error",
39
- "noUnknownUnit": "error"
40
- },
41
- "suspicious": {
42
- "useAwait": "error"
43
- },
44
- "performance": {
45
- "noAccumulatingSpread": "off"
46
- },
47
- "style": {
48
- "useLiteralEnumMembers": "off",
49
- "useImportType": "off",
50
- "noNamespace": "error",
51
- "noNamespaceImport": "error",
52
- "useFragmentSyntax": "error",
53
- "useFilenamingConvention": {
54
- "level": "error",
55
- "options": {
56
- "strictCase": false,
57
- "filenameCases": [
58
- "camelCase",
59
- "PascalCase",
60
- "kebab-case"
61
- ]
62
- }
63
- },
64
- "useNamingConvention": {
65
- "level": "error",
66
- "options": {
67
- "strictCase": false,
68
- "conventions": [
69
- {
70
- "formats": [
71
- "camelCase",
72
- "PascalCase"
73
- ],
74
- "selector": {
75
- "kind": "variable"
76
- }
77
- },
78
- {
79
- "selector": {
80
- "kind": "interface"
81
- },
82
- "formats": [
83
- "PascalCase"
84
- ]
85
- },
86
- {
87
- "selector": {
88
- "kind": "enum"
89
- },
90
- "formats": [
91
- "PascalCase"
92
- ]
93
- },
94
- {
95
- "selector": {
96
- "kind": "objectLiteralProperty"
97
- },
98
- "match": ".*"
99
- },
100
- {
101
- "match": "_(.*)|([a-zA-Z].*)",
102
- "selector": {
103
- "kind": "functionParameter"
104
- },
105
- "formats": [
106
- "snake_case",
107
- "PascalCase",
108
- "camelCase"
109
- ]
110
- },
111
- {
112
- "match": ".*",
113
- "formats": [
114
- "snake_case",
115
- "camelCase",
116
- "PascalCase",
117
- "CONSTANT_CASE"
118
- ]
119
- }
120
- ]
121
- }
122
- },
123
- "noRestrictedGlobals": {
124
- "level": "error",
125
- "options": {
126
- "deniedGlobals": [
127
- "isFinite",
128
- "isNaN",
129
- "addEventListener",
130
- "blur",
131
- "close",
132
- "closed",
133
- "confirm",
134
- "defaultStatus",
135
- "defaultstatus",
136
- "event",
137
- "external",
138
- "find",
139
- "focus",
140
- "frameElement",
141
- "frames",
142
- "history",
143
- "innerHeight",
144
- "innerWidth",
145
- "length",
146
- "location",
147
- "locationbar",
148
- "menubar",
149
- "moveBy",
150
- "moveTo",
151
- "name",
152
- "onblur",
153
- "onerror",
154
- "onfocus",
155
- "onload",
156
- "onresize",
157
- "onunload",
158
- "open",
159
- "opener",
160
- "opera",
161
- "outerHeight",
162
- "outerWidth",
163
- "pageXOffset",
164
- "pageYOffset",
165
- "parent",
166
- "print",
167
- "removeEventListener",
168
- "resizeBy",
169
- "resizeTo",
170
- "screen",
171
- "screenLeft",
172
- "screenTop",
173
- "screenX",
174
- "screenY",
175
- "scroll",
176
- "scrollbars",
177
- "scrollBy",
178
- "scrollTo",
179
- "scrollX",
180
- "scrollY",
181
- "self",
182
- "status",
183
- "statusbar",
184
- "stop",
185
- "toolbar",
186
- "top"
187
- ]
188
- }
189
- }
190
- }
191
- }
192
- },
193
- "javascript": {
194
- "formatter": {
195
- "enabled": true,
196
- "quoteStyle": "single",
197
- "semicolons": "always",
198
- "indentStyle": "space",
199
- "trailingCommas": "none"
200
- },
201
- "linter": {
202
- "enabled": true
203
- }
204
- },
205
- "json": {
206
- "parser": {
207
- "allowComments": true,
208
- "allowTrailingCommas": false
209
- },
210
- "formatter": {
211
- "enabled": true,
212
- "indentStyle": "space"
213
- }
214
- },
215
- "css": {
216
- "formatter": {
217
- "enabled": true,
218
- "indentStyle": "space"
219
- },
220
- "linter": {
221
- "enabled": true
222
- }
223
- }
224
- }
@@ -1,19 +0,0 @@
1
- const disableMotion = (win): void => {
2
- const injectedStyleEl = win.document.getElementById('__cy_disable_motion__');
3
- if (injectedStyleEl) {
4
- return;
5
- }
6
- win.document.head.insertAdjacentHTML(
7
- 'beforeend',
8
- `
9
- <style id="__cy_disable_motion__">
10
- /* Disable CSS transitions. */
11
- *, *::before, *::after { -webkit-transition: none !important; -moz-transition: none !important; -o-transition: none !important; -ms-transition: none !important; transition: none !important; }
12
- /* Disable CSS animations. */
13
- *, *::before, *::after { -webkit-animation: none !important; -moz-animation: none !important; -o-animation: none !important; -ms-animation: none !important; animation: none !important; }
14
- </style>
15
- `.trim()
16
- );
17
- };
18
-
19
- export default disableMotion;
@@ -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
- }
@@ -1,117 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-namespace */
2
-
3
- const apiBase = '/centreon/api';
4
- const apiActionV1 = `${apiBase}/index.php`;
5
-
6
- const getStatusNumberFromString = (status: string): number => {
7
- const statuses = {
8
- critical: '2',
9
- down: '1',
10
- ok: '0',
11
- unknown: '3',
12
- unreachable: '2',
13
- up: '0',
14
- warning: '1'
15
- };
16
-
17
- if (status in statuses) {
18
- return statuses[status];
19
- }
20
-
21
- throw new Error(`Status ${status} does not exist`);
22
- };
23
-
24
- interface SubmitResult {
25
- host: string;
26
- output: string;
27
- perfdata?: string | null;
28
- service?: string | null;
29
- status: string;
30
- }
31
-
32
- Cypress.Commands.add(
33
- 'submitResults',
34
- (results: Array<SubmitResult>): Cypress.Chainable => {
35
- results.forEach(
36
- ({ host, output, perfdata = '', service = null, status }) => {
37
- const timestampNow = Math.floor(Date.now() / 1000) - 15;
38
- const updatetime = timestampNow.toString();
39
-
40
- const result = {
41
- host,
42
- output,
43
- perfdata,
44
- service,
45
- status: getStatusNumberFromString(status),
46
- updatetime
47
- };
48
-
49
- cy.request({
50
- body: {
51
- results: [result]
52
- },
53
- headers: {
54
- 'Content-Type': 'application/json',
55
- 'centreon-auth-token': window.localStorage.getItem('userTokenApiV1')
56
- },
57
- method: 'POST',
58
- url: `${apiActionV1}?action=submit&object=centreon_submit_results`
59
- });
60
- }
61
- );
62
-
63
- return cy.wrap(null);
64
- }
65
- );
66
-
67
- interface Downtime {
68
- host: string;
69
- service?: string | null;
70
- }
71
-
72
- Cypress.Commands.add(
73
- 'waitForDowntime',
74
- (downtime: Downtime): Cypress.Chainable => {
75
- cy.log('Checking hosts in database');
76
-
77
- let query = `SELECT COUNT(d.downtime_id) AS count_downtimes FROM downtimes as d
78
- INNER JOIN hosts as h ON h.host_id = d.host_id AND h.name = '${downtime.host}'`;
79
- if (downtime.service) {
80
- query += ` INNER JOIN services as s ON s.service_id = d.service_id AND s.description = '${downtime.service}'`;
81
- }
82
- query += ` WHERE d.started=1`;
83
- if (!downtime.service) {
84
- query += ` AND d.service_id = 0`;
85
- }
86
-
87
- cy.log(query);
88
-
89
- cy.waitUntil(() => {
90
- return cy
91
- .requestOnDatabase({
92
- database: 'centreon_storage',
93
- query
94
- })
95
- .then(([rows]) => {
96
- const foundDowntimesCount = rows.length ? rows[0].count_downtimes : 0;
97
-
98
- cy.log('Downtime count in database', foundDowntimesCount);
99
-
100
- return cy.wrap(foundDowntimesCount > 0);
101
- });
102
- });
103
-
104
- return cy.wrap(null);
105
- }
106
- );
107
-
108
- declare global {
109
- namespace Cypress {
110
- interface Chainable {
111
- submitResults: (props: Array<SubmitResult>) => Cypress.Chainable;
112
- waitForDowntime: (downtime: Downtime) => Cypress.Chainable;
113
- }
114
- }
115
- }
116
-
117
- export {};
@@ -1,26 +0,0 @@
1
- import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill';
2
- import { NodeModulesPolyfillPlugin } from '@esbuild-plugins/node-modules-polyfill';
3
- import { addCucumberPreprocessorPlugin } from '@badeball/cypress-cucumber-preprocessor';
4
- import createBundler from '@bahmutov/cypress-esbuild-preprocessor';
5
- import createEsbuildPlugin from '@badeball/cypress-cucumber-preprocessor/esbuild';
6
-
7
- export default async (
8
- on: Cypress.PluginEvents,
9
- config: Cypress.PluginConfigOptions
10
- ): Promise<void> => {
11
- await addCucumberPreprocessorPlugin(on, config);
12
-
13
- on(
14
- 'file:preprocessor',
15
- createBundler({
16
- plugins: [
17
- createEsbuildPlugin(config),
18
- NodeModulesPolyfillPlugin(),
19
- NodeGlobalsPolyfillPlugin({
20
- buffer: true,
21
- process: true
22
- })
23
- ]
24
- })
25
- );
26
- };
@@ -1,13 +0,0 @@
1
- module.exports = {
2
- mochawesomeReporterOptions: {
3
- consoleReporter: 'none',
4
- html: false,
5
- json: true,
6
- overwrite: true,
7
- reportDir: 'results/reports',
8
- reportFilename: '[name]-report.json'
9
- },
10
- reporterEnabled: `mochawesome,${require.resolve(
11
- '@badeball/cypress-cucumber-preprocessor/pretty-reporter'
12
- )}`
13
- };