Skip to content

Commit 2c16a8b

Browse files
committed
Refactor + cleanup detector/common files
1 parent 1315bc7 commit 2c16a8b

37 files changed

+2740
-1367
lines changed

AGENTS.md

Lines changed: 79 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -142,26 +142,73 @@ lightfold/
142142
│ ├── configure.go # Server configuration (idempotent)
143143
│ ├── push.go # Release deployment
144144
│ ├── deploy.go # Orchestrator (chains all steps)
145+
│ ├── autodeploy.go # Auto-deployment workflow
145146
│ ├── status.go # Deployment status viewer (with health checks)
146147
│ ├── logs.go # Application log viewer
147148
│ ├── rollback.go # Release rollback
149+
│ ├── sync.go # State synchronization
148150
│ ├── config.go # Config/token management
149151
│ ├── keygen.go # SSH key generation
150152
│ ├── ssh.go # Interactive SSH sessions
151153
│ ├── destroy.go # VM destruction and cleanup
152154
│ ├── server.go # Multi-app server management
153-
│ ├── common.go # Shared helpers (resolveTarget, createTarget, configureTarget, multi-app helpers)
155+
│ ├── domain.go # Custom domain and SSL management
156+
│ ├── common.go # Shared command helpers and wrapper functions
157+
│ ├── provider_bootstrap.go # Provider registry and configuration
158+
│ ├── provider_state.go # Provider state handlers for IP recovery
159+
│ ├── utils/ # Refactored shared utilities
160+
│ │ ├── target_resolution.go # Target resolution logic
161+
│ │ ├── server_setup.go # Server creation and configuration helpers
162+
│ │ ├── provider_recovery.go # Generic IP recovery from providers
163+
│ │ └── port_allocation.go # Multi-app port allocation
164+
│ ├── templates/ # Command templates
154165
│ └── ui/ # TUI components
155166
│ ├── detection/ # Detection results display
167+
│ ├── deployment/ # Deployment UI components
156168
│ ├── sequential/ # Token collection flows
157169
│ ├── spinner/ # Loading animations
158170
│ ├── progress.go # Deployment progress bars
159171
│ └── animation.go # Shared animations
160172
├── pkg/
161173
│ ├── detector/ # Framework detection engine
162-
│ │ ├── detector.go # Core detection logic
163-
│ │ ├── plans.go # Build/run plans
164-
│ │ └── exports.go # Test helpers
174+
│ │ ├── detector.go # Core detection orchestrator
175+
│ │ ├── fsreader.go # Filesystem reader abstraction
176+
│ │ ├── helpers.go # Shared detection helpers
177+
│ │ ├── types.go # Core detection types
178+
│ │ ├── exports.go # Test helpers
179+
│ │ ├── detectors/ # Framework-specific detectors
180+
│ │ │ ├── types.go # Detector types and interfaces
181+
│ │ │ ├── scoring.go # Scoring system
182+
│ │ │ ├── builder.go # Detector registry builder
183+
│ │ │ ├── javascript.go # JS/TS frameworks (Next.js, Astro, SvelteKit, etc.)
184+
│ │ │ ├── python.go # Python frameworks (Django, Flask, FastAPI)
185+
│ │ │ ├── go.go # Go frameworks
186+
│ │ │ ├── php.go # PHP frameworks
187+
│ │ │ ├── ruby.go # Ruby frameworks
188+
│ │ │ ├── rust.go # Rust frameworks
189+
│ │ │ ├── java.go # Java frameworks
190+
│ │ │ ├── csharp.go # C# frameworks
191+
│ │ │ ├── elixir.go # Elixir frameworks
192+
│ │ │ └── docker.go # Dockerfile detection
193+
│ │ ├── packagemanagers/ # Package manager detection
194+
│ │ │ ├── javascript.go # JS package managers (npm, yarn, pnpm, bun)
195+
│ │ │ └── python.go # Python package managers (pip, poetry, uv, pipenv)
196+
│ │ ├── helpers/ # Framework-specific helper utilities
197+
│ │ │ └── javascript.go # JS framework detection helpers
198+
│ │ └── plans/ # Build/run plan generators
199+
│ │ ├── types.go # Plan function type
200+
│ │ ├── common.go # Shared plan helpers
201+
│ │ ├── helpers.go # Plan utility functions
202+
│ │ ├── javascript.go # JS framework plans
203+
│ │ ├── python.go # Python framework plans
204+
│ │ ├── go.go # Go framework plans
205+
│ │ ├── php.go # PHP framework plans
206+
│ │ ├── ruby.go # Ruby framework plans
207+
│ │ ├── rust.go # Rust framework plans
208+
│ │ ├── java.go # Java framework plans
209+
│ │ ├── csharp.go # C# framework plans
210+
│ │ ├── elixir.go # Elixir framework plans
211+
│ │ └── docker.go # Docker-based plans
165212
│ ├── builders/ # Build system registry
166213
│ │ ├── builder.go # Builder interface
167214
│ │ ├── registry.go # Builder factory + auto-selection
@@ -175,25 +222,44 @@ lightfold/
175222
│ │ ├── state.go # Local/remote state management
176223
│ │ ├── server.go # Multi-app server state
177224
│ │ └── ports.go # Port allocation and conflict detection
178-
│ ├── runtime/ # Runtime cleanup system
225+
│ ├── runtime/ # Runtime management system
179226
│ │ ├── types.go # Runtime types and info
180-
│ │ └── cleaner.go # Cleanup orchestration
227+
│ │ ├── cleaner.go # Cleanup orchestration
228+
│ │ └── installers/ # Runtime installer registry
229+
│ │ ├── registry.go # Installer interface and registry
230+
│ │ ├── helpers.go # Shared installer utilities
231+
│ │ ├── node.go # Node.js runtime installer
232+
│ │ ├── python.go # Python runtime installer
233+
│ │ ├── go.go # Go runtime installer
234+
│ │ ├── php.go # PHP runtime installer
235+
│ │ └── ruby.go # Ruby runtime installer
181236
│ ├── deploy/ # Deployment logic
182237
│ │ ├── orchestrator.go # Multi-provider orchestration
183238
│ │ ├── executor.go # Blue/green deployment executor
184239
│ │ └── templates/ # Deployment templates
185240
│ ├── ssh/ # SSH operations
186241
│ │ ├── executor.go # SSH command execution
187242
│ │ └── keygen.go # SSH key generation
243+
│ ├── ssl/ # SSL certificate management
244+
│ │ ├── manager.go # SSL manager interface + registry
245+
│ │ ├── certbot/ # Certbot (Let's Encrypt) manager
246+
│ │ └── caddy/ # Caddy manager (future)
247+
│ ├── proxy/ # Reverse proxy management
248+
│ │ ├── proxy.go # Proxy manager interface + registry
249+
│ │ ├── nginx/ # Nginx manager
250+
│ │ └── caddy/ # Caddy manager (future)
188251
│ ├── util/ # Shared utilities
189252
│ │ ├── env.go # .env file parsing
190-
│ │ └── project.go # Project path validation
253+
│ │ └── git.go # Git operations
254+
│ ├── flyctl/ # Fly.io CLI wrapper
255+
│ │ └── flyctl.go # flyctl command execution
191256
│ └── providers/ # Cloud provider registry
192257
│ ├── provider.go # Provider interface
193258
│ ├── registry.go # Provider factory
194259
│ ├── digitalocean/ # DigitalOcean implementation
195260
│ ├── vultr/ # Vultr implementation
196261
│ ├── hetzner/ # Hetzner implementation
262+
│ ├── flyio/ # Fly.io implementation
197263
│ └── cloudinit/ # Cloud-init template generation
198264
├── test/
199265
│ ├── detector/ # Detection test suite
@@ -899,16 +965,6 @@ Generates cloud-init user data for server provisioning:
899965
3. Add appropriate plan functions
900966
4. Update documentation
901967

