Skip to content

feat: [#423] Replace all fixed paths#1292

Merged
hwbrzzl merged 6 commits intomasterfrom
bowen/#423-3
Dec 12, 2025
Merged

feat: [#423] Replace all fixed paths#1292
hwbrzzl merged 6 commits intomasterfrom
bowen/#423-3

Conversation

@hwbrzzl
Copy link
Contributor

@hwbrzzl hwbrzzl commented Dec 10, 2025

📑 Description

Related Issue: goravel/goravel#423

This pull request refactors the setup and stub generation logic for several framework packages to use a new, more flexible path abstraction. It replaces direct usage of module and package names with a unified Paths interface, improving maintainability and reducing hardcoded paths throughout the codebase. Additionally, stub functions are updated to accept package names as arguments, allowing for more dynamic and accurate code generation.

Refactoring to use new path abstraction:

  • Updated all setup scripts (e.g., auth, cache, crypt, database, event) to use setup.Paths() for retrieving module imports and package names, replacing previous usage of setup.ModulePath() and setup.PackageName(). This ensures consistent and accurate path handling across all packages. [1] [2] [3] [4] [5]
  • Modified the Setup interface in contracts/packages/setup.go to introduce Paths, Path, and related methods, providing a structured way to access different package paths and names.

Stub generation improvements:

  • Refactored stub generation functions (e.g., Config, AuthFacade, GateFacade, CryptFacade, DBFacade, OrmFacade, SchemaFacade, SeederFacade) to accept package names as arguments and to dynamically replace placeholders, enabling more flexible and correct stub code generation. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14]

Code cleanup and test adjustments:

  • Removed unused imports and redundant code in test and stub files, and updated tests to align with the new path abstraction and stub generation logic. [1] [2] [3] [4] [5]

Configuration and provider registration updates:

  • Adjusted logic for registering service providers and writing configuration files to use the new path abstraction and updated stub generation, ensuring correct file content and registration in all scenarios. [1] [2] [3] [4] [5] [6] [7] [8]

These changes collectively improve the maintainability, flexibility, and correctness of the setup and stub generation processes across the framework.

✅ Checks

  • Added test cases for my code

@codecov
Copy link

codecov bot commented Dec 12, 2025

Codecov Report

❌ Patch coverage is 6.91643% with 323 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.82%. Comparing base (8d66b1f) to head (e59c79a).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
packages/paths.go 4.87% 39 Missing ⚠️
http/setup/stubs.go 0.00% 27 Missing ⚠️
testing/setup/stubs.go 0.00% 16 Missing ⚠️
auth/setup/stubs.go 0.00% 12 Missing ⚠️
grpc/setup/stubs.go 0.00% 12 Missing ⚠️
http/setup/setup.go 0.00% 12 Missing ⚠️
queue/setup/stubs.go 0.00% 11 Missing ⚠️
filesystem/setup/stubs.go 0.00% 9 Missing ⚠️
hash/setup/stubs.go 0.00% 9 Missing ⚠️
mail/setup/stubs.go 0.00% 9 Missing ⚠️
... and 37 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1292      +/-   ##
==========================================
- Coverage   69.01%   68.82%   -0.19%     
==========================================
  Files         278      278              
  Lines       16071    16114      +43     
==========================================
  Hits        11091    11091              
- Misses       4506     4549      +43     
  Partials      474      474              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@hwbrzzl hwbrzzl marked this pull request as ready for review December 12, 2025 11:36
@hwbrzzl hwbrzzl requested a review from a team as a code owner December 12, 2025 11:36
Copilot AI review requested due to automatic review settings December 12, 2025 11:36
@hwbrzzl hwbrzzl merged commit 35eaec3 into master Dec 12, 2025
16 of 19 checks passed
@hwbrzzl hwbrzzl deleted the bowen/#423-3 branch December 12, 2025 11:38
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the framework to replace hardcoded file paths with configurable paths using a new Paths abstraction. The change enables greater flexibility for users to customize their project structure.

Key Changes

  • Introduces new Paths and Path interfaces in contracts/packages/setup.go to provide structured access to package paths and imports
  • Replaces setup.ModulePath() and setup.PackageName() methods with a unified setup.Paths() API
  • Moves path utility functions from support/variable.go to support/path/internals/path.go for better organization
  • Updates all setup and stub files across packages to use dynamic package names instead of hardcoded "facades" package references

Reviewed changes

Copilot reviewed 60 out of 60 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
contracts/packages/setup.go Adds new Paths, Path interfaces to replace string-based path methods
packages/paths.go New file implementing path abstractions for different package types
packages/setup.go Replaces ModulePath()/PackageName() with Paths() method
support/variable.go Removes PathToSlice() and PathPackage() helper functions
support/path/internals/path.go Adds ToSlice() function (moved from support/variable.go)
foundation/application.go Updates to use internals.ToSlice() instead of support.PathToSlice()
view/view.go Uses support.Config.Paths.Resources instead of hardcoded "resources"
support/env/env.go Uses support.Config.Paths.Bootstrap instead of hardcoded "bootstrap"
translation/service_provider.go Uses configurable lang path with fallback to support.Config.Paths.Lang
*/setup/stubs.go Updates stub generators to accept dynamic package names as parameters
*/setup/setup.go Updates all setup files to use new Paths() API for package resolution
mocks/packages/*.go Regenerated mocks for updated interfaces
support/variable_test.go Test moved to support/path/internals/path_test.go

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +54 to +55
content = strings.ReplaceAll(content, "DummyPackage", pkg)
content = strings.ReplaceAll(content, "DummyModule", main)
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable 'DummyModule' is being replaced with 'main' instead of 'DummyMain'. This is inconsistent with the naming convention used throughout the rest of the PR where 'DummyMain' is the placeholder for the main package import. The replacement should use 'DummyMain' as the placeholder.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants