suspenders 20230113.0 → 20250317.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 (170) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +98 -170
  3. data/Rakefile +17 -0
  4. data/lib/generators/suspenders/accessibility_generator.rb +24 -0
  5. data/lib/generators/suspenders/advisories_generator.rb +32 -0
  6. data/lib/generators/suspenders/ci_generator.rb +54 -0
  7. data/lib/generators/suspenders/email_generator.rb +56 -0
  8. data/lib/generators/suspenders/environments/development_generator.rb +50 -0
  9. data/lib/generators/suspenders/environments/production_generator.rb +27 -0
  10. data/lib/generators/suspenders/environments/test_generator.rb +39 -0
  11. data/lib/generators/suspenders/factories_generator.rb +64 -0
  12. data/lib/generators/suspenders/inline_svg_generator.rb +24 -0
  13. data/lib/generators/suspenders/install/web_generator.rb +85 -0
  14. data/lib/generators/suspenders/jobs_generator.rb +34 -0
  15. data/lib/generators/suspenders/lint_generator.rb +94 -0
  16. data/lib/generators/suspenders/prerequisites_generator.rb +19 -0
  17. data/lib/generators/suspenders/rake_generator.rb +25 -0
  18. data/lib/generators/suspenders/setup_generator.rb +14 -0
  19. data/lib/generators/suspenders/styles_generator.rb +84 -0
  20. data/lib/generators/suspenders/tasks_generator.rb +20 -0
  21. data/lib/generators/suspenders/testing_generator.rb +113 -0
  22. data/lib/generators/suspenders/views_generator.rb +38 -0
  23. data/lib/generators/templates/ci/ci.yml.tt +148 -0
  24. data/lib/generators/templates/email/email_interceptor.rb +11 -0
  25. data/lib/generators/templates/factories/factories_spec.rb +7 -0
  26. data/lib/generators/templates/factories/factories_test.rb +9 -0
  27. data/lib/generators/templates/install/web/CONTRIBUTING.md +94 -0
  28. data/lib/generators/templates/lint/config_better_html.yml +2 -0
  29. data/lib/generators/templates/lint/config_initializers_better_html.rb +9 -0
  30. data/lib/generators/templates/lint/erb-lint.yml +63 -0
  31. data/lib/generators/templates/lint/erblint.rake +47 -0
  32. data/lib/generators/templates/lint/eslintrc.json +7 -0
  33. data/lib/generators/templates/lint/package.json +4 -0
  34. data/lib/generators/templates/lint/prettierignore +1 -0
  35. data/lib/generators/templates/lint/prettierrc +11 -0
  36. data/lib/generators/templates/lint/rubocop.yml.tt +7 -0
  37. data/lib/generators/templates/prerequisites/node-version.tt +1 -0
  38. data/lib/generators/templates/setup/bin_setup.rb +39 -0
  39. data/lib/generators/templates/styles/postcss.config.js +11 -0
  40. data/lib/generators/templates/testing/driver.rb +5 -0
  41. data/lib/generators/templates/views/flashes.html.erb +7 -0
  42. data/lib/install/web.rb +70 -0
  43. data/lib/suspenders/cleanup/generate_readme.rb +165 -0
  44. data/lib/suspenders/cleanup/organize_gemfile.rb +134 -0
  45. data/lib/suspenders/engine.rb +5 -0
  46. data/lib/suspenders/generators.rb +126 -0
  47. data/lib/suspenders/railtie.rb +4 -0
  48. data/lib/suspenders/version.rb +4 -6
  49. data/lib/suspenders.rb +9 -33
  50. data/lib/tasks/suspenders.rake +37 -0
  51. metadata +81 -173
  52. data/.ruby-version +0 -1
  53. data/CONTRIBUTING.md +0 -59
  54. data/GOALS.md +0 -65
  55. data/LICENSE +0 -21
  56. data/NEWS.md +0 -738
  57. data/RELEASING.md +0 -18
  58. data/bin/suspenders +0 -50
  59. data/docs/heroku_deploy.md +0 -19
  60. data/docs/rails_7.md +0 -5
  61. data/lib/suspenders/actions/strip_comments_action.rb +0 -254
  62. data/lib/suspenders/actions.rb +0 -106
  63. data/lib/suspenders/adapters/heroku.rb +0 -136
  64. data/lib/suspenders/app_builder.rb +0 -267
  65. data/lib/suspenders/exit_on_failure.rb +0 -19
  66. data/lib/suspenders/generators/accessibility_generator.rb +0 -12
  67. data/lib/suspenders/generators/advisories_generator.rb +0 -15
  68. data/lib/suspenders/generators/analytics_generator.rb +0 -24
  69. data/lib/suspenders/generators/app_generator.rb +0 -215
  70. data/lib/suspenders/generators/base.rb +0 -60
  71. data/lib/suspenders/generators/ci_generator.rb +0 -32
  72. data/lib/suspenders/generators/db_optimizations_generator.rb +0 -18
  73. data/lib/suspenders/generators/factories_generator.rb +0 -22
  74. data/lib/suspenders/generators/forms_generator.rb +0 -18
  75. data/lib/suspenders/generators/inline_svg_generator.rb +0 -14
  76. data/lib/suspenders/generators/jobs_generator.rb +0 -37
  77. data/lib/suspenders/generators/js_driver_generator.rb +0 -18
  78. data/lib/suspenders/generators/json_generator.rb +0 -14
  79. data/lib/suspenders/generators/lint_generator.rb +0 -14
  80. data/lib/suspenders/generators/production/compression_generator.rb +0 -14
  81. data/lib/suspenders/generators/production/deployment_generator.rb +0 -16
  82. data/lib/suspenders/generators/production/email_generator.rb +0 -34
  83. data/lib/suspenders/generators/production/force_tls_generator.rb +0 -11
  84. data/lib/suspenders/generators/production/manifest_generator.rb +0 -25
  85. data/lib/suspenders/generators/production/single_redirect.rb +0 -15
  86. data/lib/suspenders/generators/production/timeout_generator.rb +0 -22
  87. data/lib/suspenders/generators/profiler_generator.rb +0 -35
  88. data/lib/suspenders/generators/runner_generator.rb +0 -48
  89. data/lib/suspenders/generators/staging/pull_requests_generator.rb +0 -25
  90. data/lib/suspenders/generators/static_generator.rb +0 -14
  91. data/lib/suspenders/generators/stylelint_generator.rb +0 -71
  92. data/lib/suspenders/generators/stylesheet_base_generator.rb +0 -15
  93. data/lib/suspenders/generators/testing_generator.rb +0 -43
  94. data/lib/suspenders/generators/views_generator.rb +0 -25
  95. data/templates/Gemfile.erb +0 -49
  96. data/templates/Procfile +0 -2
  97. data/templates/README.md.erb +0 -28
  98. data/templates/_analytics.html.erb +0 -8
  99. data/templates/_css_overrides.html.erb +0 -7
  100. data/templates/_flashes.html.erb +0 -7
  101. data/templates/active_job.rb +0 -14
  102. data/templates/application.postcss.css +0 -1
  103. data/templates/bin_auto_migrate +0 -5
  104. data/templates/bin_deploy +0 -10
  105. data/templates/bin_setup +0 -28
  106. data/templates/bin_setup_review_app.erb +0 -21
  107. data/templates/bin_yarn +0 -18
  108. data/templates/bundler_audit.rake +0 -4
  109. data/templates/capybara_silence_puma.rb +0 -1
  110. data/templates/chromedriver.rb +0 -27
  111. data/templates/circle.yml.erb +0 -6
  112. data/templates/config_locales_en.yml.erb +0 -19
  113. data/templates/descriptions/advisories.md +0 -5
  114. data/templates/descriptions/analytics.md +0 -4
  115. data/templates/descriptions/ci.md +0 -4
  116. data/templates/descriptions/compression.md +0 -4
  117. data/templates/descriptions/db_optimizations.md +0 -2
  118. data/templates/descriptions/deployment.md +0 -5
  119. data/templates/descriptions/email.md +0 -9
  120. data/templates/descriptions/factories.md +0 -12
  121. data/templates/descriptions/force_tls.md +0 -1
  122. data/templates/descriptions/forms.md +0 -1
  123. data/templates/descriptions/inline_svg.md +0 -2
  124. data/templates/descriptions/jobs.md +0 -3
  125. data/templates/descriptions/js_driver.md +0 -4
  126. data/templates/descriptions/json.md +0 -1
  127. data/templates/descriptions/lint.md +0 -3
  128. data/templates/descriptions/manifest.md +0 -2
  129. data/templates/descriptions/profiler.md +0 -7
  130. data/templates/descriptions/pull_requests.md +0 -4
  131. data/templates/descriptions/runner.md +0 -10
  132. data/templates/descriptions/single_redirect.md +0 -1
  133. data/templates/descriptions/static.md +0 -5
  134. data/templates/descriptions/stylelint.md +0 -3
  135. data/templates/descriptions/stylesheet_base.md +0 -1
  136. data/templates/descriptions/testing.md +0 -9
  137. data/templates/descriptions/timeout.md +0 -4
  138. data/templates/descriptions/views.md +0 -8
  139. data/templates/email.rb +0 -3
  140. data/templates/errors.rb +0 -35
  141. data/templates/flashes_helper.rb +0 -5
  142. data/templates/hound.yml +0 -15
  143. data/templates/json_encoding.rb +0 -1
  144. data/templates/oj.rb +0 -3
  145. data/templates/partials/ci_simplecov.rb +0 -14
  146. data/templates/partials/db_optimizations_configuration.rb +0 -7
  147. data/templates/partials/deployment_readme.md +0 -8
  148. data/templates/partials/email_smtp.rb +0 -2
  149. data/templates/partials/profiler_readme.md +0 -8
  150. data/templates/partials/pull_requests_config.rb +0 -5
  151. data/templates/partials/runner_readme.md +0 -31
  152. data/templates/partials/runner_setup.rb +0 -2
  153. data/templates/postcss.config.js +0 -8
  154. data/templates/postgresql_database.yml.erb +0 -20
  155. data/templates/rack_mini_profiler.rb +0 -7
  156. data/templates/rails_helper.rb +0 -25
  157. data/templates/sample_env +0 -12
  158. data/templates/secrets.yml +0 -8
  159. data/templates/smtp.rb +0 -9
  160. data/templates/spec_helper.rb +0 -25
  161. data/templates/suspenders_gitignore +0 -18
  162. data/templates/suspenders_layout.html.erb.erb +0 -23
  163. /data/{templates → lib/generators/templates/factories}/factories.rb +0 -0
  164. /data/{templates → lib/generators/templates/factories}/factory_bot_rspec.rb +0 -0
  165. /data/{templates → lib/generators/templates/inline_svg}/inline_svg.rb +0 -0
  166. /data/{templates → lib/generators/templates/lint}/stylelintrc.json +0 -0
  167. /data/{templates → lib/generators/templates/tasks}/dev.rake +0 -0
  168. /data/{templates → lib/generators/templates/testing}/action_mailer.rb +0 -0
  169. /data/{templates → lib/generators/templates/testing}/i18n.rb +0 -0
  170. /data/{templates/shoulda_matchers_config_rspec.rb → lib/generators/templates/testing/shoulda_matchers.rb} +0 -0
