Skip to content

Commit

Permalink
Allow running against suspenders main (#1230)
Browse files Browse the repository at this point in the history
**This PR:**
- Fixes [Issue 1229: How do we want to handle un-released versions?](#1229)
- Allows passing a `--suspenders-main` parameter to use the `main` branch of suspenders instead of the latest released version
- Updates documentation to suggest `skip-rubocop` over `skip_rubocop`

**Example:**
```
rails new app_name \
 --suspenders-main \
 --skip-rubocop \
 --skip-test \
 -d=postgresql \
 -m=https://raw.githubusercontent.com/thoughtbot/suspenders/main/lib/install/web.rb
```

Co-authored-by: Steve Polito <[email protected]>
  • Loading branch information
louis-antonopoulos and stevepolitodesign authored Oct 8, 2024
1 parent 1f13e7b commit 3bc560e
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 6 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Unreleased

* Require `--skip-rubocop` in favor of our [linting configuration][]
* Fixed: [Specify a tag when installing capybara_accessible_selectors](https://github.com/thoughtbot/suspenders/issues/1228)
* Fixed: [Issue 1229: How do we want to handle un-released versions?](https://github.com/thoughtbot/suspenders/issues/1229)

[linting configuration]: https://github.com/thoughtbot/suspenders/blob/main/FEATURES.md#linting

Expand Down
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,22 @@ PostgreSQL][] as our database.

We skip [RuboCop rules by default][] in favor of our [holistic linting rules][].

#### Use the latest suspenders release:

```
rails new app_name \
--skip-rubocop \
--skip-test \
-d=postgresql \
-m=https://raw.githubusercontent.com/thoughtbot/suspenders/main/lib/install/web.rb
```

#### OR use the current (possibly unreleased) `main` branch of suspenders:

```
rails new app_name \
--skip_rubocop \
--suspenders-main \
--skip-rubocop \
--skip-test \
-d=postgresql \
-m=https://raw.githubusercontent.com/thoughtbot/suspenders/main/lib/install/web.rb
Expand All @@ -49,7 +62,7 @@ Alternatively, if you're using our [dotfiles][], then you can just run `rails ne
app_name`, or create your own [railsrc][] file with the following configuration:

```
--skip_rubocop
--skip-rubocop
--skip-test
--database=postgresql
-m=https://raw.githubusercontent.com/thoughtbot/suspenders/main/lib/install/web.rb
Expand Down
19 changes: 16 additions & 3 deletions lib/generators/suspenders/install/web_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,24 @@ class WebGenerator < Rails::Generators::Base
This generatator is intended to be invoked as part of an [application template][].
#### Use the latest suspenders release:
```
rails new <app_name> \\
--skip-rubocop \\
--skip-test \\
-d=postgresql \\
-m=https://raw.githubusercontent.com/thoughtbot/suspenders/main/lib/install/web.rb
```
#### OR use the current (possibly unreleased) `main` branch of suspenders:
```
rails new <app_name> \
rails new app_name \\
--suspenders-main \\
--skip-rubocop \\
--skip-test \
-d=postgresql \
--skip-test \\
-d=postgresql \\
-m=https://raw.githubusercontent.com/thoughtbot/suspenders/main/lib/install/web.rb
```
Expand Down
16 changes: 15 additions & 1 deletion lib/install/web.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ def apply_template!
if options[:database] == "postgresql" && options[:skip_test] && options[:skip_rubocop]
after_bundle do
gem_group :development, :test do
gem "suspenders"
if ARGV.include?("--suspenders-main")
gem "suspenders", github: "thoughtbot/suspenders", branch: "main"
else
gem "suspenders"
end
end

run "bundle install"
Expand All @@ -41,11 +45,21 @@ def apply_template!
=== Please use the correct options ===
# Use the latest suspenders release:
rails new <app_name> \\
--skip-rubocop \\
--skip-test \\
-d=postgresql \\
-m=https://raw.githubusercontent.com/thoughtbot/suspenders/main/lib/install/web.rb
# OR use the current (possibly unreleased) `main` branch of suspenders:
rails new <app_name> \\
--suspenders-main \\
--skip-rubocop \\
--skip-test \\
-d=postgresql \\
-m=https://raw.githubusercontent.com/thoughtbot/suspenders/main/lib/install/web.rb
ERROR

fail Rails::Generators::Error, message
Expand Down

0 comments on commit 3bc560e

Please sign in to comment.