fastlane 2.142.0 → 2.146.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +80 -80
  3. data/credentials_manager/lib/credentials_manager/appfile_config.rb +4 -0
  4. data/deliver/lib/deliver/app_screenshot.rb +1 -0
  5. data/deliver/lib/deliver/options.rb +30 -1
  6. data/deliver/lib/deliver/setup.rb +4 -4
  7. data/fastlane/lib/fastlane/actions/automatic_code_signing.rb +7 -1
  8. data/fastlane/lib/fastlane/actions/clean_build_artifacts.rb +3 -0
  9. data/fastlane/lib/fastlane/actions/crashlytics.rb +14 -2
  10. data/fastlane/lib/fastlane/actions/create_pull_request.rb +7 -1
  11. data/fastlane/lib/fastlane/actions/docs/capture_ios_screenshots.md +10 -4
  12. data/fastlane/lib/fastlane/actions/docs/frame_screenshots.md +22 -6
  13. data/fastlane/lib/fastlane/actions/docs/sync_code_signing.md +23 -7
  14. data/fastlane/lib/fastlane/actions/frame_screenshots.rb +2 -1
  15. data/fastlane/lib/fastlane/actions/get_version_number.rb +1 -1
  16. data/fastlane/lib/fastlane/actions/pod_lib_lint.rb +7 -1
  17. data/fastlane/lib/fastlane/actions/s3.rb +3 -289
  18. data/fastlane/lib/fastlane/actions/setup_ci.rb +1 -1
  19. data/fastlane/lib/fastlane/actions/setup_jenkins.rb +11 -2
  20. data/fastlane/lib/fastlane/actions/slather.rb +1 -1
  21. data/fastlane/lib/fastlane/actions/swiftlint.rb +28 -7
  22. data/fastlane/lib/fastlane/actions/update_code_signing_settings.rb +203 -0
  23. data/fastlane/lib/fastlane/actions/upload_symbols_to_crashlytics.rb +1 -1
  24. data/fastlane/lib/fastlane/actions/verify_build.rb +1 -1
  25. data/fastlane/lib/fastlane/helper/s3_client_helper.rb +61 -0
  26. data/fastlane/lib/fastlane/version.rb +1 -1
  27. data/fastlane/swift/Deliverfile.swift +1 -1
  28. data/fastlane/swift/Fastlane.swift +147 -8
  29. data/fastlane/swift/Gymfile.swift +1 -1
  30. data/fastlane/swift/Matchfile.swift +1 -1
  31. data/fastlane/swift/MatchfileProtocol.swift +17 -1
  32. data/fastlane/swift/Precheckfile.swift +1 -1
  33. data/fastlane/swift/Scanfile.swift +1 -1
  34. data/fastlane/swift/ScanfileProtocol.swift +5 -1
  35. data/fastlane/swift/Screengrabfile.swift +1 -1
  36. data/fastlane/swift/Snapshotfile.swift +1 -1
  37. data/fastlane_core/lib/fastlane_core/configuration/config_item.rb +9 -0
  38. data/fastlane_core/lib/fastlane_core/device_manager.rb +3 -3
  39. data/fastlane_core/lib/fastlane_core/ipa_file_analyser.rb +1 -0
  40. data/fastlane_core/lib/fastlane_core/provisioning_profile.rb +15 -2
  41. data/frameit/lib/frameit/commands_generator.rb +25 -0
  42. data/frameit/lib/frameit/config_parser.rb +31 -9
  43. data/frameit/lib/frameit/device.rb +90 -0
  44. data/frameit/lib/frameit/device_types.rb +121 -5
  45. data/frameit/lib/frameit/editor.rb +29 -41
  46. data/frameit/lib/frameit/offsets.rb +8 -1
  47. data/frameit/lib/frameit/options.rb +81 -54
  48. data/frameit/lib/frameit/runner.rb +17 -7
  49. data/frameit/lib/frameit/screenshot.rb +39 -47
  50. data/frameit/lib/frameit/template_finder.rb +15 -12
  51. data/gym/lib/gym/generators/package_command_generator.rb +4 -0
  52. data/gym/lib/gym/generators/package_command_generator_xcode7.rb +5 -0
  53. data/gym/lib/gym/runner.rb +14 -0
  54. data/match/lib/match/change_password.rb +1 -1
  55. data/match/lib/match/encryption.rb +4 -0
  56. data/match/lib/match/importer.rb +37 -20
  57. data/match/lib/match/module.rb +1 -1
  58. data/match/lib/match/nuke.rb +5 -1
  59. data/match/lib/match/options.rb +18 -0
  60. data/match/lib/match/runner.rb +4 -0
  61. data/match/lib/match/setup.rb +1 -1
  62. data/match/lib/match/storage.rb +4 -0
  63. data/match/lib/match/storage/s3_storage.rb +167 -0
  64. data/pilot/lib/pilot/build_manager.rb +15 -4
  65. data/pilot/lib/pilot/options.rb +8 -0
  66. data/produce/lib/produce/developer_center.rb +11 -2
  67. data/produce/lib/produce/itunes_connect.rb +11 -3
  68. data/produce/lib/produce/options.rb +12 -0
  69. data/scan/lib/scan/options.rb +5 -0
  70. data/scan/lib/scan/test_command_generator.rb +5 -1
  71. data/screengrab/lib/screengrab/runner.rb +12 -4
  72. data/snapshot/lib/snapshot/reports_generator.rb +4 -0
  73. data/spaceship/lib/spaceship/connect_api/models/app.rb +11 -0
  74. data/spaceship/lib/spaceship/connect_api/models/build.rb +1 -2
  75. data/spaceship/lib/spaceship/connect_api/models/certificate.rb +2 -0
  76. data/spaceship/lib/spaceship/connect_api/testflight/testflight.rb +23 -0
  77. data/spaceship/lib/spaceship/portal/app_service.rb +2 -2
  78. data/spaceship/lib/spaceship/portal/portal_client.rb +13 -0
  79. data/spaceship/lib/spaceship/tunes/app_version.rb +6 -1
  80. data/spaceship/lib/spaceship/tunes/application.rb +2 -1
  81. data/spaceship/lib/spaceship/tunes/tunes_client.rb +2 -2
  82. data/spaceship/lib/spaceship/two_step_or_factor_client.rb +52 -16
  83. data/supply/lib/supply/client.rb +4 -4
  84. data/supply/lib/supply/setup.rb +5 -3
  85. metadata +34 -17
  86. data/gym/lib/gym/.code_signing_mapping.rb.swp +0 -0
