credflowcli
v1.0.2
Published
๐ CredFlow Ultimate - Enhanced CLI tool for GitLab automation, ERPNext integration, and DevOps workflows
Maintainers
Readme
๐ CredFlow CLI - Ultimate DevOps Automation Tool
A powerful, enterprise-ready command-line tool for automating GitLab workflows, ERPNext integration, and deployment processes.
Built by: Gaurav, Manthan, Sharat
โจ What is CredFlow?
CredFlow is your one-stop solution for automating complex DevOps workflows. Whether you're a beginner or an experienced developer, CredFlow makes it easy to:
- ๐ Create and manage GitLab merge requests with automatic conflict resolution
- ๐ฆ Deploy patches with smart version management (including addon patches)
- ๐ Integrate with ERPNext for software release management
- ๐ข Automate enterprise workflows with TOTP authentication
- ๐ฑ Interactive CLI that guides you through every step
๐ฏ Perfect For
- DevOps Engineers automating deployment pipelines
- Software Developers managing merge requests and releases
- Project Managers tracking software releases in ERPNext
- Enterprise Teams requiring secure, automated workflows
- Beginners who want guided, interactive assistance
๐ Quick Start (5 Minutes!)
Step 1: Installation
Option 1: Install from npm (Recommended)
# Install globally
npm install -g credflowcli
# Verify installation
credflow --versionOption 2: Install from source
# Clone the repository
git clone https://gitlab.credenceanalytics.com/sharatyaragatti/CredflowCLI.git
cd CredflowCLI
# Install dependencies
npm install
# Make CLI globally available
npm linkPrerequisites
Required:
- ๐ฆ Node.js >= 18.0.0
- ๐ GitLab Personal Access Token
- ๐ข ERPNext Credentials (if using ERPNext features)
Optional (for AI-Enhanced Features):
- ๐ค Gemini CLI - For AI-powered tag naming and branch generation
- Install globally:
npm install -g @google/generative-ai-clior use Gemini CLI - Alternative: Set
GEMINI_API_KEYenvironment variable to use API instead - Benefits: Intelligent pattern learning from existing tags, smart branch name generation
- Install globally:
Step 2: Initialize CredFlow
Run the initialization wizard - it will guide you through everything:
credflow initThe wizard will ask for:
- ๐ GitLab URL (e.g.,
https://gitlab.credenceanalytics.com) - ๐ GitLab Personal Access Token (we'll show you how to get one)
- ๐ข ERPNext URL (e.g.,
https://erp.credenceanalytics.com) - ๐ค ERPNext Credentials (username and password)
- ๐ TOTP Setup (optional, for two-factor authentication)
Step 3: Start Using CredFlow!
# Launch interactive menu
credflow
# Or use specific commands
credflow mr --from-mr "https://gitlab.../merge_requests/123" --target preprodThat's it! You're ready to automate your workflows! ๐
๐ Complete Feature Guide
๐ฎ Interactive Mode (Recommended for Beginners)
Simply run credflow to access the interactive menu:
credflowYou'll see options like:
- ๐ฆ Deploy from MR - Automated patch deployment (with Thomas Cook project support!)
- ๐ Create Merge Request - Smart MR creation
- ๐ Create Patch - Generate deployment patches
- ๐ Setup TOTP - Two-factor authentication setup
- ๐ Create Software Release - ERPNext integration
- ๐ท๏ธ Create GitLab Tag (from MR) - Generate release tags from merge requests
- ๐ข Test ERP Login - Verify your credentials
๐ง Command Line Mode (For Power Users)
1. ๐ฆ Deploy from Merge Request (Patch Automation)
Deploy a new development patch:
credflow mr --from-mr "https://gitlab.../merge_requests/123" --target preprodDeploy an addon patch (additional changes to existing deployment):
credflow mr \
--from-mr "https://gitlab.../merge_requests/124" \
--target preprod \
--patch-type addon \
--original-branch "PREPROD-v6.5.0.286_Update_BBPS_SMS_templates"What happens behind the scenes:
- ๐ Extracts project info from MR URL
- ๐ฟ Creates deployment branch with proper naming
- ๐ Applies changes from source MR
- ๐ค Pushes to GitLab
- ๐ฏ Creates new MR for deployment
2. ๐ Create Merge Request
Basic MR creation:
credflow mr --source feature/my-feature --target main --title "Add new feature"Advanced MR with file attachments:
credflow mr \
--source feature/user-auth \
--target main \
--title "Feature: User Authentication" \
--description "Implements JWT-based authentication" \
--files ./documentation \
--report ./test-results.docx \
--push \
--merge3. ๐ Create Software Release in ERPNext
credflow software-release --mr-url "https://gitlab.../merge_requests/123"This will:
- ๐ Extract release information from MR
- ๐ข Login to ERPNext with TOTP
- ๐ Create software release record
- ๐ Attach relevant files
4. ๐ท๏ธ Create GitLab Tag from Merge Request
Create release tags automatically based on merged MRs:
credflow # Then select "๐ท๏ธ Create GitLab Tag (from MR)"What happens:
- ๐ Enter MR URL - Provide the merged MR URL
- ๐ท๏ธ Auto-generate Tag Name - Format:
TARGET-vX.X.X.X_SOURCE_BRANCH_NAME - ๐ Create Release - Optionally create GitLab release with MR description
- ๐ Link Everything - Release includes MR metadata and links
Example Tag Names:
- Source:
release/lrs-rbi_2025_07_16โ Tag:PREPROD-v6.5.0.286_lrs-rbi_2025_07_16 - Source:
feature/new-apiโ Tag:PROD-v6.5.0.287_new-api
Features:
- โ Follows your naming convention (TARGET-vVERSION_DESCRIPTION)
- โ Removes "release/" prefix automatically
- โ Uses target branch for tagging (preprod/prod)
- โ Creates clean tags (no comments/annotations)
- โ Auto-populates release description with MR details
- โ Warns if MR is not merged yet
๐๏ธ Advanced Features
๐ข Thomas Cook Patch Automation (NEW!)
CredFlow automatically detects Thomas Cook projects (mercuryfx/tcil) and uses their specific patch structure and naming conventions.
How It Works
When you use "Deploy from MR" with a Thomas Cook project, CredFlow automatically:
- ๐ Detects the Project Type - Recognizes Thomas Cook projects automatically
- ๐ท๏ธ Uses Proper Tag Format - Follows
MFXSTD_RETAIL_LIVE_X_X_X_XXXnaming convention - ๐ฟ Creates Patch Branch - Branches from UAT/target with cherry-picked commits
- ๐ Generates Correct Structure:
MFXSTD_RETAIL_LIVE_5_0_0_439/ โโโ ReleaseNote.txt (with proper metadata format) โโโ MR_Description.md (template for GitLab) โโโ code/ โ โโโ new/ (modified files) โ โโโ old/ (original files) โโโ script/ โโโ applyscript.sql โโโ revertscript.sql
Example Usage
# Just use the normal Deploy from MR workflow
credflow
# Select: ๐ฆ Deploy from MR
# Enter Thomas Cook project MR URL
# Select target branch (e.g., uat)
# CredFlow will detect it's Thomas Cook and handle the rest!What You Get
- โ Proper ReleaseNote.txt with all required fields
- โ MR description template following Thomas Cook format
- โ Automatic tag versioning (analyzes existing tags)
- โ Cherry-pick support for merge commits
- โ Issue tracking integration
- โ Database change management
- โ Structured patch directory
Thomas Cook ReleaseNote.txt Format
patch_no:MFXSTD_RETAIL_LIVE_5_0_0_439
codebase:1
prev_patch_no:MFXSTD_RETAIL_LIVE_5_0_0_438
release_date:13-10-2025
released_by:Your Name
isaddon:no
parentaddon:MFXSTD_RETAIL_LIVE_5_0_0_439
codechanges:yes
object1:file#filename.jds#Framewrk#0.0.0.1#modify#comment.
total_no_objects:2
dbchanges:no
comments:
authorised_by:Approver Name
qa_certified:yes๐ค AI-Enhanced Tag Naming
CredFlow now supports intelligent tag naming and branch generation powered by Google Gemini AI. The AI learns from your existing project tags to automatically generate branch names that follow your project's conventions.
Features
- ๐ฏ Pattern Learning - Analyzes recent tags to detect naming conventions
- ๐ท๏ธ Smart Branch Generation - Creates branch names matching your project style
- ๐ Intelligent Descriptions - Converts MR titles to tag descriptions following detected patterns
- ๐ Automatic Version Increment - Correctly increments version numbers based on target branch
- ๐จ Style Detection - Recognizes casing (lowercase, Title_Case), separators, and abbreviations
- โก Hybrid Approach - Falls back to regex-based analysis if AI is unavailable
Setup Options
Option 1: Use Local Gemini CLI (No API Key Required)
# Install Gemini CLI globally
npm install -g @google/generative-ai-cli
# CredFlow will automatically detect and use it
credflow mr --from-mr "https://gitlab.../123" --target prodOption 2: Use Gemini API
# Set API key in environment
export GEMINI_API_KEY="your-api-key-here"
# Or add to ~/.credflow.env
echo "GEMINI_API_KEY=your-api-key-here" >> ~/.credflow.envHow It Works
- Fetches Recent Tags - Retrieves 30 most recent tags from your project
- Filters by Target - Analyzes only tags relevant to target branch (PROD/PREPROD/UAT)
- Pattern Analysis - AI identifies:
- Version format (4-part, 5-part, semver)
- Prefix patterns (PROD-, PREPROD-, UAT-)
- Description style (lowercase_with_underscores, Title_Case, etc.)
- Separator usage (underscore, hyphen)
- Smart Generation - Creates new branch name with:
- Correct version increment (e.g., PROD-v6.5.0.222 โ PROD-v6.5.0.223)
- Matching description style from MR title
- Project-specific conventions
Example
Input:
- Target:
master(maps to PROD) - MR Title: "Update BBPS SMS templates"
- Latest Tag:
PROD-v6.5.0.222_Cross_Currency_Split
AI Output:
release/PROD-v6.5.0.223_update_bbps_sms_templatesโ Correct prefix (PROD) โ Incremented version (223) โ Lowercase style (matching existing tags) โ Underscore separators
Confidence Score: AI provides confidence (0-1) for generated names. CredFlow uses AI suggestions only if confidence โฅ 0.7
๐ TOTP (Two-Factor Authentication) Setup
CredFlow supports secure TOTP authentication for ERPNext. Follow these steps to set up TOTP:
Step 1: Reset OTP Secret in ERPNext
- ๐ Login to ERPNext with your regular credentials
- ๐ค Go to My Settings (usually in the user dropdown menu)
- ๐ Click on Password button - you'll see a dropdown menu
- ๐ Select "Reset OTP Secret" from the dropdown
- ๐ช Logout of the application completely
Step 2: Get QR Code from Email
- ๐ Login again to ERPNext (use regular login, NOT Google login)
- ๐ง Check your email - ERPNext will send you a verification URL
- ๐ Click the verification URL from your email
- ๐ฑ Save the QR code as an SVG file to your local computer
Step 3: Configure CredFlow
Run the interactive setup:
credflow totpWhen prompted for QR code:
- ๐ Provide the path to the SVG file you saved
- ๐ท Supports multiple formats - PNG, JPG, SVG (SVG recommended)
Options available:
- ๐ฑ Upload QR code image - Use the QR code from ERPNext email
- ๐ Enter otpauth:// URL - Manual URL entry (if you can extract it)
Example:
# When prompted, provide the SVG file path
Enter QR code image path: /path/to/your/qr-code.svg๐ฆ Addon Patch System
CredFlow intelligently handles sequential deployments:
Scenario 1: Base Branch โ First Addon
- Input:
PREPROD-v6.5.0.286_Update_BBPS_SMS_templates - Output:
PREPROD-v6.5.0.286_1_Update_BBPS_SMS_templates
Scenario 2: Addon โ Next Addon
- Input:
PREPROD-v6.5.0.286_1_Update_BBPS_SMS_templates - Output:
PREPROD-v6.5.0.286_2_Update_BBPS_SMS_templates
Unlimited sequential patches supported! ๐
โก Automatic Conflict Resolution
CredFlow can automatically resolve merge conflicts:
# Prefer source branch changes (for features)
credflow mr --source feature/new-feature --auto-resolve prefer-source
# Prefer target branch changes (for hotfixes)
credflow mr --source hotfix/urgent-fix --auto-resolve prefer-target
# Manual resolution (default)
credflow mr --source my-branch --auto-resolve manual๐ ๏ธ Configuration Guide
๐ Getting GitLab Personal Access Token
- ๐ Log in to your GitLab instance
- ๐ค Go to User Settings โ Access Tokens
- ๐ Create new token with these scopes:
- โ
api- Full API access - โ
read_repository- Read repository access - โ
write_repository- Write repository access - โ
read_user- Read user information
- โ
- ๐ Copy the token (you won't see it again!)
๐ข ERPNext Setup
- ๐ Get your ERPNext URL (e.g.,
https://erp.credenceanalytics.com) - ๐ค Use your regular ERPNext username/email
- ๐ Use your ERPNext password
- ๐ฑ Set up TOTP for enhanced security (see detailed TOTP setup instructions above)
๐ Global Configuration File
After running credflow init, your global configuration file (~/.credflow.env) will contain:
# GitLab Configuration
GITLAB_URL=https://gitlab.credenceanalytics.com
GITLAB_TOKEN=your_gitlab_token_here
# ERPNext Configuration
ERP_URL=https://erp.credenceanalytics.com
[email protected]
ERP_PASSWORD=your_erp_password
ERP_RELEASED_BY_NAME=Your Full Name
# Optional: TOTP for ERPNext (if enabled)
ERP_TOTP_SECRET=your_base32_secret_here๐ Benefits of Global Configuration:
- โ Shared across all projects - No need to set up credentials in each project
- โ One-time setup - Configure once, use everywhere
- โ Secure location - Stored in your home directory
- โ
Project-specific overrides - Local
.envfiles can still override global settings if needed
๐ Command Reference
Core Commands
| Command | Description | Example |
|---------|-------------|---------|
| credflow | ๐ฎ Launch interactive menu | credflow |
| credflow init | ๐ง Initialize CLI with credentials | credflow init |
| credflow mr | ๐ Create/manage merge requests | credflow mr --help |
| credflow totp | ๐ Setup TOTP authentication | credflow totp |
| credflow --help | โ Show help information | credflow --help |
MR Command Options
| Option | Description | Example |
|--------|-------------|---------|
| --from-mr <url> | ๐ฆ Deploy from existing MR | --from-mr "https://gitlab.../123" |
| --target <branch> | ๐ฏ Target deployment branch | --target preprod |
| --patch-type <type> | ๐ Patch type (new/addon) | --patch-type addon |
| --original-branch <name> | ๐ฟ Original branch for addon | --original-branch "PREPROD-v6.5.0.286_Feature" |
| --source <branch> | ๐ฑ Source branch | --source feature/my-feature |
| --push | ๐ค Push branch before MR | --push |
| --merge | ๐ Auto-merge after creation | --merge |
๐ Common Workflows
๐ Production Deployment Workflow
# 1. Deploy to preprod first
credflow mr \
--from-mr "https://gitlab.../merge_requests/123" \
--target preprod
# 2. Test in preprod environment
# ... run your tests ...
# 3. Deploy to production
credflow mr \
--from-mr "https://gitlab.../merge_requests/124" \
--target prod๐ง Hotfix Workflow
# Deploy urgent hotfix
credflow mr \
--from-mr "https://gitlab.../merge_requests/urgent-fix" \
--target prod \
--auto-resolve prefer-target๐ฆ Addon Patch Workflow
# Additional changes to existing deployment
credflow mr \
--from-mr "https://gitlab.../merge_requests/addon-changes" \
--target preprod \
--patch-type addon \
--original-branch "PREPROD-v6.5.0.286_Original_Feature"๐ข ERPNext Release Workflow
# Create software release in ERPNext
credflow software-release \
--mr-url "https://gitlab.../merge_requests/123"๐ท๏ธ Tag Creation Workflow
# Create a release tag from merged MR
credflow # Select "๐ท๏ธ Create GitLab Tag (from MR)"
# Enter MR URL: https://gitlab.../merge_requests/123
# Result: Creates tag like PREPROD-v6.5.0.286_feature_name
# with full GitLab release and MR metadataComplete Release Workflow:
# 1. Deploy to preprod
credflow mr --from-mr "https://gitlab.../MR/123" --target preprod
# 2. Test and validate
# 3. Create release tag (optional)
credflow # โ Create GitLab Tag (from MR) โ Enter same MR URL
# 4. Deploy to production
credflow mr --from-mr "https://gitlab.../MR/123" --target prod
# 5. Create production tag
credflow # โ Create GitLab Tag (from MR) โ Enter prod MR URL๐จ Troubleshooting
โ Common Issues & Solutions
Problem: "CredFlow CLI is not initialized"
# Solution: Run initialization
credflow initProblem: "Failed to resolve project from MR URL"
# Solution: Check MR URL format
# Correct: https://gitlab.../namespace/project/-/merge_requests/123
# Wrong: https://gitlab.../merge_requests/123Problem: "ERPNext login failed"
# Solution: Check credentials and run
credflow # Then select "Test ERP Login"Problem: "TOTP authentication failed"
# Solution: Re-setup TOTP
credflow totpProblem: "Merge conflicts detected"
# Solution: Use auto-resolution or resolve manually
credflow mr --source my-branch --auto-resolve prefer-source๐ Debug Mode
Enable detailed logging:
# Set in .env file
LOG_LEVEL=debug
# Or run with debug
DEBUG=* credflow mr --source my-branch๐ Getting Help
- ๐ Check command help:
credflow --helporcredflow mr --help - ๐ฎ Use interactive mode:
credflow(guides you through everything) - ๐ Check logs: Look at
credflow.logfor detailed information - ๐ Debug mode: Set
LOG_LEVEL=debugin.env
๐๏ธ For Developers
๐ Project Structure
CredflowCLI/
โโโ ๐ bin/
โ โโโ credflow.js # ๐ฏ Main CLI entry point
โโโ ๐ src/
โ โโโ ๐ config/
โ โ โโโ index.js # โ๏ธ Configuration management
โ โโโ ๐ modules/
โ โ โโโ gitlab.js # ๐ฆ GitLab API integration
โ โ โโโ git-operations.js # ๐ฟ Git operations
โ โ โโโ erp.js # ๐ข ERPNext integration
โ โ โโโ prompt-flows.js # ๐ฎ Interactive flows
โ โโโ ๐ utils/
โ โ โโโ logger.js # ๐ Logging utility
โ โ โโโ project-resolver.js # ๐ Project resolution
โ โ โโโ version-manager.js # ๐ท๏ธ Version management
โ โโโ ๐ commands/
โ โโโ patch-create.js # ๐ฆ Patch creation
โโโ ๐ .env.example # ๐ Environment template
โโโ ๐ package.json # ๐ฆ Project metadata
โโโ ๐ README.md # ๐ This documentation๐งช Running Tests
# Run test suite
npm test
# Run with coverage
npm run test:coverage
# Lint code
npm run lint๐ Development Workflow
- ๐ฟ Create feature branch:
git checkout -b feature/my-feature - ๐ ๏ธ Make changes and test
- โ
Run tests:
npm test - ๐ Lint code:
npm run lint - ๐ Commit changes: Use conventional commits
- ๐ Create MR: Use CredFlow itself!
credflow mr --source feature/my-feature
๐ฎ Future Features
- [x] ๐ค AI-powered tag naming and branch generation โจ NEW!
- [ ] ๐ณ Docker integration for containerized deployments
- [ ] ๐ Slack/Teams notifications for deployment status
- [ ] ๐ Dashboard integration for release tracking
- [ ] ๐ค AI-powered conflict resolution suggestions
- [ ] ๐ Multi-platform support (Jenkins, Azure DevOps)
- [ ] ๐ฑ Mobile app for deployment approvals
- [ ] ๐ Advanced analytics and reporting
๐ License
MIT License - feel free to use in your projects!
๐ฅ Contributing
We welcome contributions! Here's how:
- ๐ด Fork the repository
- ๐ฟ Create feature branch:
git checkout -b feature/amazing-feature - ๐ป Make your changes
- โ Test thoroughly
- ๐ Follow commit conventions
- ๐ Create merge request (use CredFlow!)
๐ Credits
Core Team:
- ๐จโ๐ป Gaurav - Architecture & GitLab Integration
- ๐จโ๐ป Manthan - Git Operations & Conflict Resolution
- ๐จโ๐ป Sharat - CLI Interface & ERPNext Integration
Special Thanks:
- ๐ข Credence Analytics for supporting this project
- ๐ Open Source Community for inspiration and tools
๐ Support
- ๐ง Email: [email protected]
- ๐ Issues: GitLab Issues
- ๐ Documentation: This README +
credflow --help
Made with โค๏ธ by the CredFlow Team
Automate your workflows, focus on what matters! ๐
