vagrant-devcommands 0.1.0 → 0.2.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/CHANGELOG.md +10 -0
- data/README.md +40 -5
- data/lib/vagrant/devcommands/command.rb +7 -34
- data/lib/vagrant/devcommands/commandfile.rb +38 -0
- data/lib/vagrant/devcommands/help.rb +40 -0
- data/lib/vagrant/devcommands/plugin.rb +0 -1
- data/lib/vagrant/devcommands/version.rb +1 -3
- data/lib/vagrant/devcommands.rb +3 -0
- metadata +22 -10
- data/.gitignore +0 -2
- data/.travis.yml +0 -6
- data/Gemfile +0 -9
- data/Rakefile +0 -26
- data/vagrant-devcommands.gemspec +0 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1835de5d77e36ecc2fdda818fd4b6f682d044b8
|
4
|
+
data.tar.gz: b9edaee5f787c09dd8b4783d5342fb7e55045a0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5cc5094fa2638a80ce20390587e42c26b589c02c8744fe112166cd82f2d54f796983866967af80021ad7c97a5b6caa52cc3fc03f62c412f36525ffca99590b6c
|
7
|
+
data.tar.gz: 9323285ba6a94e6339f28c44b539c7cc0eb27698acc28b08ea22671a5c08c8a07230f1de03e3ed41cbd7ce6c2aba3bd8517dc5bb704edd4afa436baaa6942198
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## v0.2.0 (2015-11-02)
|
4
|
+
|
5
|
+
- Enhancements
|
6
|
+
- Commandfile is read from the path of the loaded Vagrantfile
|
7
|
+
- Commandfile is looked up case insensitive (`Commandfile` vs `commandfile`)
|
8
|
+
- Descriptions can be set for commands
|
9
|
+
|
10
|
+
- Bug fixes
|
11
|
+
- Commandfile can be located outside of current working directory
|
12
|
+
|
3
13
|
## v0.1.0 (2015-10-16)
|
4
14
|
|
5
15
|
- Initial Release
|
data/README.md
CHANGED
@@ -3,24 +3,30 @@
|
|
3
3
|
Runs vagrant commands from a Commandfile.
|
4
4
|
|
5
5
|
|
6
|
-
##
|
6
|
+
## Usage
|
7
|
+
|
8
|
+
### Command Definition
|
7
9
|
|
8
10
|
Add to a `Commandfile` besides your `Vagrantfile`:
|
9
11
|
|
10
12
|
```ruby
|
11
|
-
VagrantDevCommands.define '
|
12
|
-
|
13
|
+
VagrantDevCommands.define 'basic', 'hostname'
|
14
|
+
|
15
|
+
VagrantDevCommands.define 'with_options',
|
16
|
+
box: :my_box,
|
17
|
+
desc: 'executes "hostname" on the box "my_box"',
|
18
|
+
command: 'hostname'
|
13
19
|
```
|
14
20
|
|
15
21
|
|
16
|
-
|
22
|
+
### Command Listing
|
17
23
|
|
18
24
|
```shell
|
19
25
|
vagrant run
|
20
26
|
```
|
21
27
|
|
22
28
|
|
23
|
-
|
29
|
+
### Command Execution
|
24
30
|
|
25
31
|
```shell
|
26
32
|
# single-vm environment
|
@@ -32,6 +38,35 @@ vagrant run your_box your_command
|
|
32
38
|
```
|
33
39
|
|
34
40
|
|
41
|
+
## Notes for Windows Users
|
42
|
+
|
43
|
+
### SSH
|
44
|
+
|
45
|
+
If you are using this plugin on a Windows host system, please make sure your
|
46
|
+
regular `vagrant ssh [box]` succeeds. In some cases you may need to add the
|
47
|
+
`ssh.exe` (i.e. from a git installation) manually to your `%PATH%`.
|
48
|
+
|
49
|
+
### Command Definition
|
50
|
+
|
51
|
+
When using multi-line commands you probably need to define your command using
|
52
|
+
a sigil notation like the following:
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
VagrantDevCommands.define 'long_running_task',
|
56
|
+
command: %(cd /path/to/somewhere \
|
57
|
+
&& echo "starting long running task" \
|
58
|
+
&& ./long_running_task.sh \
|
59
|
+
&& echo "finished long running task")
|
60
|
+
```
|
61
|
+
|
62
|
+
Using a quote delimited command definition might otherwise result in not that
|
63
|
+
helpful error messages about a bad shell command.
|
64
|
+
|
65
|
+
It might also help to double check the line endings in your Commandfile are set
|
66
|
+
unix-style (`\n`) and not windows-style (`\r\n`) if you get errors when running
|
67
|
+
your commands.
|
68
|
+
|
69
|
+
|
35
70
|
## License
|
36
71
|
|
37
72
|
Licensed under the [MIT license](http://opensource.org/licenses/MIT).
|
@@ -7,18 +7,17 @@ module VagrantPlugins
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def execute
|
10
|
-
command
|
10
|
+
command = @argv.last
|
11
|
+
commandfile = Commandfile.new(@env)
|
11
12
|
|
12
|
-
unless
|
13
|
-
return display_error('Missing "Commandfile"')
|
14
|
-
end
|
13
|
+
return display_error('Missing "Commandfile"') unless commandfile.exist?
|
15
14
|
|
16
|
-
|
15
|
+
commandfile.import
|
17
16
|
|
18
17
|
return display_help unless command
|
19
18
|
|
20
19
|
unless valid_command?(command)
|
21
|
-
return display_error("Invalid command \"#{command}\"")
|
20
|
+
return display_error("Invalid command \"#{command}\"\n")
|
22
21
|
end
|
23
22
|
|
24
23
|
run command
|
@@ -26,43 +25,17 @@ module VagrantPlugins
|
|
26
25
|
|
27
26
|
private
|
28
27
|
|
29
|
-
def command_file_path
|
30
|
-
File.join @env.cwd, 'Commandfile'
|
31
|
-
end
|
32
|
-
|
33
28
|
def display_error(msg)
|
34
|
-
puts
|
35
|
-
|
36
|
-
display_help
|
29
|
+
puts(msg) && display_help
|
37
30
|
end
|
38
31
|
|
39
32
|
def display_help
|
40
|
-
|
33
|
+
Help.display
|
41
34
|
|
42
35
|
# return exit code
|
43
36
|
127
|
44
37
|
end
|
45
38
|
|
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
39
|
def run(name)
|
67
40
|
cmd = Definer.commands[name]
|
68
41
|
argv = run_argv(cmd)
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module DevCommands
|
3
|
+
# Loads and handles the Commandfile
|
4
|
+
class Commandfile
|
5
|
+
def initialize(env)
|
6
|
+
@env = env
|
7
|
+
end
|
8
|
+
|
9
|
+
def exist?
|
10
|
+
nil != find_commandfile
|
11
|
+
end
|
12
|
+
|
13
|
+
def path
|
14
|
+
find_commandfile
|
15
|
+
end
|
16
|
+
|
17
|
+
def import
|
18
|
+
load path
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
attr_accessor :env
|
24
|
+
|
25
|
+
def find_commandfile
|
26
|
+
return nil unless @env.root_path
|
27
|
+
|
28
|
+
%w(Commandfile commandfile).each do |commandfile|
|
29
|
+
current_path = @env.root_path.join(commandfile)
|
30
|
+
|
31
|
+
return current_path if current_path.file?
|
32
|
+
end
|
33
|
+
|
34
|
+
nil
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module DevCommands
|
3
|
+
# Defines the help output
|
4
|
+
#
|
5
|
+
# Printed when running "vagrant run" without a command
|
6
|
+
class Help
|
7
|
+
def self.display
|
8
|
+
if Definer.commands.empty?
|
9
|
+
puts 'No commands defined!'
|
10
|
+
return
|
11
|
+
end
|
12
|
+
|
13
|
+
display_header
|
14
|
+
display_commands
|
15
|
+
end
|
16
|
+
|
17
|
+
class << self
|
18
|
+
private
|
19
|
+
|
20
|
+
def display_commands
|
21
|
+
pad_to = Definer.commands.keys.map(&:length).max
|
22
|
+
|
23
|
+
Definer.commands.each do |name, command|
|
24
|
+
if command.key?(:desc)
|
25
|
+
puts " #{name.ljust(pad_to)} #{command[:desc]}"
|
26
|
+
else
|
27
|
+
puts " #{name}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def display_header
|
33
|
+
puts 'Usage: vagrant run [box] <command>'
|
34
|
+
puts ''
|
35
|
+
puts 'Available commands:'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/vagrant/devcommands.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-devcommands
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marc Neudert
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.8'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: coveralls
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.8'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.8'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rake
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,28 +80,26 @@ dependencies:
|
|
66
80
|
- - "~>"
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: '0.34'
|
69
|
-
description:
|
83
|
+
description: Vagrant plugin to run commands specified in a Commandfile inside one
|
84
|
+
of your vagrant boxes
|
70
85
|
email:
|
71
86
|
- marc.neudert@gmail.com
|
72
87
|
executables: []
|
73
88
|
extensions: []
|
74
89
|
extra_rdoc_files: []
|
75
90
|
files:
|
76
|
-
- ".gitignore"
|
77
|
-
- ".travis.yml"
|
78
91
|
- CHANGELOG.md
|
79
|
-
- Gemfile
|
80
92
|
- LICENSE.txt
|
81
93
|
- README.md
|
82
|
-
- Rakefile
|
83
94
|
- lib/vagrant/devcommands.rb
|
84
95
|
- lib/vagrant/devcommands/_proxy.rb
|
85
96
|
- lib/vagrant/devcommands/command.rb
|
97
|
+
- lib/vagrant/devcommands/commandfile.rb
|
86
98
|
- lib/vagrant/devcommands/definer.rb
|
99
|
+
- lib/vagrant/devcommands/help.rb
|
87
100
|
- lib/vagrant/devcommands/plugin.rb
|
88
101
|
- lib/vagrant/devcommands/version.rb
|
89
|
-
|
90
|
-
homepage: ''
|
102
|
+
homepage: https://github.com/mneudert/vagrant-devcommands
|
91
103
|
licenses:
|
92
104
|
- MIT
|
93
105
|
metadata:
|
@@ -108,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
120
|
version: '0'
|
109
121
|
requirements: []
|
110
122
|
rubyforge_project:
|
111
|
-
rubygems_version: 2.4.
|
123
|
+
rubygems_version: 2.4.8
|
112
124
|
signing_key:
|
113
125
|
specification_version: 4
|
114
126
|
summary: Runs vagrant commands from a Commandfile
|
data/.gitignore
DELETED
data/.travis.yml
DELETED
data/Gemfile
DELETED
data/Rakefile
DELETED
@@ -1,26 +0,0 @@
|
|
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']
|
data/vagrant-devcommands.gemspec
DELETED
@@ -1,35 +0,0 @@
|
|
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
|