@@ -18,8 +18,9 @@ module Frameit
18
18
  attr_accessor :image # the current image used for editing
19
19
  attr_accessor :space_to_device
20
20
 
21
- def initialize(screenshot, debug_mode = false)
21
+ def initialize(screenshot, config, debug_mode = false)
22
22
  @screenshot = screenshot
23
+ @config = config
23
24
  self.debug_mode = debug_mode
24
25
  end
25
26
 
@@ -121,7 +122,7 @@ module Frameit
121
122
  def offset
122
123
  return @offset_information if @offset_information
123
124
 
124
- @offset_information = fetch_config['offset'] || Offsets.image_offset(screenshot).dup
125
+ @offset_information = @config['offset'] || Offsets.image_offset(screenshot).dup
125
126
 
126
127
  if @offset_information && (@offset_information['offset'] || @offset_information['offset'])
127
128
  return @offset_information
@@ -148,7 +149,7 @@ module Frameit
148
149
 
149
150
  # Do we add a background and title as well?
150
151
  def is_complex_framing_mode?
151
- return (fetch_config['background'] and (fetch_config['title'] or fetch_config['keyword']))
152
+ return (@config['background'] and (@config['title'] or @config['keyword']))
152
153
  end
153
154
 
154
155
  # more complex mode: background, frame and title
@@ -157,8 +158,8 @@ module Frameit
157
158
 
158
159
  self.space_to_device = vertical_frame_padding
159
160
 
160
- if fetch_config['title']
161
- background = put_title_into_background(background, fetch_config['stack_title'])
161
+ if @config['title']
162
+ background = put_title_into_background(background, @config['stack_title'])
162
163
  end
163
164
 
164
165
  if self.frame # we have no frame on le mac
@@ -169,7 +170,7 @@ module Frameit
169
170
  frame_width = background.width - horizontal_frame_padding * 2
170
171
  frame_height = background.height - effective_text_height - vertical_frame_padding
171
172
 
172
- if fetch_config['show_complete_frame']
173
+ if @config['show_complete_frame']
173
174
  # calculate the final size of the screenshot to resize in one go
