Skip to content

Conversation

stevepolitodesign
Copy link
Contributor

@stevepolitodesign stevepolitodesign commented Nov 11, 2023

Add necessary files to make the plugin an engine, which
automatically loads Rake tasks located in lib/tasks. This means when
the suspenders gem is installed, the consumer can run bundle exec rake suspenders:rake, and any future tasks.

Because suspenders:lint and suspenders:advisories may not
necessarily have been invoked, we need to check if those gems are
installed.

How to review this pull request

  1. Spin up a new Rails application.

    rails new rake_demo
  2. Scaffold a domain in order to generate passing tests.

    bin/rails g scaffold post title
    bin/rails db:migrate
  3. Install suspenders on this branch.

    group :development, :test do
      gem "suspenders", github: "thoughtbot/suspenders", branch: "suspenders-3-0-0-rake-generator"
    end
  4. Run the following generators.

    bin/rails g suspenders:advisories
    bin/rails g suspenders:lint
    bin/rails g suspenders:rake
  5. Run Rake and note the output. It should run the test suite, run standard
    and run bundler-audit.

    bundle exec rake

Co-authored-by: Mike Burns mburns@thoughtbot.com

@stevepolitodesign stevepolitodesign changed the base branch from main to suspenders-3-0-0 November 11, 2023 01:49
@stevepolitodesign stevepolitodesign force-pushed the suspenders-3-0-0-rake-generator branch 3 times, most recently from 87032f1 to cece45a Compare November 11, 2023 02:08
@mike-burns
Copy link
Contributor

I think we're running into a flexibility issue.

What if we made a default rake task that looks for whether bundler-audit is installed and run it if so, ignore it otherwise? I have no idea whether that's possible, but it would allow for the kind of extensibility we need.

in lib/suspenders/tasks.rb

task :suspenders do
  if Bundler.rubygems.find_name("bundle-audit").any?
    Rake::Task[:"bundle:audit"].run
  end

  if Bundler.rubygems.find_name("standard").any?
    Rake::Task[:standard].run
  end
end

generated Rakefile

require 'suspenders/tasks'
default: [:suspenders]

@stevepolitodesign stevepolitodesign mentioned this pull request Nov 17, 2023
17 tasks
stevepolitodesign added a commit that referenced this pull request Nov 28, 2023
The [original implementation][] was written in 2014, and is no longer
relevant. This is because the gem ships [with a Rake task][] that can be
set as the default task, which will be addressed in #1144

[original implementation]: e23157e
[with a Rake task]: https://github.com/rubysec/bundler-audit#rake-tasks
stevepolitodesign added a commit that referenced this pull request Nov 28, 2023
Uses the [bundler-audit][] gem to update the local security database and
show any relevant issues with the app's dependencies. This generator is
only responsible for installing the gem.

The [original implementation][] was written in 2014, and is no longer
relevant. This is because the gem ships [with a Rake task][] that can be
set as the default task, which will be addressed in #1144

Also exposes `backup_file` and `restore_file` test helpers into the
public API.

[bundler-audit]: https://github.com/rubysec/bundler-audit
[original implementation]: e23157e
[with a Rake task]: https://github.com/rubysec/bundler-audit#rake-tasks
stevepolitodesign added a commit that referenced this pull request Nov 28, 2023
Uses the [bundler-audit][] gem to update the local security database and
show any relevant issues with the app's dependencies. This generator is
only responsible for installing the gem.

The [original implementation][] was written in 2014, and is no longer
relevant. This is because the gem ships [with a Rake task][] that can be
set as the default task, which will be addressed in #1144

Also exposes `backup_file` and `restore_file` test helpers into the
public API.

[bundler-audit]: https://github.com/rubysec/bundler-audit
[original implementation]: e23157e
[with a Rake task]: https://github.com/rubysec/bundler-audit#rake-tasks
stevepolitodesign added a commit that referenced this pull request Nov 28, 2023
Uses the [bundler-audit][] gem to update the local security database and
show any relevant issues with the app's dependencies. This generator is
only responsible for installing the gem and adding the Rake task.

