fastlane-plugin-screenshotslive 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6957eb0962a899fd926ee2a16a5c88ee497568f7d12d8d6948c0216c0e26d2d4
4
- data.tar.gz: 22498ae68c91506f3c47ad2ca484af2124d0908c7668ba3a9ea8d7bbe8111e32
3
+ metadata.gz: 0a91b927b5744c2efd5aad0a8c96cb6c42b647e3e97068c2b60dbdccf6176936
4
+ data.tar.gz: 979e2087477a99574ef505dd10f6bff7be07db12de1c35d0e30b57e6af61ffad
5
5
  SHA512:
6
- metadata.gz: 442f0916ce16e5093e9b04741c3d6f3eb530d61531f323b3fd640b2133fc950af2915dea5fd0072d2f282194f77878e0ef72cc4aa0885b8175766a43bd8e02d3
7
- data.tar.gz: 1cc9fa4819ee9eaed055dbeffaf05a2936cf0f9fd479c954e279cf1bd6303736a57035a80035da4b106914043d43d4e036a72eae1e9bc62fa9850d0885f20c2e
6
+ metadata.gz: 65c7aa68146ce999f8a19fad51dbc643e3935f024df337c295864738ba67ee2a5de9b2b515a250b9117266cabe4f04f065880e8475219e393ca8dab7fd131075
7
+ data.tar.gz: 9458ad975229773cfa1ce307279d4b43b9d0a98ef922bb424c7c8b94459697d231f4481065834beccad3f4a0134a90762a047cbfa96770d27b0d0a515ed9a535
@@ -14,26 +14,21 @@ module Fastlane
14
14
  output_dir = params[:output_directory]
15
15
  base_url = params[:base_url]
16
16
  overrides = params[:overrides] || {}
17
- screenshots = params[:screenshots] || {}
18
17
 
19
18
  yaml_config = File.read(yaml_path)
19
+ picture_files = {}
20
20
 
21
- if !overrides.empty? || !screenshots.empty?
22
- yaml_config = apply_overrides(yaml_config, overrides, screenshots)
21
+ unless overrides.empty?
22
+ yaml_config, picture_files = apply_overrides(yaml_config, overrides)
23
23
  end
24
24
 
25
25
  UI.message("Dispatching render via Screenshots.live API...")
26
-
27
26
  client = Screenshotslive::ApiClient.new(api_key: api_key, base_url: base_url)
28
27
 
29
- if screenshots.empty?
28
+ if picture_files.empty?
30
29
  result = client.render(yaml_config: yaml_config)
31
30
  else
32
- picture_files = {}
33
- screenshots.each do |_item_id, path|
34
- filename = File.basename(path)
35
- picture_files[filename] = path
36
- end
31
+ UI.message("Uploading #{picture_files.size} local screenshot(s)...")
37
32
  result = client.render_with_pictures(yaml_config: yaml_config, picture_files: picture_files)
38
33
  end
39
34
 
@@ -67,31 +62,32 @@ module Fastlane
67
62
 
68
63
  File.delete(zip_path)
69
64
 
70
- file_count = Dir.glob(File.join(output_dir, "*.png")).length
65
+ file_count = Dir.glob(File.join(output_dir, "*.*")).length
71
66
  UI.success("#{file_count} screenshots rendered and saved to #{output_dir}")
72
67
  output_dir
73
68
  end
74
69
 
75
- def self.apply_overrides(yaml_string, overrides, screenshots)
70
+ def self.apply_overrides(yaml_string, overrides)
76
71
  data = YAML.safe_load(yaml_string)
72
+ picture_files = {}
77
73
 
78
74
  items = data["items"] || []
79
75
  items.each do |item|
80
76
  item_id = item["itemId"]
81
-
82
- if overrides.key?(item_id)
83
- overrides[item_id].each do |field, value|
77
+ next unless overrides.key?(item_id)
78
+
79
+ overrides[item_id].each do |field, value|
80
+ if field.to_s == "screenshotUrl" && File.exist?(value.to_s)
81
+ filename = File.basename(value.to_s)
82
+ picture_files[filename] = value.to_s
83
+ item["screenshotUrl"] = "#{PICTURE_REF_PREFIX}#{filename}"
84
+ else
84
85
  item[field.to_s] = value