174
175
  # it may be limited either by the width or height of the frame
175
176
  image_aspect_ratio = @image.width.to_f / @image.height.to_f
@@ -191,7 +192,7 @@ module Frameit
191
192
 
192
193
  # Horizontal adding around the frames
193
194
  def horizontal_frame_padding
194
- padding = fetch_config['padding']
195
+ padding = @config['padding']
195
196
  if padding.kind_of?(String) && padding.split('x').length == 2
196
197
  padding = padding.split('x')[0]
197
198
  padding = padding.to_i unless padding.end_with?('%')
@@ -201,7 +202,7 @@ module Frameit
201
202
 
202
203
  # Vertical adding around the frames
203
204
  def vertical_frame_padding
204
- padding = fetch_config['padding']
205
+ padding = @config['padding']
205
206
  if padding.kind_of?(String) && padding.split('x').length == 2
206
207
  padding = padding.split('x')[1]
207
208
  padding = padding.to_i unless padding.end_with?('%')
@@ -212,7 +213,7 @@ module Frameit
212
213
  # Minimum height for the title
213
214
  def title_min_height
214
215
  @title_min_height ||= begin
215
- height = fetch_config['title_min_height'] || 0
216
+ height = @config['title_min_height'] || 0
216
217
  if height.kind_of?(String) && height.end_with?('%')
217
218
  height = ([image.width, image.height].min * height.to_f * 0.01).ceil
218
219
  end
@@ -244,12 +245,12 @@ module Frameit
244
245
  end
245
246
 
246
247
  def title_below_image
247
- @title_below_image ||= fetch_config['title_below_image']
248
+ @title_below_image ||= @config['title_below_image']
248
249
  end
249
250
 
250
251
  # Returns a correctly sized background image
251
252
  def generate_background
252
- background = MiniMagick::Image.open(fetch_config['background'])
253
+ background = MiniMagick::Image.open(@config['background'])
253
254
 
254
255
  if background.height != screenshot.size[1]
255
256
  background.resize("#{screenshot.size[0]}x#{screenshot.size[1]}^") # `^` says it should fill area
@@ -338,12 +339,12 @@ module Frameit
338
339
  sum_width = title.width
339
340
  sum_width += keyword.width + keyword_padding if keyword
340
341
 
341
- title_below_image = fetch_config['title_below_image']
342
+ title_below_image = @config['title_below_image']
342
343
 
343
344
  # Resize the 2 labels if they exceed the available space either horizontally or vertically:
344
345
  image_scale_factor = 1.0 # default
345
346
  ratio_horizontal = sum_width / (image.width.to_f - horizontal_frame_padding * 2) # The fraction of the text images compared to the left and right padding
346
- ratio_vertical = title.height.to_f / actual_font_size # The fraction of the actual height of the images compared to the available space
347
+ ratio_vertical = title.height.to_f / effective_text_height # The fraction of the actual height of the images compared to the available space
347
348
  if ratio_horizontal > 1.0 || ratio_vertical > 1.0
348
349
  # If either is too large, resize with the maximum ratio:
349
350
  image_scale_factor = (1.0 / [ratio_horizontal, ratio_vertical].max)
@@ -385,7 +386,7 @@ module Frameit
385
386
  end
386
387
 
387
388
  def actual_font_size
388
- font_scale_factor = fetch_config['font_scale_factor'] || 0.1
389
+ font_scale_factor = @config['font_scale_factor'] || 0.1
389
390
  UI.user_error!("Parameter 'font_scale_factor' can not be 0. Please provide a value larger than 0.0 (default = 0.1).") if font_scale_factor == 0.0
390
391
  [@image.width * font_scale_factor].max.round
391
392
  end
@@ -420,7 +421,7 @@ module Frameit
420
421
  text.gsub!('\n', "\n")
