cdd-cli 3.1.4 → 3.1.6

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 (140) hide show
  1. package/.eslintrc.json +30 -0
  2. package/.github/workflows/docs.yml +35 -0
  3. package/CHANGELOG.md +37 -4
  4. package/README.md +26 -0
  5. package/_config.yml +13 -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 +27 -3
  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 +47 -8
  17. package/dist/components/UsageMenu.js +30 -1
  18. package/dist/helpers/actionHelpers.js +17 -6
  19. package/dist/helpers/appInfo.js +21 -0
  20. package/dist/helpers/constants.js +30 -0
  21. package/dist/helpers/dockerService/dockerService.js +19 -0
  22. package/dist/helpers/dockerService/serviceComponents/containerActions.js +194 -35
  23. package/dist/helpers/dockerService/serviceComponents/containerList.js +45 -8
  24. package/dist/helpers/dockerService/serviceComponents/containerLogs.js +16 -6
  25. package/dist/helpers/dockerService/serviceComponents/containerStats.js +28 -9
  26. package/dist/helpers/exitWithMessage.js +2 -1
  27. package/dist/helpers/logger.js +126 -0
  28. package/dist/helpers/safeCall.js +21 -0
  29. package/dist/helpers/validationHelpers.js +20 -1
  30. package/dist/hooks/creation/useContainerActions.js +2 -1
  31. package/dist/hooks/creation/useContainerCreation.js +5 -4
  32. package/dist/hooks/creation/useLogsViewer.js +3 -2
  33. package/dist/hooks/useContainers.js +6 -3
  34. package/dist/hooks/useControls.js +253 -122
  35. package/dist/hooks/useLogsStream.js +3 -2
  36. package/dist/index.js +1 -0
  37. package/docs/_config.yml +13 -0
  38. package/docs/components_ContainerCreationPrompt.jsx.html +114 -0
  39. package/docs/components_ContainerRow.jsx.html +151 -0
  40. package/docs/components_ContainerSection.jsx.html +75 -0
  41. package/docs/components_Footer.jsx.html +66 -0
  42. package/docs/components_Header.jsx.html +84 -0
  43. package/docs/components_LogViewer.jsx.html +91 -0
  44. package/docs/components_MessageFeedback.jsx.html +76 -0
  45. package/docs/components_PromptField.jsx.html +99 -0
  46. package/docs/components_StatsBar.jsx.html +105 -0
  47. package/docs/components_UsageMenu.jsx.html +73 -0
  48. package/docs/fonts/OpenSans-Bold-webfont.eot +0 -0
  49. package/docs/fonts/OpenSans-Bold-webfont.svg +1830 -0
  50. package/docs/fonts/OpenSans-Bold-webfont.woff +0 -0
  51. package/docs/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
  52. package/docs/fonts/OpenSans-BoldItalic-webfont.svg +1830 -0
  53. package/docs/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
  54. package/docs/fonts/OpenSans-Italic-webfont.eot +0 -0
  55. package/docs/fonts/OpenSans-Italic-webfont.svg +1830 -0
  56. package/docs/fonts/OpenSans-Italic-webfont.woff +0 -0
  57. package/docs/fonts/OpenSans-Light-webfont.eot +0 -0
  58. package/docs/fonts/OpenSans-Light-webfont.svg +1831 -0
  59. package/docs/fonts/OpenSans-Light-webfont.woff +0 -0
  60. package/docs/fonts/OpenSans-LightItalic-webfont.eot +0 -0
  61. package/docs/fonts/OpenSans-LightItalic-webfont.svg +1835 -0
  62. package/docs/fonts/OpenSans-LightItalic-webfont.woff +0 -0
  63. package/docs/fonts/OpenSans-Regular-webfont.eot +0 -0
  64. package/docs/fonts/OpenSans-Regular-webfont.svg +1831 -0
  65. package/docs/fonts/OpenSans-Regular-webfont.woff +0 -0
  66. package/docs/global.html +6145 -0
  67. package/docs/helpers_actionHelpers.js.html +94 -0
  68. package/docs/helpers_constants.js.html +81 -0
  69. package/docs/helpers_dockerService_dockerService.js.html +79 -0
  70. package/docs/helpers_dockerService_serviceComponents_containerActions.js.html +153 -0
  71. package/docs/helpers_dockerService_serviceComponents_containerList.js.html +81 -0
  72. package/docs/helpers_dockerService_serviceComponents_containerLogs.js.html +85 -0
  73. package/docs/helpers_dockerService_serviceComponents_containerStats.js.html +107 -0
  74. package/docs/helpers_dockerService_serviceComponents_imageUtils.js.html +82 -0
  75. package/docs/helpers_exitWithMessage.js.html +77 -0
  76. package/docs/helpers_safeCall.js.html +68 -0
  77. package/docs/helpers_validationHelpers.js.html +96 -0
  78. package/docs/hooks_creation_useContainerActions.js.html +120 -0
  79. package/docs/hooks_creation_useContainerCreation.js.html +152 -0
  80. package/docs/hooks_creation_useLogsViewer.js.html +102 -0
  81. package/docs/hooks_useControls.js.html +298 -0
  82. package/docs/hooks_useLogsStream.js.html +82 -0
  83. package/docs/index.html +65 -0
  84. package/docs/index.js.html +65 -0
  85. package/docs/module-index.html +171 -0
  86. package/docs/scripts/linenumber.js +25 -0
  87. package/docs/scripts/prettify/Apache-License-2.0.txt +202 -0
  88. package/docs/scripts/prettify/lang-css.js +2 -0
  89. package/docs/scripts/prettify/prettify.js +28 -0
  90. package/docs/styles/jsdoc-default.css +358 -0
  91. package/docs/styles/prettify-jsdoc.css +111 -0
  92. package/docs/styles/prettify-tomorrow.css +132 -0
  93. package/fix-imports.cjs +33 -6
  94. package/jest.config.cjs +2 -1
  95. package/package.json +19 -9
  96. package/src/App.jsx +16 -2
  97. package/src/components/ContainerCreationPrompt.jsx +26 -0
  98. package/src/components/ContainerList.jsx +12 -13
  99. package/src/components/ContainerRow.jsx +55 -20
  100. package/src/components/ContainerSection.jsx +15 -1
  101. package/src/components/Footer.jsx +6 -1
  102. package/src/components/Header.jsx +27 -3
  103. package/src/components/LogViewer.jsx +19 -2
  104. package/src/components/MessageFeedback.jsx +14 -0
  105. package/src/components/PromptField.jsx +30 -0
  106. package/src/components/StatsBar.jsx +47 -8
  107. package/src/components/UsageMenu.jsx +38 -8
  108. package/src/helpers/actionHelpers.js +16 -7
  109. package/src/helpers/appInfo.js +23 -0
  110. package/src/helpers/constants.js +30 -0
  111. package/src/helpers/dockerService/dockerService.js +19 -0
  112. package/src/helpers/dockerService/serviceComponents/containerActions.js +123 -12
  113. package/src/helpers/dockerService/serviceComponents/containerList.js +61 -23
  114. package/src/helpers/dockerService/serviceComponents/containerLogs.js +20 -6
  115. package/src/helpers/dockerService/serviceComponents/containerStats.js +24 -5
  116. package/src/helpers/dockerService/serviceComponents/imageUtils.js +1 -1
  117. package/src/helpers/exitWithMessage.js +2 -1
  118. package/src/helpers/logger.js +113 -0
  119. package/src/helpers/safeCall.js +18 -0
  120. package/src/helpers/validationHelpers.js +21 -3
  121. package/src/hooks/creation/useContainerActions.js +4 -3
  122. package/src/hooks/creation/useContainerCreation.js +5 -4
  123. package/src/hooks/creation/useLogsViewer.js +2 -1
  124. package/src/hooks/useContainers.js +6 -3
  125. package/src/hooks/useControls.js +244 -91
  126. package/src/hooks/useLogsStream.js +2 -1
  127. package/src/index.js +1 -0
  128. package/test/actionHelpers.test.js +106 -0
  129. package/test/containerActions.test.js +138 -0
  130. package/test/containerList.test.js +79 -0
  131. package/test/jest.setup.js +7 -0
  132. package/test/safeCall.test.js +25 -0
  133. package/test/useContainerCreation.dom.test.js +97 -0
  134. package/test/validationHelpers.test.js +2 -2
  135. package/dist/cdd.bundle.js +0 -8
  136. package/dist/components/ContainerCreator.js +0 -81
  137. package/dist/components/StatsViewer.js +0 -0
  138. package/dist/helpers/dockerActions.js +0 -64
  139. package/dist/helpers/dockerService.js +0 -284
  140. package/dist/hooks/useStatsPolling.js +0 -54
