dip 3.2.3 → 3.3.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/README.md +40 -11
- data/lib/dip.rb +5 -0
- data/lib/dip/cli.rb +4 -0
- data/lib/dip/cli/console.rb +34 -0
- data/lib/dip/commands/console.rb +91 -0
- data/lib/dip/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39afd269d744387e64e708e2c173c38ffe35605ae8aa4dffa9cd074142e0e9b1
|
4
|
+
data.tar.gz: efb60031ad5646986fc5672b4579671d3225624b9bc38d1d26ba142a91b1b3ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6d434a4250d5276e4ce91d3ed2393be9cbc93108a8fe32052f3cb6f54b2fd8fd740ee0652352fb32f26310ed30e559dbe17565eb2e16a195d7e6d7f226aaa58
|
7
|
+
data.tar.gz: 5a5512fff638facb0f3bf185703a53df02fb009e1d3c29a80803724336607f8198891f4465f0b9b2cd730d6b866225118dd9d2efa59eacc77776038039be64c5
|
data/README.md
CHANGED
@@ -1,4 +1,8 @@
|
|
1
|
-
|
1
|
+
[](https://badge.fury.io/rb/dip)
|
2
|
+
[](https://travis-ci.org/bibendi/dip)
|
3
|
+
[](https://codeclimate.com/github/bibendi/dip/maintainability)
|
4
|
+
|
5
|
+
# DIP
|
2
6
|
|
3
7
|
Docker Interaction Process
|
4
8
|
|
@@ -22,6 +26,10 @@ https://github.com/bibendi/dip/releases
|
|
22
26
|
- [Ubuntu](docs/docker-ubuntu-install.md)
|
23
27
|
- [Mac OS](docs/docker-for-mac-install.md)
|
24
28
|
|
29
|
+
## Examples
|
30
|
+
|
31
|
+
- [Modern Rails application with webpack](https://github.com/bibendi/dip-example-rails)
|
32
|
+
|
25
33
|
## Usage
|
26
34
|
|
27
35
|
```sh
|
@@ -36,48 +44,47 @@ version: '2'
|
|
36
44
|
|
37
45
|
environment:
|
38
46
|
COMPOSE_EXT: development
|
39
|
-
RAILS_ENV: development
|
40
47
|
|
41
48
|
compose:
|
42
49
|
files:
|
43
50
|
- docker/docker-compose.yml
|
44
51
|
- docker/docker-compose.$COMPOSE_EXT.yml
|
45
52
|
- docker/docker-compose.$DIP_OS.yml
|
46
|
-
project_name: bear
|
53
|
+
project_name: bear
|
47
54
|
|
48
55
|
interaction:
|
49
56
|
sh:
|
50
|
-
service:
|
57
|
+
service: app
|
51
58
|
compose_run_options: [no-deps]
|
52
59
|
|
53
60
|
bundle:
|
54
|
-
service:
|
61
|
+
service: app
|
55
62
|
command: bundle
|
56
63
|
|
57
64
|
rake:
|
58
|
-
service:
|
65
|
+
service: app
|
59
66
|
command: bundle exec rake
|
60
67
|
|
61
68
|
rspec:
|
62
|
-
service:
|
69
|
+
service: app
|
63
70
|
environment:
|
64
71
|
RAILS_ENV: test
|
65
72
|
command: bundle exec rspec
|
66
73
|
|
67
74
|
rails:
|
68
|
-
service:
|
75
|
+
service: app
|
69
76
|
command: bundle exec rails
|
70
77
|
subcommands:
|
71
78
|
s:
|
72
|
-
service:
|
79
|
+
service: web
|
73
80
|
compose_method: up
|
74
81
|
|
75
82
|
psql:
|
76
|
-
service:
|
83
|
+
service: app
|
77
84
|
command: psql -h pg -U postgres
|
78
85
|
|
79
86
|
provision:
|
80
|
-
- dip compose up -d
|
87
|
+
- dip compose up -d pg redis
|
81
88
|
- dip bundle install
|
82
89
|
- dip rake db:migrate
|
83
90
|
```
|
@@ -112,6 +119,28 @@ dip compose COMMAND [OPTIONS]
|
|
112
119
|
dip compose up -d redis
|
113
120
|
```
|
114
121
|
|
122
|
+
### Integration with shell
|
123
|
+
|
124
|
+
Dip can be injected into your current shell. For now, it supported ZSH only.
|
125
|
+
|
126
|
+
Inject Dip rc file (by default it saved to ~/.dip_shell_rc) into ZSH:
|
127
|
+
|
128
|
+
```sh
|
129
|
+
source $(dip console)
|
130
|
+
```
|
131
|
+
|
132
|
+
After that you can type commands without `dip` prefix. For example:
|
133
|
+
|
134
|
+
```sh
|
135
|
+
d> <run-command> *any-args
|
136
|
+
d> compose *any-compose-arg
|
137
|
+
d> up <service>
|
138
|
+
d> down
|
139
|
+
d> provision
|
140
|
+
```
|
141
|
+
|
142
|
+
When you change the current directory, all shell aliases will be automatically removed. But when you will enter back to a directory with a dip.yml file, then shell aliases will be renewed.
|
143
|
+
|
115
144
|
### dip ssh
|
116
145
|
|
117
146
|
Runs ssh-agent container based on https://github.com/whilp/ssh-agent with your ~/.ssh/id_rsa.
|
data/lib/dip.rb
CHANGED
@@ -15,6 +15,11 @@ module Dip
|
|
15
15
|
@env ||= Dip::Environment.new(config.exist? ? config.environment : {})
|
16
16
|
end
|
17
17
|
|
18
|
+
def bin_path
|
19
|
+
# TODO: Maybe there's a better way?
|
20
|
+
$PROGRAM_NAME.start_with?("./") ? File.expand_path($PROGRAM_NAME) : $PROGRAM_NAME
|
21
|
+
end
|
22
|
+
|
18
23
|
%w(test debug).each do |key|
|
19
24
|
define_method("#{key}?") do
|
20
25
|
ENV["DIP_ENV"] == key
|
data/lib/dip/cli.rb
CHANGED
@@ -99,5 +99,9 @@ module Dip
|
|
99
99
|
require_relative 'cli/nginx'
|
100
100
|
desc "nginx", "Nginx reverse proxy server"
|
101
101
|
subcommand :nginx, Dip::CLI::Nginx
|
102
|
+
|
103
|
+
require_relative 'cli/console'
|
104
|
+
desc "console", "Integrate Dip commands into shell (only ZSH is supported now)"
|
105
|
+
subcommand :console, Dip::CLI::Console
|
102
106
|
end
|
103
107
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'thor'
|
4
|
+
require_relative "../commands/console"
|
5
|
+
|
6
|
+
module Dip
|
7
|
+
class CLI
|
8
|
+
class Console < Thor
|
9
|
+
desc "start", "Integrate Dip into current shell"
|
10
|
+
method_option :help, aliases: '-h', type: :boolean,
|
11
|
+
desc: 'Display usage information'
|
12
|
+
def start
|
13
|
+
if options[:help]
|
14
|
+
invoke :help, ['start']
|
15
|
+
else
|
16
|
+
Dip::Commands::Console::Start.new.execute
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
default_task :start
|
21
|
+
|
22
|
+
desc "inject", "Inject aliases"
|
23
|
+
method_option :help, aliases: '-h', type: :boolean,
|
24
|
+
desc: 'Display usage information'
|
25
|
+
def inject
|
26
|
+
if options[:help]
|
27
|
+
invoke :help, ['inject']
|
28
|
+
else
|
29
|
+
Dip::Commands::Console::Inject.new.execute
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../command'
|
4
|
+
|
5
|
+
module Dip
|
6
|
+
module Commands
|
7
|
+
module Console
|
8
|
+
class Start < Dip::Command
|
9
|
+
def execute
|
10
|
+
File.write(rc_file, script_content)
|
11
|
+
|
12
|
+
puts rc_file
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def rc_file
|
18
|
+
@rc_file ||= "#{Dir.home}/.dip_shell_rc"
|
19
|
+
end
|
20
|
+
|
21
|
+
def script_content
|
22
|
+
<<-SH.gsub(/^[ ]{12}/, '')
|
23
|
+
if [ "$DIP_SHELL" != "1" ]; then
|
24
|
+
export PS1="${PS1}d> "
|
25
|
+
export DIP_SHELL=1
|
26
|
+
fi
|
27
|
+
|
28
|
+
function _dip_remove_aliases() {
|
29
|
+
# will be redefined
|
30
|
+
}
|
31
|
+
|
32
|
+
function _dip_source_aliases() {
|
33
|
+
#{Dip.bin_path} console inject | source /dev/stdin
|
34
|
+
}
|
35
|
+
|
36
|
+
_dip_source_aliases
|
37
|
+
|
38
|
+
function chpwd() {
|
39
|
+
_dip_remove_aliases
|
40
|
+
_dip_source_aliases
|
41
|
+
}
|
42
|
+
SH
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
class Inject < Dip::Command
|
47
|
+
def initialize
|
48
|
+
@aliases = []
|
49
|
+
@out = []
|
50
|
+
end
|
51
|
+
|
52
|
+
def execute
|
53
|
+
if Dip.config.exist?
|
54
|
+
alias_interaction if Dip.config.interaction
|
55
|
+
alias_compose
|
56
|
+
add_alias("provision")
|
57
|
+
end
|
58
|
+
|
59
|
+
fill_removing_aliases
|
60
|
+
|
61
|
+
puts @out.join("\n\n")
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
def alias_interaction
|
67
|
+
Dip.config.interaction.keys.each do |name|
|
68
|
+
add_alias(name)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def alias_compose
|
73
|
+
%w(compose up down).each do |name|
|
74
|
+
add_alias(name)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def add_alias(name)
|
79
|
+
@aliases << name
|
80
|
+
@out << "function #{name}() { #{Dip.bin_path} #{name} $@; }"
|
81
|
+
end
|
82
|
+
|
83
|
+
def fill_removing_aliases
|
84
|
+
@out << "function _dip_remove_aliases() { \n" \
|
85
|
+
"#{@aliases.map { |a| " unset -f #{a}" }.join("\n")} " \
|
86
|
+
"\n}"
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
data/lib/dip/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bibendi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -136,11 +136,13 @@ files:
|
|
136
136
|
- exe/dip
|
137
137
|
- lib/dip.rb
|
138
138
|
- lib/dip/cli.rb
|
139
|
+
- lib/dip/cli/console.rb
|
139
140
|
- lib/dip/cli/dns.rb
|
140
141
|
- lib/dip/cli/nginx.rb
|
141
142
|
- lib/dip/cli/ssh.rb
|
142
143
|
- lib/dip/command.rb
|
143
144
|
- lib/dip/commands/compose.rb
|
145
|
+
- lib/dip/commands/console.rb
|
144
146
|
- lib/dip/commands/dns.rb
|
145
147
|
- lib/dip/commands/nginx.rb
|
146
148
|
- lib/dip/commands/provision.rb
|