suspenders 20250317.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.
- checksums.yaml +4 -4
- data/.ruby-version +1 -0
- data/CODEOWNERS +9 -0
- data/CONTRIBUTING.md +71 -0
- data/FEATURES.md +177 -0
- data/GOALS.md +65 -0
- data/LICENSE +21 -0
- data/NEWS.md +808 -0
- data/README.md +59 -67
- data/RELEASING.md +18 -0
- data/Rakefile +6 -13
- data/SECURITY.md +19 -0
- data/exe/suspenders +38 -0
- data/lib/suspenders/cli.rb +64 -0
- data/lib/suspenders/version.rb +4 -4
- data/lib/suspenders.rb +5 -6
- data/lib/templates/Procfile +3 -0
- data/lib/templates/Procfile.dev +2 -0
- data/lib/{generators/templates/views/flashes.html.erb → templates/app/views/application/_flashes.html.erb} +4 -2
- data/lib/templates/app/views/application/_form_errors.html.erb +11 -0
- data/lib/templates/config/initializers/sidekiq.rb +14 -0
- data/lib/templates/lib/development/seeder.rb +21 -0
- data/lib/templates/lib/tasks/development.rake +15 -0
- data/lib/templates/spec/support/action_mailer.rb +11 -0
- data/lib/{generators/templates/factories/factory_bot_rspec.rb → templates/spec/support/factory_bot.rb} +0 -2
- data/lib/templates/web.rb +544 -0
- data/sig/suspenders.rbs +4 -0
- metadata +34 -119
- data/lib/generators/suspenders/accessibility_generator.rb +0 -24
- data/lib/generators/suspenders/advisories_generator.rb +0 -32
- data/lib/generators/suspenders/ci_generator.rb +0 -54
- data/lib/generators/suspenders/email_generator.rb +0 -56
- data/lib/generators/suspenders/environments/development_generator.rb +0 -50
- data/lib/generators/suspenders/environments/production_generator.rb +0 -27
- data/lib/generators/suspenders/environments/test_generator.rb +0 -39
- data/lib/generators/suspenders/factories_generator.rb +0 -64
- data/lib/generators/suspenders/inline_svg_generator.rb +0 -24
- data/lib/generators/suspenders/install/web_generator.rb +0 -85
- data/lib/generators/suspenders/jobs_generator.rb +0 -34
- data/lib/generators/suspenders/lint_generator.rb +0 -94
- data/lib/generators/suspenders/prerequisites_generator.rb +0 -19
- data/lib/generators/suspenders/rake_generator.rb +0 -25
- data/lib/generators/suspenders/setup_generator.rb +0 -14
- data/lib/generators/suspenders/styles_generator.rb +0 -84
- data/lib/generators/suspenders/tasks_generator.rb +0 -20
- data/lib/generators/suspenders/testing_generator.rb +0 -113
- data/lib/generators/suspenders/views_generator.rb +0 -38
- data/lib/generators/templates/ci/ci.yml.tt +0 -148
- data/lib/generators/templates/email/email_interceptor.rb +0 -11
- data/lib/generators/templates/factories/factories.rb +0 -2
- data/lib/generators/templates/factories/factories_test.rb +0 -9
- data/lib/generators/templates/inline_svg/inline_svg.rb +0 -3
- data/lib/generators/templates/install/web/CONTRIBUTING.md +0 -94
- data/lib/generators/templates/lint/config_better_html.yml +0 -2
- data/lib/generators/templates/lint/config_initializers_better_html.rb +0 -9
- data/lib/generators/templates/lint/erb-lint.yml +0 -63
- data/lib/generators/templates/lint/erblint.rake +0 -47
- data/lib/generators/templates/lint/eslintrc.json +0 -7
- data/lib/generators/templates/lint/package.json +0 -4
- data/lib/generators/templates/lint/prettierignore +0 -1
- data/lib/generators/templates/lint/prettierrc +0 -11
- data/lib/generators/templates/lint/rubocop.yml.tt +0 -7
- data/lib/generators/templates/lint/stylelintrc.json +0 -3
- data/lib/generators/templates/prerequisites/node-version.tt +0 -1
- data/lib/generators/templates/setup/bin_setup.rb +0 -39
- data/lib/generators/templates/styles/postcss.config.js +0 -11
- data/lib/generators/templates/tasks/dev.rake +0 -12
- data/lib/generators/templates/testing/action_mailer.rb +0 -5
- data/lib/install/web.rb +0 -70
- data/lib/suspenders/cleanup/generate_readme.rb +0 -165
- data/lib/suspenders/cleanup/organize_gemfile.rb +0 -134
- data/lib/suspenders/engine.rb +0 -5
- data/lib/suspenders/generators.rb +0 -126
- data/lib/suspenders/railtie.rb +0 -4
- data/lib/tasks/suspenders.rake +0 -37
- /data/lib/{generators/templates/factories → templates/spec}/factories_spec.rb +0 -0
- /data/lib/{generators/templates/testing → templates/spec/support}/driver.rb +0 -0
- /data/lib/{generators/templates/testing → templates/spec/support}/i18n.rb +0 -0
- /data/lib/{generators/templates/testing → templates/spec/support}/shoulda_matchers.rb +0 -0
metadata
CHANGED
|
@@ -1,71 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: suspenders
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: '
|
|
4
|
+
version: '20251219.0'
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- thoughtbot
|
|
8
|
-
|
|
9
|
-
bindir: bin
|
|
8
|
+
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
12
|
-
dependencies:
|
|
13
|
-
- !ruby/object:Gem::Dependency
|
|
14
|
-
name: rails
|
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
|
16
|
-
requirements:
|
|
17
|
-
- - "~>"
|
|
18
|
-
- !ruby/object:Gem::Version
|
|
19
|
-
version: '8.0'
|
|
20
|
-
type: :runtime
|
|
21
|
-
prerelease: false
|
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
-
requirements:
|
|
24
|
-
- - "~>"
|
|
25
|
-
- !ruby/object:Gem::Version
|
|
26
|
-
version: '8.0'
|
|
27
|
-
- !ruby/object:Gem::Dependency
|
|
28
|
-
name: climate_control
|
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
|
30
|
-
requirements:
|
|
31
|
-
- - ">="
|
|
32
|
-
- !ruby/object:Gem::Version
|
|
33
|
-
version: '0'
|
|
34
|
-
type: :development
|
|
35
|
-
prerelease: false
|
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
-
requirements:
|
|
38
|
-
- - ">="
|
|
39
|
-
- !ruby/object:Gem::Version
|
|
40
|
-
version: '0'
|
|
41
|
-
- !ruby/object:Gem::Dependency
|
|
42
|
-
name: mocha
|
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
|
44
|
-
requirements:
|
|
45
|
-
- - ">="
|
|
46
|
-
- !ruby/object:Gem::Version
|
|
47
|
-
version: '0'
|
|
48
|
-
type: :development
|
|
49
|
-
prerelease: false
|
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
-
requirements:
|
|
52
|
-
- - ">="
|
|
53
|
-
- !ruby/object:Gem::Version
|
|
54
|
-
version: '0'
|
|
55
|
-
- !ruby/object:Gem::Dependency
|
|
56
|
-
name: standard
|
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
|
58
|
-
requirements:
|
|
59
|
-
- - ">="
|
|
60
|
-
- !ruby/object:Gem::Version
|
|
61
|
-
version: '0'
|
|
62
|
-
type: :development
|
|
63
|
-
prerelease: false
|
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
-
requirements:
|
|
66
|
-
- - ">="
|
|
67
|
-
- !ruby/object:Gem::Version
|
|
68
|
-
version: '0'
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
69
12
|
description: |
|
|
70
13
|
Suspenders is a Rails plugin containing generators for configuring Rails
|
|
71
14
|
applications. It is used by thoughtbot to get a jump start on a new or
|
|
@@ -73,67 +16,41 @@ description: |
|
|
|
73
16
|
don't use it if you like missing deadlines.
|
|
74
17
|
email:
|
|
75
18
|
- support@thoughtbot.com
|
|
76
|
-
executables:
|
|
19
|
+
executables:
|
|
20
|
+
- suspenders
|
|
77
21
|
extensions: []
|
|
78
22
|
extra_rdoc_files: []
|
|
79
23
|
files:
|
|
24
|
+
- ".ruby-version"
|
|
25
|
+
- CODEOWNERS
|
|
26
|
+
- CONTRIBUTING.md
|
|
27
|
+
- FEATURES.md
|
|
28
|
+
- GOALS.md
|
|
29
|
+
- LICENSE
|
|
30
|
+
- NEWS.md
|
|
80
31
|
- README.md
|
|
32
|
+
- RELEASING.md
|
|
81
33
|
- Rakefile
|
|
82
|
-
-
|
|
83
|
-
-
|
|
84
|
-
- lib/generators/suspenders/ci_generator.rb
|
|
85
|
-
- lib/generators/suspenders/email_generator.rb
|
|
86
|
-
- lib/generators/suspenders/environments/development_generator.rb
|
|
87
|
-
- lib/generators/suspenders/environments/production_generator.rb
|
|
88
|
-
- lib/generators/suspenders/environments/test_generator.rb
|
|
89
|
-
- lib/generators/suspenders/factories_generator.rb
|
|
90
|
-
- lib/generators/suspenders/inline_svg_generator.rb
|
|
91
|
-
- lib/generators/suspenders/install/web_generator.rb
|
|
92
|
-
- lib/generators/suspenders/jobs_generator.rb
|
|
93
|
-
- lib/generators/suspenders/lint_generator.rb
|
|
94
|
-
- lib/generators/suspenders/prerequisites_generator.rb
|
|
95
|
-
- lib/generators/suspenders/rake_generator.rb
|
|
96
|
-
- lib/generators/suspenders/setup_generator.rb
|
|
97
|
-
- lib/generators/suspenders/styles_generator.rb
|
|
98
|
-
- lib/generators/suspenders/tasks_generator.rb
|
|
99
|
-
- lib/generators/suspenders/testing_generator.rb
|
|
100
|
-
- lib/generators/suspenders/views_generator.rb
|
|
101
|
-
- lib/generators/templates/ci/ci.yml.tt
|
|
102
|
-
- lib/generators/templates/email/email_interceptor.rb
|
|
103
|
-
- lib/generators/templates/factories/factories.rb
|
|
104
|
-
- lib/generators/templates/factories/factories_spec.rb
|
|
105
|
-
- lib/generators/templates/factories/factories_test.rb
|
|
106
|
-
- lib/generators/templates/factories/factory_bot_rspec.rb
|
|
107
|
-
- lib/generators/templates/inline_svg/inline_svg.rb
|
|
108
|
-
- lib/generators/templates/install/web/CONTRIBUTING.md
|
|
109
|
-
- lib/generators/templates/lint/config_better_html.yml
|
|
110
|
-
- lib/generators/templates/lint/config_initializers_better_html.rb
|
|
111
|
-
- lib/generators/templates/lint/erb-lint.yml
|
|
112
|
-
- lib/generators/templates/lint/erblint.rake
|
|
113
|
-
- lib/generators/templates/lint/eslintrc.json
|
|
114
|
-
- lib/generators/templates/lint/package.json
|
|
115
|
-
- lib/generators/templates/lint/prettierignore
|
|
116
|
-
- lib/generators/templates/lint/prettierrc
|
|
117
|
-
- lib/generators/templates/lint/rubocop.yml.tt
|
|
118
|
-
- lib/generators/templates/lint/stylelintrc.json
|
|
119
|
-
- lib/generators/templates/prerequisites/node-version.tt
|
|
120
|
-
- lib/generators/templates/setup/bin_setup.rb
|
|
121
|
-
- lib/generators/templates/styles/postcss.config.js
|
|
122
|
-
- lib/generators/templates/tasks/dev.rake
|
|
123
|
-
- lib/generators/templates/testing/action_mailer.rb
|
|
124
|
-
- lib/generators/templates/testing/driver.rb
|
|
125
|
-
- lib/generators/templates/testing/i18n.rb
|
|
126
|
-
- lib/generators/templates/testing/shoulda_matchers.rb
|
|
127
|
-
- lib/generators/templates/views/flashes.html.erb
|
|
128
|
-
- lib/install/web.rb
|
|
34
|
+
- SECURITY.md
|
|
35
|
+
- exe/suspenders
|
|
129
36
|
- lib/suspenders.rb
|
|
130
|
-
- lib/suspenders/
|
|
131
|
-
- lib/suspenders/cleanup/organize_gemfile.rb
|
|
132
|
-
- lib/suspenders/engine.rb
|
|
133
|
-
- lib/suspenders/generators.rb
|
|
134
|
-
- lib/suspenders/railtie.rb
|
|
37
|
+
- lib/suspenders/cli.rb
|
|
135
38
|
- lib/suspenders/version.rb
|
|
136
|
-
- lib/
|
|
39
|
+
- lib/templates/Procfile
|
|
40
|
+
- lib/templates/Procfile.dev
|
|
41
|
+
- lib/templates/app/views/application/_flashes.html.erb
|
|
42
|
+
- lib/templates/app/views/application/_form_errors.html.erb
|
|
43
|
+
- lib/templates/config/initializers/sidekiq.rb
|
|
44
|
+
- lib/templates/lib/development/seeder.rb
|
|
45
|
+
- lib/templates/lib/tasks/development.rake
|
|
46
|
+
- lib/templates/spec/factories_spec.rb
|
|
47
|
+
- lib/templates/spec/support/action_mailer.rb
|
|
48
|
+
- lib/templates/spec/support/driver.rb
|
|
49
|
+
- lib/templates/spec/support/factory_bot.rb
|
|
50
|
+
- lib/templates/spec/support/i18n.rb
|
|
51
|
+
- lib/templates/spec/support/shoulda_matchers.rb
|
|
52
|
+
- lib/templates/web.rb
|
|
53
|
+
- sig/suspenders.rbs
|
|
137
54
|
homepage: http://github.com/thoughtbot/suspenders
|
|
138
55
|
licenses:
|
|
139
56
|
- MIT
|
|
@@ -141,7 +58,6 @@ metadata:
|
|
|
141
58
|
homepage_uri: http://github.com/thoughtbot/suspenders
|
|
142
59
|
source_code_uri: http://github.com/thoughtbot/suspenders
|
|
143
60
|
changelog_uri: https://github.com/thoughtbot/suspenders/blob/main/NEWS.md
|
|
144
|
-
post_install_message:
|
|
145
61
|
rdoc_options: []
|
|
146
62
|
require_paths:
|
|
147
63
|
- lib
|
|
@@ -149,15 +65,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
149
65
|
requirements:
|
|
150
66
|
- - ">="
|
|
151
67
|
- !ruby/object:Gem::Version
|
|
152
|
-
version:
|
|
68
|
+
version: 3.2.0
|
|
153
69
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
154
70
|
requirements:
|
|
155
71
|
- - ">="
|
|
156
72
|
- !ruby/object:Gem::Version
|
|
157
73
|
version: '0'
|
|
158
74
|
requirements: []
|
|
159
|
-
rubygems_version: 3.
|
|
160
|
-
signing_key:
|
|
75
|
+
rubygems_version: 3.7.2
|
|
161
76
|
specification_version: 4
|
|
162
77
|
summary: Rails generators using thoughtbot's best practices.
|
|
163
78
|
test_files: []
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
module Suspenders
|
|
2
|
-
module Generators
|
|
3
|
-
class AccessibilityGenerator < Rails::Generators::Base
|
|
4
|
-
include Suspenders::Generators::APIAppUnsupported
|
|
5
|
-
|
|
6
|
-
desc <<~MARKDOWN
|
|
7
|
-
Uses [capybara_accessibility_audit][] and
|
|
8
|
-
[capybara_accessible_selectors][] to encourage and enforce accessibility best
|
|
9
|
-
practices.
|
|
10
|
-
|
|
11
|
-
[capybara_accessibility_audit]: https://github.com/thoughtbot/capybara_accessibility_audit
|
|
12
|
-
[capybara_accessible_selectors]: https://github.com/citizensadvice/capybara_accessible_selectors
|
|
13
|
-
MARKDOWN
|
|
14
|
-
|
|
15
|
-
def add_capybara_gems
|
|
16
|
-
gem_group :test do
|
|
17
|
-
gem "capybara_accessibility_audit", github: "thoughtbot/capybara_accessibility_audit"
|
|
18
|
-
gem "capybara_accessible_selectors", github: "citizensadvice/capybara_accessible_selectors", tag: "v0.12.0"
|
|
19
|
-
end
|
|
20
|
-
Bundler.with_unbundled_env { run "bundle install" }
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
module Suspenders
|
|
2
|
-
module Generators
|
|
3
|
-
class AdvisoriesGenerator < Rails::Generators::Base
|
|
4
|
-
source_root File.expand_path("../../templates/advisories", __FILE__)
|
|
5
|
-
desc <<~MARKDOWN
|
|
6
|
-
Uses [bundler-audit][] to update the local security database and show
|
|
7
|
-
any relevant issues with the app's dependencies via a Rake task.
|
|
8
|
-
|
|
9
|
-
[bundler-audit]: https://github.com/rubysec/bundler-audit
|
|
10
|
-
MARKDOWN
|
|
11
|
-
|
|
12
|
-
def add_bundler_audit
|
|
13
|
-
gem_group :development, :test do
|
|
14
|
-
gem "bundler-audit", ">= 0.7.0", require: false
|
|
15
|
-
end
|
|
16
|
-
Bundler.with_unbundled_env { run "bundle install" }
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def modify_rakefile
|
|
20
|
-
content = <<~RUBY
|
|
21
|
-
|
|
22
|
-
if Rails.env.local?
|
|
23
|
-
require "bundler/audit/task"
|
|
24
|
-
Bundler::Audit::Task.new
|
|
25
|
-
end
|
|
26
|
-
RUBY
|
|
27
|
-
|
|
28
|
-
insert_into_file "Rakefile", content, after: /require_relative "config\/application"\n/
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
module Suspenders
|
|
2
|
-
module Generators
|
|
3
|
-
class CiGenerator < Rails::Generators::Base
|
|
4
|
-
include Suspenders::Generators::DatabaseUnsupported
|
|
5
|
-
include Suspenders::Generators::Helpers
|
|
6
|
-
|
|
7
|
-
source_root File.expand_path("../../templates/ci", __FILE__)
|
|
8
|
-
desc <<~MARKDOWN
|
|
9
|
-
Uses [GitHub Actions][] for CI
|
|
10
|
-
|
|
11
|
-
[GitHub Actions]: https://docs.github.com/en/actions
|
|
12
|
-
MARKDOWN
|
|
13
|
-
|
|
14
|
-
def ci_files
|
|
15
|
-
template "ci.yml", ".github/workflows/ci.yml", force: true
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
private
|
|
19
|
-
|
|
20
|
-
def scan_ruby?
|
|
21
|
-
has_gem? "bundler-audit"
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def scan_js?
|
|
25
|
-
File.exist?("bin/importmap") && using_node?
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def lint?
|
|
29
|
-
using_node? && has_gem?("standard") && has_yarn_script?("lint")
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def using_node?
|
|
33
|
-
File.exist? "package.json"
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def has_gem?(name)
|
|
37
|
-
Bundler.rubygems.find_name(name).any?
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def using_rspec?
|
|
41
|
-
File.exist? "spec"
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def has_yarn_script?(name)
|
|
45
|
-
return false if !using_node?
|
|
46
|
-
|
|
47
|
-
content = File.read("package.json")
|
|
48
|
-
json = JSON.parse(content)
|
|
49
|
-
|
|
50
|
-
json.dig("scripts", name)
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
module Suspenders
|
|
2
|
-
module Generators
|
|
3
|
-
class EmailGenerator < Rails::Generators::Base
|
|
4
|
-
source_root File.expand_path("../../templates/email", __FILE__)
|
|
5
|
-
desc <<~MARKDOWN
|
|
6
|
-
[Intercept][] emails in non-production environments by setting `INTERCEPTOR_ADDRESSES`.
|
|
7
|
-
|
|
8
|
-
```sh
|
|
9
|
-
INTERCEPTOR_ADDRESSES="user_1@example.com,user_2@example.com" bin/rails s
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
Configuration can be found at `config/initializers/email_interceptor.rb`.
|
|
13
|
-
|
|
14
|
-
Interceptor can be found at `app/mailers/email_interceptor.rb`.
|
|
15
|
-
|
|
16
|
-
[Intercept]: https://guides.rubyonrails.org/action_mailer_basics.html#intercepting-emails
|
|
17
|
-
MARKDOWN
|
|
18
|
-
|
|
19
|
-
def create_email_interceptor
|
|
20
|
-
copy_file "email_interceptor.rb", "app/mailers/email_interceptor.rb"
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def create_email_interceptor_initializer
|
|
24
|
-
initializer "email_interceptor.rb", <<~RUBY
|
|
25
|
-
Rails.application.configure do
|
|
26
|
-
if ENV["INTERCEPTOR_ADDRESSES"].present?
|
|
27
|
-
config.action_mailer.interceptors = %w[EmailInterceptor]
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
RUBY
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def configure_email_interceptor
|
|
34
|
-
environment do
|
|
35
|
-
%(
|
|
36
|
-
config.to_prepare do
|
|
37
|
-
EmailInterceptor.config.interceptor_addresses = ENV.fetch("INTERCEPTOR_ADDRESSES", "").split(",")
|
|
38
|
-
end
|
|
39
|
-
)
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
# TODO: Remove once https://github.com/rails/rails/pull/51191 is in latest
|
|
44
|
-
# Rails release
|
|
45
|
-
def configure_development_environment
|
|
46
|
-
environment %(config.action_mailer.default_url_options = { host: "localhost", port: 3000 }), env: "development"
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
# TODO: Remove once https://github.com/rails/rails/pull/51191 is in latest
|
|
50
|
-
# Rails release
|
|
51
|
-
def configure_test_environment
|
|
52
|
-
environment %(config.action_mailer.default_url_options = { host: "www.example.com" }), env: "test"
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
end
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
module Suspenders
|
|
2
|
-
module Generators
|
|
3
|
-
module Environments
|
|
4
|
-
class DevelopmentGenerator < Rails::Generators::Base
|
|
5
|
-
desc <<~MARKDOWN
|
|
6
|
-
- Enables [raise_on_missing_translations][].
|
|
7
|
-
- Enables [annotate_rendered_view_with_filenames][].
|
|
8
|
-
- Enables [i18n_customize_full_message][].
|
|
9
|
-
- Enables [query_log_tags_enabled][].
|
|
10
|
-
|
|
11
|
-
[raise_on_missing_translations]: https://guides.rubyonrails.org/configuring.html#config-i18n-raise-on-missing-translations
|
|
12
|
-
[annotate_rendered_view_with_filenames]: https://guides.rubyonrails.org/configuring.html#config-action-view-annotate-rendered-view-with-filenames
|
|
13
|
-
[i18n_customize_full_message]: https://guides.rubyonrails.org/configuring.html#config-active-model-i18n-customize-full-message
|
|
14
|
-
[query_log_tags_enabled]: https://guides.rubyonrails.org/configuring.html#config-active-record-query-log-tags-enabled
|
|
15
|
-
MARKDOWN
|
|
16
|
-
|
|
17
|
-
def raise_on_missing_translations
|
|
18
|
-
if development_config.match?(/^\s#\s*config\.i18n\.raise_on_missing_translations/)
|
|
19
|
-
uncomment_lines "config/environments/development.rb", "config.i18n.raise_on_missing_translations = true"
|
|
20
|
-
else
|
|
21
|
-
environment %(config.i18n.raise_on_missing_translations = true), env: "development"
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def annotate_render_view_with_filename
|
|
26
|
-
if development_config.match?(/^\s#\s*config\.action_view\.annotate_render_view_with_filename/)
|
|
27
|
-
uncomment_lines "config/environments/development.rb",
|
|
28
|
-
"config.action_view.annotate_rendered_view_with_filenames = true"
|
|
29
|
-
else
|
|
30
|
-
environment %(config.action_view.annotate_rendered_view_with_filenames = true), env: "development"
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def enable_i18n_customize_full_message
|
|
35
|
-
environment %(config.active_model.i18n_customize_full_message = true), env: "development"
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def enable_query_log_tags_enabled
|
|
39
|
-
environment %(config.active_record.query_log_tags_enabled = true), env: "development"
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
private
|
|
43
|
-
|
|
44
|
-
def development_config
|
|
45
|
-
File.read(Rails.root.join("config/environments/development.rb"))
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
module Suspenders
|
|
2
|
-
module Generators
|
|
3
|
-
module Environments
|
|
4
|
-
class ProductionGenerator < Rails::Generators::Base
|
|
5
|
-
desc <<~MARKDOWN
|
|
6
|
-
- Enables [require_master_key][].
|
|
7
|
-
|
|
8
|
-
[require_master_key]: https://guides.rubyonrails.org/configuring.html#config-require-master-key
|
|
9
|
-
MARKDOWN
|
|
10
|
-
|
|
11
|
-
def require_master_key
|
|
12
|
-
if production_config.match?(/^\s*#\s*config\.require_master_key\s*=\s*true/)
|
|
13
|
-
uncomment_lines "config/environments/production.rb", /config\.require_master_key\s*=\s*true/
|
|
14
|
-
else
|
|
15
|
-
environment %(config.require_master_key = true), env: "production"
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
private
|
|
20
|
-
|
|
21
|
-
def production_config
|
|
22
|
-
File.read(Rails.root.join("config/environments/production.rb"))
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
module Suspenders
|
|
2
|
-
module Generators
|
|
3
|
-
module Environments
|
|
4
|
-
class TestGenerator < Rails::Generators::Base
|
|
5
|
-
desc <<~MARKDOWN
|
|
6
|
-
- Enables [raise_on_missing_translations][].
|
|
7
|
-
- Disables [action_dispatch.show_exceptions][].
|
|
8
|
-
|
|
9
|
-
[raise_on_missing_translations]: https://guides.rubyonrails.org/configuring.html#config-i18n-raise-on-missing-translations
|
|
10
|
-
[action_dispatch.show_exceptions]: https://edgeguides.rubyonrails.org/configuring.html#config-action-dispatch-show-exceptions
|
|
11
|
-
MARKDOWN
|
|
12
|
-
|
|
13
|
-
def raise_on_missing_translations
|
|
14
|
-
if test_config.match?(/^\s*#\s*config\.i18n\.raise_on_missing_translations\s*=\s*true/)
|
|
15
|
-
uncomment_lines "config/environments/test.rb", /config\.i18n\.raise_on_missing_translations\s*=\s*true/
|
|
16
|
-
else
|
|
17
|
-
environment %(config.i18n.raise_on_missing_translations = true), env: "test"
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def disable_action_dispatch_show_exceptions
|
|
22
|
-
if test_config.match?(/^\s*config\.action_dispatch\.show_exceptions\s*=\s*:rescuable/)
|
|
23
|
-
gsub_file "config/environments/test.rb", /^\s*config\.action_dispatch\.show_exceptions\s*=\s*:rescuable/,
|
|
24
|
-
"config.action_dispatch.show_exceptions = :none"
|
|
25
|
-
gsub_file "config/environments/test.rb", /^\s*#\s*Raise exceptions instead of rendering exception templates/i, ""
|
|
26
|
-
else
|
|
27
|
-
environment %(config.action_dispatch.show_exceptions = :none), env: "test"
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
private
|
|
32
|
-
|
|
33
|
-
def test_config
|
|
34
|
-
File.read(Rails.root.join("config/environments/test.rb"))
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
module Suspenders
|
|
2
|
-
module Generators
|
|
3
|
-
class FactoriesGenerator < Rails::Generators::Base
|
|
4
|
-
include Suspenders::Generators::Helpers
|
|
5
|
-
|
|
6
|
-
source_root File.expand_path("../../templates/factories", __FILE__)
|
|
7
|
-
desc <<~MARKDOWN
|
|
8
|
-
Uses [FactoryBot][] as an alternative to [Fixtures][] to help you define
|
|
9
|
-
dummy and test data for your test suite. The `create`, `build`, and
|
|
10
|
-
`build_stubbed` class methods are directly available to all tests.
|
|
11
|
-
|
|
12
|
-
Place FactoryBot definitions in `spec/factories.rb`, at least until it
|
|
13
|
-
grows unwieldy. This helps reduce confusion around circular dependencies and
|
|
14
|
-
makes it easy to jump between definitions.
|
|
15
|
-
|
|
16
|
-
[FactoryBot]: https://github.com/thoughtbot/factory_bot
|
|
17
|
-
[Fixtures]: https://guides.rubyonrails.org/testing.html#the-low-down-on-fixtures
|
|
18
|
-
MARKDOWN
|
|
19
|
-
|
|
20
|
-
def add_factory_bot
|
|
21
|
-
gem_group :development, :test do
|
|
22
|
-
gem "factory_bot_rails"
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
Bundler.with_unbundled_env { run "bundle install" }
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def set_up_factory_bot
|
|
29
|
-
if default_test_helper_present?
|
|
30
|
-
insert_into_file Rails.root.join("test/test_helper.rb"), after: "class TestCase" do
|
|
31
|
-
"\n include FactoryBot::Syntax::Methods"
|
|
32
|
-
end
|
|
33
|
-
elsif rspec_test_helper_present?
|
|
34
|
-
copy_file "factory_bot_rspec.rb", "spec/support/factory_bot.rb"
|
|
35
|
-
insert_into_file Rails.root.join("spec/rails_helper.rb") do
|
|
36
|
-
%(Dir[Rails.root.join("spec/support/**/*.rb")].sort.each { |file| require file })
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def generate_empty_factories_file
|
|
42
|
-
if default_test_suite?
|
|
43
|
-
copy_file "factories.rb", "test/factories.rb"
|
|
44
|
-
elsif rspec_test_suite?
|
|
45
|
-
copy_file "factories.rb", "spec/factories.rb"
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def remove_fixture_definitions
|
|
50
|
-
if default_test_helper_present?
|
|
51
|
-
comment_lines "test/test_helper.rb", /fixtures :all/
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def create_linting_test
|
|
56
|
-
if default_test_suite?
|
|
57
|
-
copy_file "factories_test.rb", "test/factory_bots/factories_test.rb"
|
|
58
|
-
elsif rspec_test_suite?
|
|
59
|
-
copy_file "factories_spec.rb", "spec/factory_bots/factories_spec.rb"
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
end
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
module Suspenders
|
|
2
|
-
module Generators
|
|
3
|
-
class InlineSvgGenerator < Rails::Generators::Base
|
|
4
|
-
include Suspenders::Generators::APIAppUnsupported
|
|
5
|
-
source_root File.expand_path("../../templates/inline_svg", __FILE__)
|
|
6
|
-
desc <<~MARKDOWN
|
|
7
|
-
Uses [inline_svg][] for embedding SVG documents into views.
|
|
8
|
-
|
|
9
|
-
Configuration can be found at `config/initializers/inline_svg.rb`
|
|
10
|
-
|
|
11
|
-
[inline_svg]: https://github.com/jamesmartin/inline_svg
|
|
12
|
-
MARKDOWN
|
|
13
|
-
|
|
14
|
-
def add_inline_svg_gem
|
|
15
|
-
gem "inline_svg"
|
|
16
|
-
Bundler.with_unbundled_env { run "bundle install" }
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def configure_inline_svg
|
|
20
|
-
copy_file "inline_svg.rb", "config/initializers/inline_svg.rb"
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
module Suspenders
|
|
2
|
-
module Generators
|
|
3
|
-
module Install
|
|
4
|
-
class WebGenerator < Rails::Generators::Base
|
|
5
|
-
include Suspenders::Generators::APIAppUnsupported
|
|
6
|
-
include Suspenders::Generators::DatabaseUnsupported
|
|
7
|
-
include Suspenders::Generators::NodeNotInstalled
|
|
8
|
-
include Suspenders::Generators::NodeVersionUnsupported
|
|
9
|
-
|
|
10
|
-
source_root File.expand_path("../../../templates/install/web", __FILE__)
|
|
11
|
-
desc <<~MARKDOWN
|
|
12
|
-
Invokes all necessary generators for new Rails applications generated with Suspenders.
|
|
13
|
-
|
|
14
|
-
This generatator is intended to be invoked as part of an [application template][].
|
|
15
|
-
|
|
16
|
-
#### Use the latest suspenders release:
|
|
17
|
-
|
|
18
|
-
```
|
|
19
|
-
rails new <app_name> \\
|
|
20
|
-
--skip-rubocop \\
|
|
21
|
-
--skip-test \\
|
|
22
|
-
-d=postgresql \\
|
|
23
|
-
-m=https://raw.githubusercontent.com/thoughtbot/suspenders/main/lib/install/web.rb
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
#### OR use the current (possibly unreleased) `main` branch of suspenders:
|
|
27
|
-
|
|
28
|
-
```
|
|
29
|
-
rails new app_name \\
|
|
30
|
-
--suspenders-main \\
|
|
31
|
-
--skip-rubocop \\
|
|
32
|
-
--skip-test \\
|
|
33
|
-
-d=postgresql \\
|
|
34
|
-
-m=https://raw.githubusercontent.com/thoughtbot/suspenders/main/lib/install/web.rb
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
[application template]: https://guides.rubyonrails.org/rails_application_templates.html
|
|
38
|
-
MARKDOWN
|
|
39
|
-
|
|
40
|
-
def invoke_generators
|
|
41
|
-
# This needs to go first, since it configures `.node-version`
|
|
42
|
-
generate "suspenders:prerequisites"
|
|
43
|
-
|
|
44
|
-
generate "suspenders:accessibility"
|
|
45
|
-
generate "suspenders:advisories"
|
|
46
|
-
generate "suspenders:email"
|
|
47
|
-
generate "suspenders:factories"
|
|
48
|
-
generate "suspenders:inline_svg"
|
|
49
|
-
generate "suspenders:lint"
|
|
50
|
-
generate "suspenders:rake"
|
|
51
|
-
generate "suspenders:setup"
|
|
52
|
-
generate "suspenders:tasks"
|
|
53
|
-
generate "suspenders:testing"
|
|
54
|
-
generate "suspenders:views"
|
|
55
|
-
|
|
56
|
-
# suspenders:jobs needs to be invoked before suspenders:styles, since
|
|
57
|
-
# suspenders:styles generator creates Procfile.dev
|
|
58
|
-
generate "suspenders:styles"
|
|
59
|
-
generate "suspenders:jobs"
|
|
60
|
-
|
|
61
|
-
# Needs to run after other generators, since some touch the
|
|
62
|
-
# configuration files.
|
|
63
|
-
generate "suspenders:environments:test"
|
|
64
|
-
generate "suspenders:environments:development"
|
|
65
|
-
generate "suspenders:environments:production"
|
|
66
|
-
|
|
67
|
-
# Needs to be run last since it depends on lint, testing, and
|
|
68
|
-
# advisories
|
|
69
|
-
generate "suspenders:ci"
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
def cleanup
|
|
73
|
-
rake "suspenders:cleanup:organize_gemfile"
|
|
74
|
-
rake "suspenders:cleanup:generate_readme"
|
|
75
|
-
copy_file "CONTRIBUTING.md", "CONTRIBUTING.md"
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
def lint
|
|
79
|
-
run "yarn run fix:prettier"
|
|
80
|
-
run "bundle exec rake standard:fix_unsafely"
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
end
|