suspenders 1.55.1 → 1.56.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/CONTRIBUTING.md +1 -1
- data/NEWS.md +28 -1
- data/README.md +4 -11
- data/bin/suspenders +29 -2
- data/lib/suspenders/actions/strip_comments_action.rb +254 -0
- data/lib/suspenders/actions.rb +1 -1
- data/lib/suspenders/app_builder.rb +13 -11
- data/lib/suspenders/exit_on_failure.rb +19 -0
- data/lib/suspenders/generators/app_generator.rb +21 -14
- data/lib/suspenders/generators/base.rb +1 -0
- data/lib/suspenders/generators/json_generator.rb +4 -0
- data/lib/suspenders/generators/production/email_generator.rb +2 -2
- data/lib/suspenders/generators/testing_generator.rb +1 -2
- data/lib/suspenders/version.rb +1 -1
- data/lib/suspenders.rb +2 -1
- 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/postgresql_database.yml.erb +1 -0
- metadata +53 -95
- 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/descriptions/preloader.md +0 -3
- data/templates/spring.rb +0 -6
@@ -1,47 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
RSpec.describe "suspenders:production:email", type: :generator do
|
4
|
-
it "generates the configuration for a production email deployment" do
|
5
|
-
with_app { generate("suspenders:production:email") }
|
6
|
-
|
7
|
-
expect("config/smtp.rb").to match_contents(%r{SMTP_SETTINGS\s*=})
|
8
|
-
|
9
|
-
expect("config/environments/production.rb").to \
|
10
|
-
match_contents(%r{require.+config/smtp})
|
11
|
-
expect("config/environments/production.rb").to \
|
12
|
-
match_contents(%r{action_mailer.delivery_method\s*=\s*:smtp})
|
13
|
-
expect("config/environments/production.rb").to \
|
14
|
-
match_contents(%r{action_mailer.smtp_settings\s*=\s*SMTP_SETTINGS})
|
15
|
-
|
16
|
-
expect("app.json").to contain_json(
|
17
|
-
env: {
|
18
|
-
SMTP_ADDRESS: {required: true},
|
19
|
-
SMTP_DOMAIN: {required: true},
|
20
|
-
SMTP_PASSWORD: {required: true},
|
21
|
-
SMTP_USERNAME: {required: true}
|
22
|
-
}
|
23
|
-
)
|
24
|
-
end
|
25
|
-
|
26
|
-
it "destroys the configuration for a production email deployment" do
|
27
|
-
with_app { destroy("suspenders:production:email") }
|
28
|
-
|
29
|
-
expect("config/smtp.rb").not_to exist_as_a_file
|
30
|
-
|
31
|
-
expect("config/environments/production.rb").not_to \
|
32
|
-
match_contents(%r{require.+config/smtp})
|
33
|
-
expect("config/environments/production.rb").not_to \
|
34
|
-
match_contents(%r{action_mailer.delivery_method\s*=\s*:smtp})
|
35
|
-
expect("config/environments/production.rb").not_to \
|
36
|
-
match_contents(%r{action_mailer.smtp_settings\s*=\s*SMTP_SETTINGS})
|
37
|
-
|
38
|
-
expect("app.json").not_to contain_json(
|
39
|
-
env: {
|
40
|
-
SMTP_ADDRESS: {required: true},
|
41
|
-
SMTP_DOMAIN: {required: true},
|
42
|
-
SMTP_PASSWORD: {required: true},
|
43
|
-
SMTP_USERNAME: {required: true}
|
44
|
-
}
|
45
|
-
)
|
46
|
-
end
|
47
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
RSpec.describe "suspenders:production:manifest", type: :generator do
|
4
|
-
it "generates the manifest for a production build" do
|
5
|
-
with_app { generate("suspenders:production:manifest") }
|
6
|
-
|
7
|
-
expect("app.json").to contain_json(
|
8
|
-
name: SuspendersTestHelpers::APP_NAME.dasherize,
|
9
|
-
env: {
|
10
|
-
APPLICATION_HOST: {required: true},
|
11
|
-
AUTO_MIGRATE_DB: {value: true},
|
12
|
-
EMAIL_RECIPIENTS: {required: true},
|
13
|
-
HEROKU_APP_NAME: {required: true},
|
14
|
-
HEROKU_PARENT_APP_NAME: {required: true},
|
15
|
-
RACK_ENV: {required: true},
|
16
|
-
SECRET_KEY_BASE: {generator: "secret"}
|
17
|
-
}
|
18
|
-
)
|
19
|
-
end
|
20
|
-
|
21
|
-
it "destroys the manifest for a production build" do
|
22
|
-
with_app { destroy("suspenders:production:manifest") }
|
23
|
-
|
24
|
-
expect("app.json").not_to contain_json(
|
25
|
-
name: SuspendersTestHelpers::APP_NAME.dasherize,
|
26
|
-
env: {
|
27
|
-
APPLICATION_HOST: {required: true},
|
28
|
-
AUTO_MIGRATE_DB: {value: true},
|
29
|
-
EMAIL_RECIPIENTS: {required: true},
|
30
|
-
HEROKU_APP_NAME: {required: true},
|
31
|
-
HEROKU_PARENT_APP_NAME: {required: true},
|
32
|
-
RACK_ENV: {required: true},
|
33
|
-
SECRET_KEY_BASE: {generator: "secret"}
|
34
|
-
}
|
35
|
-
)
|
36
|
-
end
|
37
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
RSpec.describe "suspenders:production:single_redirect", type: :generator do
|
4
|
-
context "generate" do
|
5
|
-
it "adds Rack::CanonicalHost to the production middleware" do
|
6
|
-
with_app { generate("suspenders:production:single_redirect") }
|
7
|
-
middleware_canonical_host = %r{config.middleware.use Rack::CanonicalHost, ENV.fetch\("APPLICATION_HOST"\)}
|
8
|
-
|
9
|
-
expect("config/environments/production.rb").to match_contents(
|
10
|
-
middleware_canonical_host
|
11
|
-
)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
context "destroy" do
|
16
|
-
it "removes Rack::CanonicalHost from the production middleware" do
|
17
|
-
with_app { destroy("suspenders:production:single_redirect") }
|
18
|
-
middleware_canonical_host = %r{config.middleware.use Rack::CanonicalHost, ENV.fetch\("APPLICATION_HOST"\)}
|
19
|
-
|
20
|
-
expect("config/environments/production.rb").not_to match_contents(
|
21
|
-
middleware_canonical_host
|
22
|
-
)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
RSpec.describe "suspenders:profiler", type: :generator do
|
4
|
-
it "sets up rack-min-profiler" do
|
5
|
-
with_app { generate("suspenders:profiler") }
|
6
|
-
|
7
|
-
expect("config/initializers/rack_mini_profiler.rb").to \
|
8
|
-
match_contents(/Rack::MiniProfilerRails.initialize/)
|
9
|
-
expect("Gemfile").to match_contents(/rack-mini-profiler/)
|
10
|
-
expect(".sample.env").to match_contents(/RACK_MINI_PROFILER=0/)
|
11
|
-
end
|
12
|
-
|
13
|
-
it "removes rack-min-profiler" do
|
14
|
-
with_app { destroy("suspenders:profiler") }
|
15
|
-
|
16
|
-
expect("config/initializers/rack_mini_profiler.rb").not_to exist_as_a_file
|
17
|
-
expect("Gemfile").not_to match_contents(/rack-mini-profiler/)
|
18
|
-
expect(".sample.env").not_to exist_as_a_file
|
19
|
-
end
|
20
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
RSpec.describe "suspenders:runner", type: :generator do
|
4
|
-
it "configures the app for running" do
|
5
|
-
with_app { generate("suspenders:runner") }
|
6
|
-
|
7
|
-
expect("Procfile").to exist_as_a_file
|
8
|
-
expect(".sample.env").to exist_as_a_file
|
9
|
-
expect("bin/setup").to match_contents(/\.sample\.env/)
|
10
|
-
expect("README.md").to match_contents(/\.sample\.env/)
|
11
|
-
end
|
12
|
-
|
13
|
-
it "removes custom app running configuration" do
|
14
|
-
with_app { destroy("suspenders:runner") }
|
15
|
-
|
16
|
-
expect("README.md").not_to match_contents(/\.sample\.env/)
|
17
|
-
expect("bin/setup").not_to match_contents(/\.sample\.env/)
|
18
|
-
expect(".sample.env").not_to exist_as_a_file
|
19
|
-
expect("Procfile").not_to exist_as_a_file
|
20
|
-
end
|
21
|
-
|
22
|
-
it "configures the app with a shell script bin/setup" do
|
23
|
-
with_app do
|
24
|
-
copy_file "bin_setup", "bin/setup"
|
25
|
-
generate("suspenders:runner")
|
26
|
-
end
|
27
|
-
|
28
|
-
expect("bin/setup").to match_contents(/\.sample\.env/)
|
29
|
-
end
|
30
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
RSpec.describe "suspenders:staging:pull_requests", type: :generator do
|
4
|
-
it "generates the configuration for Heroku pipeline review apps" do
|
5
|
-
with_app { generate("suspenders:staging:pull_requests") }
|
6
|
-
|
7
|
-
expect("config/environments/production.rb").to \
|
8
|
-
match_contents(%r{HEROKU_APP_NAME})
|
9
|
-
|
10
|
-
expect("bin/setup_review_app").to \
|
11
|
-
match_contents(%r{APP_NAME=dummy-app-staging-pr-\$1})
|
12
|
-
end
|
13
|
-
|
14
|
-
it "destroys the configuration for Heroku pipeline review apps" do
|
15
|
-
with_app { destroy("suspenders:staging:pull_requests") }
|
16
|
-
|
17
|
-
expect("config/environments/production.rb").not_to \
|
18
|
-
match_contents(%r{APP_NAME=dummy-app-staging-pr-\$1})
|
19
|
-
|
20
|
-
expect("bin/setup_review_app").not_to exist_as_a_file
|
21
|
-
end
|
22
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
RSpec.describe "suspenders:static", type: :generator do
|
4
|
-
it "adds the gem and pages directory" do
|
5
|
-
with_app { generate("suspenders:static") }
|
6
|
-
|
7
|
-
expect("Gemfile").to match_contents(/high_voltage/)
|
8
|
-
expect("app/views/pages/.keep").to exist_as_a_file
|
9
|
-
end
|
10
|
-
|
11
|
-
it "removes the gem and pages directory" do
|
12
|
-
with_app { destroy("suspenders:static") }
|
13
|
-
|
14
|
-
expect("app/views/pages/.keep").not_to exist_as_a_file
|
15
|
-
expect("Gemfile").not_to match_contents(/high_voltage/)
|
16
|
-
end
|
17
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
RSpec.describe "suspenders:stylelint", type: :generator do
|
4
|
-
context "generate" do
|
5
|
-
it "creates .stylelintrc.json" do
|
6
|
-
with_app { generate("suspenders:stylelint") }
|
7
|
-
|
8
|
-
expect(".stylelintrc.json")
|
9
|
-
.to match_contents(%r{"extends": "@thoughtbot/stylelint-config"})
|
10
|
-
end
|
11
|
-
|
12
|
-
it "adds stylelint and @thoughtbot/stylelint-config to the package.json" do
|
13
|
-
with_app { generate("suspenders:stylelint") }
|
14
|
-
|
15
|
-
expect("package.json").to match_contents(/devDependencies/)
|
16
|
-
expect("package.json").to match_contents(/stylelint/)
|
17
|
-
expect("package.json").to match_contents(%r{@thoughtbot/stylelint-config})
|
18
|
-
end
|
19
|
-
|
20
|
-
it "uncomments the hound config_file option" do
|
21
|
-
with_app { generate("suspenders:stylelint") }
|
22
|
-
|
23
|
-
expect(".hound.yml").to(
|
24
|
-
match_contents(/^ config_file: \.stylelintrc\.json/)
|
25
|
-
)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
context "destroy" do
|
30
|
-
it "removes .stylelintrc.json" do
|
31
|
-
with_app do
|
32
|
-
generate("suspenders:stylelint")
|
33
|
-
destroy("suspenders:stylelint")
|
34
|
-
end
|
35
|
-
|
36
|
-
expect(".stylelintrc.json").not_to exist_as_a_file
|
37
|
-
end
|
38
|
-
|
39
|
-
it "removes stylelint and @thoughtbot/stylelint-config from package.json" do
|
40
|
-
with_app do
|
41
|
-
generate("suspenders:stylelint")
|
42
|
-
destroy("suspenders:stylelint")
|
43
|
-
end
|
44
|
-
|
45
|
-
expect("package.json").not_to match_contents(/stylelint/)
|
46
|
-
expect("package.json")
|
47
|
-
.not_to match_contents(%r{@thoughtbot/stylelint-config})
|
48
|
-
end
|
49
|
-
|
50
|
-
it "comments in the hound config_file option" do
|
51
|
-
with_app do
|
52
|
-
generate("suspenders:stylelint")
|
53
|
-
destroy("suspenders:stylelint")
|
54
|
-
end
|
55
|
-
|
56
|
-
expect(".hound.yml")
|
57
|
-
.to match_contents(/^ # config_file: \.stylelintrc\.json/)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
require "bundler/setup"
|
2
|
-
|
3
|
-
Bundler.require(:default, :test)
|
4
|
-
|
5
|
-
require (Pathname.new(__FILE__).dirname + "../lib/suspenders").expand_path
|
6
|
-
|
7
|
-
Dir["./spec/support/**/*.rb"].sort.each { |file| require file }
|
8
|
-
|
9
|
-
RSpec.configure do |config|
|
10
|
-
config.include SuspendersTestHelpers
|
11
|
-
config.include ProjectFiles
|
12
|
-
|
13
|
-
config.before(:all) do
|
14
|
-
add_fakes_to_path
|
15
|
-
create_tmp_directory
|
16
|
-
end
|
17
|
-
|
18
|
-
config.before(:each) do
|
19
|
-
FakeGithub.clear!
|
20
|
-
end
|
21
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "json"
|
4
|
-
|
5
|
-
RSpec::Matchers.define :contain_json do
|
6
|
-
match do
|
7
|
-
@sub_json = expected
|
8
|
-
@filename = actual
|
9
|
-
|
10
|
-
@filepath = File.join(project_path, @filename)
|
11
|
-
@json = JSON.parse(IO.read(@filepath), symbolize_names: true)
|
12
|
-
|
13
|
-
subhash?(@sub_json, @json)
|
14
|
-
end
|
15
|
-
|
16
|
-
failure_message do
|
17
|
-
"in #{@filename}, expected to find\n#{@sub_json.inspect}\n" \
|
18
|
-
"in\n#{@json.inspect}"
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
def subhash?(inner, outer)
|
24
|
-
if inner.is_a?(Hash) && outer.is_a?(Hash)
|
25
|
-
inner.all? { |key, value| subhash?(value, outer[key]) }
|
26
|
-
else
|
27
|
-
inner == outer
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
data/spec/support/fake_github.rb
DELETED
@@ -1,21 +0,0 @@
|
|
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
|
data/spec/support/fake_heroku.rb
DELETED
@@ -1,53 +0,0 @@
|
|
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
|
-
if @args.first == "help"
|
10
|
-
puts "pipelines # manage collections of apps in pipelines"
|
11
|
-
end
|
12
|
-
File.open(RECORDER, "a") do |file|
|
13
|
-
file.puts @args.join(" ")
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.clear!
|
18
|
-
FileUtils.rm_rf RECORDER
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.has_gem_included?(project_path, gem_name)
|
22
|
-
gemfile = File.open(File.join(project_path, "Gemfile"), "a")
|
23
|
-
|
24
|
-
File.foreach(gemfile).any? do |line|
|
25
|
-
line.match(/#{Regexp.quote(gem_name)}/)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.has_created_app_for?(environment, flags = nil)
|
30
|
-
app_name = "#{SuspendersTestHelpers::APP_NAME.dasherize}-#{environment}"
|
31
|
-
|
32
|
-
command = if flags
|
33
|
-
"create #{app_name} #{flags} --remote #{environment}\n"
|
34
|
-
else
|
35
|
-
"create #{app_name} --remote #{environment}\n"
|
36
|
-
end
|
37
|
-
|
38
|
-
File.foreach(RECORDER).any? { |line| line == command }
|
39
|
-
end
|
40
|
-
|
41
|
-
def self.has_configured_vars?(remote_name, var)
|
42
|
-
commands_ran =~ /^config:add #{var}=.+ --remote #{remote_name}\n/
|
43
|
-
end
|
44
|
-
|
45
|
-
def self.has_setup_pipeline_for?(app_name)
|
46
|
-
commands_ran =~ /^pipelines:create #{app_name} -a #{app_name}-staging --stage staging/ &&
|
47
|
-
commands_ran =~ /^pipelines:add #{app_name} -a #{app_name}-production --stage production/
|
48
|
-
end
|
49
|
-
|
50
|
-
def self.commands_ran
|
51
|
-
@commands_ran ||= File.read(RECORDER)
|
52
|
-
end
|
53
|
-
end
|
data/spec/support/generators.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
module ProjectFiles
|
2
|
-
def touch(filename)
|
3
|
-
path = File.join(project_path, filename)
|
4
|
-
dirname = File.dirname(path)
|
5
|
-
FileUtils.mkdir_p(dirname)
|
6
|
-
FileUtils.touch(path)
|
7
|
-
end
|
8
|
-
|
9
|
-
def rm(filename)
|
10
|
-
path = File.join(project_path, filename)
|
11
|
-
FileUtils.rm_rf(path)
|
12
|
-
end
|
13
|
-
|
14
|
-
def copy_file(from_in_templates, to_in_project)
|
15
|
-
destination = File.join(project_path, to_in_project)
|
16
|
-
destination_dirname = File.dirname(destination)
|
17
|
-
|
18
|
-
FileUtils.mkdir_p(destination_dirname)
|
19
|
-
|
20
|
-
FileUtils.cp(
|
21
|
-
File.join(root_path, "templates", from_in_templates),
|
22
|
-
destination
|
23
|
-
)
|
24
|
-
end
|
25
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
gem "suspenders", path: File.expand_path("../..", __dir__)
|
data/spec/support/suspenders.rb
DELETED
@@ -1,184 +0,0 @@
|
|
1
|
-
module SuspendersTestHelpers
|
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_suspenders(arguments = nil)
|
13
|
-
arguments = "--path=#{root_path} #{arguments}"
|
14
|
-
run_in_tmp do
|
15
|
-
add_fakes_to_path
|
16
|
-
|
17
|
-
with_revision_for_honeybadger do
|
18
|
-
debug `#{suspenders_bin} #{APP_NAME} #{arguments}`
|
19
|
-
end
|
20
|
-
|
21
|
-
Dir.chdir(APP_NAME) do
|
22
|
-
commit_all
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def with_app
|
28
|
-
drop_dummy_database
|
29
|
-
remove_project_directory
|
30
|
-
rails_new
|
31
|
-
setup_app_dependencies
|
32
|
-
|
33
|
-
yield
|
34
|
-
end
|
35
|
-
|
36
|
-
def rails_new
|
37
|
-
run_in_tmp do
|
38
|
-
add_fakes_to_path
|
39
|
-
|
40
|
-
with_revision_for_honeybadger do
|
41
|
-
debug `#{system_rails_bin} new #{APP_NAME} -m #{rails_template_path}`
|
42
|
-
end
|
43
|
-
|
44
|
-
Dir.chdir(APP_NAME) do
|
45
|
-
commit_all
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def generate(generator)
|
51
|
-
run_in_project do
|
52
|
-
with_revision_for_honeybadger do
|
53
|
-
debug `bin/spring stop`
|
54
|
-
debug `#{project_rails_bin} generate #{generator}`
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def destroy(generator)
|
60
|
-
run_in_project do
|
61
|
-
with_revision_for_honeybadger do
|
62
|
-
`bin/spring stop`
|
63
|
-
`#{project_rails_bin} destroy #{generator}`
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
def suspenders_help_command
|
69
|
-
run_in_tmp do
|
70
|
-
debug `#{suspenders_bin} -h`
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
def setup_app_dependencies
|
75
|
-
run_in_project do
|
76
|
-
debug `bundle check || bundle install`
|
77
|
-
end
|
78
|
-
rescue Errno::ENOENT
|
79
|
-
# The project_path might not exist, in which case we can skip this.
|
80
|
-
end
|
81
|
-
|
82
|
-
def drop_dummy_database
|
83
|
-
run_in_project do
|
84
|
-
debug `#{project_rails_bin} db:drop 2>&1`
|
85
|
-
end
|
86
|
-
rescue Errno::ENOENT
|
87
|
-
# The project_path might not exist, in which case we can skip this.
|
88
|
-
end
|
89
|
-
|
90
|
-
def add_fakes_to_path
|
91
|
-
ENV["PATH"] = "#{support_bin}:#{ENV["PATH"]}"
|
92
|
-
end
|
93
|
-
|
94
|
-
def project_path
|
95
|
-
@project_path ||= Pathname.new("#{tmp_path}/#{APP_NAME}")
|
96
|
-
end
|
97
|
-
|
98
|
-
def usage_file
|
99
|
-
@usage_path ||= File.join(root_path, "USAGE")
|
100
|
-
end
|
101
|
-
|
102
|
-
private
|
103
|
-
|
104
|
-
def tmp_path
|
105
|
-
@tmp_path ||= Pathname.new("#{root_path}/tmp")
|
106
|
-
end
|
107
|
-
|
108
|
-
def suspenders_bin
|
109
|
-
File.join(root_path, "bin", "suspenders")
|
110
|
-
end
|
111
|
-
|
112
|
-
def system_rails_bin
|
113
|
-
"rails"
|
114
|
-
end
|
115
|
-
|
116
|
-
def project_rails_bin
|
117
|
-
"bin/rails"
|
118
|
-
end
|
119
|
-
|
120
|
-
def support_bin
|
121
|
-
File.join(root_path, "spec", "fakes", "bin")
|
122
|
-
end
|
123
|
-
|
124
|
-
def root_path
|
125
|
-
File.expand_path("../../../", __FILE__)
|
126
|
-
end
|
127
|
-
|
128
|
-
def rails_template_path
|
129
|
-
File.join(root_path, "spec", "support", "rails_template.rb")
|
130
|
-
end
|
131
|
-
|
132
|
-
def commit_all
|
133
|
-
with_env("HOME", tmp_path) do
|
134
|
-
debug `git config user.email suspenders@example.com`
|
135
|
-
debug `git config user.name "Suspenders Boy"`
|
136
|
-
debug `git add .`
|
137
|
-
debug `git commit -m 'Initial commit'`
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
def with_env(name, new_value)
|
142
|
-
had_key = ENV.has_key?(name)
|
143
|
-
prior = ENV[name]
|
144
|
-
ENV[name] = new_value.to_s
|
145
|
-
|
146
|
-
yield
|
147
|
-
ensure
|
148
|
-
ENV.delete(name)
|
149
|
-
|
150
|
-
if had_key
|
151
|
-
ENV[name] = prior
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
def with_revision_for_honeybadger
|
156
|
-
with_env("HEROKU_SLUG_COMMIT", 1) do
|
157
|
-
yield
|
158
|
-
end
|
159
|
-
end
|
160
|
-
|
161
|
-
def run_in_tmp
|
162
|
-
Dir.chdir(tmp_path) do
|
163
|
-
Bundler.with_unbundled_env do
|
164
|
-
yield
|
165
|
-
end
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
def run_in_project
|
170
|
-
Dir.chdir(project_path) do
|
171
|
-
Bundler.with_unbundled_env do
|
172
|
-
yield
|
173
|
-
end
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
def debug(output)
|
178
|
-
if ENV["DEBUG"]
|
179
|
-
warn output
|
180
|
-
end
|
181
|
-
|
182
|
-
output
|
183
|
-
end
|
184
|
-
end
|
data/suspenders.gemspec
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
$:.push File.expand_path("../lib", __FILE__)
|
2
|
-
require "suspenders/version"
|
3
|
-
require "date"
|
4
|
-
|
5
|
-
Gem::Specification.new do |s|
|
6
|
-
s.required_ruby_version = ">= #{Suspenders::RUBY_VERSION}"
|
7
|
-
s.required_rubygems_version = ">= 2.7.4"
|
8
|
-
s.authors = ["thoughtbot"]
|
9
|
-
s.date = Date.today.strftime("%Y-%m-%d")
|
10
|
-
|
11
|
-
s.description = <<~HERE
|
12
|
-
Suspenders is a base Rails project that you can upgrade. It is used by
|
13
|
-
thoughtbot to get a jump start on a working app. Use Suspenders if you're in a
|
14
|
-
rush to build something amazing; don't use it if you like missing deadlines.
|
15
|
-
HERE
|
16
|
-
|
17
|
-
s.email = "support@thoughtbot.com"
|
18
|
-
s.executables = ["suspenders"]
|
19
|
-
s.extra_rdoc_files = %w[README.md LICENSE]
|
20
|
-
s.files = `git ls-files`.split("\n")
|
21
|
-
s.homepage = "http://github.com/thoughtbot/suspenders"
|
22
|
-
s.license = "MIT"
|
23
|
-
s.name = "suspenders"
|
24
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
25
|
-
s.require_paths = ["lib"]
|
26
|
-
s.summary = "Generate a Rails app using thoughtbot's best practices."
|
27
|
-
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
28
|
-
s.version = Suspenders::VERSION
|
29
|
-
|
30
|
-
s.add_dependency "bitters", ">= 2.0.4"
|
31
|
-
s.add_dependency "rails", Suspenders::RAILS_VERSION
|
32
|
-
|
33
|
-
s.add_development_dependency "rspec", "~> 3.2"
|
34
|
-
s.add_development_dependency "standard"
|
35
|
-
end
|