Skip to content

feat: optimize install schedule#1209

Merged
hwbrzzl merged 6 commits intomasterfrom
bowen/install-schedule
Sep 28, 2025
Merged

feat: optimize install schedule#1209
hwbrzzl merged 6 commits intomasterfrom
bowen/install-schedule

Conversation

@hwbrzzl
Copy link
Contributor

@hwbrzzl hwbrzzl commented Sep 26, 2025

📑 Description

Relate goravel/goravel#612

This pull request introduces enhancements and refactoring to the Goravel console command generation system, focusing on automating kernel initialization, improving code modification utilities, and expanding unit test coverage. The changes ensure that the console kernel and its registration in the service provider are automatically created and updated when generating new commands, reducing manual setup and potential errors. The modification utilities are extended to support more flexible and robust Go code manipulation, and new tests are added to verify these behaviors.

  1. When creating a command via the make:command command, create the app/console/kernel.go file if not exist, and register the kernel in app_service_provider.go.
image
  1. Add a new match.RegisterFunc function to match app_service_provider.go::Register.
  2. Add a new modify.Add function to add code in a function.
  3. Add a new modify.Remove function to remove a function's code.
image
  1. Add a new modify.When function to control install/uninstall the package.
image
  1. Add a new modify.FindOrCreate function to create something if it can't be found.
  2. Add a new modify.CreateImport function to create import if a go file doesn't exist import.
image
  1. Remove file.WithAppend's parameter, set the default action to Append.

✅ Checks

  • Added test cases for my code

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: f3e1545 Previous: 20c63f2 Ratio
BenchmarkFile_ReadWrite 277536 ns/op 6257 B/op 99 allocs/op 175681 ns/op 6258 B/op 99 allocs/op 1.58
BenchmarkFile_ReadWrite - ns/op 277536 ns/op 175681 ns/op 1.58

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

@codecov
Copy link

codecov bot commented Sep 27, 2025

Codecov Report

❌ Patch coverage is 56.12903% with 68 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.01%. Comparing base (4b7bb1d) to head (f3e1545).
⚠️ Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
schedule/setup/setup.go 0.00% 25 Missing ⚠️
support/stub/stub.go 0.00% 19 Missing ⚠️
packages/match/match.go 0.00% 11 Missing ⚠️
console/console/make_command.go 68.18% 5 Missing and 2 partials ⚠️
packages/modify/actions.go 91.66% 2 Missing and 1 partial ⚠️
packages/modify/modify.go 91.66% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1209      +/-   ##
==========================================
- Coverage   68.73%   68.01%   -0.72%     
==========================================
  Files         232      236       +4     
  Lines       15104    15424     +320     
==========================================
+ Hits        10381    10491     +110     
- Misses       4363     4568     +205     
- Partials      360      365       +5     

☔ 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 September 27, 2025 13:05
@hwbrzzl hwbrzzl requested a review from a team as a code owner September 27, 2025 13:05
Copilot AI review requested due to automatic review settings September 27, 2025 13:05
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 pull request enhances the Goravel console command generation system by automating kernel initialization, improving code modification utilities, and expanding test coverage. It introduces new functionality to automatically create console kernels and register them in service providers when generating commands, reducing manual setup requirements.

  • Automatically creates app/console/kernel.go when generating console commands if it doesn't exist
  • Adds new modification functions for better Go code manipulation (Add, Remove, When, FindOrCreate, CreateImport)
  • Simplifies the WithAppend function by removing the boolean parameter and defaulting to append mode

Reviewed Changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
support/stub/stub.go Adds ConsoleKernel stub template for generating console kernel files
support/file/options.go Simplifies WithAppend function by removing boolean parameter
support/file/file_test.go Updates test to use simplified WithAppend function
schedule/setup/setup.go Refactors setup logic with improved kernel initialization and conditional modifications
packages/modify/modify.go Adds new modification utilities: When, FindOrCreate, and enhanced goNode functionality
packages/modify/modify_test.go Adds comprehensive tests for new modification functions
packages/modify/actions.go Implements Add, Remove, and CreateImport actions for function modification
packages/modify/actions_test.go Adds tests for new Add and Remove actions
packages/match/match.go Extends matching functionality for expression statements and call expressions
packages/match/helper.go Adds RegisterFunc helper for matching Register functions
packages/match/helper_test.go Adds test coverage for RegisterFunc matcher
console/console/stubs.go Adds Kernel stub method using the new ConsoleKernel stub
console/console/make_command.go Implements automatic kernel initialization when creating commands
console/console/make_command_test.go Adds comprehensive tests for kernel initialization functionality
contracts/packages/modify/modify.go Updates GoFile interface to include FindOrCreate method
mocks/packages/modify/GoFile.go Adds mock implementation for FindOrCreate method

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@hwbrzzl hwbrzzl merged commit 1e241cd into master Sep 28, 2025
11 of 14 checks passed
@hwbrzzl hwbrzzl deleted the bowen/install-schedule branch September 28, 2025 08:50
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