boxen 0.0.0 → 0.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.
data/Gemfile.lock CHANGED
@@ -5,6 +5,7 @@ PATH
5
5
  ansi (~> 1.4)
6
6
  highline (~> 1.6)
7
7
  json_pure (~> 1.7)
8
+ librarian-puppet (~> 0.9)
8
9
  octokit (~> 1.15)
9
10
  puppet (~> 3.0)
10
11
 
@@ -24,6 +25,10 @@ GEM
24
25
  highline (1.6.15)
25
26
  json (1.7.5)
26
27
  json_pure (1.7.5)
28
+ librarian-puppet (0.9.5)
29
+ json
30
+ puppet
31
+ thor (~> 0.15)
27
32
  metaclass (0.0.1)
28
33
  minitest (3.5.0)
29
34
  mocha (0.12.6)
@@ -39,6 +44,7 @@ GEM
39
44
  puppet (3.0.0)
40
45
  facter (>= 1.6.11)
41
46
  hiera (>= 1.0.0rc)
47
+ thor (0.16.0)
42
48
 
43
49
  PLATFORMS
44
50
  ruby
data/boxen.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = "boxen"
5
- gem.version = "0.0.0"
5
+ gem.version = "0.1.0"
6
6
  gem.authors = ["John Barnette", "Will Farrington"]
7
7
  gem.email = ["jbarnette@github.com", "wfarr@github.com"]
8
8
  gem.description = "Manage Mac development boxes with love (and Puppet)."
@@ -13,11 +13,12 @@ Gem::Specification.new do |gem|
13
13
  gem.test_files = gem.files.grep /^test/
14
14
  gem.require_paths = ["lib"]
15
15
 
16
- gem.add_dependency "ansi", "~> 1.4"
17
- gem.add_dependency "highline", "~> 1.6"
18
- gem.add_dependency "json_pure", "~> 1.7"
19
- gem.add_dependency "octokit", "~> 1.15"
20
- gem.add_dependency "puppet", "~> 3.0"
16
+ gem.add_dependency "ansi", "~> 1.4"
17
+ gem.add_dependency "highline", "~> 1.6"
18
+ gem.add_dependency "json_pure", "~> 1.7"
19
+ gem.add_dependency "librarian-puppet", "~> 0.9"
20
+ gem.add_dependency "octokit", "~> 1.15"
21
+ gem.add_dependency "puppet", "~> 3.0"
21
22
 
22
23
  gem.add_development_dependency "minitest", "3.5.0" # pinned for mocha
23
24
  gem.add_development_dependency "mocha", "~> 0.12"
data/lib/boxen/cli.rb CHANGED
@@ -3,6 +3,7 @@ require "boxen/flags"
3
3
  require "boxen/postflight"
4
4
  require "boxen/preflight"
5
5
  require "boxen/puppeteer"
6
+ require "boxen/util"
6
7
 
7
8
  module Boxen
8
9
  class CLI
@@ -37,9 +38,10 @@ module Boxen
37
38
  exit
38
39
  end
39
40
 
40
- status = puppet.run
41
+ # Actually run Puppet and return its exit code. FIX: Here's
42
+ # where we'll reintegrate automatic error reporting.
41
43
 
42
- return status
44
+ return puppet.run
43
45
  end
44
46
 
45
47
  # Run Boxen by wiring together the command-line flags, config,
@@ -59,6 +61,11 @@ module Boxen
59
61
 
60
62
  Boxen::Preflight.run config
61
63
 
64
+ # Okay, we're gonna run Puppet. Let's make some dirs.
65
+
66
+ Boxen::Util.sudo("mkdir", "-p", config.homedir) &&
67
+ Boxen::Util.sudo("chown", "#{config.user}:staff", config.homedir)
68
+
62
69
  # Save the config for Puppet (and next time).
63
70
 
64
71
  Boxen::Config.save config
data/lib/boxen/config.rb CHANGED
@@ -55,6 +55,7 @@ module Boxen
55
55
  :puppetdir => config.puppetdir,
56
56
  :repodir => config.repodir,
57
57
  :srcdir => config.srcdir,
58
+ :token => config.token,
58
59
  :user => config.user
59
60
  }
60
61
 
@@ -240,6 +241,10 @@ module Boxen
240
241
 
241
242
  attr_writer :stealth
242
243
 
244
+ # A GitHub OAuth token. Default is `nil`.
245
+
246
+ attr_accessor :token
247
+
243
248
  # A local user login. Default is the `USER` environment variable.
