capiploy2 v3.0.0
Capiploy: A Modular Deployment Tool
Capiploy is an interactive CLI tool designed to simplify the deployment process for individual modules and predefined module groups. Built with flexibility in mind, it allows you to create, execute, and manage deployment tasks efficiently.
Features
- Module Deployment: Deploy individual modules with custom logic.
- Group Deployment: Combine and deploy multiple modules in predefined groups.
- Dynamic Module Management: Create new modules and groups on the fly.
- Interactive Menu: Navigate and deploy through a visually rich terminal interface.
- Error Handling: Detailed error messages for failed tasks.
- Logs: Automatically log all deployment activities.
Prerequisites
1. Software Requirements
- Node.js (16+ recommended)
- npm (for dependency management)
2. Permissions
Ensure you have appropriate permissions to execute system-level commands required for deployment.
Project Structure
.
├── deploy.js # Main script to run Capiploy
├── package.json # Project configuration
├── README.md # Documentation
└── system
├── functions.js # Core utilities for deployment
└── templates
├── deploy_modules_template.js # Template for defining modules and groups
└── module_template.js # Template for creating new modules
Installation
Local Installation
Clone the repository:
git clone git@gitlab.com\:carloshsilva1989/capiploy.git cd capiploy
Install dependencies:
npm install
Run Capiploy locally:
node deploy.js
Global Installation
Install Capiploy globally via npm:
npm install -g capiploy
After global installation, you can run the tool from anywhere using the command:
capi
Configuration
1. Module Definition
Modules are defined in system/templates/deploy_modules_template.js
. Add your modules in the MODULES
array:
export const MODULES = [
{ name: "backend", path: "modules/backend.js" },
{ name: "frontend", path: "modules/frontend.js" },
];
2. Group Definition
Groups are combinations of modules and are defined in the GROUPS
array:
export const GROUPS = [
{ name: "Full Deployment", modules: ["modules/backend.js", "modules/frontend.js"] },
];
3. Module Template
Create new modules using module_template.js
:
import { runTasks } from '../system/functions.js';
export async function deploy() {
await runTasks('backend', [
{ description: 'Pull latest changes', command: 'git pull origin main' },
{ description: 'Restart server', command: 'systemctl restart backend.service' },
]);
}
4. Credentials Configuration
Configure your remote credentials in system/remote_credentials.json
:
{
"host": "your_remote_host",
"username": "your_remote_username",
"privateKeyPath": "/path/to/your/private/key"
}
Ensure your SSH private key is added to the ~/.ssh/authorized_keys
file on the remote server.
Usage
Start Capiploy:
capi
Navigate the Menu:
----------------------------------------- Capiploy Deployment Tool ----------------------------------------- 1) Deploy Backend 2) Deploy Frontend 3) Deploy Full Deployment 4) Exit ----------------------------------------- Select an option:
Add New Modules or Groups: Use the built-in options to create new modules or groups dynamically.
Logs
All deployment activities are logged to logs/deploy.log
for audit and troubleshooting purposes.
Example Workflow
1. Define a New Module
Create a new module in modules/backend.js
:
import { runTasks } from '../system/functions.js';
export async function deploy() {
await runTasks('backend', [
{ description: 'Pull latest code', command: 'git pull origin main' },
{ description: 'Restart backend service', command: 'sudo systemctl restart backend' },
]);
}
Add the module to deploy_modules_template.js
:
export const MODULES = [
{ name: "backend", path: "modules/backend.js" },
];
2. Run Deployment
Launch Capiploy and select "Deploy Backend" from the menu.
Contributing
- Fork the repository.
- Create a feature branch:
git checkout -b feature/your-feature
- Commit your changes:
git commit -m "Add your feature"
- Push and create a pull request.
License
Capiploy is released under the MIT License. See LICENSE for details.