Skip to content

Commit

Permalink
Merge pull request #67 from KBSchmidt/feature/remove-graphicsmagick-d…
Browse files Browse the repository at this point in the history
…ependency

Add minimagick_cli option to choose graphicsmagick or imagemagick
  • Loading branch information
Josh Holtz authored Mar 25, 2021
2 parents bd872a0 + 3ca1b51 commit e8c65cc
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 17 deletions.
14 changes: 5 additions & 9 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,16 @@
Style/ClassCheck:
EnforcedStyle: kind_of?

# It's better to be more explicit about the type
Style/BracesAroundHashParameters:
Enabled: false

# specs sometimes have useless assignments, which is fine
Lint/UselessAssignment:
Exclude:
- '**/spec/**/*'

# We could potentially enable the 2 below:
Layout/IndentHash:
Layout/FirstHashElementIndentation:
Enabled: false

Layout/AlignHash:
Layout/HashAlignment:
Enabled: false

# HoundCI doesn't like this rule
Expand All @@ -27,7 +23,7 @@ Style/DoubleNegation:
Enabled: false

# Sometimes we allow a rescue block that doesn't contain code
Lint/HandleExceptions:
Lint/SuppressedException:
Enabled: false

# Cop supports --auto-correct.
Expand Down Expand Up @@ -79,7 +75,7 @@ Metrics/CyclomaticComplexity:
Max: 17

# Configuration parameters: AllowURI, URISchemes.
Metrics/LineLength:
Layout/LineLength:
Max: 370

# Configuration parameters: CountKeywordArgs.
Expand Down Expand Up @@ -119,7 +115,7 @@ Lint/ParenthesesAsGroupedExpression:

# This would reject is_ in front of methods
# We use `is_supported?` everywhere already
Style/PredicateName:
Naming/PredicateName:
Enabled: false

# We allow the $
Expand Down
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,19 @@ This project is a [fastlane](https://github.com/fastlane/fastlane) plugin. To ge
fastlane add_plugin appicon
```

Please note that this plugin uses the GraphicsMagick library. If you do not have it, you can install it via Homebrew:

Please 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:


```
brew install graphicsmagick
```
or
```
brew install imagemagick
```

The 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.

## About appicon

Expand Down Expand Up @@ -131,7 +139,7 @@ If you have trouble using plugins, check out the [Plugins Troubleshooting](https

## Using `fastlane` Plugins

For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Plugins.md).
For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).

## About `fastlane`

Expand Down
10 changes: 6 additions & 4 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# frozen_string_literal: true

lane :ios do
appicon(
appicon_image_file: 'spec/fixtures/Themoji.png',
appicon_devices: [:ipad, :iphone, :ios_marketing, :watch, :watch_marketing],
appicon_devices: %i[ipad iphone ios_marketing watch watch_marketing],
appicon_path: 'app'
)
end
Expand All @@ -18,7 +20,7 @@ end
lane :ios_messages_extension do
appicon(
appicon_image_file: 'spec/fixtures/ThemojiSplash.png',
appicon_devices: [:iphone, :ipad, :ios_marketing, :messages],
appicon_devices: %i[iphone ipad ios_marketing messages],
appicon_path: 'app/iMessageStickers/Stickers.xcassets',
messages_extension: true
)
Expand All @@ -44,8 +46,8 @@ end
lane :android_splash do
android_appicon(
appicon_image_file: 'spec/fixtures/ThemojiSplash.png',
appicon_icon_types: [:splash_port, :splash_land],
appicon_icon_types: %i[splash_port splash_land],
appicon_path: 'app/res/drawable',
appicon_filename: 'splash'
)
)
end
14 changes: 13 additions & 1 deletion lib/fastlane/plugin/appicon/actions/android_appicon_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ def self.needed_icons
end

def self.run(params)

Helper::AppiconHelper.set_cli(params[:minimagick_cli])

fname = params[:appicon_image_file]
custom_sizes = params[:appicon_custom_sizes]

Expand Down Expand Up @@ -169,7 +172,16 @@ def self.available_options
FastlaneCore::ConfigItem.new(key: :generate_rounded,
description: "Generate round icons?",
default_value: false,
type: Boolean)
type: Boolean),
FastlaneCore::ConfigItem.new(key: :minimagick_cli,
env_name: "APPICON_MINIMAGICK_CLI",
description: "Set MiniMagick CLI (auto picked by default). Values are: graphicsmagick, imagemagick",
optional: true,
type: String,
verify_block: proc do |value|
av = %w(graphicsmagick imagemagick)
UI.user_error!("Unsupported minimagick cli '#{value}', must be: #{av}") unless av.include?(value)
end)
]
end

Expand Down
13 changes: 12 additions & 1 deletion lib/fastlane/plugin/appicon/actions/appicon_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ def self.run(params)
fname = params[:appicon_image_file]
basename = File.basename(fname, File.extname(fname))

Helper::AppiconHelper.set_cli(params[:minimagick_cli])

is_messages_extension = params[:messages_extension]
basepath = Pathname.new(File.join(params[:appicon_path], is_messages_extension ? params[:appicon_messages_name] : params[:appicon_name]))

Expand Down Expand Up @@ -205,7 +207,16 @@ def self.available_options
default_value: false,
description: "App icon is generated for Messages extension",
optional: true,
type: Boolean)
type: Boolean),
FastlaneCore::ConfigItem.new(key: :minimagick_cli,
env_name: "APPICON_MINIMAGICK_CLI",
description: "Set MiniMagick CLI (auto picked by default). Values are: graphicsmagick, imagemagick",
optional: true,
type: String,
verify_block: proc do |value|
av = %w(graphicsmagick imagemagick)
UI.user_error!("Unsupported minimagick cli '#{value}', must be: #{av}") unless av.include?(value)
end)
]
end

Expand Down
16 changes: 16 additions & 0 deletions lib/fastlane/plugin/appicon/helper/appicon_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'mini_magick'

module Fastlane
module Helper
class AppiconHelper
Expand All @@ -7,6 +9,20 @@ def self.check_input_image_size(image, width, height)
UI.user_error!("Input image should be square") if image.width / image.height != width / height
end

def self.set_cli(minimagick_cli)
MiniMagick.configure do |config|
case minimagick_cli
when "graphicsmagick"
config.cli = :graphicsmagick
when "imagemagick"
config.cli = :imagemagick
else
config.cli = MiniMagick.cli()
end
config.timeout = 5
end
end

def self.get_needed_icons(devices, needed_icons, is_android = false, custom_sizes = {})
icons = []
devices.each do |device|
Expand Down

0 comments on commit e8c65cc

Please sign in to comment.