fastlane-plugin-carthage_cache_ftps 0.1.3

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 958099796491c60baa9a025946f3a9ba5b93780a
4
+ data.tar.gz: 886efc29362b1090a3e991c9fa733e2a61e17d32
5
+ SHA512:
6
+ metadata.gz: 27b42a1ed8695f21c59c8d8ea7d19542a7b2666c425fa8bc316456378df3f80e59f6f26c38889b8e5a2874182f77b0a3a9e2ebf1e77fe0e19dcff682334b172a
7
+ data.tar.gz: 82cb326aa8f3680a65a96091973a949889fdfd45b64d9599afaff969d6a0ab77730eabfbf7cecb2852674ab4842050d01f54559fa6aa408c0e5486dfa845f2d4
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Wolfgang Lutz <wlut@num42.de>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,113 @@
1
+ # carthage_cache_ftps plugin
2
+
3
+ [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-carthage_cache_ftps)
4
+
5
+ ## Getting Started
6
+
7
+ This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-carthage_cache_ftps`, add it to your project by running:
8
+
9
+ ```bash
10
+ fastlane add_plugin carthage_cache_ftps
11
+ ```
12
+
13
+ ## About carthage_cache_ftps
14
+
15
+ Allows to publish or install the carthage builds via FTPS or AWS to avoid recompilation.
16
+
17
+
18
+ ### AWS
19
+
20
+ First, run
21
+
22
+ ```bash
23
+ carthage_cache config
24
+ ```
25
+
26
+ to create the `.carthage_cache.yml` file.
27
+
28
+ Then, call the plugin from the Fastfile using
29
+
30
+ ```ruby
31
+ carthage_cache (
32
+ command: "install" #This is the default and can be omitted
33
+ )
34
+ ```
35
+
36
+ to install from cache and use
37
+
38
+ ```ruby
39
+ carthage_cache (
40
+ command: "publish"
41
+ )
42
+ ```
43
+
44
+ to push the current state to the remote.
45
+
46
+ Run
47
+
48
+ ```bash
49
+ bundle exec fastlane actions carthage_cache
50
+ ```
51
+
52
+ for more information.
53
+
54
+ ### FTPS
55
+
56
+ Call the plugin from the Fastfile using
57
+
58
+ ```ruby
59
+ carthage_cache_ftps (
60
+ host: "ftp.yourdomain.de",
61
+ user: "username",
62
+ command: "install" #This is the default and can be omitted
63
+ )
64
+ ```
65
+
66
+ to install from cache and use
67
+
68
+ ```ruby
69
+ carthage_cache (
70
+ host: "ftp.yourdomain.de",
71
+ user: "username",
72
+ command: "publish"
73
+ )
74
+ ```
75
+
76
+ to push the current state to the remote.
77
+
78
+ Run
79
+
80
+ ```bash
81
+ bundle exec fastlane actions carthage_cache_ftps
82
+ ```
83
+
84
+ for more information and parameters.
85
+
86
+ ## Run tests for this plugin
87
+
88
+ To run both the tests, and code style validation, run
89
+
90
+ ```
91
+ rake
92
+ ```
93
+
94
+ To automatically fix many of the styling issues, use
95
+ ```
96
+ rubocop -a
97
+ ```
98
+
99
+ ## Issues and Feedback
100
+
101
+ For any other issues and feedback about this plugin, please submit it to this repository.
102
+
103
+ ## Troubleshooting
104
+
105
+ If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
106
+
107
+ ## Using _fastlane_ Plugins
108
+
109
+ For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
110
+
111
+ ## About _fastlane_
112
+
113
+ _fastlane_ is the easiest way to automate beta deployments and releases for your iOS and Android apps. To learn more, check out [fastlane.tools](https://fastlane.tools).
@@ -0,0 +1,16 @@
1
+ require 'fastlane/plugin/carthage_cache_ftps/version'
2
+
3
+ module Fastlane
4
+ module CarthageCacheFtps
5
+ # Return all .rb files inside the "actions" and "helper" directory
6
+ def self.all_classes
7
+ Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))]
8
+ end
9
+ end
10
+ end
11
+
12
+ # By default we want to import all available actions and helpers
13
+ # A plugin can contain any number of actions and plugins
14
+ Fastlane::CarthageCacheFtps.all_classes.each do |current|
15
+ require current
16
+ end
@@ -0,0 +1,57 @@
1
+ require 'carthage_cache'
2
+
3
+ module Fastlane
4
+ module Actions
5
+ class CarthageCacheAction < Action
6
+ def self.run(params)
7
+ FastlaneCore::PrintTable.print_values(config: params, title: "Summary for Carthage Cache")
8
+
9
+ application = CarthageCache::Application.new(".", true, {})
10
+
11
+ command = params.values[:command]
12
+
13
+ case command.to_sym
14
+ when :install
15
+ exit 1 unless application.install_archive
16
+ when :publish
17
+ exit 1 unless application.create_archive
18
+ end
19
+ end
20
+
21
+ def self.description
22
+ "Allows to publish or install the carthage builds to AWS to avoid recompilation. Needs a configuration created by 'carthage_cache config'"
23
+ end
24
+
25
+ def self.authors
26
+ ["Wolfgang Lutz"]
27
+ end
28
+
29
+ def self.return_value
30
+ # If your method provides a return value, you can describe here what it does
31
+ end
32
+
33
+ def self.details
34
+ "This action uses the carthage_cache_gem to cache the built carthage libraries remotely on AWS."
35
+ end
36
+
37
+ def self.available_options
38
+ [
39
+ FastlaneCore::ConfigItem.new(key: :command,
40
+ env_name: "CARTHAGE_CACHE_COMMAND",
41
+ description: "The carthage cache command to use. Allowed values: publish, install",
42
+ optional: false,
43
+ type: String,
44
+ default_value: "install",
45
+ short_option: "c",
46
+ verify_block: proc do |value|
47
+ UI.user_error!("Unknown carthage cache command. Allowed: install, publish") unless ["install", "publish"].include?(value)
48
+ end)
49
+ ]
50
+ end
51
+
52
+ def self.is_supported?(platform)
53
+ [:ios, :mac].include?(platform)
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,110 @@
1
+ require 'carthage_cache'
2
+
3
+ module Fastlane
4
+ module Actions
5
+ class CarthageCacheFtpsAction < Action
6
+ def self.run(params)
7
+ FastlaneCore::PrintTable.print_values(config: params, title: "Summary for Carthage Cache FTPS")
8
+
9
+ host = params.values[:host]
10
+ remote_subfolder = params.values[:subfolder]
11
+ username = params.values[:username]
12
+ password = params.values[:password] || PasswordHelper.new.password(host, username)
13
+
14
+ config = {
15
+ bucket_name: remote_subfolder,
16
+ aws_s3_client_options: {
17
+ region: host,
18
+ aws_access_key_id: username,
19
+ secret_access_key: password,
20
+ access_key_id: "bla"
21
+ }
22
+ }
23
+
24
+ local_path = params.values[:local_path]
25
+ application = CarthageCache::Application.new(local_path, true, config, repository: FTPRepository)
26
+
27
+ puts application.inspect
28
+
29
+ command = params.values[:command]
30
+
31
+ case command.to_sym
32
+ when :install
33
+ exit 1 unless application.install_archive
34
+ when :publish
35
+ exit 1 unless application.create_archive
36
+ end
37
+ end
38
+
39
+ def self.description
40
+ "Allows to publish or install the carthage builds via ftps to avoid recompilation"
41
+ end
42
+
43
+ def self.authors
44
+ ["Wolfgang Lutz"]
45
+ end
46
+
47
+ def self.return_value
48
+ # If your method provides a return value, you can describe here what it does
49
+ end
50
+
51
+ def self.details
52
+ "This plugin extends the carthage_cache_gem with ftps functionality, to be able to cache the built carthage libraries remotely on an ftp server."
53
+ end
54
+
55
+ def self.available_options
56
+ [
57
+ FastlaneCore::ConfigItem.new(key: :host,
58
+ env_name: "CARTHAGE_CACHE_FTPS_HOST",
59
+ description: "The ftps host to use for carthage cache",
60
+ optional: false,
61
+ type: String,
62
+ default_value: "127.0.0.1",
63
+ short_option: "h"),
64
+ FastlaneCore::ConfigItem.new(key: :username,
65
+ env_name: "CARTHAGE_CACHE_FTPS_USERNAME",
66
+ description: "The ftps username to use for carthage cache",
67
+ optional: false,
68
+ type: String,
69
+ default_value: "anonymous",
70
+ short_option: "u"),
71
+ FastlaneCore::ConfigItem.new(key: :password,
72
+ env_name: "CARTHAGE_CACHE_FTPS_PASSWORD",
73
+ description: "The ftps password to use for carthage cache. If not given, keychain is used",
74
+ optional: true,
75
+ type: String,
76
+ sensitive: true,
77
+ short_option: "p"),
78
+ FastlaneCore::ConfigItem.new(key: :command,
79
+ env_name: "CARTHAGE_CACHE_COMMAND",
80
+ description: "The carthage cache command to use. Allowed values: publish, install",
81
+ optional: false,
82
+ type: String,
83
+ default_value: "install",
84
+ short_option: "c",
85
+ verify_block: proc do |value|
86
+ UI.user_error!("Unknown carthage cache command. Allowed: install, publish") unless ["install", "publish"].include?(value)
87
+ end),
88
+ FastlaneCore::ConfigItem.new(key: :subfolder,
89
+ env_name: "CARTHAGE_CACHE_FTPS_SUBFOLDER",
90
+ description: "The subfolder to use for carthage cache",
91
+ optional: true,
92
+ type: String,
93
+ default_value: "carthage_cache",
94
+ short_option: "f"),
95
+ FastlaneCore::ConfigItem.new(key: :local_path,
96
+ env_name: "CARTHAGE_CACHE_FTPS_LOCAL_PATH",
97
+ description: "The path to the folder containing the 'Carthage' folder",
98
+ optional: true,
99
+ type: String,
100
+ default_value: ".",
101
+ short_option: "l")
102
+ ]
103
+ end
104
+
105
+ def self.is_supported?(platform)
106
+ [:ios, :mac].include?(platform)
107
+ end
108
+ end
109
+ end
110
+ end
@@ -0,0 +1,31 @@
1
+ require "fastlane_core"
2
+
3
+ module Fastlane
4
+ module Helper
5
+ class CarthageCacheFtpsHelper
6
+ UI = FastlaneCore::UI
7
+
8
+ def self.ask_password(message: "Passphrase for FTP: ", confirm: true)
9
+ ensure_ui_interactive
10
+ loop do
11
+ password = UI.password(message)
12
+ if confirm
13
+ password2 = UI.password("Type passphrase again: ")
14
+ if password == password2
15
+ return password
16
+ end
17
+ else
18
+ return password
19
+ end
20
+ UI.error("Passphrases differ. Try again")
21
+ end
22
+ end
23
+
24
+ def self.ensure_ui_interactive
25
+ raise "This code should only run in interactive mode" unless UI.interactive?
26
+ end
27
+
28
+ private_class_method :ensure_ui_interactive
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,45 @@
1
+ class FTPRepository
2
+ require 'double_bag_ftps'
3
+
4
+ attr_reader :ftps_host
5
+ attr_reader :ftps_remote_path
6
+ attr_reader :ftps_username
7
+ attr_reader :ftps_password
8
+
9
+ def initialize(host, config)
10
+ @ftps_host = config[:region]
11
+ @ftps_remote_path = host
12
+ @ftps_username = config[:aws_access_key_id]
13
+ @ftps_password = config[:secret_access_key]
14
+ end
15
+
16
+ def login
17
+ # Connect to a host using explicit FTPS and do not verify the host's cert
18
+ ftps = DoubleBagFTPS.new
19
+ ftps.ssl_context = DoubleBagFTPS.create_ssl_context(verify_mode: OpenSSL::SSL::VERIFY_NONE)
20
+ ftps.connect(@ftps_host)
21
+ ftps.login(@ftps_username, @ftps_password)
22
+ ftps
23
+ end
24
+
25
+ def archive_exist?(archive_filename)
26
+ ftps = login
27
+ files = ftps.list
28
+ ftps.close
29
+ return !files.select { |f| f.include? "#{@ftps_remote_path}/#{archive_filename}" }.empty?
30
+ end
31
+
32
+ def download(archive_filename, destination_path)
33
+ ftps = login
34
+ ftps.getbinaryfile("#{@ftps_remote_path}/#{archive_filename}", destination_path)
35
+ ftps.close
36
+ end
37
+
38
+ def upload(archive_filename, archive_path)
39
+ ftps = login
40
+ files = ftps.list
41
+ ftps.mkdir(@ftps_remote_path) if files.select { |f| f.include? @ftps_remote_path }.empty?
42
+ ftps.putbinaryfile(archive_path, "#{@ftps_remote_path}/#{archive_filename}")
43
+ ftps.close
44
+ end
45
+ end
@@ -0,0 +1,37 @@
1
+ require 'security'
2
+ require 'shellwords'
3
+
4
+ class PasswordHelper
5
+ UI = FastlaneCore::UI
6
+
7
+ def server_name(host, username)
8
+ ["carthage_cache_ftps", host, username].join("_")
9
+ end
10
+
11
+ def password(host, username)
12
+ password = ENV["CARTHAGE_CACHE_FTPS_PASSWORD"]
13
+ unless password
14
+ item = Security::InternetPassword.find(server: server_name(host, username))
15
+ password = item.password if item
16
+ end
17
+
18
+ unless password
19
+ if !UI.interactive?
20
+ UI.error "Neither the CARTHAGE_CACHE_FTPS_PASSWORD environment variable nor the local keychain contained a password."
21
+ UI.error "Bailing out instead of asking for a password, since this is non-interactive mode."
22
+ UI.user_error!("Try setting the CARTHAGE_CACHE_FTPS_PASSWORD environment variable, or temporarily enable interactive mode to store a password.")
23
+ else
24
+ UI.important "Enter the passphrase that should be used to login to the ftps"
25
+ UI.important "This passphrase is specific per host and username and will be stored in your local keychain"
26
+ password = Fastlane::Helper::CarthageCacheFtpsHelper.ask_password(confirm: false)
27
+ store_password(host, username, password)
28
+ end
29
+ end
30
+
31
+ return password
32
+ end
33
+
34
+ def store_password(host, username, password)
35
+ Security::InternetPassword.add(server_name(host, username), "", password)
36
+ end
37
+ end
@@ -0,0 +1,5 @@
1
+ module Fastlane
2
+ module CarthageCacheFtps
3
+ VERSION = "0.1.3"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,164 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fastlane-plugin-carthage_cache_ftps
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.3
5
+ platform: ruby
6
+ authors:
7
+ - Wolfgang Lutz
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-07-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: carthage_cache
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: double-bag-ftps
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: fastlane
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: 2.44.1
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: 2.44.1
125
+ description:
126
+ email: wlut@num42.de
127
+ executables: []
128
+ extensions: []
129
+ extra_rdoc_files: []
130
+ files:
131
+ - LICENSE
132
+ - README.md
133
+ - lib/fastlane/plugin/carthage_cache_ftps.rb
134
+ - lib/fastlane/plugin/carthage_cache_ftps/actions/carthage_cache_action.rb
135
+ - lib/fastlane/plugin/carthage_cache_ftps/actions/carthage_cache_ftps_action.rb
136
+ - lib/fastlane/plugin/carthage_cache_ftps/helper/carthage_cache_ftps_helper.rb
137
+ - lib/fastlane/plugin/carthage_cache_ftps/helper/ftp_repository.rb
138
+ - lib/fastlane/plugin/carthage_cache_ftps/helper/password_helper.rb
139
+ - lib/fastlane/plugin/carthage_cache_ftps/version.rb
140
+ homepage:
141
+ licenses:
142
+ - MIT
143
+ metadata: {}
144
+ post_install_message:
145
+ rdoc_options: []
146
+ require_paths:
147
+ - lib
148
+ required_ruby_version: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ required_rubygems_version: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - ">="
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ requirements: []
159
+ rubyforge_project:
160
+ rubygems_version: 2.4.5.1
161
+ signing_key:
162
+ specification_version: 4
163
+ summary: Allows to publish or install the carthage builds via ftps to avoid recompilation
164
+ test_files: []