suspenders 20240516.0 → 20251219.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -0
  3. data/CODEOWNERS +9 -0
  4. data/CONTRIBUTING.md +71 -0
  5. data/FEATURES.md +177 -0
  6. data/GOALS.md +65 -0
  7. data/LICENSE +21 -0
  8. data/NEWS.md +808 -0
  9. data/README.md +73 -60
  10. data/RELEASING.md +18 -0
  11. data/Rakefile +7 -10
  12. data/SECURITY.md +19 -0
  13. data/exe/suspenders +38 -0
  14. data/lib/suspenders/cli.rb +64 -0
  15. data/lib/suspenders/version.rb +4 -4
  16. data/lib/suspenders.rb +5 -6
  17. data/lib/templates/Procfile +3 -0
  18. data/lib/templates/Procfile.dev +2 -0
  19. data/lib/{generators/templates/views/flashes.html.erb → templates/app/views/application/_flashes.html.erb} +4 -2
  20. data/lib/templates/app/views/application/_form_errors.html.erb +11 -0
  21. data/lib/templates/config/initializers/sidekiq.rb +14 -0
  22. data/lib/templates/lib/development/seeder.rb +21 -0
  23. data/lib/templates/lib/tasks/development.rake +15 -0
  24. data/lib/templates/spec/support/action_mailer.rb +11 -0
  25. data/lib/{generators/templates/factories/factory_bot_rspec.rb → templates/spec/support/factory_bot.rb} +0 -2
  26. data/lib/templates/web.rb +544 -0
  27. data/sig/suspenders.rbs +4 -0
  28. metadata +34 -120
  29. data/lib/generators/suspenders/accessibility_generator.rb +0 -24
  30. data/lib/generators/suspenders/advisories_generator.rb +0 -32
  31. data/lib/generators/suspenders/ci_generator.rb +0 -57
  32. data/lib/generators/suspenders/email_generator.rb +0 -56
  33. data/lib/generators/suspenders/environments/development_generator.rb +0 -50
  34. data/lib/generators/suspenders/environments/production_generator.rb +0 -27
  35. data/lib/generators/suspenders/environments/test_generator.rb +0 -39
  36. data/lib/generators/suspenders/factories_generator.rb +0 -64
  37. data/lib/generators/suspenders/inline_svg_generator.rb +0 -24
  38. data/lib/generators/suspenders/install/web_generator.rb +0 -71
  39. data/lib/generators/suspenders/jobs_generator.rb +0 -34
  40. data/lib/generators/suspenders/lint_generator.rb +0 -94
  41. data/lib/generators/suspenders/prerequisites_generator.rb +0 -19
  42. data/lib/generators/suspenders/rake_generator.rb +0 -25
  43. data/lib/generators/suspenders/setup_generator.rb +0 -14
  44. data/lib/generators/suspenders/styles_generator.rb +0 -84
  45. data/lib/generators/suspenders/tasks_generator.rb +0 -20
  46. data/lib/generators/suspenders/testing_generator.rb +0 -113
  47. data/lib/generators/suspenders/views_generator.rb +0 -38
  48. data/lib/generators/templates/ci/ci.yml.tt +0 -148
  49. data/lib/generators/templates/ci/dependabot.yml +0 -7
  50. data/lib/generators/templates/email/email_interceptor.rb +0 -11
  51. data/lib/generators/templates/factories/factories.rb +0 -2
  52. data/lib/generators/templates/factories/factories_test.rb +0 -9
  53. data/lib/generators/templates/inline_svg/inline_svg.rb +0 -3
  54. data/lib/generators/templates/install/web/CONTRIBUTING.md +0 -94
  55. data/lib/generators/templates/lint/config_better_html.yml +0 -2
  56. data/lib/generators/templates/lint/config_initializers_better_html.rb +0 -9
  57. data/lib/generators/templates/lint/erb-lint.yml +0 -63
  58. data/lib/generators/templates/lint/erblint.rake +0 -47
  59. data/lib/generators/templates/lint/eslintrc.json +0 -7
  60. data/lib/generators/templates/lint/package.json +0 -4
  61. data/lib/generators/templates/lint/prettierignore +0 -1
  62. data/lib/generators/templates/lint/prettierrc +0 -11
  63. data/lib/generators/templates/lint/rubocop.yml.tt +0 -7
  64. data/lib/generators/templates/lint/stylelintrc.json +0 -3
  65. data/lib/generators/templates/prerequisites/node-version.tt +0 -1
  66. data/lib/generators/templates/setup/bin_setup.rb +0 -39
  67. data/lib/generators/templates/styles/postcss.config.js +0 -11
  68. data/lib/generators/templates/tasks/dev.rake +0 -12
  69. data/lib/generators/templates/testing/action_mailer.rb +0 -5
  70. data/lib/install/web.rb +0 -54
  71. data/lib/suspenders/cleanup/generate_readme.rb +0 -165
  72. data/lib/suspenders/cleanup/organize_gemfile.rb +0 -134
  73. data/lib/suspenders/engine.rb +0 -5
  74. data/lib/suspenders/generators.rb +0 -126
  75. data/lib/suspenders/railtie.rb +0 -4
  76. data/lib/tasks/suspenders.rake +0 -37
  77. /data/lib/{generators/templates/factories → templates/spec}/factories_spec.rb +0 -0
  78. /data/lib/{generators/templates/testing → templates/spec/support}/driver.rb +0 -0
  79. /data/lib/{generators/templates/testing → templates/spec/support}/i18n.rb +0 -0
  80. /data/lib/{generators/templates/testing → templates/spec/support}/shoulda_matchers.rb +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8c2709f640163cac9a711d3fbc428db7771bf0082f8052f0e37cf1b60357fcbf
