Skip to content

Commit 83a7a40

Browse files
committed
chore(dependencies): update forgeui dependency and enhance README documentation
- Updated the `github.com/xraph/forgeui` dependency from v0.0.4 to v0.0.8 in `go.mod` and `go.sum` to ensure compatibility with the latest features and improvements. - Enhanced the README documentation for the Forge CLI, adding example configurations and a migration guide to simplify the transition from verbose to minimal configuration. - Improved clarity on configuration defaults and provided a structured overview of key configuration sections. Signed-off-by: Rex Raphael <rex.raphael@outlook.com>
1 parent 25d3f34 commit 83a7a40

35 files changed

Lines changed: 2312 additions & 350 deletions

app_impl.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,18 +252,29 @@ func newApp(config AppConfig) *app {
252252
// Register core services with DI - Both key-based (legacy) and type-based (new pattern)
253253

254254
// Key-based registration (backward compatibility)
255+
// Register with both the full keys and simple keys for vessel compatibility
255256
_ = RegisterSingleton(container, shared.LoggerKey, func(c Container) (Logger, error) {
256257
return logger, nil
257258
})
259+
_ = RegisterSingleton(container, "logger", func(c Container) (Logger, error) {
260+
return logger, nil
261+
}) // Simple key for vessel.GetLogger
262+
258263
_ = RegisterSingleton(container, shared.ConfigKey, func(c Container) (ConfigManager, error) {
259264
return configManager, nil
260265
})
266+
261267
_ = RegisterSingleton(container, shared.MetricsKey, func(c Container) (Metrics, error) {
262268
return metrics, nil
263269
})
270+
_ = RegisterSingleton(container, "metrics", func(c Container) (Metrics, error) {
271+
return metrics, nil
272+
}) // Simple key for vessel.GetMetrics
273+
264274
_ = RegisterSingleton(container, shared.HealthManagerKey, func(c Container) (HealthManager, error) {
265275
return healthManager, nil
266276
})
277+
267278
_ = RegisterSingleton(container, shared.RouterKey, func(c Container) (Router, error) {
268279
return router, nil
269280
})

cmd/forge/README.md

Lines changed: 108 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,51 @@ forge ext info -n database
238238

239239
The `.forge.yaml` file configures your Forge project. It's automatically searched up the directory tree, so you can run `forge` commands from any subdirectory.
240240

241-
See example configurations:
242-
- [single-module.forge.yaml](./examples/single-module.forge.yaml)
243-
- [multi-module.forge.yaml](./examples/multi-module.forge.yaml)
241+
**Forge uses convention over configuration** - most projects only need a minimal config file. Smart defaults handle the rest!
242+
243+
#### Example Configurations
244+
245+
- **[minimal.forge.yaml](./examples/minimal.forge.yaml)** - Minimal config (recommended for most projects)
246+
- **[typical.forge.yaml](./examples/typical.forge.yaml)** - Common customizations
247+
- **[single-module.forge.yaml](./examples/single-module.forge.yaml)** - Full single-module example
248+
- **[multi-module.forge.yaml](./examples/multi-module.forge.yaml)** - Full multi-module example
249+
250+
#### Minimal Configuration (Recommended)
251+
252+
Most projects only need this:
253+
254+
```yaml
255+
project:
256+
name: "my-project"
257+
module: "github.com/myorg/my-project"
258+
259+
database:
260+
driver: "postgres"
261+
connections:
262+
dev:
263+
url: "postgres://localhost:5432/mydb_dev?sslmode=disable"
264+
production:
265+
url: "${DATABASE_URL}"
266+
```
267+
268+
**That's it!** Everything else uses smart defaults:
269+
- Project structure: Go conventions (`cmd/`, `apps/`, `pkg/`, `internal/`)
270+
- Build: Auto-discovers apps in `cmd/`
271+
- Dev: Auto-discovers and watches Go files
272+
- Migrations: `./database/migrations`
273+
- Output: `./bin`
274+
275+
### Configuration by Convention
276+
277+
Forge follows Go conventions and provides sensible defaults:
278+
279+
| Setting | Default | Override When |
280+
|---------|---------|---------------|
281+
| `cmd/` directory | `./cmd` | Non-standard layout |
282+
| `apps/` directory | `./apps` | Non-standard layout |
283+
| Build output | `./bin` | Custom output location |
284+
| Migrations path | `./database/migrations` | Custom location |
285+
| Auto-discovery | Enabled | Need explicit control |
244286

245287
### Key Configuration Sections
246288

@@ -316,6 +358,69 @@ extensions:
316358
jwt_secret: "${JWT_SECRET}"
317359
```
318360

361+
## Migration Guide
362+
363+
### Migrating from Verbose to Minimal Config
364+
365+
If you have an existing verbose `.forge.yaml`, you can simplify it:
366+
367+
**Before (verbose):**
368+
```yaml
369+
project:
370+
name: "my-project"
371+
module: "github.com/myorg/my-project"
372+
layout: "single-module"
373+
structure:
374+
cmd: "./cmd"
375+
apps: "./apps"
376+
pkg: "./pkg"
377+
internal: "./internal"
378+
379+
dev:
380+
auto_discover: true
381+
watch:
382+
enabled: true
383+
paths:
384+
- "./apps/**/*.go"
385+
- "./pkg/**/*.go"
386+
387+
database:
388+
driver: "postgres"
389+
migrations_path: "./database/migrations"
390+
seeds_path: "./database/seeds"
391+
392+
build:
393+
output_dir: "./bin"
394+
auto_discover: true
395+
```
396+
397+
**After (minimal):**
398+
```yaml
399+
project:
400+
name: "my-project"
401+
module: "github.com/myorg/my-project"
402+
403+
database:
404+
driver: "postgres"
405+
connections:
406+
dev:
407+
url: "postgres://localhost:5432/mydb_dev"
408+
```
409+
410+
**What changed:**
411+
- Removed `structure` - uses Go conventions
412+
- Removed `dev.watch.paths` - auto-discovers Go files
413+
- Removed `build.output_dir` - defaults to `./bin`
414+
- Removed `migrations_path` - defaults to `./database/migrations`
415+
- All fields with default values can be omitted
416+
417+
**Breaking Changes in v2.x:**
418+
- `database.codegen` removed (never implemented - use sqlc, gorm-gen, or sqlboiler)
419+
- `project.structure` is now optional (nil = use conventions)
420+
- Build auto-discovery is now default
421+
422+
Your existing verbose configs will continue to work, but you can gradually simplify them.
423+
319424
## Plugin System
320425

321426
Forge CLI is built on a plugin architecture. Current plugins:

cmd/forge/config/loader.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,24 @@ func tryLoadConfig(path string) (*ForgeConfig, error) {
7373
}
7474

7575
// SaveForgeConfig saves the configuration to a file.
76+
// Uses omitempty tags to produce clean, minimal YAML output.
7677
func SaveForgeConfig(config *ForgeConfig, path string) error {
77-
// Marshal to YAML
78+
// Marshal to YAML with proper formatting
7879
data, err := yaml.Marshal(config)
7980
if err != nil {
8081
return fmt.Errorf("failed to marshal config: %w", err)
8182
}
8283

84+
// Add header comment
85+
header := `# Forge Configuration
86+
# This file uses smart defaults - only specify what you need to override.
87+
# See https://forge.dev/docs/configuration for full documentation.
88+
89+
`
90+
finalData := []byte(header + string(data))
91+
8392
// Write to file
84-
if err := os.WriteFile(path, data, 0644); err != nil {
93+
if err := os.WriteFile(path, finalData, 0644); err != nil {
8594
return fmt.Errorf("failed to write config file: %w", err)
8695
}
8796

0 commit comments

Comments
 (0)