bib-vagrant 0.1.1 → 0.1.2

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 CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MDc0MzRhOTYzNGU2OTliYWE2Y2ZlMGMyNDFhZWIwOTMyZTFhMzRkNA==
5
- data.tar.gz: !binary |-
6
- MzY5N2VmMDU4NDFjOTZkZDc1ODQ2NmI1YjVkMmVhZWQzZTI2NThhNA==
2
+ SHA1:
3
+ metadata.gz: e61e6e30152c53c0beb8c47629d5ab6c02a20131
4
+ data.tar.gz: 20110d8627d95de0556d45585f2fe657b2fe10d4
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- ZjZlZWExZmIwOTA0Njg0M2Q0YTY2N2ZkZDUwNTZhZDUxMWYyNDg5YTBjMThm
10
- Nzk3ZGE0YTBmMjJiNjk4ZGM4NDU4Nzk0NDMwNmRmMjYwNzcyMDczODMxNGYz
11
- YjRhYTg1ODc3NGMxNTRiYWY1NjgyODFhODA2MDVmZmQ1OWZjNTY=
12
- data.tar.gz: !binary |-
13
- MTkzYTE3NmEyZTdhMWI1NzA0YjdmM2NmYWVhY2Q4NjM1ZTE3OGY1ZDA4ZWYx
14
- NDI5NjM3MjMwOGJhOWRmOGZjYjk3MjllMDEyNWFjODVlMjk5OWFkYWU0YmU4
15
- MGMwYTlkMDQ0YzBiYmYyYjlmNTY2MmU0Y2MyNDgyMTllZDRmYjA=
6
+ metadata.gz: 4e2981e65dcd8d39210e4c71d32128e23427d987aaf170e80349266f5b415db0375f454eb59847500406e626ffd01b692cbbb6687f17ff55098af46e596e0610
7
+ data.tar.gz: 0c7f5978c96ad4e529d50ccb68f40a42893eeda13820c7d8e9ba73681909c76b6867450a37f5139c9d8f4a9a26a47f6eed666b5b0fa3d2c9d6670549013b7044
data/.gitignore CHANGED
@@ -1,5 +1,6 @@
1
1
  *.gem
2
2
  *.rbc
3
+ .vagrant
3
4
  .bundle
4
5
  .config
5
6
  .yardoc
data/.travis.yml CHANGED
@@ -1,3 +1,4 @@
1
+ sudo: false
1
2
  language: ruby
2
3
  rvm:
3
4
  - 1.9.3
data/CONTRIBUTING.md CHANGED
@@ -6,3 +6,7 @@
6
6
  4. Push to the branch (`git push origin my-new-feature`)
7
7
  5. Create new Pull Request
8
8
 
9
+ # publishing new release
10
+
11
+ Use `rake release` to tag & publish a new release
12
+
data/Gemfile CHANGED
@@ -5,5 +5,12 @@ source 'https://rubygems.org'
5
5
  gemspec
6
6
 
7
7
  group :development do
8
- gem "vagrant", git: "git://github.com/mitchellh/vagrant.git", tag: "v1.3.5"
8
+ gem "vagrant", git: "https://github.com/mitchellh/vagrant.git"
9
+ # gem "vagrant", git: "git://github.com/mitchellh/vagrant.git", tag: "v1.7.4"
10
+ # gem "vagrant", git: "git://github.com/mitchellh/vagrant.git", tag: "v1.3.5"
9
11
  end
12
+
13
+ group :plugins do
14
+ gem "bib-vagrant", path: "."
15
+ end
16
+
data/README.md CHANGED
@@ -43,6 +43,23 @@ additional_json: ! '{}'
43
43
 
44
44
  #Show Virtualbox GUI
45
45
  gui: false
46
+
47
+ # Token to use with composer
48
+ composer_github_token: <github token>
49
+
50
+ # npm proxy in the form of "http://npm-proxy.tld/"
51
+ npm_registry: <npm registry or proxy url>
52
+
53
+ # your npm user email address in the form of user@domain.tld
54
+ npm_username: <github or npm username>
55
+
56
+ # your npm or user email address in the form of user@domain.tld
57
+ npm_usermail: <npm or github users email address>
58
+
59
+ # Authentication Token to use with npm
60
+ npm_userpass: <npm or github authentication token>
61
+
62
+
46
63
  ```
47
64
 
48
65
  Additional parameters can be added to the file and used in the Vagrantfile - but you then have to make sure to use sensible fallback defaults in your Vagrantfile, since not every developer might have this setting in the .yml.
@@ -75,7 +92,9 @@ Vagrant.configure("2") do |config|
75
92
  chef.add_recipe "something::here"
76
93
  chef.log_level = vagrantconfig["chef_log_level"]
77
94
  end
78
-
95
+
96
+ web_config.vm.provision "bib_configure_npm"
97
+
79
98
  end
80
99
  ```
