Skip to content

feat: [#423] goravel/framework could run independently of goravel/goravel#1289

Merged
hwbrzzl merged 12 commits intomasterfrom
bowen/#423-1
Dec 8, 2025
Merged

feat: [#423] goravel/framework could run independently of goravel/goravel#1289
hwbrzzl merged 12 commits intomasterfrom
bowen/#423-1

Conversation

@hwbrzzl
Copy link
Contributor

@hwbrzzl hwbrzzl commented Dec 8, 2025

📑 Description

This PR enables the Goravel framework to run independently without requiring the goravel/goravel skeleton project. It introduces a flexible path configuration system that allows users to customize project structure.

Related Issue: goravel/goravel#423

🔧 Changes

Core Changes

1. Path Configuration System

  • Extended Paths interface with new methods (App(), Config(), Database(), Facades(), Lang(), Public(), Resources(), Storage())
  • Renamed singular methods to plural for consistency (Command()Commands(), Model()Models(), etc.)
  • Added comprehensive path configuration in support.Config.Paths with default values
  • All paths now use forward slashes for cross-platform compatibility

2. Package Installation System

  • Replaced --module flag with --package-name in setup commands
  • Added --paths flag to pass path configuration as JSON
  • Setup script now accepts and applies custom paths configuration
  • Updated PackageInstallCommand and PackageUninstallCommand to pass paths to setup scripts

3. Path Resolution

  • Refactored application path methods (ConfigPath(), DatabasePath(), ModelPath(), etc.) to use configured paths instead of hardcoded values
  • Updated LangPath() with backward compatibility for deprecated app.lang_path config
  • Simplified path resolution logic using PathToSlice() helper

4. Cache Setup Example

  • Updated cache/setup as reference implementation
  • Removed dependency on WhenFacade() modifier
  • Setup now receives package name and paths from command line arguments

New Helper Functions

// Converts path string to slice, handling both Unix and Windows separators
func PathToSlice(path string) []string

// Extracts package name from path
func PathPackage(pkg, def string) string

✅ Checks

  • Added test cases for my code

)

func main() {
setup := packages.Setup(os.Args)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

os.Args contains the paths info, packages.Setup(os.Args) should always be called at the start.


// install package
if err := supportconsole.ExecuteCommand(ctx, exec.Command("go", "run", setup, "install", "--module="+packages.GetModuleName())); err != nil {
if err := supportconsole.ExecuteCommand(ctx, exec.Command("go", "run", setup, "install", "--package-name="+packages.GetPackageName(), "--paths="+r.paths)); err != nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

support.Config.Paths cannot be shared with module when installing facade, so paths should be passed here.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.50.

Benchmark suite Current: b4d0279 Previous: 9a4a7b4 Ratio
Benchmark_DecryptString 5252 ns/op 2032 B/op 16 allocs/op 2082 ns/op 2032 B/op 16 allocs/op 2.52
Benchmark_DecryptString - ns/op 5252 ns/op 2082 ns/op 2.52
Benchmark_Fatal 5e-7 ns/op 0 B/op 0 allocs/op 2e-7 ns/op 0 B/op 0 allocs/op 2.50
Benchmark_Fatal - ns/op 5e-7 ns/op 2e-7 ns/op 2.50

This comment was automatically generated by workflow using github-action-benchmark.

@hwbrzzl hwbrzzl marked this pull request as ready for review December 8, 2025 10:50
@hwbrzzl hwbrzzl requested a review from a team as a code owner December 8, 2025 10:50
Copilot AI review requested due to automatic review settings December 8, 2025 10:50
@codecov
Copy link

codecov bot commented Dec 8, 2025

Codecov Report

❌ Patch coverage is 59.42857% with 71 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.91%. Comparing base (6ef4277) to head (4ce0ebc).
⚠️ Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
packages/match/match.go 0.00% 30 Missing ⚠️
cache/setup/setup.go 0.00% 12 Missing ⚠️
cache/setup/stubs.go 0.00% 8 Missing ⚠️
foundation/application.go 76.00% 6 Missing ⚠️
packages/setup.go 73.68% 4 Missing and 1 partial ⚠️
support/variable.go 54.54% 5 Missing ⚠️
foundation/console/package_install_command.go 75.00% 1 Missing and 1 partial ⚠️
foundation/console/package_uninstall_command.go 66.66% 1 Missing and 1 partial ⚠️
foundation/console/test_make_command.go 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1289      +/-   ##
==========================================
+ Coverage   68.58%   68.91%   +0.32%     
==========================================
  Files         264      265       +1     
  Lines       15641    15732      +91     
==========================================
+ Hits        10728    10841     +113     
+ Misses       4447     4424      -23     
- Partials      466      467       +1     

☔ 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.

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 enables the Goravel framework to run independently of the goravel/goravel skeleton project by introducing a flexible path configuration system. The changes allow users to customize project structure through configurable paths, replacing hardcoded directory structures.

Key Changes:

  • Introduced comprehensive path configuration with 23+ configurable directory paths, all using forward slashes for cross-platform compatibility
  • Renamed interface methods from singular to plural (e.g., Command()Commands(), Model()Models()) for better clarity
  • Replaced --module flag with --package-name and added --paths flag for JSON-based path configuration in package setup commands
  • Added helper functions PathToSlice() and PathPackage() to parse path strings and extract package names
  • Refactored all application path methods to use the new configurable paths instead of hardcoded values
  • Updated the cache setup as a reference implementation showing how packages should handle custom paths

Reviewed changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
support/variable.go Adds comprehensive Paths struct with 23+ configurable directory paths and helper functions for path manipulation
support/variable_test.go Adds comprehensive test coverage for PathToSlice function with various path formats
contracts/foundation/configuration/paths.go Updates Paths interface with singular→plural method names and adds new path configuration methods
foundation/configuration/paths.go Implements all new Paths interface methods to configure custom directory structures
foundation/configuration/paths_test.go Adds comprehensive tests for all path configuration methods
foundation/application.go Refactors path resolution methods to use PathToSlice and configured paths instead of hardcoded values
foundation/application_test.go Updates LangPath tests to handle deprecated config key and new path resolution
foundation/application_builder_test.go Updates WithPaths tests to use plural method names
support/path/internals/path.go Updates internal path helpers to use PathToSlice for path resolution
support/path/internals/path_test.go Adds new tests for Abs and BootstrapApp functions
support/path/path.go Adds warning comment about avoiding import cycles in framework code
packages/setup.go Replaces --module with --package-name flag, adds --paths JSON flag, and implements PackageName() method
packages/setup_test.go Updates tests for new package name handling and refactors test structure
contracts/packages/setup.go Adds PackageName() method to Setup interface
mocks/packages/Setup.go Regenerates mock with new PackageName() method
foundation/console/package_install_command.go Updates to pass package name and paths JSON to setup scripts
foundation/console/package_install_command_test.go Updates all test expectations to include new --package-name and --paths flags
foundation/console/package_uninstall_command.go Updates to pass package name and paths JSON to setup scripts
foundation/console/package_uninstall_command_test.go Updates all test expectations to include new flags and adds json mock
foundation/console/test_make_command.go Renames GetModuleName to GetPackageName
cache/setup/setup.go Updates as reference implementation to handle custom paths and package names
cache/setup/stubs.go Updates stubs to accept package parameter for proper code generation
mocks/foundation/configuration/Paths.go Regenerates mocks with all new plural method names
database/console/migration/migrate_make_command.go Minor formatting improvement (blank line after import)

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

hwbrzzl and others added 6 commits December 8, 2025 19:02
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

@almas-x almas-x left a comment

Choose a reason for hiding this comment

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

LGTM👍

@hwbrzzl hwbrzzl merged commit d735058 into master Dec 8, 2025
13 of 14 checks passed
@hwbrzzl hwbrzzl deleted the bowen/#423-1 branch December 8, 2025 13:43
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.

3 participants