suspenders 1.50.0 → 1.54.1
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/.travis.yml +6 -4
- data/CONTRIBUTING.md +15 -15
- data/GOALS.md +65 -0
- data/NEWS.md +55 -0
- data/README.md +7 -4
- data/docs/heroku_deploy.md +19 -0
- data/lib/suspenders.rb +10 -0
- data/lib/suspenders/actions.rb +2 -2
- data/lib/suspenders/adapters/heroku.rb +14 -5
- data/lib/suspenders/app_builder.rb +3 -91
- data/lib/suspenders/generators/advisories_generator.rb +15 -0
- data/lib/suspenders/generators/analytics_generator.rb +2 -7
- data/lib/suspenders/generators/app_generator.rb +14 -41
- data/lib/suspenders/generators/base.rb +59 -0
- data/lib/suspenders/generators/ci_generator.rb +20 -14
- data/lib/suspenders/generators/db_optimizations_generator.rb +6 -18
- data/lib/suspenders/generators/factories_generator.rb +3 -8
- data/lib/suspenders/generators/forms_generator.rb +3 -3
- data/lib/suspenders/generators/inline_svg_generator.rb +14 -0
- data/lib/suspenders/generators/jobs_generator.rb +3 -13
- data/lib/suspenders/generators/js_driver_generator.rb +9 -11
- data/lib/suspenders/generators/json_generator.rb +3 -3
- data/lib/suspenders/generators/lint_generator.rb +2 -7
- data/lib/suspenders/generators/preloader_generator.rb +122 -0
- data/lib/suspenders/generators/production/compression_generator.rb +14 -0
- data/lib/suspenders/generators/production/deployment_generator.rb +16 -0
- data/lib/suspenders/generators/production/email_generator.rb +7 -18
- data/lib/suspenders/generators/production/force_tls_generator.rb +2 -5
- data/lib/suspenders/generators/production/manifest_generator.rb +25 -0
- data/lib/suspenders/generators/production/single_redirect.rb +15 -0
- data/lib/suspenders/generators/production/timeout_generator.rb +3 -2
- data/lib/suspenders/generators/profiler_generator.rb +35 -0
- data/lib/suspenders/generators/runner_generator.rb +48 -0
- data/lib/suspenders/generators/staging/pull_requests_generator.rb +4 -26
- data/lib/suspenders/generators/static_generator.rb +7 -3
- data/lib/suspenders/generators/stylelint_generator.rb +70 -0
- data/lib/suspenders/generators/stylesheet_base_generator.rb +8 -13
- data/lib/suspenders/generators/testing_generator.rb +6 -22
- data/lib/suspenders/generators/views_generator.rb +2 -7
- data/lib/suspenders/version.rb +2 -2
- data/spec/adapters/heroku_spec.rb +28 -2
- data/spec/expand_json_spec.rb +89 -0
- data/spec/features/advisories_spec.rb +24 -0
- data/spec/features/api_spec.rb +1 -1
- data/spec/features/ci_spec.rb +31 -0
- data/spec/features/db_optimizations_spec.rb +19 -0
- data/spec/features/heroku_spec.rb +7 -14
- data/spec/features/inline_svg_spec.rb +10 -0
- data/spec/features/json_spec.rb +1 -1
- data/spec/features/new_project_spec.rb +17 -35
- data/spec/features/preloader_spec.rb +25 -0
- data/spec/features/production/compression_spec.rb +23 -0
- data/spec/features/production/deployment_spec.rb +22 -0
- data/spec/features/production/email_spec.rb +1 -1
- data/spec/features/production/manifest_spec.rb +37 -0
- data/spec/features/production/single_redirect_spec.rb +25 -0
- data/spec/features/profiler_spec.rb +20 -0
- data/spec/features/runner_spec.rb +30 -0
- data/spec/features/staging/pull_requests_spec.rb +1 -1
- data/spec/features/static_spec.rb +17 -0
- data/spec/features/stylelint_spec.rb +60 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/support/be_executable_matcher.rb +7 -0
- data/spec/support/contain_json_matcher.rb +16 -10
- data/spec/support/generators.rb +5 -0
- data/spec/support/project_files.rb +25 -0
- data/spec/support/rails_template.rb +1 -0
- data/spec/support/suspenders.rb +18 -15
- data/suspenders.gemspec +1 -1
- data/templates/Gemfile.erb +5 -11
- data/templates/_javascript.html.erb +1 -1
- data/templates/application.scss +0 -1
- data/templates/bin_auto_migrate +5 -0
- data/templates/bin_deploy +0 -2
- data/templates/bin_setup +2 -2
- data/templates/bin_setup_review_app.erb +0 -1
- data/templates/capybara_silence_puma.rb +1 -0
- data/templates/chromedriver.rb +14 -4
- data/templates/descriptions/advisories.md +5 -0
- data/templates/descriptions/analytics.md +4 -0
- data/templates/descriptions/ci.md +4 -0
- data/templates/descriptions/compression.md +4 -0
- data/templates/descriptions/db_optimizations.md +2 -0
- data/templates/descriptions/deployment.md +5 -0
- data/templates/descriptions/email.md +9 -0
- data/templates/descriptions/factories.md +12 -0
- data/templates/descriptions/force_tls.md +1 -0
- data/templates/descriptions/forms.md +1 -0
- data/templates/descriptions/inline_svg.md +2 -0
- data/templates/descriptions/jobs.md +3 -0
- data/templates/descriptions/js_driver.md +4 -0
- data/templates/descriptions/json.md +1 -0
- data/templates/descriptions/lint.md +3 -0
- data/templates/descriptions/manifest.md +2 -0
- data/templates/descriptions/preloader.md +3 -0
- data/templates/descriptions/profiler.md +7 -0
- data/templates/descriptions/pull_requests.md +4 -0
- data/templates/descriptions/runner.md +10 -0
- data/templates/descriptions/single_redirect.md +1 -0
- data/templates/descriptions/static.md +5 -0
- data/templates/descriptions/stylelint.md +3 -0
- data/templates/descriptions/stylesheet_base.md +4 -0
- data/templates/descriptions/testing.md +9 -0
- data/templates/descriptions/timeout.md +4 -0
- data/templates/descriptions/views.md +8 -0
- data/templates/hound.yml +3 -1
- data/templates/inline_svg.rb +3 -0
- data/templates/partials/ci_simplecov.rb +16 -0
- data/templates/partials/db_optimizations_configuration.rb +7 -0
- data/templates/partials/deployment_readme.md +8 -0
- data/templates/partials/email_smtp.rb +3 -0
- data/templates/partials/profiler_readme.md +8 -0
- data/templates/partials/pull_requests_config.rb +5 -0
- data/templates/partials/runner_readme.md +31 -0
- data/templates/partials/runner_setup.rb +3 -0
- data/templates/rack_mini_profiler.rb +2 -0
- data/templates/rails_helper.rb +7 -4
- data/templates/{dotfiles/.env → sample_env} +0 -2
- data/templates/spec_helper.rb +4 -7
- data/templates/spring.rb +6 -0
- data/templates/stylelintrc.json +3 -0
- data/templates/suspenders_gitignore +1 -1
- metadata +119 -17
- data/templates/app.json.erb +0 -27
- data/templates/browserslist +0 -3
- data/templates/dotfiles/.ctags +0 -2
- data/templates/puma.rb +0 -28
data/templates/application.scss
CHANGED
data/templates/bin_deploy
CHANGED
data/templates/bin_setup
CHANGED
@@ -17,6 +17,5 @@ heroku pg:backups:capture --app $PARENT_APP_NAME
|
|
17
17
|
URL=`heroku pg:backups public-url --app $PARENT_APP_NAME`
|
18
18
|
|
19
19
|
heroku pg:backups restore $URL DATABASE_URL --confirm $APP_NAME --app $APP_NAME
|
20
|
-
heroku run rails db:migrate --exit-code --app $APP_NAME
|
21
20
|
heroku ps:scale worker=1 --app $APP_NAME
|
22
21
|
heroku restart --app $APP_NAME
|
@@ -0,0 +1 @@
|
|
1
|
+
Capybara.server = :puma, { Silent: true }
|
data/templates/chromedriver.rb
CHANGED
@@ -5,13 +5,23 @@ Capybara.register_driver :chrome do |app|
|
|
5
5
|
end
|
6
6
|
|
7
7
|
Capybara.register_driver :headless_chrome do |app|
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
options = ::Selenium::WebDriver::Chrome::Options.new
|
9
|
+
options.headless!
|
10
|
+
options.add_argument "--window-size=1680,1050"
|
11
11
|
|
12
12
|
Capybara::Selenium::Driver.new app,
|
13
13
|
browser: :chrome,
|
14
|
-
|
14
|
+
options: options
|
15
15
|
end
|
16
16
|
|
17
17
|
Capybara.javascript_driver = :headless_chrome
|
18
|
+
|
19
|
+
RSpec.configure do |config|
|
20
|
+
config.before(:each, type: :system) do
|
21
|
+
driven_by :rack_test
|
22
|
+
end
|
23
|
+
|
24
|
+
config.before(:each, type: :system, js: true) do
|
25
|
+
driven_by Capybara.javascript_driver
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
Build test data with clarity and ease.
|
2
|
+
|
3
|
+
This uses FactoryBot to help you define dummy and test data for your test
|
4
|
+
suite. The `create`, `build`, and `build_stubbed` class methods are directly
|
5
|
+
available to all tests.
|
6
|
+
|
7
|
+
We recommend putting FactoryBot definitions in one `spec/factories.rb` file, at
|
8
|
+
least until it grows unwieldy. This helps reduce confusion around circular
|
9
|
+
dependencies and makes it easy to jump between definitions.
|
10
|
+
|
11
|
+
Outside of the tests, the `dev:prime` rake task can be used to insert initial
|
12
|
+
development data into the database. You can use FactoryBot here, too.
|
@@ -0,0 +1 @@
|
|
1
|
+
Redirect users to the HTTPS URL on the production Web site.
|
@@ -0,0 +1 @@
|
|
1
|
+
Make forms easier to make with form helpers. This mostly involves SimpleForm.
|
@@ -0,0 +1 @@
|
|
1
|
+
Use the fastest JSON parser available.
|
@@ -0,0 +1,7 @@
|
|
1
|
+
Show runtime profiling for your Rails app as you develop it.
|
2
|
+
|
3
|
+
This uses the `rack-mini-profiler` gem to show a speed badge on every page.
|
4
|
+
This is controlled by the `RACK_MINI_PROFILER` environment variable which
|
5
|
+
defaults to `0` in the `.sample.env`. Set it to `1` to enable profiling.
|
6
|
+
|
7
|
+
Updates your README.md to explain this environment variable.
|
@@ -0,0 +1,10 @@
|
|
1
|
+
Set up the app to run locally with ease.
|
2
|
+
|
3
|
+
Use Puma and the Rails jobs runner to run the app. This can be done via either
|
4
|
+
`heroku local` or any Foreman-compatible project runner (e.g. `foreman start`).
|
5
|
+
|
6
|
+
Configure your app using `.env`. Installs a basic `.sample.env` that is meant
|
7
|
+
to be checked into git and used as a template for your `.env`. The `bin/setup`
|
8
|
+
script is modified to safely copy `.sample.env` to `.env` for you.
|
9
|
+
|
10
|
+
Document all of this in the README.
|
@@ -0,0 +1 @@
|
|
1
|
+
Canonicalize the URL by configuring the `Rack::CanonicalHost` middleware.
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Set up the project for an in-depth test-driven development workflow.
|
2
|
+
|
3
|
+
- Maintain the test DB schema.
|
4
|
+
- Clear mail deliveries between tests.
|
5
|
+
- Import i18n helpers for use in tests.
|
6
|
+
- Prepare for system tests in `spec/system`.
|
7
|
+
- Integrate Formulaic for easier form testing.
|
8
|
+
- RSpec infers the file type based on the directory name.
|
9
|
+
- Install and configure RSpec and shoulda-matchers, with Spring integration.
|
@@ -0,0 +1,8 @@
|
|
1
|
+
View templates for flash, JavaScript, and CSS.
|
2
|
+
|
3
|
+
- Disable CSS animations in tests.
|
4
|
+
- Run JavaScript when the page has loaded.
|
5
|
+
- Use the `title` gem for controlling the page title via i18n.
|
6
|
+
- Insert one-off JavaScript into a `:javascript` content block.
|
7
|
+
- Creates the directory for storing generic, application-level partials.
|
8
|
+
- Render user-facing partials (alert, error, notice, success) on all pages.
|
data/templates/hound.yml
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
if ENV.fetch("COVERAGE", false)
|
2
|
+
require "simplecov"
|
3
|
+
|
4
|
+
if ENV["CIRCLE_ARTIFACTS"]
|
5
|
+
dir = File.join(ENV["CIRCLE_ARTIFACTS"], "coverage")
|
6
|
+
SimpleCov.coverage_dir(dir)
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
SimpleCov.start "rails"
|
11
|
+
|
12
|
+
if defined?(Spring) && ENV["DISABLE_SPRING"].to_i == 1
|
13
|
+
Rails.application.eager_load!
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
## Configuration
|
2
|
+
|
3
|
+
Environment variables during local development are handled by the node-foreman
|
4
|
+
project runner. To provide environment variables, create a `.env` file at the
|
5
|
+
root of the project. In that file provide the environment variables listed in
|
6
|
+
`.sample.env`. The `bin/setup` script does this for you, but be careful about
|
7
|
+
overwriting your existing `.env` file.
|
8
|
+
|
9
|
+
`app.json` also contains a list of environment variables that are required for
|
10
|
+
the application. The `.sample.env` file provides either non-secret vars that
|
11
|
+
can be copied directly into your own `.env` file or instructions on where to
|
12
|
+
obtain secret values.
|
13
|
+
|
14
|
+
During development add any new environment variables needed by the application
|
15
|
+
to both `.sample.env` and `app.json`, providing either **public** default
|
16
|
+
values or brief instructions on where secret values may be found.
|
17
|
+
|
18
|
+
Do not commit the `.env` file to the git repo.
|
19
|
+
|
20
|
+
## Running the Application
|
21
|
+
|
22
|
+
Use the `heroku local` runner to run the app locally as it would run on Heroku.
|
23
|
+
This uses the node-forman runner, which reads from the `Procfile` file.
|
24
|
+
|
25
|
+
```sh
|
26
|
+
heroku local
|
27
|
+
```
|
28
|
+
|
29
|
+
Once the server is started the application is reachable at
|
30
|
+
`http://localhost:3000`.
|
31
|
+
|
data/templates/rails_helper.rb
CHANGED
@@ -1,19 +1,22 @@
|
|
1
1
|
ENV["RACK_ENV"] = "test"
|
2
2
|
|
3
3
|
require File.expand_path("../../config/environment", __FILE__)
|
4
|
-
|
4
|
+
|
5
|
+
if Rails.env.production?
|
6
|
+
abort("The Rails environment is running in production mode!")
|
7
|
+
end
|
5
8
|
|
6
9
|
require "rspec/rails"
|
7
10
|
|
8
11
|
Dir[Rails.root.join("spec/support/**/*.rb")].sort.each { |file| require file }
|
9
12
|
|
10
|
-
module
|
11
|
-
# Extend this module in spec/support/
|
13
|
+
module SystemTestHelper
|
14
|
+
# Extend this module in spec/support/system/*.rb
|
12
15
|
include Formulaic::Dsl
|
13
16
|
end
|
14
17
|
|
15
18
|
RSpec.configure do |config|
|
16
|
-
config.include
|
19
|
+
config.include SystemTestHelper, type: :system
|
17
20
|
config.infer_base_class_for_anonymous_controllers = false
|
18
21
|
config.infer_spec_type_from_file_location!
|
19
22
|
config.use_transactional_fixtures = true
|
data/templates/spec_helper.rb
CHANGED
@@ -1,9 +1,3 @@
|
|
1
|
-
if ENV.fetch("COVERAGE", false)
|
2
|
-
require "simplecov"
|
3
|
-
|
4
|
-
SimpleCov.start "rails"
|
5
|
-
end
|
6
|
-
|
7
1
|
require "webmock/rspec"
|
8
2
|
require "timecop"
|
9
3
|
|
@@ -22,7 +16,10 @@ RSpec.configure do |config|
|
|
22
16
|
config.order = :random
|
23
17
|
end
|
24
18
|
|
25
|
-
WebMock.disable_net_connect!(
|
19
|
+
WebMock.disable_net_connect!(
|
20
|
+
allow_localhost: true,
|
21
|
+
allow: "chromedriver.storage.googleapis.com",
|
22
|
+
)
|
26
23
|
|
27
24
|
# Only allow Timecop with block syntax
|
28
25
|
Timecop.safe_mode = true
|
data/templates/spring.rb
ADDED