cdd-cli 3.1.3 → 3.1.5

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 (138) hide show
  1. package/.eslintrc.json +30 -0
  2. package/.github/workflows/docs.yml +35 -0
  3. package/CHANGELOG.md +44 -4
  4. package/FIXES_APPLIED.md +145 -147
  5. package/README.md +26 -0
  6. package/dist/App.js +20 -3
  7. package/dist/components/ContainerCreationPrompt.js +27 -1
  8. package/dist/components/ContainerList.js +11 -15
  9. package/dist/components/ContainerRow.js +73 -14
  10. package/dist/components/ContainerSection.js +16 -2
  11. package/dist/components/Footer.js +7 -1
  12. package/dist/components/Header.js +17 -1
  13. package/dist/components/LogViewer.js +21 -3
  14. package/dist/components/MessageFeedback.js +15 -1
  15. package/dist/components/PromptField.js +31 -1
  16. package/dist/components/StatsBar.js +46 -8
  17. package/dist/components/UsageMenu.js +30 -1
  18. package/dist/helpers/actionHelpers.js +17 -6
  19. package/dist/helpers/constants.js +30 -0
  20. package/dist/helpers/dockerService/dockerService.js +19 -0
  21. package/dist/helpers/dockerService/serviceComponents/containerActions.js +194 -35
  22. package/dist/helpers/dockerService/serviceComponents/containerList.js +45 -8
  23. package/dist/helpers/dockerService/serviceComponents/containerLogs.js +16 -6
  24. package/dist/helpers/dockerService/serviceComponents/containerStats.js +28 -9
  25. package/dist/helpers/exitWithMessage.js +2 -1
  26. package/dist/helpers/logger.js +112 -0
  27. package/dist/helpers/safeCall.js +21 -0
  28. package/dist/helpers/validationHelpers.js +20 -1
  29. package/dist/hooks/creation/useContainerActions.js +2 -1
  30. package/dist/hooks/creation/useContainerCreation.js +5 -4
  31. package/dist/hooks/creation/useLogsViewer.js +3 -2
  32. package/dist/hooks/useContainers.js +6 -3
  33. package/dist/hooks/useControls.js +253 -122
  34. package/dist/hooks/useLogsStream.js +3 -2
  35. package/dist/index.js +1 -0
  36. package/docs/components_ContainerCreationPrompt.jsx.html +114 -0
  37. package/docs/components_ContainerRow.jsx.html +151 -0
  38. package/docs/components_ContainerSection.jsx.html +75 -0
  39. package/docs/components_Footer.jsx.html +66 -0
  40. package/docs/components_Header.jsx.html +84 -0
  41. package/docs/components_LogViewer.jsx.html +91 -0
  42. package/docs/components_MessageFeedback.jsx.html +76 -0
  43. package/docs/components_PromptField.jsx.html +99 -0
  44. package/docs/components_StatsBar.jsx.html +105 -0
  45. package/docs/components_UsageMenu.jsx.html +73 -0
  46. package/docs/fonts/OpenSans-Bold-webfont.eot +0 -0
  47. package/docs/fonts/OpenSans-Bold-webfont.svg +1830 -0
  48. package/docs/fonts/OpenSans-Bold-webfont.woff +0 -0
  49. package/docs/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
  50. package/docs/fonts/OpenSans-BoldItalic-webfont.svg +1830 -0
  51. package/docs/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
  52. package/docs/fonts/OpenSans-Italic-webfont.eot +0 -0
  53. package/docs/fonts/OpenSans-Italic-webfont.svg +1830 -0
  54. package/docs/fonts/OpenSans-Italic-webfont.woff +0 -0
  55. package/docs/fonts/OpenSans-Light-webfont.eot +0 -0
  56. package/docs/fonts/OpenSans-Light-webfont.svg +1831 -0
  57. package/docs/fonts/OpenSans-Light-webfont.woff +0 -0
  58. package/docs/fonts/OpenSans-LightItalic-webfont.eot +0 -0
  59. package/docs/fonts/OpenSans-LightItalic-webfont.svg +1835 -0
  60. package/docs/fonts/OpenSans-LightItalic-webfont.woff +0 -0
  61. package/docs/fonts/OpenSans-Regular-webfont.eot +0 -0
  62. package/docs/fonts/OpenSans-Regular-webfont.svg +1831 -0
  63. package/docs/fonts/OpenSans-Regular-webfont.woff +0 -0
  64. package/docs/global.html +6145 -0
  65. package/docs/helpers_actionHelpers.js.html +94 -0
  66. package/docs/helpers_constants.js.html +81 -0
  67. package/docs/helpers_dockerService_dockerService.js.html +79 -0
  68. package/docs/helpers_dockerService_serviceComponents_containerActions.js.html +153 -0
  69. package/docs/helpers_dockerService_serviceComponents_containerList.js.html +81 -0
  70. package/docs/helpers_dockerService_serviceComponents_containerLogs.js.html +85 -0
  71. package/docs/helpers_dockerService_serviceComponents_containerStats.js.html +107 -0
  72. package/docs/helpers_dockerService_serviceComponents_imageUtils.js.html +82 -0
  73. package/docs/helpers_exitWithMessage.js.html +77 -0
  74. package/docs/helpers_safeCall.js.html +68 -0
  75. package/docs/helpers_validationHelpers.js.html +96 -0
  76. package/docs/hooks_creation_useContainerActions.js.html +120 -0
  77. package/docs/hooks_creation_useContainerCreation.js.html +152 -0
  78. package/docs/hooks_creation_useLogsViewer.js.html +102 -0
  79. package/docs/hooks_useControls.js.html +298 -0
  80. package/docs/hooks_useLogsStream.js.html +82 -0
  81. package/docs/index.html +65 -0
  82. package/docs/index.js.html +65 -0
  83. package/docs/module-index.html +171 -0
  84. package/docs/scripts/linenumber.js +25 -0
  85. package/docs/scripts/prettify/Apache-License-2.0.txt +202 -0
  86. package/docs/scripts/prettify/lang-css.js +2 -0
  87. package/docs/scripts/prettify/prettify.js +28 -0
  88. package/docs/styles/jsdoc-default.css +358 -0
  89. package/docs/styles/prettify-jsdoc.css +111 -0
  90. package/docs/styles/prettify-tomorrow.css +132 -0
  91. package/fix-imports.cjs +33 -6
  92. package/jest.config.cjs +2 -1
  93. package/package.json +19 -9
  94. package/src/App.jsx +16 -2
  95. package/src/components/ContainerCreationPrompt.jsx +26 -0
  96. package/src/components/ContainerList.jsx +12 -13
  97. package/src/components/ContainerRow.jsx +55 -20
  98. package/src/components/ContainerSection.jsx +15 -1
  99. package/src/components/Footer.jsx +6 -1
  100. package/src/components/Header.jsx +16 -0
  101. package/src/components/LogViewer.jsx +19 -2
  102. package/src/components/MessageFeedback.jsx +14 -0
  103. package/src/components/PromptField.jsx +30 -0
  104. package/src/components/StatsBar.jsx +47 -8
  105. package/src/components/UsageMenu.jsx +38 -8
  106. package/src/helpers/actionHelpers.js +16 -7
  107. package/src/helpers/constants.js +30 -0
  108. package/src/helpers/dockerService/dockerService.js +19 -0
  109. package/src/helpers/dockerService/serviceComponents/containerActions.js +123 -12
  110. package/src/helpers/dockerService/serviceComponents/containerList.js +61 -23
  111. package/src/helpers/dockerService/serviceComponents/containerLogs.js +20 -6
  112. package/src/helpers/dockerService/serviceComponents/containerStats.js +24 -5
  113. package/src/helpers/dockerService/serviceComponents/imageUtils.js +1 -1
  114. package/src/helpers/exitWithMessage.js +2 -1
  115. package/src/helpers/logger.js +113 -0
  116. package/src/helpers/safeCall.js +18 -0
  117. package/src/helpers/validationHelpers.js +21 -3
  118. package/src/hooks/creation/useContainerActions.js +4 -3
  119. package/src/hooks/creation/useContainerCreation.js +5 -4
  120. package/src/hooks/creation/useLogsViewer.js +2 -1
  121. package/src/hooks/useContainers.js +6 -3
  122. package/src/hooks/useControls.js +244 -91
  123. package/src/hooks/useLogsStream.js +2 -1
  124. package/src/index.js +1 -0
  125. package/test/actionHelpers.test.js +106 -0
  126. package/test/containerActions.test.js +138 -0
  127. package/test/containerList.test.js +79 -0
  128. package/test/jest.setup.js +7 -0
  129. package/test/safeCall.test.js +25 -0
  130. package/test/useContainerCreation.dom.test.js +97 -0
  131. package/test/validationHelpers.test.js +2 -2
  132. package/AUDIT_REPORT.md +0 -1004
  133. package/dist/cdd.bundle.js +0 -8
  134. package/dist/components/ContainerCreator.js +0 -81
  135. package/dist/components/StatsViewer.js +0 -0
  136. package/dist/helpers/dockerActions.js +0 -64
  137. package/dist/helpers/dockerService.js +0 -284
  138. package/dist/hooks/useStatsPolling.js +0 -54
