@centreon/js-config 26.7.8 → 26.7.10
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 +7 -1
- package/cypress/e2e/commands/monitoring.ts +10 -11
- package/cypress/e2e/commands.ts +5 -3
- package/cypress/e2e/tasks.ts +28 -9
- package/package.json +1 -1
- package/rspack/base/index.js +3 -1
- package/rspack/patch/dev.js +0 -1
- package/rspack/patch/devServer.js +2 -4
|
@@ -63,8 +63,14 @@ module.exports = ({
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
// Save the testRetries object to a file in the e2e/results directory
|
|
66
|
+
const projectRoot = path.resolve(process.cwd());
|
|
67
|
+
const resolvedFolder = path.resolve(mainCypressFolder);
|
|
68
|
+
if (resolvedFolder !== projectRoot && !resolvedFolder.startsWith(projectRoot + path.sep)) {
|
|
69
|
+
throw new Error('mainCypressFolder is outside of the project directory');
|
|
70
|
+
}
|
|
71
|
+
|
|
66
72
|
const resultFilePath = path.join(
|
|
67
|
-
|
|
73
|
+
resolvedFolder,
|
|
68
74
|
'results',
|
|
69
75
|
'retries.json'
|
|
70
76
|
);
|
|
@@ -32,12 +32,11 @@ Cypress.Commands.add(
|
|
|
32
32
|
host,
|
|
33
33
|
isForced = true
|
|
34
34
|
}: ServiceCheck): Cypress.Chainable => {
|
|
35
|
-
let query = `SELECT id FROM resources WHERE name = '${host}' AND type = 1`;
|
|
36
|
-
|
|
37
35
|
return cy
|
|
38
36
|
.requestOnDatabase({
|
|
39
37
|
database: 'centreon_storage',
|
|
40
|
-
query
|
|
38
|
+
query: 'SELECT id FROM resources WHERE name = ? AND type = 1',
|
|
39
|
+
params: [host]
|
|
41
40
|
})
|
|
42
41
|
.then(([rows]) => {
|
|
43
42
|
if (rows.length === 0) {
|
|
@@ -84,12 +83,11 @@ Cypress.Commands.add(
|
|
|
84
83
|
isForced = true,
|
|
85
84
|
service
|
|
86
85
|
}: ServiceCheck): Cypress.Chainable => {
|
|
87
|
-
let query = `SELECT parent_id, id FROM resources WHERE parent_name = '${host}' AND name = '${service}'`;
|
|
88
|
-
|
|
89
86
|
return cy
|
|
90
87
|
.requestOnDatabase({
|
|
91
88
|
database: 'centreon_storage',
|
|
92
|
-
query
|
|
89
|
+
query: 'SELECT parent_id, id FROM resources WHERE parent_name = ? AND name = ?',
|
|
90
|
+
params: [host, service]
|
|
93
91
|
})
|
|
94
92
|
.then(([rows]) => {
|
|
95
93
|
if (rows.length === 0) {
|
|
@@ -181,22 +179,23 @@ Cypress.Commands.add(
|
|
|
181
179
|
cy.log('Checking hosts in database');
|
|
182
180
|
|
|
183
181
|
let query = `SELECT COUNT(d.downtime_id) AS count_downtimes FROM downtimes as d
|
|
184
|
-
INNER JOIN hosts as h ON h.host_id = d.host_id AND h.name =
|
|
182
|
+
INNER JOIN hosts as h ON h.host_id = d.host_id AND h.name = ?`;
|
|
183
|
+
const params: Array<string> = [downtime.host];
|
|
185
184
|
if (downtime.service) {
|
|
186
|
-
query += ` INNER JOIN services as s ON s.service_id = d.service_id AND s.description =
|
|
185
|
+
query += ` INNER JOIN services as s ON s.service_id = d.service_id AND s.description = ?`;
|
|
186
|
+
params.push(downtime.service);
|
|
187
187
|
}
|
|
188
188
|
query += ` WHERE d.started=1`;
|
|
189
189
|
if (!downtime.service) {
|
|
190
190
|
query += ` AND d.service_id = 0`;
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
-
cy.log(query);
|
|
194
|
-
|
|
195
193
|
cy.waitUntil(() => {
|
|
196
194
|
return cy
|
|
197
195
|
.requestOnDatabase({
|
|
198
196
|
database: 'centreon_storage',
|
|
199
|
-
query
|
|
197
|
+
query,
|
|
198
|
+
params
|
|
200
199
|
})
|
|
201
200
|
.then(([rows]) => {
|
|
202
201
|
const foundDowntimesCount = rows.length ? rows[0].count_downtimes : 0;
|
package/cypress/e2e/commands.ts
CHANGED
|
@@ -459,13 +459,14 @@ Output:\n${displayedOutput}`);
|
|
|
459
459
|
|
|
460
460
|
interface RequestOnDatabaseProps {
|
|
461
461
|
database: string;
|
|
462
|
+
params?: Array<string | number>;
|
|
462
463
|
query: string;
|
|
463
464
|
}
|
|
464
465
|
|
|
465
466
|
Cypress.Commands.add(
|
|
466
467
|
'requestOnDatabase',
|
|
467
|
-
({ database, query }: RequestOnDatabaseProps): Cypress.Chainable => {
|
|
468
|
-
return cy.task('requestOnDatabase', { database, query });
|
|
468
|
+
({ database, query, params }: RequestOnDatabaseProps): Cypress.Chainable => {
|
|
469
|
+
return cy.task('requestOnDatabase', { database, query, params });
|
|
469
470
|
}
|
|
470
471
|
);
|
|
471
472
|
|
|
@@ -1046,7 +1047,8 @@ declare global {
|
|
|
1046
1047
|
}: NavigateToProps) => Cypress.Chainable;
|
|
1047
1048
|
requestOnDatabase: ({
|
|
1048
1049
|
database,
|
|
1049
|
-
query
|
|
1050
|
+
query,
|
|
1051
|
+
params
|
|
1050
1052
|
}: RequestOnDatabaseProps) => Cypress.Chainable;
|
|
1051
1053
|
setUserTokenApiV1: ({
|
|
1052
1054
|
login,
|
package/cypress/e2e/tasks.ts
CHANGED
|
@@ -155,7 +155,7 @@ export default (on: Cypress.PluginEvents): void => {
|
|
|
155
155
|
|
|
156
156
|
return container.getMappedPort(containerPort);
|
|
157
157
|
},
|
|
158
|
-
requestOnDatabase: async ({ database, query }) => {
|
|
158
|
+
requestOnDatabase: async ({ database, query, params }) => {
|
|
159
159
|
let container: StartedTestContainer | null = null;
|
|
160
160
|
|
|
161
161
|
if (dockerEnvironment !== null) {
|
|
@@ -172,11 +172,15 @@ export default (on: Cypress.PluginEvents): void => {
|
|
|
172
172
|
user: "centreon",
|
|
173
173
|
});
|
|
174
174
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
175
|
+
try {
|
|
176
|
+
const [rows, fields] = params
|
|
177
|
+
? await client.execute(query, params)
|
|
178
|
+
: await client.query(query);
|
|
178
179
|
|
|
179
|
-
|
|
180
|
+
return [rows, fields];
|
|
181
|
+
} finally {
|
|
182
|
+
await client.end();
|
|
183
|
+
}
|
|
180
184
|
},
|
|
181
185
|
startContainer: async ({
|
|
182
186
|
command,
|
|
@@ -308,21 +312,36 @@ export default (on: Cypress.PluginEvents): void => {
|
|
|
308
312
|
return path.join(downloadsFolder, files[0].name);
|
|
309
313
|
},
|
|
310
314
|
readCsvFile({ filePath }: { filePath: string }): Promise<string> {
|
|
315
|
+
const projectRoot = path.resolve(process.cwd());
|
|
316
|
+
const resolvedPath = path.resolve(filePath);
|
|
317
|
+
if (resolvedPath !== projectRoot && !resolvedPath.startsWith(projectRoot + path.sep)) {
|
|
318
|
+
return Promise.reject(new Error("Path is outside of the project directory"));
|
|
319
|
+
}
|
|
320
|
+
|
|
311
321
|
return new Promise((resolve, reject) => {
|
|
312
|
-
fs.readFile(
|
|
322
|
+
fs.readFile(resolvedPath, "utf8", (err, data) => {
|
|
313
323
|
if (err) return reject(err);
|
|
314
324
|
resolve(data);
|
|
315
325
|
});
|
|
316
326
|
});
|
|
317
327
|
},
|
|
318
328
|
clearDownloadsFolder({ downloadsFolder }: { downloadsFolder: string }): null {
|
|
319
|
-
|
|
329
|
+
const projectRoot = path.resolve(process.cwd());
|
|
330
|
+
const resolvedFolder = path.resolve(downloadsFolder);
|
|
331
|
+
if (resolvedFolder !== projectRoot && !resolvedFolder.startsWith(projectRoot + path.sep)) {
|
|
332
|
+
throw new Error("Path is outside of the project directory");
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
if (!fs.existsSync(resolvedFolder)) {
|
|
320
336
|
return null;
|
|
321
337
|
}
|
|
322
338
|
|
|
323
|
-
const files = fs.readdirSync(
|
|
339
|
+
const files = fs.readdirSync(resolvedFolder);
|
|
324
340
|
for (const file of files) {
|
|
325
|
-
const filePath = path.join(
|
|
341
|
+
const filePath = path.join(resolvedFolder, file);
|
|
342
|
+
if (!filePath.startsWith(resolvedFolder + path.sep)) {
|
|
343
|
+
continue;
|
|
344
|
+
}
|
|
326
345
|
fs.unlinkSync(filePath);
|
|
327
346
|
}
|
|
328
347
|
|
package/package.json
CHANGED
package/rspack/base/index.js
CHANGED
|
@@ -42,11 +42,13 @@ const getBaseConfiguration = ({
|
|
|
42
42
|
library: moduleName,
|
|
43
43
|
uniqueName: moduleName
|
|
44
44
|
},
|
|
45
|
+
experiments: {
|
|
46
|
+
css: true
|
|
47
|
+
},
|
|
45
48
|
plugins: [
|
|
46
49
|
moduleName &&
|
|
47
50
|
new rspack.container.ModuleFederationPlugin({
|
|
48
51
|
filename: 'remoteEntry.[chunkhash:8].js',
|
|
49
|
-
injectTreeShakingUsedExports: false,
|
|
50
52
|
library: { name: moduleName, type: 'umd' },
|
|
51
53
|
name: moduleName,
|
|
52
54
|
shared: [
|
package/rspack/patch/dev.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const os = require('os');
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const ReactRefreshPlugin = require('@rspack/plugin-react-refresh');
|
|
4
4
|
|
|
5
5
|
const devServerPort = 9090;
|
|
6
6
|
|
|
@@ -19,9 +19,7 @@ const publicPath = `http://${devServerAddress}:${devServerPort}/static/`;
|
|
|
19
19
|
|
|
20
20
|
const isDevelopmentMode = process.env.NODE_ENV !== 'production';
|
|
21
21
|
|
|
22
|
-
const devServerPlugins = isDevelopmentMode
|
|
23
|
-
? [new ReactRefreshRspackPlugin()]
|
|
24
|
-
: [];
|
|
22
|
+
const devServerPlugins = isDevelopmentMode ? [new ReactRefreshPlugin()] : [];
|
|
25
23
|
|
|
26
24
|
module.exports = {
|
|
27
25
|
devServer: {
|