๐ CredFlow Ultimate - Enhanced CLI tool for GitLab automation, ERPNext integration, and DevOps workflows
npm install credflowclibash
Install globally
npm install -g credflowcli
Verify installation
credflow --version
`
Option 2: Install from source
`bash
Clone the repository
git clone https://gitlab.credenceanalytics.com/sharatyaragatti/CredflowCLI.git
cd CredflowCLI
Install dependencies
npm install
Make CLI globally available
npm link
`
$3
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-cli or use Gemini CLI
- Alternative: Set GEMINI_API_KEY environment variable to use API instead
- Benefits: Intelligent pattern learning from existing tags, smart branch name generation
$3
Run the initialization wizard - it will guide you through everything:
`bash
credflow init
`
The 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)
$3
`bash
Launch interactive menu
credflow
Or use specific commands
credflow mr --from-mr "https://gitlab.../merge_requests/123" --target preprod
`
That's it! You're ready to automate your workflows! ๐
---
๐ Complete Feature Guide
$3
Simply run credflow to access the interactive menu:
`bash
credflow
`
You'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
$3
#### 1. ๐ฆ Deploy from Merge Request (Patch Automation)
Deploy a new development patch:
`bash
credflow mr --from-mr "https://gitlab.../merge_requests/123" --target preprod
`
Deploy an addon patch (additional changes to existing deployment):
`bash
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:
1. ๐ Extracts project info from MR URL
2. ๐ฟ Creates deployment branch with proper naming
3. ๐ Applies changes from source MR
4. ๐ค Pushes to GitLab
5. ๐ฏ Creates new MR for deployment
#### 2. ๐ Create Merge Request
Basic MR creation:
`bash
credflow mr --source feature/my-feature --target main --title "Add new feature"
`
Advanced MR with file attachments:
`bash
credflow mr \
--source feature/user-auth \
--target main \
--title "Feature: User Authentication" \
--description "Implements JWT-based authentication" \
--files ./documentation \
--report ./test-results.docx \
--push \
--merge
`
#### 3. ๐ Create Software Release in ERPNext
`bash
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:
`bash
credflow # Then select "๐ท๏ธ Create GitLab Tag (from MR)"
`
What happens:
1. ๐ Enter MR URL - Provide the merged MR URL
2. ๐ท๏ธ Auto-generate Tag Name - Format: TARGET-vX.X.X.X_SOURCE_BRANCH_NAME
3. ๐ Create Release - Optionally create GitLab release with MR description
4. ๐ 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
$3
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:
1. ๐ Detects the Project Type - Recognizes Thomas Cook projects automatically
2. ๐ท๏ธ Uses Proper Tag Format - Follows MFXSTD_RETAIL_LIVE_X_X_X_XXX naming convention
3. ๐ฟ Creates Patch Branch - Branches from UAT/target with cherry-picked commits
4. ๐ 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
`bash
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
`
---
$3
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)
`bash
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 prod
`
Option 2: Use Gemini API
`bash
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.env
`
#### How It Works
1. Fetches Recent Tags - Retrieves 30 most recent tags from your project
2. Filters by Target - Analyzes only tags relevant to target branch (PROD/PREPROD/UAT)
3. 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)
4. 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
$3
CredFlow supports secure TOTP authentication for ERPNext. Follow these steps to set up TOTP:
#### Step 1: Reset OTP Secret in ERPNext
1. ๐ Login to ERPNext with your regular credentials
2. ๐ค Go to My Settings (usually in the user dropdown menu)
3. ๐ Click on Password button - you'll see a dropdown menu
4. ๐ Select "Reset OTP Secret" from the dropdown
5. ๐ช Logout of the application completely
#### Step 2: Get QR Code from Email
1. ๐ Login again to ERPNext (use regular login, NOT Google login)
2. ๐ง Check your email - ERPNext will send you a verification URL
3. ๐ Click the verification URL from your email
4. ๐ฑ Save the QR code as an SVG file to your local computer
#### Step 3: Configure CredFlow
Run the interactive setup:
`bash
credflow totp
`
When 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:
`bash
When prompted, provide the SVG file path
Enter QR code image path: /path/to/your/qr-code.svg
`
$3
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! ๐
$3
CredFlow can automatically resolve merge conflicts:
`bash
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
$3
1. ๐ Log in to your GitLab instance
2. ๐ค Go to User Settings โ Access Tokens
3. ๐ 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
4. ๐ Copy the token (you won't see it again!)
$3
1. ๐ Get your ERPNext URL (e.g., https://erp.credenceanalytics.com)
2. ๐ค Use your regular ERPNext username/email
3. ๐ Use your ERPNext password
4. ๐ฑ Set up TOTP for enhanced security (see detailed TOTP setup instructions above)
$3
After running credflow init, your global configuration file (~/.credflow.env) will contain:
`env
GitLab Configuration
GITLAB_URL=https://gitlab.credenceanalytics.com
GITLAB_TOKEN=your_gitlab_token_here
ERPNext Configuration
ERP_URL=https://erp.credenceanalytics.com
ERP_USER=your.email@company.com
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 .env files can still override global settings if needed
---
๐ Command Reference
$3
| 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 |
$3
| Option | Description | Example |
|--------|-------------|---------|
| --from-mr | ๐ฆ Deploy from existing MR | --from-mr "https://gitlab.../123" |
| --target | ๐ฏ Target deployment branch | --target preprod |
| --patch-type | ๐ Patch type (new/addon) | --patch-type addon |
| --original-branch | ๐ฟ Original branch for addon | --original-branch "PREPROD-v6.5.0.286_Feature" |
| --source | ๐ฑ Source branch | --source feature/my-feature |
| --push | ๐ค Push branch before MR | --push |
| --merge | ๐ Auto-merge after creation | --merge |
---
๐ Common Workflows
$3
`bash
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
`
$3
`bash
Deploy urgent hotfix
credflow mr \
--from-mr "https://gitlab.../merge_requests/urgent-fix" \
--target prod \
--auto-resolve prefer-target
`
$3
`bash
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"
`
$3
`bash
Create software release in ERPNext
credflow software-release \
--mr-url "https://gitlab.../merge_requests/123"
`
$3
`bash
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 metadata
`
Complete Release Workflow:
`bash
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
$3
Problem: "CredFlow CLI is not initialized"
`bash
Solution: Run initialization
credflow init
`
Problem: "Failed to resolve project from MR URL"
`bash
Solution: Check MR URL format
Correct: https://gitlab.../namespace/project/-/merge_requests/123
Wrong: https://gitlab.../merge_requests/123
`
Problem: "ERPNext login failed"
`bash
Solution: Check credentials and run
credflow # Then select "Test ERP Login"
`
Problem: "TOTP authentication failed"
`bash
Solution: Re-setup TOTP
credflow totp
`
Problem: "Merge conflicts detected"
`bash
Solution: Use auto-resolution or resolve manually
credflow mr --source my-branch --auto-resolve prefer-source
`
$3
Enable detailed logging:
`bash
Set in .env file
LOG_LEVEL=debug
Or run with debug
DEBUG=* credflow mr --source my-branch
`
$3
1. ๐ Check command help: credflow --help or credflow mr --help
2. ๐ฎ Use interactive mode: credflow (guides you through everything)
3. ๐ Check logs: Look at credflow.log for detailed information
4. ๐ Debug mode: Set LOG_LEVEL=debug in .env
---
๐๏ธ For Developers
$3
`
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
`
$3
`bash
Run test suite
npm test
Run with coverage
npm run test:coverage
Lint code
npm run lint
`
$3
1. ๐ฟ Create feature branch: git checkout -b feature/my-feature
2. ๐ ๏ธ Make changes and test
3. โ
Run tests: npm test
4. ๐ Lint code: npm run lint
5. ๐ Commit changes: Use conventional commits
6. ๐ 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:
1. ๐ด Fork the repository
2. ๐ฟ Create feature branch: git checkout -b feature/amazing-feature
3. ๐ป Make your changes
4. โ
Test thoroughly
5. ๐ Follow commit conventions
6. ๐ 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: support@credenceanalytics.com
- ๐ Issues: GitLab Issues
- ๐ Documentation: This README + credflow --help`