902-
## Testing Checklist
903-
904-
### Framework Detection
905-
- [ ] Framework detection accuracy
906-
- [ ] Package manager detection
907-
- [ ] Build command generation
908-
- [ ] JSON output format
909-
- [ ] Edge case handling
910-
- [ ] Performance with large projects
911-
912968
### Composable Commands
913969
- [ ] `create` - BYOS and provision modes, 3 invocation patterns
914970
- [ ] `configure` - Idempotency and force flag, 3 invocation patterns
@@ -1036,12 +1092,17 @@ lightfold destroy --target myapp # Destroy VM and cleanup
10361092
- **Unified command pattern**: All commands support 3 invocation methods (current dir, path arg, --target flag)
10371093
- State tracking is dual: local JSON files + remote markers on servers
10381094
- Idempotency is critical - commands check state first, then execute, then update state
1039-
- **Code reuse pattern**: Core logic extracted to `cmd/common.go`
1095+
- **Code reuse pattern**: Core logic extracted to `cmd/common.go` and refactored utilities
10401096
- `resolveTarget()` - Unified target resolution from 3 input patterns (DRY principle)
10411097
- `createTarget()` and `configureTarget()` - Reusable deployment logic
10421098
- Cobra commands are thin wrappers that call these shared functions
10431099
- `deploy` orchestrator calls these reusable functions directly
10441100
- Single source of truth for all deployment logic
1101+
- **Provider-agnostic refactoring**: Registry patterns for extensibility
1102+
- `cmd/provider_bootstrap.go` - Provider registration with O(1) lookup, SSH key generation
1103+
- `cmd/provider_state.go` - Unified IP recovery handlers for all providers
1104+
- `pkg/runtime/installers/` - Pluggable runtime installer system with auto-registration
1105+
- Adding new providers/runtimes requires only one new entry, zero changes to core logic
10451106
- **New convenience commands**:
10461107
- `logs` - View application logs via journalctl (supports --tail and --lines)
10471108
- `rollback` - Standalone rollback command (removed from deploy --rollback)

0 commit comments

Comments
 (0)