vagrant-devcommands 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.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/.travis.yml +6 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +9 -0
- data/LICENSE.txt +21 -0
- data/README.md +37 -0
- data/Rakefile +26 -0
- data/lib/vagrant/devcommands/_proxy.rb +6 -0
- data/lib/vagrant/devcommands/command.rb +101 -0
- data/lib/vagrant/devcommands/definer.rb +18 -0
- data/lib/vagrant/devcommands/plugin.rb +14 -0
- data/lib/vagrant/devcommands/version.rb +8 -0
- data/lib/vagrant/devcommands.rb +7 -0
- data/vagrant-devcommands.gemspec +35 -0
- metadata +115 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3de3849c6e3d761ca5b178fdc94bf957632e3b78
|
4
|
+
data.tar.gz: eda7f7046ff1ba3ed1f71d36b90acb595d887b4c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 53997668cf426e5f6536a72bd3013807d4fd7209ee2adb58850d54220c1b6071fbfd2e5d7074c87b3fdfb6b5965c3e7de5bf3ffae52137e96fcf26fd430677f9
|
7
|
+
data.tar.gz: 69a93bfdb2e66e45833d4b9ee2164cb3d334ce0b05e3defa4ac954c3bfe659ee7c2ed78c9545364af53a2bea1e61dae15aaf4c6c9291a3284e7d0a13aa7ac598
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015-* Marc Neudert
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# Vagrant DevCommands
|
2
|
+
|
3
|
+
Runs vagrant commands from a Commandfile.
|
4
|
+
|
5
|
+
|
6
|
+
## Command Definition
|
7
|
+
|
8
|
+
Add to a `Commandfile` besides your `Vagrantfile`:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
VagrantDevCommands.define 'with_options', box: :my_box, command: 'hostname'
|
12
|
+
VagrantDevCommands.define 'without_otions', 'hostname'
|
13
|
+
```
|
14
|
+
|
15
|
+
|
16
|
+
## Command Listing
|
17
|
+
|
18
|
+
```shell
|
19
|
+
vagrant run
|
20
|
+
```
|
21
|
+
|
22
|
+
|
23
|
+
## Command Execution
|
24
|
+
|
25
|
+
```shell
|
26
|
+
# single-vm environment
|
27
|
+
# or multi-vm environment with :box option
|
28
|
+
vagrant run your_command
|
29
|
+
|
30
|
+
# multi-vm environment
|
31
|
+
vagrant run your_box your_command
|
32
|
+
```
|
33
|
+
|
34
|
+
|
35
|
+
## License
|
36
|
+
|
37
|
+
Licensed under the [MIT license](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
require 'rubocop/rake_task'
|
4
|
+
|
5
|
+
namespace :style do
|
6
|
+
desc 'Run ruby style checks'
|
7
|
+
|
8
|
+
RuboCop::RakeTask.new(:ruby) do |task|
|
9
|
+
task.patterns = [
|
10
|
+
'**/*.rb',
|
11
|
+
'*.gemspec',
|
12
|
+
'Gemfile',
|
13
|
+
'Rakefile'
|
14
|
+
]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
namespace :test do
|
19
|
+
desc 'Run tests'
|
20
|
+
|
21
|
+
RSpec::Core::RakeTask.new(:unit) do |t|
|
22
|
+
t.pattern = 'test/unit/**/*_spec.rb'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
task default: ['style:ruby', 'test:unit']
|
@@ -0,0 +1,101 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module DevCommands
|
3
|
+
# Defines the executable vagrant command
|
4
|
+
class Command < Vagrant.plugin(2, :command)
|
5
|
+
def self.synopsis
|
6
|
+
'runs vagrant commands from a Commandfile'
|
7
|
+
end
|
8
|
+
|
9
|
+
def execute
|
10
|
+
command = @argv.last
|
11
|
+
|
12
|
+
unless File.exist?(command_file_path)
|
13
|
+
return display_error('Missing "Commandfile"')
|
14
|
+
end
|
15
|
+
|
16
|
+
import_commands(command_file_path)
|
17
|
+
|
18
|
+
return display_help unless command
|
19
|
+
|
20
|
+
unless valid_command?(command)
|
21
|
+
return display_error("Invalid command \"#{command}\"")
|
22
|
+
end
|
23
|
+
|
24
|
+
run command
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def command_file_path
|
30
|
+
File.join @env.cwd, 'Commandfile'
|
31
|
+
end
|
32
|
+
|
33
|
+
def display_error(msg)
|
34
|
+
puts msg
|
35
|
+
|
36
|
+
display_help
|
37
|
+
end
|
38
|
+
|
39
|
+
def display_help
|
40
|
+
list_commands
|
41
|
+
|
42
|
+
# return exit code
|
43
|
+
127
|
44
|
+
end
|
45
|
+
|
46
|
+
def import_commands(command_file)
|
47
|
+
load command_file
|
48
|
+
end
|
49
|
+
|
50
|
+
def list_commands
|
51
|
+
if Definer.commands.empty?
|
52
|
+
puts 'No commands defined!'
|
53
|
+
return
|
54
|
+
end
|
55
|
+
|
56
|
+
puts 'Available commands:'
|
57
|
+
|
58
|
+
Definer.commands.each_key do |name|
|
59
|
+
puts "- #{name}"
|
60
|
+
end
|
61
|
+
|
62
|
+
puts ''
|
63
|
+
puts 'Usage: vagrant run <command>'
|
64
|
+
end
|
65
|
+
|
66
|
+
def run(name)
|
67
|
+
cmd = Definer.commands[name]
|
68
|
+
argv = run_argv(cmd)
|
69
|
+
|
70
|
+
run_command(cmd, argv)
|
71
|
+
end
|
72
|
+
|
73
|
+
def run_argv(cmd)
|
74
|
+
argv = @argv.dup
|
75
|
+
argv.pop
|
76
|
+
|
77
|
+
if cmd[:box] && argv.empty?
|
78
|
+
argv.unshift(cmd[:box].to_s)
|
79
|
+
elsif cmd[:box] && 1 == argv.size
|
80
|
+
argv[0] = cmd[:box].to_s
|
81
|
+
end
|
82
|
+
|
83
|
+
argv
|
84
|
+
end
|
85
|
+
|
86
|
+
def run_command(cmd, argv)
|
87
|
+
with_target_vms(argv, single_target: true) do |vm|
|
88
|
+
env = vm.action(:ssh_run,
|
89
|
+
ssh_opts: { extra_args: ['-q'] },
|
90
|
+
ssh_run_command: cmd[:command])
|
91
|
+
|
92
|
+
return env[:ssh_run_exit_status] || 0
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def valid_command?(command)
|
97
|
+
Definer.commands.include? command
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module DevCommands
|
3
|
+
# Public interface to define and access commands.
|
4
|
+
class Definer
|
5
|
+
class << self; attr_accessor :commands end
|
6
|
+
|
7
|
+
@commands = {}
|
8
|
+
|
9
|
+
def self.define(name, options)
|
10
|
+
if options.is_a?(String)
|
11
|
+
@commands[name] = { command: options }
|
12
|
+
else
|
13
|
+
@commands[name] = options
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module DevCommands
|
3
|
+
# Vagrant plugin definition
|
4
|
+
class Plugin < Vagrant.plugin(2)
|
5
|
+
name 'vagrant-devcommands'
|
6
|
+
description 'Runs vagrant commands from a Commandfile'
|
7
|
+
|
8
|
+
command :run do
|
9
|
+
require_relative 'command'
|
10
|
+
Command
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
|
6
|
+
require 'vagrant/devcommands/version'
|
7
|
+
|
8
|
+
Gem::Specification.new do |spec|
|
9
|
+
spec.name = 'vagrant-devcommands'
|
10
|
+
spec.version = VagrantPlugins::DevCommands::VERSION
|
11
|
+
spec.platform = Gem::Platform::RUBY
|
12
|
+
spec.authors = ['Marc Neudert']
|
13
|
+
spec.email = ['marc.neudert@gmail.com']
|
14
|
+
|
15
|
+
spec.summary = 'Runs vagrant commands from a Commandfile'
|
16
|
+
spec.description = ''
|
17
|
+
spec.homepage = ''
|
18
|
+
spec.license = 'MIT'
|
19
|
+
|
20
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f|
|
21
|
+
f.match(%r{^(test|spec|features)/})
|
22
|
+
}
|
23
|
+
|
24
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
|
+
spec.require_paths = ['lib']
|
26
|
+
|
27
|
+
if spec.respond_to?(:metadata)
|
28
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
29
|
+
end
|
30
|
+
|
31
|
+
spec.add_development_dependency 'bundler', '~> 1.8'
|
32
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
33
|
+
spec.add_development_dependency 'rspec', '~> 3.3'
|
34
|
+
spec.add_development_dependency 'rubocop', '~> 0.34'
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vagrant-devcommands
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Marc Neudert
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-10-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.8'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.8'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.34'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.34'
|
69
|
+
description: ''
|
70
|
+
email:
|
71
|
+
- marc.neudert@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".travis.yml"
|
78
|
+
- CHANGELOG.md
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- lib/vagrant/devcommands.rb
|
84
|
+
- lib/vagrant/devcommands/_proxy.rb
|
85
|
+
- lib/vagrant/devcommands/command.rb
|
86
|
+
- lib/vagrant/devcommands/definer.rb
|
87
|
+
- lib/vagrant/devcommands/plugin.rb
|
88
|
+
- lib/vagrant/devcommands/version.rb
|
89
|
+
- vagrant-devcommands.gemspec
|
90
|
+
homepage: ''
|
91
|
+
licenses:
|
92
|
+
- MIT
|
93
|
+
metadata:
|
94
|
+
allowed_push_host: https://rubygems.org
|
95
|
+
post_install_message:
|
96
|
+
rdoc_options: []
|
97
|
+
require_paths:
|
98
|
+
- lib
|
99
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
requirements: []
|
110
|
+
rubyforge_project:
|
111
|
+
rubygems_version: 2.4.5
|
112
|
+
signing_key:
|
113
|
+
specification_version: 4
|
114
|
+
summary: Runs vagrant commands from a Commandfile
|
115
|
+
test_files: []
|