Module: Deliver::Loader

Defined in:
deliver/lib/deliver/loader.rb

Constant Summary collapse

APPLE_TV_DIR_NAME =

The directory 'appleTV' and `iMessage` are special folders that will cause our screenshot gathering code to iterate through it as well searching for language folders.

"appleTV".freeze
IMESSAGE_DIR_NAME =
"iMessage".freeze
DEFAULT_DIR_NAME =
"default".freeze
SPECIAL_DIR_NAMES =
[APPLE_TV_DIR_NAME, IMESSAGE_DIR_NAME, DEFAULT_DIR_NAME].freeze
SUPPLY_DIR_NAME =

Some exception directories may exist from other actions that should not be iterated through

"android".freeze
FRAMEIT_FONTS_DIR_NAME =
"fonts".freeze
META_DIR_NAMES =
UploadMetadata::ALL_META_SUB_DIRS.map(&:downcase)
EXCEPTION_DIRECTORIES =
(META_DIR_NAMES << SUPPLY_DIR_NAME << FRAMEIT_FONTS_DIR_NAME).freeze

Class Method Summary collapse

Class Method Details

.language_folders(root, ignore_validation) ⇒ Object


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
# File 'deliver/lib/deliver/loader.rb', line 24

def self.language_folders(root, ignore_validation)
  folders = Dir.glob(File.join(root, '*'))

  if Helper.test?
    available_languages = FastlaneCore::Languages::ALL_LANGUAGES
  else
    available_languages = Spaceship::Tunes.client.available_languages.sort
  end

  allowed_directory_names_with_case = (available_languages + SPECIAL_DIR_NAMES)
  allowed_directory_names = allowed_directory_names_with_case.map(&:downcase).freeze

  selected_folders = folders.select do |path|
    File.directory?(path) && allowed_directory_names.include?(File.basename(path).downcase)
  end.sort

  # Gets list of folders that are not supported languages
  rejected_folders = folders.select do |path|
    normalized_path = File.basename(path).downcase
    File.directory?(path) && !allowed_directory_names.include?(normalized_path) && !EXCEPTION_DIRECTORIES.include?(normalized_path)
  end.sort

  if !ignore_validation && !rejected_folders.empty?
    rejected_folders = rejected_folders.map { |path| File.basename(path) }
    UI.user_error!("Unsupported directory name(s) for screenshots/metadata in '#{root}': #{rejected_folders.join(', ')}" \
                   "\nValid directory names are: #{allowed_directory_names_with_case}" \
                   "\n\nEnable 'ignore_language_directory_validation' to prevent this validation from happening")
  end

  selected_folders
end