feat: [#423] goravel/framework could run independently of goravel/goravel#1222
feat: [#423] goravel/framework could run independently of goravel/goravel#1222
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR introduces configurable paths to replace hardcoded file paths throughout the framework, supporting the goal of making goravel/framework run independently of goravel/goravel. The changes centralize path configuration in a new Configuration struct with predefined default paths.
- Replaces hardcoded
filepath.Join()calls with configurable path references - Adds a new
Pathsstruct andConfigurationtype insupport/variable.go - Updates all console make commands to use the centralized path configuration
Reviewed Changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| support/variable.go | Adds new Paths struct and Configuration with default path mappings |
| validation/console/rule_make_command.go | Replaces hardcoded rule path with support.Config.Paths.Rule |
| validation/console/filter_make_command.go | Replaces hardcoded filter path with support.Config.Paths.Filter |
| queue/console/job_make_command.go | Replaces hardcoded job path with support.Config.Paths.Job |
| mail/console/mail_make_command.go | Replaces hardcoded mail path with support.Config.Paths.Mail |
| http/console/request_make_command.go | Replaces hardcoded request path with support.Config.Paths.Request |
| http/console/middleware_make_command.go | Replaces hardcoded middleware path with support.Config.Paths.Middleware |
| http/console/controller_make_command.go | Replaces hardcoded controller path with support.Config.Paths.Controller |
| foundation/console/test_make_command.go | Replaces hardcoded test path with support.Config.Paths.Test |
| foundation/console/provider_make_command.go | Replaces hardcoded provider path with support.Config.Paths.Provider |
| foundation/console/package_make_command.go | Replaces hardcoded package default with support.Config.Paths.Package |
| event/console/listener_make_command.go | Replaces hardcoded listener path with support.Config.Paths.Listener |
| event/console/event_make_command.go | Replaces hardcoded event path with support.Config.Paths.Event |
| database/migration/creator.go | Replaces hardcoded migration path with support.Config.Paths.Migration |
| database/console/seeder_make_command.go | Replaces hardcoded seeder path with support.Config.Paths.Seeder |
| database/console/observer_make_command.go | Replaces hardcoded observer path with support.Config.Paths.Observer |
| database/console/model_make_command.go | Replaces hardcoded model path with support.Config.Paths.Model |
| database/console/factory_make_command.go | Replaces hardcoded factory path with support.Config.Paths.Factory |
| console/console/make_command.go | Replaces hardcoded command path with support.Config.Paths.Command |
| auth/console/policy_make_command.go | Replaces hardcoded policy path with support.Config.Paths.Policy |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1222 +/- ##
=======================================
Coverage 66.66% 66.66%
=======================================
Files 237 237
Lines 15879 15879
=======================================
Hits 10585 10585
Misses 4928 4928
Partials 366 366 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@goravel/core-developers Please help confirm if |
@bowen I believe it would be better if we expose a method instead of directly accessing the internal representation. That way, we can always change the internal logic later without breaking anything. For example: path := support.ConfigPath("filter")
// or
path := support.ConfigPath(support.FilterKey)This is similar to how you previously moved from direct access to using functions in the facades. |
|
Or we can add a new |
Yes, we could add a new Instead of passing a large WithPaths(
WithModelPath(""),
WithFilterPath(""),
...
) |
|
Good point, the sub paths can be below. And this PR can be merged first if there is no problem. We can optimize it when implementing |
📑 Description
Relate goravel/goravel#423
This is the first PR for this issue, to replace some fixed paths. User can configure the code structure by adding the code below in the
bootstrap/app.gofile in the future. The code can be optimized if needed.✅ Checks