grok_cli 1.0.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 +9 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/README.md +50 -0
- data/Rakefile +11 -0
- data/bin/console +7 -0
- data/bin/grok +8 -0
- data/bin/setup +8 -0
- data/grok_cli.gemspec +25 -0
- data/lib/grok_cli/docker/boot.rb +47 -0
- data/lib/grok_cli/docker/configure.rb +52 -0
- data/lib/grok_cli/docker/node/setup.rb +37 -0
- data/lib/grok_cli/docker/node/test.rb +41 -0
- data/lib/grok_cli/docker/rails/rake.rb +41 -0
- data/lib/grok_cli/docker/rails/rspec.rb +42 -0
- data/lib/grok_cli/docker/rails/setup.rb +35 -0
- data/lib/grok_cli/docker/rails/test.rb +41 -0
- data/lib/grok_cli/docker/run.rb +47 -0
- data/lib/grok_cli/docker/start.rb +51 -0
- data/lib/grok_cli/docker/stop.rb +40 -0
- data/lib/grok_cli/docker/update_etc_hosts.rb +57 -0
- data/lib/grok_cli/docker.rb +14 -0
- data/lib/grok_cli/version.rb +3 -0
- data/lib/grok_cli.rb +11 -0
- metadata +132 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7b09626294ce9d4e323d7518861c33df61808f57
|
4
|
+
data.tar.gz: f1dc1a532f50d2d8e03b581b16fb4d04d0627fcf
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 15e23d6b8eca8ae288ee94feebbe85d38d00cd4d2aa85bd79111cce07ca963aa6df651907ca08e8f18dfdac6df786875cdb440668d61815c38f7e1195d4a2740
|
7
|
+
data.tar.gz: a12a7624e66c7996f78d1846b41ca9dfb54bb04817575bf41271a83ec2689744dc5143f14d8d0c0a7a8624fcdbc2cf07add34f6a7227a4b83d4fd741d6d264c8
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# GrokCLI
|
2
|
+
|
3
|
+
Here's your one-stop shop for common docker command management.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
```bash
|
8
|
+
gem install grok_cli
|
9
|
+
```
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
```bash
|
14
|
+
|
15
|
+
# List universal commands
|
16
|
+
grok help docker
|
17
|
+
|
18
|
+
# List Rails-specific commands
|
19
|
+
grok help docker:rails
|
20
|
+
|
21
|
+
# List Node-specific commands
|
22
|
+
grok help docker:node
|
23
|
+
```
|
24
|
+
|
25
|
+
## Quickstart: Rails
|
26
|
+
|
27
|
+
```
|
28
|
+
# List universal commands
|
29
|
+
grok docker:rails setup
|
30
|
+
grok docker:rails test [$OPTIONS]
|
31
|
+
|
32
|
+
grok docker start
|
33
|
+
```
|
34
|
+
|
35
|
+
## Quickstart: Node
|
36
|
+
|
37
|
+
```
|
38
|
+
# List universal commands
|
39
|
+
grok docker:node setup
|
40
|
+
grok docker:node test [$OPTIONS]
|
41
|
+
|
42
|
+
grok docker start
|
43
|
+
```
|
44
|
+
|
45
|
+
|
46
|
+
## Everything Else
|
47
|
+
|
48
|
+
```bash
|
49
|
+
grok docker run $COMMAND
|
50
|
+
```
|
data/Rakefile
ADDED
data/bin/console
ADDED
data/bin/grok
ADDED
data/bin/setup
ADDED
data/grok_cli.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'grok_cli/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "grok_cli"
|
8
|
+
spec.version = GrokCLI::VERSION
|
9
|
+
spec.authors = ["Josh Freeman"]
|
10
|
+
spec.email = ["jdfreeman11@gmail.com"]
|
11
|
+
spec.license = 'MIT'
|
12
|
+
|
13
|
+
spec.summary = "Common CLI tools designed by Grok Interactive, LLC"
|
14
|
+
spec.homepage = "https://github.com/GrokInteractive/grok_cli"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "bin"
|
18
|
+
spec.executables = ["grok"]
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
24
|
+
spec.add_runtime_dependency "gli", '~> 2.13', '>= 2.13.4'
|
25
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module GrokCLI::Docker
|
2
|
+
class Boot
|
3
|
+
def initialize(config = Configuration.new)
|
4
|
+
@config = config
|
5
|
+
end
|
6
|
+
|
7
|
+
def execute
|
8
|
+
system <<~CMD
|
9
|
+
|
10
|
+
docker-machine ls | grep #{@config.machine_name} | grep -qi Running
|
11
|
+
|
12
|
+
if [ $? -ne 0 ]
|
13
|
+
then
|
14
|
+
docker-machine start #{@config.machine_name}
|
15
|
+
docker-machine regenerate-certs #{@config.machine_name}
|
16
|
+
fi
|
17
|
+
|
18
|
+
CMD
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
module GrokCLI
|
24
|
+
|
25
|
+
definition = Proc.new do |c|
|
26
|
+
c.desc "Boot the docker machine"
|
27
|
+
|
28
|
+
c.command 'boot' do |c|
|
29
|
+
c.action do
|
30
|
+
GrokCLI::Docker::Boot.new.execute
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
command 'docker' do |c|
|
37
|
+
definition.call(c)
|
38
|
+
end
|
39
|
+
|
40
|
+
command 'docker:node' do |c|
|
41
|
+
definition.call(c)
|
42
|
+
end
|
43
|
+
|
44
|
+
command 'docker:rails' do |c|
|
45
|
+
definition.call(c)
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module GrokCLI::Docker
|
2
|
+
class Configure
|
3
|
+
def execute(machine_name, hostname)
|
4
|
+
body = <<~BODY
|
5
|
+
machine_name: #{machine_name}
|
6
|
+
hostname: #{hostname}
|
7
|
+
BODY
|
8
|
+
|
9
|
+
File.open('.grok-cli.yml', 'w') do |f|
|
10
|
+
f.write(body)
|
11
|
+
end
|
12
|
+
|
13
|
+
puts "Created the file \".grok-cli.yml\"\n\n#{body}"
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
module GrokCLI
|
20
|
+
include GLI::App
|
21
|
+
|
22
|
+
definition = Proc.new do |c|
|
23
|
+
c.desc "Generate a .grok-cli.yml configuration file"
|
24
|
+
c.long_desc <<-DESC
|
25
|
+
Generate a .grok-cli.yml configuration file
|
26
|
+
|
27
|
+
The other docker: commands will use this configuration file
|
28
|
+
when booting the docker machine and configuring /etc/hosts
|
29
|
+
DESC
|
30
|
+
|
31
|
+
c.arg :docker_machine_name
|
32
|
+
c.arg :hostname
|
33
|
+
|
34
|
+
c.command 'configure' do |c|
|
35
|
+
c.action do |global_options, options, arguments|
|
36
|
+
GrokCLI::Docker::Configure.new.execute(arguments[0], arguments[1])
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
command 'docker' do |c|
|
42
|
+
definition.call(c)
|
43
|
+
end
|
44
|
+
|
45
|
+
command 'docker:node' do |c|
|
46
|
+
definition.call(c)
|
47
|
+
end
|
48
|
+
|
49
|
+
command 'docker:rails' do |c|
|
50
|
+
definition.call(c)
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module GrokCLI::Docker::Node
|
2
|
+
class Setup
|
3
|
+
def initialize(config = GrokCLI::Docker::Configuration.new)
|
4
|
+
@config = config
|
5
|
+
end
|
6
|
+
|
7
|
+
def execute
|
8
|
+
system <<~CMD
|
9
|
+
|
10
|
+
docker-machine create #{@config.machine_name} --driver virtualbox
|
11
|
+
|
12
|
+
eval "$(docker-machine env #{@config.machine_name})"
|
13
|
+
|
14
|
+
docker-compose build
|
15
|
+
|
16
|
+
docker-compose run --rm web npm -g install webpack
|
17
|
+
docker-compose run --rm web npm install
|
18
|
+
|
19
|
+
cp .env.example .env
|
20
|
+
|
21
|
+
CMD
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
module GrokCLI
|
27
|
+
command 'docker:node' do |c|
|
28
|
+
|
29
|
+
c.desc "Create a docker machine and setup the node application"
|
30
|
+
|
31
|
+
c.command 'setup' do |c|
|
32
|
+
c.action do
|
33
|
+
GrokCLI::Docker::Node::Setup.new.execute
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module GrokCLI::Docker::Node
|
2
|
+
class Test
|
3
|
+
def initialize(config = GrokCLI::Docker::Configuration.new)
|
4
|
+
@config = config
|
5
|
+
end
|
6
|
+
|
7
|
+
def execute(test_options = "")
|
8
|
+
GrokCLI::Docker::Boot.new.execute
|
9
|
+
GrokCLI::Docker::UpdateEtcHosts.new.execute
|
10
|
+
|
11
|
+
system <<~CMD
|
12
|
+
|
13
|
+
eval "$(docker-machine env #{@config.machine_name})"
|
14
|
+
|
15
|
+
docker-compose run --rm web npm test #{test_options}
|
16
|
+
|
17
|
+
CMD
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
module GrokCLI
|
23
|
+
command 'docker:node' do |c|
|
24
|
+
|
25
|
+
c.desc "Run tests"
|
26
|
+
c.long_desc <<-DESC
|
27
|
+
Run tests
|
28
|
+
|
29
|
+
Boots the docker machine and configures /etc/hosts if necessary,
|
30
|
+
then runs `docker-compose run --rm web npm test ?`
|
31
|
+
DESC
|
32
|
+
|
33
|
+
c.arg :test_options, [:optional, :multiple]
|
34
|
+
|
35
|
+
c.command 'test' do |c|
|
36
|
+
c.action do |global_options,options,arguments|
|
37
|
+
GrokCLI::Docker::Node::Test.new.execute(arguments.join(' '))
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module GrokCLI::Docker::Rails
|
2
|
+
class Rake
|
3
|
+
def initialize(config = GrokCLI::Docker::Configuration.new)
|
4
|
+
@config = config
|
5
|
+
end
|
6
|
+
|
7
|
+
def execute(rake_command = "")
|
8
|
+
GrokCLI::Docker::Boot.new.execute
|
9
|
+
GrokCLI::Docker::UpdateEtcHosts.new.execute
|
10
|
+
|
11
|
+
system <<~CMD
|
12
|
+
|
13
|
+
eval "$(docker-machine env #{@config.machine_name})"
|
14
|
+
|
15
|
+
docker-compose run --rm web bundle exec rake #{rake_command}
|
16
|
+
|
17
|
+
CMD
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
module GrokCLI
|
23
|
+
command 'docker:rails' do |c|
|
24
|
+
|
25
|
+
c.desc "Run rspec tests"
|
26
|
+
c.long_desc <<-DESC
|
27
|
+
Run rspec tests
|
28
|
+
|
29
|
+
Boots the docker machine and configures /etc/hosts if necessary,
|
30
|
+
then runs `docker-compose run --rm web bundle exec rake ?`
|
31
|
+
DESC
|
32
|
+
|
33
|
+
c.arg :rake_command, [:optional, :multiple]
|
34
|
+
|
35
|
+
c.command 'rake' do |c|
|
36
|
+
c.action do |global_options,options,arguments|
|
37
|
+
GrokCLI::Docker::Rails::Rake.new.execute(arguments.join(' '))
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module GrokCLI::Docker::Rails
|
2
|
+
class RSpec
|
3
|
+
def initialize(config = GrokCLI::Docker::Configuration.new)
|
4
|
+
@config = config
|
5
|
+
end
|
6
|
+
|
7
|
+
def execute(test_options = "")
|
8
|
+
GrokCLI::Docker::Boot.new.execute
|
9
|
+
GrokCLI::Docker::UpdateEtcHosts.new.execute
|
10
|
+
|
11
|
+
system <<~CMD
|
12
|
+
|
13
|
+
eval "$(docker-machine env #{@config.machine_name})"
|
14
|
+
|
15
|
+
docker-compose run --rm web bundle exec rspec #{test_options}
|
16
|
+
|
17
|
+
CMD
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
module GrokCLI
|
23
|
+
command 'docker:rails' do |c|
|
24
|
+
|
25
|
+
c.desc "Run rspec tests"
|
26
|
+
c.long_desc <<-DESC
|
27
|
+
Run rspec tests
|
28
|
+
|
29
|
+
Boots the docker machine and configures /etc/hosts if necessary,
|
30
|
+
then effectively runs `docker-compose run --rm web bundle exec rspec ?`
|
31
|
+
DESC
|
32
|
+
|
33
|
+
c.arg :rspec_options, [:optional, :multiple]
|
34
|
+
|
35
|
+
c.command 'rspec' do |c|
|
36
|
+
c.action do |global_options,options,arguments|
|
37
|
+
GrokCLI::Docker::Rails::RSpec.new.execute(arguments.join(' '))
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module GrokCLI::Docker::Rails
|
2
|
+
class Setup
|
3
|
+
def initialize(config = GrokCLI::Docker::Configuration.new)
|
4
|
+
@config = config
|
5
|
+
end
|
6
|
+
|
7
|
+
def execute
|
8
|
+
system <<~CMD
|
9
|
+
|
10
|
+
docker-machine create #{@config.machine_name} --driver virtualbox
|
11
|
+
|
12
|
+
eval "$(docker-machine env #{@config.machine_name})"
|
13
|
+
|
14
|
+
docker-compose build
|
15
|
+
docker-compose run --rm web bundle install --jobs 16
|
16
|
+
docker-compose run --rm web bundle exec rake db:create db:migrate db:populate
|
17
|
+
docker-compose run --rm web bundle exec rake db:create db:migrate db:populate RAILS_ENV=test
|
18
|
+
|
19
|
+
CMD
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
module GrokCLI
|
25
|
+
command 'docker:rails' do |c|
|
26
|
+
|
27
|
+
c.desc "Create a docker machine and setup the rails application"
|
28
|
+
|
29
|
+
c.command 'setup' do |c|
|
30
|
+
c.action do
|
31
|
+
GrokCLI::Docker::Rails::Setup.new.execute
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module GrokCLI::Docker::Rails
|
2
|
+
class Test
|
3
|
+
def initialize(config = GrokCLI::Docker::Configuration.new)
|
4
|
+
@config = config
|
5
|
+
end
|
6
|
+
|
7
|
+
def execute(test_options = "")
|
8
|
+
GrokCLI::Docker::Boot.new.execute
|
9
|
+
GrokCLI::Docker::UpdateEtcHosts.new.execute
|
10
|
+
|
11
|
+
system <<~CMD
|
12
|
+
|
13
|
+
eval "$(docker-machine env #{@config.machine_name})"
|
14
|
+
|
15
|
+
docker-compose run --rm web bundle exec rake test #{test_options}
|
16
|
+
|
17
|
+
CMD
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
module GrokCLI
|
23
|
+
command 'docker:rails' do |c|
|
24
|
+
|
25
|
+
c.desc "Run tests"
|
26
|
+
c.long_desc <<-DESC
|
27
|
+
Run tests
|
28
|
+
|
29
|
+
Boots the docker machine and configures /etc/hosts if necessary,
|
30
|
+
then runs `docker-compose run --rm web bundle exec rake test ?`
|
31
|
+
DESC
|
32
|
+
|
33
|
+
c.arg :test_options, [:optional, :multiple]
|
34
|
+
|
35
|
+
c.command 'test' do |c|
|
36
|
+
c.action do |global_options,options,arguments|
|
37
|
+
GrokCLI::Docker::Rails::Test.new.execute(arguments.join(' '))
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module GrokCLI::Docker
|
2
|
+
class Run
|
3
|
+
def initialize(config = Configuration.new)
|
4
|
+
@config = config
|
5
|
+
end
|
6
|
+
|
7
|
+
def execute(command)
|
8
|
+
Boot.new.execute
|
9
|
+
UpdateEtcHosts.new.execute
|
10
|
+
|
11
|
+
system <<~CMD
|
12
|
+
|
13
|
+
eval "$(docker-machine env #{@config.machine_name})"
|
14
|
+
|
15
|
+
docker-compose run --rm web #{command}
|
16
|
+
|
17
|
+
CMD
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
module GrokCLI
|
23
|
+
definition = Proc.new do |c|
|
24
|
+
|
25
|
+
c.desc "Run a command within the container"
|
26
|
+
|
27
|
+
c.arg :command, :multiple
|
28
|
+
|
29
|
+
c.command 'run' do |c|
|
30
|
+
c.action do |global_options,options,arguments|
|
31
|
+
GrokCLI::Docker::Run.new.execute(arguments.join(' '))
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
command 'docker' do |c|
|
37
|
+
definition.call(c)
|
38
|
+
end
|
39
|
+
|
40
|
+
command 'docker:node' do |c|
|
41
|
+
definition.call(c)
|
42
|
+
end
|
43
|
+
|
44
|
+
command 'docker:rails' do |c|
|
45
|
+
definition.call(c)
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module GrokCLI::Docker
|
2
|
+
class Start
|
3
|
+
def initialize(config = Configuration.new)
|
4
|
+
@config = config
|
5
|
+
end
|
6
|
+
|
7
|
+
def execute
|
8
|
+
Boot.new.execute
|
9
|
+
UpdateEtcHosts.new.execute
|
10
|
+
|
11
|
+
system <<~CMD
|
12
|
+
|
13
|
+
eval "$(docker-machine env #{@config.machine_name})"
|
14
|
+
|
15
|
+
docker-compose run --service-ports --rm web
|
16
|
+
|
17
|
+
CMD
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
module GrokCLI
|
23
|
+
definition = Proc.new do |c|
|
24
|
+
|
25
|
+
c.desc "Start the application"
|
26
|
+
c.long_desc <<-DESC
|
27
|
+
Start the application
|
28
|
+
|
29
|
+
Boots the docker machine and configures /etc/hosts if necessary,
|
30
|
+
then starts the application
|
31
|
+
DESC
|
32
|
+
|
33
|
+
c.command 'start' do |c|
|
34
|
+
c.action do
|
35
|
+
GrokCLI::Docker::Start.new.execute
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
command 'docker' do |c|
|
41
|
+
definition.call(c)
|
42
|
+
end
|
43
|
+
|
44
|
+
command 'docker:node' do |c|
|
45
|
+
definition.call(c)
|
46
|
+
end
|
47
|
+
|
48
|
+
command 'docker:rails' do |c|
|
49
|
+
definition.call(c)
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module GrokCLI::Docker
|
2
|
+
class Stop
|
3
|
+
def initialize(config = Configuration.new)
|
4
|
+
@config = config
|
5
|
+
end
|
6
|
+
|
7
|
+
def execute
|
8
|
+
system <<~CMD
|
9
|
+
|
10
|
+
docker-machine stop #{@config.machine_name}
|
11
|
+
|
12
|
+
CMD
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
module GrokCLI
|
18
|
+
definition = Proc.new do |c|
|
19
|
+
|
20
|
+
c.desc "Stop the docker machine"
|
21
|
+
|
22
|
+
c.command 'stop' do |c|
|
23
|
+
c.action do
|
24
|
+
GrokCLI::Docker::Stop.new.execute
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
command 'docker' do |c|
|
30
|
+
definition.call(c)
|
31
|
+
end
|
32
|
+
|
33
|
+
command 'docker:node' do |c|
|
34
|
+
definition.call(c)
|
35
|
+
end
|
36
|
+
|
37
|
+
command 'docker:rails' do |c|
|
38
|
+
definition.call(c)
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module GrokCLI::Docker
|
2
|
+
class UpdateEtcHosts
|
3
|
+
def initialize(config = Configuration.new)
|
4
|
+
@config = config
|
5
|
+
end
|
6
|
+
|
7
|
+
def execute
|
8
|
+
system <<~CMD
|
9
|
+
|
10
|
+
IP=`docker-machine ip #{@config.machine_name}`
|
11
|
+
|
12
|
+
IP_MAP="$IP #{@config.hostname}"
|
13
|
+
|
14
|
+
if grep -Fxq "$IP_MAP" /etc/hosts; then
|
15
|
+
:
|
16
|
+
else
|
17
|
+
|
18
|
+
if sudo -n true 2>/dev/null; then
|
19
|
+
:
|
20
|
+
else
|
21
|
+
echo "You may be prompted for your password; this is to permit updating your /etc/hosts for #{@config.hostname}"
|
22
|
+
fi
|
23
|
+
|
24
|
+
sudo sed -i '' '/#{@config.hostname.gsub('.', '\.')}$/d' /etc/hosts
|
25
|
+
|
26
|
+
echo $IP_MAP | sudo tee -a /etc/hosts
|
27
|
+
fi
|
28
|
+
|
29
|
+
CMD
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
module GrokCLI
|
35
|
+
|
36
|
+
definition = Proc.new do |c|
|
37
|
+
c.desc "Updates /etc/hosts with the configured hostname and current IP address"
|
38
|
+
|
39
|
+
c.command 'update-hosts-file' do |c|
|
40
|
+
c.action do
|
41
|
+
GrokCLI::Docker::UpdateEtcHosts.new.execute
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
command 'docker' do |c|
|
47
|
+
definition.call(c)
|
48
|
+
end
|
49
|
+
|
50
|
+
command 'docker:node' do |c|
|
51
|
+
definition.call(c)
|
52
|
+
end
|
53
|
+
|
54
|
+
command 'docker:rails' do |c|
|
55
|
+
definition.call(c)
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module GrokCLI
|
4
|
+
module Docker
|
5
|
+
class Configuration
|
6
|
+
attr_reader :machine_name, :hostname
|
7
|
+
|
8
|
+
def initialize(config = YAML.load_file('.grok-cli.yml'))
|
9
|
+
@machine_name = config.fetch('machine_name')
|
10
|
+
@hostname = config.fetch('hostname')
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/grok_cli.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
module GrokCLI
|
2
|
+
require 'gli'
|
3
|
+
include GLI::App
|
4
|
+
extend self
|
5
|
+
|
6
|
+
program_desc 'Command-Line Tools from Grok Interactive'
|
7
|
+
subcommand_option_handling :normal
|
8
|
+
arguments :strict
|
9
|
+
|
10
|
+
Dir[File.dirname(__FILE__) + '/**/*.rb'].each { |file| require file }
|
11
|
+
end
|
metadata
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: grok_cli
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Josh Freeman
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-04-28 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.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
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: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: gli
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.13'
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: 2.13.4
|
65
|
+
type: :runtime
|
66
|
+
prerelease: false
|
67
|
+
version_requirements: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - "~>"
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '2.13'
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 2.13.4
|
75
|
+
description:
|
76
|
+
email:
|
77
|
+
- jdfreeman11@gmail.com
|
78
|
+
executables:
|
79
|
+
- grok
|
80
|
+
extensions: []
|
81
|
+
extra_rdoc_files: []
|
82
|
+
files:
|
83
|
+
- ".gitignore"
|
84
|
+
- ".travis.yml"
|
85
|
+
- Gemfile
|
86
|
+
- README.md
|
87
|
+
- Rakefile
|
88
|
+
- bin/console
|
89
|
+
- bin/grok
|
90
|
+
- bin/setup
|
91
|
+
- grok_cli.gemspec
|
92
|
+
- lib/grok_cli.rb
|
93
|
+
- lib/grok_cli/docker.rb
|
94
|
+
- lib/grok_cli/docker/boot.rb
|
95
|
+
- lib/grok_cli/docker/configure.rb
|
96
|
+
- lib/grok_cli/docker/node/setup.rb
|
97
|
+
- lib/grok_cli/docker/node/test.rb
|
98
|
+
- lib/grok_cli/docker/rails/rake.rb
|
99
|
+
- lib/grok_cli/docker/rails/rspec.rb
|
100
|
+
- lib/grok_cli/docker/rails/setup.rb
|
101
|
+
- lib/grok_cli/docker/rails/test.rb
|
102
|
+
- lib/grok_cli/docker/run.rb
|
103
|
+
- lib/grok_cli/docker/start.rb
|
104
|
+
- lib/grok_cli/docker/stop.rb
|
105
|
+
- lib/grok_cli/docker/update_etc_hosts.rb
|
106
|
+
- lib/grok_cli/version.rb
|
107
|
+
homepage: https://github.com/GrokInteractive/grok_cli
|
108
|
+
licenses:
|
109
|
+
- MIT
|
110
|
+
metadata: {}
|
111
|
+
post_install_message:
|
112
|
+
rdoc_options: []
|
113
|
+
require_paths:
|
114
|
+
- lib
|
115
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
requirements: []
|
126
|
+
rubyforge_project:
|
127
|
+
rubygems_version: 2.5.1
|
128
|
+
signing_key:
|
129
|
+
specification_version: 4
|
130
|
+
summary: Common CLI tools designed by Grok Interactive, LLC
|
131
|
+
test_files: []
|
132
|
+
has_rdoc:
|