81
100
 
@@ -88,6 +107,11 @@ cookbook_path: ~/Documents/workspaces/easybib-cookbooks
88
107
  chef_log_level: debug
89
108
  additional_json: ! '{}'
90
109
  gui: true
110
+ composer_github_token: <github token>
111
+ npm_registry: <npm registry or proxy url>
112
+ npm_username: <github or npm username>
113
+ npm_usermail: <npm or github users email address>
114
+ npm_userpass: <npm or github authentication token>
91
115
  ```
92
116
 
93
117
  ## Contributing
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
- require "coveralls"
1
+ require 'coveralls'
2
2
  Coveralls.wear!
3
3
 
4
+ ## Bundler::GemHelper.install_tasks
5
+
4
6
  require "bundler/gem_tasks"
5
7
  require "minitest/autorun"
6
8
 
data/Vagrantfile CHANGED
@@ -1,7 +1,30 @@
1
- Vagrant.require_plugin "bib-vagrant"
2
1
 
3
2
  Vagrant.configure("2") do |config|
4
- foo = ::Bib::Vagrant::Config.new()
3
+ foo = Bib::Vagrant::Config.new()
5
4
  puts foo.get.inspect
6
- config.vm.box = "precise"
5
+
6
+ # for testing ubuntu 14.04
7
+ config.vm.box = 'trusty-server-cloudimg-amd64-vagrant-disk1.box'
8
+ config.vm.box_url = 'https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box'
9
+
10
+ # for testing ubuntu 15.04
11
+ # config.vm.box = 'vivid-server-cloudimg-amd64-vagrant-disk1.box'
12
+ # config.vm.box_url = 'https://cloud-images.ubuntu.com/vagrant/vivid/current/vivid-server-cloudimg-amd64-vagrant-disk1.box'
13
+
14
+ # config.vm.provision :shell, :path => 'apt-spy-2-bootstrap.sh'
15
+
16
+ config.vm.provision 'shell', inline: 'sudo apt-get -y update'
17
+
18
+ # for testing the latest greatest npm
19
+ # config.vm.provision 'shell', inline: 'sudo apt-get -y install curl'
20
+ # config.vm.provision 'shell', inline: 'curl -sL https://deb.nodesource.com/setup_0.12 | sudo bash -'
21
+
22
+ config.vm.provision 'shell', inline: 'sudo apt-get -y install nodejs npm'
23
+
24
+ config.vm.provision 'bib_configure_npm'
25
+
26
+ config.vm.provision 'shell', inline: 'npm config list'
27
+
28
+ config.vm.provision 'shell', inline: 'npm --loglevel silly view test'
29
+
7
30
  end
data/bib-vagrant.gemspec CHANGED
@@ -6,7 +6,7 @@ require 'bib/vagrant/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "bib-vagrant"
8
8
  spec.version = Bib::Vagrant::VERSION
9
- spec.authors = ["tillk", "fh"]
9
+ spec.authors = ["tillk", "fh", "gilleyj"]
10
10
  spec.email = ["till@php.net"]
11
11
  spec.description = "A rubygem to centralize configuration and setup in every project's Vagrantfile"
12
12
  spec.summary = "Centralize configuration and setup"
@@ -20,10 +20,12 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_dependency 'thor', '>= 0.18.1'
22
22
  spec.add_dependency 'colored', '>= 1.2'
23
+ spec.add_dependency 'rest_client'
23
24
  spec.add_dependency 'json'
24
25
 
25
- spec.add_development_dependency "bundler", "~> 1.3"
26
+ spec.add_development_dependency "bundler", "~> 1.5"
26
27
  spec.add_development_dependency "rake"
27
28
  spec.add_development_dependency "minitest", "~> 5.0.8"
28
29
  spec.add_development_dependency "coveralls"
29
30
  end
31
+
@@ -0,0 +1,210 @@
1
+ require 'vagrant'
2
+ require 'rubygems'
3
+ require 'rest_client'
4
+ require 'json'
5
+ require 'base64'
6
+
7
+ # Define the plugin.
8
+ class BibConfigurePlugin < Vagrant.plugin('2')
9
+ name 'NPM configuration Plugin'
10
+
11
+ # This plugin provides a provisioner called unix_reboot.
12
+ provisioner 'bib_configure_npm' do
13
+
14
+ # Create a provisioner.
15
+ class BibConfigureProvisioner < Vagrant.plugin('2', :provisioner)
16
+ # Initialization, define internal state. Nothing needed.
17
+
18
+ attr_reader :bib_config
19
+
20
+ def initialize(machine, config)
21
+ super(machine, config)
22
+ end
23
+
24
+ # Configuration changes to be done. Nothing needed here either.
25
+ def configure(root_config)
26
+ super(root_config)
27
+ end
28
+
29
+ # Run the provisioning.
30
+ def provision
31
+ return unless @machine.communicate.ready?
32
+ bib_config = Bib::Vagrant::Config.new
33
+ bib_config_values = bib_config.get
34
+ bib_config.validate!(bib_config_values)
35
+
36
+ # sneaky fix to "stdin: is not a tty" noise
37
+ # sudo_command("sudo sed -i 's/^mesg n$/tty -s \&\& mesg n/g' /root/.profile")
38
+
39
+ # inbound variables
40
+ registry = false
41
+ username = false
42
+ usermail = false
43
+ userpass = false
44
+
45
+ if bib_config_values.include?('npm_registry')
46
+ registry = bib_config_values['npm_registry'].clone
47
+ end
48
+
49
+ if bib_config_values.include?('npm_username')
50
+ username = bib_config_values['npm_username'].clone
51
+ end
52
+
53
+ if bib_config_values.include?('npm_usermail')
54
+ usermail = bib_config_values['npm_usermail'].clone
55
+ end
56
+
57
+ if bib_config_values.include?('npm_userpass')
58
+ userpass = bib_config_values['npm_userpass'].clone
59
+ end
60
+
61
+ if ( registry && username && usermail && userpass)
62
+ auth_hash = Base64.strict_encode64(username + ':' + userpass)
63
+ auth_token = get_npm_token(registry, username, usermail, userpass)
64
+ if auth_token
65
+ registry_ident = registry.clone
66
+ registry_ident.slice!('http:')
67
+
68
+ npmrc_set('always-auth', 'true')
69
+ npmrc_set('registry', registry)
70
+ npmrc_set('email', usermail)
71
+
72
+ # this seems to break 1.4.x (it gets username from _auth base64)
73
+ # npmrc_set('username', username)
74
+
75
+ # for older npm user/pass hash authentication
76
+ npmrc_set( '_auth', '"' + auth_hash + '"')
77
+
78
+ # for newer npm token authentication
79
+ npmrc_set( registry_ident + ':_authToken', '"' + auth_token + '"')
80
+
81
+ else
82
+ @machine.ui.info("npm registry token request failed. Attempting old style auth configuration.")
83
+ npmrc_set('always-auth', 'true')
84
+ npmrc_set('registry', registry)
85
+ npmrc_set('email', usermail)
86
+
87
+ # this seems to break 1.4.x (it gets username from _auth base64)
88
+ # npmrc_set('username', username)
89
+
90
+ npmrc_set('_auth', auth_hash)
91
+ end
92
+
93
+ else
94
+
95
+ message = ''
96
+ if !registry
97
+ message += " npm_registry"
98
+ end
99
+
100
+ if !username
101
+ message += " npm_username"
102
+ end
103
+
104
+ if !usermail
105
+ message += " npm_userpass"
106
+ end
107
+
108
+ if !userpass
109
+ message += " npm_userpass"
110
+ end
111
+
112
+ @machine.ui.warn("WARNING: Missing " + message + " value(s) in ~/.config/easybib/vagrantdefault.yml (Your HOST OS)")
113
+ @machine.ui.warn("WARNING: .npmrc not setup on guest OS")
114
+ end
115
+
116
+ # if bib_config_values.includ?('composer_github_token')
117
+ # composer_set('github-oauth.github.com', bib_config_values['composer_github_token'])
118
+ # else
119
+ # @machine.ui.warn("Missing composer_github_token value in config")
120
+ # end
121
+
122
+ send_command("mkdir -p ~/.npm/_locks")
123
+ send_command("sudo chown -R $USER ~/.npm")
124
+
125
+ # Now the machine is up again, perform the necessary tasks.
126
+ @machine.ui.info('bib-vagrant config complete...')
127
+ end
128
+
129
+ # def composer_set(key, value)
130
+ # command = "composer config -g #{key} #{value}"
131
+ # sudo_command(command)
132
+ # end
133
+
134
+ def npmrc_set(key, value)
135
+ command = "npm -g config "
136
+ if value
137
+ command << "set #{key} #{value}"
138
+ else
139
+ # if value is null assume a delete
140
+ command << "delete #{key}"
141
+ # fix for npmrc key not existing
142
+ sudo_command("npm -g set #{key} GNDN")
143
+ end
144
+ # do not to echo the command all the time (need if debug?)
145
+ # @machine.ui.info(command)
146
+ sudo_command(command)
147
+ end
148
+
149
+ def send_command(command)
150
+ @machine.communicate.execute(command) do |type, data|
151
+ if type == :stderr
152
+ @machine.ui.warn(data)
153
+ else
154
+ @machine.ui.info(data)
155
+ end
156
+ end
157
+ end
158
+
159
+ def sudo_command(command)
160
+ @machine.communicate.sudo(command) do |type, data|
161
+ if type == :stderr
162
+ @machine.ui.warn(data)
163
+ else
164
+ @machine.ui.info(data)
165
+ end
166
+ end
167
+ end
168
+
169
+ # my nifty function to get an NPM token from the registry
170
+ def get_npm_token(registry_url, username, usermail, userpass)
171
+ # get the date for some reason
172
+ date = Time.now;
173
+ # set up the request _id ???
174
+ _id = 'org.couchdb.user:' + username
175
+ # set up the registry URL to request the token from
176
+ url = registry_url + '-/user/' + _id
177
+ # create json object passed to the registry
178
+ data = { _id: _id ,
179
+ name: username,
180
+ password: userpass,
181
+ email: usermail,
182
+ type: 'user',
183
+ roles: [],
184
+ date: date
185
+ }
186
+ # convert it to json
187
+ jdata = JSON.generate(data)
188
+ # make the request and see if we get a token
189
+ response_json = RestClient.put url, jdata, {:content_type => :json}
190
+ # convert the response to a hash???
191
+ hash = JSON.parse response_json
192
+ # check to see if the key token is there
193
+ if hash.has_key?('token')
194
+ # it is, so return it
195
+ hash['token']
196
+ else
197
+ # it doesn't so return false
198
+ false
199
+ end
200
+ end
201
+
202
+ # Nothing needs to be done on cleanup.
203
+ def cleanup
204
+ super
205
+ end
206
+ end
207
+ BibConfigureProvisioner
208
+ end
209
+ end
210
+
@@ -1,5 +1,5 @@
1
1
  module Bib
2
2
  module Vagrant
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
data/lib/bib-vagrant.rb CHANGED
@@ -4,4 +4,5 @@ rescue LoadError
4
4
  raise "This plugin must be run within Vagrant."
5
5
  end
6
6
 
7
- require "bib/vagrant/plugin"
7
+ require "bib/vagrant/plugin"
8
+ require "bib/vagrant/provisioner"
metadata CHANGED
@@ -1,56 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bib-vagrant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - tillk
8
8
  - fh
9
+ - gilleyj
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2014-05-12 00:00:00.000000000 Z
13
+ date: 2015-10-16 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: thor
16
17
  requirement: !ruby/object:Gem::Requirement
17
18
  requirements:
18
- - - ! '>='
19
+ - - '>='
19
20
  - !ruby/object:Gem::Version
20
21
  version: 0.18.1
21
22
  type: :runtime
22
23
  prerelease: false
23
24
  version_requirements: !ruby/object:Gem::Requirement
24
25
  requirements:
25
- - - ! '>='
26
+ - - '>='
26
27
  - !ruby/object:Gem::Version
27
28
  version: 0.18.1
28
29
  - !ruby/object:Gem::Dependency
29
30
  name: colored
30
31
  requirement: !ruby/object:Gem::Requirement
31
32
  requirements:
32
- - - ! '>='
33
+ - - '>='
33
34
  - !ruby/object:Gem::Version
34
35
  version: '1.2'
35
36
  type: :runtime
36
37
  prerelease: false
37
38
  version_requirements: !ruby/object:Gem::Requirement
38
39
  requirements:
39
- - - ! '>='
40
+ - - '>='
40
41
  - !ruby/object:Gem::Version
41
42
  version: '1.2'
43
+ - !ruby/object:Gem::Dependency
44
+ name: rest_client
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ type: :runtime
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - '>='
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
42
57
  - !ruby/object:Gem::Dependency
43
58
  name: json
44
59
  requirement: !ruby/object:Gem::Requirement
45
60
  requirements:
46
- - - ! '>='
61
+ - - '>='
47
62
  - !ruby/object:Gem::Version
48
63
  version: '0'
49
64
  type: :runtime
50
65
  prerelease: false
51
66
  version_requirements: !ruby/object:Gem::Requirement
52
67
  requirements:
53
- - - ! '>='
68
+ - - '>='
54
69
  - !ruby/object:Gem::Version
55
70
  version: '0'
56
71
  - !ruby/object:Gem::Dependency
@@ -59,26 +74,26 @@ dependencies:
59
74
  requirements:
60
75
  - - ~>
61
76
  - !ruby/object:Gem::Version
62
- version: '1.3'
77
+ version: '1.5'
63
78
  type: :development
64
79
  prerelease: false
65
80
  version_requirements: !ruby/object:Gem::Requirement
66
81
  requirements:
67
82
  - - ~>
68
83
  - !ruby/object:Gem::Version
69
- version: '1.3'
84
+ version: '1.5'
70
85
  - !ruby/object:Gem::Dependency
71
86
  name: rake
72
87
  requirement: !ruby/object:Gem::Requirement
73
88
  requirements:
74
- - - ! '>='
89
+ - - '>='
75
90
  - !ruby/object:Gem::Version
76
91
  version: '0'
77
92
  type: :development
78
93
  prerelease: false
79
94
  version_requirements: !ruby/object:Gem::Requirement
80
95
  requirements:
81
- - - ! '>='
96
+ - - '>='
82
97
  - !ruby/object:Gem::Version
83
98
  version: '0'
84
99
  - !ruby/object:Gem::Dependency
@@ -99,14 +114,14 @@ dependencies:
99
114
  name: coveralls
100
115
  requirement: !ruby/object:Gem::Requirement
101
116
  requirements:
102
- - - ! '>='
117
+ - - '>='
103
118
  - !ruby/object:Gem::Version
104
119
  version: '0'
105
120
  type: :development
106
121
  prerelease: false
107
122
  version_requirements: !ruby/object:Gem::Requirement
108
123
  requirements:
109
- - - ! '>='
124
+ - - '>='
110
125
  - !ruby/object:Gem::Version
111
126
  version: '0'
112
127
  description: A rubygem to centralize configuration and setup in every project's Vagrantfile
@@ -131,6 +146,7 @@ files:
131
146
  - lib/bib/vagrant.rb
132
147
  - lib/bib/vagrant/config.rb
133
148
  - lib/bib/vagrant/plugin.rb
149
+ - lib/bib/vagrant/provisioner.rb
134
150
  - lib/bib/vagrant/version.rb
135
151
  - test/config_test.rb
136
152
  homepage: https://github.com/easybiblabs/bib-vagrant
@@ -143,17 +159,17 @@ require_paths:
143
159
  - lib
144
160
  required_ruby_version: !ruby/object:Gem::Requirement
145
161
  requirements:
146
- - - ! '>='
162
+ - - '>='
147
163
  - !ruby/object:Gem::Version
148
164
  version: '0'
149
165
  required_rubygems_version: !ruby/object:Gem::Requirement
150
166
  requirements:
151
- - - ! '>='
167
+ - - '>='
152
168
  - !ruby/object:Gem::Version
153
169
  version: '0'
154
170
  requirements: []
155
171
  rubyforge_project:
156
- rubygems_version: 2.2.2
172
+ rubygems_version: 2.0.14
157
173
  signing_key:
158
174
  specification_version: 4
159
175
  summary: Centralize configuration and setup