boxen 3.0.0.beta1 → 3.1.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 +7 -0
- data/.travis.yml +0 -1
- data/README.md +1 -1
- data/boxen.gemspec +13 -13
- data/lib/boxen/check.rb +39 -8
- data/lib/boxen/cli.rb +45 -19
- data/lib/boxen/config.rb +61 -43
- data/lib/boxen/flags.rb +282 -0
- data/lib/boxen/hook.rb +8 -15
- data/lib/boxen/hook/github_issue.rb +120 -0
- data/lib/boxen/hook/web.rb +56 -0
- data/lib/boxen/keychain.rb +1 -1
- data/lib/boxen/postflight/env.rb +1 -1
- data/lib/boxen/preflight.rb +7 -4
- data/lib/boxen/preflight/creds.rb +47 -8
- data/lib/boxen/preflight/identity.rb +0 -2
- data/lib/boxen/preflight/os.rb +6 -2
- data/lib/boxen/puppeteer.rb +121 -0
- data/lib/boxen/runner.rb +149 -0
- data/script/bootstrap +1 -1
- data/script/tests +0 -1
- data/test/boxen/test.rb +1 -1
- data/test/boxen_check_test.rb +55 -0
- data/test/boxen_cli_test.rb +31 -8
- data/test/boxen_config_test.rb +31 -1
- data/test/boxen_directories_test.rb +4 -4
- data/test/boxen_flags_test.rb +217 -0
- data/test/{postflight/boxen_postflight_github_issue_test.rb → boxen_hook_github_issue_test.rb} +82 -72
- data/test/{postflight/boxen_postflight_web_hook_test.rb → boxen_hook_web_test.rb} +11 -12
- data/test/{postflight/boxen_postflight_active_test.rb → boxen_postflight_active_test.rb} +3 -3
- data/test/{postflight/boxen_postflight_env_test.rb → boxen_postflight_env_test.rb} +0 -0
- data/test/boxen_preflight_creds_test.rb +177 -0
- data/test/{preflight/boxen_preflight_etc_my_cnf_test.rb → boxen_preflight_etc_my_cnf_test.rb} +1 -1
- data/test/{preflight/boxen_preflight_rvm_test.rb → boxen_preflight_rvm_test.rb} +1 -1
- data/test/boxen_puppeteer_test.rb +101 -0
- data/test/boxen_runner_test.rb +171 -0
- metadata +172 -251
- data/lib/boxen/command.rb +0 -142
- data/lib/boxen/command/help.rb +0 -40
- data/lib/boxen/command/preflight.rb +0 -38
- data/lib/boxen/command/project.rb +0 -49
- data/lib/boxen/command/project/install.rb +0 -33
- data/lib/boxen/command/run.rb +0 -199
- data/lib/boxen/command/service.rb +0 -61
- data/lib/boxen/command/service/disable.rb +0 -15
- data/lib/boxen/command/service/enable.rb +0 -15
- data/lib/boxen/command/service/restart.rb +0 -24
- data/lib/boxen/command/version.rb +0 -29
- data/lib/boxen/command_status.rb +0 -15
- data/lib/boxen/postflight/github_issue.rb +0 -124
- data/lib/boxen/postflight/hooks.rb +0 -16
- data/lib/boxen/postflight/web_hook.rb +0 -63
- data/lib/boxen/preflight/facts.rb +0 -36
- data/lib/boxen/preflight/homebrew.rb +0 -13
- data/lib/boxen/preflight/offline.rb +0 -33
- data/lib/boxen/preflight/update.rb +0 -109
- data/lib/boxen/util/logging.rb +0 -59
- data/lib/boxen/version.rb +0 -3
- data/lib/system_timer.rb +0 -13
- data/test/boxen_command_test.rb +0 -93
- data/test/boxen_hook_test.rb +0 -25
- data/test/command/help_test.rb +0 -49
- data/test/command/project/install_test.rb +0 -34
- data/test/command/project_test.rb +0 -32
- data/test/command/run_test.rb +0 -21
- data/test/command/service/disable_test.rb +0 -49
- data/test/command/service/enable_test.rb +0 -49
- data/test/command/service/restart_test.rb +0 -53
- data/test/command/service_test.rb +0 -55
- data/test/command/version_test.rb +0 -15
- data/test/preflight/boxen_preflight_creds_test.rb +0 -82
- data/test/preflight/boxen_preflight_homebrew_test.rb +0 -10
- data/test/system_timer.rb +0 -10
@@ -1,109 +0,0 @@
|
|
1
|
-
require "boxen/preflight"
|
2
|
-
|
3
|
-
class Boxen::Preflight::Update < Boxen::Preflight
|
4
|
-
def ok?
|
5
|
-
if config.offline?
|
6
|
-
warn "Skipping update because we're offline."
|
7
|
-
|
8
|
-
elsif no_pull?
|
9
|
-
debug "Skipping update because we were asked to by the --no-pull flag"
|
10
|
-
|
11
|
-
elsif !on_branch?
|
12
|
-
warn "Boxen not on a branch (ref: #{ref}), cannot update!"
|
13
|
-
|
14
|
-
elsif !on_master_branch?
|
15
|
-
local_branch = current_branch.rpartition("/").last
|
16
|
-
warn "Boxen on a non-master branch '#{local_branch}', cannot update!"
|
17
|
-
|
18
|
-
elsif !fast_forwardable?
|
19
|
-
warn "Boxen has unpushed changes, cannot update!"
|
20
|
-
|
21
|
-
elsif !clean_tree?
|
22
|
-
warn "Boxen repo has untracked or uncommitted changes, cannot update!"
|
23
|
-
|
24
|
-
else
|
25
|
-
update!
|
26
|
-
end
|
27
|
-
|
28
|
-
true
|
29
|
-
end
|
30
|
-
|
31
|
-
def run
|
32
|
-
abort "Auto-update of Boxen FAILED, please fix manually."
|
33
|
-
end
|
34
|
-
|
35
|
-
private
|
36
|
-
|
37
|
-
def ref
|
38
|
-
%x(git log -1 --pretty=format:%h)
|
39
|
-
end
|
40
|
-
|
41
|
-
def fetch
|
42
|
-
"git fetch --quiet origin"
|
43
|
-
end
|
44
|
-
|
45
|
-
def reset_hard
|
46
|
-
"git reset --hard origin/master 2>&1 >/dev/null"
|
47
|
-
end
|
48
|
-
|
49
|
-
def clean
|
50
|
-
"git clean -qdf"
|
51
|
-
end
|
52
|
-
|
53
|
-
def update_boxen_checkout
|
54
|
-
%x(#{reset} && #{clean})
|
55
|
-
$? == 0
|
56
|
-
end
|
57
|
-
|
58
|
-
def on_branch?
|
59
|
-
!current_branch.empty?
|
60
|
-
end
|
61
|
-
|
62
|
-
def on_master_branch?
|
63
|
-
current_branch == "refs/heads/master"
|
64
|
-
end
|
65
|
-
|
66
|
-
def clean_tree?
|
67
|
-
%x(git status --porcelain).chomp.empty?
|
68
|
-
end
|
69
|
-
|
70
|
-
def upstream_changes?
|
71
|
-
%x(git rev-list --count HEAD..origin/master).chomp != "0"
|
72
|
-
end
|
73
|
-
|
74
|
-
def no_pull?
|
75
|
-
ARGV.any? { |arg| arg == "--no-pull" }
|
76
|
-
end
|
77
|
-
|
78
|
-
def fast_forwardable?
|
79
|
-
%x(git rev-list --count origin/master..master).chomp == "0"
|
80
|
-
end
|
81
|
-
|
82
|
-
def current_branch
|
83
|
-
@current_branch ||= %x(git symbolic-ref HEAD).chomp
|
84
|
-
end
|
85
|
-
|
86
|
-
def update!
|
87
|
-
info "Updating boxen..."
|
88
|
-
fetch
|
89
|
-
|
90
|
-
if !upstream_changes?
|
91
|
-
info "Boxen is up-to-date with origin/master"
|
92
|
-
|
93
|
-
elsif update_boxen_checkout
|
94
|
-
info "Successfully updated to #{ref}"
|
95
|
-
rerun_boxen
|
96
|
-
|
97
|
-
else
|
98
|
-
warn "Failed to auto-update!"
|
99
|
-
false
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
def rerun_boxen
|
104
|
-
command = "#{$0} #{ARGV.join ' '} --no-pull"
|
105
|
-
debug "Re-running boxen:"
|
106
|
-
debug " #{command.inspect}"
|
107
|
-
exec command
|
108
|
-
end
|
109
|
-
end
|
data/lib/boxen/util/logging.rb
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
require "ansi"
|
2
|
-
|
3
|
-
module Boxen
|
4
|
-
module Util
|
5
|
-
module Logging
|
6
|
-
|
7
|
-
# A fancier `abort` and `warn`. This will probably really annoy
|
8
|
-
# someone at some point because it's overriding a Kernel method,
|
9
|
-
# but it's limited to checks.
|
10
|
-
|
11
|
-
alias :fail :abort
|
12
|
-
|
13
|
-
def abort(message, *extras)
|
14
|
-
extras << { :color => :red, :stream => $stderr }
|
15
|
-
log "FAIL: #{message}", *extras
|
16
|
-
exit 1
|
17
|
-
end
|
18
|
-
|
19
|
-
def warn(message, *extras)
|
20
|
-
extras << { :color => :yellow, :stream => $stderr }
|
21
|
-
log "--> #{message}", *extras
|
22
|
-
end
|
23
|
-
|
24
|
-
def info(message, *extras)
|
25
|
-
extras << { :color => :cyan }
|
26
|
-
log "--> #{message}", *extras
|
27
|
-
end
|
28
|
-
|
29
|
-
def debug(message, *extras)
|
30
|
-
if debug?
|
31
|
-
extras << { :color => :white }
|
32
|
-
log " DEBUG: #{message}", *extras
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def log(message, *extras)
|
37
|
-
options = Hash === extras.last ? extras.pop : {}
|
38
|
-
|
39
|
-
stream = options[:stream] || $stdout
|
40
|
-
|
41
|
-
if color = options[:color]
|
42
|
-
stream.puts ANSI.send(color) { message }
|
43
|
-
else
|
44
|
-
stream.puts message
|
45
|
-
end
|
46
|
-
|
47
|
-
unless extras.empty?
|
48
|
-
extras.each { |line| stream.puts " #{line}" }
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def debug?
|
53
|
-
false
|
54
|
-
end
|
55
|
-
|
56
|
-
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
data/lib/boxen/version.rb
DELETED
data/lib/system_timer.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
# Faraday helpfully reminds you to install `system_timer` if you're
|
2
|
-
# running Ruby 1.8, since Timeout can give unreliable results. We
|
3
|
-
# can't do this during first-time runs, since there's no C compiler
|
4
|
-
# available.
|
5
|
-
#
|
6
|
-
# To squash the message and stop confusing people, this shim just
|
7
|
-
# exposes Timeout as SystemTimer. I'm a bad person.
|
8
|
-
|
9
|
-
|
10
|
-
if (!defined?(RUBY_ENGINE) || "ruby" == RUBY_ENGINE) && RUBY_VERSION < '1.9'
|
11
|
-
require "timeout"
|
12
|
-
SystemTimer = Timeout
|
13
|
-
end
|
data/test/boxen_command_test.rb
DELETED
@@ -1,93 +0,0 @@
|
|
1
|
-
require "boxen/command"
|
2
|
-
|
3
|
-
class Failing < Boxen::Check
|
4
|
-
def initialize(*args); end
|
5
|
-
def ok?; false; end
|
6
|
-
def run; warn "lol this fails in ur face"; end
|
7
|
-
end
|
8
|
-
|
9
|
-
class Boxen::Command::Foo < Boxen::Command
|
10
|
-
def run
|
11
|
-
puts "foo"
|
12
|
-
Boxen::CommandStatus.new(0)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
class Boxen::Command::Barnette < Boxen::Command
|
17
|
-
preflight Failing
|
18
|
-
|
19
|
-
def run
|
20
|
-
puts "bar"
|
21
|
-
Boxen::CommandStatus.new(0)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
class Boxen::Command::Atmos < Boxen::Command
|
26
|
-
postflight Failing
|
27
|
-
|
28
|
-
def run
|
29
|
-
puts "hello, cindarella"
|
30
|
-
Boxen::CommandStatus.new(0)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe Boxen::Command do
|
35
|
-
before do
|
36
|
-
@config = Minitest::Mock.new
|
37
|
-
def @config.debug?; false; end
|
38
|
-
end
|
39
|
-
|
40
|
-
it "registers commands and shoves them into a hash, and can invoke them" do
|
41
|
-
Boxen::Command.register :foo, Boxen::Command::Foo
|
42
|
-
|
43
|
-
stdout, _ = capture_io do
|
44
|
-
Boxen::Command.invoke :foo, @config
|
45
|
-
end
|
46
|
-
|
47
|
-
assert_match "foo", stdout
|
48
|
-
end
|
49
|
-
|
50
|
-
it "fails with UnknownCommandError if the invoked command is not registered" do
|
51
|
-
assert_raises Boxen::Command::UnknownCommandError do
|
52
|
-
Boxen::Command.invoke :random_command
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
it "fails with UnknownCommandError if the invoked command is nil" do
|
57
|
-
assert_raises Boxen::Command::UnknownCommandError do
|
58
|
-
Boxen::Command.invoke nil
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
it "registers command aliases" do
|
63
|
-
Boxen::Command.register :foo, Boxen::Command::Foo, :bar
|
64
|
-
|
65
|
-
stdout, _ = capture_io do
|
66
|
-
Boxen::Command.invoke :bar, @config
|
67
|
-
end
|
68
|
-
|
69
|
-
assert_match "foo", stdout
|
70
|
-
end
|
71
|
-
|
72
|
-
it "executes preflight hooks" do
|
73
|
-
Boxen::Command.register :barnette, Boxen::Command::Barnette
|
74
|
-
|
75
|
-
stdout, stderr = capture_io do
|
76
|
-
Boxen::Command.invoke :barnette, @config
|
77
|
-
end
|
78
|
-
|
79
|
-
assert_match "lol this fails in ur face", stderr
|
80
|
-
refute_match "bar", stdout
|
81
|
-
end
|
82
|
-
|
83
|
-
it "executes postflight hooks" do
|
84
|
-
Boxen::Command.register :atmos, Boxen::Command::Atmos
|
85
|
-
|
86
|
-
stdout, stderr = capture_io do
|
87
|
-
Boxen::Command.invoke :atmos, @config
|
88
|
-
end
|
89
|
-
|
90
|
-
assert_match "lol this fails in ur face", stderr
|
91
|
-
assert_match "hello, cindarella", stdout
|
92
|
-
end
|
93
|
-
end
|
data/test/boxen_hook_test.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
require "boxen/hook"
|
2
|
-
|
3
|
-
class DatHook < Boxen::Hook
|
4
|
-
def enabled?
|
5
|
-
true
|
6
|
-
end
|
7
|
-
|
8
|
-
def run
|
9
|
-
puts "yolo"
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
describe Boxen::Hook do
|
14
|
-
|
15
|
-
it "registers hooks and executes them" do
|
16
|
-
Boxen::Hook.register DatHook
|
17
|
-
|
18
|
-
stdout, _ = capture_io do
|
19
|
-
Boxen::Hook.run
|
20
|
-
end
|
21
|
-
|
22
|
-
assert_equal "yolo\n", stdout
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
data/test/command/help_test.rb
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
require "boxen/command/help"
|
2
|
-
|
3
|
-
class FooBar
|
4
|
-
def self.detailed_help
|
5
|
-
"okay fine I'll help you"
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.help
|
9
|
-
"help yourself"
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
class BarBaz
|
14
|
-
def self.help
|
15
|
-
"no you"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe Boxen::Command::Help do
|
20
|
-
before do
|
21
|
-
@config = mock("config")
|
22
|
-
|
23
|
-
Boxen::Command.reset!
|
24
|
-
Boxen::Command.register :foo_bar, FooBar
|
25
|
-
Boxen::Command.register :bar_baz, BarBaz
|
26
|
-
Boxen::Command.register :help, Boxen::Command::Help
|
27
|
-
end
|
28
|
-
|
29
|
-
after do
|
30
|
-
Boxen::Command.reset!
|
31
|
-
end
|
32
|
-
|
33
|
-
it "can write help for all commands" do
|
34
|
-
stdout, _ = capture_io do
|
35
|
-
Boxen::Command.invoke(:help, @config)
|
36
|
-
end
|
37
|
-
|
38
|
-
assert_match " foo_bar help yourself", stdout
|
39
|
-
assert_match " bar_baz no you", stdout
|
40
|
-
end
|
41
|
-
|
42
|
-
it "can write detailed help for a single command" do
|
43
|
-
stdout, _ = capture_io do
|
44
|
-
Boxen::Command.invoke(:help, @config, "foo_bar")
|
45
|
-
end
|
46
|
-
|
47
|
-
assert_match "okay fine I'll help you", stdout
|
48
|
-
end
|
49
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require "boxen/command/project/install"
|
2
|
-
require "tmpdir"
|
3
|
-
|
4
|
-
describe Boxen::Command::Project::Install do
|
5
|
-
before do
|
6
|
-
@config = mock("config")
|
7
|
-
end
|
8
|
-
|
9
|
-
describe "#run" do
|
10
|
-
before do
|
11
|
-
Boxen::Command.expects(:invoke).with('run', @config)
|
12
|
-
end
|
13
|
-
|
14
|
-
it "installs a single project" do
|
15
|
-
Dir.mktmpdir { |dir|
|
16
|
-
@config.stubs(:repodir).returns(dir)
|
17
|
-
Boxen::Command::Project::Install.new(@config, 'awesome-project').run
|
18
|
-
|
19
|
-
projects = File.read("#{dir}/.projects")
|
20
|
-
assert_equal projects, "awesome-project"
|
21
|
-
}
|
22
|
-
end
|
23
|
-
|
24
|
-
it "installs multiple projects" do
|
25
|
-
Dir.mktmpdir { |dir|
|
26
|
-
@config.stubs(:repodir).returns(dir)
|
27
|
-
Boxen::Command::Project::Install.new(@config, 'awesome-project', 'better-project').run
|
28
|
-
|
29
|
-
projects = File.read("#{dir}/.projects")
|
30
|
-
assert_equal projects, "awesome-project,better-project"
|
31
|
-
}
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
require "boxen/command/project"
|
2
|
-
|
3
|
-
describe Boxen::Command::Project do
|
4
|
-
before do
|
5
|
-
@config = mock("config")
|
6
|
-
end
|
7
|
-
|
8
|
-
describe "#run" do
|
9
|
-
before do
|
10
|
-
@config.stubs(:projects).returns([
|
11
|
-
mock("project-a", :name => "puppet-boxen"),
|
12
|
-
mock("project-b", :name => "puppet-ruby")
|
13
|
-
])
|
14
|
-
end
|
15
|
-
|
16
|
-
it "displays the projects we know about" do
|
17
|
-
stdout, _ = capture_io do
|
18
|
-
Boxen::Command::Project.new(@config).run
|
19
|
-
end
|
20
|
-
|
21
|
-
assert_equal stdout, <<-EOS
|
22
|
-
Boxen knows about the following projects:
|
23
|
-
|
24
|
-
puppet-boxen
|
25
|
-
puppet-ruby
|
26
|
-
|
27
|
-
You can install any of them by running \"boxen project:install <project>\"
|
28
|
-
|
29
|
-
EOS
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
data/test/command/run_test.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
require "boxen/command/run"
|
2
|
-
|
3
|
-
describe Boxen::Command::Run do
|
4
|
-
before do
|
5
|
-
@config = mock("config")
|
6
|
-
end
|
7
|
-
|
8
|
-
it "should enable puppet reports" do
|
9
|
-
command = Boxen::Command::Run.new(@config, "--report")
|
10
|
-
assert command.report?
|
11
|
-
end
|
12
|
-
it "should enable puppet profiling" do
|
13
|
-
command = Boxen::Command::Run.new(@config, "--profile")
|
14
|
-
assert command.profile?
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should enable puppet's future parser" do
|
18
|
-
command = Boxen::Command::Run.new(@config, "--future-parser")
|
19
|
-
assert command.future_parser?
|
20
|
-
end
|
21
|
-
end
|