Class: Fastlane::Actions::EnsureDotnetVersionAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::EnsureDotnetVersionAction
- Defined in:
- lib/fastlane/plugin/sapfire/actions/ensure_dotnet_version_action.rb
Class Method Summary collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .category ⇒ Object
- .description ⇒ Object
- .error(version, available_versions) ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .output ⇒ Object
- .run(params) ⇒ Object
- .success(version) ⇒ Object
Class Method Details
.authors ⇒ Object
89 90 91 |
# File 'lib/fastlane/plugin/sapfire/actions/ensure_dotnet_version_action.rb', line 89 def self. ["CheeryLee"] end |
.available_options ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/fastlane/plugin/sapfire/actions/ensure_dotnet_version_action.rb', line 103 def self. [ FastlaneCore::ConfigItem.new( key: :version, env_name: "SF_ENSURE_DOTNET_VERSION", description: ".NET version to verify that is installed", optional: false, type: String, verify_block: proc do |value| UI.user_error!("The version of .NET to check is empty") unless value && !value.empty? end ), FastlaneCore::ConfigItem.new( key: :strict, description: "Should the version be verified strictly (all 3 version numbers), or matching only the given version numbers (i.e. 6.0 == 6.0.x)", optional: true, default_value: true, type: Boolean ) ] end |
.category ⇒ Object
125 126 127 |
# File 'lib/fastlane/plugin/sapfire/actions/ensure_dotnet_version_action.rb', line 125 def self.category :building end |
.description ⇒ Object
85 86 87 |
# File 'lib/fastlane/plugin/sapfire/actions/ensure_dotnet_version_action.rb', line 85 def self.description "Ensures the right version of .NET is installed and can be used" end |
.error(version, available_versions) ⇒ Object
76 77 78 79 80 81 82 83 |
# File 'lib/fastlane/plugin/sapfire/actions/ensure_dotnet_version_action.rb', line 76 def self.error(version, available_versions) str = [ "Required .NET version hasn't been found: #{version}", "Available versions: #{available_versions}" ].join("\n") UI.user_error!(str) end |
.is_supported?(platform) ⇒ Boolean
93 94 95 |
# File 'lib/fastlane/plugin/sapfire/actions/ensure_dotnet_version_action.rb', line 93 def self.is_supported?(platform) true end |
.output ⇒ Object
97 98 99 100 101 |
# File 'lib/fastlane/plugin/sapfire/actions/ensure_dotnet_version_action.rb', line 97 def self.output [ ["SF_ENSURE_DOTNET_VERSION", ".NET version to verify that is installed"] ] end |
.run(params) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/fastlane/plugin/sapfire/actions/ensure_dotnet_version_action.rb', line 7 def self.run(params) UI.user_error!("Can't find dotnet") unless Helper::SapfireHelper.dotnet_specified? dotnet_path = Actions.lane_context[SharedValues::SF_DOTNET_PATH] cmd = "\"#{dotnet_path}\" --list-sdks" UI.command(cmd) stdin, stdout = Open3.popen2(cmd) output = stdout.read stdin.close stdout.close versions = output.split("\n") available_versions = [] current_version = nil required_version = nil found = false begin required_version = Gem::Version.new(params[:version]) rescue ArgumentError => ex UI.user_error!("Invalid version number provided, make sure it's valid: #{ex}") end required_version_numbers = required_version.to_s.split(".") versions.each do |value| path_bracket_index = value.index("[") begin ver_number = value[0..path_bracket_index - 1].strip current_version = Gem::Version.new(ver_number) available_versions.append(current_version.to_s) rescue ArgumentError => ex UI.user_error!("Can't parse the version entry from dotnet output: #{ex}") end if params[:strict] next unless current_version == required_version success(required_version) else current_version_numbers = current_version.to_s.split(".") all_correct = true required_version_numbers.each_with_index do |required_version_number, index| current_version_number = current_version_numbers[index] next if required_version_number == current_version_number all_correct = false break end next unless all_correct success(current_version) end found = true break end error(required_version, available_versions) unless found end |
.success(version) ⇒ Object
72 73 74 |
# File 'lib/fastlane/plugin/sapfire/actions/ensure_dotnet_version_action.rb', line 72 def self.success(version) UI.success("Required .NET version has found: #{version}") end |