[
  {
    "path": ".gitignore",
    "content": "*.gem\n/gems/\nGemfile.lock\n\n## Documentation cache and generated files:\n/.yardoc/\n/_yardoc/\n/doc/\n/rdoc/\nfastlane/README.md\nfastlane/report.xml\n.DS_Store\n\n## Ignore generated asset catalogue\nAssets.xcassets/\n\n## Ignore android generated icon\napp/\n"
  },
  {
    "path": ".rspec",
    "content": "--require spec_helper\n--color\n--format d\n"
  },
  {
    "path": ".rubocop.yml",
    "content": "# kind_of? is a good way to check a type\nStyle/ClassCheck:\n  EnforcedStyle: kind_of?\n\n# specs sometimes have useless assignments, which is fine\nLint/UselessAssignment:\n  Exclude:\n    - '**/spec/**/*'\n\n# We could potentially enable the 2 below:\nLayout/FirstHashElementIndentation:\n  Enabled: false\n\nLayout/HashAlignment:\n  Enabled: false\n\n# HoundCI doesn't like this rule\nLayout/DotPosition:\n  Enabled: false\n\n# We allow !! as it's an easy way to convert ot boolean\nStyle/DoubleNegation:\n  Enabled: false\n\n# Sometimes we allow a rescue block that doesn't contain code\nLint/SuppressedException:\n  Enabled: false\n\n# Cop supports --auto-correct.\nLint/UnusedBlockArgument:\n  Enabled: false\n\n# Needed for $verbose\nStyle/GlobalVars:\n  Enabled: false\n\n# We want to allow class Fastlane::Class\nStyle/ClassAndModuleChildren:\n  Enabled: false\n\n# $? Exit\nStyle/SpecialGlobalVars:\n  Enabled: false\n\nMetrics/AbcSize:\n  Max: 60\n  Exclude:\n    - '**/lib/*/options.rb'\n\n# The %w might be confusing for new users\nStyle/WordArray:\n  MinSize: 19\n\n# raise and fail are both okay\nStyle/SignalException:\n  Enabled: false\n\n# Better too much 'return' than one missing\nStyle/RedundantReturn:\n  Enabled: false\n\n# Having if in the same line might not always be good\nStyle/IfUnlessModifier:\n  Enabled: false\n\n# and and or is okay\nStyle/AndOr:\n  Enabled: false\n\n# Configuration parameters: CountComments.\nMetrics/ClassLength:\n  Max: 320\n\nMetrics/CyclomaticComplexity:\n  Max: 17\n\n# Configuration parameters: AllowURI, URISchemes.\nLayout/LineLength:\n  Max: 370\n\n# Configuration parameters: CountKeywordArgs.\nMetrics/ParameterLists:\n  Max: 17\n\nMetrics/PerceivedComplexity:\n  Max: 18\n\n# Sometimes it's easier to read without guards\nStyle/GuardClause:\n  Enabled: false\n\n# We allow both \" and '\nStyle/StringLiterals:\n  Enabled: false\n\n# something = if something_else\n# that's confusing\nStyle/ConditionalAssignment:\n  Enabled: false\n\n# Better to have too much self than missing a self\nStyle/RedundantSelf:\n  Enabled: false\n\n# e.g.\n# def self.is_supported?(platform)\n# we may never use `platform`\nLint/UnusedMethodArgument:\n  Enabled: false\n\n# the let(:key) { ... }\nLint/ParenthesesAsGroupedExpression:\n  Exclude:\n    - '**/spec/**/*'\n\n# This would reject is_ in front of methods\n# We use `is_supported?` everywhere already\nNaming/PredicateName:\n  Enabled: false\n\n# We allow the $\nStyle/PerlBackrefs:\n  Enabled: false\n\n# Disable '+ should be surrounded with a single space' for xcodebuild_spec.rb\nLayout/SpaceAroundOperators:\n  Exclude:\n    - '**/spec/actions_specs/xcodebuild_spec.rb'\n\nMetrics/MethodLength:\n  Exclude:\n    - '**/lib/fastlane/actions/*.rb'\n    - '**/bin/fastlane'\n    - '**/lib/*/options.rb'\n  Max: 60\n\nAllCops:\n  Include:\n    - '**/fastlane/Fastfile'\n  Exclude:\n    - '**/lib/assets/custom_action_template.rb'\n    - './vendor/**/*'\n\n# We're not there yet\nStyle/Documentation:\n  Enabled: false\n\n# Added after upgrade to 0.38.0\nStyle/MutableConstant:\n  Enabled: false\n\n# length > 0 is good\nStyle/ZeroLengthPredicate:\n  Enabled: false\n\n# Adds complexity\nStyle/IfInsideElse:\n  Enabled: false\n"
  },
  {
    "path": ".travis.yml",
    "content": "# os: osx # enable this if you need OS X support\nlanguage: ruby\nrvm:\n  - 2.2.4\n"
  },
  {
    "path": "Gemfile",
    "content": "source 'https://rubygems.org'\n\ngemspec\n\nplugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile')\neval(File.read(plugins_path), binding) if File.exist?(plugins_path)\n\ngem 'activesupport', '~> 4.0'\n"
  },
  {
    "path": "LICENSE",
    "content": "The MIT License (MIT)\n\nCopyright (c) 2016 Boris Bügling <boris@icculus.org>\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# appicon plugin\n\n[![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-appicon)\n\n![Demo image](demo.png)\n\n## Getting Started\n\nThis project is a [fastlane](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-appicon`, add it to your project by running:\n\n```bash\nfastlane add_plugin appicon\n```\n\n\nPlease note that this plugin uses [minimagick](https://github.com/minimagick/minimagick), which requires either GraphicsMagick or ImageMagick library. If you have neither, you can install either via Homebrew:\n\n\n```\nbrew install graphicsmagick\n```\nor\n```\nbrew install imagemagick\n```\n\nThe default CLI for the `mini_magick` gem is set to auto pick. It will first try to use `GraphicsMagick` (if you have it installed) otherwise it will use `ImageMagick`. If you want to be explicit about which CLI you use, set the `minimagick_cli` option to `graphicsmagick` or `imagemagick`. Not specifying this option will set `MiniMagick` to use auto which will choose what's available.\n\n## About appicon\n\nGenerate required icon sizes and iconset from a master application icon.\n\nSince many apps use a single 1024x1024 icon to produce all the required sizes from, why not automate the process and save lots of time?\n\n## Example\n\nCheck out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plugin. Try it by cloning the repo, running `fastlane install_plugins` and `bundle exec fastlane test`.\n\nJust specify the source image using the `appicon_image_file`. Optionally specify the devices using `appicon_devices` and the destination path using `appicon_path`.\n\nWe recommend storing the full-size picture at `fastlane/metadata/app_icon.png` so it can be picked up by _deliver_, as well as this plugin.\n\nIf you want to use this plugin to generate a app icon for Messages(sticker) extension, set `messages_extension` to `true` and add `messages` to the `appicon_devices`.\n\n```ruby\nlane :basic do\n  appicon(\n    appicon_devices: [:ipad, :iphone, :ios_marketing],\n    appicon_path: \"MajorKey/Assets.xcassets\"\n  )\nend\n\nlane :test1 do\n  appicon(appicon_image_file: 'spec/fixtures/Themoji.png',\n             appicon_devices: [:ipad, :iphone, :ios_marketing])\nend\n\n\nlane :test2 do\n  appicon(appicon_image_file: 'spec/fixtures/Themoji.png',\n             appicon_devices: [:ipad, :iphone, :ios_marketing, :watch, :watch_marketing])\nend\n\nlane :test3 do\n  # `appicon_image_file` defaults to \"fastlane/metadata/app_icon.png\"\n  appicon(\n    appicon_devices: [:iphone],\n    appicon_path: 'wwdcfamily/Images.xcassets' # output path\n  )\nend\n\nlane :test4 do\n  appicon(appicon_image_file: 'spec/fixtures/Themoji.png',\n             appicon_devices: [:macos])\nend\n\nlane :splash_screen do\n  appicon(\n    appicon_image_file: 'spec/fixtures/splash_screen.png',\n    appicon_devices: [:universal],\n    appicon_path: \"ios/App/App/Assets.xcassets\",\n    appicon_name: 'Splash.imageset'\n  )\nend\n\nlane :messages_extension do\n  appicon(\n    appicon_image_file: \"fastlane/metadata/iMessageAppIcon.png\",\n    appicon_devices: [:iphone, :ipad, :ios_marketing, :messages],\n    appicon_path: 'iMessageStickers/Stickers.xcassets',\n    messages_extension: true\n  )\nend\n\n# or\n\nlane :android do\n  android_appicon(\n    appicon_image_file: 'spec/fixtures/Themoji.png',\n    appicon_icon_types: [:launcher],\n    appicon_path: 'app/res/mipmap'\n  )\n  android_appicon(\n    appicon_image_file: 'spec/fixtures/ThemojiNotification.png',\n    appicon_icon_types: [:notification],\n    appicon_path: 'app/res/drawable',\n    appicon_filename: 'ic_notification',\n    generate_rounded: true\n  )\n  android_appicon(\n    appicon_image_file: 'spec/fixtures/splash_base_image.png',\n    appicon_icon_types: [:splash_port, :splash_land],\n    appicon_path: 'app/res/drawable',\n    appicon_filename: 'splash'\n  )\nend\n```\n\n## Run tests for this plugin\n\nTo run both the tests, and code style validation, run\n\n```\nrake\n```\n\nTo automatically fix many of the styling issues, use\n```\nrubocop -a\n```\n\n## Issues and Feedback\n\nFor any other issues and feedback about this plugin, please submit it to this repository.\n\n## Troubleshooting\n\nIf you have trouble using plugins, check out the [Plugins Troubleshooting](https://github.com/fastlane/fastlane/blob/master/fastlane/docs/PluginsTroubleshooting.md) doc in the main `fastlane` repo.\n\n## Using `fastlane` Plugins\n\nFor more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).\n\n## About `fastlane`\n\n`fastlane` is the easiest way to automate building and releasing your iOS and Android apps. To learn more, check out [fastlane.tools](https://fastlane.tools).\n"
  },
  {
    "path": "Rakefile",
    "content": "require 'bundler/gem_tasks'\n\nrequire 'rspec/core/rake_task'\nRSpec::Core::RakeTask.new\n\nrequire 'rubocop/rake_task'\nRuboCop::RakeTask.new(:rubocop)\n\ntask default: [:spec, :rubocop]\n"
  },
  {
    "path": "fastlane/Fastfile",
    "content": "# frozen_string_literal: true\n\nlane :ios do\n  appicon(\n    appicon_image_file: 'spec/fixtures/Themoji.png',\n    appicon_devices: %i[ipad iphone ios_marketing watch watch_marketing],\n    appicon_path: 'app'\n  )\nend\n\nlane :ios_splash do\n  appicon(\n    appicon_image_file: 'spec/fixtures/ThemojiSplash.png',\n    appicon_devices: [:universal],\n    appicon_path: 'app',\n    appicon_name: 'Splash.imageset'\n  )\nend\n\nlane :ios_messages_extension do\n  appicon(\n    appicon_image_file: 'spec/fixtures/ThemojiSplash.png',\n    appicon_devices: %i[iphone ipad ios_marketing messages],\n    appicon_path: 'app/iMessageStickers/Stickers.xcassets',\n    messages_extension: true\n  )\nend\n\nlane :macos do\n  appicon(\n    appicon_image_file: 'spec/fixtures/ThemojiSplash.png',\n    appicon_devices: [:macos],\n    appicon_path: 'app',\n    appicon_name: 'Mac.appiconset'\n  )\nend\n\nlane :android do\n  android_appicon(\n    appicon_image_file: 'spec/fixtures/Themoji.png',\n    appicon_path: 'app/res/mipmap',\n    generate_rounded: true\n  )\nend\n\nlane :android_splash do\n  android_appicon(\n    appicon_image_file: 'spec/fixtures/ThemojiSplash.png',\n    appicon_icon_types: %i[splash_port splash_land],\n    appicon_path: 'app/res/drawable',\n    appicon_filename: 'splash'\n  )\nend\n"
  },
  {
    "path": "fastlane/Pluginfile",
    "content": "# Autogenerated by fastlane\n"
  },
  {
    "path": "fastlane-plugin-appicon.gemspec",
    "content": "# coding: utf-8\nlib = File.expand_path(\"../lib\", __FILE__)\n$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)\nrequire 'fastlane/plugin/appicon/version'\n\nGem::Specification.new do |spec|\n  spec.name          = 'fastlane-plugin-appicon'\n  spec.version       = Fastlane::Appicon::VERSION\n  spec.author        = [\"Boris Bügling\", \"Felix Krause\"]\n  spec.email         = %q{boris@icculus.org}\n\n  spec.summary       = %q{Generate required icon sizes and iconset from a master application icon.}\n  spec.homepage      = \"https://github.com/fastlane-community/fastlane-plugin-appicon\"\n  spec.license       = \"MIT\"\n\n  spec.files         = Dir[\"lib/**/*\"] + %w(README.md LICENSE)\n  spec.test_files    = spec.files.grep(%r{^(test|spec|features)/})\n  spec.require_paths = ['lib']\n\n  spec.add_dependency 'mini_magick', '>= 4.9.4', '< 5.0.0'\n  spec.add_dependency 'json'\n\n  spec.add_development_dependency 'pry'\n  spec.add_development_dependency 'bundler'\n  spec.add_development_dependency 'rspec'\n  spec.add_development_dependency 'rake'\n  spec.add_development_dependency 'rubocop'\n  spec.add_development_dependency 'fastlane', '>= 1.95.0'\nend\n"
  },
  {
    "path": "lib/fastlane/plugin/appicon/actions/android_appicon_action.rb",
    "content": "require 'mini_magick'\n\nmodule Fastlane\n  module Actions\n    class AndroidAppiconAction < Action\n\n      def self.needed_icons\n        {\n          launcher: {\n            :ldpi => ['36x36'],\n            :mdpi => ['48x48'],\n            :hdpi => ['72x72'],\n            :xhdpi => ['96x96'],\n            :xxhdpi => ['144x144'],\n            :xxxhdpi => ['192x192']\n          },\n          notification: {\n            :ldpi => ['18x18'],\n            :mdpi => ['24x24'],\n            :hdpi => ['36x36'],\n            :xhdpi => ['48x48'],\n            :xxhdpi => ['72x72'],\n            :xxxhdpi => ['96x96'],\n          },\n          splash_land: {\n            'land-ldpi' => ['320x200'],\n            'land-mdpi' => ['480x320'],\n            'land-hdpi' => ['800x480'],\n            'land-xhdpi' => ['1280x720'],\n            'land-xxhdpi' => ['1600x960'],\n            'land-xxxhdpi' => ['1920x1280']\n          },\n          splash_port: {\n            'port-ldpi' => ['200x320'],\n            'port-mdpi' => ['320x480'],\n            'port-hdpi' => ['480x800'],\n            'port-xhdpi' => ['720x1280'],\n            'port-xxhdpi' => ['960x1600'],\n            'port-xxxhdpi' => ['1280x1920']\n          }\n        }\n      end\n\n      def self.run(params)\n\n        Helper::AppiconHelper.set_cli(params[:minimagick_cli])\n\n        fname = params[:appicon_image_file]\n        custom_sizes = params[:appicon_custom_sizes]\n\n        icons = Helper::AppiconHelper.get_needed_icons(params[:appicon_icon_types], self.needed_icons, true, custom_sizes)\n        icons.each do |icon|\n          image = MiniMagick::Image.open(fname)\n\n          Helper::AppiconHelper.check_input_image_size(image, 1024, 1024)\n\n          # Custom icons will have basepath and filename already defined\n          if icon.has_key?('basepath') && icon.has_key?('filename')\n            basepath = Pathname.new(icon['basepath'])\n            filename = icon['filename']\n          else\n            basepath = Pathname.new(\"#{params[:appicon_path]}-#{icon['scale']}\")\n            filename = \"#{params[:appicon_filename]}.png\"\n          end\n\n          width_height = [icon['width'], icon['height']].map(&:to_i)\n          width, height = width_height\n          max = width_height.max\n\n          image.format 'png'\n          image.resize \"#{max}x#{max}\"\n\n          unless width == height\n            offset =\n            if width > height\n              \"+0+#{(width - height) / 2}\"\n            elsif height > width\n              \"+#{(height - width) / 2}+0\"\n            end\n\n            image.crop \"#{icon['size']}#{offset}\"\n          end\n\n          FileUtils.mkdir_p(basepath)\n          image.write basepath + filename\n\n          if basepath.to_s.match(\"port-\")\n            default_portrait_path = basepath.to_s.gsub(\"port-\",\"\")\n            FileUtils.mkdir_p(default_portrait_path)\n            image.write default_portrait_path + '/' + filename\n          end\n\n          if params[:generate_rounded]\n            rounded_image = MiniMagick::Image.open(fname)\n            rounded_image.format 'png'\n            rounded_image.resize \"#{width}x#{height}\"\n            rounded_image = round(rounded_image)\n            rounded_image.write basepath + filename.gsub('.png', '_round.png')\n          end\n        end\n\n        UI.success(\"Successfully stored launcher icons at '#{params[:appicon_path]}'\")\n      end\n\n      def self.round(img)\n        require 'mini_magick'\n        img.format 'png'\n\n        width = img[:width]-2\n        radius = width/2\n\n        mask = ::MiniMagick::Image.open img.path\n        mask.format 'png'\n\n        mask.combine_options do |m|\n          m.alpha 'transparent'\n          m.background 'none'\n          m.fill 'white'\n          m.draw 'roundrectangle 1,1,%s,%s,%s,%s' % [width, width, radius, radius]\n        end\n\n        masked = img.composite(mask, 'png') do |i|\n          i.alpha \"set\"\n          i.compose 'DstIn'\n        end\n\n        return masked\n      end\n\n      def self.get_custom_sizes(image, custom_sizes)\n\n      end\n\n      def self.description\n        \"Generate required icon sizes from a master application icon\"\n      end\n\n      def self.authors\n        [\"@adrum\"]\n      end\n\n      def self.available_options\n        [\n          FastlaneCore::ConfigItem.new(key: :appicon_image_file,\n                                  env_name: \"APPICON_IMAGE_FILE\",\n                               description: \"Path to a square image file, at least 512x512\",\n                                  optional: false,\n                                      type: String),\n          FastlaneCore::ConfigItem.new(key: :appicon_icon_types,\n                                  env_name: \"APPICON_ICON_TYPES\",\n                             default_value: [:launcher],\n                               description: \"Array of device types to generate icons for\",\n                                  optional: true,\n                                      type: Array),\n          FastlaneCore::ConfigItem.new(key: :appicon_path,\n                                  env_name: \"APPICON_PATH\",\n                             default_value: 'app/res/mipmap',\n                               description: \"Path to res subfolder\",\n                                  optional: true,\n                                      type: String),\n          FastlaneCore::ConfigItem.new(key: :appicon_filename,\n                                  env_name: \"APPICON_FILENAME\",\n                             default_value: 'ic_launcher',\n                               description: \"The output filename of each image\",\n                                  optional: true,\n                                      type: String),\n          FastlaneCore::ConfigItem.new(key: :appicon_custom_sizes,\n                               description: \"Hash of custom sizes - {'path/icon.png' => '256x256'}\",\n                             default_value: {},\n                                  optional: true,\n                                      type: Hash),\n          FastlaneCore::ConfigItem.new(key: :generate_rounded,\n                               description: \"Generate round icons?\",\n                             default_value: false,\n                                      type: Boolean),\n          FastlaneCore::ConfigItem.new(key: :minimagick_cli,\n                                  env_name: \"APPICON_MINIMAGICK_CLI\",\n                               description: \"Set MiniMagick CLI (auto picked by default). Values are: graphicsmagick, imagemagick\",\n                                  optional: true,\n                                      type: String,\n                              verify_block: proc do |value|\n                                        av = %w(graphicsmagick imagemagick)\n                                        UI.user_error!(\"Unsupported minimagick cli '#{value}', must be: #{av}\") unless av.include?(value)\n                                      end)\n        ]\n      end\n\n      def self.is_supported?(platform)\n        [:android].include?(platform)\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/fastlane/plugin/appicon/actions/appicon_action.rb",
    "content": "require 'json'\nrequire 'mini_magick'\n\nmodule Fastlane\n  module Actions\n    class AppiconAction < Action\n      def self.needed_icons\n        {\n          universal: {\n            '1x' => ['2732x2732'],\n            '2x' => ['2732x2732'],\n            '3x' => ['2732x2732']\n          },\n          iphone: {\n            '2x' => ['20x20', '29x29', '40x40', '60x60'],\n            '3x' => ['20x20', '29x29', '40x40', '60x60']\n          },\n          ipad: {\n            '1x' => ['20x20', '29x29', '40x40', '76x76'],\n            '2x' => ['20x20', '29x29', '40x40', '76x76', '83.5x83.5']\n          },\n          :ios_marketing => {\n            '1x' => ['1024x1024']\n          },\n          :watch => {\n            '2x' => [\n                      ['24x24', 'notificationCenter', '38mm'],\n                      ['27.5x27.5', 'notificationCenter', '42mm'],\n                      ['29x29', 'companionSettings'],\n                      ['40x40', 'appLauncher', '38mm'],\n                      ['44x44', 'appLauncher', '40mm'],\n                      ['50x50', 'appLauncher', '44mm'],\n                      ['86x86', 'quickLook', '38mm'],\n                      ['98x98', 'quickLook', '42mm'],\n                      ['108x108', 'quickLook', '44mm']\n                    ],\n            '3x' => [['29x29', 'companionSettings']]\n          },\n          :watch_marketing => {\n            '1x' => ['1024x1024']\n          },\n          :macos => {\n            '1x' => ['16x16', '32x32', '128x128', '256x256', '512x512'],\n            '2x' => ['16x16', '32x32', '128x128', '256x256', '512x512'],\n          }\n        }\n      end\n\n      def self.needed_icons_messages_extension\n        {\n          iphone: {\n            '2x' => ['60x45'],\n            '3x' => ['60x45']\n          },\n          ipad: {\n            '2x' => ['67x50', '74x55']\n          },\n          messages: {\n            '2x' => ['27x20', '32x24'],\n            '3x' => ['27x20', '32x24']\n          },\n          ios_marketing: {\n            '1x' => ['1024x768']\n          }\n        }\n      end\n\n      def self.run(params)\n        fname = params[:appicon_image_file]\n        basename = File.basename(fname, File.extname(fname))\n\n        Helper::AppiconHelper.set_cli(params[:minimagick_cli])\n\n        is_messages_extension = params[:messages_extension]\n        basepath = Pathname.new(File.join(params[:appicon_path], is_messages_extension ? params[:appicon_messages_name] : params[:appicon_name]))\n        \n        image = MiniMagick::Image.open(fname)\n\n        if is_messages_extension\n          Helper::AppiconHelper.check_input_image_size(image, 1024, 768)\n        else\n          Helper::AppiconHelper.check_input_image_size(image, 1024, 1024)\n        end\n\n        # Convert image to png\n        image.format 'png'\n\n        # remove alpha channel\n        if params[:remove_alpha]\n          image.alpha 'remove'\n        end\n\n        # Recreate the base path\n        FileUtils.rm_rf(basepath)\n        FileUtils.mkdir_p(basepath)\n\n        images = []\n\n        icons = Helper::AppiconHelper.get_needed_icons(params[:appicon_devices], is_messages_extension ? self.needed_icons_messages_extension : self.needed_icons, false)\n        icons.each do |icon|\n          width = icon['width']\n          height = icon['height']\n          filename = basename\n          unless icon['device'] == 'universal'\n            filename += \"-#{width.to_i}x#{height.to_i}\"\n          end\n          filename += \".png\"\n\n          # downsize icon\n          # \"!\" resizes to exact size (needed for messages extension)\n          image.resize \"#{width}x#{height}!\"\n\n          # Don't write change/created times into the PNG properties\n          # so unchanged files don't have different hashes.\n          image.define(\"png:exclude-chunks=date,time\")\n\n          image.write basepath + filename\n\n          info = {\n            'idiom' => icon['device'],\n            'filename' => filename,\n            'scale' => icon['scale']\n          }\n\n          # if device is messages, we need to set it to universal\n          if icon['device'] == 'messages'\n            info['idiom'] = 'universal'\n            info['platform'] = 'ios'\n          end\n\n          # if device is ios_marketing but we are generating messages extension app, set the idiom correctly\n          if icon['device'] == 'ios_marketing' && is_messages_extension\n            info['platform'] = 'ios'\n          end\n          \n\n          unless icon['device'] == 'universal'\n            info['size'] = icon['size']\n          end\n\n          info['role'] = icon['role'] unless icon['role'].nil?\n          info['subtype'] = icon['subtype'] unless icon['subtype'].nil?\n\n          images << info\n        end\n\n        contents = {\n          'images' => images,\n          'info' => {\n            'version' => 1,\n            'author' => 'fastlane'\n          }\n        }\n\n        File.write(File.join(basepath, 'Contents.json'), JSON.pretty_generate(contents))\n        UI.success(\"Successfully stored app icon at '#{basepath}'\")\n      end\n\n      def self.description\n        \"Generate required icon sizes and iconset from a master application icon\"\n      end\n\n      def self.authors\n        [\"@NeoNacho\"]\n      end\n\n      def self.available_options\n        [\n          FastlaneCore::ConfigItem.new(key: :appicon_image_file,\n                                  env_name: \"APPICON_IMAGE_FILE\",\n                               description: \"Path to a square image file, at least 1024x1024\",\n                                  optional: false,\n                                      type: String,\n                             default_value: Dir[\"fastlane/metadata/app_icon.png\"].last), # that's the default when using fastlane to manage app metadata\n          FastlaneCore::ConfigItem.new(key: :appicon_devices,\n                                  env_name: \"APPICON_DEVICES\",\n                             default_value: [:iphone],\n                               description: \"Array of device idioms to generate icons for\",\n                                  optional: true,\n                                      type: Array),\n          FastlaneCore::ConfigItem.new(key: :appicon_path,\n                                  env_name: \"APPICON_PATH\",\n                             default_value: 'Assets.xcassets',\n                               description: \"Path to the Asset catalogue for the generated iconset\",\n                                  optional: true,\n                                      type: String),\n          FastlaneCore::ConfigItem.new(key: :appicon_name,\n                                  env_name: \"APPICON_NAME\",\n                             default_value: 'AppIcon.appiconset',\n                               description: \"Name of the appiconset inside the asset catalogue\",\n                                  optional: true,\n                                      type: String),\n          FastlaneCore::ConfigItem.new(key: :appicon_messages_name,\n                                  env_name: \"APPICON_MESSAGES_NAME\",\n                             default_value: 'AppIcon.stickersiconset',\n                               description: \"Name of the appiconset inside the asset catalogue\",\n                                  optional: true,\n                                      type: String),\n          FastlaneCore::ConfigItem.new(key: :remove_alpha,\n                                  env_name: \"REMOVE_ALPHA\",\n                             default_value: false,\n                               description: \"Remove the alpha channel from generated PNG\",\n                                  optional: true,\n                                      type: Boolean),\n          FastlaneCore::ConfigItem.new(key: :messages_extension,\n                                  env_name: \"APPICON_MESSAGES_EXTENSION\",\n                             default_value: false,\n                               description: \"App icon is generated for Messages extension\",\n                                  optional: true,\n                                      type: Boolean),\n          FastlaneCore::ConfigItem.new(key: :minimagick_cli,\n                                  env_name: \"APPICON_MINIMAGICK_CLI\",\n                               description: \"Set MiniMagick CLI (auto picked by default). Values are: graphicsmagick, imagemagick\",\n                                  optional: true,\n                                      type: String,\n                              verify_block: proc do |value|\n                                        av = %w(graphicsmagick imagemagick)\n                                        UI.user_error!(\"Unsupported minimagick cli '#{value}', must be: #{av}\") unless av.include?(value)\n                                      end)\n        ]\n      end\n\n      def self.is_supported?(platform)\n        [:ios, :mac, :macos, :caros, :rocketos].include?(platform)\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/fastlane/plugin/appicon/helper/appicon_helper.rb",
    "content": "require 'mini_magick'\n\nmodule Fastlane\n  module Helper\n    class AppiconHelper\n      def self.check_input_image_size(image, width, height)\n        UI.user_error!(\"Minimum width of input image should be #{width}\") if image.width < width\n        UI.user_error!(\"Minimum height of input image should be #{height}\") if image.height < height\n        UI.user_error!(\"Input image should be square\") if image.width / image.height != width / height\n      end\n\n      def self.set_cli(minimagick_cli)\n        MiniMagick.configure do |config|\n          case minimagick_cli\n          when \"graphicsmagick\"\n          config.cli = :graphicsmagick\n          when \"imagemagick\"\n            config.cli = :imagemagick\n          else\n            config.cli = MiniMagick.cli()\n          end\n          config.timeout = 5\n        end\n      end\n\n      def self.get_needed_icons(devices, needed_icons, is_android = false, custom_sizes = {})\n        icons = []\n        devices.each do |device|\n          needed_icons[device].each do |scale, sizes|\n            sizes.each do |size|\n              if size.kind_of?(Array)\n                size, role, subtype = size\n              end\n\n              if is_android\n                width, height = size.split('x').map { |v| v.to_f }\n              else\n                multiple = device.match(/universal/) ? 1 : scale.to_i\n                width, height = size.split('x').map { |v| v.to_f * multiple }\n              end\n\n              icons << {\n                'width' => width,\n                'height' => height,\n                'size' => size,\n                'device' => device.to_s.gsub('_', '-'),\n                'scale' => scale,\n                'role' => role,\n                'subtype' => subtype\n              }\n\n            end\n          end\n        end\n\n        # Add custom icon sizes (probably for notifications)\n        custom_sizes.each do |path, size|\n          path = path.to_s\n          width, height = size.split('x').map { |v| v.to_f }\n\n          icons << {\n            'width' => width,\n            'height' => height,\n            'size' => size,\n            'basepath' => File.dirname(path),\n            'filename' => File.basename(path)\n          }\n        end\n\n        # Sort from the largest to the smallest needed icon\n        icons = icons.sort_by {|value| value['width']} .reverse\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/fastlane/plugin/appicon/version.rb",
    "content": "module Fastlane\n  module Appicon\n    VERSION = \"0.16.0\"\n  end\nend\n"
  },
  {
    "path": "lib/fastlane/plugin/appicon.rb",
    "content": "require 'fastlane/plugin/appicon/version'\n\nmodule Fastlane\n  module Appicon\n    # Return all .rb files inside the \"actions\" directory\n    def self.all_classes\n      Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))]\n    end\n  end\nend\n\n# By default we want to import all available actions\n# A plugin can contain any number of actions and plugins\nFastlane::Appicon.all_classes.each do |current|\n  require current\nend\n"
  },
  {
    "path": "spec/appicon_action_spec.rb",
    "content": "describe Fastlane::Actions::AppiconAction do\nend\n"
  },
  {
    "path": "spec/spec_helper.rb",
    "content": "$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)\n\n# This module is only used to check the environment is currently a testing env\nmodule SpecHelper\nend\n\nrequire 'fastlane' # to import the Action super class\nrequire 'fastlane/plugin/appicon' # import the actual plugin\n\nFastlane.load_actions # load other actions (in case your plugin calls other actions or shared values)\n"
  }
]