421
422
  text.gsub!(/(?<!\\)(')/) { |s| "\\#{s}" } # escape unescaped apostrophes with a backslash
422
423
 
423
- interline_spacing = fetch_config['interline_spacing']
424
+ interline_spacing = @config['interline_spacing']
424
425
 
425
426
  # Add the actual title
426
427
  text_image.combine_options do |i|
@@ -429,7 +430,7 @@ module Frameit
429
430
  i.pointsize(actual_font_size)
430
431
  i.draw("text 0,0 '#{text}'")
431
432
  i.interline_spacing(interline_spacing) if interline_spacing
432
- i.fill(fetch_config[key.to_s]['color'])
433
+ i.fill(@config[key.to_s]['color'])
433
434
  end
434
435
 
435
436
  results[key] = text_image
@@ -491,18 +492,6 @@ module Frameit
491
492
  results
492
493
  end
493
494
 
494
- # Loads the config (colors, background, texts, etc.)
495
- # Don't use this method to access the actual text and use `fetch_texts` instead
496
- def fetch_config
497
- return @config if @config
498
-
499
- config_path = File.join(File.expand_path("..", screenshot.path), "Framefile.json")
500
- config_path = File.join(File.expand_path("../..", screenshot.path), "Framefile.json") unless File.exist?(config_path)
501
- file = ConfigParser.new.load(config_path)
502
- return {} unless file # no config file at all
503
- @config = file.fetch_value(screenshot.path)
504
- end
505
-
506
495
  # Fetches the title + keyword for this particular screenshot
507
496
  def fetch_text(type)
508
497
  UI.user_error!("Valid parameters :keyword, :title") unless [:keyword, :title].include?(type)
@@ -518,20 +507,19 @@ module Frameit
518
507
  UI.verbose("Falling back to text in Framefile.json as there was nothing specified in the #{type}.strings file")
519
508
 
520
509
  # No string files, fallback to Framefile config
521
- text = fetch_config[type.to_s]['text'] if fetch_config[type.to_s] && fetch_config[type.to_s]['text'] && fetch_config[type.to_s]['text'].length > 0 # Ignore empty string
510
+ text = @config[type.to_s]['text'] if @config[type.to_s] && @config[type.to_s]['text'] && @config[type.to_s]['text'].length > 0 # Ignore empty string
522
511
  return text
523
512
  end
524
513
 
525
514
  def fetch_frame_color
526
- color = fetch_config['frame']
527
- if color == "BLACK"
528
- return Frameit::Color::BLACK
529
- elsif color == "WHITE"
530
- return Frameit::Color::SILVER
531
- elsif color == "GOLD"
532
- return Frameit::Color::GOLD
533
- elsif color == "ROSE_GOLD"
534
- return Frameit::Color::ROSE_GOLD
515
+ color = @config['frame']
516
+ unless color.nil?
517
+ Frameit::Color.constants.each do |c|
518
+ constant = Frameit::Color.const_get(c)
519
+ if color == constant.upcase.gsub(' ', '_')
520
+ return constant
521
+ end
522
+ end
535
523
  end
536
524
 
537
525
  return nil
@@ -539,15 +527,15 @@ module Frameit
539
527
 
540
528
  # The font we want to use
541
529
  def font(key)
542
- single_font = fetch_config[key.to_s]['font']
530
+ single_font = @config[key.to_s]['font']
543
531
  return single_font if single_font
544
532
 
545
- fonts = fetch_config[key.to_s]['fonts']
533
+ fonts = @config[key.to_s]['fonts']
546
534
  if fonts
547
535
  fonts.each do |font|
548
536
  if font['supported']
549
537
  font['supported'].each do |language|
550
- if screenshot.path.include?(language)
538
+ if screenshot.language == language
551
539
  return font["font"]
552
540
  end
553
541
  end
@@ -13,9 +13,16 @@ module Frameit
13
13
  @offsets_cache = JSON.parse(File.read(offsets_json_path))
14
14
  end
15
15
 
16
- offset_value = @offsets_cache["portrait"][screenshot.device_name]
16
+ offset_value = @offsets_cache["portrait"][sanitize_device_name(screenshot.device_name)]
17
17
  UI.error("Tried looking for offset information for 'portrait', #{screenshot.device_name} in '#{offsets_json_path}'") unless offset_value
18
18
  return offset_value
19
19
  end
20
+
21
+ def self.sanitize_device_name(basename)
22
+ # this should be the same as frames_generator's sanitize_device_name (except stripping colors):
23
+ basename = basename.gsub("Apple", "")
24
+ basename = basename.gsub("-", " ")
25
+ basename.strip.to_s
26
+ end
20
27
  end
21
28
  end
@@ -1,6 +1,8 @@
1
1
  require 'fastlane_core/configuration/config_item'
2
2
 
3
3
  require_relative 'module'
4
+ require_relative 'config_parser'
5
+ require_relative 'device_types'
4
6
 
5
7
  module Frameit
6
8
  class Options
@@ -8,74 +10,99 @@ module Frameit
8
10
  @options ||= [
9
11
 
10
12
  FastlaneCore::ConfigItem.new(key: :white,
11
- env_name: "FRAMEIT_WHITE_FRAME",
12
- description: "Use white device frames",
13
- type: Boolean,
14
- optional: true),
13
+ env_name: "FRAMEIT_WHITE_FRAME",
14
+ description: "Use white device frames",
15
+ type: Boolean,
16
+ optional: true),
15
17
  FastlaneCore::ConfigItem.new(key: :silver,
16
- env_name: "FRAMEIT_SILVER_FRAME",
17
- description: "Use white device frames. Alias for :white",
18
- type: Boolean,
19
- optional: true),
18
+ env_name: "FRAMEIT_SILVER_FRAME",
19
+ description: "Use white device frames. Alias for :white",
20
+ type: Boolean,
21
+ optional: true),
20
22
  FastlaneCore::ConfigItem.new(key: :rose_gold,
21
- env_name: "FRAMEIT_ROSE_GOLD_FRAME",
22
- description: "Use rose gold device frames. Alias for :rose_gold",
23
- type: Boolean,
24
- optional: true),
23
+ env_name: "FRAMEIT_ROSE_GOLD_FRAME",
24
+ description: "Use rose gold device frames. Alias for :rose_gold",
25
+ type: Boolean,
26
+ optional: true),
25
27
  FastlaneCore::ConfigItem.new(key: :gold,
26
- env_name: "FRAMEIT_GOLD_FRAME",
27
- description: "Use gold device frames. Alias for :gold",
28
- type: Boolean,
29
- optional: true),
28
+ env_name: "FRAMEIT_GOLD_FRAME",
29
+ description: "Use gold device frames. Alias for :gold",
30
+ type: Boolean,
31
+ optional: true),
30
32
  FastlaneCore::ConfigItem.new(key: :force_device_type,
31
- env_name: "FRAMEIT_FORCE_DEVICE_TYPE",
32
- description: "Forces a given device type, useful for Mac screenshots, as their sizes vary",
33
- optional: true,
34
- verify_block: proc do |value|
35
- available = ['iPhone_6_Plus', 'iPhone_5s', 'iPhone_4', 'iPad_mini', 'Mac']
36
- unless available.include?(value)
37
- UI.user_error!("Invalid device type '#{value}'. Available values: #{available}")
38
- end
39
- end),
33
+ env_name: "FRAMEIT_FORCE_DEVICE_TYPE",
34
+ description: "Forces a given device type, useful for Mac screenshots, as their sizes vary",
35
+ optional: true,
36
+ verify_block: proc do |value|
37
+ UI.user_error!("Invalid device type '#{value}'. Available values: " + Devices.all_device_names_without_apple.join(', ')) unless ConfigParser.supported_device?(value)
38
+ end),
40
39
  FastlaneCore::ConfigItem.new(key: :use_legacy_iphone5s,
41
- env_name: "FRAMEIT_USE_LEGACY_IPHONE_5_S",
42
- description: "Use iPhone 5s instead of iPhone SE frames",
40
+ env_name: "FRAMEIT_USE_LEGACY_IPHONE_5_S",
41
+ description: "Use iPhone 5s instead of iPhone SE frames",
42
+ default_value: false,
43
+ type: Boolean),
44
+ FastlaneCore::ConfigItem.new(key: :use_legacy_iphone6s,
45
+ env_name: "FRAMEIT_USE_LEGACY_IPHONE_6_S",
46
+ description: "Use iPhone 6s frames instead of iPhone 7 frames",
47
+ default_value: false,
48
+ type: Boolean),
49
+ FastlaneCore::ConfigItem.new(key: :use_legacy_iphone7,
50
+ env_name: "FRAMEIT_USE_LEGACY_IPHONE_7",
51
+ description: "Use iPhone 7 frames instead of iPhone 8 frames",
52
+ default_value: false,
53
+ type: Boolean),
54
+ FastlaneCore::ConfigItem.new(key: :use_legacy_iphonex,
55
+ env_name: "FRAMEIT_USE_LEGACY_IPHONE_X",
56
+ description: "Use iPhone X instead of iPhone XS frames",
57
+ default_value: false,
58
+ type: Boolean),
59
+ FastlaneCore::ConfigItem.new(key: :use_legacy_iphonexr,
60
+ env_name: "FRAMEIT_USE_LEGACY_IPHONE_XR",
61
+ description: "Use iPhone XR instead of iPhone 11 frames",
43
62
  default_value: false,
44
63
  type: Boolean),
