underwear 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +4 -0
- data/.ruby-version +1 -0
- data/.travis.yml +11 -0
- data/CONTRIBUTING.md +38 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +123 -0
- data/LICENSE +21 -0
- data/NEWS.md +0 -0
- data/README.md +194 -0
- data/Rakefile +8 -0
- data/bin/rake +16 -0
- data/bin/rspec +16 -0
- data/bin/setup +13 -0
- data/bin/underwear +13 -0
- data/lib/underwear.rb +4 -0
- data/lib/underwear/actions.rb +33 -0
- data/lib/underwear/app_builder.rb +511 -0
- data/lib/underwear/generators/app_generator.rb +239 -0
- data/lib/underwear/version.rb +5 -0
- data/spec/fakes/bin/heroku +5 -0
- data/spec/fakes/bin/hub +5 -0
- data/spec/features/github_spec.rb +15 -0
- data/spec/features/heroku_spec.rb +46 -0
- data/spec/features/new_project_spec.rb +113 -0
- data/spec/spec_helper.rb +20 -0
- data/spec/support/fake_github.rb +21 -0
- data/spec/support/fake_heroku.rb +43 -0
- data/spec/support/underwear.rb +49 -0
- data/templates/Gemfile.erb +65 -0
- data/templates/Procfile +3 -0
- data/templates/README.md.erb +32 -0
- data/templates/_analytics.html.erb +7 -0
- data/templates/_flashes.html.erb +7 -0
- data/templates/_javascript.html.erb +12 -0
- data/templates/action_mailer.rb +5 -0
- data/templates/application.scss +1 -0
- data/templates/bin_deploy +12 -0
- data/templates/bin_setup.erb +36 -0
- data/templates/browserslist +4 -0
- data/templates/bundler_audit.rake +12 -0
- data/templates/circle.yml.erb +8 -0
- data/templates/config_i18n_tasks.yml +11 -0
- data/templates/config_locales_en.yml.erb +16 -0
- data/templates/database_cleaner_rspec.rb +21 -0
- data/templates/dev.rake +12 -0
- data/templates/disable_xml_params.rb +3 -0
- data/templates/errors.rb +34 -0
- data/templates/factory_girl_rspec.rb +3 -0
- data/templates/flashes_helper.rb +5 -0
- data/templates/i18n.rb +3 -0
- data/templates/json_encoding.rb +1 -0
- data/templates/newrelic.yml.erb +34 -0
- data/templates/postgresql_database.yml.erb +22 -0
- data/templates/puma.rb +19 -0
- data/templates/rails_helper.rb +17 -0
- data/templates/sample.env +6 -0
- data/templates/secrets.yml +14 -0
- data/templates/sidekiq.rb +1 -0
- data/templates/smtp.rb +9 -0
- data/templates/spec_helper.rb +23 -0
- data/templates/staging.rb +5 -0
- data/templates/test.rb +48 -0
- data/templates/underwear_gitignore +14 -0
- data/templates/underwear_layout.html.erb.erb +21 -0
- data/underwear.gemspec +33 -0
- metadata +166 -0
@@ -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 = "#{UnderwearTestHelpers::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,49 @@
|
|
1
|
+
module UnderwearTestHelpers
|
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_underwear(arguments = nil)
|
13
|
+
Dir.chdir(tmp_path) do
|
14
|
+
Bundler.with_clean_env do
|
15
|
+
ENV['TESTING'] = '1'
|
16
|
+
|
17
|
+
%x(#{underwear_bin} #{APP_NAME} #{arguments})
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def drop_dummy_database
|
23
|
+
if File.exist?(project_path)
|
24
|
+
Dir.chdir(project_path) do
|
25
|
+
Bundler.with_clean_env do
|
26
|
+
`rake db:drop`
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def project_path
|
33
|
+
@project_path ||= Pathname.new("#{tmp_path}/#{APP_NAME}")
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def tmp_path
|
39
|
+
@tmp_path ||= Pathname.new("#{root_path}/tmp")
|
40
|
+
end
|
41
|
+
|
42
|
+
def underwear_bin
|
43
|
+
File.join(root_path, 'bin', 'underwear')
|
44
|
+
end
|
45
|
+
|
46
|
+
def root_path
|
47
|
+
File.expand_path('../../../', __FILE__)
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
ruby "<%= Underwear::RUBY_VERSION %>"
|
4
|
+
|
5
|
+
gem "aasm"
|
6
|
+
gem "autoprefixer-rails"
|
7
|
+
gem "awesome_print"
|
8
|
+
gem "coffee-rails", "~> 4.1.0"
|
9
|
+
gem "devise"
|
10
|
+
gem "friendly_id"
|
11
|
+
gem "i18n-tasks"
|
12
|
+
gem "jquery-rails"
|
13
|
+
gem "newrelic_rpm", ">= 3.9.8"
|
14
|
+
gem "paperclip"
|
15
|
+
gem "pg"
|
16
|
+
gem "puma"
|
17
|
+
gem "rack-canonical-host"
|
18
|
+
gem "rails", "<%= Underwear::RAILS_VERSION %>"
|
19
|
+
gem "recipient_interceptor"
|
20
|
+
gem "sass-rails", "~> 5.0"
|
21
|
+
gem 'semantic-ui-sass', github: 'doabit/semantic-ui-sass'
|
22
|
+
gem "sentry-raven"
|
23
|
+
gem "sidekiq"
|
24
|
+
gem "uglifier"
|
25
|
+
#gem "rails_admin"
|
26
|
+
|
27
|
+
group :development do
|
28
|
+
gem 'brakeman', :require => false
|
29
|
+
gem 'rack-mini-profiler'
|
30
|
+
gem 'better_errors'
|
31
|
+
gem 'guard'
|
32
|
+
gem 'guard-rspec', require: false
|
33
|
+
gem 'guard-brakeman'
|
34
|
+
gem 'guard-rubocop'
|
35
|
+
gem "guard-rubycritic"
|
36
|
+
gem 'rubocop', require: false
|
37
|
+
gem "rubycritic", :require => false
|
38
|
+
gem "spring"
|
39
|
+
gem "spring-commands-rspec"
|
40
|
+
gem "web-console"
|
41
|
+
end
|
42
|
+
|
43
|
+
group :development, :test do
|
44
|
+
gem "bullet"
|
45
|
+
gem "bundler-audit", require: false
|
46
|
+
gem "byebug"
|
47
|
+
gem "dotenv-rails"
|
48
|
+
gem "factory_girl_rails"
|
49
|
+
gem "faker"
|
50
|
+
gem "pry-rails"
|
51
|
+
gem "rspec-rails", "~> 3.3.0"
|
52
|
+
end
|
53
|
+
|
54
|
+
group :test do
|
55
|
+
gem "capybara-webkit", ">= 1.2.0"
|
56
|
+
gem "database_cleaner"
|
57
|
+
gem "shoulda-matchers", require: false
|
58
|
+
gem "simplecov", require: false
|
59
|
+
gem "webmock"
|
60
|
+
gem "vcr"
|
61
|
+
end
|
62
|
+
|
63
|
+
group :staging, :production do
|
64
|
+
gem "rack-timeout"
|
65
|
+
end
|
data/templates/Procfile
ADDED
@@ -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 @@
|
|
1
|
+
@charset "utf-8";
|
@@ -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,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,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
|
data/templates/dev.rake
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
if Rails.env.development? || Rails.env.test?
|
2
|
+
require "factory_girl"
|
3
|
+
|
4
|
+
namespace :dev do
|
5
|
+
desc "Sample data for local 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
|
data/templates/errors.rb
ADDED
@@ -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
|