nitor
v1.4.2
Published
A comprehensive CLI toolkit for automating GitLab operations, AI-powered code review, build/deploy automation, MongoDB backup/restore, and developer productivity tools
Maintainers
Readme
nitor
A CLI utility toolkit for automating and managing build, deploy, and status operations for projects, AI code review, AI text refactor and related components.
Features
- Build and deploy Gitlab project
- Check build and deployment status
- Utility functions for parameter parsing and object cleaning
- Extensible and scriptable for automation
- Create git branch
- AI Review merge request
- AI text refactoring
- Backup and restore MongoDB
- Merge git branches
- Cleanup local git branches
- Time entry management with Zoho integration
- GitLab activity tracking
- Task statistics with merge request details
- Extract Zoho task IDs from GitLab issue descriptions
- Merge request status tracking for active tasks
Requirements
- Node.js >= 14.x
- npm >= 6.x
- A properly configured
.env.nufile in your~/Desktopdirectory with required tokens and URLs:CSRF_TOKEN- CSRF token for Gitlab (Copy from browser)COOKIE- Cookie for Gitlab (Copy from browser)GITLAB_URI- GitLab API URL, eg:https://gitlab.com/GITLAB_TOKEN- Gitlab tokenGITLAB_DEFAULT_PROJECT_ID- Default GitLab project ID for issue lookupsMR_PROMPT- Merge request promptMR_LANG- Merge request languageAI_API_KEY- AI API keyAI_MODEL- AI modelBACKUP_CONFIG- Backup configurationRESTORE_CONFIG- Restore configurationZOHO_COOKIE- Zoho cookie for authenticationZOHO_CUSTOMVIEW_ID- Zoho custom view IDZOHO_DEFAULT_PROJECT_ID- Default Zoho project IDZOHO_PORTAL_ID- Zoho portal IDZOHO_PROJECTS- Zoho projects configurationZOHO_SESSION_ID- Zoho session IDZOHO_SOURCE- Zoho sourceZOHO_TEAM- Zoho team IDZOHO_TOKEN- Zoho CSRF tokenZOHO_URI- Zoho API URLZOHO_USERID- Zoho user ID
Installation
After installing the package globally, you can enable autocomplete:
nitor completionThis will add autocomplete support to your shell. Restart your terminal or run:
source ~/.bashrc # for bash
source ~/.zshrc # for zshUsage
You can use the CLI via the nitor command:
nitor <command> [options]Autocomplete
Once enabled, you can use Tab to autocomplete:
- Commands (build, deploy, cleanup, etc.)
- Options (-project, -components, etc.)
- Values (portal, gateway, dev, qa, etc.)
Example Commands
Build:
nitor build -project <project name> -components <component name> -instance <instance name>Deploy:
nitor deploy -project <project name> -components <component name> -instance <instance name>Build & Deploy:
nitor build-deploy -project <project name> -components <component name> -instance <instance name>Create branch:
nitor create-branch -task <task number> -type <feat|fix> -description <description> -repository <repository name>Review:
nitor review -project <project short name> -mergeId <merge id> -repository <repository name>Refactor Text:
nitor refactor <text>MongoDB Backup & Restore:
# Backup from Kubernetes pods and restore to local MongoDB nitor backup # Backup specific projects only nitor backup -project <project1> <project2> # Restore to Docker container (default: local MongoDB) nitor backup -docker <boolean>Merge:
nitor merge -source <source branch> -target <target branch>Cleanup:
nitor cleanupTime Entry - Initialize:
nitor time-initTime Entry - Add:
nitor time-add -project <project name> -sprint <sprint name> -task <task id> -date <YYYY-MM-DD> -work <work description> -duration <minutes> -remarks <remarks>Time Entry - Update:
nitor time-update -id <entry id> -task <task id> -work <work description> -duration <minutes> -remarks <remarks> -date <YYYY-MM-DD>Time Entry - Delete:
nitor time-delete -id <entry id> -date <YYYY-MM-DD>Time Entry - View Entries:
nitor time-entries -from <YYYY-MM-DD> -to <YYYY-MM-DD>Time Entry - View Stats:
nitor time-stats -from <YYYY-MM-DD> -to <YYYY-MM-DD>Time Entry - Sync to Zoho:
nitor time-zohoTime Entry - GitLab Activities:
nitor time-gitlab -from <YYYY-MM-DD> -to <YYYY-MM-DD>Time Entry - Merge Request Status:
nitor time-mergeTime Entry - Switch Project:
nitor time-switchTask Stats:
nitor task-stats -task <task numbers with space>Get Task (Extract Zoho Task IDs):
nitor get-task -task <task numbers with space>
Command Reference
build: Build specified componentsdeploy: Deploy specified componentsbuild-deploy: Build and then deployversion: Show version infohelp: Show helpinit: Initialize configurationcreate-branch: Create git branchreview: AI review specified merge requestrefactor: AI refactor specified textbackup: Backup MongoDB databases from Kubernetes pods and restore to local/Dockermerge: Merge source branch into target branchcleanup: Cleanup local git branches (checkout to master and delete all other branches)time-init: Initialize time entry configurationtime-add: Add time entry with support for multiple tagstime-update: Update existing time entrytime-delete: Delete time entrytime-entries: View time entries by date rangetime-stats: View daily statistics of time entriestime-zoho: Sync time entries to Zohotime-gitlab: Get GitLab activities for a date rangetime-merge: View merge request status for active taskstime-switch: Switch between default projectstask-stats: View task statistics with GitLab merge request detailsget-task: Extract Zoho task IDs from GitLab issue descriptions
MongoDB Backup & Restore
Overview
The MongoDB backup service provides automated backup and restore functionality for MongoDB databases running in Kubernetes pods. It supports:
- ✅ Backup from Kubernetes pods using
kubectl - ✅ Restore to Docker containers or local MongoDB instances
- ✅ Cross-platform support (Windows, macOS, Linux)
- ✅ Multi-project configuration
- ✅ Automatic cleanup of temporary files
- ✅ Error handling with detailed logging
Configuration
Configure your backup settings in the .env.nu file using JSON format:
BACKUP_CONFIG
Defines the source databases to backup from Kubernetes pods:
BACKUP_CONFIG={
"project1": [
{
"pod": "mongodb-pod-name",
"username": "admin",
"password": "password123",
"database": "mydb",
"backupPath": "/data/backup",
"localBackupPath": "~/backups/mongo"
}
],
"project2": [
{
"pod": "another-pod",
"username": "dbuser",
"password": "dbpass",
"database": "anotherdb"
}
]
}Configuration Options:
pod(required): Name of the Kubernetes podusername(required): MongoDB usernamepassword(required): MongoDB passworddatabase(required): Database namebackupPath(optional): Path inside pod for temporary backup (default:/data/backup)localBackupPath(optional): Local path to store backups (default:~/backups/mongo)
RESTORE_CONFIG
Defines where to restore the backup:
RESTORE_CONFIG={
"mongoInDocker": false,
"containerName": "mongodb",
"localBackupPath": "~/backups/mongo",
"containerBackupPath": "/data/backup"
}Configuration Options:
mongoInDocker(optional): Set totrueto restore to Docker container,falsefor local MongoDB (can be overridden with-dockerflag)containerName(optional): Docker container name (default:mongodb)localBackupPath(optional): Path where backup is stored (default:~/backups/mongo)containerBackupPath(optional): Path inside container for temporary files (default:/data/backup)
How It Works
Backup Phase:
- Executes
mongodumpinside the Kubernetes pod - Copies backup files to your local machine using
kubectl cp - Cleans up temporary files from the pod
- Saves to
~/backups/mongo/<database-name>by default
- Executes
Restore Phase:
- Docker Mode (
-dockerflag):- Copies backup from local machine to Docker container
- Executes
mongorestore --dropinside the container - Cleans up temporary files from container
- Local Mode (default):
- Executes
mongorestore --dropdirectly on local machine - Connects to
mongodb://localhost:27017/
- Executes
- Docker Mode (
Usage Examples
Backup all configured projects:
nitor backupBackup specific projects:
nitor backup -project project1 project2Backup and restore to Docker container:
nitor backup -dockerPrerequisites
- For Backup:
kubectlconfigured with access to your Kubernetes cluster - For Restore (Docker): Docker running with MongoDB container
- For Restore (Local): MongoDB installed and running locally on port 27017
- MongoDB tools (
mongodump,mongorestore) must be available in the pod/container
Cross-Platform Support
The backup service is designed to work on Windows, macOS, and Linux:
- Automatically detects the operating system
- Uses appropriate shell (
cmd.exeon Windows,/bin/shon Unix) - Handles path normalization across platforms
- Adjusts command flags for Windows compatibility (e.g., removes
-itflags)
Error Handling
- Non-zero exit codes from
mongorestoreare treated as warnings (common with duplicate keys) - Detailed error messages with color-coded output
- Continues processing remaining projects even if one fails
- Cleanup operations run even if restore encounters errors
Options
-projector-p: Project name (portal,gateway,phr)-componentsor-c: Components (client,backend, etc.)-instanceor-i: Instance/environment (dev,qa,pilot)-branchor-b: Git branch (optional)-taskor-t: Task number-typeor-ty: Type (feat,fix)-descriptionor-d: Description-repositoryor-r: Repository name-mergeIdor-mId: Merge ID-sourceor-so: Source branch name-targetor-ta: Target branch name
Time Entry Options
-projector-p: Project name-sprintor-s: Sprint name (e.g., "sprint 1")-taskor-t: Task ID-dateor-dt: Date in YYYY-MM-DD format-workor-w: Work description (supports multiple tags)-durationor-du: Duration in minutes-remarksor-r: Additional remarks-idor-i: Entry ID (for update/delete operations)-fromor-f: Start date for filtering-toor-t: End date for filtering
License
ISC
Author
Nithin V ([email protected])
