@centreon/js-config 25.10.1 → 25.10.2-dev-25-10-x.0

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.
@@ -19,13 +19,6 @@ interface Containers {
19
19
  [key: string]: StartedTestContainer;
20
20
  }
21
21
 
22
- class NotFoundContainerError extends Error {
23
- constructor(message) {
24
- super(message);
25
- this.name = 'NotFoundContainerError';
26
- }
27
- }
28
-
29
22
  export default (on: Cypress.PluginEvents): void => {
30
23
  let dockerEnvironment: StartedDockerComposeEnvironment | null = null;
31
24
  const containers: Containers = {};
@@ -38,7 +31,7 @@ export default (on: Cypress.PluginEvents): void => {
38
31
  } else if (containers[containerName]) {
39
32
  container = containers[containerName];
40
33
  } else {
41
- throw new NotFoundContainerError(`Cannot get container ${containerName}`);
34
+ throw new Error(`Cannot get container ${containerName}`);
42
35
  }
43
36
 
44
37
  return container;
@@ -61,6 +54,35 @@ export default (on: Cypress.PluginEvents): void => {
61
54
  }
62
55
 
63
56
  on("task", {
57
+ checkDockerImage: async (params: StartContainerProps) => {
58
+ const { image, name } = params;
59
+ console.log(`🔍 [checkDockerImage] Checking if image exists: ${image}`);
60
+
61
+ if (!image) {
62
+ console.error("❌ [checkDockerImage] No image name provided");
63
+ return { exists: false, error: "Image name is undefined" };
64
+ }
65
+
66
+ try {
67
+ execSync(`docker image inspect ${image}`, { stdio: "ignore" });
68
+ console.log(`✅ [checkDockerImage] Image already exists locally: ${image}`);
69
+ return { exists: true, image };
70
+ } catch {
71
+ console.log(`â„šī¸ [checkDockerImage] Image not found locally, trying to pull...`);
72
+
73
+ try {
74
+ execSync(`docker pull ${image}`, { stdio: "pipe" });
75
+ console.log(`✅ [checkDockerImage] Image successfully pulled: ${image}`);
76
+ return { exists: true, image };
77
+ } catch (err: unknown) {
78
+ const errorMessage =
79
+ err instanceof Error ? err.message : JSON.stringify(err);
80
+ console.warn(`âš ī¸ [checkDockerImage] Image not found or pull failed: ${errorMessage}`);
81
+
82
+ return { exists: false, error: errorMessage, image };
83
+ }
84
+ }
85
+ },
64
86
  copyFromContainer: async ({ destination, serviceName, source }) => {
65
87
  try {
66
88
  const container = getContainer(serviceName);
@@ -75,11 +97,7 @@ export default (on: Cypress.PluginEvents): void => {
75
97
  });
76
98
  });
77
99
  } catch (error) {
78
- if (error instanceof NotFoundContainerError) {
79
- console.log(`Cannot get ${source} from container ${serviceName} because it doesn't exist.`);
80
- } else {
81
- console.error(error);
82
- }
100
+ console.error(error);
83
101
  }
84
102
 
85
103
  return null;
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.10.1",
4
+ "version": "25.10.2-dev-25-10-x.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/centreon/centreon-frontend.git"