4.6 KiB
4.6 KiB
GitZone Services Command Implementation Plan
Overview
Implement the gitzone services command to manage MongoDB and MinIO containers for development projects.
Tasks
Module Structure Setup
- Create
ts/mod_services/directory - Create
mod.plugins.tswith required imports - Create
helpers.tswith utility functions - Create
classes.serviceconfiguration.tsfor config handling - Create
classes.dockercontainer.tsfor Docker operations - Create
classes.servicemanager.tsfor service management - Create
index.tswith main command logic
Core Functionality
-
Implement ServiceConfiguration class
- Load/create
.nogit/env.jsonconfiguration - Generate random available ports (20000-30000 range)
- Preserve existing custom values
- Provide default values for missing fields
- Load/create
-
Implement DockerContainer class
- Check container status
- Start/stop/restart containers
- Execute Docker commands
- Handle container logs
- Manage volumes and port bindings
-
Implement ServiceManager class
- Manage MongoDB containers
- Manage MinIO containers
- Handle container lifecycle
- Generate project-specific container names
- Manage data directories in
.nogit/ - Generate MongoDB Compass connection strings
Commands Implementation
startcommand - Start services (mongo|s3|all)stopcommand - Stop services (mongo|s3|all)restartcommand - Restart services (mongo|s3|all)statuscommand - Show service statusconfigcommand - Show current configurationcompasscommand - Show MongoDB Compass connection stringlogscommand - Show service logs with line countremovecommand - Remove containers (preserve data)cleancommand - Remove containers and data
Integration
- Add
@push.rocks/smartshellto main plugins.ts - Add
@push.rocks/smartnetworkto main plugins.ts - Add
@push.rocks/smartinteractionto main plugins.ts - Register services command in
gitzone.cli.ts
Features
- Auto-configuration with smart defaults
- Random port assignment to avoid conflicts
- Project isolation with unique container names
- Data persistence in
.nogit/directories - Status display (running/stopped/not installed)
- Interactive confirmations for destructive operations
- Colored console output
- MinIO bucket auto-creation
- MongoDB Compass connection string with network IP
Testing
- Test service start/stop operations
- Test configuration creation and updates
- Test port collision handling
- Test data persistence
- Test MongoDB Compass connection string generation
- Test all command variations
Configuration Format
{
"PROJECT_NAME": "derived-from-package-name",
"MONGODB_HOST": "localhost",
"MONGODB_NAME": "project-name",
"MONGODB_PORT": "random-port",
"MONGODB_USER": "defaultadmin",
"MONGODB_PASS": "defaultpass",
"S3_HOST": "localhost",
"S3_PORT": "random-port",
"S3_CONSOLE_PORT": "s3-port+1",
"S3_USER": "defaultadmin",
"S3_PASS": "defaultpass",
"S3_BUCKET": "project-name-documents"
}
Command Examples
gitzone services start # Start all services
gitzone services start mongo # Start only MongoDB
gitzone services stop # Stop all services
gitzone services status # Check service status
gitzone services config # Show configuration
gitzone services compass # Show MongoDB Compass connection string
gitzone services logs mongo 50 # Show last 50 lines of MongoDB logs
gitzone services remove # Remove containers (preserve data)
gitzone services clean # Remove containers and data
Progress Notes
Implementation started: 2025-08-14 Implementation completed: 2025-08-14
Summary
Successfully implemented the gitzone services command in TypeScript, providing a complete replacement for the services.sh shell script. The implementation includes:
- Complete Docker service management for MongoDB and MinIO containers
- Smart configuration management with automatic port assignment and conflict avoidance
- MongoDB Compass support with network IP detection for remote connections
- Project isolation using project-specific container names
- Data persistence in
.nogit/directories - Interactive confirmations for destructive operations
- Comprehensive command set including start, stop, restart, status, config, compass, logs, remove, and clean commands
The module is fully integrated into the gitzone CLI and ready for testing.