fastlane-plugin-sftp 0.1.0 → 1.0.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 +1 -6
- data/lib/fastlane/plugin/sftp.rb +0 -2
- data/lib/fastlane/plugin/sftp/actions/sftp_download.rb +8 -5
- data/lib/fastlane/plugin/sftp/actions/sftp_upload.rb +8 -5
- data/lib/fastlane/plugin/sftp/helper/downloader.rb +9 -22
- data/lib/fastlane/plugin/sftp/helper/options.rb +6 -3
- data/lib/fastlane/plugin/sftp/helper/sftp_helper.rb +36 -20
- data/lib/fastlane/plugin/sftp/helper/uploader.rb +2 -9
- data/lib/fastlane/plugin/sftp/version.rb +2 -2
- metadata +49 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc66d85ec195721ab4c6a225cf10ca1f2e3fb17b
|
4
|
+
data.tar.gz: b6143dde40ce31cd9455793c83c00768aac0b7be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c54feaffcef63bc4b86526dca8c741d230ccc5416973541a138f8974284462bffdc6d998d25669a6a7b88fcbe52e1ecb17f9c367b08c96830255fca2049104f4
|
7
|
+
data.tar.gz: 18ac204189bd30f664976663f02f9cbacf444e6c1bddb58982d904b46c51feda708802584e759662319c8989a978ac6e55151607b07d356de103610d0f9130d1
|
data/README.md
CHANGED
@@ -1,11 +1,6 @@
|
|
1
1
|
# sftp plugin
|
2
2
|
|
3
|
-
[](https://rubygems.org/gems/fastlane-plugin-sftp)
|
4
|
-
[](http://rubygems.org/gems/fastlane-plugin-sftp)
|
5
|
-
[](https://coveralls.io/github/suculent/fastlane-plugin-sftp?branch=master)
|
6
|
-
[](https://travis-ci.org/oklimberg/fastlane-plugin-sftp)
|
7
|
-
[](https://twitter.com/oklimberg)
|
8
|
-
[](https://github.com/suculent/fastlane-plugin-apprepo/blob/master/LICENSE)
|
3
|
+
[](https://rubygems.org/gems/fastlane-plugin-sftp) [](http://rubygems.org/gems/fastlane-plugin-sftp) [](https://github.com/oklimberg/fastlane-plugin-sftp/blob/master/LICENSE) [](https://travis-ci.org/oklimberg/fastlane-plugin-sftp) [](https://coveralls.io/github/oklimberg/fastlane-plugin-sftp?branch=master) [](https://twitter.com/oklimberg)
|
9
4
|
|
10
5
|
## Getting Started
|
11
6
|
|
data/lib/fastlane/plugin/sftp.rb
CHANGED
@@ -7,7 +7,7 @@ module Fastlane
|
|
7
7
|
class SftpDownloadAction < Action
|
8
8
|
def self.run(params)
|
9
9
|
# sh 'bundle exec rubocop -D'
|
10
|
-
FastlaneCore::PrintTable.print_values(config: params,
|
10
|
+
FastlaneCore::PrintTable.print_values(config: params, mask_keys: [:server_password, :server_key, :server_key_passphrase], title: "SFTP Download #{Sftp::VERSION} Summary")
|
11
11
|
|
12
12
|
UI.success('SFTP Downloader running...')
|
13
13
|
downloader = Sftp::Downloader.new(params)
|
@@ -26,21 +26,24 @@ module Fastlane
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def self.details
|
29
|
-
|
30
|
-
"TODO"
|
29
|
+
"More information: https://github.com/oklimberg/fastlane-plugin-sftp/"
|
31
30
|
end
|
32
31
|
|
33
32
|
def self.available_options
|
34
33
|
Sftp::Options.available_options_download
|
35
34
|
end
|
36
35
|
|
37
|
-
def self.
|
38
|
-
|
36
|
+
def self.author
|
37
|
+
'oklimberg'
|
39
38
|
end
|
40
39
|
|
41
40
|
def self.is_supported?(platform)
|
42
41
|
true
|
43
42
|
end
|
43
|
+
|
44
|
+
def self.category
|
45
|
+
:misc
|
46
|
+
end
|
44
47
|
end
|
45
48
|
end
|
46
49
|
end
|
@@ -7,7 +7,7 @@ module Fastlane
|
|
7
7
|
class SftpUploadAction < Action
|
8
8
|
def self.run(params)
|
9
9
|
# sh 'bundle exec rubocop -D'
|
10
|
-
FastlaneCore::PrintTable.print_values(config: params,
|
10
|
+
FastlaneCore::PrintTable.print_values(config: params, mask_keys: [:server_password, :server_key, :server_key_passphrase], title: "SFTP Upload #{Sftp::VERSION} Summary")
|
11
11
|
|
12
12
|
UI.success('SFTP Uploader running...')
|
13
13
|
uploader = Sftp::Uploader.new(params)
|
@@ -26,21 +26,24 @@ module Fastlane
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def self.details
|
29
|
-
|
30
|
-
"TODO"
|
29
|
+
"More information: https://github.com/oklimberg/fastlane-plugin-sftp/"
|
31
30
|
end
|
32
31
|
|
33
32
|
def self.available_options
|
34
33
|
Sftp::Options.available_options_upload
|
35
34
|
end
|
36
35
|
|
37
|
-
def self.
|
38
|
-
|
36
|
+
def self.author
|
37
|
+
'oklimberg'
|
39
38
|
end
|
40
39
|
|
41
40
|
def self.is_supported?(platform)
|
42
41
|
true
|
43
42
|
end
|
43
|
+
|
44
|
+
def self.category
|
45
|
+
:misc
|
46
|
+
end
|
44
47
|
end
|
45
48
|
end
|
46
49
|
end
|
@@ -44,9 +44,6 @@ module Fastlane
|
|
44
44
|
# Login & Download all files using RSA key or username/password
|
45
45
|
UI.message('download...')
|
46
46
|
session = Helper::SftpHelper.login(host, user, password, rsa_keypath, rsa_keypath_passphrase)
|
47
|
-
if session.nil?
|
48
|
-
return false
|
49
|
-
end
|
50
47
|
UI.message('Downloading files...')
|
51
48
|
|
52
49
|
session.sftp.connect do |sftp|
|
@@ -70,6 +67,8 @@ module Fastlane
|
|
70
67
|
downloads = []
|
71
68
|
source_files.each do |source|
|
72
69
|
begin
|
70
|
+
UI.message('Checking remote file')
|
71
|
+
UI.message("remote path #{source}")
|
73
72
|
attrs = sftp.stat!(source)
|
74
73
|
if attrs.directory?
|
75
74
|
children = []
|
@@ -96,27 +95,15 @@ module Fastlane
|
|
96
95
|
# @param [String] remote_file_path
|
97
96
|
# @param [String] local_file_path
|
98
97
|
def download_file(sftp, remote_file_path, local_file_path)
|
99
|
-
UI.
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
download = sftp.download(remote_file_path, local_file_path) do |event, _uploader, *_args|
|
107
|
-
case event
|
108
|
-
when :open then
|
109
|
-
UI.message("starting download of file #{remote_file_path} to #{local_file_path}")
|
110
|
-
when :finish then
|
111
|
-
UI.success("download of file #{remote_file_path} to #{local_file_path} successful")
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
98
|
+
UI.success('Loading remote file:')
|
99
|
+
return sftp.download(remote_file_path, local_file_path) do |event, _uploader, *_args|
|
100
|
+
case event
|
101
|
+
when :open then
|
102
|
+
UI.message("starting download of file #{remote_file_path} to #{local_file_path}")
|
103
|
+
when :finish then
|
104
|
+
UI.success("download of file #{remote_file_path} to #{local_file_path} successful")
|
115
105
|
end
|
116
|
-
rescue => e
|
117
|
-
UI.message("remote file not found #{e}")
|
118
106
|
end
|
119
|
-
return download
|
120
107
|
end
|
121
108
|
end
|
122
109
|
end
|
@@ -23,16 +23,19 @@ module Fastlane
|
|
23
23
|
description: 'PASSWORD for your server (not for production)',
|
24
24
|
conflicting_options: [:server_key],
|
25
25
|
conflict_block: proc do |value|
|
26
|
-
UI.user_error!("You can't use '
|
26
|
+
UI.user_error!("You can't use 'server_password' and '#{value.key}' options in one run.")
|
27
27
|
end),
|
28
28
|
FastlaneCore::ConfigItem.new(key: :server_key,
|
29
29
|
short_option: '-k',
|
30
|
-
optional:
|
30
|
+
optional: true,
|
31
31
|
env_name: 'SERVER_KEY',
|
32
32
|
description: 'RSA key for your server',
|
33
33
|
conflicting_options: [:server_password],
|
34
34
|
conflict_block: proc do |value|
|
35
|
-
UI.user_error!("You can't use '
|
35
|
+
UI.user_error!("You can't use 'server_key' and '#{value.key}' options in one run.")
|
36
|
+
end,
|
37
|
+
verify_block: proc do |value|
|
38
|
+
UI.user_error!("Key file '#{value}' does not exist") unless File.exist?(value)
|
36
39
|
end),
|
37
40
|
FastlaneCore::ConfigItem.new(key: :server_key_passphrase,
|
38
41
|
short_option: '-v',
|
@@ -12,26 +12,39 @@ module Fastlane
|
|
12
12
|
#
|
13
13
|
|
14
14
|
def self.login(host, user, password, rsa_keypath, rsa_keypath_passphrase)
|
15
|
-
if host.nil? || user.nil?
|
16
|
-
UI.user_error('server_url, server_user and server_password or server_key must be set')
|
17
|
-
return nil
|
15
|
+
if host.nil? || user.nil? || (password.nil? && rsa_keypath.nil?)
|
16
|
+
UI.user_error!('server_url, server_user and server_password or server_key must be set')
|
18
17
|
end
|
19
18
|
|
20
19
|
if rsa_keypath
|
20
|
+
# will raise an excetion if file is empty
|
21
21
|
rsa_key = Helper::SftpHelper.load_rsa_key(rsa_keypath)
|
22
|
-
if rsa_key.nil?
|
23
|
-
UI.user_error("Failed to load RSA key... #{rsa_keypath}")
|
24
|
-
end
|
25
22
|
end
|
26
23
|
|
24
|
+
logging_level = :warn
|
25
|
+
if ENV["DEBUG"] == "1"
|
26
|
+
logging_level = :debug
|
27
|
+
end
|
28
|
+
options = {
|
29
|
+
verbose: logging_level,
|
30
|
+
non_interactive: true
|
31
|
+
}
|
27
32
|
if !rsa_key.nil?
|
28
33
|
UI.message('Logging in with RSA key...')
|
29
|
-
|
34
|
+
options = options.merge({
|
35
|
+
key_data: rsa_key,
|
36
|
+
keys_only: true,
|
37
|
+
passphrase: rsa_keypath_passphrase,
|
38
|
+
auth_methods: ["publickey"]
|
39
|
+
})
|
30
40
|
else
|
31
41
|
UI.message('Logging in with username/password...')
|
32
|
-
|
42
|
+
options = options.merge({
|
43
|
+
password: password,
|
44
|
+
auth_methods: ["password"]
|
45
|
+
})
|
33
46
|
end
|
34
|
-
return
|
47
|
+
return Net::SSH.start(host, user, options)
|
35
48
|
end
|
36
49
|
|
37
50
|
# Check file existence locally
|
@@ -52,22 +65,25 @@ module Fastlane
|
|
52
65
|
end
|
53
66
|
|
54
67
|
def self.remote_mkdir(sftp, remote_path)
|
55
|
-
sftp.mkdir(remote_path)
|
68
|
+
sftp.mkdir!(remote_path)
|
56
69
|
rescue Net::SFTP::StatusException => e
|
57
|
-
|
70
|
+
# the returned code depends on the implementation of the SFTP server
|
71
|
+
# we handle code FX_FILE_ALREADY_EXISTS and FX_FAILURE the same
|
72
|
+
codes = Net::SFTP::Constants::StatusCodes
|
73
|
+
raise if e.code != codes::FX_FAILURE && e.code != codes::FX_FILE_ALREADY_EXISTS
|
58
74
|
UI.message("Remote dir #{remote_path} exists.")
|
59
75
|
end
|
60
76
|
|
61
77
|
def self.load_rsa_key(rsa_keypath)
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
rsa_key
|
78
|
+
UI.user_error!("RSA key file #{rsa_keypath} does not exist") unless check_file(rsa_keypath)
|
79
|
+
|
80
|
+
rsa_key = IO.read(rsa_keypath)
|
81
|
+
if !rsa_key.to_s.empty?
|
82
|
+
UI.success('Successfully loaded RSA key...')
|
83
|
+
else
|
84
|
+
UI.user_error!("Failed to load RSA key... #{rsa_keypath}")
|
70
85
|
end
|
86
|
+
return rsa_key
|
71
87
|
end
|
72
88
|
|
73
89
|
def self.generate_remote_path(user, target_dir)
|
@@ -75,7 +91,7 @@ module Fastlane
|
|
75
91
|
if user != "root"
|
76
92
|
path = File.join('/home', path)
|
77
93
|
end
|
78
|
-
path
|
94
|
+
return path
|
79
95
|
end
|
80
96
|
end
|
81
97
|
end
|
@@ -45,10 +45,8 @@ module Fastlane
|
|
45
45
|
UI.message('upload...')
|
46
46
|
|
47
47
|
session = Helper::SftpHelper.login(host, user, password, rsa_keypath, rsa_keypath_passphrase)
|
48
|
-
if session.nil?
|
49
|
-
return false
|
50
|
-
end
|
51
48
|
UI.message('Uploading files...')
|
49
|
+
|
52
50
|
session.sftp.connect do |sftp|
|
53
51
|
Helper::SftpHelper.remote_mkdir(sftp, Helper::SftpHelper.generate_remote_path(user, target_dir))
|
54
52
|
path = target_dir
|
@@ -82,17 +80,12 @@ module Fastlane
|
|
82
80
|
# @param [String] local_file_path
|
83
81
|
# @param [String] remote_file_path
|
84
82
|
def upload_file(sftp, local_file_path, remote_file_path)
|
85
|
-
unless Helper::SftpHelper.check_file(local_file_path)
|
86
|
-
UI.message("local file #{local_file_path} not found #{e}")
|
87
|
-
return
|
88
|
-
end
|
89
|
-
|
90
83
|
if File.file?(local_file_path)
|
91
84
|
type = "file"
|
92
85
|
else
|
93
86
|
type = "folder"
|
94
87
|
end
|
95
|
-
UI.message("starting upload of #{type} #{local_file_path} to #{
|
88
|
+
UI.message("starting upload of #{type} #{local_file_path} to #{remote_file_path}")
|
96
89
|
return sftp.upload(local_file_path, remote_file_path) do |event, _uploader, *args|
|
97
90
|
case event
|
98
91
|
when :mkdir then
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Fastlane
|
2
2
|
module Sftp
|
3
|
-
VERSION = "
|
4
|
-
SUMMARY = 'Fastlane plugin
|
3
|
+
VERSION = "1.0.0".freeze
|
4
|
+
SUMMARY = 'Fastlane plugin to upload or dowload files/folders via SFTP'.freeze
|
5
5
|
DESCRIPTION = 'Fastlane plugin SFTP'.freeze
|
6
6
|
end
|
7
7
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastlane-plugin-sftp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oliver Limberg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-ssh
|
@@ -16,20 +16,20 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '5.1'
|
20
20
|
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
22
|
+
version: 5.1.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - "~>"
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
29
|
+
version: '5.1'
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
32
|
+
version: 5.1.0
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: net-sftp
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -50,6 +50,34 @@ dependencies:
|
|
50
50
|
- - ">="
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: 2.1.2
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: ed25519
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '1.2'
|
60
|
+
type: :runtime
|
61
|
+
prerelease: false
|
62
|
+
version_requirements: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - "~>"
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '1.2'
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: bcrypt_pbkdf
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - "~>"
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '1.0'
|
74
|
+
type: :runtime
|
75
|
+
prerelease: false
|
76
|
+
version_requirements: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - "~>"
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '1.0'
|
53
81
|
- !ruby/object:Gem::Dependency
|
54
82
|
name: pry
|
55
83
|
requirement: !ruby/object:Gem::Requirement
|
@@ -176,8 +204,22 @@ dependencies:
|
|
176
204
|
- - ">="
|
177
205
|
- !ruby/object:Gem::Version
|
178
206
|
version: 2.116.0
|
207
|
+
- !ruby/object:Gem::Dependency
|
208
|
+
name: coveralls
|
209
|
+
requirement: !ruby/object:Gem::Requirement
|
210
|
+
requirements:
|
211
|
+
- - ">="
|
212
|
+
- !ruby/object:Gem::Version
|
213
|
+
version: '0'
|
214
|
+
type: :development
|
215
|
+
prerelease: false
|
216
|
+
version_requirements: !ruby/object:Gem::Requirement
|
217
|
+
requirements:
|
218
|
+
- - ">="
|
219
|
+
- !ruby/object:Gem::Version
|
220
|
+
version: '0'
|
179
221
|
description:
|
180
|
-
email:
|
222
|
+
email: oklimberg@gmail
|
181
223
|
executables: []
|
182
224
|
extensions: []
|
183
225
|
extra_rdoc_files: []
|