class Fastlane::Actions::FivSelectEnvAction

Public Class Methods

author() click to toggle source
# File lib/fastlane/plugin/fivethree_ionic/actions/fiv_select_env.rb, line 102
def self.author
  'Marc'
end
available_options() click to toggle source
# File lib/fastlane/plugin/fivethree_ionic/actions/fiv_select_env.rb, line 41
def self.available_options
  [
    FastlaneCore::ConfigItem.new(
      key: :clients_folder,
      env_name: 'FIV_CLIENTS_FOLDER',
      # The name of the environment variable
      description: 'Clients folder path for SelectEnvAction',
      # a short description of this parameter
      default_value: 'clients',
      is_string: true,
      verify_block:
        proc do |value|
          unless (value and not value.empty?)
            UI.user_error!(
              "No client folder path for SelectClientAction given, pass using `client_folder: '../path_to_clients_folder'`"
            )
          end
          unless File.directory?(value)
            UI.user_error!(
              "Couldn't find clients folder at path '#{value}'"
            )
          end
        end
    ),
    FastlaneCore::ConfigItem.new(
      key: :environments_folder,
      env_name: 'FIV_ENVIRONMENT_FOLDER',
      # The name of the environment variable
      description: 'Environment folder path for SelectEnvAction',
      # a short description of this parameter
      default_value: 'environments',
      is_string: true,
      verify_block:
        proc do |value|
          unless (value and not value.empty?)
            UI.user_error!(
              "No environment folder path for SelectClientAction given, pass using `environment: '../path_to_environment_folder'`"
            )
          end
        end
    ),
    FastlaneCore::ConfigItem.new(
      key: :client,
      env_name: 'FIV_CLIENT',
      # The name of the environment variable
      description: 'Client folder path for SelectEnvAction',
      # a short description of this parameter
      is_string: true,
      optional: false,
      verify_block:
        proc do |value|
          unless (value and not value.empty?)
            UI.user_error!(
              "No client folder path for SelectEnvAction given, pass using `client: '../path_to_client_folder'`"
            )
          end
        end
    )
  ]
end
description() click to toggle source
# File lib/fastlane/plugin/fivethree_ionic/actions/fiv_select_env.rb, line 37
def self.description
  'Select a client'
end
is_supported?(platform) click to toggle source
# File lib/fastlane/plugin/fivethree_ionic/actions/fiv_select_env.rb, line 106
def self.is_supported?(platform)
  %i[ios mac android].include? platform
end
run(params) click to toggle source
# File lib/fastlane/plugin/fivethree_ionic/actions/fiv_select_env.rb, line 4
def self.run(params)
  Dir.chdir "#{params[:clients_folder]}/#{params[:client]}/#{
              params[:environments_folder]
            }" do
    environment = Dir.glob('*').sort.select { |f| File.directory? f }
    if (ENV['ENV'] && environment.include?(ENV['ENV']))
      puts(
        "
            ***********************************************
              Selected environment: #{
          ENV['ENV']
        }
            ***********************************************
            "
      )
      return ENV['ENV']
    end

    selected_env = UI.select('Select one environment: ', environment)

    puts(
      "
          ***********************************************
              Selected environment: #{
        selected_env
      }
          ***********************************************
          "
    )
    return selected_env
  end
end