bowties 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +4 -0
  3. data/.rspec +1 -0
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/CONTRIBUTING.md +43 -0
  7. data/Gemfile +3 -0
  8. data/Gemfile.lock +129 -0
  9. data/LICENSE +21 -0
  10. data/NEWS.md +405 -0
  11. data/README.md +219 -0
  12. data/Rakefile +8 -0
  13. data/bin/bowties +18 -0
  14. data/bin/rake +16 -0
  15. data/bin/rspec +16 -0
  16. data/bin/setup +13 -0
  17. data/bowties.gemspec +34 -0
  18. data/circle.yml +6 -0
  19. data/lib/bowties.rb +4 -0
  20. data/lib/bowties/actions.rb +33 -0
  21. data/lib/bowties/app_builder.rb +499 -0
  22. data/lib/bowties/generators/app_generator.rb +238 -0
  23. data/lib/bowties/version.rb +5 -0
  24. data/spec/fakes/bin/heroku +5 -0
  25. data/spec/fakes/bin/hub +5 -0
  26. data/spec/features/github_spec.rb +15 -0
  27. data/spec/features/heroku_spec.rb +46 -0
  28. data/spec/features/new_project_spec.rb +135 -0
  29. data/spec/spec_helper.rb +20 -0
  30. data/spec/support/bowties.rb +48 -0
  31. data/spec/support/fake_github.rb +21 -0
  32. data/spec/support/fake_heroku.rb +43 -0
  33. data/templates/Gemfile.erb +58 -0
  34. data/templates/Procfile +2 -0
  35. data/templates/README.md.erb +32 -0
  36. data/templates/_analytics.html.erb +7 -0
  37. data/templates/_flashes.html.erb +7 -0
  38. data/templates/_javascript.html.erb +12 -0
  39. data/templates/action_mailer.rb +5 -0
  40. data/templates/application.scss +8 -0
  41. data/templates/bin_deploy +12 -0
  42. data/templates/bin_setup.erb +36 -0
  43. data/templates/browserslist +4 -0
  44. data/templates/bundler_audit.rake +12 -0
  45. data/templates/circle.yml.erb +8 -0
  46. data/templates/config_i18n_tasks.yml +13 -0
  47. data/templates/config_locales_en.yml.erb +19 -0
  48. data/templates/database_cleaner_rspec.rb +21 -0
  49. data/templates/development_seeds.rb +12 -0
  50. data/templates/disable_xml_params.rb +3 -0
  51. data/templates/errors.rb +34 -0
  52. data/templates/factory_girl_rspec.rb +3 -0
  53. data/templates/flashes_helper.rb +5 -0
  54. data/templates/hound.yml +17 -0
  55. data/templates/i18n.rb +3 -0
  56. data/templates/json_encoding.rb +1 -0
  57. data/templates/newrelic.yml.erb +34 -0
  58. data/templates/postgresql_database.yml.erb +12 -0
  59. data/templates/rails_helper.rb +23 -0
  60. data/templates/sample.env +6 -0
  61. data/templates/secrets.yml +14 -0
  62. data/templates/smtp.rb +9 -0
  63. data/templates/spec_helper.rb +23 -0
  64. data/templates/staging.rb +5 -0
  65. data/templates/suspenders_gitignore +14 -0
  66. data/templates/suspenders_layout.html.erb.erb +21 -0
  67. data/templates/unicorn.rb +30 -0
  68. metadata +181 -0
