hem-tasks-rsync 2.3.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hem/lib/patches/rake.rb +1 -1
- data/lib/hem/tasks/rsync/deps.rb +21 -50
- data/lib/hem/tasks/rsync/version.rb +1 -1
- data/lib/hem/tasks/rsync/vm.rb +4 -40
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: beacc1cb0322af29f8d32050646b29fe4aafcf53
|
4
|
+
data.tar.gz: 7d46d11304b50912820aafb45a7a3e6ebf033804
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c8918e6e3b0676d2dd67e007507410107d918df4c9c3ff686d17b25c7651ade0723efccd728cdbf5e0154c4fe9812c3b411a54379310d4ea24c4e713b8d6375
|
7
|
+
data.tar.gz: 81477e4f3607a42d4defd8b73852b7a8b89bd3f85e633cf000f710340443b7c7a9e5e6f896d1d91944be7cdb3ca51a3d4a740e6e658a246eaf547eb73d945d4b
|
data/lib/hem/lib/patches/rake.rb
CHANGED
data/lib/hem/tasks/rsync/deps.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# ^ Syntax hint
|
3
3
|
|
4
|
-
|
5
|
-
after 'deps:composer', 'deps:sync:reload_or_sync'
|
4
|
+
after 'deps:composer', 'deps:sync:vendor_directory'
|
6
5
|
|
7
6
|
after 'vm:reload', 'deps:composer_preload'
|
8
7
|
after 'vm:start', 'deps:composer_preload'
|
@@ -16,8 +15,6 @@ namespace :deps do
|
|
16
15
|
|
17
16
|
Rake::Task['tools:composer'].invoke
|
18
17
|
|
19
|
-
Rake::Task['deps:sync:composer_files_to_guest'].execute
|
20
|
-
|
21
18
|
packages = args[:packages].map(&:shellescape).join(' ')
|
22
19
|
|
23
20
|
Hem.ui.title 'Updating composer dependencies'
|
@@ -33,9 +30,6 @@ namespace :deps do
|
|
33
30
|
begin
|
34
31
|
shell(*args)
|
35
32
|
|
36
|
-
Rake::Task['deps:sync:composer_files_to_guest'].execute
|
37
|
-
Rake::Task['vm:rsync_mount_sync'].execute
|
38
|
-
|
39
33
|
complete = true
|
40
34
|
rescue Hem::ExternalCommandError
|
41
35
|
Hem.ui.warning 'Updating composer dependencies locally failed!'
|
@@ -43,12 +37,9 @@ namespace :deps do
|
|
43
37
|
end
|
44
38
|
end
|
45
39
|
|
46
|
-
unless complete
|
47
|
-
run(*args)
|
40
|
+
run(*args) unless complete
|
48
41
|
|
49
|
-
|
50
|
-
Rake::Task['deps:sync:vendor_directory_from_guest'].execute
|
51
|
-
end
|
42
|
+
Rake::Task['deps:sync:vendor_directory'].execute
|
52
43
|
|
53
44
|
Hem.ui.success 'Composer dependencies updated'
|
54
45
|
end
|
@@ -59,36 +50,29 @@ namespace :deps do
|
|
59
50
|
desc 'Preload the composer files into file system cache'
|
60
51
|
task :composer_preload do
|
61
52
|
Hem.ui.title 'Composer PHP files loading into file system cache'
|
62
|
-
|
53
|
+
command = <<-COMMAND
|
54
|
+
if [ -e vendor ]; then \
|
55
|
+
find vendor -type f -name "*.php" -exec cat {} > /dev/null + ; \
|
56
|
+
fi
|
57
|
+
COMMAND
|
58
|
+
run command, realtime: true
|
63
59
|
Hem.ui.success 'Composer PHP files loaded into file system cache'
|
64
60
|
end
|
65
61
|
|
66
62
|
desc 'Syncing dependencies to/from the VM'
|
67
63
|
namespace :sync do
|
68
|
-
desc '
|
69
|
-
task :
|
70
|
-
Hem.ui.title '
|
64
|
+
desc 'Syncing vendor directory changes, in either direction'
|
65
|
+
task :vendor_directory do
|
66
|
+
Hem.ui.title 'Syncing vendor directory changes'
|
71
67
|
|
72
|
-
Rake::Task['vm:
|
73
|
-
from_path:
|
74
|
-
to_path:
|
75
|
-
|
76
|
-
)
|
77
|
-
Rake::Task['vm:rsync_manual'].execute(
|
78
|
-
from_path: File.join(Hem.project_config.vm.project_mount_path, 'composer.lock'),
|
79
|
-
to_path: File.join(Hem.project_path, 'composer.lock'),
|
80
|
-
is_reverse: true
|
68
|
+
Rake::Task['vm:sync_guest_changes'].execute(
|
69
|
+
from_path: 'vendor/',
|
70
|
+
to_path: 'vendor',
|
71
|
+
deciding_file_path: File.join('vendor', 'autoload.php')
|
81
72
|
)
|
82
|
-
Hem.ui.success 'Downloaded composer files to host'
|
83
|
-
end
|
84
|
-
|
85
|
-
desc 'Upload the composer.json and lock from the host to the guest'
|
86
|
-
task :composer_files_to_guest do
|
87
|
-
Hem.ui.title 'Uploading composer files to guest'
|
88
|
-
|
89
|
-
Rake::Task['vm:upload_root_files_to_guest'].invoke
|
90
73
|
|
91
|
-
Hem.ui.success
|
74
|
+
Hem.ui.success 'Synced vendor directory changes'
|
75
|
+
Hem.ui.separator
|
92
76
|
end
|
93
77
|
|
94
78
|
desc 'Download the vendor directory from the guest to the host'
|
@@ -97,10 +81,10 @@ namespace :deps do
|
|
97
81
|
|
98
82
|
Rake::Task['vm:sync_guest_changes'].execute(
|
99
83
|
from_path: 'vendor/',
|
100
|
-
to_path: 'vendor'
|
101
|
-
deciding_file_path: File.join('vendor', 'autoload.php'),
|
102
|
-
host_to_guest_allowed: false
|
84
|
+
to_path: 'vendor'
|
103
85
|
)
|
86
|
+
|
87
|
+
Hem.ui.success('Downloaded vendor directory changes from guest')
|
104
88
|
end
|
105
89
|
|
106
90
|
desc 'Upload the vendor directory from the host to the guest'
|
@@ -114,18 +98,5 @@ namespace :deps do
|
|
114
98
|
|
115
99
|
Hem.ui.success('Uploaded vendor directory changes to guest')
|
116
100
|
end
|
117
|
-
|
118
|
-
desc 'Reload the VM to use NFS mounts per directory, or sync rsync mounts if already enabled'
|
119
|
-
task :reload_or_sync do
|
120
|
-
one_mount_point = run 'grep "/vagrant " /proc/mounts || true', capture: true
|
121
|
-
if one_mount_point != ''
|
122
|
-
Rake::Task['vm:reload'].execute
|
123
|
-
Rake::Task['vm:provision_shell'].execute
|
124
|
-
Rake::Task['vm:upload_root_files_to_guest'].execute
|
125
|
-
else
|
126
|
-
Rake::Task['deps:sync:vendor_directory_from_guest'].execute
|
127
|
-
Rake::Task['vm:rsync_mount_sync'].execute
|
128
|
-
end
|
129
|
-
end
|
130
101
|
end
|
131
102
|
end
|
data/lib/hem/tasks/rsync/vm.rb
CHANGED
@@ -2,47 +2,9 @@
|
|
2
2
|
# ^ Syntax hint
|
3
3
|
|
4
4
|
after 'vm:reload', 'vm:provision_shell'
|
5
|
-
after 'vm:reload', 'vm:upload_root_files_to_guest'
|
6
5
|
after 'vm:start', 'vm:provision_shell'
|
7
|
-
after 'vm:start', 'vm:upload_root_files_to_guest'
|
8
6
|
|
9
7
|
namespace :vm do
|
10
|
-
desc 'Trigger a sync to occur for rsync mountpoints'
|
11
|
-
task :rsync_mount_sync do
|
12
|
-
vagrantfile do
|
13
|
-
Hem.ui.title 'Syncing directories'
|
14
|
-
vagrant_exec 'rsync'
|
15
|
-
Hem.ui.success('Vendor directory synced')
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
desc 'Rsync any files in the project root the guest'
|
20
|
-
task :upload_root_files_to_guest do
|
21
|
-
one_mount_point = run 'grep "/vagrant " /proc/mounts || true', capture: true
|
22
|
-
next unless one_mount_point == ''
|
23
|
-
|
24
|
-
Hem.ui.title 'Uploading project root files to the guest'
|
25
|
-
|
26
|
-
files = shell "find '#{Hem.project_path}' -type f -maxdepth 1 -print0",
|
27
|
-
local: true, on: :host, capture: true, pwd: Hem.project_path
|
28
|
-
|
29
|
-
next unless files
|
30
|
-
|
31
|
-
run "sudo chown vagrant:vagrant '#{Hem.project_config.vm.project_mount_path}'", realtime: true
|
32
|
-
|
33
|
-
rsync_command = <<-COMMAND
|
34
|
-
find '.' -type f -maxdepth 1 -print0 | \
|
35
|
-
rsync --files-from=- --from0 --human-readable --progress \
|
36
|
-
--verbose --compress --archive --rsh='%s' \
|
37
|
-
'#{Hem.project_path}' 'default:#{Hem.project_config.vm.project_mount_path}'
|
38
|
-
COMMAND
|
39
|
-
args = [rsync_command, { local: true, realtime: true, indent: 2, on: :host, pwd: Hem.project_path }]
|
40
|
-
require_relative File.join('..', '..', 'lib', 'vm', 'ReverseCommand')
|
41
|
-
Hem::Lib::Vm::ReverseCommand.new(*args).run
|
42
|
-
|
43
|
-
Hem.ui.success 'Uploaded project root files to the guest'
|
44
|
-
end
|
45
|
-
|
46
8
|
desc 'Rsync from host to guest, or if in reverse mode, from guest to host'
|
47
9
|
argument :from_path
|
48
10
|
argument :to_path
|
@@ -90,6 +52,8 @@ namespace :vm do
|
|
90
52
|
argument :deciding_file_path
|
91
53
|
argument :host_to_guest_allowed, optional: true, default: true
|
92
54
|
task :sync_guest_changes do |_task_name, args|
|
55
|
+
args[:host_to_guest_allowed] = true unless args.key? :host_to_guest_allowed
|
56
|
+
|
93
57
|
Hem.ui.title "Determining if #{args[:deciding_file_path]} is newer on the host or guest"
|
94
58
|
|
95
59
|
local_file_path = File.join(Hem.project_path, args[:deciding_file_path])
|
@@ -112,8 +76,8 @@ namespace :vm do
|
|
112
76
|
)
|
113
77
|
elsif args[:host_to_guest_allowed] && local_file_modified.to_i > remote_file_modified.to_i
|
114
78
|
Hem.ui.success("Host file #{args[:deciding_file_path]} is newer, syncing to guest")
|
115
|
-
from_path = File.join(Hem.project_path, args[:
|
116
|
-
to_path = File.join(Hem.project_config.vm.project_mount_path, args[:
|
79
|
+
from_path = File.join(Hem.project_path, args[:from_path])
|
80
|
+
to_path = File.join(Hem.project_config.vm.project_mount_path, args[:to_path])
|
117
81
|
|
118
82
|
Rake::Task['vm:rsync_manual'].execute(
|
119
83
|
from_path: from_path,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hem-tasks-rsync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kieren Evans
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|