Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: generators can run without prior migrations #2861

Merged
merged 4 commits into from
Jun 21, 2024

Conversation

adrianthedev
Copy link
Collaborator

Description

Fixes an issue where the generators would fail if there were pending migrations.
This is common if you install rails, run the devise generator and then Avo's.

This PR also brings a new command all_resources which will generate all resources.

Problem

We're now stuck at generating all the resources. The all_resources generator will not continue past the first resource it finds.

CleanShot 2024-06-14 at 16 43 02@2x

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works

Screenshots & recording

Manual review steps

  1. Step 1
  2. Step 2

Manual reviewer: please leave a comment with output from the test if that's the case.

@github-actions github-actions bot added the Fix label Jun 14, 2024
Copy link

codeclimate bot commented Jun 14, 2024

Code Climate has analyzed commit 48a05c4 and detected 1 issue on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 1

View more on Code Climate.

model.in?(%w[ApplicationRecord])
end
.each do |model|
begin
Copy link
Contributor

Choose a reason for hiding this comment

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

[rubocop] reported by reviewdog 🐶
[Corrected] Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body beginning.

model.in?(%w[ApplicationRecord])
end
.each do |model|
begin
Copy link
Contributor

Choose a reason for hiding this comment

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

[rubocop] reported by reviewdog 🐶
[Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.

model.in?(%w[ApplicationRecord])
end
.each do |model|
begin
Copy link
Contributor

Choose a reason for hiding this comment

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

[rubocop] reported by reviewdog 🐶
[Corrected] Style/RedundantBegin: Redundant begin block detected.

end
.each do |model|
begin
invoke "avo:resource", [model.underscore], {}
Copy link
Contributor

Choose a reason for hiding this comment

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

[rubocop] reported by reviewdog 🐶
[Corrected] Layout/IndentationWidth: Use 2 (not 4) spaces for indentation.

.each do |model|
begin
invoke "avo:resource", [model.underscore], {}
rescue => e
Copy link
Contributor

Choose a reason for hiding this comment

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

[rubocop] reported by reviewdog 🐶
[Corrected] Layout/RescueEnsureAlignment: rescue at 20, 12 is not aligned with models

model_name.camelize.constantize
model_name.camelize
rescue NameError
nil
Copy link
Contributor

Choose a reason for hiding this comment

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

[rubocop] reported by reviewdog 🐶
[Corrected] Layout/IndentationWidth: Use 2 (not 0) spaces for indentation.

lib/generators/avo/install_generator.rb Outdated Show resolved Hide resolved
lib/generators/avo/resource_generator.rb Outdated Show resolved Hide resolved
lib/generators/avo/resource_generator.rb Outdated Show resolved Hide resolved
lib/generators/avo/resource_generator.rb Show resolved Hide resolved
models
.each do |model|
begin
Rails::Generators.invoke "avo:resource", [model.underscore], {}
Copy link
Contributor

Choose a reason for hiding this comment

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

[rubocop] reported by reviewdog 🐶
[Corrected] Layout/IndentationWidth: Use 2 (not 4) spaces for indentation.

.each do |model|
begin
Rails::Generators.invoke "avo:resource", [model.underscore], {}
rescue => e
Copy link
Contributor

Choose a reason for hiding this comment

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

[rubocop] reported by reviewdog 🐶
[Corrected] Layout/RescueEnsureAlignment: rescue at 18, 12 is not aligned with models

@adrianthedev adrianthedev merged commit 4a85c71 into main Jun 21, 2024
8 of 27 checks passed
@adrianthedev adrianthedev deleted the fix/generators-can-run-without-prior-migrations branch June 21, 2024 11:30
Copy link
Contributor

This PR has been merged into main. The functionality will be available in the next release.

Please check the release guide for more information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants