feat: [#576] add package manager functionality#920
Conversation
|
Important Review skippedAuto reviews are limited to specific labels. 🏷️ Labels to auto review (1)
Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #920 +/- ##
==========================================
- Coverage 69.14% 69.06% -0.09%
==========================================
Files 158 168 +10
Lines 10607 11364 +757
==========================================
+ Hits 7334 7848 +514
- Misses 2942 3163 +221
- Partials 331 353 +22 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
⚠️ 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: 72f4028 | Previous: ab139f2 | Ratio |
|---|---|---|---|
BenchmarkFile_ReadWrite |
332358 ns/op 2073 B/op 28 allocs/op |
212688 ns/op 2072 B/op 28 allocs/op |
1.56 |
BenchmarkFile_ReadWrite - ns/op |
332358 ns/op |
212688 ns/op |
1.56 |
This comment was automatically generated by workflow using github-action-benchmark.
0b08b3f to
2946b9b
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR introduces package manager functionality to support installation and uninstallation of packages, along with updates to console commands and helper functions for managing Go source modifications. Key changes include:
- New console commands for package:install and package:uninstall.
- Enhancements to package helper logic (modifiers, matchers, and tests) used in configuration and provider registration.
- Updates to the package make command to support a new “manager” flag that generates the package manager files.
Reviewed Changes
Copilot reviewed 21 out of 22 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| foundation/console/package_uninstall_command.go | Implements package uninstallation logic using Go commands. |
| foundation/console/package_install_command.go | Implements package installation logic with version handling and tidying. |
| packages/* | Introduces new helper, modifier, matcher functions and test cases. |
| foundation/console/package_make_command*.go | Adds support for the “manager” flag and updates file generation logic. |
| foundation/application.go | Registers new package management commands during application boot. |
Files not reviewed (1)
- go.mod: Language not supported
Comments suppressed due to low confidence (2)
foundation/console/package_make_command_test.go:45
- [nitpick] The test error message for flag type assertions can be made more descriptive by clearly indicating whether the failure is for the manager flag or the root flag. This will help in debugging flag configuration issues.
managerFlag, ok := got.Flags[0].(*command.BoolFlag)
foundation/console/package_make_command.go:34
- [nitpick] Consider enhancing the usage description for the 'manager' flag to more explicitly state its effect (for example, that it creates a manager folder with the necessary files) so that users immediately understand its functionality.
&command.BoolFlag{ Name: "manager", Aliases: []string{"m"}, Usage: "Create a package manager", DisableDefaultText: true, }
There was a problem hiding this comment.
Can we add some test cases for this file? Although It may be a bit complex.
There was a problem hiding this comment.
I will add test case in new PR after merged this one.
446e763 to
da055d8
Compare
56c478c to
f5a081e
Compare
|
Please pin me if this PR is ready. |
Almost ready, but I still need to think about the streaming call we discussed last time 🤔 |
|
I haven’t figured out a good approach for the streaming call yet. How about using a declarative approach for now and optimizing it later? |
cc @hwbrzzl |
Oh sorry, missed this message, sure, we can optimize it with #920 (comment) in another PR. |
📑 Description
This feature introduces a package manager to handle the installation and uninstallation of packages within the framework. A
setupfolder is created in the package repository’s root directory, containing thesetup.gofile. Thesetup.gofile handles key package management operations such as registering providers, adding configuration settings, and modifying Go files in the project.The part of the package manager responsible for registering providers is automatically handled when creating a new package using the
artisan make:packagecommand. This ensures that the necessary providers are registered in the configuration files when installing a new package. For example, when installing the Redis package (github.com/goravel/redis), the ServiceProvider for Redis is added to config/app.go.For example, using the Redis package (github.com/goravel/redis) as a case study, the package manager performs the following tasks:
config/app.gofile to register the Redis service provider, ensuring that Redis is available for use throughout the application.config/cache.goandconfig/queue.goto include necessary imports, configuration options, and Redis drivers, enabling caching and queue functionalities powered by Redis.app.go,cache.go, andqueue.go.The installation and uninstallation processes are executed via command line, providing a simple and efficient way to manage packages. To install a package, run:
To uninstall the package, run:
Additionally, the package manager supports a
--force (-f)flag, which allows the installation process to proceed even if errors are encountered.The
setup.gofile in the manager folder is responsible for managing the core functionality of the package manager. Below is the complete example code for themanager.gofile:This feature also supports local package installation. For example, a local package can be created using:
Then, the package can be installed using the package manager:
Closes goravel/goravel#576?
@coderabbitai summary
✅ Checks