45
- FastlaneCore::ConfigItem.new(key: :use_legacy_iphone6s,
46
- env_name: "FRAMEIT_USE_LEGACY_IPHONE_6_S",
47
- description: "Use iPhone 6s frames instead of iPhone 7 frames",
64
+ FastlaneCore::ConfigItem.new(key: :use_legacy_iphonexs,
65
+ env_name: "FRAMEIT_USE_LEGACY_IPHONE_XS",
66
+ description: "Use iPhone XS instead of iPhone 11 Pro frames",
48
67
  default_value: false,
49
68
  type: Boolean),
50
- FastlaneCore::ConfigItem.new(key: :use_legacy_iphonex,
51
- env_name: "FRAMEIT_USE_LEGACY_IPHONE_X",
52
- description: "Use iPhone X instead of iPhone XS frames",
69
+ FastlaneCore::ConfigItem.new(key: :use_legacy_iphonexsmax,
70
+ env_name: "FRAMEIT_USE_LEGACY_IPHONE_XS_MAX",
71
+ description: "Use iPhone XS Max instead of iPhone 11 Pro Max frames",
53
72
  default_value: false,
54
73
  type: Boolean),
55
74
  FastlaneCore::ConfigItem.new(key: :force_orientation_block,
56
- type: :string_callback,
57
- description: "[Advanced] A block to customize your screenshots' device orientation",
58
- display_in_shell: false,
59
- optional: true,
60
- default_value: proc do |filename|
61
- f = filename.downcase
62
- if f.end_with?("force_landscapeleft")
63
- :landscape_left
64
- elsif f.end_with?("force_landscaperight")
65
- :landscape_right
66
- end
67
- end,
68
- default_value_dynamic: true),
75
+ type: :string_callback,
76
+ description: "[Advanced] A block to customize your screenshots' device orientation",
77
+ display_in_shell: false,
78
+ optional: true,
79
+ default_value: proc do |filename|
80
+ f = filename.downcase
81
+ if f.end_with?("force_landscapeleft")
82
+ :landscape_left
83
+ elsif f.end_with?("force_landscaperight")
84
+ :landscape_right
85
+ end
86
+ end,
87
+ default_value_dynamic: true),
69
88
  FastlaneCore::ConfigItem.new(key: :debug_mode,
70
- env_name: "FRAMEIT_DEBUG_MODE",
71
- description: "Output debug information in framed screenshots",
72
- default_value: false,
73
- type: Boolean),
89
+ env_name: "FRAMEIT_DEBUG_MODE",
90
+ description: "Output debug information in framed screenshots",
91
+ default_value: false,
92
+ type: Boolean),
74
93
  FastlaneCore::ConfigItem.new(key: :resume,
75
- env_name: "FRAMEIT_RESUME",
76
- description: "Resume frameit instead of reprocessing all screenshots",
77
- default_value: false,
78
- type: Boolean)
94
+ env_name: "FRAMEIT_RESUME",
95
+ description: "Resume frameit instead of reprocessing all screenshots",
96
+ default_value: false,
97
+ type: Boolean),
98
+ FastlaneCore::ConfigItem.new(key: :use_platform,
99
+ env_name: "FRAMEIT_USE_PLATFORM",
100
+ description: "Choose a platform, the valid options are IOS, ANDROID and ANY (IOS is default to ensure backward compatibility)",
101
+ optional: true,
102
+ default_value: Platform::IOS,
103
+ verify_block: proc do |value|
104
+ UI.user_error!("Invalid platform type '#{value}'. Available values are " + Platform.all_platforms.join(', ') + ".") unless ConfigParser.supported_platform?(value)
105
+ end)
79
106
  ]
80
107
  end
81
108
  end
@@ -14,9 +14,8 @@ module Frameit
14
14
  end
15
15
  end
16
16
 
17
- def run(path, color = nil)
17
+ def run(path, color = nil, platform = nil)
18
18
  unless color
19
- color = Frameit::Color::BLACK
20
19
  color = Frameit::Color::SILVER if Frameit.config[:white] || Frameit.config[:silver]
21
20
  color = Frameit::Color::GOLD if Frameit.config[:gold]
22
21
  color = Frameit::Color::ROSE_GOLD if Frameit.config[:rose_gold]
@@ -29,11 +28,12 @@ module Frameit
29
28
  next if skip_path?(full_path)
30
29
 
31
30
  begin
32
- screenshot = Screenshot.new(full_path, color)
31
+ config = create_config(full_path)
32
+ screenshot = Screenshot.new(full_path, color, config, platform)
33
33
 
34
34
  next if skip_up_to_date?(screenshot)
35
35
 
36
- editor = editor(screenshot)
36
+ editor = editor(screenshot, config)
37
37
 
38
38
  if editor.should_skip?
39
39
  UI.message("Skipping framing of screenshot #{screenshot.path}. No title provided in your Framefile.json or title.strings.")
@@ -71,12 +71,22 @@ module Frameit
71
71
  false
