stairs 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -36
- data/.travis.yml +6 -2
- data/Guardfile +2 -2
- data/Rakefile +4 -4
- data/bin/stairs +10 -10
- data/lib/stairs.rb +13 -13
- data/lib/stairs/env_adapters.rb +6 -6
- data/lib/stairs/env_adapters/dotenv.rb +3 -3
- data/lib/stairs/env_adapters/rbenv.rb +3 -3
- data/lib/stairs/env_adapters/rvm.rb +3 -3
- data/lib/stairs/interactive_configuration.rb +11 -11
- data/lib/stairs/railtie.rb +1 -1
- data/lib/stairs/runner.rb +2 -2
- data/lib/stairs/step.rb +20 -17
- data/lib/stairs/steps.rb +3 -3
- data/lib/stairs/steps/facebook.rb +6 -6
- data/lib/stairs/steps/postgresql.rb +11 -11
- data/lib/stairs/steps/secret_key_base.rb +4 -4
- data/lib/stairs/tasks.rb +2 -2
- data/lib/stairs/util.rb +2 -2
- data/lib/stairs/util/cli.rb +3 -4
- data/lib/stairs/util/file_mutation.rb +10 -10
- data/lib/stairs/version.rb +1 -1
- data/spec/lib/configuration_spec.rb +8 -8
- data/spec/lib/stairs/env_adapters/dotenv_spec.rb +20 -20
- data/spec/lib/stairs/env_adapters/rbenv_spec.rb +22 -22
- data/spec/lib/stairs/env_adapters/rvm_spec.rb +22 -22
- data/spec/lib/stairs/env_adapters_spec.rb +12 -14
- data/spec/lib/stairs/interactive_configuration_spec.rb +27 -20
- data/spec/lib/stairs/runner_spec.rb +18 -14
- data/spec/lib/stairs/script_spec.rb +13 -14
- data/spec/lib/stairs/step_spec.rb +225 -189
- data/spec/lib/stairs/steps/secret_key_base_spec.rb +7 -5
- data/spec/lib/stairs/util/cli_spec.rb +29 -29
- data/spec/lib/stairs/util/file_mutation_spec.rb +46 -46
- data/spec/spec_helper.rb +6 -8
- data/stairs.gemspec +28 -23
- metadata +22 -23
- data/spec/support/configuration_helper.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f7585f6811ddc955a889ce075fa31bc41435a88
|
4
|
+
data.tar.gz: c80320f149af4d28ec0d92cf92d8655f5e53f164
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 405fb108cd9ccb42df1829b31cd0980195818eecda482d67670a2ac36087b3e9652c00bb4b20c1952f48d0f485481bc92b55bc5862015583cd50b32a889d4272
|
7
|
+
data.tar.gz: de05b5f9ae3d57cdf3303b999cf14b11766caad3f2568a9d872c403cc3e780fe2c7eded0e463448856a1be34e0643d0f04d8cedcbb5c5d745f8a7507ddbd7461
|
data/.rubocop.yml
CHANGED
@@ -1,46 +1,13 @@
|
|
1
|
-
StringLiterals:
|
2
|
-
EnforcedStyle: "double_quotes"
|
3
|
-
|
4
|
-
LineLength:
|
5
|
-
Max: 80
|
6
|
-
|
7
|
-
# This offends when not tabbed way out while using case in assignment
|
8
|
-
CaseIndentation:
|
9
|
-
Enabled: false
|
10
|
-
|
11
|
-
# Not a part of our coding conventions
|
12
1
|
Documentation:
|
13
2
|
Enabled: false
|
14
3
|
|
15
4
|
DoubleNegation:
|
16
5
|
Enabled: false
|
17
6
|
|
18
|
-
TrailingComma:
|
19
|
-
EnforcedStyleForMultiline: comma
|
20
|
-
|
21
|
-
DeprecatedClassMethods:
|
22
|
-
Enabled: false
|
23
|
-
|
24
|
-
SingleLineBlockParams:
|
25
|
-
Enabled: false
|
26
|
-
|
27
|
-
# Also just not something I've ever done or want to do...
|
28
|
-
SpaceAroundEqualsInParameterDefault:
|
29
|
-
Enabled: false
|
30
|
-
|
31
|
-
# I don't see why... It's shorthand, just know your ruby!
|
32
7
|
SpecialGlobalVars:
|
33
8
|
Enabled: false
|
34
9
|
|
35
|
-
|
36
|
-
CollectionMethods:
|
37
|
-
Enabled: false
|
38
|
-
|
39
|
-
# Cuz we don't use any fancy characters anyway
|
40
|
-
Encoding:
|
41
|
-
Enabled: false
|
42
|
-
|
43
|
-
# I just don't care so much about clean specs.. Like short methods and short lines
|
44
|
-
AllCops:
|
10
|
+
BlockLength:
|
45
11
|
Exclude:
|
46
|
-
- spec
|
12
|
+
- "spec/**/*"
|
13
|
+
- "stairs.gemspec"
|
data/.travis.yml
CHANGED
data/Guardfile
CHANGED
data/Rakefile
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
require 'rubocop/rake_task'
|
4
4
|
|
5
5
|
RSpec::Core::RakeTask.new(:spec)
|
6
|
-
|
6
|
+
RuboCop::RakeTask.new
|
7
7
|
|
8
8
|
task default: [:spec, :rubocop]
|
data/bin/stairs
CHANGED
@@ -1,30 +1,30 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'optparse'
|
4
|
+
require 'stairs'
|
5
5
|
|
6
6
|
groups = nil
|
7
7
|
|
8
8
|
Stairs.configure do |config|
|
9
9
|
OptionParser.new do |options|
|
10
|
-
options.banner =
|
10
|
+
options.banner = 'Usage: stairs [options]'
|
11
11
|
|
12
|
-
options.on(
|
12
|
+
options.on('--use-defaults', 'Use defaults when available') do |value|
|
13
13
|
config.use_defaults = value
|
14
14
|
end
|
15
15
|
|
16
16
|
options.on(
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
'-g',
|
18
|
+
'--groups GROUPS',
|
19
|
+
'Specify groups to run. e.g. init,reset'
|
20
20
|
) do |value|
|
21
|
-
groups = value.split(
|
21
|
+
groups = value.split(',').map(&:to_sym) if value
|
22
22
|
end
|
23
23
|
end.parse!
|
24
24
|
end
|
25
25
|
|
26
26
|
# Load Rails environment if we're in Rails
|
27
|
-
rails_application = File.expand_path(
|
28
|
-
require rails_application if File.
|
27
|
+
rails_application = File.expand_path('./config/application.rb')
|
28
|
+
require rails_application if File.exist?(rails_application)
|
29
29
|
|
30
30
|
Stairs::Runner.new(groups).run!
|
data/lib/stairs.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require 'stairs/version'
|
2
|
+
require 'active_support'
|
3
|
+
require 'active_support/core_ext'
|
4
|
+
require 'colorize'
|
5
5
|
|
6
6
|
module Stairs
|
7
|
-
autoload :Step,
|
8
|
-
autoload :Script,
|
9
|
-
autoload :Steps,
|
10
|
-
autoload :EnvAdapters,
|
11
|
-
autoload :Configuration,
|
12
|
-
autoload :InteractiveConfiguration,
|
13
|
-
autoload :Util,
|
14
|
-
autoload :Runner,
|
7
|
+
autoload :Step, 'stairs/step'
|
8
|
+
autoload :Script, 'stairs/script'
|
9
|
+
autoload :Steps, 'stairs/steps'
|
10
|
+
autoload :EnvAdapters, 'stairs/env_adapters'
|
11
|
+
autoload :Configuration, 'stairs/configuration'
|
12
|
+
autoload :InteractiveConfiguration, 'stairs/interactive_configuration'
|
13
|
+
autoload :Util, 'stairs/util'
|
14
|
+
autoload :Runner, 'stairs/runner'
|
15
15
|
|
16
16
|
class << self
|
17
17
|
def configure
|
@@ -28,4 +28,4 @@ module Stairs
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
require
|
31
|
+
require 'stairs/railtie' if defined?(Rails)
|
data/lib/stairs/env_adapters.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
module Stairs
|
2
2
|
module EnvAdapters
|
3
|
-
autoload :Rbenv,
|
4
|
-
autoload :RVM,
|
5
|
-
autoload :Dotenv,
|
3
|
+
autoload :Rbenv, 'stairs/env_adapters/rbenv'
|
4
|
+
autoload :RVM, 'stairs/env_adapters/rvm'
|
5
|
+
autoload :Dotenv, 'stairs/env_adapters/dotenv'
|
6
6
|
|
7
7
|
ADAPTERS = {
|
8
8
|
dotenv: Dotenv,
|
9
9
|
rbenv: Rbenv,
|
10
|
-
rvm: RVM
|
11
|
-
}
|
10
|
+
rvm: RVM
|
11
|
+
}.freeze
|
12
12
|
|
13
13
|
def self.recommended_adapter
|
14
|
-
ADAPTERS.values.find
|
14
|
+
ADAPTERS.values.find(&:present?)
|
15
15
|
end
|
16
16
|
|
17
17
|
def self.name_for_adapter_class(adapter)
|
@@ -2,19 +2,19 @@ module Stairs
|
|
2
2
|
module EnvAdapters
|
3
3
|
class Dotenv
|
4
4
|
def self.present?
|
5
|
-
defined?
|
5
|
+
!!defined?(::Dotenv)
|
6
6
|
end
|
7
7
|
|
8
8
|
def set(name, value)
|
9
9
|
Util::FileMutation.replace_or_append(
|
10
10
|
Regexp.new("^#{name}=(.*)$"),
|
11
11
|
"#{name}=#{value}",
|
12
|
-
|
12
|
+
'.env'
|
13
13
|
)
|
14
14
|
end
|
15
15
|
|
16
16
|
def unset(name)
|
17
|
-
Util::FileMutation.remove Regexp.new("^#{name}=(.*)\n"),
|
17
|
+
Util::FileMutation.remove Regexp.new("^#{name}=(.*)\n"), '.env'
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -3,19 +3,19 @@ module Stairs
|
|
3
3
|
class Rbenv
|
4
4
|
def self.present?
|
5
5
|
`which rbenv-vars`
|
6
|
-
|
6
|
+
$CHILD_STATUS.success?
|
7
7
|
end
|
8
8
|
|
9
9
|
def set(name, value)
|
10
10
|
Util::FileMutation.replace_or_append(
|
11
11
|
Regexp.new("^#{name}=(.*)$"),
|
12
12
|
"#{name}=#{value}",
|
13
|
-
|
13
|
+
'.rbenv-vars'
|
14
14
|
)
|
15
15
|
end
|
16
16
|
|
17
17
|
def unset(name)
|
18
|
-
Util::FileMutation.remove Regexp.new("^#{name}=(.*)\n"),
|
18
|
+
Util::FileMutation.remove Regexp.new("^#{name}=(.*)\n"), '.rbenv-vars'
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -3,19 +3,19 @@ module Stairs
|
|
3
3
|
class RVM
|
4
4
|
def self.present?
|
5
5
|
`which rvm`
|
6
|
-
|
6
|
+
$CHILD_STATUS.success?
|
7
7
|
end
|
8
8
|
|
9
9
|
def set(name, value)
|
10
10
|
Util::FileMutation.replace_or_append(
|
11
11
|
Regexp.new("^export #{name}=(.*)$"),
|
12
12
|
"export #{name}=#{value}",
|
13
|
-
|
13
|
+
'.rvmrc'
|
14
14
|
)
|
15
15
|
end
|
16
16
|
|
17
17
|
def unset(name)
|
18
|
-
Util::FileMutation.remove Regexp.new("^export #{name}=(.*)\n"),
|
18
|
+
Util::FileMutation.remove Regexp.new("^export #{name}=(.*)\n"), '.rvmrc'
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Stairs
|
2
2
|
class InteractiveConfiguration < Stairs::Step
|
3
|
-
title
|
4
|
-
description
|
3
|
+
title 'Configuration'
|
4
|
+
description 'Interactive prompt for configuring Stairs'
|
5
5
|
|
6
6
|
def run!
|
7
7
|
if Stairs.configuration.use_defaults
|
@@ -26,7 +26,7 @@ module Stairs
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def select_env_adapter
|
29
|
-
choice
|
29
|
+
choice 'Which would you prefer?', adapter_names do |name|
|
30
30
|
adapter_class = Stairs::EnvAdapters::ADAPTERS[name.to_sym]
|
31
31
|
Stairs.configuration.env_adapter = adapter_class.new
|
32
32
|
end
|
@@ -45,9 +45,9 @@ module Stairs
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def prompt
|
48
|
-
|
48
|
+
''.tap do |message|
|
49
49
|
message << "Looks like you're using #{recommended_adapter_name} to "
|
50
|
-
message <<
|
50
|
+
message << 'manage environment variables. Is this correct?'
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
@@ -56,12 +56,12 @@ module Stairs
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def require_installed_adapter!
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
59
|
+
return if recommended_adapter
|
60
|
+
|
61
|
+
abort <<-MSG
|
62
|
+
Please install a supported ENV variable manager:
|
63
|
+
#{adapter_names.join(', ')}
|
64
|
+
MSG
|
65
65
|
end
|
66
66
|
end
|
67
67
|
end
|
data/lib/stairs/railtie.rb
CHANGED
data/lib/stairs/runner.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
module Stairs
|
2
2
|
class Runner
|
3
|
-
def initialize(groups=nil)
|
3
|
+
def initialize(groups = nil)
|
4
4
|
@groups = groups
|
5
5
|
end
|
6
6
|
|
7
7
|
def run!
|
8
8
|
Stairs::InteractiveConfiguration.new.run!
|
9
|
-
Stairs::Script.new(
|
9
|
+
Stairs::Script.new('setup.rb', groups).run!
|
10
10
|
end
|
11
11
|
|
12
12
|
private
|
data/lib/stairs/step.rb
CHANGED
@@ -36,12 +36,10 @@ module Stairs
|
|
36
36
|
end
|
37
37
|
|
38
38
|
# Prompt user to provide input
|
39
|
-
def provide(prompt, options={})
|
39
|
+
def provide(prompt, options = {})
|
40
40
|
options.reverse_merge! required: true, default: nil
|
41
41
|
required = options[:required] && !options[:default]
|
42
|
-
|
43
|
-
prompt << " (leave blank for #{options[:default]})" if options[:default]
|
44
|
-
prompt << ": "
|
42
|
+
prompt = "#{defaulted_prompt(prompt, options[:default])}: "
|
45
43
|
|
46
44
|
if Stairs.configuration.use_defaults && options[:default]
|
47
45
|
options[:default]
|
@@ -86,7 +84,7 @@ module Stairs
|
|
86
84
|
# Embed a step where step_name is a symbol that can be resolved to a class
|
87
85
|
# in Stairs::Steps or a block is provided to be executed in an instance
|
88
86
|
# of Step
|
89
|
-
def setup(step_name, options={}, &block)
|
87
|
+
def setup(step_name, options = {}, &block)
|
90
88
|
if block_given?
|
91
89
|
Step.new(groups, options).tap do |step|
|
92
90
|
step.define_singleton_method :run, &block
|
@@ -103,7 +101,7 @@ module Stairs
|
|
103
101
|
end
|
104
102
|
|
105
103
|
def finish(message)
|
106
|
-
puts
|
104
|
+
puts '== All done!'.green
|
107
105
|
puts message.green
|
108
106
|
end
|
109
107
|
|
@@ -115,12 +113,17 @@ module Stairs
|
|
115
113
|
|
116
114
|
def run_step?
|
117
115
|
return true if options[:required]
|
118
|
-
choice
|
116
|
+
choice 'This step is optional, would you like to perform it?'
|
117
|
+
end
|
118
|
+
|
119
|
+
def defaulted_prompt(prompt, default = nil)
|
120
|
+
return prompt if default.nil?
|
121
|
+
"#{prompt} (leave blank for #{default})"
|
119
122
|
end
|
120
123
|
|
121
124
|
class Choice
|
122
125
|
# TODO: shouldn't care about case?
|
123
|
-
def initialize(question, choices
|
126
|
+
def initialize(question, choices = %w(Y N), &block)
|
124
127
|
@question = question
|
125
128
|
@choices = choices
|
126
129
|
@block = block
|
@@ -136,22 +139,22 @@ module Stairs
|
|
136
139
|
attr_reader :question, :choices, :block
|
137
140
|
|
138
141
|
def prompt
|
139
|
-
"#{question} (#{choices.join(
|
142
|
+
"#{question} (#{choices.join('/')}): "
|
140
143
|
end
|
141
144
|
|
142
145
|
def processed_response
|
143
146
|
@processed_response ||= case response
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
147
|
+
when 'Y'
|
148
|
+
true
|
149
|
+
when 'N'
|
150
|
+
false
|
151
|
+
else
|
152
|
+
response
|
153
|
+
end
|
151
154
|
end
|
152
155
|
|
153
156
|
def response
|
154
|
-
@reponse ||= Stairs::Util::CLI.collect prompt.blue do |value,
|
157
|
+
@reponse ||= Stairs::Util::CLI.collect prompt.blue do |value, _i|
|
155
158
|
choices.include? value
|
156
159
|
end
|
157
160
|
end
|
data/lib/stairs/steps.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Stairs
|
2
2
|
module Steps
|
3
|
-
autoload :SecretKeyBase,
|
4
|
-
autoload :Postgresql,
|
5
|
-
autoload :Facebook,
|
3
|
+
autoload :SecretKeyBase, 'stairs/steps/secret_key_base'
|
4
|
+
autoload :Postgresql, 'stairs/steps/postgresql'
|
5
|
+
autoload :Facebook, 'stairs/steps/facebook'
|
6
6
|
end
|
7
7
|
end
|
@@ -1,22 +1,22 @@
|
|
1
1
|
module Stairs
|
2
2
|
module Steps
|
3
3
|
class Facebook < Stairs::Step
|
4
|
-
title
|
5
|
-
description
|
4
|
+
title 'Facebook App'
|
5
|
+
description 'Configure credentials for Facebook app'
|
6
6
|
|
7
7
|
def run
|
8
|
-
env id_name, provide(
|
9
|
-
env secret_name, provide(
|
8
|
+
env id_name, provide('Facebook App ID')
|
9
|
+
env secret_name, provide('Facebook App Secret')
|
10
10
|
end
|
11
11
|
|
12
12
|
private
|
13
13
|
|
14
14
|
def id_name
|
15
|
-
options[:app_id] ||
|
15
|
+
options[:app_id] || 'FACEBOOK_ID'
|
16
16
|
end
|
17
17
|
|
18
18
|
def secret_name
|
19
|
-
options[:app_secret] ||
|
19
|
+
options[:app_secret] || 'FACEBOOK_SECRET'
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|