The [original implementation][] was written in 2014, and is no longer
relevant. This is because the gem ships [with a Rake task][] that can be
set as the default task, which will be addressed in #1144

Also exposes `backup_file` and `restore_file` test helpers into the
public API.

[bundler-audit]: https://github.com/rubysec/bundler-audit
[original implementation]: e23157e
[with a Rake task]: https://github.com/rubysec/bundler-audit#rake-tasks
stevepolitodesign added a commit that referenced this pull request Nov 28, 2023
Uses the [bundler-audit][] gem to update the local security database and
show any relevant issues with the app's dependencies. This generator is
only responsible for installing the gem and adding the Rake task.

The [original implementation][] was written in 2014, and is no longer
relevant. This is because the gem ships [with a Rake task][] that can be
set as the default task, which will be addressed in #1144

Also exposes `backup_file` and `restore_file` test helpers into the
public API.

[bundler-audit]: https://github.com/rubysec/bundler-audit
[original implementation]: e23157e
[with a Rake task]: https://github.com/rubysec/bundler-audit#rake-tasks
@stevepolitodesign stevepolitodesign force-pushed the suspenders-3-0-0-rake-generator branch from cece45a to 34fb28a Compare December 12, 2023 10:48
@stevepolitodesign stevepolitodesign marked this pull request as ready for review December 12, 2023 15:17
@stevepolitodesign stevepolitodesign force-pushed the suspenders-3-0-0-rake-generator branch from 34fb28a to 83ba7fd Compare December 12, 2023 15:17
Add necessary files to make the [plugin][] an [engine][], which
automatically loads Rake tasks located in `lib/tasks`. This means when
the `suspenders` gem is installed, the consumer can run `bundle exec
rake suspenders:rake`, and any future tasks.

Because `suspenders:lint` and `suspenders:advisories` may not
necessarily have been invoked, we need to check if those gems are
installed.

[plugin]: https://guides.rubyonrails.org/plugins.html
[engine]: https://guides.rubyonrails.org/engines.html

Co-authored-by: Mike Burns <mburns@thoughtbot.com>
@stevepolitodesign stevepolitodesign force-pushed the suspenders-3-0-0-rake-generator branch from 83ba7fd to 6251e9f Compare December 12, 2023 15:43
@stevepolitodesign stevepolitodesign merged commit 551d60b into suspenders-3-0-0 Dec 12, 2023
@stevepolitodesign stevepolitodesign deleted the suspenders-3-0-0-rake-generator branch December 12, 2023 17:51
stevepolitodesign added a commit that referenced this pull request May 10, 2024
Uses the [bundler-audit][] gem to update the local security database and
show any relevant issues with the app's dependencies. This generator is
only responsible for installing the gem and adding the Rake task.

The [original implementation][] was written in 2014, and is no longer
relevant. This is because the gem ships [with a Rake task][] that can be
set as the default task, which will be addressed in #1144

Also exposes `backup_file` and `restore_file` test helpers into the
public API.

[bundler-audit]: https://github.com/rubysec/bundler-audit
[original implementation]: e23157e
[with a Rake task]: https://github.com/rubysec/bundler-audit#rake-tasks
stevepolitodesign added a commit that referenced this pull request May 10, 2024
Add necessary files to make the [plugin][] an [engine][], which automatically
loads Rake tasks located in `lib/tasks`. This means when the `suspenders` gem is
installed, the consumer can run `bundle exec rake suspenders:rake`, and any
future tasks.

Because `suspenders:lint` and `suspenders:advisories` may not necessarily have
been invoked, we need to check if those gems are installed.

[plugin]: https://guides.rubyonrails.org/plugins.html
[engine]: https://guides.rubyonrails.org/engines.html

Co-authored-by: Mike Burns <mburns@thoughtbot.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants