cdd-cli 3.0.0 → 3.0.1
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/LICENSE +23 -0
- package/README.md +14 -3
- package/docs/en/README.md +167 -0
- package/package.json +1 -1
- package/src/App.jsx +11 -0
- package/src/components/ContainerList.jsx +13 -0
- package/src/helpers/dockerActions.js +13 -0
- package/src/helpers/dockerService.js +12 -0
- package/src/hooks/useContainers.js +10 -0
- package/src/index.js +13 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
SPDX-License-Identifier: MIT
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2025 caertos
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -149,9 +149,18 @@ CDD-CLI es una herramienta de línea de comandos (CLI) multiplataforma que te pe
|
|
|
149
149
|
```
|
|
150
150
|
|
|
151
151
|
## Uso
|
|
152
|
-
- Al ejecutar `cdd`, verás una tabla con todos tus contenedores Docker.
|
|
152
|
+
- Al ejecutar `cdd`, verás una tabla interactiva con todos tus contenedores Docker.
|
|
153
153
|
- Los contenedores en ejecución muestran estadísticas de CPU y memoria en tiempo real.
|
|
154
|
-
-
|
|
154
|
+
- Puedes navegar usando las flechas ↑/↓ y controlar los contenedores con atajos de teclado.
|
|
155
|
+
- Usa `Ctrl+C` o la tecla `Q` para salir.
|
|
156
|
+
|
|
157
|
+
### ⌨️ Atajos de teclado
|
|
158
|
+
|
|
159
|
+
- ↑ / ↓ : Navegar entre contenedores
|
|
160
|
+
- I : Iniciar el contenedor seleccionado
|
|
161
|
+
- P : Parar el contenedor seleccionado
|
|
162
|
+
- L : Ver logs en tiempo real del contenedor seleccionado
|
|
163
|
+
- Q : Salir del dashboard o de la vista de logs
|
|
155
164
|
|
|
156
165
|
## Funcionalidades principales
|
|
157
166
|
- 🐳 Visualización clara y compacta de todos los contenedores.
|
|
@@ -200,8 +209,10 @@ CDD-CLI is a cross-platform command-line tool (CLI) to monitor and visualize you
|
|
|
200
209
|
|
|
201
210
|
## Main features
|
|
202
211
|
- 🐳 Clear, compact visualization of all containers.
|
|
203
|
-
- 🔄 Automatic data refresh.
|
|
212
|
+
- 🔄 Automatic data refresh (every 2 seconds).
|
|
213
|
+
- ⌨️ Keyboard shortcuts for fast actions (navigate, start, stop, logs, quit).
|
|
204
214
|
- 📊 Live resource usage stats for running containers.
|
|
215
|
+
- 🪵 Real-time log streaming for selected containers.
|
|
205
216
|
- 🎨 Visual interface with colors and emojis for states.
|
|
206
217
|
- 👤 Author: Carlos Cochero (2025)
|
|
207
218
|
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# README (ENGLISH)
|
|
2
|
+
*Generated: 2025-10-13*
|
|
3
|
+
|
|
4
|
+
## Table of Contents
|
|
5
|
+
- [Project Scope](#project-scope)
|
|
6
|
+
- [Objectives & Roadmap](#objectives--roadmap)
|
|
7
|
+
- [Requirements](#requirements)
|
|
8
|
+
- [Installation](#installation)
|
|
9
|
+
- [Quick Start](#quick-start)
|
|
10
|
+
- [Use Cases](#use-cases)
|
|
11
|
+
- [Technical Documentation](#technical-documentation)
|
|
12
|
+
- [API Reference](#api-reference)
|
|
13
|
+
- [License](#license)
|
|
14
|
+
- [Contributing](#contributing)
|
|
15
|
+
- [Code of Conduct](#code-of-conduct)
|
|
16
|
+
- [Changelog](#changelog)
|
|
17
|
+
- [FAQ](#faq)
|
|
18
|
+
- [Publishing & Maintenance](#publishing--maintenance)
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Project Scope
|
|
23
|
+
This project is a cross-platform CLI tool for managing Docker containers with real-time log streaming and keyboard shortcuts. It is designed for developers and DevOps engineers who need fast, scriptable, and interactive container management from the terminal.
|
|
24
|
+
|
|
25
|
+
**What it does:**
|
|
26
|
+
- Lists, starts, stops, and removes Docker containers.
|
|
27
|
+
- Streams logs in real time.
|
|
28
|
+
- Provides keyboard shortcuts for common actions.
|
|
29
|
+
- Offers feedback and stats in the terminal.
|
|
30
|
+
|
|
31
|
+
**What it does NOT do:**
|
|
32
|
+
- Does not replace Docker Compose or advanced orchestration tools.
|
|
33
|
+
- Does not manage images or networks directly.
|
|
34
|
+
- No GUI; terminal only.
|
|
35
|
+
|
|
36
|
+
## Objectives & Roadmap
|
|
37
|
+
**Short-term (3 months):**
|
|
38
|
+
- Polish CLI UX and error handling.
|
|
39
|
+
- Add more keyboard shortcuts.
|
|
40
|
+
- Improve documentation and add more use cases.
|
|
41
|
+
|
|
42
|
+
**Medium-term (6 months):**
|
|
43
|
+
- Add plugin system for custom actions.
|
|
44
|
+
- Support for container stats export (JSON/CSV).
|
|
45
|
+
- Integration with CI/CD pipelines.
|
|
46
|
+
|
|
47
|
+
**Known limitations:**
|
|
48
|
+
- Requires Docker daemon running locally.
|
|
49
|
+
- Only supports local containers (no remote).
|
|
50
|
+
- Limited to Node.js LTS versions.
|
|
51
|
+
|
|
52
|
+
## Requirements
|
|
53
|
+
| Requirement | Minimum | Recommended |
|
|
54
|
+
|--------------------|----------------|-----------------|
|
|
55
|
+
| Node.js | 16.x | 18.x+ |
|
|
56
|
+
| npm | 7.x | 8.x+ |
|
|
57
|
+
| OS | Linux, macOS, Windows | Linux, macOS |
|
|
58
|
+
| Docker | 20.x | Latest stable |
|
|
59
|
+
| Permissions | Docker group or sudo | Docker group |
|
|
60
|
+
|
|
61
|
+
**Development:**
|
|
62
|
+
- ESLint, Prettier
|
|
63
|
+
- Jest or Mocha for tests
|
|
64
|
+
- GitHub Actions for CI
|
|
65
|
+
|
|
66
|
+
**Production:**
|
|
67
|
+
- Only Node.js and Docker required
|
|
68
|
+
|
|
69
|
+
## Installation
|
|
70
|
+
### Global install
|
|
71
|
+
```bash
|
|
72
|
+
npm install -g cdd-cli
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Update
|
|
76
|
+
```bash
|
|
77
|
+
npm update -g cdd-cli
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Uninstall
|
|
81
|
+
```bash
|
|
82
|
+
npm uninstall -g cdd-cli
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Check version
|
|
86
|
+
```bash
|
|
87
|
+
cdd -v
|
|
88
|
+
cdd --version
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
#### Notes
|
|
92
|
+
- On Linux/macOS, you may need `sudo` for global install.
|
|
93
|
+
- Ensure your global npm bin is in your PATH.
|
|
94
|
+
- On Windows, use an Administrator terminal if needed.
|
|
95
|
+
|
|
96
|
+
## Quick Start
|
|
97
|
+
```bash
|
|
98
|
+
cdd list
|
|
99
|
+
cdd logs <container>
|
|
100
|
+
cdd start <container>
|
|
101
|
+
cdd stop <container>
|
|
102
|
+
cdd remove <container>
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Use Cases
|
|
106
|
+
1. **List all containers**
|
|
107
|
+
- `cdd list`
|
|
108
|
+
- *Shows all containers with status.*
|
|
109
|
+
2. **Start a container**
|
|
110
|
+
- `cdd start my_container`
|
|
111
|
+
- *Starts the specified container.*
|
|
112
|
+
3. **Stop a container**
|
|
113
|
+
- `cdd stop my_container`
|
|
114
|
+
- *Stops the specified container.*
|
|
115
|
+
4. **Stream logs in real time**
|
|
116
|
+
- `cdd logs my_container`
|
|
117
|
+
- *Shows live logs with color highlighting.*
|
|
118
|
+
5. **Remove a container**
|
|
119
|
+
- `cdd remove my_container`
|
|
120
|
+
- *Deletes the container after confirmation.*
|
|
121
|
+
6. **Use keyboard shortcuts**
|
|
122
|
+
- While viewing logs, press `q` to quit, `r` to restart, etc.
|
|
123
|
+
|
|
124
|
+
## Technical Documentation
|
|
125
|
+
See inline JSDoc comments in source files. Example:
|
|
126
|
+
```js
|
|
127
|
+
/**
|
|
128
|
+
* Start a Docker container by name.
|
|
129
|
+
* @param {string} name - Container name
|
|
130
|
+
* @returns {Promise<boolean>} True if started
|
|
131
|
+
* @throws {Error} If Docker is not running
|
|
132
|
+
* @example
|
|
133
|
+
* await startContainer('my_container');
|
|
134
|
+
*/
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## API Reference
|
|
138
|
+
See [API Reference](./api.md) for all exported functions and CLI commands.
|
|
139
|
+
|
|
140
|
+
## License
|
|
141
|
+
MIT License. See [LICENSE](../../LICENSE).
|
|
142
|
+
|
|
143
|
+
## Contributing
|
|
144
|
+
See [CONTRIBUTING.md](../../CONTRIBUTING.md).
|
|
145
|
+
|
|
146
|
+
## Code of Conduct
|
|
147
|
+
See [CODE_OF_CONDUCT.md](../../CODE_OF_CONDUCT.md).
|
|
148
|
+
|
|
149
|
+
## Changelog
|
|
150
|
+
See [CHANGELOG.md](../../CHANGELOG.md).
|
|
151
|
+
|
|
152
|
+
## FAQ
|
|
153
|
+
- **Does it work with Docker Desktop?**
|
|
154
|
+
- Yes, as long as Docker CLI is available.
|
|
155
|
+
- **Can I use it in CI?**
|
|
156
|
+
- Yes, see examples below.
|
|
157
|
+
- **How do I add my own commands?**
|
|
158
|
+
- Plugin system coming soon.
|
|
159
|
+
|
|
160
|
+
## Publishing & Maintenance
|
|
161
|
+
To publish to npm:
|
|
162
|
+
```bash
|
|
163
|
+
npm login
|
|
164
|
+
npm publish --access public
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Keep documentation updated with every release. See CONTRIBUTING.md for details.
|
package/package.json
CHANGED
package/src/App.jsx
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Main React component for the CDD CLI UI.
|
|
3
|
+
* Componente principal de React para la UI del CLI CDD.
|
|
4
|
+
*
|
|
5
|
+
* @component
|
|
6
|
+
* @returns {JSX.Element} The rendered app / La app renderizada
|
|
7
|
+
* @example
|
|
8
|
+
* // EN: Render the app
|
|
9
|
+
* // ES: Renderizar la app
|
|
10
|
+
* <App />
|
|
11
|
+
*/
|
|
1
12
|
import React from "react";
|
|
2
13
|
import { Box, Text, Spacer } from "ink";
|
|
3
14
|
import { useContainers } from "./hooks/useContainers";
|
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* List component for Docker containers.
|
|
3
|
+
* Componente de lista para contenedores Docker.
|
|
4
|
+
*
|
|
5
|
+
* @component
|
|
6
|
+
* @param {Object} props - Component props / Props del componente
|
|
7
|
+
* @param {Array} props.containers - Containers to display / Contenedores a mostrar
|
|
8
|
+
* @returns {JSX.Element} Rendered list / Lista renderizada
|
|
9
|
+
* @example
|
|
10
|
+
* // EN: Render with containers
|
|
11
|
+
* // ES: Renderizar con contenedores
|
|
12
|
+
* <ContainerList containers={containers} />
|
|
13
|
+
*/
|
|
1
14
|
import React from "react";
|
|
2
15
|
import { Box, Text } from "ink";
|
|
3
16
|
import ContainerRow from "./ContainerRow";
|
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run a Docker action by name (start, stop, remove).
|
|
3
|
+
* Ejecuta una acción Docker por nombre (start, stop, remove).
|
|
4
|
+
*
|
|
5
|
+
* @param {string} action - Action to perform / Acción a realizar
|
|
6
|
+
* @param {string} container - Container name / Nombre del contenedor
|
|
7
|
+
* @returns {Promise<boolean>} True if successful / True si es exitoso
|
|
8
|
+
* @throws {Error} If Docker is not running / Si Docker no está corriendo
|
|
9
|
+
* @example
|
|
10
|
+
* // EN: Start a container
|
|
11
|
+
* // ES: Iniciar un contenedor
|
|
12
|
+
* await runDockerAction('start', 'my_container');
|
|
13
|
+
*/
|
|
1
14
|
import { spawn } from "child_process";
|
|
2
15
|
|
|
3
16
|
/**
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility to interact with Docker CLI.
|
|
3
|
+
* Utilidad para interactuar con el CLI de Docker.
|
|
4
|
+
*
|
|
5
|
+
* @param {string} cmd - Docker command / Comando Docker
|
|
6
|
+
* @returns {Promise<string>} Output from Docker / Salida de Docker
|
|
7
|
+
* @throws {Error} If command fails / Si el comando falla
|
|
8
|
+
* @example
|
|
9
|
+
* // EN: Run a Docker command
|
|
10
|
+
* // ES: Ejecutar un comando Docker
|
|
11
|
+
* await dockerService('ps -a');
|
|
12
|
+
*/
|
|
1
13
|
|
|
2
14
|
import Docker from "dockerode";
|
|
3
15
|
const docker = new Docker({ socketPath: "/var/run/docker.sock" });
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React hook to manage Docker containers state.
|
|
3
|
+
* Hook de React para gestionar el estado de contenedores Docker.
|
|
4
|
+
*
|
|
5
|
+
* @returns {[Array, Function]} [containers, refresh] / [contenedores, refrescar]
|
|
6
|
+
* @example
|
|
7
|
+
* // EN: Use in a component
|
|
8
|
+
* // ES: Usar en un componente
|
|
9
|
+
* const [containers, refresh] = useContainers();
|
|
10
|
+
*/
|
|
1
11
|
import React, { useState, useEffect } from "react";
|
|
2
12
|
import { getContainers } from "../helpers/dockerService";
|
|
3
13
|
|
package/src/index.js
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Entry point for the CDD CLI application.
|
|
5
|
+
* Punto de entrada para la aplicación CLI de CDD.
|
|
6
|
+
*
|
|
7
|
+
* @module index
|
|
8
|
+
* @example
|
|
9
|
+
* // EN: Run the CLI
|
|
10
|
+
* // ES: Ejecutar el CLI
|
|
11
|
+
* node index.js
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
|
|
2
15
|
import React from "react";
|
|
3
16
|
import { render } from "ink";
|
|
4
17
|
import App from './App';
|