welaika-suspenders 2.20.0 → 2.21.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/NEWS.md +15 -1
- data/README.md +3 -5
- data/RELEASING.md +19 -0
- data/lib/suspenders.rb +1 -0
- data/lib/suspenders/adapters/heroku.rb +68 -0
- data/lib/suspenders/app_builder.rb +43 -99
- data/lib/suspenders/generators/app_generator.rb +6 -20
- data/lib/suspenders/version.rb +1 -1
- data/spec/adapters/heroku_spec.rb +52 -0
- data/spec/features/heroku_spec.rb +52 -46
- data/spec/features/new_project_spec.rb +26 -3
- data/spec/spec_helper.rb +1 -1
- data/spec/support/fake_heroku.rb +5 -3
- data/spec/support/suspenders.rb +12 -3
- data/suspenders.gemspec +2 -4
- data/templates/Gemfile.erb +0 -1
- data/templates/README.md.erb +4 -20
- data/templates/{application.css.sass → application.sass} +0 -3
- data/templates/bin_setup.erb +0 -15
- data/templates/{sample.env → dotfiles/.env} +3 -1
- data/templates/suspenders_gitignore +1 -2
- data/templates/suspenders_layout.html.slim +1 -1
- metadata +15 -39
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: caa6bea955825db755fa23569d1b1d70d5ebde16
|
4
|
+
data.tar.gz: 32bccbce056de85654fdb8999bcf3cde6a8c2c0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4dcc5577049163c170df77633aac90297fc4ecb09c174f3e63ef576ba80107046a4ef4cc15decf1f2cfeae993b266d056247ae9a470ef003fb0449da3af5546c
|
7
|
+
data.tar.gz: 40bda7c47ef7be947af94dee506fddd15ed2d3ea8128e7dcdb476ea1dc219f4aecc242ddbd5f255854a6f9797ea662702b8cdf44d76d6dfb35a3c996149cf8ed
|
data/LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
The MIT License
|
2
2
|
|
3
|
-
Copyright (c)
|
3
|
+
Copyright (c) 2008-2015 thoughtbot, inc.
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
data/NEWS.md
CHANGED
@@ -1,6 +1,20 @@
|
|
1
|
-
|
1
|
+
HEAD
|
2
2
|
|
3
|
+
* Add ability to use byebug navigation commands inside of Pry using the
|
4
|
+
`pry-byebug` gem
|
5
|
+
|
6
|
+
1.34.0 (November 15, 2015)
|
7
|
+
|
8
|
+
* Fix `block_unknown_urls` deprecation warning with capybara_webkit when running
|
9
|
+
Javascript tests
|
10
|
+
* Inherit staging's `action_mailer_host` config from production
|
3
11
|
* Suspenders command line responds to `-v` and `--version` options
|
12
|
+
* Clean up `bin/rake`
|
13
|
+
* Remove `email_validator` gem from generated Gemfile
|
14
|
+
* Fix Circle deploys by removing redundant remote
|
15
|
+
* Add `bullet` as development dependency
|
16
|
+
* Use Heroku Local (Forego) instead of Foreman
|
17
|
+
* Raise on missing Sprockets assets in test environment
|
4
18
|
|
5
19
|
1.33.0 (October 23, 2015)
|
6
20
|
|
data/README.md
CHANGED
@@ -37,8 +37,6 @@ See all possible Heroku flags:
|
|
37
37
|
This will create a rails app in `projectname`. This script creates a
|
38
38
|
new git repository. It is not meant to be used against an existing repo.
|
39
39
|
|
40
|
-
Then run:
|
41
|
-
|
42
40
|
cd projectname && bin/setup
|
43
41
|
|
44
42
|
If you want to add an empty bare repository as origin, run
|
@@ -64,11 +62,10 @@ List of changes we made since [this is commit](https://github.com/thoughtbot/sus
|
|
64
62
|
- add [slim-rails](https://github.com/slim-template/slim-rails) gem
|
65
63
|
- add some html meta tags
|
66
64
|
- use EU region as default for Heroku
|
67
|
-
- use pry-byebug instead of byebug
|
68
65
|
- use CDATA wrapper for javascript
|
69
66
|
- create a .ruby-gemset file with app name
|
70
67
|
- create common folders like `app/queries`, `app/services`, etc.
|
71
|
-
- use `application.
|
68
|
+
- use `application.sass` instead of `application.scss`
|
72
69
|
- add `brakeman` gem
|
73
70
|
- change `i18n_tasks` configuration: set `it` as base locale
|
74
71
|
- set `Rome` as `time_zone`
|
@@ -81,10 +78,11 @@ List of changes we made since [this is commit](https://github.com/thoughtbot/sus
|
|
81
78
|
- add helpers for capybara (`page!`, `screenshot!`)
|
82
79
|
- drop support for IE 9 in AutoPrefixer
|
83
80
|
- removed [hound](https://houndci.com) configuration
|
84
|
-
- add [bullet](https://github.com/flyerhzm/bullet)
|
85
81
|
- add [draper](https://github.com/drapergem/draper) gem and rename `presenters` folder to `decorators`
|
86
82
|
- add [rubocop](https://github.com/bbatsov/rubocop) and a template of `.rubocop.yml`
|
87
83
|
- change rake default task: now includes rubocop and brakeman too
|
88
84
|
- prefer a single file for each `factory_girl` factories
|
89
85
|
- remove new-relic
|
90
86
|
- add [email-validator](https://github.com/balexand/email_validator) gem
|
87
|
+
- remove circle-ci
|
88
|
+
- remove bitters and refills
|
data/RELEASING.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# Releasing
|
2
|
+
|
3
|
+
1. Update `lib/suspenders/version.rb` file accordingly.
|
4
|
+
2. Update `NEWS.md` to reflect the changes since last release.
|
5
|
+
3. Commit changes. There shouldn't be code changes, and thus CI doesn't need to
|
6
|
+
run, you can then add `[ci skip]` to the commit message.
|
7
|
+
4. Tag the release: `git tag vVERSION -a`. The tag message should contain the
|
8
|
+
appropriate `NEWS.md` subsection.
|
9
|
+
5. Push changes: `git push --tags`
|
10
|
+
6. Build and publish to rubygems:
|
11
|
+
```bash
|
12
|
+
gem build suspenders.gemspec
|
13
|
+
gem push suspenders-*.gem
|
14
|
+
```
|
15
|
+
|
16
|
+
7. Add a new GitHub release:
|
17
|
+
https://github.com/thoughtbot/suspenders/releases/new?tag=vVERSION
|
18
|
+
8. Announce the new release, making sure to say "thank you" to the contributors
|
19
|
+
who helped shape this version!
|
data/lib/suspenders.rb
CHANGED
@@ -0,0 +1,68 @@
|
|
1
|
+
module Suspenders
|
2
|
+
module Adapters
|
3
|
+
class Heroku
|
4
|
+
def initialize(app_builder)
|
5
|
+
@app_builder = app_builder
|
6
|
+
end
|
7
|
+
|
8
|
+
def set_heroku_remotes
|
9
|
+
remotes = <<-SHELL.strip_heredoc
|
10
|
+
|
11
|
+
# Set up the staging and production apps.
|
12
|
+
#{command_to_join_heroku_app('staging')}
|
13
|
+
#{command_to_join_heroku_app('production')}
|
14
|
+
git config heroku.remote staging
|
15
|
+
SHELL
|
16
|
+
|
17
|
+
app_builder.append_file "bin/setup", remotes
|
18
|
+
end
|
19
|
+
|
20
|
+
def set_up_heroku_specific_gems
|
21
|
+
app_builder.inject_into_file(
|
22
|
+
"Gemfile",
|
23
|
+
%{\n\s\sgem "rails_stdout_logging"},
|
24
|
+
after: /group :staging, :production do/,
|
25
|
+
)
|
26
|
+
end
|
27
|
+
|
28
|
+
def set_heroku_rails_secrets
|
29
|
+
%w(staging production).each do |environment|
|
30
|
+
run_toolbelt_command(
|
31
|
+
"config:add SECRET_KEY_BASE=#{generate_secret}",
|
32
|
+
environment,
|
33
|
+
)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
attr_reader :app_builder
|
40
|
+
|
41
|
+
def command_to_join_heroku_app(environment)
|
42
|
+
heroku_app_name = heroku_app_name_for(environment)
|
43
|
+
<<-SHELL
|
44
|
+
if heroku join --app #{heroku_app_name} &> /dev/null; then
|
45
|
+
git remote add #{environment} git@heroku.com:#{heroku_app_name}.git || true
|
46
|
+
printf 'You are a collaborator on the "#{heroku_app_name}" Heroku app\n'
|
47
|
+
else
|
48
|
+
printf 'Ask for access to the "#{heroku_app_name}" Heroku app\n'
|
49
|
+
fi
|
50
|
+
SHELL
|
51
|
+
end
|
52
|
+
|
53
|
+
def heroku_app_name_for(environment)
|
54
|
+
"#{app_builder.app_name.dasherize}-#{environment}"
|
55
|
+
end
|
56
|
+
|
57
|
+
def generate_secret
|
58
|
+
SecureRandom.hex(64)
|
59
|
+
end
|
60
|
+
|
61
|
+
def run_toolbelt_command(command, environment)
|
62
|
+
app_builder.run(
|
63
|
+
"heroku #{command} --remote #{environment}",
|
64
|
+
)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -1,11 +1,27 @@
|
|
1
|
+
require "forwardable"
|
2
|
+
|
1
3
|
module Suspenders
|
2
4
|
class AppBuilder < Rails::AppBuilder
|
3
5
|
include Suspenders::Actions
|
6
|
+
extend Forwardable
|
7
|
+
|
8
|
+
def_delegators :heroku_adapter,
|
9
|
+
:set_heroku_remotes,
|
10
|
+
:set_up_heroku_specific_gems,
|
11
|
+
:set_heroku_rails_secrets
|
4
12
|
|
5
13
|
def readme
|
6
14
|
template 'README.md.erb', 'README.md'
|
7
15
|
end
|
8
16
|
|
17
|
+
def raise_on_missing_assets_in_test
|
18
|
+
inject_into_file(
|
19
|
+
"config/environments/test.rb",
|
20
|
+
"\n config.assets.raise_runtime_errors = true",
|
21
|
+
after: "Rails.application.configure do",
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
9
25
|
def raise_on_delivery_errors
|
10
26
|
replace_in_file 'config/environments/development.rb',
|
11
27
|
'raise_delivery_errors = false', 'raise_delivery_errors = true'
|
@@ -19,17 +35,21 @@ module Suspenders
|
|
19
35
|
)
|
20
36
|
end
|
21
37
|
|
22
|
-
def
|
23
|
-
config = <<-RUBY
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
end
|
38
|
+
def add_bullet_gem_configuration
|
39
|
+
config = <<-RUBY
|
40
|
+
config.after_initialize do
|
41
|
+
Bullet.enable = true
|
42
|
+
Bullet.bullet_logger = true
|
43
|
+
Bullet.rails_logger = true
|
44
|
+
end
|
45
|
+
|
31
46
|
RUBY
|
32
|
-
|
47
|
+
|
48
|
+
inject_into_file(
|
49
|
+
"config/environments/development.rb",
|
50
|
+
config,
|
51
|
+
after: "config.action_mailer.raise_delivery_errors = true\n",
|
52
|
+
)
|
33
53
|
end
|
34
54
|
|
35
55
|
def raise_on_unpermitted_parameters
|
@@ -212,14 +232,6 @@ end
|
|
212
232
|
create_file '.ruby-gemset', "#{app_name}\n"
|
213
233
|
end
|
214
234
|
|
215
|
-
def setup_heroku_specific_gems
|
216
|
-
inject_into_file(
|
217
|
-
"Gemfile",
|
218
|
-
%{\n\s\sgem "rails_stdout_logging"},
|
219
|
-
after: /group :staging, :production do/
|
220
|
-
)
|
221
|
-
end
|
222
|
-
|
223
235
|
def enable_database_cleaner
|
224
236
|
copy_file 'database_cleaner_rspec.rb', 'spec/support/database_cleaner.rb'
|
225
237
|
end
|
@@ -243,10 +255,6 @@ end
|
|
243
255
|
copy_file "spec_helper.rb", "spec/spec_helper.rb"
|
244
256
|
end
|
245
257
|
|
246
|
-
def configure_ci
|
247
|
-
template "circle.yml.erb", "circle.yml"
|
248
|
-
end
|
249
|
-
|
250
258
|
def configure_i18n_for_test_environment
|
251
259
|
copy_file "i18n.rb", "spec/support/i18n.rb"
|
252
260
|
end
|
@@ -276,16 +284,14 @@ end
|
|
276
284
|
def configure_locales
|
277
285
|
remove_file "config/locales/en.yml"
|
278
286
|
template "config_locales_it.yml.erb", "config/locales/it.yml"
|
279
|
-
end
|
280
|
-
|
281
|
-
def configure_time_formats
|
282
|
-
replace_in_file "config/application.rb",
|
283
|
-
"# config.time_zone = 'Central Time (US & Canada)'",
|
284
|
-
"config.time_zone = 'Rome'"
|
285
287
|
|
286
288
|
replace_in_file "config/application.rb",
|
287
289
|
"# config.i18n.default_locale = :de",
|
288
290
|
"config.i18n.default_locale = :it"
|
291
|
+
|
292
|
+
replace_in_file "config/application.rb",
|
293
|
+
"# config.time_zone = 'Central Time (US & Canada)'",
|
294
|
+
"config.time_zone = 'Rome'"
|
289
295
|
end
|
290
296
|
|
291
297
|
def configure_rack_timeout
|
@@ -341,25 +347,14 @@ Rack::Timeout.timeout = (ENV["RACK_TIMEOUT"] || 10).to_i
|
|
341
347
|
copy_file "puma.rb", "config/puma.rb"
|
342
348
|
end
|
343
349
|
|
344
|
-
def
|
345
|
-
copy_file
|
346
|
-
copy_file 'Procfile', 'Procfile'
|
350
|
+
def set_up_forego
|
351
|
+
copy_file "Procfile", "Procfile"
|
347
352
|
end
|
348
353
|
|
349
354
|
def setup_stylesheets
|
350
355
|
remove_file 'app/assets/stylesheets/application.css'
|
351
|
-
copy_file 'application.
|
352
|
-
'app/assets/stylesheets/application.
|
353
|
-
end
|
354
|
-
|
355
|
-
def install_refills
|
356
|
-
run "rails generate refills:import flashes"
|
357
|
-
run "rm app/views/refills/_flashes.html.erb"
|
358
|
-
run "rmdir app/views/refills"
|
359
|
-
end
|
360
|
-
|
361
|
-
def install_bitters
|
362
|
-
run "bitters install --path app/assets/stylesheets"
|
356
|
+
copy_file 'application.sass',
|
357
|
+
'app/assets/stylesheets/application.sass'
|
363
358
|
end
|
364
359
|
|
365
360
|
def gitignore_files
|
@@ -415,35 +410,6 @@ Rack::Timeout.timeout = (ENV["RACK_TIMEOUT"] || 10).to_i
|
|
415
410
|
create_production_heroku_app(flags)
|
416
411
|
end
|
417
412
|
|
418
|
-
def set_heroku_remotes
|
419
|
-
remotes = <<-SHELL
|
420
|
-
|
421
|
-
# Set up the staging and production apps.
|
422
|
-
#{join_heroku_app('staging')}
|
423
|
-
#{join_heroku_app('production')}
|
424
|
-
SHELL
|
425
|
-
|
426
|
-
append_file 'bin/setup', remotes
|
427
|
-
end
|
428
|
-
|
429
|
-
def join_heroku_app(environment)
|
430
|
-
heroku_app_name = heroku_app_name_for(environment)
|
431
|
-
<<-SHELL
|
432
|
-
if heroku join --app #{heroku_app_name} &> /dev/null; then
|
433
|
-
git remote add #{environment} git@heroku.com:#{heroku_app_name}.git || true
|
434
|
-
printf 'You are a collaborator on the "#{heroku_app_name}" Heroku app\n'
|
435
|
-
else
|
436
|
-
printf 'Ask for access to the "#{heroku_app_name}" Heroku app\n'
|
437
|
-
fi
|
438
|
-
SHELL
|
439
|
-
end
|
440
|
-
|
441
|
-
def set_heroku_rails_secrets
|
442
|
-
%w(staging production).each do |environment|
|
443
|
-
run_heroku "config:add SECRET_KEY_BASE=#{generate_secret}", environment
|
444
|
-
end
|
445
|
-
end
|
446
|
-
|
447
413
|
def set_heroku_serve_static_files
|
448
414
|
%w(staging production).each do |environment|
|
449
415
|
run_heroku "config:add RAILS_SERVE_STATIC_FILES=true", environment
|
@@ -468,23 +434,8 @@ you can deploy to staging and production with:
|
|
468
434
|
run "chmod a+x bin/deploy"
|
469
435
|
end
|
470
436
|
|
471
|
-
def configure_automatic_deployment
|
472
|
-
staging_remote_name = heroku_app_name_for("staging")
|
473
|
-
deploy_command = <<-YML.strip_heredoc
|
474
|
-
deployment:
|
475
|
-
staging:
|
476
|
-
branch: master
|
477
|
-
commands:
|
478
|
-
- git remote add staging git@heroku.com:#{staging_remote_name}.git
|
479
|
-
- bin/deploy staging
|
480
|
-
YML
|
481
|
-
|
482
|
-
append_file "circle.yml", deploy_command
|
483
|
-
end
|
484
|
-
|
485
437
|
def create_github_repo(repo_name)
|
486
|
-
|
487
|
-
run "#{path_addition} hub create #{repo_name}"
|
438
|
+
run "hub create #{repo_name}"
|
488
439
|
end
|
489
440
|
|
490
441
|
def setup_bundler_audit
|
@@ -507,6 +458,7 @@ you can deploy to staging and production with:
|
|
507
458
|
def create_binstubs
|
508
459
|
bundle_command "binstubs brakeman"
|
509
460
|
bundle_command "binstubs rubocop"
|
461
|
+
bundle_command "binstubs i18n-tasks"
|
510
462
|
end
|
511
463
|
|
512
464
|
def copy_miscellaneous_files
|
@@ -588,20 +540,12 @@ task default: "bundler:audit"
|
|
588
540
|
uncomment_lines("config/environments/#{environment}.rb", config)
|
589
541
|
end
|
590
542
|
|
591
|
-
def override_path_for_tests
|
592
|
-
if ENV['TESTING']
|
593
|
-
support_bin = File.expand_path(File.join('..', '..', 'spec', 'fakes', 'bin'))
|
594
|
-
"PATH=#{support_bin}:$PATH"
|
595
|
-
end
|
596
|
-
end
|
597
|
-
|
598
543
|
def run_heroku(command, environment)
|
599
|
-
|
600
|
-
run "#{path_addition} heroku #{command} --remote #{environment}"
|
544
|
+
run "heroku #{command} --remote #{environment}"
|
601
545
|
end
|
602
546
|
|
603
|
-
def
|
604
|
-
|
547
|
+
def heroku_adapter
|
548
|
+
@heroku_adapter ||= Adapters::Heroku.new(self)
|
605
549
|
end
|
606
550
|
|
607
551
|
def serve_static_files_line
|
@@ -39,8 +39,6 @@ module Suspenders
|
|
39
39
|
invoke :create_suspenders_views
|
40
40
|
invoke :configure_app
|
41
41
|
invoke :setup_stylesheets
|
42
|
-
invoke :install_bitters
|
43
|
-
invoke :install_refills
|
44
42
|
invoke :copy_miscellaneous_files
|
45
43
|
invoke :customize_error_pages
|
46
44
|
invoke :remove_config_comment_lines
|
@@ -61,7 +59,7 @@ module Suspenders
|
|
61
59
|
build :set_ruby_to_version_being_used
|
62
60
|
|
63
61
|
if options[:heroku]
|
64
|
-
build :
|
62
|
+
build :set_up_heroku_specific_gems
|
65
63
|
end
|
66
64
|
|
67
65
|
bundle_command 'install'
|
@@ -80,9 +78,11 @@ module Suspenders
|
|
80
78
|
|
81
79
|
def setup_development_environment
|
82
80
|
say 'Setting up the development environment'
|
81
|
+
build :raise_on_missing_assets_in_test
|
83
82
|
build :raise_on_delivery_errors
|
84
83
|
build :configure_letter_opener
|
85
|
-
build :
|
84
|
+
build :set_test_delivery_method
|
85
|
+
build :add_bullet_gem_configuration
|
86
86
|
build :raise_on_unpermitted_parameters
|
87
87
|
build :provide_setup_script
|
88
88
|
build :provide_dev_prime_task
|
@@ -105,7 +105,6 @@ module Suspenders
|
|
105
105
|
build :enable_database_cleaner
|
106
106
|
build :provide_shoulda_matchers_config
|
107
107
|
build :configure_spec_support_features
|
108
|
-
build :configure_ci
|
109
108
|
build :configure_i18n_for_test_environment
|
110
109
|
build :configure_i18n_tasks
|
111
110
|
build :configure_action_mailer_in_specs
|
@@ -145,15 +144,13 @@ module Suspenders
|
|
145
144
|
build :configure_action_mailer
|
146
145
|
build :configure_locales
|
147
146
|
build :configure_active_job
|
148
|
-
build :configure_rack_timeout
|
149
|
-
build :configure_time_formats
|
150
147
|
build :configure_slim
|
151
148
|
build :disable_xml_params
|
152
149
|
build :configure_available_locales
|
153
150
|
build :fix_i18n_deprecation_warning
|
154
151
|
build :setup_default_rake_task
|
155
152
|
build :configure_puma
|
156
|
-
build :
|
153
|
+
build :set_up_forego
|
157
154
|
end
|
158
155
|
|
159
156
|
def setup_stylesheets
|
@@ -161,16 +158,6 @@ module Suspenders
|
|
161
158
|
build :setup_stylesheets
|
162
159
|
end
|
163
160
|
|
164
|
-
def install_bitters
|
165
|
-
say 'Install Bitters'
|
166
|
-
build :install_bitters
|
167
|
-
end
|
168
|
-
|
169
|
-
def install_refills
|
170
|
-
say "Install Refills"
|
171
|
-
build :install_refills
|
172
|
-
end
|
173
|
-
|
174
161
|
def setup_git
|
175
162
|
if !options[:skip_git]
|
176
163
|
say 'Initializing git'
|
@@ -187,7 +174,6 @@ module Suspenders
|
|
187
174
|
build :set_heroku_remotes
|
188
175
|
build :set_heroku_rails_secrets
|
189
176
|
build :provide_deploy_script
|
190
|
-
build :configure_automatic_deployment
|
191
177
|
end
|
192
178
|
end
|
193
179
|
|
@@ -240,7 +226,7 @@ module Suspenders
|
|
240
226
|
|
241
227
|
def outro
|
242
228
|
say "Congratulations!"
|
243
|
-
say "
|
229
|
+
say "Now read the README.md"
|
244
230
|
end
|
245
231
|
|
246
232
|
protected
|
data/lib/suspenders/version.rb
CHANGED
@@ -0,0 +1,52 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module Suspenders
|
4
|
+
module Adapters
|
5
|
+
RSpec.describe Heroku do
|
6
|
+
it "sets the heroku remotes" do
|
7
|
+
setup_file = "bin/setup"
|
8
|
+
app_builder = double(app_name: app_name)
|
9
|
+
allow(app_builder).to receive(:append_file)
|
10
|
+
|
11
|
+
Heroku.new(app_builder).set_heroku_remotes
|
12
|
+
|
13
|
+
expect(app_builder).to have_received(:append_file).
|
14
|
+
with(setup_file, /heroku join --app #{app_name.dasherize}-production/)
|
15
|
+
expect(app_builder).to have_received(:append_file).
|
16
|
+
with(setup_file, /heroku join --app #{app_name.dasherize}-staging/)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "sets up the heroku specific gems" do
|
20
|
+
app_builder = double(app_name: app_name)
|
21
|
+
allow(app_builder).to receive(:inject_into_file)
|
22
|
+
|
23
|
+
Heroku.new(app_builder).set_up_heroku_specific_gems
|
24
|
+
|
25
|
+
expect(app_builder).to have_received(:inject_into_file).
|
26
|
+
with("Gemfile", /rails_stdout_logging/, anything)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "sets the heroku rails secrets" do
|
30
|
+
app_builder = double(app_name: app_name)
|
31
|
+
allow(app_builder).to receive(:run)
|
32
|
+
|
33
|
+
Heroku.new(app_builder).set_heroku_rails_secrets
|
34
|
+
|
35
|
+
expect(app_builder).to(
|
36
|
+
have_configured_var("staging", "SECRET_KEY_BASE"),
|
37
|
+
)
|
38
|
+
expect(app_builder).to(
|
39
|
+
have_configured_var("production", "SECRET_KEY_BASE"),
|
40
|
+
)
|
41
|
+
end
|
42
|
+
|
43
|
+
def app_name
|
44
|
+
SuspendersTestHelpers::APP_NAME
|
45
|
+
end
|
46
|
+
|
47
|
+
def have_configured_var(remote_name, var)
|
48
|
+
have_received(:run).with(/config:add #{var}=.+ --remote #{remote_name}/)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -1,56 +1,62 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
RSpec.describe "Heroku" do
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
context "--heroku" do
|
5
|
+
before(:all) do
|
6
|
+
clean_up
|
7
|
+
run_suspenders("--heroku=true")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "suspends a project for Heroku" do
|
11
|
+
app_name = SuspendersTestHelpers::APP_NAME.dasherize
|
12
|
+
|
13
|
+
expect(FakeHeroku).to(
|
14
|
+
have_gem_included(project_path, "rails_stdout_logging"),
|
15
|
+
)
|
16
|
+
expect(FakeHeroku).to have_created_app_for("staging", "--region eu")
|
17
|
+
expect(FakeHeroku).to have_created_app_for("production", "--region eu")
|
18
|
+
expect(FakeHeroku).to have_configured_vars("staging", "SECRET_KEY_BASE")
|
19
|
+
expect(FakeHeroku).to have_configured_vars(
|
20
|
+
"production",
|
21
|
+
"SECRET_KEY_BASE",
|
22
|
+
)
|
23
|
+
|
24
|
+
bin_setup_path = "#{project_path}/bin/setup"
|
25
|
+
bin_setup = IO.read(bin_setup_path)
|
26
|
+
|
27
|
+
expect(bin_setup).to include("heroku join --app #{app_name}-production")
|
28
|
+
expect(bin_setup).to include("heroku join --app #{app_name}-staging")
|
29
|
+
expect(bin_setup).to include("git config heroku.remote staging")
|
30
|
+
expect(File.stat(bin_setup_path)).to be_executable
|
31
|
+
|
32
|
+
bin_deploy_path = "#{project_path}/bin/deploy"
|
33
|
+
bin_deploy = IO.read(bin_deploy_path)
|
34
|
+
|
35
|
+
expect(bin_deploy).to include("heroku run rake db:migrate")
|
36
|
+
expect(File.stat(bin_deploy_path)).to be_executable
|
37
|
+
|
38
|
+
readme = IO.read("#{project_path}/README.md")
|
39
|
+
|
40
|
+
expect(readme).to include("./bin/deploy staging")
|
41
|
+
expect(readme).to include("./bin/deploy production")
|
42
|
+
end
|
7
43
|
end
|
8
44
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
expect(FakeHeroku).to have_created_app_for("production", "--region eu")
|
15
|
-
expect(FakeHeroku).to have_configured_vars("staging", "SECRET_KEY_BASE")
|
16
|
-
expect(FakeHeroku).to have_configured_vars("production", "SECRET_KEY_BASE")
|
17
|
-
|
18
|
-
bin_setup_path = "#{project_path}/bin/setup"
|
19
|
-
bin_setup = IO.read(bin_setup_path)
|
20
|
-
app_name = SuspendersTestHelpers::APP_NAME.dasherize
|
21
|
-
|
22
|
-
expect(bin_setup).to include("heroku join --app #{app_name}-production")
|
23
|
-
expect(bin_setup).to include("heroku join --app #{app_name}-staging")
|
24
|
-
expect(File.stat(bin_setup_path)).to be_executable
|
25
|
-
|
26
|
-
bin_deploy_path = "#{project_path}/bin/deploy"
|
27
|
-
bin_deploy = IO.read(bin_deploy_path)
|
28
|
-
|
29
|
-
expect(bin_deploy).to include("heroku run rake db:migrate")
|
30
|
-
expect(File.stat(bin_deploy_path)).to be_executable
|
45
|
+
context "--heroku with region flag" do
|
46
|
+
before(:all) do
|
47
|
+
clean_up
|
48
|
+
run_suspenders(%{--heroku=true --heroku-flags="--region eu"})
|
49
|
+
end
|
31
50
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
circle_yml_path = "#{project_path}/circle.yml"
|
38
|
-
circle_yml = IO.read(circle_yml_path)
|
39
|
-
|
40
|
-
expect(circle_yml).to include <<-YML.strip_heredoc
|
41
|
-
deployment:
|
42
|
-
staging:
|
43
|
-
branch: master
|
44
|
-
commands:
|
45
|
-
- git remote add staging git@heroku.com:#{app_name}-staging.git
|
46
|
-
- bin/deploy staging
|
47
|
-
YML
|
51
|
+
it "suspends a project with extra Heroku flags" do
|
52
|
+
expect(FakeHeroku).to have_created_app_for("staging", "--region eu")
|
53
|
+
expect(FakeHeroku).to have_created_app_for("production", "--region eu")
|
54
|
+
end
|
48
55
|
end
|
49
56
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
expect(FakeHeroku).to have_created_app_for("production", "--region eu")
|
57
|
+
def clean_up
|
58
|
+
drop_dummy_database
|
59
|
+
remove_project_directory
|
60
|
+
FakeHeroku.clear!
|
55
61
|
end
|
56
62
|
end
|
@@ -36,7 +36,9 @@ RSpec.describe "Suspend a new project with default configuration" do
|
|
36
36
|
end
|
37
37
|
|
38
38
|
it "copies dotfiles" do
|
39
|
-
|
39
|
+
%w[.ctags .env].each do |dotfile|
|
40
|
+
expect(File).to exist("#{project_path}/#{dotfile}")
|
41
|
+
end
|
40
42
|
end
|
41
43
|
|
42
44
|
it "loads secret_key_base from env" do
|
@@ -141,6 +143,12 @@ RSpec.describe "Suspend a new project with default configuration" do
|
|
141
143
|
expect(prod_env_file).not_to match(/"HOST"/)
|
142
144
|
end
|
143
145
|
|
146
|
+
it "configures language in html element" do
|
147
|
+
layout_path = "/app/views/layouts/application.html.slim"
|
148
|
+
layout_file = IO.read("#{project_path}#{layout_path}")
|
149
|
+
expect(layout_file).to match(/html lang="it"/)
|
150
|
+
end
|
151
|
+
|
144
152
|
it "configs active job queue adapter" do
|
145
153
|
application_config = IO.read("#{project_path}/config/application.rb")
|
146
154
|
test_config = IO.read("#{project_path}/config/environments/test.rb")
|
@@ -153,13 +161,28 @@ RSpec.describe "Suspend a new project with default configuration" do
|
|
153
161
|
)
|
154
162
|
end
|
155
163
|
|
164
|
+
it "configs bullet gem in development" do
|
165
|
+
test_config = IO.read("#{project_path}/config/environments/development.rb")
|
166
|
+
|
167
|
+
expect(test_config).to match /^ +Bullet.enable = true$/
|
168
|
+
expect(test_config).to match /^ +Bullet.bullet_logger = true$/
|
169
|
+
expect(test_config).to match /^ +Bullet.rails_logger = true$/
|
170
|
+
end
|
171
|
+
|
172
|
+
it "configs missing assets to raise in test" do
|
173
|
+
test_config = IO.read("#{project_path}/config/environments/test.rb")
|
174
|
+
|
175
|
+
expect(test_config).to match(
|
176
|
+
/^ +config.assets.raise_runtime_errors = true$/,
|
177
|
+
)
|
178
|
+
end
|
179
|
+
|
156
180
|
it "adds spring to binstubs" do
|
157
181
|
expect(File).to exist("#{project_path}/bin/spring")
|
158
182
|
|
159
|
-
spring_line = /^ +load File.expand_path\("\.\.\/spring", __FILE__\)$/
|
160
183
|
bin_stubs = %w(rake rails rspec)
|
161
184
|
bin_stubs.each do |bin_stub|
|
162
|
-
expect(IO.read("#{project_path}/bin/#{bin_stub}")).to match(
|
185
|
+
expect(IO.read("#{project_path}/bin/#{bin_stub}")).to match(/spring/)
|
163
186
|
end
|
164
187
|
end
|
165
188
|
|
data/spec/spec_helper.rb
CHANGED
data/spec/support/fake_heroku.rb
CHANGED
@@ -36,8 +36,10 @@ class FakeHeroku
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def self.has_configured_vars?(remote_name, var)
|
39
|
-
|
40
|
-
|
41
|
-
|
39
|
+
commands_ran =~ /^config:add #{var}=.+ --remote #{remote_name}\n/
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.commands_ran
|
43
|
+
@commands_ran ||= File.read(RECORDER)
|
42
44
|
end
|
43
45
|
end
|
data/spec/support/suspenders.rb
CHANGED
@@ -12,9 +12,10 @@ module SuspendersTestHelpers
|
|
12
12
|
def run_suspenders(arguments = nil)
|
13
13
|
Dir.chdir(tmp_path) do
|
14
14
|
Bundler.with_clean_env do
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
add_fakes_to_path
|
16
|
+
`
|
17
|
+
#{suspenders_bin} #{APP_NAME} #{arguments}
|
18
|
+
`
|
18
19
|
end
|
19
20
|
end
|
20
21
|
end
|
@@ -29,6 +30,10 @@ module SuspendersTestHelpers
|
|
29
30
|
end
|
30
31
|
end
|
31
32
|
|
33
|
+
def add_fakes_to_path
|
34
|
+
ENV["PATH"] = "#{support_bin}:#{ENV['PATH']}"
|
35
|
+
end
|
36
|
+
|
32
37
|
def project_path
|
33
38
|
@project_path ||= Pathname.new("#{tmp_path}/#{APP_NAME}")
|
34
39
|
end
|
@@ -43,6 +48,10 @@ module SuspendersTestHelpers
|
|
43
48
|
File.join(root_path, 'bin', 'welaika-suspenders')
|
44
49
|
end
|
45
50
|
|
51
|
+
def support_bin
|
52
|
+
File.join(root_path, "spec", "fakes", "bin")
|
53
|
+
end
|
54
|
+
|
46
55
|
def root_path
|
47
56
|
File.expand_path('../../../', __FILE__)
|
48
57
|
end
|
data/suspenders.gemspec
CHANGED
@@ -25,11 +25,9 @@ weLaika's fork of the famous thoughbot suspenders gem.
|
|
25
25
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
26
26
|
s.version = Suspenders::VERSION
|
27
27
|
|
28
|
-
s.add_dependency '
|
29
|
-
s.add_dependency 'bundler', '~> 1.3'
|
28
|
+
s.add_dependency 'bundler', '>= 1.8.4'
|
30
29
|
s.add_dependency 'rails', Suspenders::RAILS_VERSION
|
31
|
-
s.add_dependency 'nokogiri', '1.6.0' # temp fix for iconv.h problem
|
32
30
|
|
33
|
-
s.add_development_dependency 'rspec', '~> 3.
|
31
|
+
s.add_development_dependency 'rspec', '~> 3.4'
|
34
32
|
s.add_development_dependency 'pry-byebug'
|
35
33
|
end
|
data/templates/Gemfile.erb
CHANGED
data/templates/README.md.erb
CHANGED
@@ -7,26 +7,10 @@ with the necessary dependencies to run and test this app:
|
|
7
7
|
|
8
8
|
% ./bin/setup
|
9
9
|
|
10
|
-
It assumes you have a machine equipped with Ruby, Postgres, etc.
|
11
|
-
your machine with [this script].
|
10
|
+
It assumes you have a machine equipped with Ruby, Postgres, etc.
|
12
11
|
|
13
|
-
[
|
12
|
+
After setting up, you can run the application using [Heroku Local]:
|
14
13
|
|
15
|
-
|
14
|
+
% heroku local
|
16
15
|
|
17
|
-
|
18
|
-
|
19
|
-
If you don't have `foreman`, see [Foreman's install instructions][foreman]. It
|
20
|
-
is [purposefully excluded from the project's `Gemfile`][exclude].
|
21
|
-
|
22
|
-
[foreman]: https://github.com/ddollar/foreman
|
23
|
-
[exclude]: https://github.com/ddollar/foreman/pull/437#issuecomment-41110407
|
24
|
-
|
25
|
-
## Guidelines
|
26
|
-
|
27
|
-
Use the following guides for getting things done, programming well, and
|
28
|
-
programming in style.
|
29
|
-
|
30
|
-
* [Protocol](http://github.com/thoughtbot/guides/blob/master/protocol)
|
31
|
-
* [Best Practices](http://github.com/thoughtbot/guides/blob/master/best-practices)
|
32
|
-
* [Style](http://github.com/thoughtbot/guides/blob/master/style)
|
16
|
+
[Heroku Local]: https://devcenter.heroku.com/articles/heroku-local
|
data/templates/bin_setup.erb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
#!/usr/bin/env sh
|
2
2
|
|
3
3
|
# Set up Rails app. Run this script immediately after cloning the codebase.
|
4
|
-
# https://github.com/thoughtbot/guides/tree/master/protocol
|
5
4
|
|
6
5
|
# Exit if any subcommand fails
|
7
6
|
set -e
|
@@ -10,26 +9,12 @@ set -e
|
|
10
9
|
gem install bundler --conservative
|
11
10
|
bundle check || bundle install
|
12
11
|
|
13
|
-
# Set up configurable environment variables
|
14
|
-
if [ ! -f .env ]; then
|
15
|
-
cp .sample.env .env
|
16
|
-
fi
|
17
|
-
|
18
12
|
# Set up database and add any development seed data
|
19
13
|
bin/rake dev:prime
|
20
14
|
|
21
15
|
# Add binstubs to PATH via export PATH=".git/safe/../../bin:$PATH" in ~/.zshenv
|
22
16
|
mkdir -p .git/safe
|
23
17
|
|
24
|
-
# Pick a port for Foreman
|
25
|
-
if ! grep --quiet --no-messages --fixed-strings 'port' .foreman; then
|
26
|
-
printf 'port: 3000\n' >> .foreman
|
27
|
-
fi
|
28
|
-
|
29
|
-
if ! command -v foreman > /dev/null; then
|
30
|
-
gem install foreman
|
31
|
-
fi
|
32
|
-
|
33
18
|
# Only if this isn't CI
|
34
19
|
# if [ -z "$CI" ]; then
|
35
20
|
# fi
|
@@ -1,6 +1,7 @@
|
|
1
|
-
#
|
1
|
+
# https://github.com/ddollar/forego
|
2
2
|
ASSET_HOST=localhost:3000
|
3
3
|
APPLICATION_HOST=localhost:3000
|
4
|
+
PORT=3000
|
4
5
|
RACK_ENV=development
|
5
6
|
SECRET_KEY_BASE=development_secret
|
6
7
|
EXECJS_RUNTIME=Node
|
@@ -8,3 +9,4 @@ SMTP_ADDRESS=smtp.example.com
|
|
8
9
|
SMTP_DOMAIN=example.com
|
9
10
|
SMTP_PASSWORD=password
|
10
11
|
SMTP_USERNAME=username
|
12
|
+
WEB_CONCURRENCY=1
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: welaika-suspenders
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.21.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- thoughtbot
|
@@ -9,36 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-12-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
-
- !ruby/object:Gem::Dependency
|
15
|
-
name: bitters
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
requirements:
|
18
|
-
- - "~>"
|
19
|
-
- !ruby/object:Gem::Version
|
20
|
-
version: 1.1.0
|
21
|
-
type: :runtime
|
22
|
-
prerelease: false
|
23
|
-
version_requirements: !ruby/object:Gem::Requirement
|
24
|
-
requirements:
|
25
|
-
- - "~>"
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
version: 1.1.0
|
28
14
|
- !ruby/object:Gem::Dependency
|
29
15
|
name: bundler
|
30
16
|
requirement: !ruby/object:Gem::Requirement
|
31
17
|
requirements:
|
32
|
-
- - "
|
18
|
+
- - ">="
|
33
19
|
- !ruby/object:Gem::Version
|
34
|
-
version:
|
20
|
+
version: 1.8.4
|
35
21
|
type: :runtime
|
36
22
|
prerelease: false
|
37
23
|
version_requirements: !ruby/object:Gem::Requirement
|
38
24
|
requirements:
|
39
|
-
- - "
|
25
|
+
- - ">="
|
40
26
|
- !ruby/object:Gem::Version
|
41
|
-
version:
|
27
|
+
version: 1.8.4
|
42
28
|
- !ruby/object:Gem::Dependency
|
43
29
|
name: rails
|
44
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,34 +39,20 @@ dependencies:
|
|
53
39
|
- - "~>"
|
54
40
|
- !ruby/object:Gem::Version
|
55
41
|
version: 4.2.0
|
56
|
-
- !ruby/object:Gem::Dependency
|
57
|
-
name: nokogiri
|
58
|
-
requirement: !ruby/object:Gem::Requirement
|
59
|
-
requirements:
|
60
|
-
- - '='
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
version: 1.6.0
|
63
|
-
type: :runtime
|
64
|
-
prerelease: false
|
65
|
-
version_requirements: !ruby/object:Gem::Requirement
|
66
|
-
requirements:
|
67
|
-
- - '='
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: 1.6.0
|
70
42
|
- !ruby/object:Gem::Dependency
|
71
43
|
name: rspec
|
72
44
|
requirement: !ruby/object:Gem::Requirement
|
73
45
|
requirements:
|
74
46
|
- - "~>"
|
75
47
|
- !ruby/object:Gem::Version
|
76
|
-
version: '3.
|
48
|
+
version: '3.4'
|
77
49
|
type: :development
|
78
50
|
prerelease: false
|
79
51
|
version_requirements: !ruby/object:Gem::Requirement
|
80
52
|
requirements:
|
81
53
|
- - "~>"
|
82
54
|
- !ruby/object:Gem::Version
|
83
|
-
version: '3.
|
55
|
+
version: '3.4'
|
84
56
|
- !ruby/object:Gem::Dependency
|
85
57
|
name: pry-byebug
|
86
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,6 +86,7 @@ files:
|
|
114
86
|
- LICENSE
|
115
87
|
- NEWS.md
|
116
88
|
- README.md
|
89
|
+
- RELEASING.md
|
117
90
|
- Rakefile
|
118
91
|
- bin/rake
|
119
92
|
- bin/rspec
|
@@ -121,9 +94,11 @@ files:
|
|
121
94
|
- bin/welaika-suspenders
|
122
95
|
- lib/suspenders.rb
|
123
96
|
- lib/suspenders/actions.rb
|
97
|
+
- lib/suspenders/adapters/heroku.rb
|
124
98
|
- lib/suspenders/app_builder.rb
|
125
99
|
- lib/suspenders/generators/app_generator.rb
|
126
100
|
- lib/suspenders/version.rb
|
101
|
+
- spec/adapters/heroku_spec.rb
|
127
102
|
- spec/fakes/bin/heroku
|
128
103
|
- spec/fakes/bin/hub
|
129
104
|
- spec/features/github_spec.rb
|
@@ -140,7 +115,7 @@ files:
|
|
140
115
|
- templates/_flashes.html.slim
|
141
116
|
- templates/_javascript.html.slim
|
142
117
|
- templates/action_mailer.rb
|
143
|
-
- templates/application.
|
118
|
+
- templates/application.sass
|
144
119
|
- templates/bin_deploy
|
145
120
|
- templates/bin_setup.erb
|
146
121
|
- templates/brakeman.rake
|
@@ -154,6 +129,7 @@ files:
|
|
154
129
|
- templates/dev.rake
|
155
130
|
- templates/disable_xml_params.rb
|
156
131
|
- templates/dotfiles/.ctags
|
132
|
+
- templates/dotfiles/.env
|
157
133
|
- templates/errors.rb
|
158
134
|
- templates/factories.rb
|
159
135
|
- templates/factory_girl_rspec.rb
|
@@ -168,7 +144,6 @@ files:
|
|
168
144
|
- templates/rails_helper.rb
|
169
145
|
- templates/rubocop.rake
|
170
146
|
- templates/rubocop.yml
|
171
|
-
- templates/sample.env
|
172
147
|
- templates/secrets.yml
|
173
148
|
- templates/shoulda_matchers_config_rspec.rb
|
174
149
|
- templates/slim.rb
|
@@ -198,11 +173,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
198
173
|
version: '0'
|
199
174
|
requirements: []
|
200
175
|
rubyforge_project:
|
201
|
-
rubygems_version: 2.
|
176
|
+
rubygems_version: 2.5.0
|
202
177
|
signing_key:
|
203
178
|
specification_version: 4
|
204
179
|
summary: Generate a Rails app using thoughtbot's best practices.
|
205
180
|
test_files:
|
181
|
+
- spec/adapters/heroku_spec.rb
|
206
182
|
- spec/fakes/bin/heroku
|
207
183
|
- spec/fakes/bin/hub
|
208
184
|
- spec/features/github_spec.rb
|