72
72
  end
73
73
 
74
- def editor(screenshot)
74
+ def editor(screenshot, config)
75
75
  if screenshot.mac?
76
- return MacEditor.new(screenshot)
76
+ return MacEditor.new(screenshot, config)
77
77
  else
78
- return Editor.new(screenshot, Frameit.config[:debug_mode])
78
+ return Editor.new(screenshot, config, Frameit.config[:debug_mode])
79
79
  end
80
80
  end
81
+
82
+ # Loads the config (colors, background, texts, etc.)
83
+ # Don't use this method to access the actual text and use `fetch_texts` instead
84
+ def create_config(screenshot_path)
85
+ config_path = File.join(File.expand_path("..", screenshot_path), "Framefile.json")
86
+ config_path = File.join(File.expand_path("../..", screenshot_path), "Framefile.json") unless File.exist?(config_path)
87
+ file = ConfigParser.new.load(config_path)
88
+ return {} unless file # no config file at all
89
+ file.fetch_value(screenshot_path)
90
+ end
81
91
  end
82
92
  end
@@ -1,87 +1,75 @@
1
- require 'deliver/app_screenshot'
2
-
3
1
  require_relative 'editor'
4
2
  require_relative 'mac_editor'
5
3
  require_relative 'device_types'
6
4
  require_relative 'module'
5
+ require_relative 'device'
7
6
 
8
7
  module Frameit
9
8
  # Represents one screenshot
10
9
  class Screenshot
11
10
  attr_accessor :path # path to the screenshot
12
11
  attr_accessor :size # size in px array of 2 elements: height and width
13
- attr_accessor :screen_size # deliver screen size type, is unique per device type, used in device_name
12
+ attr_accessor :device # device detected according to resolution, priority and settings
14
13
  attr_accessor :color # the color to use for the frame (from Frameit::Color)
15
14
 
16
15
  # path: Path to screenshot
17
16
  # color: Color to use for the frame
18
- def initialize(path, color)
17
+ def initialize(path, color, config, platform_command)
19
18
  UI.user_error!("Couldn't find file at path '#{path}'") unless File.exist?(path)
20
19
  @color = color
21
20
  @path = path
22
21
  @size = FastImage.size(path)
23
22
 
24
- @screen_size = ENV["FRAMEIT_FORCE_DEVICE_TYPE"] || Deliver::AppScreenshot.calculate_screen_size(path)
23
+ # There are three ways how we can get settings to Frameit:
24
+ # - options.rb
25
+ # - gets parameters via CLI (e. g. fastlane run frameit use_platform:"android") or fastfile (Fastlane's global
26
+ # settings for a given project)
27
+ # - see Parameters in the doc
28
+ # - contains default values and validates values
29
+ # - accessed via Frameit.config[:key]
30
+ # - lowest priority
31
+ # - commands_generator.rb
32
+ # - commands entered directly to CLI (e. g. fastlane frameit android)
33
+ # - they are passed via constructors to other classes
34
+ # - higher priority than options.rb (user may enter a command to override fastfile's global setting)
35
+ # - config_parser.rb
36
+ # - gets key / values from Framefile.json
37
+ # - see Advanced usage in the doc
38
+ # - both default and specific values can be entered in the file (filtered by file name)
39
+ # - accessed via ConfigParser.fetch_value(screenshot.path)[key] (the ConfigParser's instance is passed
40
+ # to Screenshot's constructor as config, i.e. we call config[key])
41
+ # - should have the highest priority, because user might set a specific value for a specific screenshot which
42
+ # should override CLI parameters and fastfile global setting
43
+ platform = config['use_platform'] || platform_command || Frameit.config[:use_platform]
44
+ @device = Device.find_device_by_id_or_name(config['force_device_type'] || Frameit.config[:force_device_type]) || Device.detect_device(path, platform)
25
45
  end