244
249
 
245
250
  def user
@@ -1,5 +1,6 @@
1
- require "highline"
2
1
  require "boxen/preflight"
2
+ require "highline"
3
+ require "octokit"
3
4
 
4
5
  # HACK: Unless this is `false`, HighLine has some really bizarre
5
6
  # problems with empty/expended streams at bizarre intervals.
@@ -7,10 +8,23 @@ require "boxen/preflight"
7
8
  HighLine.track_eof = false
8
9
 
9
10
  class Boxen::Preflight::Creds < Boxen::Preflight
10
- def ok?
11
+ def basic?
11
12
  config.api.user rescue nil
12
13
  end
13
14
 
15
+ def ok?
16
+ basic? && token?
17
+ end
18
+
19
+ def token?
20
+ return unless config.token
21
+
22
+ tapi = Octokit::Client.new \
23
+ :login => config.login, :oauth_token => config.token
24
+
25
+ tapi.user rescue nil
26
+ end
27
+
14
28
  def run
15
29
  console = HighLine.new
16
30
 
@@ -24,11 +38,22 @@ class Boxen::Preflight::Creds < Boxen::Preflight
24
38
  q.echo = "*"
25
39
  end
26
40
 
27
- unless ok?
41
+ unless basic?
28
42
  puts # i <3 vertical whitespace
29
43
 
30
44
  abort "Sorry, I can't auth you on GitHub.",
31
45
  "Please check your credentials and teams and give it another try."
32
46
  end
47
+
48
+ # Okay, the basic creds are good, let's deal with an OAuth token.
49
+
50
+ unless auth = config.api.authorizations.detect { |a| a.note == "Boxen" }
51
+ auth = config.api.create_authorization \
52
+ :note => "Boxen", :scopes => %w(repo user)
53
+ end
54
+
55
+ # Reset the token for later.
56
+
57
+ config.token = auth.token
33
58
  end
34
59
  end
@@ -0,0 +1,12 @@
1
+ require "boxen/preflight"
2
+
3
+ class Boxen::Preflight::RVM < Boxen::Preflight
4
+ def run
5
+ abort "You have an rvm installed in ~/.rvm.",
6
+ "The Setup uses rbenv to install ruby, so please `rvm implode`"
7
+ end
8
+
9
+ def ok?
10
+ !File.exist? "#{ENV['HOME']}/.rvm"
11
+ end
12
+ end
@@ -25,7 +25,8 @@ module Boxen
25
25
 
26
26
  flags << ["--confdir", "#{config.puppetdir}/conf"]
27
27
  flags << ["--vardir", "#{config.puppetdir}/var"]
28
- flags << ["--libdir", "#{config.repodir}/lib"]
28
+ flags << ["--libdir", "#{config.repodir}/lib"]#:#{root}/lib"]
29
+ flags << ["--libdir", "#{root}/lib"]
29
30
  flags << ["--manifestdir", "#{config.repodir}/manifests"]
30
31
  flags << ["--modulepath", "#{config.repodir}/modules:#{config.repodir}/shared"]
31
32
 
@@ -59,6 +60,19 @@ module Boxen
59
60
  FileUtils.mkdir_p File.dirname config.logfile
60
61
  FileUtils.touch config.logfile
61
62
 
63
+ if File.file? "Puppetfile"
64
+ librarian = "#{config.repodir}/bin/librarian-puppet"
65
+
66
+ # Set an environment variable for librarian-puppet's
67
+ # github_tarball source strategy.
68
+
69
+ ENV["GITHUB_API_TOKEN"] = config.token
70
+
71
+ unless system librarian, "install", "--path=#{config.repodir}/shared"
72
+ abort "Can't run Puppet, fetching dependencies with librarian failed."
73
+ end
74
+ end
75
+
62
76
  warn command.join " " if config.debug?
63
77
  Boxen::Util.sudo *command
64
78
 
