Class: Fastlane::Actions::InstallXcodePluginAction
Constant Summary
Fastlane::Action::AVAILABLE_CATEGORIES
Class Method Summary
collapse
action_name, author, details, lane_context, method_missing, other_action, sample_return_value, sh, step_text
Class Method Details
.authors ⇒ Object
76
77
78
|
# File 'lib/fastlane/actions/install_xcode_plugin.rb', line 76
def self.authors
["NeoNachoSoto"]
end
|
.available_options ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/fastlane/actions/install_xcode_plugin.rb', line 50
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :url,
env_name: "FL_XCODE_PLUGIN_URL",
description: "URL for Xcode plugin ZIP file",
verify_block: proc do |value|
UI.user_error!("No URL for InstallXcodePluginAction given, pass using `url: 'url'`") if value.to_s.length == 0
UI.user_error!("URL doesn't use HTTPS") unless value.start_with?("https://")
end),
FastlaneCore::ConfigItem.new(key: :github,
env_name: "FL_XCODE_PLUGIN_GITHUB",
description: "GitHub repository URL for Xcode plugin",
optional: true,
verify_block: proc do |value|
UI.user_error!("No GitHub URL for InstallXcodePluginAction given, pass using `github: 'url'`") if value.to_s.length == 0
UI.user_error!("URL doesn't use HTTPS") unless value.start_with?("https://")
end)
]
end
|
.category ⇒ Object
91
92
93
|
# File 'lib/fastlane/actions/install_xcode_plugin.rb', line 91
def self.category
:misc
end
|
.description ⇒ Object
46
47
48
|
# File 'lib/fastlane/actions/install_xcode_plugin.rb', line 46
def self.description
"Install an Xcode plugin for the current user"
end
|
.example_code ⇒ Object
84
85
86
87
88
89
|
# File 'lib/fastlane/actions/install_xcode_plugin.rb', line 84
def self.example_code
[
'install_xcode_plugin(url: "https://example.com/clubmate/plugin.zip")',
'install_xcode_plugin(github: "https://github.com/contentful/ContentfulXcodePlugin")'
]
end
|
.fetch_json(url) ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/fastlane/actions/install_xcode_plugin.rb', line 24
def self.fetch_json(url)
require 'excon'
require 'json'
response = Excon.get(url)
if response[:status] != 200
if response[:status] == 404
UI.error("No latest release found for the specified GitHub repository")
else
UI.error("GitHub responded with #{response[:status]}:#{response[:body]}")
end
return nil
end
JSON.parse(response.body)
end
|
.is_supported?(platform) ⇒ Boolean
80
81
82
|
# File 'lib/fastlane/actions/install_xcode_plugin.rb', line 80
def self.is_supported?(platform)
[:ios, :mac, :tvos, :watchos, :caros].include?(platform)
end
|
.output ⇒ Object
70
71
|
# File 'lib/fastlane/actions/install_xcode_plugin.rb', line 70
def self.output
end
|
.return_value ⇒ Object
73
74
|
# File 'lib/fastlane/actions/install_xcode_plugin.rb', line 73
def self.return_value
end
|
.run(params) ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/fastlane/actions/install_xcode_plugin.rb', line 4
def self.run(params)
require 'fileutils'
unless params[:github].nil?
github_api_url = params[:github].sub('https://github.com', 'https://api.github.com/repos')
release = self.fetch_json(github_api_url + '/releases/latest')
return if release.nil?
params[:url] = release['assets'][0]['browser_download_url']
end
zip_path = File.join(Dir.tmpdir, 'plugin.zip')
sh "curl -Lso #{zip_path} #{params[:url]}"
plugins_path = "#{ENV['HOME']}/Library/Application Support/Developer/Shared/Xcode/Plug-ins"
FileUtils.mkdir_p(plugins_path)
Action.sh "unzip -qo '#{zip_path}' -d '#{plugins_path}'"
UI.success("Plugin #{File.basename(params[:url], '.zip')} installed successfully")
UI.message("Please restart Xcode to use the newly installed plugin")
end
|