dip 3.3.0 → 3.4.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 +15 -9
- data/exe/dip +2 -17
- data/lib/dip/commands/console.rb +4 -10
- data/lib/dip/run_vars.rb +61 -0
- data/lib/dip/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6b63ce6f69f4354b803173e399cb4f60578424af67138b7414374a5b72f459d
|
4
|
+
data.tar.gz: c1d60e9f4967bd4646b8c25eddf78f73c50573f2c8a0ecb8fd4124ec43356759
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0315179aee1699c6e95ab45adb50d41a4ee672830c325f82f5e1e5fb99dde1080e89f728507b81b6b92d3a24db0161e290f85c9e32768aa0ef15b1bf7ef9c943'
|
7
|
+
data.tar.gz: dde2a5dc5f9c9ba5560a596ab0c3e4a8ce7793f66968bf618354063dedeae96ef988ed544b817ffd2744bdcd7aaa4d58346b2e035fbac4f7812cd28aad24e2af
|
data/README.md
CHANGED
@@ -121,25 +121,31 @@ dip compose up -d redis
|
|
121
121
|
|
122
122
|
### Integration with shell
|
123
123
|
|
124
|
-
Dip can be injected into
|
124
|
+
Dip can be injected into current shell. For now, it supported ZSH only.
|
125
125
|
|
126
126
|
Inject Dip rc file (by default it saved to ~/.dip_shell_rc) into ZSH:
|
127
127
|
|
128
128
|
```sh
|
129
|
-
|
129
|
+
dip console | source /dev/stdin
|
130
130
|
```
|
131
131
|
|
132
|
-
After that
|
132
|
+
After that we can type commands without `dip` prefix. For example:
|
133
133
|
|
134
134
|
```sh
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
135
|
+
<run-command> *any-args
|
136
|
+
compose *any-compose-arg
|
137
|
+
up <service>
|
138
|
+
down
|
139
|
+
provision
|
140
140
|
```
|
141
141
|
|
142
|
-
When
|
142
|
+
When we change the current directory, all shell aliases will be automatically removed. But when we will enter back to a directory with a dip.yml file, then shell aliases will be renewed.
|
143
|
+
|
144
|
+
Also, in shell mode Dip is trying to determine passed manually environment variables. For example:
|
145
|
+
|
146
|
+
```sh
|
147
|
+
VERSION=20180515103400 rails db:migrate:down
|
148
|
+
```
|
143
149
|
|
144
150
|
### dip ssh
|
145
151
|
|
data/exe/dip
CHANGED
@@ -6,6 +6,7 @@ $LOAD_PATH.unshift(lib_path) unless $LOAD_PATH.include?(lib_path)
|
|
6
6
|
|
7
7
|
require 'dip'
|
8
8
|
require 'dip/cli'
|
9
|
+
require 'dip/run_vars'
|
9
10
|
|
10
11
|
begin
|
11
12
|
require 'pry-byebug' if Dip.debug?
|
@@ -19,23 +20,7 @@ Signal.trap('INT') do
|
|
19
20
|
end
|
20
21
|
|
21
22
|
begin
|
22
|
-
|
23
|
-
|
24
|
-
ARGV.each do |arg|
|
25
|
-
if !run_vars.frozen? && arg.include?("=")
|
26
|
-
key, val = arg.split("=", 2)
|
27
|
-
run_vars << "#{'--x-dip-run-vars=' if run_vars.empty?}#{key}:#{val}"
|
28
|
-
else
|
29
|
-
run_vars.freeze
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
unless run_vars.empty?
|
34
|
-
ARGV.shift(run_vars.size)
|
35
|
-
ARGV.push(*run_vars)
|
36
|
-
end
|
37
|
-
|
38
|
-
Dip::CLI.start
|
23
|
+
Dip::CLI.start(Dip::RunVars.call(ARGV, ENV))
|
39
24
|
rescue Dip::Error => err
|
40
25
|
puts "ERROR: #{err.message}"
|
41
26
|
exit 1
|
data/lib/dip/commands/console.rb
CHANGED
@@ -7,22 +7,16 @@ module Dip
|
|
7
7
|
module Console
|
8
8
|
class Start < Dip::Command
|
9
9
|
def execute
|
10
|
-
|
11
|
-
|
12
|
-
puts rc_file
|
10
|
+
puts script
|
13
11
|
end
|
14
12
|
|
15
13
|
private
|
16
14
|
|
17
|
-
def
|
18
|
-
@rc_file ||= "#{Dir.home}/.dip_shell_rc"
|
19
|
-
end
|
20
|
-
|
21
|
-
def script_content
|
15
|
+
def script
|
22
16
|
<<-SH.gsub(/^[ ]{12}/, '')
|
23
17
|
if [ "$DIP_SHELL" != "1" ]; then
|
24
|
-
export
|
25
|
-
export
|
18
|
+
export DIP_SHELL=zsh
|
19
|
+
export DIP_EARLY_ENVS=#{ENV.keys.join(',')}
|
26
20
|
fi
|
27
21
|
|
28
22
|
function _dip_remove_aliases() {
|
data/lib/dip/run_vars.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Dip
|
4
|
+
class RunVars
|
5
|
+
attr_reader :argv, :env, :early_envs, :env_vars, :result_argv
|
6
|
+
|
7
|
+
def self.call(*args)
|
8
|
+
new(*args).call
|
9
|
+
end
|
10
|
+
|
11
|
+
def initialize(argv, env = ENV)
|
12
|
+
@argv = argv
|
13
|
+
@env = env
|
14
|
+
@env_vars = {}
|
15
|
+
@result_argv = []
|
16
|
+
end
|
17
|
+
|
18
|
+
def call
|
19
|
+
extract_new_env_vars
|
20
|
+
extract_passed_env_vars
|
21
|
+
|
22
|
+
result_argv.push(*argv_env_vars) unless env_vars.empty?
|
23
|
+
|
24
|
+
result_argv
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def extract_new_env_vars
|
30
|
+
early_envs = env['DIP_EARLY_ENVS'].to_s
|
31
|
+
return if early_envs.empty?
|
32
|
+
|
33
|
+
(env.keys - early_envs.split(',')).each do |key|
|
34
|
+
next if key.start_with?("DIP_")
|
35
|
+
|
36
|
+
env_vars[key] = env[key]
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def extract_passed_env_vars
|
41
|
+
stop_parse = false
|
42
|
+
|
43
|
+
argv.each do |arg|
|
44
|
+
if !stop_parse && arg.include?("=")
|
45
|
+
key, val = arg.split("=", 2)
|
46
|
+
env_vars[key] = val
|
47
|
+
else
|
48
|
+
result_argv << arg
|
49
|
+
stop_parse ||= true
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def argv_env_vars
|
55
|
+
result = env_vars.map { |key, val| "#{key}:#{val}" }
|
56
|
+
result[0] = "--x-dip-run-vars=#{result[0]}"
|
57
|
+
|
58
|
+
result
|
59
|
+
end
|
60
|
+
end
|
61
|
+
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.4.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-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -150,6 +150,7 @@ files:
|
|
150
150
|
- lib/dip/commands/ssh.rb
|
151
151
|
- lib/dip/config.rb
|
152
152
|
- lib/dip/environment.rb
|
153
|
+
- lib/dip/run_vars.rb
|
153
154
|
- lib/dip/version.rb
|
154
155
|
homepage: https://github.com/bibendi/dip
|
155
156
|
licenses:
|