@@ -0,0 +1,22 @@
1
+ require "json"
2
+ require "boxen/config"
3
+
4
+ config = Boxen::Config.load
5
+ facts = {}
6
+ factsdir = File.join config.homedir, "config", "facts"
7
+
8
+ facts["github_login"] = config.login
9
+ facts["github_email"] = config.email
10
+ facts["github_name"] = config.name
11
+ facts["github_token"] = config.token
12
+
13
+ facts["boxen_home"] = config.homedir
14
+ facts["boxen_srcdir"] = config.srcdir
15
+
16
+ facts["luser"] = config.user
17
+
18
+ Dir["#{config.homedir}/config/facts/*.json"].each do |file|
19
+ facts.merge! JSON.parse File.read file
20
+ end
21
+
22
+ facts.each { |k, v| Facter.add(k) { setcode { v } } }
data/script/release ADDED
@@ -0,0 +1,30 @@
1
+ #!/bin/sh
2
+ # Tag and push a release.
3
+
4
+ set -e
5
+
6
+ # Make sure we're in the project root.
7
+
8
+ cd $(dirname "$0")/..
9
+
10
+ # Build a new gem archive.
11
+
12
+ rm boxen-*.gem
13
+ gem build -q boxen.gemspec
14
+
15
+ # Figure out what version we're releasing.
16
+
17
+ tag=v`ls boxen-*.gem | sed 's/^boxen-\(.*\)\.gem$/\1/'`
18
+
19
+ # Make sure we haven't released this version before.
20
+
21
+ git fetch -t origin
22
+
23
+ (git tag -l | grep "$tag") && {
24
+ echo "Whoops, there's already a '${tag}' tag."
25
+ exit 1
26
+ }
27
+
28
+ # Tag it and bag it.
29
+
30
+ gem push boxen-*.gem && git tag "$tag" && git push origin --tags
@@ -147,6 +147,13 @@ def test_initialize
147
147
  assert @config.stealth?
148
148
  end
149
149
 
150
+ def test_token
151
+ assert_nil @config.token
152
+
153
+ @config.token = "foo"
154
+ assert_equal "foo", @config.token
155
+ end
156
+
150
157
  def test_user
151
158
  ENV.expects(:[]).with("USER").returns "foo"
152
159
  assert_equal "foo", @config.user
@@ -0,0 +1,10 @@
1
+ require 'boxen/test'
2
+ require 'boxen/preflight/rvm'
3
+
4
+ class BoxenPreflightRVMTest < Boxen::Test
5
+ def test_directory_check
6
+ preflight = Boxen::Preflight::RVM.new(mock('config'))
7
+ File.expects(:exist?).with("#{ENV['HOME']}/.rvm").returns(false)
8
+ assert preflight.ok?
9
+ end
10
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boxen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -60,6 +60,22 @@ dependencies:
60
60
  - - ~>
61
61
  - !ruby/object:Gem::Version
62
62
  version: '1.7'
63
+ - !ruby/object:Gem::Dependency
64
+ name: librarian-puppet
65
+ requirement: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ~>
69
+ - !ruby/object:Gem::Version
70
+ version: '0.9'
71
+ type: :runtime
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ~>
77
+ - !ruby/object:Gem::Version
78
+ version: '0.9'
63
79
  - !ruby/object:Gem::Dependency
64
80
  name: octokit
65
81
  requirement: !ruby/object:Gem::Requirement
@@ -153,10 +169,13 @@ files:
153
169
  - lib/boxen/preflight/identity.rb
154
170
  - lib/boxen/preflight/os.rb
155
171
  - lib/boxen/preflight/rbenv.rb
172
+ - lib/boxen/preflight/rvm.rb
156
173
  - lib/boxen/project.rb
157
174
  - lib/boxen/puppeteer.rb
158
175
  - lib/boxen/util.rb
176
+ - lib/facter/boxen.rb
159
177
  - script/bootstrap
178
+ - script/release
160
179
  - script/tests
161
180
  - test/boxen/test.rb
162
181
  - test/boxen_check_test.rb
@@ -165,6 +184,7 @@ files:
165
184
  - test/boxen_flags_test.rb
166
185
  - test/boxen_postflight_active_test.rb
167
186
  - test/boxen_postflight_env_test.rb
187
+ - test/boxen_preflight_rvm_test.rb
168
188
  - test/boxen_project_test.rb
169
189
  - test/boxen_puppeteer_test.rb
170
190
  - test/boxen_util_test.rb
@@ -203,6 +223,7 @@ test_files:
203
223
  - test/boxen_flags_test.rb
204
224
  - test/boxen_postflight_active_test.rb
205
225
  - test/boxen_postflight_env_test.rb
226
+ - test/boxen_preflight_rvm_test.rb
206
227
  - test/boxen_project_test.rb
207
228
  - test/boxen_puppeteer_test.rb
208
229
  - test/boxen_util_test.rb