26
46
 
27
47
  # Device name for a given screen size. Used to use the correct template
28
48
  def device_name
29
- # rubocop:disable Require/MissingRequireStatement
30
- sizes = Deliver::AppScreenshot::ScreenSize
31
- case @screen_size
32
- when sizes::IOS_65
33
- return 'iPhone XS Max'
34
- when sizes::IOS_61
35
- return 'iPhone XR'
36
- when sizes::IOS_58
37
- return Frameit.config[:use_legacy_iphonex] ? 'iPhone X' : 'iPhone XS'
38
- when sizes::IOS_55
39
- return Frameit.config[:use_legacy_iphone6s] ? 'iPhone 6s Plus' : 'iPhone 7 Plus'
40
- when sizes::IOS_47
41
- return Frameit.config[:use_legacy_iphone6s] ? 'iPhone 6s' : 'iPhone 7'
42
- when sizes::IOS_40
43
- return Frameit.config[:use_legacy_iphone5s] ? 'iPhone 5s' : 'iPhone SE'
44
- when sizes::IOS_35
45
- return 'iPhone 4'
46
- when sizes::IOS_IPAD
47
- return 'iPad Air 2'
48
- when sizes::IOS_IPAD_10_5
49
- return 'iPad Pro (10.5-inch)'
50
- when sizes::IOS_IPAD_11
51
- return 'iPad Pro (11-inch)'
52
- when sizes::IOS_IPAD_PRO
53
- return 'iPad Pro'
54
- when sizes::IOS_IPAD_PRO_12_9
55
- return 'iPad Pro (12.9-inch) (3rd generation)'
56
- when sizes::MAC
57
- return 'MacBook'
58
- else
59
- UI.error("Unknown device type for size #{@screen_size} for path '#{path}'")
60
- end
49
+ @device.formatted_name
61
50
  # rubocop:enable Require/MissingRequireStatement
62
51
  end
63
52
 
64
- def color
65
- if !Frameit.config[:use_legacy_iphone6s] && @color == Frameit::Color::BLACK
66
- if @screen_size == Deliver::AppScreenshot::ScreenSize::IOS_55 || @screen_size == Deliver::AppScreenshot::ScreenSize::IOS_47
67
- return "Matte Black" # RIP space gray
68
- end
69
- end
70
- return @color
53
+ def default_color
54
+ @device.default_color
55
+ end
56
+
57
+ def deliver_screen_id
58
+ @device.deliver_screen_id
71
59
  end
72
60
 
73
61
  # Is the device a 3x device? (e.g. iPhone 6 Plus, iPhone X)
74
62
  def triple_density?
75
- (screen_size == Deliver::AppScreenshot::ScreenSize::IOS_55 || screen_size == Deliver::AppScreenshot::ScreenSize::IOS_58 || screen_size == Deliver::AppScreenshot::ScreenSize::IOS_65)
63
+ !device.density_ppi.nil? && device.density_ppi > 400
76
64
  end
77
65
 
78
66
  # Super old devices (iPhone 4)
79
67
  def mini?
80
- (screen_size == Deliver::AppScreenshot::ScreenSize::IOS_35)
68
+ !device.density_ppi.nil? && device.density_ppi < 300
81
69
  end
82
70
 
83
71
  def mac?
84
- return device_name == 'MacBook'
72
+ device_name == 'MacBook'
85
73
  end
86
74
 
87
75
  # The name of the orientation of a screenshot. Used to find the correct template
@@ -134,6 +122,10 @@ module Frameit
134
122
  return File.mtime(path) > File.mtime(output_path)
135
123
  end
136
124
 
125
+ def language
126
+ @language ||= Pathname.new(path).parent.basename.to_s
127
+ end
128
+
137
129
  def to_s
138
130
  self.path
139
131
  end