vagrant-scp-sync 0.5.14 → 0.5.16
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/CHANGELOG.md +17 -0
- data/lib/vagrant-scp-sync/action/scp_sync.rb +67 -25
- data/lib/vagrant-scp-sync/ssh_options.rb +19 -0
- data/lib/vagrant-scp-sync/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39eb1408a8d8e620bac881ec74ac17bab6834e2d0a5506278aa88922c0481585
|
4
|
+
data.tar.gz: 3239d37962771cc1a7e330a633617fce7f6fb96bbb4a522569389d10f9595beb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b0cf61de8a0475b78eb94db00cf064be8e135924ec6760c8e7b21330900fe6451c450854c2257051bf2d9db588b8976cfa56013c6196a01392d2f7e76de97bc
|
7
|
+
data.tar.gz: 2a295ad03d2082d32fbc5ac8dfea8753f44431c79315faaad0394f82f7d5b57856000ec59c817e8f02b5043da6bd61f0ceb4c3e41a92711f3c5989abffc86d5a
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [0.5.16](https://github.com/STARTcloud/vagrant-scp-sync/compare/v0.5.15...v0.5.16) (2024-12-23)
|
4
|
+
|
5
|
+
|
6
|
+
### Bug Fixes
|
7
|
+
|
8
|
+
* single file sync - lint ([d953d76](https://github.com/STARTcloud/vagrant-scp-sync/commit/d953d761e37668f77d2b8d2c4417a3351bd260e8))
|
9
|
+
* single file sync - lint ([9d179eb](https://github.com/STARTcloud/vagrant-scp-sync/commit/9d179eb36d01b85c75aade4a04a59eae8280264b))
|
10
|
+
* single file sync - lint ([dad006f](https://github.com/STARTcloud/vagrant-scp-sync/commit/dad006fa9da87ac57a79a95124a741f9183a67f0))
|
11
|
+
|
12
|
+
## [0.5.15](https://github.com/STARTcloud/vagrant-scp-sync/compare/v0.5.14...v0.5.15) (2024-12-23)
|
13
|
+
|
14
|
+
|
15
|
+
### Bug Fixes
|
16
|
+
|
17
|
+
* single file sync - lint ([3f77284](https://github.com/STARTcloud/vagrant-scp-sync/commit/3f772846fee7d2a42b7ffa6cfcc4bf4547e09466))
|
18
|
+
* single file sync - lint ([029372f](https://github.com/STARTcloud/vagrant-scp-sync/commit/029372fbb906281ee70d0bcae800f71b73f88f73))
|
19
|
+
|
3
20
|
## [0.5.14](https://github.com/STARTcloud/vagrant-scp-sync/compare/v0.5.13...v0.5.14) (2024-12-23)
|
4
21
|
|
5
22
|
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'vagrant/util/platform'
|
4
4
|
require 'vagrant/util/subprocess'
|
5
|
+
require 'vagrant-scp-sync/ssh_options'
|
5
6
|
|
6
7
|
module VagrantPlugins
|
7
8
|
module ScpSync
|
@@ -17,32 +18,75 @@ module VagrantPlugins
|
|
17
18
|
opts[:owner] ||= ssh_info[:username]
|
18
19
|
opts[:group] ||= ssh_info[:username]
|
19
20
|
|
20
|
-
ssh_opts =
|
21
|
+
ssh_opts = SshOptions.build(ssh_info)
|
21
22
|
scp_opts = build_scp_options(opts)
|
22
23
|
|
23
24
|
delete = scp_opts.include?('--delete')
|
24
25
|
|
26
|
+
# Handle source and target path behaviors
|
27
|
+
has_trailing_slash_source = opts[:map].end_with?('/')
|
28
|
+
has_trailing_slash_target = opts[:to].end_with?('/')
|
29
|
+
is_source_directory = File.directory?(source_files)
|
30
|
+
|
25
31
|
if opts[:direction] == :upload || opts[:direction].nil?
|
26
|
-
|
27
|
-
|
28
|
-
|
32
|
+
# For upload direction
|
33
|
+
target_check = build_ssh_command(ssh_opts, "test -e #{target_files} && echo 'EXISTS' || echo 'NOT_EXISTS'", ssh_info)
|
34
|
+
target_type_check = build_ssh_command(ssh_opts, "test -d #{target_files} && echo 'DIR' || echo 'FILE'", ssh_info)
|
35
|
+
|
36
|
+
# Check if target exists and its type
|
37
|
+
target_exists = execute_command_with_output(machine, target_check).strip == 'EXISTS'
|
38
|
+
target_is_dir = target_exists && execute_command_with_output(machine, target_type_check).strip == 'DIR'
|
39
|
+
|
40
|
+
# Determine source path based on trailing slash and directory status
|
41
|
+
source = if is_source_directory && has_trailing_slash_source
|
42
|
+
"#{source_files}/*" # Copy contents of directory
|
43
|
+
else
|
44
|
+
source_files # Copy directory itself or single file
|
45
|
+
end
|
46
|
+
|
47
|
+
# Determine target path based on existence and trailing slash
|
48
|
+
target_base = "#{ssh_info[:username]}@#{ssh_info[:host]}:#{target_files}"
|
49
|
+
target = if target_exists && target_is_dir && !has_trailing_slash_target
|
50
|
+
# If target exists as directory but no trailing slash, put source inside it
|
51
|
+
"#{target_base}/#{File.basename(source_files)}"
|
52
|
+
else
|
53
|
+
target_base
|
54
|
+
end
|
55
|
+
|
56
|
+
# Prepare remote target directory with proper permissions
|
57
|
+
target_dir = target_files
|
58
|
+
target_dir = File.dirname(target_files) unless target_is_dir || has_trailing_slash_target
|
59
|
+
|
29
60
|
make_dir = build_ssh_command(ssh_opts, "sudo mkdir -p #{target_dir}", ssh_info)
|
30
61
|
change_ownership = build_ssh_command(ssh_opts, "sudo chown -R #{opts[:owner]}:#{opts[:group]} #{target_dir}", ssh_info)
|
31
|
-
change_permissions = build_ssh_command(ssh_opts, "sudo chmod 777 #{target_dir}", ssh_info)
|
32
|
-
remove_dir = build_ssh_command(ssh_opts, "sudo rm -rf #{target_files}", ssh_info)
|
62
|
+
change_permissions = build_ssh_command(ssh_opts, "sudo chmod -R 777 #{target_dir}", ssh_info)
|
63
|
+
remove_dir = build_ssh_command(ssh_opts, "sudo rm -rf #{target_files}", ssh_info) if delete
|
64
|
+
|
33
65
|
elsif opts[:direction] == :download
|
66
|
+
# For download direction
|
34
67
|
source = "#{ssh_info[:username]}@#{ssh_info[:host]}:#{source_files}"
|
68
|
+
source = "#{source}/*" if has_trailing_slash_source
|
69
|
+
|
70
|
+
# Create local target directory without sudo
|
35
71
|
target = target_files
|
36
|
-
target_dir =
|
37
|
-
|
72
|
+
target_dir = target_files
|
73
|
+
target_dir = File.dirname(target_files) unless File.directory?(target_files) || has_trailing_slash_target
|
74
|
+
make_dir = "mkdir -p #{target_dir}"
|
75
|
+
end
|
76
|
+
|
77
|
+
# Execute commands with proper error messages
|
78
|
+
execute_command(machine, remove_dir, true, 'scp_sync_error_delete_directory', opts) if delete
|
79
|
+
execute_command(machine, make_dir, true, 'scp_sync_error_make_directory', opts)
|
80
|
+
|
81
|
+
# For upload, ensure remote directory permissions
|
82
|
+
if opts[:direction] == :upload || opts[:direction].nil?
|
83
|
+
execute_command(machine, change_ownership, true, 'scp_sync_error_change_ownership_directory', opts)
|
84
|
+
execute_command(machine, change_permissions, true, 'scp_sync_error_change_permissions_directory', opts)
|
38
85
|
end
|
39
86
|
|
87
|
+
# Build and execute the scp command
|
40
88
|
synchronize = build_scp_command(scp_path, ssh_opts, source, target)
|
41
|
-
execute_command(machine,
|
42
|
-
execute_command(machine, make_dir, false, nil, opts)
|
43
|
-
execute_command(machine, change_ownership, false, nil, opts)
|
44
|
-
execute_command(machine, change_permissions, false, nil, opts)
|
45
|
-
execute_command(machine, synchronize, true, 'scp_sync_folder', opts)
|
89
|
+
execute_command(machine, synchronize, true, 'scp_sync_folder_error', opts)
|
46
90
|
end
|
47
91
|
|
48
92
|
def self.expand_path(path, machine)
|
@@ -50,17 +94,6 @@ module VagrantPlugins
|
|
50
94
|
Vagrant::Util::Platform.fs_real_path(expanded_path).to_s
|
51
95
|
end
|
52
96
|
|
53
|
-
def self.build_ssh_options(ssh_info)
|
54
|
-
opts = %w[
|
55
|
-
-o StrictHostKeyChecking=no
|
56
|
-
-o UserKnownHostsFile=/dev/null
|
57
|
-
-o LogLevel=ERROR
|
58
|
-
]
|
59
|
-
opts << "-o port=#{ssh_info[:port]}"
|
60
|
-
opts << ssh_info[:private_key_path].map { |k| "-i #{k}" }.join(' ')
|
61
|
-
opts
|
62
|
-
end
|
63
|
-
|
64
97
|
def self.build_scp_options(opts)
|
65
98
|
opts[:scp__args] ? Array(opts[:scp__args]).dup : ['--verbose']
|
66
99
|
end
|
@@ -92,13 +125,22 @@ module VagrantPlugins
|
|
92
125
|
raise_scp_error(message_key, command, result.stderr) if raise_error && !result.exit_code.zero?
|
93
126
|
end
|
94
127
|
|
128
|
+
def self.execute_command_with_output(_machine, command)
|
129
|
+
return '' if command.nil?
|
130
|
+
|
131
|
+
result = Vagrant::Util::Subprocess.execute('sh', '-c', command)
|
132
|
+
result.stdout
|
133
|
+
end
|
134
|
+
|
95
135
|
def self.raise_scp_error(message_key, command, stderr)
|
96
136
|
raise Errors.const_get("SyncedFolderScpSync#{message_key.split('_').map(&:capitalize).join}Error"),
|
97
137
|
command: command,
|
98
138
|
stderr: stderr
|
99
139
|
end
|
100
140
|
|
101
|
-
private_class_method :expand_path, :
|
141
|
+
private_class_method :expand_path, :build_scp_options,
|
142
|
+
:build_ssh_command, :build_scp_command, :execute_command,
|
143
|
+
:execute_command_with_output, :raise_scp_error
|
102
144
|
end
|
103
145
|
end
|
104
146
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module ScpSync
|
5
|
+
# Helper class for building SSH options
|
6
|
+
class SshOptions
|
7
|
+
def self.build(ssh_info)
|
8
|
+
opts = %w[
|
9
|
+
-o StrictHostKeyChecking=no
|
10
|
+
-o UserKnownHostsFile=/dev/null
|
11
|
+
-o LogLevel=ERROR
|
12
|
+
]
|
13
|
+
opts << "-o port=#{ssh_info[:port]}"
|
14
|
+
opts << ssh_info[:private_key_path].map { |k| "-i #{k}" }.join(' ')
|
15
|
+
opts
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-scp-sync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Gilbert
|
@@ -143,6 +143,7 @@ files:
|
|
143
143
|
- lib/vagrant-scp-sync/command/scp.rb
|
144
144
|
- lib/vagrant-scp-sync/errors.rb
|
145
145
|
- lib/vagrant-scp-sync/plugin.rb
|
146
|
+
- lib/vagrant-scp-sync/ssh_options.rb
|
146
147
|
- lib/vagrant-scp-sync/synced_folder.rb
|
147
148
|
- lib/vagrant-scp-sync/version.rb
|
148
149
|
- locales/en.yml
|