suspenders 1.55.1 → 20230113.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/CONTRIBUTING.md +2 -2
- data/NEWS.md +41 -1
- data/README.md +13 -16
- data/bin/suspenders +29 -2
- data/docs/rails_7.md +5 -0
- data/lib/suspenders/actions/strip_comments_action.rb +254 -0
- data/lib/suspenders/actions.rb +22 -1
- data/lib/suspenders/app_builder.rb +34 -19
- data/lib/suspenders/exit_on_failure.rb +19 -0
- data/lib/suspenders/generators/accessibility_generator.rb +12 -0
- data/lib/suspenders/generators/advisories_generator.rb +1 -1
- data/lib/suspenders/generators/app_generator.rb +27 -21
- data/lib/suspenders/generators/base.rb +1 -0
- data/lib/suspenders/generators/jobs_generator.rb +7 -8
- data/lib/suspenders/generators/json_generator.rb +4 -0
- data/lib/suspenders/generators/production/email_generator.rb +2 -2
- data/lib/suspenders/generators/production/manifest_generator.rb +1 -1
- data/lib/suspenders/generators/stylesheet_base_generator.rb +5 -20
- data/lib/suspenders/generators/testing_generator.rb +1 -2
- data/lib/suspenders/generators/views_generator.rb +0 -5
- data/lib/suspenders/version.rb +2 -2
- data/lib/suspenders.rb +3 -1
- data/templates/Gemfile.erb +8 -4
- data/templates/Procfile +1 -1
- data/templates/active_job.rb +1 -0
- data/templates/application.postcss.css +1 -0
- data/templates/bin_yarn +18 -0
- data/templates/descriptions/jobs.md +1 -1
- data/templates/descriptions/runner.md +1 -1
- data/templates/descriptions/stylesheet_base.md +1 -4
- data/templates/descriptions/testing.md +1 -1
- data/templates/errors.rb +1 -0
- data/templates/oj.rb +3 -0
- data/templates/partials/email_smtp.rb +2 -2
- data/templates/partials/pull_requests_config.rb +5 -4
- data/templates/postcss.config.js +8 -0
- data/templates/postgresql_database.yml.erb +1 -0
- data/templates/sample_env +1 -0
- data/templates/suspenders_layout.html.erb.erb +6 -4
- metadata +47 -100
- data/.gitignore +0 -5
- data/.standard.yml +0 -2
- data/.travis.yml +0 -15
- data/Gemfile +0 -3
- data/Rakefile +0 -9
- data/USAGE +0 -13
- data/bin/rake +0 -16
- data/bin/rspec +0 -16
- data/bin/setup +0 -13
- data/lib/suspenders/generators/preloader_generator.rb +0 -122
- data/spec/adapters/heroku_spec.rb +0 -98
- data/spec/expand_json_spec.rb +0 -89
- data/spec/fakes/bin/heroku +0 -5
- data/spec/fakes/bin/hub +0 -5
- data/spec/features/advisories_spec.rb +0 -24
- data/spec/features/api_spec.rb +0 -18
- data/spec/features/ci_spec.rb +0 -31
- data/spec/features/cli_help_spec.rb +0 -36
- data/spec/features/db_optimizations_spec.rb +0 -19
- data/spec/features/github_spec.rb +0 -16
- data/spec/features/heroku_spec.rb +0 -64
- data/spec/features/inline_svg_spec.rb +0 -10
- data/spec/features/json_spec.rb +0 -15
- data/spec/features/lint_spec.rb +0 -26
- data/spec/features/new_project_spec.rb +0 -321
- data/spec/features/preloader_spec.rb +0 -25
- data/spec/features/production/compression_spec.rb +0 -23
- data/spec/features/production/deployment_spec.rb +0 -22
- data/spec/features/production/email_spec.rb +0 -47
- data/spec/features/production/manifest_spec.rb +0 -37
- data/spec/features/production/single_redirect_spec.rb +0 -25
- data/spec/features/profiler_spec.rb +0 -20
- data/spec/features/runner_spec.rb +0 -30
- data/spec/features/staging/pull_requests_spec.rb +0 -22
- data/spec/features/static_spec.rb +0 -17
- data/spec/features/stylelint_spec.rb +0 -60
- data/spec/spec_helper.rb +0 -21
- data/spec/support/be_executable_matcher.rb +0 -7
- data/spec/support/contain_json_matcher.rb +0 -30
- data/spec/support/exist_as_a_file_matcher.rb +0 -7
- data/spec/support/fake_github.rb +0 -21
- data/spec/support/fake_heroku.rb +0 -53
- data/spec/support/generators.rb +0 -5
- data/spec/support/match_contents_matcher.rb +0 -6
- data/spec/support/project_files.rb +0 -25
- data/spec/support/rails_template.rb +0 -1
- data/spec/support/suspenders.rb +0 -184
- data/suspenders.gemspec +0 -35
- data/templates/_javascript.html.erb +0 -3
- data/templates/application.scss +0 -7
- data/templates/descriptions/preloader.md +0 -3
- data/templates/spring.rb +0 -6
@@ -3,43 +3,47 @@ require "rails/generators/rails/app/app_generator"
|
|
3
3
|
|
4
4
|
module Suspenders
|
5
5
|
class AppGenerator < Rails::Generators::AppGenerator
|
6
|
+
include ExitOnFailure
|
7
|
+
|
6
8
|
hide!
|
7
9
|
|
8
10
|
class_option :database, type: :string, aliases: "-d", default: "postgresql",
|
9
|
-
|
11
|
+
desc: "Configure for selected database (options: #{DATABASES.join("/")})"
|
10
12
|
|
11
13
|
class_option :heroku, type: :boolean, aliases: "-H", default: false,
|
12
|
-
|
14
|
+
desc: "Create staging and production Heroku apps"
|
13
15
|
|
14
16
|
class_option :heroku_flags, type: :string, default: "",
|
15
|
-
|
17
|
+
desc: "Set extra Heroku flags"
|
16
18
|
|
17
19
|
class_option :github, type: :string, default: nil,
|
18
|
-
|
20
|
+
desc: "Create Github repository and add remote origin pointed to repo"
|
19
21
|
|
20
22
|
class_option :version, type: :boolean, aliases: "-v", group: :suspenders,
|
21
|
-
|
23
|
+
desc: "Show Suspenders version number and quit"
|
22
24
|
|
23
25
|
class_option :help, type: :boolean, aliases: "-h", group: :suspenders,
|
24
|
-
|
25
|
-
|
26
|
-
class_option :path, type: :string, default: nil,
|
27
|
-
desc: "Path to the gem"
|
26
|
+
desc: "Show this help message and quit"
|
28
27
|
|
29
28
|
class_option :skip_test, type: :boolean, default: true,
|
30
|
-
|
29
|
+
desc: "Skip Test Unit"
|
31
30
|
|
32
31
|
class_option :skip_system_test,
|
33
32
|
type: :boolean, default: true, desc: "Skip system test files"
|
34
33
|
|
35
|
-
class_option :
|
36
|
-
type: :
|
34
|
+
class_option :css,
|
35
|
+
type: :string, default: "postcss", aliases: "-c", desc: "Choose CSS processor"
|
37
36
|
|
38
37
|
def finish_template
|
39
38
|
invoke :suspenders_customization
|
40
39
|
super
|
41
40
|
end
|
42
41
|
|
42
|
+
def leftovers
|
43
|
+
generate("suspenders:stylesheet_base") unless options[:api] || options[:css] != "postcss"
|
44
|
+
invoke :outro
|
45
|
+
end
|
46
|
+
|
43
47
|
def suspenders_customization
|
44
48
|
invoke :customize_gemfile
|
45
49
|
invoke :setup_development_environment
|
@@ -54,11 +58,12 @@ module Suspenders
|
|
54
58
|
invoke :generate_deployment_default
|
55
59
|
invoke :remove_config_comment_lines
|
56
60
|
invoke :remove_routes_comment_lines
|
57
|
-
invoke :
|
61
|
+
invoke :run_database_migrations
|
62
|
+
invoke :generate_views
|
58
63
|
end
|
59
64
|
|
60
65
|
def customize_gemfile
|
61
|
-
build :replace_gemfile
|
66
|
+
build :replace_gemfile
|
62
67
|
bundle_command "install"
|
63
68
|
end
|
64
69
|
|
@@ -80,6 +85,7 @@ module Suspenders
|
|
80
85
|
build :set_test_delivery_method
|
81
86
|
build :raise_on_unpermitted_parameters
|
82
87
|
build :provide_setup_script
|
88
|
+
build :provide_yarn_script
|
83
89
|
build :configure_generators
|
84
90
|
build :configure_i18n_for_missing_translations
|
85
91
|
build :configure_quiet_assets
|
@@ -137,19 +143,20 @@ module Suspenders
|
|
137
143
|
build :remove_routes_comment_lines
|
138
144
|
end
|
139
145
|
|
146
|
+
def run_database_migrations
|
147
|
+
build :run_database_migrations
|
148
|
+
end
|
149
|
+
|
140
150
|
def generate_default
|
141
|
-
run("spring stop")
|
151
|
+
run("spring stop > /dev/null 2>&1 || true")
|
142
152
|
generate("suspenders:runner")
|
143
153
|
generate("suspenders:profiler")
|
144
154
|
generate("suspenders:json")
|
145
155
|
generate("suspenders:static")
|
146
|
-
generate("suspenders:stylesheet_base")
|
147
156
|
generate("suspenders:testing")
|
148
157
|
generate("suspenders:ci")
|
149
158
|
generate("suspenders:js_driver")
|
150
|
-
unless options[:api]
|
151
|
-
generate("suspenders:forms")
|
152
|
-
end
|
159
|
+
generate("suspenders:forms") unless options[:api]
|
153
160
|
generate("suspenders:db_optimizations")
|
154
161
|
generate("suspenders:factories")
|
155
162
|
generate("suspenders:lint")
|
@@ -157,7 +164,6 @@ module Suspenders
|
|
157
164
|
generate("suspenders:analytics")
|
158
165
|
generate("suspenders:inline_svg")
|
159
166
|
generate("suspenders:advisories")
|
160
|
-
generate("suspenders:preloader")
|
161
167
|
end
|
162
168
|
|
163
169
|
def generate_deployment_default
|
@@ -176,7 +182,7 @@ module Suspenders
|
|
176
182
|
end
|
177
183
|
|
178
184
|
def outro
|
179
|
-
say "
|
185
|
+
say "\nCongratulations! You just pulled our suspenders."
|
180
186
|
say honeybadger_outro
|
181
187
|
end
|
182
188
|
|
@@ -3,14 +3,10 @@ require_relative "base"
|
|
3
3
|
module Suspenders
|
4
4
|
class JobsGenerator < Generators::Base
|
5
5
|
def add_jobs_gem
|
6
|
-
gem "
|
6
|
+
gem "sidekiq"
|
7
7
|
Bundler.with_unbundled_env { run "bundle install" }
|
8
8
|
end
|
9
9
|
|
10
|
-
def configure_background_jobs_for_rspec
|
11
|
-
generate "delayed_job:active_record"
|
12
|
-
end
|
13
|
-
|
14
10
|
def initialize_active_job
|
15
11
|
copy_file(
|
16
12
|
"active_job.rb",
|
@@ -19,9 +15,12 @@ module Suspenders
|
|
19
15
|
end
|
20
16
|
|
21
17
|
def configure_active_job
|
22
|
-
configure_application_file(
|
23
|
-
|
24
|
-
)
|
18
|
+
configure_application_file("config.active_job.queue_adapter = :sidekiq")
|
19
|
+
configure_application_file("config.action_mailer.deliver_later_queue_name = nil")
|
20
|
+
configure_application_file("config.action_mailbox.queues.routing = nil")
|
21
|
+
configure_application_file("config.active_storage.queues.analysis = nil")
|
22
|
+
configure_application_file("config.active_storage.queues.purge = nil")
|
23
|
+
configure_application_file("config.active_storage.queues.mirror = nil")
|
25
24
|
configure_environment "test", "config.active_job.queue_adapter = :inline"
|
26
25
|
end
|
27
26
|
|
@@ -7,14 +7,14 @@ module Suspenders
|
|
7
7
|
copy_file "smtp.rb", "config/smtp.rb"
|
8
8
|
|
9
9
|
prepend_file "config/environments/production.rb",
|
10
|
-
%{require Rails.root.join("config/smtp")\n}
|
10
|
+
%{require Rails.root.join("config/smtp")\n\n}
|
11
11
|
end
|
12
12
|
|
13
13
|
def use_smtp
|
14
14
|
inject_template_into_file(
|
15
15
|
"config/environments/production.rb",
|
16
16
|
"partials/email_smtp.rb",
|
17
|
-
after: "config.action_mailer.perform_caching = false"
|
17
|
+
after: "config.action_mailer.perform_caching = false\n"
|
18
18
|
)
|
19
19
|
end
|
20
20
|
|
@@ -2,29 +2,14 @@ require_relative "base"
|
|
2
2
|
|
3
3
|
module Suspenders
|
4
4
|
class StylesheetBaseGenerator < Generators::Base
|
5
|
-
def
|
6
|
-
|
7
|
-
Bundler.with_unbundled_env { run "bundle install" }
|
8
|
-
end
|
9
|
-
|
10
|
-
def remove_prior_config
|
11
|
-
remove_file "app/assets/stylesheets/application.css"
|
12
|
-
end
|
13
|
-
|
14
|
-
def add_css_config
|
5
|
+
def setup_normalize
|
6
|
+
run "yarn add postcss-normalize"
|
15
7
|
copy_file(
|
16
|
-
"application.
|
17
|
-
"app/assets/stylesheets/application.
|
8
|
+
"application.postcss.css",
|
9
|
+
"app/assets/stylesheets/application.postcss.css",
|
18
10
|
force: true
|
19
11
|
)
|
20
|
-
|
21
|
-
|
22
|
-
def install_bitters
|
23
|
-
run "bitters install --path app/assets/stylesheets"
|
24
|
-
end
|
25
|
-
|
26
|
-
def install_normalize_css
|
27
|
-
run "bin/yarn add normalize.css"
|
12
|
+
copy_file "postcss.config.js", "postcss.config.js", force: true
|
28
13
|
end
|
29
14
|
end
|
30
15
|
end
|
@@ -3,8 +3,7 @@ require_relative "base"
|
|
3
3
|
module Suspenders
|
4
4
|
class TestingGenerator < Generators::Base
|
5
5
|
def add_testing_gems
|
6
|
-
gem "
|
7
|
-
gem "rspec-rails", "~> 3.6", group: %i[development test]
|
6
|
+
gem "rspec-rails", "~> 5.1", group: %i[development test]
|
8
7
|
gem "shoulda-matchers", group: :test
|
9
8
|
|
10
9
|
Bundler.with_unbundled_env { run "bundle install" }
|
@@ -11,11 +11,6 @@ module Suspenders
|
|
11
11
|
copy_file "flashes_helper.rb", "app/helpers/flashes_helper.rb"
|
12
12
|
end
|
13
13
|
|
14
|
-
def create_shared_javascripts
|
15
|
-
copy_file "_javascript.html.erb",
|
16
|
-
"app/views/application/_javascript.html.erb"
|
17
|
-
end
|
18
|
-
|
19
14
|
def create_shared_css_overrides
|
20
15
|
copy_file "_css_overrides.html.erb",
|
21
16
|
"app/views/application/_css_overrides.html.erb"
|
data/lib/suspenders/version.rb
CHANGED
data/lib/suspenders.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
require "suspenders/version"
|
2
|
+
require "suspenders/exit_on_failure"
|
3
|
+
require "suspenders/generators/accessibility_generator"
|
2
4
|
require "suspenders/generators/advisories_generator"
|
3
5
|
require "suspenders/generators/app_generator"
|
4
6
|
require "suspenders/generators/static_generator"
|
@@ -16,7 +18,6 @@ require "suspenders/generators/js_driver_generator"
|
|
16
18
|
require "suspenders/generators/json_generator"
|
17
19
|
require "suspenders/generators/testing_generator"
|
18
20
|
require "suspenders/generators/inline_svg_generator"
|
19
|
-
require "suspenders/generators/preloader_generator"
|
20
21
|
require "suspenders/generators/profiler_generator"
|
21
22
|
require "suspenders/generators/runner_generator"
|
22
23
|
require "suspenders/generators/production/force_tls_generator"
|
@@ -28,5 +29,6 @@ require "suspenders/generators/production/manifest_generator"
|
|
28
29
|
require "suspenders/generators/production/single_redirect"
|
29
30
|
require "suspenders/generators/staging/pull_requests_generator"
|
30
31
|
require "suspenders/actions"
|
32
|
+
require "suspenders/actions/strip_comments_action"
|
31
33
|
require "suspenders/adapters/heroku"
|
32
34
|
require "suspenders/app_builder"
|
data/templates/Gemfile.erb
CHANGED
@@ -7,11 +7,14 @@ end
|
|
7
7
|
|
8
8
|
ruby "<%= Suspenders::RUBY_VERSION %>"
|
9
9
|
|
10
|
-
<%
|
11
|
-
gem "
|
10
|
+
<% if options[:api] %>
|
11
|
+
gem "sprockets", "< 4"
|
12
12
|
<% end %>
|
13
|
+
|
13
14
|
gem "bootsnap", require: false
|
15
|
+
gem "cssbundling-rails"
|
14
16
|
gem "honeybadger"
|
17
|
+
gem "jsbundling-rails"
|
15
18
|
gem "pg"
|
16
19
|
gem "puma"
|
17
20
|
gem "rack-canonical-host"
|
@@ -19,10 +22,11 @@ gem "rails", "<%= Suspenders::RAILS_VERSION %>"
|
|
19
22
|
gem "recipient_interceptor"
|
20
23
|
gem "sassc-rails"
|
21
24
|
gem "skylight"
|
22
|
-
gem "sprockets"
|
25
|
+
gem "sprockets-rails"
|
26
|
+
gem "stimulus-rails"
|
23
27
|
gem "title"
|
28
|
+
gem "turbo-rails"
|
24
29
|
gem "tzinfo-data", platforms: [:mingw, :x64_mingw, :mswin, :jruby]
|
25
|
-
gem "webpacker"
|
26
30
|
|
27
31
|
group :development do
|
28
32
|
gem "listen"
|
data/templates/Procfile
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
web: bundle exec puma -p $PORT -C ./config/puma.rb
|
2
|
-
worker: bundle exec
|
2
|
+
worker: bundle exec sidekiq
|
data/templates/active_job.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
@import "normalize.css"
|
data/templates/bin_yarn
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
APP_ROOT = File.expand_path("..", __dir__)
|
4
|
+
Dir.chdir(APP_ROOT) do
|
5
|
+
yarn = ENV["PATH"].split(File::PATH_SEPARATOR)
|
6
|
+
.select { |dir| File.expand_path(dir) != __dir__ }
|
7
|
+
.product(["yarn", "yarnpkg", "yarn.cmd", "yarn.ps1"])
|
8
|
+
.map { |dir, file| File.expand_path(file, dir) }
|
9
|
+
.find { |file| File.executable?(file) }
|
10
|
+
|
11
|
+
if yarn
|
12
|
+
exec yarn, *ARGV
|
13
|
+
else
|
14
|
+
warn "Yarn executable was not detected in the system."
|
15
|
+
warn "Download Yarn at https://yarnpkg.com/en/docs/install"
|
16
|
+
exit 1
|
17
|
+
end
|
18
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Set up the app to run locally with ease.
|
2
2
|
|
3
|
-
Use Puma and
|
3
|
+
Use Puma and Sidekiq to run the app. This can be done via either
|
4
4
|
`heroku local` or any Foreman-compatible project runner (e.g. `foreman start`).
|
5
5
|
|
6
6
|
Configure your app using `.env`. Installs a basic `.sample.env` that is meant
|
@@ -6,4 +6,4 @@ Set up the project for an in-depth test-driven development workflow.
|
|
6
6
|
- Prepare for system tests in `spec/system`.
|
7
7
|
- Integrate Formulaic for easier form testing.
|
8
8
|
- RSpec infers the file type based on the directory name.
|
9
|
-
- Install and configure RSpec and shoulda-matchers
|
9
|
+
- Install and configure RSpec and shoulda-matchers.
|
data/templates/errors.rb
CHANGED
data/templates/oj.rb
ADDED
@@ -1,2 +1,2 @@
|
|
1
|
-
config.action_mailer.delivery_method = :smtp
|
2
|
-
config.action_mailer.smtp_settings = SMTP_SETTINGS
|
1
|
+
config.action_mailer.delivery_method = :smtp
|
2
|
+
config.action_mailer.smtp_settings = SMTP_SETTINGS
|
@@ -1,4 +1,5 @@
|
|
1
|
-
if ENV.fetch("HEROKU_APP_NAME", "").include?("staging-pr-")
|
2
|
-
|
3
|
-
|
4
|
-
end
|
1
|
+
if ENV.fetch("HEROKU_APP_NAME", "").include?("staging-pr-")
|
2
|
+
ENV["APPLICATION_HOST"] = ENV["HEROKU_APP_NAME"] + ".herokuapp.com"
|
3
|
+
ENV["ASSET_HOST"] = ENV["HEROKU_APP_NAME"] + ".herokuapp.com"
|
4
|
+
end
|
5
|
+
|
data/templates/sample_env
CHANGED
@@ -1,21 +1,23 @@
|
|
1
1
|
<!DOCTYPE html>
|
2
2
|
<html lang="<%= I18n.locale %>">
|
3
3
|
<head>
|
4
|
-
<meta charset="utf-8" />
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
|
6
4
|
<%%#
|
7
5
|
Configure default and controller-, and view-specific titles in
|
8
6
|
config/locales/en.yml. For more see:
|
9
7
|
https://github.com/calebthompson/title#usage
|
10
8
|
%>
|
11
9
|
<title><%%= title %></title>
|
12
|
-
|
10
|
+
<meta charset="utf-8" />
|
11
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
|
13
12
|
<%%= csrf_meta_tags %>
|
13
|
+
<%%= csp_meta_tag %>
|
14
|
+
|
15
|
+
<%%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
|
16
|
+
<%%= javascript_include_tag "application", "data-turbo-track": "reload", defer: true %>
|
14
17
|
</head>
|
15
18
|
<body>
|
16
19
|
<%%= render "flashes" -%>
|
17
20
|
<%%= yield %>
|
18
|
-
<%%= render "javascript" %>
|
19
21
|
<%%= render "css_overrides" %>
|
20
22
|
</body>
|
21
23
|
</html>
|