@@ -0,0 +1,94 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>JSDoc: Source: helpers/actionHelpers.js</title>
6
+
7
+ <script src="scripts/prettify/prettify.js"> </script>
8
+ <script src="scripts/prettify/lang-css.js"> </script>
9
+ <!--[if lt IE 9]>
10
+ <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
11
+ <![endif]-->
12
+ <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
13
+ <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
14
+ </head>
15
+
16
+ <body>
17
+
18
+ <div id="main">
19
+
20
+ <h1 class="page-title">Source: helpers/actionHelpers.js</h1>
21
+
22
+
23
+
24
+
25
+
26
+
27
+ <section>
28
+ <article>
29
+ <pre class="prettyprint source linenums"><code>import { MESSAGE_TIMEOUTS } from "../helpers/constants";
30
+ /**
31
+ * Generic helper to perform a container action with user feedback.
32
+ *
33
+ * @param {Object} params
34
+ * @param {Array} params.containers - Array of container objects
35
+ * @param {number} params.selected - Index of the selected container
36
+ * @param {Function} params.actionFn - Async function that performs the action (receives container id)
37
+ * @param {string} params.actionLabel - Label used in feedback messages (e.g. 'Starting')
38
+ * @param {Function} params.setMessage - Setter for feedback message
39
+ * @param {Function} params.setMessageColor - Setter for feedback color
40
+ * @param {Function} [params.stateCheck] - Optional function that validates container state before action
41
+ * @returns {Promise&lt;void>}
42
+ */
43
+ export async function handleAction({
44
+ containers,
45
+ selected,
46
+ actionFn,
47
+ actionLabel,
48
+ setMessage,
49
+ setMessageColor,
50
+ stateCheck
51
+ }) {
52
+ const c = containers[selected];
53
+ if (!c) return;
54
+ if (stateCheck &amp;&amp; stateCheck(c)) {
55
+ setMessage(stateCheck(c));
56
+ setMessageColor("red");
57
+ setTimeout(() => setMessage(""), MESSAGE_TIMEOUTS.SHORT);
58
+ return;
59
+ }
60
+ setMessage(`${actionLabel} container...`);
61
+ setMessageColor("green");
62
+ try {
63
+ await actionFn(c.id);
64
+ setMessage(`${actionLabel} container completed successfully`);
65
+ setMessageColor("green");
66
+ setTimeout(() => setMessage(""), MESSAGE_TIMEOUTS.DEFAULT);
67
+ } catch (err) {
68
+ setMessage(`Failed to ${actionLabel.toLowerCase()} container.`);
69
+ setMessageColor("red");
70
+ setTimeout(() => setMessage(""), MESSAGE_TIMEOUTS.DEFAULT);
71
+ }
72
+ }</code></pre>
73
+ </article>
74
+ </section>
75
+
76
+
77
+
78
+
79
+ </div>
80
+
81
+ <nav>
82
+ <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-index.html">index</a></li></ul><h3>Global</h3><ul><li><a href="global.html#EXIT_DELAY">EXIT_DELAY</a></li><li><a href="global.html#MESSAGE_TIMEOUTS">MESSAGE_TIMEOUTS</a></li><li><a href="global.html#PromptField">PromptField</a></li><li><a href="global.html#PromptMessage">PromptMessage</a></li><li><a href="global.html#REFRESH_INTERVALS">REFRESH_INTERVALS</a></li><li><a href="global.html#TIMEOUTS">TIMEOUTS</a></li><li><a href="global.html#colorize">colorize</a></li><li><a href="global.html#createContainer">createContainer</a></li><li><a href="global.html#docker">docker</a></li><li><a href="global.html#exitWithMessage">exitWithMessage</a></li><li><a href="global.html#getContainers">getContainers</a></li><li><a href="global.html#getLogsStream">getLogsStream</a></li><li><a href="global.html#getStats">getStats</a></li><li><a href="global.html#handleAction">handleAction</a></li><li><a href="global.html#imageExists">imageExists</a></li><li><a href="global.html#makeBar">makeBar</a></li><li><a href="global.html#pullImage">pullImage</a></li><li><a href="global.html#removeContainer">removeContainer</a></li><li><a href="global.html#restartContainer">restartContainer</a></li><li><a href="global.html#safeCall">safeCall</a></li><li><a href="global.html#startContainer">startContainer</a></li><li><a href="global.html#stopContainer">stopContainer</a></li><li><a href="global.html#useContainerActions">useContainerActions</a></li><li><a href="global.html#useContainerCreation">useContainerCreation</a></li><li><a href="global.html#useControls">useControls</a></li><li><a href="global.html#useLogsStream">useLogsStream</a></li><li><a href="global.html#useLogsViewer">useLogsViewer</a></li><li><a href="global.html#validateEnvVars">validateEnvVars</a></li><li><a href="global.html#validatePorts">validatePorts</a></li><li><a href="global.html#withTimeout">withTimeout</a></li></ul>
83
+ </nav>
84
+
85
+ <br class="clear">
86
+
87
+ <footer>
88
+ Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.5</a> on Fri Oct 17 2025 16:07:18 GMT-0500 (hora estándar de Colombia)
89
+ </footer>
90
+
91
+ <script> prettyPrint(); </script>
92
+ <script src="scripts/linenumber.js"> </script>
93
+ </body>
94
+ </html>
@@ -0,0 +1,81 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>JSDoc: Source: helpers/constants.js</title>
6
+
7
+ <script src="scripts/prettify/prettify.js"> </script>
8
+ <script src="scripts/prettify/lang-css.js"> </script>
9
+ <!--[if lt IE 9]>
10
+ <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
11
+ <![endif]-->
12
+ <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
13
+ <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
14
+ </head>
15
+
16
+ <body>
17
+
18
+ <div id="main">
19
+
20
+ <h1 class="page-title">Source: helpers/constants.js</h1>
21
+
22
+
23
+
24
+
25
+
26
+
27
+ <section>
28
+ <article>
29
+ <pre class="prettyprint source linenums"><code>/**
30
+ * Time intervals used across the app (milliseconds).
31
+ * - CONTAINER_LIST: how often to refresh the list of containers
32
+ * - CONTAINER_STATS: how often to fetch stats for running containers
33
+ */
34
+ export const REFRESH_INTERVALS = {
35
+ CONTAINER_LIST: 3000,
36
+ CONTAINER_STATS: 1500,
37
+ };
38
+
39
+ /**
40
+ * Timeout values for UI messages before they disappear.
41
+ */
42
+ export const MESSAGE_TIMEOUTS = {
43
+ SHORT: 2000,
44
+ DEFAULT: 3000,
45
+ };
46
+
47
+ /**
48
+ * Delay used before exiting the process when showing an exit message.
49
+ */
50
+ export const EXIT_DELAY = 500;
51
+
52
+ /**
53
+ * Operational timeouts for Docker operations and image pulls.
54
+ */
55
+ export const TIMEOUTS = {
56
+ CONTAINER_OP: 30000,
57
+ PULL_IMAGE: 300000,
58
+ };
59
+ </code></pre>
60
+ </article>
61
+ </section>
62
+
63
+
64
+
65
+
66
+ </div>
67
+
68
+ <nav>
69
+ <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-index.html">index</a></li></ul><h3>Global</h3><ul><li><a href="global.html#EXIT_DELAY">EXIT_DELAY</a></li><li><a href="global.html#MESSAGE_TIMEOUTS">MESSAGE_TIMEOUTS</a></li><li><a href="global.html#PromptField">PromptField</a></li><li><a href="global.html#PromptMessage">PromptMessage</a></li><li><a href="global.html#REFRESH_INTERVALS">REFRESH_INTERVALS</a></li><li><a href="global.html#TIMEOUTS">TIMEOUTS</a></li><li><a href="global.html#colorize">colorize</a></li><li><a href="global.html#createContainer">createContainer</a></li><li><a href="global.html#docker">docker</a></li><li><a href="global.html#exitWithMessage">exitWithMessage</a></li><li><a href="global.html#getContainers">getContainers</a></li><li><a href="global.html#getLogsStream">getLogsStream</a></li><li><a href="global.html#getStats">getStats</a></li><li><a href="global.html#handleAction">handleAction</a></li><li><a href="global.html#imageExists">imageExists</a></li><li><a href="global.html#makeBar">makeBar</a></li><li><a href="global.html#pullImage">pullImage</a></li><li><a href="global.html#removeContainer">removeContainer</a></li><li><a href="global.html#restartContainer">restartContainer</a></li><li><a href="global.html#safeCall">safeCall</a></li><li><a href="global.html#startContainer">startContainer</a></li><li><a href="global.html#stopContainer">stopContainer</a></li><li><a href="global.html#useContainerActions">useContainerActions</a></li><li><a href="global.html#useContainerCreation">useContainerCreation</a></li><li><a href="global.html#useControls">useControls</a></li><li><a href="global.html#useLogsStream">useLogsStream</a></li><li><a href="global.html#useLogsViewer">useLogsViewer</a></li><li><a href="global.html#validateEnvVars">validateEnvVars</a></li><li><a href="global.html#validatePorts">validatePorts</a></li><li><a href="global.html#withTimeout">withTimeout</a></li></ul>
70
+ </nav>
71
+
72
+ <br class="clear">
73
+
74
+ <footer>
75
+ Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.5</a> on Fri Oct 17 2025 16:07:18 GMT-0500 (hora estándar de Colombia)
76
+ </footer>
77
+
78
+ <script> prettyPrint(); </script>
79
+ <script src="scripts/linenumber.js"> </script>
80
+ </body>
81
+ </html>
@@ -0,0 +1,79 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>JSDoc: Source: helpers/dockerService/dockerService.js</title>
6
+
7
+ <script src="scripts/prettify/prettify.js"> </script>
8
+ <script src="scripts/prettify/lang-css.js"> </script>
9
+ <!--[if lt IE 9]>
10
+ <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
11
+ <![endif]-->
12
+ <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
13
+ <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
14
+ </head>
15
+
16
+ <body>
17
+
18
+ <div id="main">
19
+
20
+ <h1 class="page-title">Source: helpers/dockerService/dockerService.js</h1>
21
+
22
+
23
+
24
+
25
+
26
+
27
+ <section>
28
+ <article>
29
+ <pre class="prettyprint source linenums"><code>import Docker from "dockerode";
30
+
31
+ // Use default dockerode configuration which automatically handles:
32
+ // - /var/run/docker.sock on Linux/Mac
33
+ // - //./pipe/docker_engine on Windows
34
+ // - Environment variables DOCKER_HOST, DOCKER_CERT_PATH, etc.
35
+
36
+ /**
37
+ * Typedef for the docker client used in this project.
38
+ * Use a generic object shape so JSDoc can render a meaningful type.
39
+ *
40
+ * @typedef {Object} DockerClient
41
+ * @property {Function} listContainers
42
+ * @property {Function} getContainer
43
+ * @property {Function} listImages
44
+ * @property {Function} createContainer
45
+ * @property {Function} pull
46
+ */
47
+
48
+ /**
49
+ * Shared Docker client instance (dockerode). Consumers import { docker }
50
+ * and use it to list/create/start/stop containers and images.
51
+ *
52
+ * @type {DockerClient}
53
+ */
54
+ const docker = new Docker();
55
+
56
+ export { docker };
57
+ </code></pre>
58
+ </article>
59
+ </section>
60
+
61
+
62
+
63
+
64
+ </div>
65
+
66
+ <nav>
67
+ <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-index.html">index</a></li></ul><h3>Global</h3><ul><li><a href="global.html#EXIT_DELAY">EXIT_DELAY</a></li><li><a href="global.html#MESSAGE_TIMEOUTS">MESSAGE_TIMEOUTS</a></li><li><a href="global.html#PromptField">PromptField</a></li><li><a href="global.html#PromptMessage">PromptMessage</a></li><li><a href="global.html#REFRESH_INTERVALS">REFRESH_INTERVALS</a></li><li><a href="global.html#TIMEOUTS">TIMEOUTS</a></li><li><a href="global.html#colorize">colorize</a></li><li><a href="global.html#createContainer">createContainer</a></li><li><a href="global.html#docker">docker</a></li><li><a href="global.html#exitWithMessage">exitWithMessage</a></li><li><a href="global.html#getContainers">getContainers</a></li><li><a href="global.html#getLogsStream">getLogsStream</a></li><li><a href="global.html#getStats">getStats</a></li><li><a href="global.html#handleAction">handleAction</a></li><li><a href="global.html#imageExists">imageExists</a></li><li><a href="global.html#makeBar">makeBar</a></li><li><a href="global.html#pullImage">pullImage</a></li><li><a href="global.html#removeContainer">removeContainer</a></li><li><a href="global.html#restartContainer">restartContainer</a></li><li><a href="global.html#safeCall">safeCall</a></li><li><a href="global.html#startContainer">startContainer</a></li><li><a href="global.html#stopContainer">stopContainer</a></li><li><a href="global.html#useContainerActions">useContainerActions</a></li><li><a href="global.html#useContainerCreation">useContainerCreation</a></li><li><a href="global.html#useControls">useControls</a></li><li><a href="global.html#useLogsStream">useLogsStream</a></li><li><a href="global.html#useLogsViewer">useLogsViewer</a></li><li><a href="global.html#validateEnvVars">validateEnvVars</a></li><li><a href="global.html#validatePorts">validatePorts</a></li><li><a href="global.html#withTimeout">withTimeout</a></li></ul>
68
+ </nav>
69
+
70
+ <br class="clear">
71
+
72
+ <footer>
73
+ Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.5</a> on Fri Oct 17 2025 16:07:18 GMT-0500 (hora estándar de Colombia)
74
+ </footer>
75
+
76
+ <script> prettyPrint(); </script>
77
+ <script src="scripts/linenumber.js"> </script>
78
+ </body>
79
+ </html>
@@ -0,0 +1,153 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>JSDoc: Source: helpers/dockerService/serviceComponents/containerActions.js</title>
6
+
7
+ <script src="scripts/prettify/prettify.js"> </script>
8
+ <script src="scripts/prettify/lang-css.js"> </script>
9
+ <!--[if lt IE 9]>
10
+ <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
11
+ <![endif]-->
12
+ <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
13
+ <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
14
+ </head>
15
+
16
+ <body>
17
+
18
+ <div id="main">
19
+
20
+ <h1 class="page-title">Source: helpers/dockerService/serviceComponents/containerActions.js</h1>
21
+
22
+
23
+
24
+
25
+
26
+
27
+ <section>
28
+ <article>
29
+ <pre class="prettyprint source linenums"><code>import { docker } from "../dockerService";
30
+ import { imageExists, pullImage } from "./imageUtils.js";
31
+ import { TIMEOUTS } from "../../constants";
32
+
33
+ /**
34
+ * Helper to add timeout to promises. If the provided promise does not settle
35
+ * within `ms` milliseconds it will reject with an Error.
36
+ *
37
+ * @template T
38
+ * @param {Promise&lt;T>} promise - Promise to wrap
39
+ * @param {number} [ms=TIMEOUTS.CONTAINER_OP] - Timeout in milliseconds
40
+ * @returns {Promise&lt;T>} The original promise result or a rejection on timeout
41
+ */
42
+ function withTimeout(promise, ms = TIMEOUTS.CONTAINER_OP) {
43
+ return Promise.race([
44
+ promise,
45
+ new Promise((_, reject) =>
46
+ setTimeout(() => reject(new Error('Operation timed out')), ms)
47
+ )
48
+ ]);
49
+ }
50
+
51
+ /**
52
+ * Remove (delete) a container by id. Force removal so running containers are stopped first.
53
+ *
54
+ * @param {string} containerId - Docker container id
55
+ * @returns {Promise&lt;void>} Resolves when removal completes
56
+ * @throws {Error} If Docker reports an error
57
+ */
58
+ export async function removeContainer(containerId) {
59
+ const container = docker.getContainer(containerId);
60
+ try {
61
+ await withTimeout(container.remove({ force: true }), TIMEOUTS.CONTAINER_OP);
62
+ } catch (err) {
63
+ throw new Error('Error removing container: ' + err.message);
64
+ }
65
+ }
66
+
67
+ /**
68
+ * Create a new container from an image. If the image is missing locally, it will be pulled.
69
+ *
70
+ * @param {string} imageName - Image name (e.g. 'nginx:alpine')
71
+ * @param {Object} [options] - Docker create options (Env, ExposedPorts, HostConfig, name, etc.)
72
+ * @returns {Promise&lt;string>} The created container id
73
+ * @throws {Error} If image listing/pull or creation fails
74
+ */
75
+ export async function createContainer(imageName, options = {}) {
76
+ let exists;
77
+ try {
78
+ exists = await withTimeout(imageExists(imageName), 10000);
79
+ } catch (err) {
80
+ throw new Error('Error listing local images: ' + err.message);
81
+ }
82
+ if (!exists) {
83
+ try {
84
+ await withTimeout(pullImage(imageName), TIMEOUTS.PULL_IMAGE); // 5 minutes for pull
85
+ } catch (err) {
86
+ throw new Error('Could not pull image: ' + err.message);
87
+ }
88
+ }
89
+ const createOpts = {
90
+ Image: imageName,
91
+ Tty: true,
92
+ ...options,
93
+ };
94
+ try {
95
+ const container = await withTimeout(docker.createContainer(createOpts), TIMEOUTS.CONTAINER_OP);
96
+ return container.id || container.Id;
97
+ } catch (err) {
98
+ throw new Error('Error creating container: ' + err.message);
99
+ }
100
+ }
101
+
102
+ /**
103
+ * Start a container by id.
104
+ * @param {string} containerId - Docker container id
105
+ * @returns {Promise&lt;void>}
106
+ */
107
+ export async function startContainer(containerId) {
108
+ const container = docker.getContainer(containerId);
109
+ await withTimeout(container.start(), TIMEOUTS.CONTAINER_OP);
110
+ }
111
+
112
+ /**
113
+ * Stop a container by id.
114
+ * @param {string} containerId - Docker container id
115
+ * @returns {Promise&lt;void>}
116
+ */
117
+ export async function stopContainer(containerId) {
118
+ const container = docker.getContainer(containerId);
119
+ await withTimeout(container.stop(), TIMEOUTS.CONTAINER_OP);
120
+ }
121
+
122
+ /**
123
+ * Restart a container by id.
124
+ * @param {string} containerId - Docker container id
125
+ * @returns {Promise&lt;void>}
126
+ */
127
+ export async function restartContainer(containerId) {
128
+ const container = docker.getContainer(containerId);
129
+ await withTimeout(container.restart(), TIMEOUTS.CONTAINER_OP);
130
+ }
131
+ </code></pre>
132
+ </article>
133
+ </section>
134
+
135
+
136
+
137
+
138
+ </div>
139
+
140
+ <nav>
141
+ <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-index.html">index</a></li></ul><h3>Global</h3><ul><li><a href="global.html#EXIT_DELAY">EXIT_DELAY</a></li><li><a href="global.html#MESSAGE_TIMEOUTS">MESSAGE_TIMEOUTS</a></li><li><a href="global.html#PromptField">PromptField</a></li><li><a href="global.html#PromptMessage">PromptMessage</a></li><li><a href="global.html#REFRESH_INTERVALS">REFRESH_INTERVALS</a></li><li><a href="global.html#TIMEOUTS">TIMEOUTS</a></li><li><a href="global.html#colorize">colorize</a></li><li><a href="global.html#createContainer">createContainer</a></li><li><a href="global.html#docker">docker</a></li><li><a href="global.html#exitWithMessage">exitWithMessage</a></li><li><a href="global.html#getContainers">getContainers</a></li><li><a href="global.html#getLogsStream">getLogsStream</a></li><li><a href="global.html#getStats">getStats</a></li><li><a href="global.html#handleAction">handleAction</a></li><li><a href="global.html#imageExists">imageExists</a></li><li><a href="global.html#makeBar">makeBar</a></li><li><a href="global.html#pullImage">pullImage</a></li><li><a href="global.html#removeContainer">removeContainer</a></li><li><a href="global.html#restartContainer">restartContainer</a></li><li><a href="global.html#safeCall">safeCall</a></li><li><a href="global.html#startContainer">startContainer</a></li><li><a href="global.html#stopContainer">stopContainer</a></li><li><a href="global.html#useContainerActions">useContainerActions</a></li><li><a href="global.html#useContainerCreation">useContainerCreation</a></li><li><a href="global.html#useControls">useControls</a></li><li><a href="global.html#useLogsStream">useLogsStream</a></li><li><a href="global.html#useLogsViewer">useLogsViewer</a></li><li><a href="global.html#validateEnvVars">validateEnvVars</a></li><li><a href="global.html#validatePorts">validatePorts</a></li><li><a href="global.html#withTimeout">withTimeout</a></li></ul>
142
+ </nav>
143
+
144
+ <br class="clear">
145
+
146
+ <footer>
147
+ Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.5</a> on Fri Oct 17 2025 16:07:18 GMT-0500 (hora estándar de Colombia)
148
+ </footer>
149
+
150
+ <script> prettyPrint(); </script>
151
+ <script src="scripts/linenumber.js"> </script>
152
+ </body>
153
+ </html>
@@ -0,0 +1,81 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>JSDoc: Source: helpers/dockerService/serviceComponents/containerList.js</title>
6
+
7
+ <script src="scripts/prettify/prettify.js"> </script>
8
+ <script src="scripts/prettify/lang-css.js"> </script>
9
+ <!--[if lt IE 9]>
10
+ <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
11
+ <![endif]-->
12
+ <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
13
+ <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
14
+ </head>
15
+
16
+ <body>
17
+
18
+ <div id="main">
19
+
20
+ <h1 class="page-title">Source: helpers/dockerService/serviceComponents/containerList.js</h1>
21
+
22
+
23
+
24
+
25
+
26
+
27
+ <section>
28
+ <article>
29
+ <pre class="prettyprint source linenums"><code>import { docker } from "../dockerService";
30
+
31
+ /**
32
+ * Return a list of containers with normalized fields for the UI.
33
+ * @returns {Promise&lt;Array&lt;Object>>}
34
+ */
35
+ export async function getContainers() {
36
+ const containers = await docker.listContainers({ all: true });
37
+ return containers.map((container) => ({
38
+ id: container.Id,
39
+ name: (container.Names &amp;&amp; container.Names[0] || 'Unknown').replace("/", ""),
40
+ image: container.Image,
41
+ state: container.State,
42
+ status: container.Status,
43
+ ports:
44
+ (() => {
45
+ const publicPorts = container.Ports.filter((port) => port.PublicPort).map(
46
+ (port) => `${port.PublicPort}:${port.PrivatePort}`
47
+ );
48
+ if (publicPorts.length > 0) {
49
+ return [...new Set(publicPorts)];
50
+ }
51
+ // If there are no public ports, show private exposed ports
52
+ const privatePorts = container.Ports.filter((port) => port.PrivatePort).map(
53
+ (port) => `:${port.PrivatePort}`
54
+ );
55
+ return [...new Set(privatePorts)];
56
+ })()
57
+ }));
58
+ }
59
+ </code></pre>
60
+ </article>
61
+ </section>
62
+
63
+
64
+
65
+
66
+ </div>
67
+
68
+ <nav>
69
+ <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-index.html">index</a></li></ul><h3>Global</h3><ul><li><a href="global.html#EXIT_DELAY">EXIT_DELAY</a></li><li><a href="global.html#MESSAGE_TIMEOUTS">MESSAGE_TIMEOUTS</a></li><li><a href="global.html#PromptField">PromptField</a></li><li><a href="global.html#PromptMessage">PromptMessage</a></li><li><a href="global.html#REFRESH_INTERVALS">REFRESH_INTERVALS</a></li><li><a href="global.html#TIMEOUTS">TIMEOUTS</a></li><li><a href="global.html#colorize">colorize</a></li><li><a href="global.html#createContainer">createContainer</a></li><li><a href="global.html#docker">docker</a></li><li><a href="global.html#exitWithMessage">exitWithMessage</a></li><li><a href="global.html#getContainers">getContainers</a></li><li><a href="global.html#getLogsStream">getLogsStream</a></li><li><a href="global.html#getStats">getStats</a></li><li><a href="global.html#handleAction">handleAction</a></li><li><a href="global.html#imageExists">imageExists</a></li><li><a href="global.html#makeBar">makeBar</a></li><li><a href="global.html#pullImage">pullImage</a></li><li><a href="global.html#removeContainer">removeContainer</a></li><li><a href="global.html#restartContainer">restartContainer</a></li><li><a href="global.html#safeCall">safeCall</a></li><li><a href="global.html#startContainer">startContainer</a></li><li><a href="global.html#stopContainer">stopContainer</a></li><li><a href="global.html#useContainerActions">useContainerActions</a></li><li><a href="global.html#useContainerCreation">useContainerCreation</a></li><li><a href="global.html#useControls">useControls</a></li><li><a href="global.html#useLogsStream">useLogsStream</a></li><li><a href="global.html#useLogsViewer">useLogsViewer</a></li><li><a href="global.html#validateEnvVars">validateEnvVars</a></li><li><a href="global.html#validatePorts">validatePorts</a></li><li><a href="global.html#withTimeout">withTimeout</a></li></ul>
70
+ </nav>
71
+
72
+ <br class="clear">
73
+
74
+ <footer>
75
+ Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.5</a> on Fri Oct 17 2025 16:07:18 GMT-0500 (hora estándar de Colombia)
76
+ </footer>
77
+
78
+ <script> prettyPrint(); </script>
79
+ <script src="scripts/linenumber.js"> </script>
80
+ </body>
81
+ </html>
@@ -0,0 +1,85 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>JSDoc: Source: helpers/dockerService/serviceComponents/containerLogs.js</title>
6
+
7
+ <script src="scripts/prettify/prettify.js"> </script>
8
+ <script src="scripts/prettify/lang-css.js"> </script>
9
+ <!--[if lt IE 9]>
10
+ <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
11
+ <![endif]-->
12
+ <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
13
+ <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
14
+ </head>
15
+
16
+ <body>
17
+
18
+ <div id="main">
19
+
20
+ <h1 class="page-title">Source: helpers/dockerService/serviceComponents/containerLogs.js</h1>
21
+
22
+
23
+
24
+
25
+
26
+
27
+ <section>
28
+ <article>
29
+ <pre class="prettyprint source linenums"><code>import { docker } from "../dockerService";
30
+ import { safeCall } from "../../../../src/helpers/safeCall.js";
31
+
32
+ /**
33
+ * Return a stream of logs from a container and call callbacks for events.
34
+ *
35
+ * @param {string} containerId - Docker container id
36
+ * @param {Function} onData - Called with chunk string when data arrives
37
+ * @param {Function} onEnd - Called when stream ends
38
+ * @param {Function} onError - Called on error
39
+ */
40
+ export function getLogsStream(containerId, onData, onEnd, onError) {
41
+ // Use shared safeCall util to call optional callbacks safely
42
+
43
+ try {
44
+ const container = docker.getContainer(containerId);
45
+ container.logs({
46
+ follow: true,
47
+ stdout: true,
48
+ stderr: true,
49
+ tail: 100
50
+ }, (err, stream) => {
51
+ if (err) {
52
+ safeCall(onError, err);
53
+ return;
54
+ }
55
+ stream.on('data', chunk => safeCall(onData, chunk.toString()));
56
+ stream.on('end', () => safeCall(onEnd));
57
+ stream.on('error', err => safeCall(onError, err));
58
+ });
59
+ } catch (err) {
60
+ safeCall(onError, err);
61
+ }
62
+ }
63
+ </code></pre>
64
+ </article>
65
+ </section>
66
+
67
+
68
+
69
+
70
+ </div>
71
+
72
+ <nav>
73
+ <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-index.html">index</a></li></ul><h3>Global</h3><ul><li><a href="global.html#EXIT_DELAY">EXIT_DELAY</a></li><li><a href="global.html#MESSAGE_TIMEOUTS">MESSAGE_TIMEOUTS</a></li><li><a href="global.html#PromptField">PromptField</a></li><li><a href="global.html#PromptMessage">PromptMessage</a></li><li><a href="global.html#REFRESH_INTERVALS">REFRESH_INTERVALS</a></li><li><a href="global.html#TIMEOUTS">TIMEOUTS</a></li><li><a href="global.html#colorize">colorize</a></li><li><a href="global.html#createContainer">createContainer</a></li><li><a href="global.html#docker">docker</a></li><li><a href="global.html#exitWithMessage">exitWithMessage</a></li><li><a href="global.html#getContainers">getContainers</a></li><li><a href="global.html#getLogsStream">getLogsStream</a></li><li><a href="global.html#getStats">getStats</a></li><li><a href="global.html#handleAction">handleAction</a></li><li><a href="global.html#imageExists">imageExists</a></li><li><a href="global.html#makeBar">makeBar</a></li><li><a href="global.html#pullImage">pullImage</a></li><li><a href="global.html#removeContainer">removeContainer</a></li><li><a href="global.html#restartContainer">restartContainer</a></li><li><a href="global.html#safeCall">safeCall</a></li><li><a href="global.html#startContainer">startContainer</a></li><li><a href="global.html#stopContainer">stopContainer</a></li><li><a href="global.html#useContainerActions">useContainerActions</a></li><li><a href="global.html#useContainerCreation">useContainerCreation</a></li><li><a href="global.html#useControls">useControls</a></li><li><a href="global.html#useLogsStream">useLogsStream</a></li><li><a href="global.html#useLogsViewer">useLogsViewer</a></li><li><a href="global.html#validateEnvVars">validateEnvVars</a></li><li><a href="global.html#validatePorts">validatePorts</a></li><li><a href="global.html#withTimeout">withTimeout</a></li></ul>
74
+ </nav>
75
+
76
+ <br class="clear">
77
+
78
+ <footer>
79
+ Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.5</a> on Fri Oct 17 2025 16:07:18 GMT-0500 (hora estándar de Colombia)
80
+ </footer>
81
+
82
+ <script> prettyPrint(); </script>
83
+ <script src="scripts/linenumber.js"> </script>
84
+ </body>
85
+ </html>