@@ -0,0 +1,20 @@
1
+ require 'bundler/setup'
2
+
3
+ Bundler.require(:default, :test)
4
+
5
+ require (Pathname.new(__FILE__).dirname + '../lib/bowties').expand_path
6
+
7
+ Dir['./spec/support/**/*.rb'].each { |file| require file }
8
+
9
+ RSpec.configure do |config|
10
+ config.include BowtiesTestHelpers
11
+
12
+ config.before(:all) do
13
+ create_tmp_directory
14
+ end
15
+
16
+ config.before(:each) do
17
+ FakeHeroku.clear!
18
+ FakeGithub.clear!
19
+ end
20
+ end
@@ -0,0 +1,48 @@
1
+ module BowtiesTestHelpers
2
+ APP_NAME = "dummy_app"
3
+
4
+ def remove_project_directory
5
+ FileUtils.rm_rf(project_path)
6
+ end
7
+
8
+ def create_tmp_directory
9
+ FileUtils.mkdir_p(tmp_path)
10
+ end
11
+
12
+ def run_bowties(arguments = nil)
13
+ Dir.chdir(tmp_path) do
14
+ Bundler.with_clean_env do
15
+ ENV['TESTING'] = '1'
16
+ %x(#{bowties_bin} #{APP_NAME} #{arguments})
17
+ end
18
+ end
19
+ end
20
+
21
+ def drop_dummy_database
22
+ if File.exist?(project_path)
23
+ Dir.chdir(project_path) do
24
+ Bundler.with_clean_env do
25
+ `rake db:drop`
26
+ end
27
+ end
28
+ end
29
+ end
30
+
31
+ def project_path
32
+ @project_path ||= Pathname.new("#{tmp_path}/#{APP_NAME}")
33
+ end
34
+
35
+ private
36
+
37
+ def tmp_path
38
+ @tmp_path ||= Pathname.new("#{root_path}/tmp")
39
+ end
40
+
41
+ def bowties_bin
42
+ File.join(root_path, 'bin', 'bowties')
43
+ end
44
+
45
+ def root_path
46
+ File.expand_path('../../../', __FILE__)
47
+ end
48
+ end
@@ -0,0 +1,21 @@
1
+ class FakeGithub
2
+ RECORDER = File.expand_path(File.join('..', '..', 'tmp', 'hub_commands'), File.dirname(__FILE__))
3
+
4
+ def initialize(args)
5
+ @args = args
6
+ end
7
+
8
+ def run!
9
+ File.open(RECORDER, 'a') do |file|
10
+ file.write @args.join(' ')
11
+ end
12
+ end
13
+
14
+ def self.clear!
15
+ FileUtils.rm_rf RECORDER
16
+ end
17
+
18
+ def self.has_created_repo?(repo_name)
19
+ File.read(RECORDER) == "create #{repo_name}"
20
+ end
21
+ end
@@ -0,0 +1,43 @@
1
+ class FakeHeroku
2
+ RECORDER = File.expand_path(File.join('..', '..', 'tmp', 'heroku_commands'), File.dirname(__FILE__))
3
+
4
+ def initialize(args)
5
+ @args = args
6
+ end
7
+
8
+ def run!
9
+ File.open(RECORDER, 'a') do |file|
10
+ file.puts @args.join(' ')
11
+ end
12
+ end
13
+
14
+ def self.clear!
15
+ FileUtils.rm_rf RECORDER
16
+ end
17
+
18
+ def self.has_gem_included?(project_path, gem_name)
19
+ gemfile = File.open(File.join(project_path, 'Gemfile'), 'a')
20
+
21
+ File.foreach(gemfile).any? do |line|
22
+ line.match(/#{Regexp.quote(gem_name)}/)
23
+ end
24
+ end
25
+
26
+ def self.has_created_app_for?(environment, flags = nil)
27
+ app_name = "#{BowtiesTestHelpers::APP_NAME.dasherize}-#{environment}"
28
+
29
+ command = if flags
30
+ "create #{app_name} #{flags} --remote #{environment}\n"
31
+ else
32
+ "create #{app_name} --remote #{environment}\n"
33
+ end
34
+
35
+ File.foreach(RECORDER).any? { |line| line == command }
36
+ end
37
+
38
+ def self.has_configured_vars?(remote_name, var)
39
+ File.foreach(RECORDER).any? do |line|
40
+ line =~ /^config:add #{var}=.+ --remote #{remote_name}\n$/
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,58 @@
1
+ source "https://rubygems.org"
2
+
3
+ ruby "<%= Bowties::RUBY_VERSION %>"
4
+
5
+ gem "airbrake"
6
+ gem "autoprefixer-rails"
7
+ gem "bourbon", "~> 4.2.0"
8
+ gem "coffee-rails", "~> 4.1.0"
9
+ gem "delayed_job_active_record"
10
+ gem "email_validator"
11
+ gem "flutie"
12
+ gem "high_voltage"
13
+ gem "i18n-tasks"
14
+ gem "jquery-rails"
15
+ gem "neat", "~> 1.7.0"
16
+ gem "newrelic_rpm", ">= 3.9.8"
17
+ gem "normalize-rails", "~> 3.0.0"
18
+ gem "pg"
19
+ gem "rack-canonical-host"
20
+ gem "rails", "<%= Bowties::RAILS_VERSION %>"
21
+ gem "recipient_interceptor"
22
+ gem "refills"
23
+ gem "sass-rails", "~> 5.0"
24
+ gem "simple_form"
25
+ gem "title"
26
+ gem "uglifier"
27
+ gem "unicorn"
28
+
29
+ group :development do
30
+ gem "spring"
31
+ gem "spring-commands-rspec"
32
+ gem "web-console"
33
+ end
34
+
35
+ group :development, :test do
36
+ gem "awesome_print"
37
+ gem "bundler-audit", require: false
38
+ gem "byebug"
39
+ gem "dotenv-rails"
40
+ gem "factory_girl_rails"
41
+ gem "pry-rails"
42
+ gem "rspec-rails", "~> 3.3.0"
43
+ end
44
+
45
+ group :test do
46
+ gem "capybara-webkit", ">= 1.2.0"
47
+ gem "database_cleaner"
48
+ gem "formulaic"
49
+ gem "launchy"
50
+ gem "shoulda-matchers", require: false
51
+ gem "simplecov", require: false
52
+ gem "timecop"
53
+ gem "webmock"
54
+ end
55
+
56
+ group :staging, :production do
57
+ gem "rack-timeout"
58
+ end
@@ -0,0 +1,2 @@
1
+ web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
2
+ worker: bundle exec rake jobs:work
@@ -0,0 +1,32 @@
1
+ # <%= app_name.humanize %>
2
+
3
+ ## Getting Started
4
+
5
+ After you have cloned this repo, run this setup script to set up your machine
6
+ with the necessary dependencies to run and test this app:
7
+
8
+ % ./bin/setup
9
+
10
+ It assumes you have a machine equipped with Ruby, Postgres, etc. If not, set up
11
+ your machine with [this script].
12
+
13
+ [this script]: https://github.com/thoughtbot/laptop
14
+
15
+ After setting up, you can run the application using [foreman]:
16
+
17
+ % foreman start
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)
@@ -0,0 +1,7 @@
1
+ <% if ENV["SEGMENT_KEY"] %>
2
+ <script type="text/javascript">
3
+ window.analytics=window.analytics||[],window.analytics.methods=["identify","group","track","page","pageview","alias","ready","on","once","off","trackLink","trackForm","trackClick","trackSubmit"],window.analytics.factory=function(t){return function(){var a=Array.prototype.slice.call(arguments);return a.unshift(t),window.analytics.push(a),window.analytics}};for(var i=0;i<window.analytics.methods.length;i++){var key=window.analytics.methods[i];window.analytics[key]=window.analytics.factory(key)}window.analytics.load=function(t){if(!document.getElementById("analytics-js")){var a=document.createElement("script");a.type="text/javascript",a.id="analytics-js",a.async=!0,a.src=("https:"===document.location.protocol?"https://":"http://")+"cdn.segment.com/analytics.js/v1/"+t+"/analytics.min.js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(a,n)}},window.analytics.SNIPPET_VERSION="2.0.9",
4
+ window.analytics.load("<%= ENV["SEGMENT_KEY"] %>");
5
+ window.analytics.page();
6
+ </script>
7
+ <% end %>
@@ -0,0 +1,7 @@
1
+ <% if flash.any? %>
2
+ <div class="flashes">
3
+ <% user_facing_flashes.each do |key, value| -%>
4
+ <div class="flash-<%= key %>"><%= value %></div>
5
+ <% end -%>
6
+ </div>
7
+ <% end %>
@@ -0,0 +1,12 @@
1
+ <%= javascript_include_tag :application %>
2
+
3
+ <%= yield :javascript %>
4
+
5
+ <%= render "analytics" %>
6
+
7
+ <% if Rails.env.test? %>
8
+ <%= javascript_tag do %>
9
+ $.fx.off = true;
10
+ $.ajaxSetup({ async: false });
11
+ <% end %>
12
+ <% end %>
@@ -0,0 +1,5 @@
1
+ RSpec.configure do |config|
2
+ config.before(:each) do
3
+ ActionMailer::Base.deliveries.clear
4
+ end
5
+ end
@@ -0,0 +1,8 @@
1
+ @charset "utf-8";
2
+
3
+ @import "normalize-rails";
4
+ @import "bourbon";
5
+ @import "base/grid-settings";
6
+ @import "neat";
7
+ @import "base/base";
8
+ @import "refills/flashes";
@@ -0,0 +1,12 @@
1
+ #!/bin/sh
2
+
3
+ # Run this script to deploy the app to Heroku.
4
+
5
+ set -e
6
+
7
+ branch="$(git symbolic-ref HEAD --short)"
8
+ target="${1:-staging}"
9
+
10
+ git push "$target" "$branch:master"
11
+ heroku run rake db:migrate --remote "$target"
12
+ heroku restart --remote "$target"
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env sh
2
+
3
+ # Set up Rails app. Run this script immediately after cloning the codebase.
4
+ # https://github.com/thoughtbot/guides/tree/master/protocol
5
+
6
+ # Exit if any subcommand fails
7
+ set -e
8
+
9
+ # Set up Ruby dependencies via Bundler
10
+ gem install bundler --conservative
11
+ bundle check || bundle install
12
+
13
+ # Set up configurable environment variables
14
+ if [ ! -f .env ]; then
15
+ cp .sample.env .env
16
+ fi
17
+
18
+ # Set up database and add any development seed data
19
+ bundle exec rake db:setup dev:prime
20
+
21
+ # Add binstubs to PATH via export PATH=".git/safe/../../bin:$PATH" in ~/.zshenv
22
+ mkdir -p .git/safe
23
+
24
+ # Pick a port for Foreman
25
+ if ! grep --quiet --no-messages --fixed-strings 'port' .foreman; then
26
+ printf 'port: <%= config[:port_number] %>\n' >> .foreman
27
+ fi
28
+
29
+ if ! command -v foreman > /dev/null; then
30
+ printf 'Foreman is not installed.\n'
31
+ printf 'See https://github.com/ddollar/foreman for install instructions.\n'
32
+ fi
33
+
34
+ # Only if this isn't CI
35
+ # if [ -z "$CI" ]; then
36
+ # fi
@@ -0,0 +1,4 @@
1
+ Last 2 versions
2
+ Explorer >= 9
3
+ iOS >= 7.1
4
+ Android >= 4.4
@@ -0,0 +1,12 @@
1
+ if Rails.env.development? || Rails.env.test?
2
+ require "bundler/audit/cli"
3
+
4
+ namespace :bundler do
5
+ desc "Updates the ruby-advisory-db and runs audit"
6
+ task :audit do
7
+ %w(update check).each do |command|
8
+ Bundler::Audit::CLI.start [command]
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,8 @@
1
+ test:
2
+ override:
3
+ - bundle exec rake
4
+ deployment:
5
+ staging:
6
+ branch: master
7
+ commands:
8
+ - bin/deploy staging
@@ -0,0 +1,13 @@
1
+ search:
2
+ paths:
3
+ - "app/controllers"
4
+ - "app/helpers"
5
+ - "app/presenters"
6
+ - "app/views"
7
+
8
+ ignore_unused:
9
+ - activerecord.*
10
+ - date.*
11
+ - simple_form.*
12
+ - time.*
13
+ - titles.*
@@ -0,0 +1,19 @@
1
+ en:
2
+ date:
3
+ formats:
4
+ default:
5
+ "%m/%d/%Y"
6
+ with_weekday:
7
+ "%a %m/%d/%y"
8
+
9
+ time:
10
+ formats:
11
+ default:
12
+ "%a, %b %-d, %Y at %r"
13
+ date:
14
+ "%b %-d, %Y"
15
+ short:
16
+ "%B %d"
17
+
18
+ titles:
19
+ application: <%= app_name.humanize %>
@@ -0,0 +1,21 @@
1
+ RSpec.configure do |config|
2
+ config.before(:suite) do
3
+ DatabaseCleaner.clean_with(:deletion)
4
+ end
5
+
6
+ config.before(:each) do
7
+ DatabaseCleaner.strategy = :transaction
8
+ end
9
+
10
+ config.before(:each, js: true) do
11
+ DatabaseCleaner.strategy = :deletion
12
+ end
13
+
14
+ config.before(:each) do
15
+ DatabaseCleaner.start
16
+ end
17
+
18
+ config.after(:each) do
19
+ DatabaseCleaner.clean
20
+ end
21
+ end
@@ -0,0 +1,12 @@
1
+ if Rails.env.development? || Rails.env.test?
2
+ require "factory_girl"
3
+
4
+ namespace :dev do
5
+ desc "Seed data for development environment"
6
+ task prime: "db:setup" do
7
+ include FactoryGirl::Syntax::Methods
8
+
9
+ # create(:user, email: "user@example.com", password: "password")
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,3 @@
1
+ # Protect against injection attacks
2
+ # http://www.kb.cert.org/vuls/id/380039
3
+ ActionDispatch::ParamsParser::DEFAULT_PARSERS.delete(Mime::XML)
@@ -0,0 +1,34 @@
1
+ require "net/http"
2
+ require "net/smtp"
3
+
4
+ # Example:
5
+ # begin
6
+ # some http call
7
+ # rescue *HTTP_ERRORS => error
8
+ # notify_hoptoad error
9
+ # end
10
+
11
+ HTTP_ERRORS = [
12
+ EOFError,
13
+ Errno::ECONNRESET,
14
+ Errno::EINVAL,
15
+ Net::HTTPBadResponse,
16
+ Net::HTTPHeaderSyntaxError,
17
+ Net::ProtocolError,
18
+ Timeout::Error
19
+ ]
20
+
21
+ SMTP_SERVER_ERRORS = [
22
+ IOError,
23
+ Net::SMTPAuthenticationError,
24
+ Net::SMTPServerBusy,
25
+ Net::SMTPUnknownError,
26
+ TimeoutError
27
+ ]
28
+
29
+ SMTP_CLIENT_ERRORS = [
30
+ Net::SMTPFatalError,
31
+ Net::SMTPSyntaxError
32
+ ]
33
+
34
+ SMTP_ERRORS = SMTP_SERVER_ERRORS + SMTP_CLIENT_ERRORS