@@ -1,267 +0,0 @@
1
- require "forwardable"
2
-
3
- module Suspenders
4
- class AppBuilder < Rails::AppBuilder
5
- include Suspenders::Actions
6
- extend Forwardable
7
-
8
- def_delegators(
9
- :heroku_adapter,
10
- :create_heroku_pipeline,
11
- :create_production_heroku_app,
12
- :create_staging_heroku_app,
13
- :set_heroku_application_host,
14
- :set_heroku_backup_schedule,
15
- :set_heroku_honeybadger_env,
16
- :set_heroku_rails_secrets,
17
- :set_heroku_remotes,
18
- :set_heroku_buildpacks
19
- )
20
-
21
- def readme
22
- template "README.md.erb", "README.md"
23
- end
24
-
25
- def gitignore
26
- copy_file "suspenders_gitignore", ".gitignore"
27
- end
28
-
29
- def gemfile
30
- template "Gemfile.erb", "Gemfile"
31
- end
32
-
33
- def setup_rack_mini_profiler
34
- copy_file(
35
- "rack_mini_profiler.rb",
36
- "config/initializers/rack_mini_profiler.rb"
37
- )
38
- end
39
-
40
- def raise_on_missing_assets_in_test
41
- configure_environment "test", "config.assets.raise_runtime_errors = true"
42
- end
43
-
44
- def raise_on_delivery_errors
45
- replace_in_file "config/environments/development.rb",
46
- "raise_delivery_errors = false", "raise_delivery_errors = true"
47
- end
48
-
49
- def set_test_delivery_method
50
- inject_into_file(
51
- "config/environments/development.rb",
52
- "\n config.action_mailer.delivery_method = :file",
53
- after: "config.action_mailer.raise_delivery_errors = true"
54
- )
55
- end
56
-
57
- def raise_on_unpermitted_parameters
58
- config = <<-RUBY
59
- config.action_controller.action_on_unpermitted_parameters = :raise
60
- RUBY
61
-
62
- inject_into_class "config/application.rb", "Application", config
63
- end
64
-
65
- def configure_quiet_assets
66
- config = <<-RUBY
67
- config.assets.quiet = true
68
- RUBY
69
-
70
- inject_into_class "config/application.rb", "Application", config
71
- end
72
-
73
- def provide_setup_script
74
- template "bin_setup", "bin/setup", force: true
75
- run "chmod a+x bin/setup"
76
- end
77
-
78
- def provide_yarn_script
79
- template "bin_yarn", "bin/yarn", force: true
80
- run "chmod a+x bin/yarn"
81
- end
82
-
83
- def configure_generators
84
- config = <<-RUBY
85
-
86
- config.generators do |generate|
87
- generate.helper false
88
- generate.javascripts false
89
- generate.controller_specs false
90
- generate.request_specs true
91
- generate.routing_specs false
92
- generate.stylesheets false
93
- generate.test_framework :rspec
94
- generate.view_specs false
95
- end
96
-
97
- RUBY
98
-
99
- inject_into_class "config/application.rb", "Application", config
100
- end
101
-
102
- def configure_local_mail
103
- copy_file "email.rb", "config/initializers/email.rb"
104
- end
105
-
106
- def setup_asset_host
107
- replace_in_file "config/environments/production.rb",
108
- %(# config.asset_host = "http://assets.example.com"),
109
- 'config.asset_host = ENV.fetch("ASSET_HOST", ENV.fetch("APPLICATION_HOST"))'
110
-
111
- if File.exist?("config/initializers/assets.rb")
112
- replace_in_file "config/initializers/assets.rb",
113
- %(Rails.application.config.assets.version = "1.0"),
114
- 'Rails.application.config.assets.version = (ENV["ASSETS_VERSION"] || "1.0")'
115
- end
116
-
117
- config = <<~EOD
118
- config.public_file_server.headers = {
119
- "Cache-Control" => "public, max-age=31557600",
120
- }
121
- EOD
122
-
123
- configure_environment("production", config)
124
- end
125
-
126
- def setup_secret_token
127
- template "secrets.yml", "config/secrets.yml", force: true
128
- end
129
-
130
- def disallow_wrapping_parameters
131
- remove_file "config/initializers/wrap_parameters.rb"
132
- end
133
-
134
- def use_postgres_config_template
135
- template "postgresql_database.yml.erb", "config/database.yml",
136
- force: true
137
- end
138
-
139
- def create_database
140
- bundle_command "exec rails db:create db:migrate"
141
- end
142
-
143
- def run_database_migrations
144
- bundle_command "exec rails db:migrate"
145
- end
146
-
147
- def replace_gemfile
148
- template "Gemfile.erb", "Gemfile", force: true do |content|
149
- if development_env?
150
- content.gsub(%r{gem .suspenders.}) { |s| %(#{s}, path: "#{root_path}") }
151
- else
152
- content
153
- end
154
- end
155
- end
156
-
157
- def ruby_version
158
- create_file ".ruby-version", "#{Suspenders::RUBY_VERSION}\n"
159
- end
160
-
161
- def configure_i18n_for_missing_translations
162
- raise_on_missing_translations_in("development")
163
- raise_on_missing_translations_in("test")
164
- end
165
-
166
- def configure_action_mailer_in_specs
167
- copy_file "action_mailer.rb", "spec/support/action_mailer.rb"
168
- end
169
-
170
- def configure_time_formats
171
- remove_file "config/locales/en.yml"
172
- template "config_locales_en.yml.erb", "config/locales/en.yml"
173
- end
174
-
175
- def configure_action_mailer
176
- action_mailer_host "development", %("localhost:3000")
177
- action_mailer_asset_host "development", %("http://localhost:3000")
178
- action_mailer_host "test", %("www.example.com")
179
- action_mailer_asset_host "test", %("http://www.example.com")
180
- action_mailer_host "production", %{ENV.fetch("APPLICATION_HOST")}
181
- # rubocop:disable Lint/InterpolationCheck
182
- action_mailer_asset_host(
183
- "production",
184
- %q{"https://#{ENV.fetch("ASSET_HOST", ENV.fetch("APPLICATION_HOST"))}"}
185
- )
186
- # rubocop:enable Lint/InterpolationCheck
187
- end
188
-
189
- def create_heroku_apps(flags)
190
- create_staging_heroku_app(flags)
191
- create_production_heroku_app(flags)
192
- end
193
-
194
- def configure_automatic_deployment
195
- append_file "Procfile", "release: bin/auto_migrate\n"
196
- copy_file "bin_auto_migrate", "bin/auto_migrate"
197
- end
198
-
199
- def create_github_repo(repo_name)
200
- run "hub create #{repo_name}"
201
- end
202
-
203
- def copy_miscellaneous_files
204
- copy_file "errors.rb", "config/initializers/errors.rb"
205
- copy_file "json_encoding.rb", "config/initializers/json_encoding.rb"
206
- end
207
-
208
- def remove_config_comment_lines
209
- config_files = [
210
- "application.rb",
211
- "environment.rb",
212
- "environments/development.rb",
213
- "environments/production.rb",
214
- "environments/test.rb"
215
- ]
216
-
217
- config_files.each do |config_file|
218
- path = Pathname(destination_root).join("config", config_file)
219
- source = Actions::StripCommentsAction.call(path.read)
220
-
221
- path.write(source)
222
- end
223
- end
224
-
225
- def remove_routes_comment_lines
226
- replace_in_file "config/routes.rb",
227
- /Rails\.application\.routes\.draw do.*end/m,
228
- "Rails.application.routes.draw do\nend"
229
- end
230
-
231
- def setup_default_rake_task
232
- append_file "Rakefile" do
233
- <<~EOS
234
- task(:default).clear
235
- task default: [:spec]
236
-
237
- if defined? RSpec
238
- task(:spec).clear
239
- RSpec::Core::RakeTask.new(:spec) do |t|
240
- t.verbose = false
241
- end
242
- end
243
- EOS
244
- end
245
- end
246
-
247
- private
248
-
249
- def root_path
250
- @root_path ||= Pathname(__dir__).join("..", "..").expand_path
251
- end
252
-
253
- def development_env?
254
- root_path.join("suspenders.gemspec").exist?
255
- end
256
-
257
- def raise_on_missing_translations_in(environment)
258
- config = "config.i18n.raise_on_missing_translations = true"
259
-
260
- uncomment_lines("config/environments/#{environment}.rb", config)
261
- end
262
-
263
- def heroku_adapter
264
- @heroku_adapter ||= Adapters::Heroku.new(self)
265
- end
266
- end
267
- end
@@ -1,19 +0,0 @@
1
- require "active_support/concern"
2
- require "English"
3
-
4
- module Suspenders
5
- module ExitOnFailure
6
- extend ActiveSupport::Concern
7
-
8
- def bundle_command(*)
9
- super
10
- exit(false) if $CHILD_STATUS.exitstatus.nonzero?
11
- end
12
-
13
- module ClassMethods
14
- def exit_on_failure?
15
- true
16
- end
17
- end
18
- end
19
- end
@@ -1,12 +0,0 @@
1
- require_relative "base"
2
-
3
- module Suspenders
4
- class AccessibilityGenerator < Generators::Base
5
- def capybara_gems
6
- gem "capybara_accessibility_audit", group: [:test]
7
- gem "capybara_accessible_selectors", group: [:test],
8
- github: "citizensadvice/capybara_accessible_selectors"
9
- Bundler.with_unbundled_env { run "bundle install" }
10
- end
11
- end
12
- end
@@ -1,15 +0,0 @@
1
- require_relative "base"
2
-
3
- module Suspenders
4
- class AdvisoriesGenerator < Generators::Base
5
- def bundler_audit_gem
6
- gem "bundler-audit", ">= 0.7.0", require: false, group: [:development, :test]
7
- Bundler.with_unbundled_env { run "bundle install" }
8
- end
9
-
10
- def rake_task
11
- copy_file "bundler_audit.rake", "lib/tasks/bundler_audit.rake"
12
- append_file "Rakefile", %(\ntask default: "bundle:audit"\n)
13
- end
14
- end
15
- end
@@ -1,24 +0,0 @@
1
- require_relative "base"
2
-
3
- module Suspenders
4
- class AnalyticsGenerator < Generators::Base
5
- def install_partial
6
- copy_file "_analytics.html.erb",
7
- "app/views/application/_analytics.html.erb"
8
- end
9
-
10
- def render_partial
11
- if File.exist?(js_partial)
12
- inject_into_file js_partial,
13
- %(\n\n<%= render "analytics" %>),
14
- after: "<%= yield :javascript %>"
15
- end
16
- end
17
-
18
- private
19
-
20
- def js_partial
21
- "app/views/application/_javascript.html.erb"
22
- end
23
- end
24
- end
@@ -1,215 +0,0 @@
1
- require "rails/generators"
2
- require "rails/generators/rails/app/app_generator"
3
-
4
- module Suspenders
5
- class AppGenerator < Rails::Generators::AppGenerator
6
- include ExitOnFailure
7
-
8
- hide!
9
-
10
- class_option :database, type: :string, aliases: "-d", default: "postgresql",
11
- desc: "Configure for selected database (options: #{DATABASES.join("/")})"
12
-
13
- class_option :heroku, type: :boolean, aliases: "-H", default: false,
14
- desc: "Create staging and production Heroku apps"
15
-
16
- class_option :heroku_flags, type: :string, default: "",
17
- desc: "Set extra Heroku flags"
18
-
19
- class_option :github, type: :string, default: nil,
20
- desc: "Create Github repository and add remote origin pointed to repo"
21
-
22
- class_option :version, type: :boolean, aliases: "-v", group: :suspenders,
23
- desc: "Show Suspenders version number and quit"
24
-
25
- class_option :help, type: :boolean, aliases: "-h", group: :suspenders,
26
- desc: "Show this help message and quit"
27
-
28
- class_option :skip_test, type: :boolean, default: true,
29
- desc: "Skip Test Unit"
30
-
31
- class_option :skip_system_test,
32
- type: :boolean, default: true, desc: "Skip system test files"
33
-
34
- class_option :css,
35
- type: :string, default: "postcss", aliases: "-c", desc: "Choose CSS processor"
36
-
37
- def finish_template
38
- invoke :suspenders_customization
39
- super
40
- end
41
-
42
- def leftovers
43
- generate("suspenders:stylesheet_base") unless options[:api] || options[:css] != "postcss"
44
- invoke :outro
45
- end
46
-
47
- def suspenders_customization
48
- invoke :customize_gemfile
49
- invoke :setup_development_environment
50
- invoke :setup_production_environment
51
- invoke :setup_secret_token
52
- invoke :configure_app
53
- invoke :copy_miscellaneous_files
54
- invoke :setup_database
55
- invoke :create_github_repo
56
- invoke :generate_default
57
- invoke :create_heroku_apps
58
- invoke :generate_deployment_default
59
- invoke :remove_config_comment_lines
60
- invoke :remove_routes_comment_lines
61
- invoke :run_database_migrations
62
- invoke :generate_views
63
- end
64
-
65
- def customize_gemfile
66
- build :replace_gemfile
67
- bundle_command "install"
68
- end
69
-
70
- def setup_database
71
- say "Setting up database"
72
-
73
- if options[:database] == "postgresql"
74
- build :use_postgres_config_template
75
- end
76
-
77
- build :create_database
78
- end
79
-
80
- def setup_development_environment
81
- say "Setting up the development environment"
82
- build :configure_local_mail
83
- build :raise_on_missing_assets_in_test
84
- build :raise_on_delivery_errors
85
- build :set_test_delivery_method
86
- build :raise_on_unpermitted_parameters
87
- build :provide_setup_script
88
- build :provide_yarn_script
89
- build :configure_generators
90
- build :configure_i18n_for_missing_translations
91
- build :configure_quiet_assets
92
- end
93
-
94
- def setup_production_environment
95
- say "Setting up the production environment"
96
- build :setup_asset_host
97
- end
98
-
99
- def setup_secret_token
100
- say "Moving secret token out of version control"
101
- build :setup_secret_token
102
- end
103
-
104
- def configure_app
105
- say "Configuring app"
106
- build :configure_action_mailer
107
- build :configure_time_formats
108
- build :setup_default_rake_task
109
- end
110
-
111
- def create_heroku_apps
112
- if options[:heroku]
113
- say "Creating Heroku apps"
114
- build :create_heroku_apps, options[:heroku_flags]
115
- build :set_heroku_remotes
116
- build :set_heroku_rails_secrets
117
- build :set_heroku_application_host
118
- build :set_heroku_honeybadger_env
119
- build :set_heroku_backup_schedule
120
- build :set_heroku_buildpacks
121
- build :create_heroku_pipeline
122
- build :configure_automatic_deployment
123
- end
124
- end
125
-
126
- def create_github_repo
127
- if !options[:skip_git] && options[:github]
128
- say "Creating Github repo"
129
- build :create_github_repo, options[:github]
130
- end
131
- end
132
-
133
- def copy_miscellaneous_files
134
- say "Copying miscellaneous support files"
135
- build :copy_miscellaneous_files
136
- end
137
-
138
- def remove_config_comment_lines
139
- build :remove_config_comment_lines
140
- end
141
-
142
- def remove_routes_comment_lines
143
- build :remove_routes_comment_lines
144
- end
145
-
146
- def run_database_migrations
147
- build :run_database_migrations
148
- end
149
-
150
- def generate_default
151
- run("spring stop > /dev/null 2>&1 || true")
152
- generate("suspenders:runner")
153
- generate("suspenders:profiler")
154
- generate("suspenders:json")
155
- generate("suspenders:static")
156
- generate("suspenders:testing")
157
- generate("suspenders:ci")
158
- generate("suspenders:js_driver")
159
- generate("suspenders:forms") unless options[:api]
160
- generate("suspenders:db_optimizations")
161
- generate("suspenders:factories")
162
- generate("suspenders:lint")
163
- generate("suspenders:jobs")
164
- generate("suspenders:analytics")
165
- generate("suspenders:inline_svg")
166
- generate("suspenders:advisories")
167
- end
168
-
169
- def generate_deployment_default
170
- generate("suspenders:staging:pull_requests")
171
- generate("suspenders:production:single_redirect")
172
- generate("suspenders:production:compression")
173
- generate("suspenders:production:force_tls")
174
- generate("suspenders:production:email")
175
- generate("suspenders:production:timeout")
176
- generate("suspenders:production:deployment")
177
- generate("suspenders:production:manifest")
178
- end
179
-
180
- def generate_views
181
- generate("suspenders:views")
182
- end
183
-
184
- def outro
185
- say "\nCongratulations! You just pulled our suspenders."
186
- say honeybadger_outro
187
- end
188
-
189
- def self.banner
190
- "suspenders #{arguments.map(&:usage).join(" ")} [options]"
191
- end
192
-
193
- protected
194
-
195
- def get_builder_class
196
- Suspenders::AppBuilder
197
- end
198
-
199
- def using_active_record?
200
- !options[:skip_active_record]
201
- end
202
-
203
- private
204
-
205
- def honeybadger_outro
206
- "Run 'bundle exec honeybadger heroku install' with your API key#{honeybadger_message_suffix}."
207
- end
208
-
209
- def honeybadger_message_suffix
210
- if options[:heroku]
211
- " unless you're using the Heroku Honeybadger add-on"
212
- end
213
- end
214
- end
215
- end
@@ -1,60 +0,0 @@
1
- require "rails/generators"
2
- require_relative "../actions"
3
-
4
- module Suspenders
5
- module Generators
6
- class Base < Rails::Generators::Base
7
- include Suspenders::Actions
8
- include ExitOnFailure
9
-
10
- def self.default_source_root
11
- File.expand_path(File.join("..", "..", "..", "templates"), __dir__)
12
- end
13
-
14
- def self.inherited(subclass)
15
- super
16
-
17
- description_file = File.expand_path(
18
- File.join(
19
- default_source_root,
20
- "descriptions",
21
- "#{subclass.generator_name}.md"
22
- )
23
- )
24
-
25
- subclass.desc File.read(description_file)
26
- rescue Errno::ENOENT
27
- end
28
-
29
- private
30
-
31
- def app_name
32
- Rails.app_class.module_parent_name.demodulize.underscore.dasherize
33
- end
34
-
35
- def empty_directory_with_keep_file(destination)
36
- empty_directory(destination, {})
37
- keep_file(destination)
38
- end
39
-
40
- def keep_file(destination)
41
- create_file(File.join(destination, ".keep"))
42
- end
43
-
44
- def append_template_to_file(destination, source, *args)
45
- partial = File.expand_path(find_in_source_paths(source))
46
- append_to_file(destination, File.read(partial, *args))
47
- end
48
-
49
- def prepend_template_to_file(destination, source, *args)
50
- partial = File.expand_path(find_in_source_paths(source))
51
- prepend_to_file(destination, File.read(partial, *args))
52
- end
53
-
54
- def inject_template_into_file(destination, source, *args)
55
- partial = File.expand_path(find_in_source_paths(source))
56
- inject_into_file(destination, File.read(partial), *args)
57
- end
58
- end
59
- end
60
- end
@@ -1,32 +0,0 @@
1
- require_relative "base"
2
-
3
- module Suspenders
4
- class CiGenerator < Generators::Base
5
- def simplecov_gem
6
- gem "simplecov", require: false, group: [:test]
7
- Bundler.with_unbundled_env { run "bundle install" }
8
- end
9
-
10
- def simplecov_test_integration
11
- prepend_template_to_file(test_helper_file, "partials/ci_simplecov.rb")
12
- end
13
-
14
- def configure_ci
15
- template "circle.yml.erb", "circle.yml"
16
- end
17
-
18
- private
19
-
20
- def test_helper_file
21
- if using_rspec?
22
- "spec/spec_helper.rb"
23
- else
24
- "test/test_helper.rb"
25
- end
26
- end
27
-
28
- def using_rspec?
29
- File.exist?("spec/spec_helper.rb")
30
- end
31
- end
32
- end
@@ -1,18 +0,0 @@
1
- require_relative "base"
2
-
3
- module Suspenders
4
- class DbOptimizationsGenerator < Generators::Base
5
- def add_bullet
6
- gem "bullet", group: %i[development test]
7
- Bundler.with_unbundled_env { run "bundle install" }
8
- end
9
-
10
- def configure_bullet
11
- inject_template_into_file(
12
- "config/environments/development.rb",
13
- "partials/db_optimizations_configuration.rb",
14
- after: /config.action_mailer.raise_delivery_errors = .*/
15
- )
16
- end
17
- end
18
- end
@@ -1,22 +0,0 @@
1
- require_relative "base"
2
-
3
- module Suspenders
4
- class FactoriesGenerator < Generators::Base
5
- def add_factory_bot
6
- gem "factory_bot_rails", group: %i[development test]
7
- Bundler.with_unbundled_env { run "bundle install" }
8
- end
9
-
10
- def set_up_factory_bot_for_rspec
11
- copy_file "factory_bot_rspec.rb", "spec/support/factory_bot.rb"
12
- end
13
-
14
- def generate_empty_factories_file
15
- copy_file "factories.rb", "spec/factories.rb"
16
- end
17
-
18
- def provide_dev_prime_task
19
- copy_file "dev.rake", "lib/tasks/dev.rake"
20
- end
21
- end
22
- end