diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4cfb6f5..5df134f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -5,7 +5,7 @@ Thank you for your interest in contributing! ## Development Setup 1. Fork the repository -2. Clone your fork: `git clone https://github.com/YOUR_USERNAME/revenueholdings.git` +2. Clone your fork: `git clone https://github.com/YOUR_USERNAME/devforge-cli.git` 3. Create a virtual environment: `python -m venv venv` 4. Install dev dependencies: `pip install -e ".[dev]"` diff --git a/Makefile b/Makefile index 0555de0..57ccdd6 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ # Generated by Agent B โ€” Lint & Type Scripts -.PHONY: lint test format typecheck format-check +.PHONY: lint test format typecheck format-check clean lint: ruff check src/ tests/ @@ -15,3 +15,7 @@ typecheck: test: pytest -q + +clean: + rm -rf build/ dist/ *.egg-info/ .pytest_cache/ __pycache__/ + find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true diff --git a/README.md b/README.md index 88b236c..c7ac10a 100644 --- a/README.md +++ b/README.md @@ -1,118 +1,118 @@ -# DevForge CLI - -[![GitHub stars](https://img.shields.io/github/stars/Coding-Dev-Tools/devforge?style=social)](https://github.com/Coding-Dev-Tools/devforge/stargazers) - -**The `devforge` command โ€” one install, ten developer CLI tools.** - -[![PyPI](https://img.shields.io/pypi/v/devforge)](https://pypi.org/project/devforge/) -[![Python Versions](https://img.shields.io/pypi/pyversions/devforge)](https://pypi.org/project/devforge/) -[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) - -Ten production-ready CLI tools for API contracts, SQL generation, infrastructure diffs, config drift, API mocking, key management, env syncing, schema conversion, MCP servers, and dead code removal โ€” in a single package. Install one meta-package and get immediate access to all tools via the unified `devforge` command. - ---- - -[๐Ÿ  Landing Page](https://coding-dev-tools.github.io/devforge/) ยท [๐Ÿ“ Blog](https://coding-dev-tools.github.io/devforge/blog.html) ยท [๐Ÿ› Report a Bug](https://github.com/Coding-Dev-Tools/devforge/issues) - ---- - -## Why the Suite? - -Instead of installing ten separate tools and learning ten different CLIs, `pip install devforge[all]` gives you: - -- **Single CLI** (`devforge`) to invoke any tool โ€” no context switching -- **Consistent flags, output formats, and help** across all tools -- **Shared configuration** โ€” one install, all tools - -## Installation - -```bash -# Install everything (recommended) -pip install devforge[all] - -# Or install individual tools -pip install devforge[guard] # API Contract Guardian -pip install devforge[sql] # json2sql -pip install devforge[deploy] # DeployDiff -pip install devforge[drift] # ConfigDrift -pip install devforge[ghost] # APIGhost -pip install devforge[auth] # APIAuth -pip install devforge[envault] # Envault -pip install devforge[schema] # SchemaForge -pip install devforge[mcp] # click-to-mcp -pip install devforge[deadcode] # DeadCode -``` - -## Usage - -```bash -devforge --version # Show version info -devforge tools # List all available tools -devforge tools guard # Show details about a specific tool -devforge versions # Show installed tool versions -``` - -Run any tool directly through `devforge`: - -```bash -# API Contract Guardian โ€” detect OpenAPI breaking changes -devforge guard check spec-v1.yaml spec-v2.yaml - -# json2sql โ€” convert JSON to SQL INSERT statements -devforge sql convert data.json --dialect postgres - -# DeployDiff โ€” preview infrastructure changes with cost estimates -devforge deploy preview plan.json - -# ConfigDrift โ€” catch config drift between environments -devforge drift check dev.yaml prod.yaml - -# APIGhost โ€” spawn mock API server from OpenAPI spec -devforge ghost serve openapi.yaml - -# APIAuth โ€” generate API keys and JWTs -devforge auth generate --type api-key - -# Envault โ€” sync .env files across environments -devforge envault diff .env.dev .env.prod - -# SchemaForge โ€” convert between ORM formats -devforge schema convert schema.prisma --to drizzle - -# click-to-mcp โ€” wrap CLI as MCP server -devforge mcp wrap my-cli --transport http - -# DeadCode โ€” find unused exports in React/Next.js -devforge deadcode scan src/ -``` - -## Tools - -| Command | Package | Description | -|---------|---------|-------------| -| `guard` | api-contract-guardian | Detect breaking API changes, generate migration guides, gate CI pipelines on contract violations | -| `sql` | json2sql | Convert JSON datasets to SQL with smart type inference across PostgreSQL, MySQL, and SQLite | -| `deploy` | deploydiff | Preview infra changes with cost estimates and automatic rollback commands for Terraform, CloudFormation, and Pulumi | -| `drift` | configdrift | Compare configs across environments, flag missing keys, deprecated values, and compliance violations | -| `ghost` | apighost | Mock API server from OpenAPI specs with VCR cassette recording and realistic fake data | -| `auth` | apiauth | API key and JWT lifecycle management with AES-256-GCM encrypted local store | -| `envault` | envault | Env variable syncing, diffing, and secret rotation with Vault/AWS SSM/Doppler/1Password support | -| `schema` | schemaforge | Bidirectional ORM schema converter โ€” 11 formats with zero-loss roundtripping | -| `mcp` | click-to-mcp | Auto-wrap any Click/typer CLI as an MCP server โ€” zero code changes | -| `deadcode` | deadcode | Detect unused exports, dead routes, orphaned CSS in TypeScript/React/Next.js projects | - -## Links - -- [Landing Page](https://coding-dev-tools.github.io/devforge/) -- [GitHub Organization](https://github.com/Coding-Dev-Tools) -- [Report an Issue](https://github.com/Coding-Dev-Tools/devforge/issues) - -## License - -MIT โ€” see [LICENSE](LICENSE) for details. - -## Test - -```bash -pytest -q -``` +# DevForge CLI + +[![GitHub stars](https://img.shields.io/github/stars/Coding-Dev-Tools/devforge?style=social)](https://github.com/Coding-Dev-Tools/devforge/stargazers) + +**The `devforge` command โ€” one install, ten developer CLI tools.** + +[![PyPI](https://img.shields.io/pypi/v/devforge)](https://pypi.org/project/devforge/) +[![Python Versions](https://img.shields.io/pypi/pyversions/devforge)](https://pypi.org/project/devforge/) +[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) + +Ten production-ready CLI tools for API contracts, SQL generation, infrastructure diffs, config drift, API mocking, key management, env syncing, schema conversion, MCP servers, and dead code removal โ€” in a single package. Install one meta-package and get immediate access to all tools via the unified `devforge` command. + +--- + +[๐Ÿ  Landing Page](https://coding-dev-tools.github.io/devforge/) ยท [๐Ÿ“ Blog](https://coding-dev-tools.github.io/devforge/blog.html) ยท [๐Ÿ› Report a Bug](https://github.com/Coding-Dev-Tools/devforge/issues) + +--- + +## Why the Suite? + +Instead of installing ten separate tools and learning ten different CLIs, `pip install devforge[all]` gives you: + +- **Single CLI** (`devforge`) to invoke any tool โ€” no context switching +- **Consistent flags, output formats, and help** across all tools +- **Shared configuration** โ€” one install, all tools + +## Installation + +```bash +# Install everything (recommended) +pip install devforge[all] + +# Or install individual tools +pip install devforge[guard] # API Contract Guardian +pip install devforge[sql] # json2sql +pip install devforge[deploy] # DeployDiff +pip install devforge[drift] # ConfigDrift +pip install devforge[ghost] # APIGhost +pip install devforge[auth] # APIAuth +pip install devforge[envault] # Envault +pip install devforge[schema] # SchemaForge +pip install devforge[mcp] # click-to-mcp +pip install devforge[deadcode] # DeadCode +``` + +## Usage + +```bash +devforge --version # Show version info +devforge tools # List all available tools +devforge tools guard # Show details about a specific tool +devforge versions # Show installed tool versions +``` + +Run any tool directly through `devforge`: + +```bash +# API Contract Guardian โ€” detect OpenAPI breaking changes +devforge guard check spec-v1.yaml spec-v2.yaml + +# json2sql โ€” convert JSON to SQL INSERT statements +devforge sql convert data.json --dialect postgres + +# DeployDiff โ€” preview infrastructure changes with cost estimates +devforge deploy preview plan.json + +# ConfigDrift โ€” catch config drift between environments +devforge drift check dev.yaml prod.yaml + +# APIGhost โ€” spawn mock API server from OpenAPI spec +devforge ghost serve openapi.yaml + +# APIAuth โ€” generate API keys and JWTs +devforge auth generate --type api-key + +# Envault โ€” sync .env files across environments +devforge envault diff .env.dev .env.prod + +# SchemaForge โ€” convert between ORM formats +devforge schema convert schema.prisma --to drizzle + +# click-to-mcp โ€” wrap CLI as MCP server +devforge mcp wrap my-cli --transport http + +# DeadCode โ€” find unused exports in React/Next.js +devforge deadcode scan src/ +``` + +## Tools + +| Command | Package | Description | +|---------|---------|-------------| +| `guard` | api-contract-guardian | Detect breaking API changes, generate migration guides, gate CI pipelines on contract violations | +| `sql` | json2sql | Convert JSON datasets to SQL with smart type inference across PostgreSQL, MySQL, and SQLite | +| `deploy` | deploydiff | Preview infra changes with cost estimates and automatic rollback commands for Terraform, CloudFormation, and Pulumi | +| `drift` | configdrift | Compare configs across environments, flag missing keys, deprecated values, and compliance violations | +| `ghost` | apighost | Mock API server from OpenAPI specs with VCR cassette recording and realistic fake data | +| `auth` | apiauth | API key and JWT lifecycle management with AES-256-GCM encrypted local store | +| `envault` | envault | Env variable syncing, diffing, and secret rotation with Vault/AWS SSM/Doppler/1Password support | +| `schema` | schemaforge | Bidirectional ORM schema converter โ€” 11 formats with zero-loss roundtripping | +| `mcp` | click-to-mcp | Auto-wrap any Click/typer CLI as an MCP server โ€” zero code changes | +| `deadcode` | deadcode | Detect unused exports, dead routes, orphaned CSS in TypeScript/React/Next.js projects | + +## Links + +- [Landing Page](https://coding-dev-tools.github.io/devforge/) +- [GitHub Organization](https://github.com/Coding-Dev-Tools) +- [Report an Issue](https://github.com/Coding-Dev-Tools/devforge/issues) + +## License + +MIT โ€” see [LICENSE](LICENSE) for details. + +## Test + +```bash +pytest -q +``` diff --git a/pyproject.toml b/pyproject.toml index 5f70712..6e33913 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,7 +26,7 @@ dependencies = [ "rich>=13.0.0", ] -# Optional groups รขโ‚ฌโ€ install with: pip install devforge[all] +# Optional groups โ€” install with: pip install devforge[all] [project.optional-dependencies] guard = ["api-contract-guardian>=0.1.0"] sql = ["json2sql>=0.1.0"] @@ -53,9 +53,9 @@ all = [ dev = ["pytest>=7.0.0", "pyright>=1.1.300"] [project.urls] -Homepage = "https://github.com/Coding-Dev-Tools/devforge" -Repository = "https://github.com/Coding-Dev-Tools/devforge" -Issues = "https://github.com/Coding-Dev-Tools/devforge/issues" +Homepage = "https://github.com/Coding-Dev-Tools/devforge-cli" +Repository = "https://github.com/Coding-Dev-Tools/devforge-cli" +Issues = "https://github.com/Coding-Dev-Tools/devforge-cli/issues" [project.scripts] devforge = "devforge.cli:app" @@ -66,6 +66,7 @@ where = ["src"] [tool.pytest.ini_options] testpaths = ["tests"] addopts = "-v --tb=short" +pythonpath = ["src"] [tool.ruff] target-version = "py310" line-length = 120 diff --git a/src/devforge/cli.py b/src/devforge/cli.py index b8a9733..24047df 100644 --- a/src/devforge/cli.py +++ b/src/devforge/cli.py @@ -1,6 +1,5 @@ """DevForge unified CLI entry point.""" -import builtins as _builtins import subprocess import sys import typer @@ -86,7 +85,7 @@ def install( ): """Install a DevForge tool.""" if tool == "all": - targets = _builtins.list(TOOLS.keys()) + targets = list(TOOLS.keys()) extras = ",".join(TOOLS.keys()) elif tool in TOOLS: targets = [tool] @@ -119,7 +118,7 @@ def show_versions( console.print(f"[red]Unknown tool: {tool}[/red]") console.print(f"Available: {', '.join(TOOLS.keys())}") raise typer.Exit(code=1) - targets = [tool] if tool else _builtins.list(TOOLS.keys()) + targets = [tool] if tool else list(TOOLS.keys()) for t in targets: info = TOOLS[t] @@ -156,15 +155,35 @@ def dispatch( try: result = subprocess.run( [sys.executable, "-m", info["package"].replace("-", "_")] + (args or []), - capture_output=False, + capture_output=True, + text=True, ) + if result.returncode == 0: + sys.stdout.write(result.stdout) + if result.stderr: + sys.stderr.write(result.stderr) + sys.exit(0) + # Module not found โ€” show friendly install message + if "No module named" in result.stderr: + console.print( + f"[red]Tool '{tool_name}' not installed.[/red]\n" + f"Install with: [green]pip install devforge[{tool_name}][/green]" + ) + raise typer.Exit(code=1) from None + # Tool ran but failed โ€” show its output and propagate exit code + sys.stdout.write(result.stdout) + sys.stderr.write(result.stderr) sys.exit(result.returncode) except FileNotFoundError: + # Only reached if sys.executable itself is missing (extremely rare) console.print( f"[red]Tool '{tool_name}' not installed.[/red]\n" f"Install with: [green]pip install devforge[{tool_name}][/green]" ) raise typer.Exit(code=1) from None + except Exception as e: + console.print(f"[red]Unexpected error running '{tool_name}': {e}[/red]") + raise typer.Exit(code=1) from e dispatch.__name__ = tool_name dispatch.__doc__ = f"Run `{pkg}` commands via the {tool_name} subcommand."