UNPKG

sourcecontrol

Version:

A modern TypeScript CLI application for source control

371 lines (269 loc) โ€ข 11.2 kB
# ๐ŸŽฏ SourceControl CLI <div align="center"> ![Application](./images/project.png) </div> ๐Ÿš€ **A modern, powerful TypeScript CLI application for advanced source control operations** Built with cutting-edge technologies and developer experience in mind, SourceControl CLI brings Git operations to the next level with beautiful interfaces, smart automation, and robust error handling. ## โœจ Features ### ๐ŸŽฏ **Core Capabilities** - ๐Ÿš€ **Modern TypeScript** - Built with TypeScript 5.x for bulletproof type safety and IntelliSense - ๐ŸŽจ **Beautiful CLI Interface** - Stunning colorful output with animated progress indicators and elegant spinners - ๐Ÿ”ง **Smart Interactive Commands** - Intuitive prompts, auto-completion, and intelligent confirmations - โšก **Lightning Fast & Reliable** - Optimized Git operations with comprehensive error handling and recovery ### ๐Ÿ›ก๏ธ **Quality & Testing** - ๐Ÿงช **Thoroughly Tested** - Comprehensive test suite with Jest covering 90%+ code coverage - ๐Ÿ“Š **Code Quality** - ESLint + Prettier + TypeScript strict mode for pristine code - ๐Ÿ” **Error Handling** - Graceful error recovery with helpful user guidance ### ๐ŸŽ **Developer Experience** - ๐Ÿ“ฆ **Zero-Config Installation** - One command setup with automatic dependency management - ๐ŸŽช **Plugin Architecture** - Extensible system for custom commands and workflows - ๐Ÿ“š **Rich Documentation** - Comprehensive guides, examples, and API documentation - ๐Ÿ”„ **Auto-Updates** - Built-in update notifications and seamless upgrades ## ๐Ÿ“ฆ Installation ### ๐ŸŒ **Global Installation** (Recommended) ```bash # Install globally for system-wide access npm install -g sourcecontrol # Verify installation sc --version ``` ### ๐Ÿ”ง **Local Development Setup** ```bash # ๐Ÿ“ฅ Clone the repository git clone https://github.com/your-org/sourcecontrol.git cd sourcecontrol # ๐Ÿ“š Install dependencies npm install # ๐Ÿ—๏ธ Build the project npm run build # ๐Ÿš€ Run in development mode with hot reload npm run dev # ๐Ÿงช Run tests to verify setup npm test ``` ### ๐Ÿณ **Docker Installation** ```bash # Run directly with Docker docker run -it --rm -v $(pwd):/workspace sourcecontrol/cli # Or build locally docker build -t sourcecontrol . docker run -it sourcecontrol ``` ## ๐ŸŽฎ Usage ### ๐ŸŒŸ **Essential Commands** ```bash # Initialize a new repository sc init # Check repository status sc status sc st # short alias # Commit changes sc commit -m "Your commit message" sc commit -a -m "Stage and commit all changes" # Manage branches sc branch # list branches sc branch feature-branch # create new branch sc branch -d old-branch # delete branch # Manage remotes sc remote # list remotes sc remote add origin <url> # add remote sc remote -v # verbose output ``` ### ๐Ÿค– **Smart Interactive Mode** Most commands feature intelligent interactive mode with auto-completion and smart defaults: ```bash sc init # ๐ŸŽฏ Interactive repository setup with templates sc commit # โœ๏ธ Interactive commit with AI-powered message suggestions sc remote add # ๐Ÿ”— Interactive remote addition with validation sc branch # ๐ŸŒฟ Interactive branch management with fuzzy search ``` > ๐Ÿ’ก **Pro Tip**: Use `--interactive` or `-i` flag to force interactive mode on any command! ### Command Options #### Global Options - `-v, --verbose` - Enable verbose logging - `-q, --quiet` - Suppress output - `--config <path>` - Specify custom config file #### Status Command ```bash sc status [options] -s, --short Show short-format output -b, --branch Show branch information ``` #### Commit Command ```bash sc commit [options] -m, --message <msg> Commit message -a, --all Stage all modified files --amend Amend previous commit -s, --signoff Add Signed-off-by line ``` #### Branch Command ```bash sc branch [options] [name] -a, --all List local and remote branches -r, --remotes List remote branches -d, --delete <branch> Delete branch -D, --force-delete <branch> Force delete branch ``` #### Remote Command ```bash sc remote [subcommand] [name] [url] -v, --verbose Show URLs Subcommands: add <name> <url> Add remote remove <name> Remove remote show <name> Show remote details ``` ## โš™๏ธ Configuration ๐Ÿ”ง **SourceControl** uses a smart configuration system with multiple levels and automatic detection: ๐Ÿ“ **Configuration Files** (in order of precedence): 1. `./sourcecontrol.config.json` (project-specific) 2. `~/.sourcecontrol/config.json` (user global) 3. `/etc/sourcecontrol/config.json` (system-wide) ### ๐Ÿ“ **Sample Configuration** ```json { "defaultBranch": "main", "editor": "nano", "user": { "name": "Your Name", "email": "your.email@example.com" }, "remote": { "origin": "" }, "ui": { "colorOutput": true, "showProgress": true } } ``` You can specify a custom config file using the `--config` option. ## ๐Ÿ› ๏ธ Development ### ๐Ÿ“œ **Available Scripts** ```bash npm run build # Build TypeScript to dist/ npm run build:watch # Build with watch mode npm run dev # Run in development mode npm run test # Run tests npm run test:watch # Run tests in watch mode npm run test:coverage # Run tests with coverage npm run lint # Run ESLint npm run lint:fix # Fix ESLint issues npm run format # Format code with Prettier npm run format:check # Check code formatting npm run clean # Clean dist directory ``` ### ๐Ÿ—๏ธ **Project Architecture** ``` src/ โ”œโ”€โ”€ cli.ts # CLI entry point โ”œโ”€โ”€ index.ts # Library exports โ”œโ”€โ”€ types/ # TypeScript type definitions โ”‚ โ””โ”€โ”€ index.ts โ”œโ”€โ”€ utils/ # Utility modules โ”‚ โ”œโ”€โ”€ config.ts # Configuration management โ”‚ โ”œโ”€โ”€ git.ts # Git operations โ”‚ โ”œโ”€โ”€ logger.ts # Logging utility โ”‚ โ””โ”€โ”€ spinner.ts # Progress indicators โ”œโ”€โ”€ commands/ # CLI commands โ”‚ โ”œโ”€โ”€ init.ts # Repository initialization โ”‚ โ”œโ”€โ”€ status.ts # Status checking โ”‚ โ”œโ”€โ”€ commit.ts # Commit operations โ”‚ โ”œโ”€โ”€ branch.ts # Branch management โ”‚ โ””โ”€โ”€ remote.ts # Remote management โ””โ”€โ”€ __tests__/ # Test files โ””โ”€โ”€ utils/ โ”œโ”€โ”€ logger.test.ts โ””โ”€โ”€ git.test.ts ``` ### ๐Ÿงช **Testing Strategy** Robust testing setup with Jest, TypeScript support, and comprehensive coverage: ๐ŸŽฏ **Testing Pyramid**: - **Unit Tests** - Individual component testing - **Integration Tests** - Command workflow testing - **E2E Tests** - Full CLI experience testing ```bash # Run all tests npm test # Run tests in watch mode npm run test:watch # Generate coverage report npm run test:coverage ``` ### ๐ŸŒŸ **Code Quality Stack** ๐Ÿ” **Static Analysis**: - ๐ŸŽฏ **ESLint** - Advanced linting with TypeScript and security rules - ๐ŸŽจ **Prettier** - Consistent code formatting across the entire codebase - ๐Ÿ›ก๏ธ **TypeScript** - Strict type checking and compilation with latest features - ๐Ÿงช **Jest** - Comprehensive unit and integration testing framework ๐Ÿš€ **Quality Gates**: - Pre-commit hooks with Husky - Automated CI/CD quality checks - Code coverage thresholds (90%+) - Security vulnerability scanning ## ๐Ÿ“š Dependencies ### ๐Ÿš€ **Production Dependencies** - ๐ŸŽฏ `commander` - Powerful CLI argument parsing and command structure - ๐ŸŒˆ `chalk` - Beautiful terminal colors and styling - โ“ `inquirer` - Rich interactive command-line prompts - โณ `ora` - Elegant terminal progress spinners - ๐Ÿ“ฆ `boxen` - Create beautiful terminal boxes and borders - ๐Ÿ”” `update-notifier` - Smart update notifications for better UX - ๐Ÿ“ `fs-extra` - Enhanced file system operations with promises - ๐Ÿ” `keytar` - Secure credential storage for Git authentication ### ๐Ÿ› ๏ธ **Development Dependencies** - ๐Ÿ“˜ `typescript` - TypeScript compiler with latest features - ๐Ÿงช `jest` - Delightful JavaScript testing framework - ๐Ÿ” `eslint` - Pluggable JavaScript and TypeScript linting - ๐ŸŽจ `prettier` - Opinionated code formatter - โšก `ts-node` - TypeScript execution environment for Node.js - ๐Ÿบ `husky` - Git hooks made easy - ๐Ÿ“Š `codecov` - Code coverage reporting ## ๐Ÿค Contributing We love contributions! Here's how to get started: ### ๐Ÿš€ **Quick Start** 1. ๐Ÿด **Fork** the repository 2. ๐ŸŒฟ **Create** a feature branch (`git checkout -b feature/amazing-feature`) 3. โœจ **Make** your changes with love 4. ๐Ÿงช **Add tests** for new functionality (required!) 5. โœ… **Run** the full test suite (`npm test`) 6. ๐Ÿ“ **Commit** with conventional commits (`npm run commit`) 7. ๐Ÿš€ **Push** to your branch (`git push origin feature/amazing-feature`) 8. ๐ŸŽฏ **Open** a Pull Request with detailed description ### ๐ŸŽฏ **Contribution Guidelines** - ๐Ÿ“– Follow our [Code of Conduct](CODE_OF_CONDUCT.md) - ๐Ÿ“ Use [Conventional Commits](https://conventionalcommits.org/) - ๐Ÿงช Maintain or improve test coverage - ๐Ÿ“š Update documentation for new features - ๐Ÿ” Run `npm run lint` before submitting ### ๐Ÿ† **Recognition** All contributors are celebrated in our [Contributors Hall of Fame](CONTRIBUTORS.md)! ## License This project is licensed under the MIT License - see the LICENSE file for details. ## ๐Ÿ—บ๏ธ Roadmap ### ๐ŸŽฏ **Phase 1: Core Enhancement** (Q1 2024) - [ ] ๐Ÿš€ Add push/pull commands with smart conflict resolution - [ ] ๐ŸŽฃ Git hooks support with custom triggers - [ ] ๐Ÿ”Œ Plugin system with marketplace - [ ] ๐Ÿ“‹ Configuration templates for popular workflows ### ๐Ÿš€ **Phase 2: Advanced Features** (Q2 2024) - [ ] ๐Ÿค AI-powered merge conflict resolution helpers - [ ] ๐ŸŒฟ Advanced branch operations (rebase, cherry-pick) - [ ] ๐ŸŒŠ Git flow support with visual workflows - [ ] โšก Performance optimizations and caching ### ๐ŸŒŸ **Phase 3: Intelligence** (Q3 2024) - [ ] ๐Ÿค– AI commit message generation - [ ] ๐Ÿ“Š Repository analytics and insights - [ ] ๐Ÿ” Smart code review suggestions - [ ] ๐ŸŽฏ Predictive branch naming ### ๐ŸŽช **Phase 4: Integration** (Q4 2024) - [ ] ๐Ÿ”— GitHub/GitLab/Bitbucket deep integration - [ ] ๐Ÿ’ฌ Slack/Teams notifications - [ ] ๐Ÿ“ฑ Mobile companion app - [ ] ๐ŸŒ Web dashboard --- <div align="center"> **Made with โค๏ธ by the SourceControl team** [๐Ÿ“– Documentation](https://docs.sourcecontrol.dev) โ€ข [๐Ÿ› Report Bug](https://github.com/owner/repo/issues) โ€ข [๐Ÿ’ก Request Feature](https://github.com/owner/repo/discussions) โ€ข [๐Ÿ’ฌ Community](https://discord.gg/sourcecontrol) </div>