85
86
  end
86
87
  end
87
-
88
- if screenshots.key?(item_id)
89
- filename = File.basename(screenshots[item_id])
90
- item["screenshotUrl"] = "#{PICTURE_REF_PREFIX}#{filename}"
91
- end
92
88
  end
93
89
 
94
- data.to_yaml
90
+ [data.to_yaml, picture_files]
95
91
  end
96
92
 
97
93
  def self.description
@@ -109,8 +105,8 @@ module Fastlane
109
105
  def self.details
110
106
  "Sends a YAML configuration to the Screenshots.live render API, polls for completion, " \
111
107
  "downloads the rendered ZIP, and extracts flat screenshot PNGs into the output directory. " \
112
- "Supports overriding YAML values (text, colors) and injecting local screenshot files " \
113
- "via the render-with-pictures endpoint."
108
+ "Override any YAML field per itemId via the overrides hash. If a screenshotUrl points " \
109
+ "to a local file, it is automatically uploaded via the render-with-pictures endpoint."
114
110
  end
115
111
 
116
112
  def self.available_options
@@ -138,14 +134,8 @@ module Fastlane
138
134
  ),
139
135
  FastlaneCore::ConfigItem.new(
140
136
  key: :overrides,
141
- description: "Hash of itemId => { field => value } overrides to apply to the YAML before rendering",
142
- optional: true,
143
- default_value: {},
144
- type: Hash
145
- ),
146
- FastlaneCore::ConfigItem.new(
147
- key: :screenshots,
148
- description: "Hash of itemId => local_file_path to inject screenshots via render-with-pictures",
137
+ description: "Hash of itemId => { field => value } to override in the YAML. " \
138
+ "If screenshotUrl points to a local file, it is uploaded automatically",
149
139
  optional: true,
150
140
  default_value: {},
151
141
  type: Hash
@@ -170,22 +160,20 @@ module Fastlane
170
160
 
171
161
  def self.example_code
172
162
  [
173
- '# Basic render from YAML
163
+ '# Basic render
174
164
  screenshotslive(
175
165
  api_key: ENV["SCREENSHOTSLIVE_API_KEY"],
176
166
  yaml_config: "./screenshots.yml",
177
167
  output_directory: "./fastlane/screenshots/en-US"
178
168
  )',
179
- '# Override text and inject local screenshots
169
+ '# Override text and screenshots per item
180
170
  screenshotslive(
181
171
  api_key: ENV["SCREENSHOTSLIVE_API_KEY"],
182
172
  yaml_config: "./screenshots.yml",
183
173
  output_directory: "./fastlane/screenshots/de-DE",
184
174
  overrides: {
185
- "abc-item-id" => { "content" => "Neue Funktion" },
186
- },
187
- screenshots: {
188
- "def-device-frame-id" => "./screens/de/home.png",
175
+ "text-item-id" => { "content" => "Neue Funktion", "color" => "#FF0000" },
176
+ "device-frame-id" => { "screenshotUrl" => "./screens/de/home.png" },
189
177
  }
190
178
  )',
191
179
  ]
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module Screenshotslive
3
- VERSION = "0.3.1"
3
+ VERSION = "0.3.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-screenshotslive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Isensee
@@ -41,16 +41,22 @@ dependencies:
41
41
  name: rubyzip
42
42
  requirement: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - "~>"
44
+ - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: '2.4'
46
+ version: '2.0'
47
+ - - "<"
48
+ - !ruby/object:Gem::Version
49
+ version: '3.0'
47
50
  type: :runtime
48
51
  prerelease: false
49
52
  version_requirements: !ruby/object:Gem::Requirement
50
53
  requirements:
51
- - - "~>"
54
+ - - ">="
52
55
  - !ruby/object:Gem::Version
53
- version: '2.4'
56
+ version: '2.0'
57
+ - - "<"
58
+ - !ruby/object:Gem::Version
59
+ version: '3.0'
54
60
  - !ruby/object:Gem::Dependency
55
61
  name: fastlane
56
62
  requirement: !ruby/object:Gem::Requirement