@@ -0,0 +1,107 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>JSDoc: Source: helpers/dockerService/serviceComponents/containerStats.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/containerStats.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
+ * Retrieve a snapshot of container resource usage (CPU, memory, network).
33
+ *
34
+ * @param {string} containerId - Docker container id
35
+ * @returns {Promise&lt;Object>} Object with cpuPercent, memPercent and netIO {rx,tx}
36
+ */
37
+ export async function getStats(containerId) {
38
+ const container = docker.getContainer(containerId);
39
+ const stream = await container.stats({ stream: false });
40
+
41
+ const cpuDelta =
42
+ stream.cpu_stats.cpu_usage.total_usage -
43
+ stream.precpu_stats.cpu_usage.total_usage;
44
+ const systemDelta =
45
+ stream.cpu_stats.system_cpu_usage - stream.precpu_stats.system_cpu_usage;
46
+
47
+ // Get number of CPUs for proper normalization
48
+ let numCpus = 1;
49
+ if (typeof stream.cpu_stats.online_cpus === 'number' &amp;&amp; stream.cpu_stats.online_cpus > 0) {
50
+ numCpus = stream.cpu_stats.online_cpus;
51
+ } else if (
52
+ stream.cpu_stats.cpu_usage &amp;&amp;
53
+ Array.isArray(stream.cpu_stats.cpu_usage.percpu_usage) &amp;&amp;
54
+ stream.cpu_stats.cpu_usage.percpu_usage.length > 0
55
+ ) {
56
+ numCpus = stream.cpu_stats.cpu_usage.percpu_usage.length;
57
+ }
58
+
59
+ // Calculate normalized CPU percentage
60
+ const cpuPercent = systemDelta > 0
61
+ ? ((cpuDelta / systemDelta) * numCpus * 100)
62
+ : 0;
63
+
64
+ const memUsage = stream.memory_stats.usage || 0;
65
+ const memLimit = stream.memory_stats.limit || 1;
66
+ const memPercent = (memUsage / memLimit) * 100;
67
+
68
+ const rx = stream.networks
69
+ ? Object.values(stream.networks)
70
+ .map((n) => n.rx_bytes)
71
+ .reduce((a, b) => a + b, 0)
72
+ : 0;
73
+ const tx = stream.networks
74
+ ? Object.values(stream.networks)
75
+ .map((n) => n.tx_bytes)
76
+ .reduce((a, b) => a + b, 0)
77
+ : 0;
78
+
79
+ return {
80
+ cpuPercent: cpuPercent.toFixed(1),
81
+ memPercent: memPercent.toFixed(1),
82
+ netIO: { rx, tx },
83
+ };
84
+ }
85
+ </code></pre>
86
+ </article>
87
+ </section>
88
+
89
+
90
+
91
+
92
+ </div>
93
+
94
+ <nav>
95
+ <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>
96
+ </nav>
97
+
98
+ <br class="clear">
99
+
100
+ <footer>
101
+ 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)
102
+ </footer>
103
+
104
+ <script> prettyPrint(); </script>
105
+ <script src="scripts/linenumber.js"> </script>
106
+ </body>
107
+ </html>
@@ -0,0 +1,82 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>JSDoc: Source: helpers/dockerService/serviceComponents/imageUtils.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/imageUtils.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
+ * Check whether an image exists locally.
33
+ * @param {string} imageName - Image name or tag
34
+ * @returns {Promise&lt;boolean>}
35
+ */
36
+ export async function imageExists(imageName) {
37
+ const images = await docker.listImages();
38
+ return images.some(img =>
39
+ (img.RepoTags || []).includes(imageName) ||
40
+ (img.RepoDigests || []).some(d => d.includes(imageName))
41
+ );
42
+ }
43
+
44
+ /**
45
+ * Pull an image from the registry.
46
+ * @param {string} imageName - Image name to pull
47
+ * @returns {Promise&lt;void>}
48
+ */
49
+ export async function pullImage(imageName) {
50
+ await new Promise((resolve, reject) => {
51
+ docker.pull(imageName, (err, stream) => {
52
+ if (err) return reject(new Error('Error pulling image: ' + err.message));
53
+ docker.modem.followProgress(stream, (pullErr) => {
54
+ if (pullErr) reject(new Error('Error during pull: ' + pullErr.message));
55
+ else resolve();
56
+ });
57
+ });
58
+ });
59
+ }
60
+ </code></pre>
61
+ </article>
62
+ </section>
63
+
64
+
65
+
66
+
67
+ </div>
68
+
69
+ <nav>
70
+ <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>
71
+ </nav>
72
+
73
+ <br class="clear">
74
+
75
+ <footer>
76
+ 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)
77
+ </footer>
78
+
79
+ <script> prettyPrint(); </script>
80
+ <script src="scripts/linenumber.js"> </script>
81
+ </body>
82
+ </html>
@@ -0,0 +1,77 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>JSDoc: Source: helpers/exitWithMessage.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/exitWithMessage.js</h1>
21
+
22
+
23
+
24
+
25
+
26
+
27
+ <section>
28
+ <article>
29
+ <pre class="prettyprint source linenums"><code>import { spawn } from "child_process";
30
+ import { EXIT_DELAY } from "./constants";
31
+
32
+ /**
33
+ * Show an exit message using provided setters, clear the terminal and exit after a delay.
34
+ *
35
+ * @param {Object} params
36
+ * @param {Function} params.setMessage - Setter for message text
37
+ * @param {Function} params.setMessageColor - Setter for message color
38
+ * @param {string} [params.message] - Message to display
39
+ * @param {string} [params.color] - Color for the message
40
+ * @param {number} [params.delay] - Delay in milliseconds before exiting
41
+ */
42
+ export function exitWithMessage({ setMessage, setMessageColor, message = "Exiting...", color = "yellow", delay = EXIT_DELAY }) {
43
+ setMessage(message);
44
+ setMessageColor(color);
45
+ setTimeout(() => {
46
+ setMessage("");
47
+ if (process.platform === "win32") {
48
+ spawn("cmd", ["/c", "cls"], { stdio: "inherit" });
49
+ } else {
50
+ spawn("clear", [], { stdio: "inherit" });
51
+ }
52
+ process.exit();
53
+ }, delay);
54
+ }
55
+ </code></pre>
56
+ </article>
57
+ </section>
58
+
59
+
60
+
61
+
62
+ </div>
63
+
64
+ <nav>
65
+ <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>
66
+ </nav>
67
+
68
+ <br class="clear">
69
+
70
+ <footer>
71
+ 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)
72
+ </footer>
73
+
74
+ <script> prettyPrint(); </script>
75
+ <script src="scripts/linenumber.js"> </script>
76
+ </body>
77
+ </html>
@@ -0,0 +1,68 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>JSDoc: Source: helpers/safeCall.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/safeCall.js</h1>
21
+
22
+
23
+
24
+
25
+
26
+
27
+ <section>
28
+ <article>
29
+ <pre class="prettyprint source linenums"><code>/**
30
+ * Call a function safely: if it's a function call it with provided args and
31
+ * catch any errors so they don't bubble to the host application.
32
+ *
33
+ * @param {Function} fn
34
+ * @param {...any} args
35
+ */
36
+ export function safeCall(fn, ...args) {
37
+ if (typeof fn === 'function') {
38
+ try {
39
+ return fn(...args);
40
+ } catch (e) {
41
+ // eslint-disable-next-line no-console
42
+ console.error('safeCall caught error:', e);
43
+ }
44
+ }
45
+ }
46
+ </code></pre>
47
+ </article>
48
+ </section>
49
+
50
+
51
+
52
+
53
+ </div>
54
+
55
+ <nav>
56
+ <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>
57
+ </nav>
58
+
59
+ <br class="clear">
60
+
61
+ <footer>
62
+ 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)
63
+ </footer>
64
+
65
+ <script> prettyPrint(); </script>
66
+ <script src="scripts/linenumber.js"> </script>
67
+ </body>
68
+ </html>
@@ -0,0 +1,96 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>JSDoc: Source: helpers/validationHelpers.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/validationHelpers.js</h1>
21
+
22
+
23
+
24
+
25
+
26
+
27
+ <section>
28
+ <article>
29
+ <pre class="prettyprint source linenums"><code>// Reusable validations for ports and environment variables
30
+
31
+ /**
32
+ * Validate a comma-separated list of port mappings in the form "host:container".
33
+ * Examples of valid input: "8080:80, 3000:3000"
34
+ *
35
+ * @param {string} portInput - Comma-separated port mappings
36
+ * @returns {boolean} True when all mappings are valid, false otherwise
37
+ */
38
+ export function validatePorts(portInput) {
39
+ if (!portInput || !portInput.trim()) return false;
40
+ const ports = portInput.split(",").map(p => p.trim()).filter(Boolean);
41
+ if (ports.length === 0) return false;
42
+ const invalid = ports.find(pair => {
43
+ const [host, cont] = pair.split(":");
44
+ return !host || !cont || isNaN(Number(host)) || isNaN(Number(cont));
45
+ });
46
+ return !invalid;
47
+ }
48
+
49
+ /**
50
+ * Validate environment variable input as comma-separated VAR=value pairs.
51
+ * Empty or whitespace-only input is considered valid (no env vars).
52
+ * Variable names must start with a letter or underscore and contain only
53
+ * alphanumeric characters and underscores.
54
+ *
55
+ * @param {string} envInput - Comma-separated environment variable assignments
56
+ * @returns {boolean} True when all env var assignments are valid, false otherwise
57
+ */
58
+ export function validateEnvVars(envInput) {
59
+ if (!envInput || !envInput.trim()) return true; // Empty is valid
60
+
61
+ const vars = envInput.split(",").map(v => v.trim()).filter(Boolean);
62
+ const invalid = vars.find(v => {
63
+ const parts = v.split("=");
64
+ // Must have at least VAR=value format
65
+ if (parts.length &lt; 2) return true;
66
+ const varName = parts[0].trim();
67
+ // Variable names should be alphanumeric with underscores
68
+ if (!/^[A-Z_][A-Z0-9_]*$/i.test(varName)) return true;
69
+ return false;
70
+ });
71
+
72
+ return !invalid;
73
+ }
74
+ </code></pre>
75
+ </article>
76
+ </section>
77
+
78
+
79
+
80
+
81
+ </div>
82
+
83
+ <nav>
84
+ <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>
85
+ </nav>
86
+
87
+ <br class="clear">
88
+
89
+ <footer>
90
+ 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)
91
+ </footer>
92
+
93
+ <script> prettyPrint(); </script>
94
+ <script src="scripts/linenumber.js"> </script>
95
+ </body>
96
+ </html>
@@ -0,0 +1,120 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>JSDoc: Source: hooks/creation/useContainerActions.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: hooks/creation/useContainerActions.js</h1>
21
+
22
+
23
+
24
+
25
+
26
+
27
+ <section>
28
+ <article>
29
+ <pre class="prettyprint source linenums"><code>import { useState } from "react";
30
+ import { safeCall } from "../../helpers/safeCall";
31
+ import { startContainer as svcStartContainer, stopContainer as svcStopContainer, restartContainer as svcRestartContainer, removeContainer as svcRemoveContainer } from "../../helpers/dockerService/serviceComponents/containerActions.js";
32
+
33
+ /**
34
+ * Custom hook to manage container actions (start, stop, restart, remove).
35
+ * Handles feedback messages and exposes helpers for each action.
36
+ *
37
+ * @param {Object} params
38
+ * @param {Array} params.containers - List of containers
39
+ * @param {Function} params.onAction - Callback after action is performed
40
+ * @returns {Object} Action helpers and feedback state
41
+ */
42
+ export function useContainerActions({ containers, onAction }) {
43
+ const [message, setMessage] = useState("");
44
+ const [messageColor, setMessageColor] = useState("yellow");
45
+
46
+ /**
47
+ * Handles a generic container action and sets feedback.
48
+ * @param {Function} actionFn - The async action function (start, stop, etc)
49
+ * @param {string} actionLabel - Action label for feedback
50
+ * @param {number} selected - Index of selected container
51
+ * @param {Function} [stateCheck] - Optional function to check state before action
52
+ */
53
+ async function handleAction({ actionFn, actionLabel, selected, stateCheck }) {
54
+ const container = containers[selected];
55
+ if (!container) return;
56
+ if (stateCheck) {
57
+ const checkMsg = stateCheck(container);
58
+ if (checkMsg) {
59
+ setMessage(checkMsg);
60
+ setMessageColor("yellow");
61
+ return;
62
+ }
63
+ }
64
+ setMessage(`${actionLabel} container...`);
65
+ setMessageColor("yellow");
66
+ try {
67
+ await actionFn(container.id);
68
+ setMessage(`${actionLabel} container successful.`);
69
+ setMessageColor("green");
70
+ safeCall(onAction);
71
+ } catch (err) {
72
+ setMessage(`Failed to ${actionLabel.toLowerCase()} container: ${err.message}`);
73
+ setMessageColor("red");
74
+ }
75
+ }
76
+
77
+ return {
78
+ message,
79
+ setMessage,
80
+ messageColor,
81
+ setMessageColor,
82
+ handleAction,
83
+ // Expose concrete actions so callers can use actions.startContainer(id)
84
+ startContainer: async (id) => {
85
+ return await svcStartContainer(id);
86
+ },
87
+ stopContainer: async (id) => {
88
+ return await svcStopContainer(id);
89
+ },
90
+ restartContainer: async (id) => {
91
+ return await svcRestartContainer(id);
92
+ },
93
+ removeContainer: async (id) => {
94
+ return await svcRemoveContainer(id);
95
+ },
96
+ };
97
+ }
98
+ </code></pre>
99
+ </article>
100
+ </section>
101
+
102
+
103
+
104
+
105
+ </div>
106
+
107
+ <nav>
108
+ <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>
109
+ </nav>
110
+
111
+ <br class="clear">
112
+
113
+ <footer>
114
+ 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)
115
+ </footer>
116
+
117
+ <script> prettyPrint(); </script>
118
+ <script src="scripts/linenumber.js"> </script>
119
+ </body>
120
+ </html>