deplomat 0.2.15 → 0.2.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +5 -5
- data/VERSION +1 -1
- data/lib/deplomat/directives.rb +18 -4
- data/lib/deplomat/local_node.rb +8 -0
- data/lib/deplomat/node.rb +16 -20
- data/lib/deplomat/remote_node.rb +9 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d96cc91e3fb5f9ac448d81d16fa287689bced45d0e3f960505d76c2227f9fa2
|
4
|
+
data.tar.gz: ca95f0c856ff64f45c2fb29da35c543453aeb2fe73e5c7f03ba48436795caa24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41b1dd78962774c875ed8822abbeee92b917a67d084c187f17475fa74e10c5920d86b2694971fbd9d3cb2f1e8b5e5c9167554d1fdefa714041eab45e9ce1c2cf
|
7
|
+
data.tar.gz: c907d938a330a5c89ea6f382960a412146efbc28d48b7f07e76d595ec33641b3420011f5b56ea3cacb25b69f5178e0a562931aa6ef3735cebc171f9caea79b0f
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
|
4
|
+
deplomat (0.2.20)
|
5
5
|
colorize
|
6
6
|
sys-proctable
|
7
7
|
|
@@ -10,7 +10,7 @@ GEM
|
|
10
10
|
specs:
|
11
11
|
colorize (0.8.1)
|
12
12
|
diff-lcs (1.3)
|
13
|
-
ffi (1.
|
13
|
+
ffi (1.14.2)
|
14
14
|
rspec (3.8.0)
|
15
15
|
rspec-core (~> 3.8.0)
|
16
16
|
rspec-expectations (~> 3.8.0)
|
@@ -24,16 +24,16 @@ GEM
|
|
24
24
|
diff-lcs (>= 1.2.0, < 2.0)
|
25
25
|
rspec-support (~> 3.8.0)
|
26
26
|
rspec-support (3.8.2)
|
27
|
-
sys-proctable (1.2.
|
27
|
+
sys-proctable (1.2.6)
|
28
28
|
ffi
|
29
29
|
|
30
30
|
PLATFORMS
|
31
31
|
ruby
|
32
32
|
|
33
33
|
DEPENDENCIES
|
34
|
-
Deplomat!
|
35
34
|
bundler (~> 2.0)
|
35
|
+
deplomat!
|
36
36
|
rspec
|
37
37
|
|
38
38
|
BUNDLED WITH
|
39
|
-
2.
|
39
|
+
2.1.4
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.20
|
data/lib/deplomat/directives.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
$partials = {}
|
2
2
|
$deplomat_tasks = []
|
3
3
|
$deplomat_tasks_callbacks = {}
|
4
|
+
$log_tasks_status = true
|
4
5
|
|
5
6
|
def execute_in(env:)
|
6
7
|
yield if $env == env
|
@@ -26,26 +27,39 @@ def print_to_terminal(message, color: nil, newline: true)
|
|
26
27
|
$stdout.print message
|
27
28
|
end
|
28
29
|
|
30
|
+
def print_task_status(name, status)
|
31
|
+
print_to_terminal("\n--- #{name} task #{status.upcase}", color: :light_blue, newline: true)
|
32
|
+
end
|
33
|
+
|
29
34
|
# This wrapper allows us to insert external before/after
|
30
35
|
# tasks into every method executed by deplomat.
|
31
36
|
# Very useful for the one-time-tasks implementation.
|
32
37
|
def add_task(*tasks)
|
38
|
+
tasks.each do |t|
|
39
|
+
init_task_callbacks(t)
|
40
|
+
$deplomat_tasks_callbacks[t][:before] << lambda { print_task_status(t, "started") }
|
41
|
+
$deplomat_tasks_callbacks[t][:after] << lambda { print_task_status(t, "finished") }
|
42
|
+
end if $log_tasks_status
|
33
43
|
$deplomat_tasks += tasks
|
34
44
|
end
|
35
45
|
alias :add_tasks :add_task
|
36
46
|
|
37
47
|
def before_task(task_name, requisite_number, &block)
|
38
|
-
|
39
|
-
$deplomat_tasks_callbacks[task_name][:before] ||= []
|
48
|
+
init_task_callbacks(task_name)
|
40
49
|
$deplomat_tasks_callbacks[task_name][:before] << lambda { block.call; update_requisite_number!(requisite_number) }
|
41
50
|
end
|
42
51
|
|
43
52
|
def after_task(task_name, requisite_number, &block)
|
44
|
-
|
45
|
-
$deplomat_tasks_callbacks[task_name][:after] ||= []
|
53
|
+
init_task_callbacks(task_name)
|
46
54
|
$deplomat_tasks_callbacks[task_name][:after] << lambda { block.call; update_requisite_number!(requisite_number) }
|
47
55
|
end
|
48
56
|
|
57
|
+
def init_task_callbacks(task_name)
|
58
|
+
$deplomat_tasks_callbacks[task_name] ||= {}
|
59
|
+
$deplomat_tasks_callbacks[task_name][:before] ||= []
|
60
|
+
$deplomat_tasks_callbacks[task_name][:after] ||= []
|
61
|
+
end
|
62
|
+
|
49
63
|
def execute_tasks!
|
50
64
|
$deplomat_tasks.each do |t|
|
51
65
|
$deplomat_tasks_callbacks[t][:before].each { |block| block.call } if $deplomat_tasks_callbacks[t] && $deplomat_tasks_callbacks[t][:before]
|
data/lib/deplomat/local_node.rb
CHANGED
@@ -6,6 +6,14 @@ module Deplomat
|
|
6
6
|
super
|
7
7
|
end
|
8
8
|
|
9
|
+
def path_exist?(path, log_not_found: true)
|
10
|
+
exists = File.exist?(adjusted_path(path))
|
11
|
+
log "NOT FOUND: #{path}" if log_not_found && !exists
|
12
|
+
exists
|
13
|
+
end
|
14
|
+
alias :path_exists? :path_exist?
|
15
|
+
alias :file_exists? :path_exist?
|
16
|
+
|
9
17
|
end
|
10
18
|
|
11
19
|
end
|
data/lib/deplomat/node.rb
CHANGED
@@ -2,8 +2,7 @@ module Deplomat
|
|
2
2
|
|
3
3
|
class Node
|
4
4
|
|
5
|
-
attr_accessor :log_to, :raise_exceptions, :logfile, :wrap_in
|
6
|
-
attr_reader :current_path
|
5
|
+
attr_accessor :log_to, :raise_exceptions, :logfile, :wrap_in, :current_path
|
7
6
|
attr_writer :stdout_lines_to_ignore
|
8
7
|
|
9
8
|
def stdout_lines_to_ignore
|
@@ -14,11 +13,12 @@ module Deplomat
|
|
14
13
|
end.compact
|
15
14
|
end
|
16
15
|
|
17
|
-
def initialize(logfile: "#{Dir.pwd}/deplomat.log", log_to: [:stdout], path: nil, raise_exceptions: true)
|
16
|
+
def initialize(logfile: "#{Dir.pwd}/deplomat.log", log_to: [:stdout], path: nil, log_tasks_status: true, raise_exceptions: true)
|
18
17
|
@log_to = log_to
|
18
|
+
@log_tasks_status = log_tasks_status
|
19
19
|
@logfile = logfile
|
20
20
|
@raise_exceptions = raise_exceptions
|
21
|
-
@current_path = path if path_exist?(path)
|
21
|
+
@current_path = path.sub(/\/+\Z/, '') if !path.nil? && path_exist?(path)
|
22
22
|
end
|
23
23
|
|
24
24
|
def execute(command, path=@current_path, message: [], stdout_source: :stdout, log_command: true, _raise_exceptions: @raise_exceptions)
|
@@ -105,29 +105,25 @@ module Deplomat
|
|
105
105
|
alias :mkdir :create_dir
|
106
106
|
|
107
107
|
def create_symlink(source, target)
|
108
|
-
execute("ln -
|
108
|
+
execute("ln -sf #{source} #{target}")
|
109
109
|
end
|
110
110
|
alias :ln :create_symlink
|
111
111
|
|
112
|
-
def
|
113
|
-
|
114
|
-
|
115
|
-
|
112
|
+
def adjusted_path(path)
|
113
|
+
if !path.match(/\A\/|~\//)
|
114
|
+
path = "#{@current_path}/#{path}".sub("//", "/")
|
115
|
+
end
|
116
|
+
File.absolute_path(path)
|
116
117
|
end
|
117
|
-
alias :path_exists? :path_exist?
|
118
|
-
alias :file_exists? :path_exist?
|
119
118
|
|
120
119
|
def cd(path)
|
121
|
-
|
122
|
-
|
123
|
-
@current_path = if path
|
120
|
+
path = adjusted_path(path)
|
121
|
+
raise Deplomat::NoSuchPathError, path unless path_exist?(path)
|
122
|
+
@current_path = if path.match(/\A\/|~\//)
|
124
123
|
path
|
125
124
|
else
|
126
|
-
|
127
|
-
end
|
128
|
-
|
129
|
-
# Making sure we don't end up with double // at the end of the path
|
130
|
-
@current_path = @current_path.chomp("/") + "/"
|
125
|
+
"#{@current_path}/#{path}"
|
126
|
+
end.sub(/\/+\Z/, '')
|
131
127
|
end
|
132
128
|
|
133
129
|
def git_push(remote="origin", branch="master")
|
@@ -184,7 +180,7 @@ module Deplomat
|
|
184
180
|
entries_by_date.reverse! if leave[1] == :first
|
185
181
|
entries_by_date = entries_by_date[leave[0]..entries_by_date.length]
|
186
182
|
end
|
187
|
-
entries_by_date.each { |entry| remove("#{path}
|
183
|
+
entries_by_date.each { |entry| remove("#{path}/#{entry}") } if entries_by_date
|
188
184
|
end
|
189
185
|
end
|
190
186
|
|
data/lib/deplomat/remote_node.rb
CHANGED
@@ -50,6 +50,15 @@ module Deplomat
|
|
50
50
|
super("#{@ssh_command} '#{command}'", nil, message: message, stdout_source: stdout_source, log_command: false, _raise_exceptions: _raise_exceptions)
|
51
51
|
end
|
52
52
|
|
53
|
+
def path_exist?(path, log_not_found: true)
|
54
|
+
path = adjusted_path(path)
|
55
|
+
status = execute("test -f #{path} || test -d #{path}", nil, log_command: true, _raise_exceptions: false)[:status]
|
56
|
+
log("NOT FOUND: #{path}") if log_not_found && status == 1
|
57
|
+
status == 0
|
58
|
+
end
|
59
|
+
alias :path_exists? :path_exist?
|
60
|
+
alias :file_exists? :path_exist?
|
61
|
+
|
53
62
|
def upload(what, where, except: nil)
|
54
63
|
except = "--exclude '#{except}'" if except
|
55
64
|
local_execute "rsync -arzve 'ssh #{@port ? "-p #{@port.to_s} " : ""}' #{except} --delete #{what} #{@user}@#{@host}:#{where}", nil
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deplomat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- romanitup
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
requirements: []
|
112
|
-
rubygems_version: 3.1.
|
112
|
+
rubygems_version: 3.1.2
|
113
113
|
signing_key:
|
114
114
|
specification_version: 4
|
115
115
|
summary: Deplomat
|