4
- data.tar.gz: 8a2d49d93399ead80a3ef658124bd3657fb68bc923b3091bc42f390c22b9abf4
3
+ metadata.gz: 34fd9221d0876ccf710832f66749e3612ded0cf199b74aa6e7de5f3349a6ee6e
4
+ data.tar.gz: 21343be6558eb34c36737078c547aefb00d2aa266b2cd4d83c30604f71fe0dbf
5
5
  SHA512:
6
- metadata.gz: ad3ba6902b12457e407ac81beade17ec912918d64a0e58eb7874c8214f861deead37497e06214fbae8effc30e7dfff02b4c0006a23a7b6bf0a03f4977538a18b
7
- data.tar.gz: f3e992788aa0424a1b198ae611a9bed2542d80c12b321946a02fdf17fc05126f6f9b7a86fccbe2470aba77a72bc02612603fcfa072fba621b458e5c3d9981afe
6
+ metadata.gz: 5bc014a8127e6574d28f2c620a0f6215382fd1adbca4c52bcce575811da459bfefe5b159fdd5468348bc114045e015b4b097370665fa8b5ca0ce45bb1f5c9e1a
7
+ data.tar.gz: 9ae2e1ea7c7bdac2a9eab343e3228290d53a953baf9514763a422a62072fd41a90b0713b271862f7f064a16cc79e5a9506086f4391c785b415895f1dc100bcf6
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.3.1
data/CODEOWNERS ADDED
@@ -0,0 +1,9 @@
1
+ # Lines starting with '#' are comments.
2
+ # Each line is a file pattern followed by one or more owners.
3
+
4
+ # More details are here: https://help.github.com/articles/about-codeowners/
5
+
6
+ # The '*' pattern is global owners.
7
+
8
+ # Global rule:
9
+ * @stevepolitodesign
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,71 @@
1
+ # Contributing
2
+
3
+ We love contributions from everyone.
4
+ By participating in this project,
5
+ you agree to abide by the thoughtbot [code of conduct].
6
+
7
+ [code of conduct]: https://thoughtbot.com/open-source-code-of-conduct
8
+
9
+ We expect everyone to follow the code of conduct
10
+ anywhere in thoughtbot's project codebases,
11
+ issue trackers, chatrooms, and mailing lists.
12
+
13
+ ## Contributing Code
14
+
15
+ Fork the repo.
16
+
17
+ Run the setup script.
18
+
19
+ ```
20
+ ./bin/setup
21
+ ```
22
+
23
+ Make sure everything passes:
24
+
25
+ ```
26
+ bundle exec rake
27
+ ```
28
+
29
+ Make your change, with new passing tests.
30
+
31
+ Mention how your changes affect the project to other developers and users in the
32
+ `NEWS.md` file.
33
+
34
+ Push to your fork. Write a [good commit message][commit]. Submit a pull request.
35
+
36
+ [commit]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
37
+
38
+ Others will give constructive feedback.
39
+ This is a time for discussion and improvements,
40
+ and making the necessary changes will be required before we can
41
+ merge the contribution.
42
+
43
+ ## Testing the executable Locally
44
+
45
+ To install this gem onto your local machine, run `bundle exec rake install`.
46
+ From there, you can run `suspenders new <app_name>` to test the current code.
47
+
48
+ In an effort to help distinguish code generated by `rails new` from code
49
+ generated by the application template, you can run `bin/qa`.
50
+
51
+ From there you can `cd qa` and run `git diff` to see what changed.
52
+
53
+ This can be useful for testing Suspenders after a new release of Rails.
54
+
55
+ ## Documenting changes to generated application
56
+
57
+ Be sure to update `FEATURES.md` and the contents of `update_readme` within
58
+ `web.rb` anytime you add, update or remove a feature to the generated
59
+ application.
60
+
61
+ ## Publishing to RubyGems
62
+
63
+ When the gem is ready to be shared as a formal release, it can be
64
+ [published][published] to RubyGems.
65
+
66
+ [published]: https://guides.rubyonrails.org/plugins.html#publishing-your-gem
67
+
68
+ 1. Bump the version number in `Suspenders::VERSION`
69
+ 2. Run `bundle exec rake build`
70
+ 3. Run `bundle exec rake install`
71
+ 4. Run `bundle exec rake release`
data/FEATURES.md ADDED
@@ -0,0 +1,177 @@
1
+ # Features
2
+
3
+ ## Local Development
4
+
5
+ ### Strong Migrations
6
+
7
+ Uses [Strong Migrations][] to catch unsafe migrations in development.
8
+
9
+ [Strong Migrations]: https://github.com/ankane/strong_migrations
10
+
11
+ ### Seed Data
12
+
13
+ Follows [our guidance][seed-data-guide] for managing seed data. Use
14
+ `db/seeds.rb` for data required in **all** environments, and
15
+ `development:db:seed` for data specific to development environments.
16
+
17
+ Place idempotent seed data in `Development::Seeder`.
18
+
19
+ To load development seed data:
20
+
21
+ ```bash
22
+ bin/rails development:db:seed
23
+ ```
24
+
25
+ To reset your database and reload seed data:
26
+
27
+ ```bash
28
+ bin/rails development:db:seed:replant
29
+ ```
30
+
31
+ The `replant` command truncates all tables and reloads the seed data, providing
32
+ a clean slate for development.
33
+
34
+ [seed-data-guide]: https://github.com/thoughtbot/guides/blob/main/rails/how-to/seed-data.md
35
+
36
+ ## Environment Variables
37
+
38
+ The following environment variables are available in `production`:
39
+
40
+ - `APPLICATION_HOST` - The domain where your application is hosted (required)
41
+ - `ASSET_HOST` - CDN or asset host URL (optional)
42
+ - `RAILS_MASTER_KEY` - Used for decrypting credentials (required)
43
+
44
+ ## Configuration
45
+
46
+ ### All Environments
47
+
48
+ - Enables [strict_loading_by_default][].
49
+ - Sets [strict_loading_mode][] to `:n_plus_one`.
50
+ - Enables [require_master_key][].
51
+
52
+ [strict_loading_by_default]: https://guides.rubyonrails.org/configuring.html#config-active-record-strict-loading-by-default
53
+ [strict_loading_mode]: https://guides.rubyonrails.org/configuring.html#config-active-record-strict-loading-mode
54
+ [require_master_key]: https://guides.rubyonrails.org/configuring.html#config-require-master-key
55
+
56
+ ### Test
57
+
58
+ - Enables [raise_on_missing_translations][].
59
+ - Sets [action_dispatch.show_exceptions][] to `:none`.
60
+
61
+ [raise_on_missing_translations]: https://guides.rubyonrails.org/configuring.html#config-i18n-raise-on-missing-translations
62
+ [action_dispatch.show_exceptions]: https://edgeguides.rubyonrails.org/configuring.html#config-action-dispatch-show-exceptions
63
+
64
+ ### Development
65
+
66
+ - Enables [raise_on_missing_translations][].
67
+ - Enables [i18n_customize_full_message][].
68
+ - Enables [apply_rubocop_autocorrect_after_generate!][].
69
+
70
+ [raise_on_missing_translations]: https://guides.rubyonrails.org/configuring.html#config-i18n-raise-on-missing-translations
71
+ [i18n_customize_full_message]: https://guides.rubyonrails.org/configuring.html#config-active-model-i18n-customize-full-message
72
+ [apply_rubocop_autocorrect_after_generate!]: https://guides.rubyonrails.org/configuring.html#configuring-generators
73
+
74
+ ### Production
75
+
76
+ - Enables [sandbox_by_default][].
77
+ - Sets [action_on_strict_loading_violation][] to `:log`.
78
+
79
+ [sandbox_by_default]: https://guides.rubyonrails.org/configuring.html#config-sandbox-by-default
80
+ [action_on_strict_loading_violation]: https://guides.rubyonrails.org/configuring.html#config-active-record-action-on-strict-loading-violation
81
+
82
+ ## Testing
83
+
84
+ Uses [RSpec][] and [RSpec Rails][] in favor of the [default test suite][].
85
+
86
+ The test suite can be run with `bin/rails spec`.
87
+
88
+ Configuration can be found in the following files:
89
+
90
+ ```
91
+ spec/rails_helper.rb
92
+ spec/spec_helper.rb
93
+ spec/support/action_mailer.rb
94
+ spec/support/driver.rb
95
+ spec/support/i18n.rb
96
+ spec/support/shoulda_matchers.rb
97
+ ```
98
+
99
+ - Uses [action_dispatch-testing-integration-capybara][] to introduce Capybara assertions into Request specs.
100
+ - Uses [shoulda-matchers][] for simple one-liner tests for common Rails functionality.
101
+ - Uses [webmock][] for stubbing and setting expectations on HTTP requests in Ruby.
102
+
103
+ [RSpec]: http://rspec.info
104
+ [RSpec Rails]: https://github.com/rspec/rspec-rails
105
+ [default test suite]: https://guides.rubyonrails.org/testing.html
106
+ [action_dispatch-testing-integration-capybara]: https://github.com/thoughtbot/action_dispatch-testing-integration-capybara
107
+ [shoulda-matchers]: https://github.com/thoughtbot/shoulda-matchers
108
+ [webmock]: https://github.com/bblimke/webmock
109
+
110
+ ### Factories
111
+
112
+ Uses [FactoryBot][] as an alternative to [Fixtures][] to help you define
113
+ dummy and test data for your test suite. The `create`, `build`, and
114
+ `build_stubbed` class methods are directly available to all tests.
115
+
116
+ Place FactoryBot definitions in `spec/factories.rb`, at least until it
117
+ grows unwieldy. This helps reduce confusion around circular dependencies and
118
+ makes it easy to jump between definitions.
119
+
120
+ [FactoryBot]: https://github.com/thoughtbot/factory_bot
121
+ [Fixtures]: https://guides.rubyonrails.org/testing.html#the-low-down-on-fixtures
122
+
123
+ ## Accessibility
124
+
125
+ Uses [capybara_accessibility_audit][] and
126
+ [capybara_accessible_selectors][] to encourage and enforce accessibility best
127
+ practices.
128
+
129
+ [capybara_accessibility_audit]: https://github.com/thoughtbot/capybara_accessibility_audit
130
+ [capybara_accessible_selectors]: https://github.com/citizensadvice/capybara_accessible_selectors
131
+
132
+ ## Mailers
133
+
134
+ [Intercept][] emails in non-production environments by setting `INTERCEPTOR_ADDRESSES`.
135
+
136
+ ```sh
137
+ INTERCEPTOR_ADDRESSES="user_1@example.com,user_2@example.com" bin/rails s
138
+ ```
139
+
140
+ Configuration can be found at `config/initializers/email_interceptor.rb`.
141
+
142
+ Interceptor can be found at `lib/email_interceptor.rb`.
143
+
144
+ [Intercept]: https://guides.rubyonrails.org/action_mailer_basics.html#intercepting-emails
145
+
146
+ ## Jobs
147
+
148
+ Uses [Sidekiq][] for [background job][] processing.
149
+
150
+ Configures the `test` environment to use the [inline][] adapter.
151
+
152
+ [Sidekiq]: https://github.com/sidekiq/sidekiq
153
+ [background job]: https://guides.rubyonrails.org/active_job_basics.html
154
+ [inline]: https://api.rubyonrails.org/classes/ActiveJob/QueueAdapters/InlineAdapter.html
155
+
156
+ ## Layout and Assets
157
+
158
+ ### Inline SVG
159
+
160
+ Uses [inline_svg][] for embedding SVG documents into views.
161
+
162
+ Configuration can be found at `config/initializers/inline_svg.rb`
163
+
164
+ [inline_svg]: https://github.com/jamesmartin/inline_svg
165
+
166
+ ### Layout
167
+
168
+ - A [partial][] for [flash messages][] is located in `app/views/application/_flashes.html.erb`.
169
+ - A [partial][] for form errors is located in `app/views/application/_form_errors.html.erb`.
170
+ - Sets [lang][] attribute on `<html>` element to `en` via `I18n.local`.
171
+ - Disables Turbo's [Prefetch][] in an effort to reduce unnecessary network requests.
172
+
173
+ [partial]: https://guides.rubyonrails.org/layouts_and_rendering.html#using-partials
174
+ [flash messages]: https://guides.rubyonrails.org/action_controller_overview.html#the-flash
175
+ [lang]: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang
176
+ [title]: https://github.com/calebhearth/title
177
+ [Prefetch]: https://turbo.hotwired.dev/handbook/drive#prefetching-links-on-hover
data/GOALS.md ADDED
@@ -0,0 +1,65 @@
1
+ # Goals
2
+
3
+ Suspenders is an opinionated platform for adding functionality to a Rails app.
4
+ It encodes thoughtbot's opinions and decisions in tooling and best practices.
5
+
6
+ We are transitioning to a library of generators. All new functionality must be
7
+ in the form of a well-tested, self-contained generator that fits within the
8
+ Suspenders framework.
9
+
10
+ ## History and transitions
11
+
12
+ In the beginning suspenders was a git repo that we would clone then use as a
13
+ template for starting a new Rails app.
14
+
15
+ It then became a command-line tool that would generate a Rails app then modify
16
+ the files in place. Over time, and with intention, most of the modifications
17
+ were focused on modifying the Gemfile.
18
+
19
+ This was identified as unscalable and we have been slowing been moving in a new
20
+ direction: a library of generators.
21
+
22
+ ## The future
23
+
24
+ The problem with a script that adds a bunch of gem requirements to the Gemfile
25
+ is: what if you don't want all those gems? Suspenders adds gem requirements and
26
+ then configures each one. On a typical project we would run Suspenders then
27
+ spend the rest of the day un-doing the parts we don't want.
28
+
29
+ In 2015, [PR #511], we discussed what we want: a gem that is a library of
30
+ generators that we can run on demand. The ideal future workflow goes like this:
31
+
32
+ [PR #511]: https://github.com/thoughtbot/suspenders/pull/511
33
+
34
+ 1. `rails new my-cool-project && cd my-cool-project`
35
+ 2. `echo "gem 'suspenders', group: :development" >> Gemfile && bundle`
36
+ 3. `rails g suspenders:ci`
37
+ 4. Repeat with other generators as needed.
38
+
39
+ In this future you would use `rails new` as normal and instead add Suspenders
40
+ as a development gem. This gives you access to opinionated generators for
41
+ adding (and removing!) whole functionality, but on demand and with your
42
+ knowledge.
43
+
44
+ The generators are all named to generically describe what functionality they
45
+ add. In this way we can change our opinions on the implementation without
46
+ needing to know new generator names. For example, `suspenders:ci` could
47
+ configure the app for CircleCI now, but down the road we may decide to switch
48
+ everything to Jenkins; we could update the implementation of the generator
49
+ without changing its name.
50
+
51
+ ## From here to there
52
+
53
+ The transition looks like this:
54
+
55
+ 1. Introduce a `suspenders:all` generator that runs Suspenders against an
56
+ existing Rails app.
57
+ 2. Change the Suspenders program to create a Rails app, add Suspenders to the
58
+ Gemfile, and run `suspenders:all` inside of it.
59
+ 3. Slowly split functionality out from the "all" generator and into smaller,
60
+ well-tested, self-contained generators. The "all" generator invokes these
61
+ generators.
62
+ 4. Once that is completed -- once "all" _only_ calls other generators -- then
63
+ remove the Suspenders program and only distribute the gem.
64
+
65
+ We are on step (3), and it's a big one. Come help out!
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) thoughtbot, inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.