cdd-cli 3.1.7 → 3.1.9
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/.eslintrc.json +1 -1
- package/.github/workflows/ci.yml +3 -0
- package/.github/workflows/docs.yml +8 -1
- package/CHANGELOG.md +23 -0
- package/CONTRIBUTING.md +28 -15
- package/README.md +56 -88
- package/babel.config.cjs +18 -1
- package/dist/components/ContainerRow.js +5 -78
- package/dist/components/LogViewer.js +4 -9
- package/dist/helpers/containerOptionsBuilder.js +58 -0
- package/dist/hooks/creation/useContainerCreation.js +16 -1
- package/dist/hooks/debug/useDebugLogs.js +46 -0
- package/dist/hooks/navigation/useContainerSelection.js +36 -0
- package/dist/hooks/useContainerCommandRouter.js +151 -0
- package/dist/{helpers/actionHelpers.js → hooks/useContainerStats.js} +76 -78
- package/dist/hooks/useControls.js +83 -342
- package/dist/hooks/useEraseConfirmation.js +47 -0
- package/dist/hooks/useExitHandler.js +68 -0
- package/jest.config.cjs +1 -1
- package/package.json +2 -3
- package/src/components/ContainerRow.jsx +3 -38
- package/src/components/LogViewer.jsx +4 -10
- package/src/helpers/containerOptionsBuilder.js +42 -0
- package/src/hooks/creation/useContainerCreation.js +15 -0
- package/src/hooks/debug/useDebugLogs.js +29 -0
- package/src/hooks/navigation/useContainerSelection.js +25 -0
- package/src/hooks/useContainerCommandRouter.js +110 -0
- package/src/hooks/useContainerStats.js +44 -0
- package/src/hooks/useControls.js +68 -272
- package/src/hooks/useEraseConfirmation.js +39 -0
- package/src/hooks/useExitHandler.js +66 -0
- package/test/useContainerCreation.dom.test.js +3 -0
- package/.babelrc +0 -6
- package/FIXES_APPLIED.md +0 -419
- package/SECURITY.md +0 -5
- package/dist/hooks/useLogsStream.js +0 -41
- package/docs/_config.yml +0 -13
- package/docs/components_ContainerCreationPrompt.jsx.html +0 -114
- package/docs/components_ContainerRow.jsx.html +0 -151
- package/docs/components_ContainerSection.jsx.html +0 -75
- package/docs/components_Footer.jsx.html +0 -66
- package/docs/components_Header.jsx.html +0 -84
- package/docs/components_LogViewer.jsx.html +0 -91
- package/docs/components_MessageFeedback.jsx.html +0 -76
- package/docs/components_PromptField.jsx.html +0 -99
- package/docs/components_StatsBar.jsx.html +0 -105
- package/docs/components_UsageMenu.jsx.html +0 -73
- package/docs/fonts/OpenSans-Bold-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Bold-webfont.svg +0 -1830
- package/docs/fonts/OpenSans-Bold-webfont.woff +0 -0
- package/docs/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-BoldItalic-webfont.svg +0 -1830
- package/docs/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Italic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Italic-webfont.svg +0 -1830
- package/docs/fonts/OpenSans-Italic-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Light-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Light-webfont.svg +0 -1831
- package/docs/fonts/OpenSans-Light-webfont.woff +0 -0
- package/docs/fonts/OpenSans-LightItalic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-LightItalic-webfont.svg +0 -1835
- package/docs/fonts/OpenSans-LightItalic-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Regular-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Regular-webfont.svg +0 -1831
- package/docs/fonts/OpenSans-Regular-webfont.woff +0 -0
- package/docs/global.html +0 -6145
- package/docs/helpers_actionHelpers.js.html +0 -94
- package/docs/helpers_constants.js.html +0 -81
- package/docs/helpers_dockerService_dockerService.js.html +0 -79
- package/docs/helpers_dockerService_serviceComponents_containerActions.js.html +0 -153
- package/docs/helpers_dockerService_serviceComponents_containerList.js.html +0 -81
- package/docs/helpers_dockerService_serviceComponents_containerLogs.js.html +0 -85
- package/docs/helpers_dockerService_serviceComponents_containerStats.js.html +0 -107
- package/docs/helpers_dockerService_serviceComponents_imageUtils.js.html +0 -82
- package/docs/helpers_exitWithMessage.js.html +0 -77
- package/docs/helpers_safeCall.js.html +0 -68
- package/docs/helpers_validationHelpers.js.html +0 -96
- package/docs/hooks_creation_useContainerActions.js.html +0 -120
- package/docs/hooks_creation_useContainerCreation.js.html +0 -152
- package/docs/hooks_creation_useLogsViewer.js.html +0 -102
- package/docs/hooks_useControls.js.html +0 -298
- package/docs/hooks_useLogsStream.js.html +0 -82
- package/docs/index.html +0 -65
- package/docs/index.js.html +0 -65
- package/docs/module-index.html +0 -171
- package/docs/scripts/linenumber.js +0 -25
- package/docs/scripts/prettify/Apache-License-2.0.txt +0 -202
- package/docs/scripts/prettify/lang-css.js +0 -2
- package/docs/scripts/prettify/prettify.js +0 -28
- package/docs/styles/jsdoc-default.css +0 -358
- package/docs/styles/prettify-jsdoc.css +0 -111
- package/docs/styles/prettify-tomorrow.css +0 -132
- package/esbuild.config.cjs +0 -11
- package/src/helpers/actionHelpers.js +0 -52
- package/src/hooks/useLogsStream.js +0 -31
- package/test/actionHelpers.test.js +0 -106
|
@@ -1,94 +0,0 @@
|
|
|
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<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 && 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>
|
|
@@ -1,81 +0,0 @@
|
|
|
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>
|
|
@@ -1,79 +0,0 @@
|
|
|
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>
|
|
@@ -1,153 +0,0 @@
|
|
|
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<T>} promise - Promise to wrap
|
|
39
|
-
* @param {number} [ms=TIMEOUTS.CONTAINER_OP] - Timeout in milliseconds
|
|
40
|
-
* @returns {Promise<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<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<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<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<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<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>
|
|
@@ -1,81 +0,0 @@
|
|
|
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<Array<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 && 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>
|
|
@@ -1,85 +0,0 @@
|
|
|
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>
|