fastlane-plugin-polidea 2.1.0 → 2.1.1.pre

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.
Files changed (27) hide show
  1. checksums.yaml +4 -4
  2. data/lib/fastlane/plugin/polidea/actions/fota_mail.rb +10 -16
  3. data/lib/fastlane/plugin/polidea/actions/fota_s3.rb +6 -25
  4. data/lib/fastlane/plugin/polidea/helper/mime.rb +22 -0
  5. data/lib/fastlane/plugin/polidea/helper/page_generator.rb +39 -3
  6. data/lib/fastlane/plugin/polidea/helper/qr_generator.rb +1 -1
  7. data/lib/fastlane/plugin/polidea/templates/download.erb +481 -0
  8. data/lib/fastlane/plugin/polidea/templates/images/cover-shuttle.jpg +0 -0
  9. data/lib/fastlane/plugin/polidea/templates/images/icon-placeholder.png +0 -0
  10. data/lib/fastlane/plugin/polidea/templates/images/polidea-logo.png +0 -0
  11. data/lib/fastlane/plugin/polidea/templates/images/social-behance.png +0 -0
  12. data/lib/fastlane/plugin/polidea/templates/images/social-dribbble.png +0 -0
  13. data/lib/fastlane/plugin/polidea/templates/images/social-facebook.png +0 -0
  14. data/lib/fastlane/plugin/polidea/templates/images/social-github.png +0 -0
  15. data/lib/fastlane/plugin/polidea/templates/images/social-instagram.png +0 -0
  16. data/lib/fastlane/plugin/polidea/templates/images/social-linkedin.png +0 -0
  17. data/lib/fastlane/plugin/polidea/templates/images/social-twitter.png +0 -0
  18. data/lib/fastlane/plugin/polidea/templates/installation-page/css/installation-page.css +2835 -1082
  19. data/lib/fastlane/plugin/polidea/templates/installation_template.erb +3 -7
  20. data/lib/fastlane/plugin/polidea/templates/mailgun_template.erb +56 -24
  21. data/lib/fastlane/plugin/polidea/templates/secure_installation_template.erb +6 -10
  22. data/lib/fastlane/plugin/polidea/version.rb +1 -1
  23. metadata +28 -8
  24. data/lib/fastlane/plugin/polidea/templates/images/logo.png +0 -0
  25. data/lib/fastlane/plugin/polidea/templates/images/polidea-facebook-icon.png +0 -0
  26. data/lib/fastlane/plugin/polidea/templates/images/polidea-github-icon.png +0 -0
  27. data/lib/fastlane/plugin/polidea/templates/images/polidea-twitter-icon.png +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c734a5f190790b057fd810e006676c877b67ca63c5f592b2b9dccd85acc604e1
4
- data.tar.gz: 3652e585a63174db49f9740d07466d4fb1681076023e8f01d029007ee2d58b9b
3
+ metadata.gz: 9389415ea79485df9f60db8fb7d36dc00f3722a0c659132f35e4744e89ab8c09
4
+ data.tar.gz: 455e97b59e28db63b05988617ab20453d49d281f8f18a987e58e12157168affe
5
5
  SHA512:
6
- metadata.gz: a737c9abc1855393221caebbf39e1235c42c124d5be2578b2c6c72048177080a056466f11f5b7eb492d7a232dd473f868472bf2d123258748d314e8f2c44ea4a
7
- data.tar.gz: 73e1a6f94666dece1de3813aeef9dd66cb50e54cec3b2b5df5d61f131cf6f455c9466211a6f4176cb9300749f6f00f20c0881b2781a5b016def83625e63089a4
6
+ metadata.gz: 6f8900858b70301309e2a41b474200a95fe0af1214a969e0a0fab853859e36fbb4e2717cd9d24240c5ea0e080f35abe7d6be5dfc8a55a2ec2198f593746c946d
7
+ data.tar.gz: edcb2e87e4381fbb62797dc9e7c5cde32db6578a315254c45c1ee0c85996024c6827d9c8a2453c184a9d57f53ea71c28b897272f65355182fe4f0948e6aefcb3
@@ -1,4 +1,5 @@
1
1
  # rubocop:disable Metrics/MethodLength
2
+ require 'redcarpet'
2
3
  require 'fastlane/erb_template_helper'
3
4
 
4
5
  module Fastlane
@@ -105,24 +106,15 @@ module Fastlane
105
106
  end
106
107
 
107
108
  def self.inline_images(options)
108
- base_path = "#{__dir__}/../templates/images"
109
109
  options[:inline] = [
110
110
  qr_code(options[:installation_link])
111
111
  ]
112
112
  options[:inline] << File.new(options[:app_icon]) if options[:app_icon]
113
- images = [
114
- "polidea-facebook-icon.png",
115
- "polidea-github-icon.png",
116
- "polidea-logo.png",
117
- "polidea-twitter-icon.png"
118
- ]
119
- images << "icon-placeholder.png" unless options[:app_icon]
120
- options[:inline].concat(images.map { |image| File.new("#{base_path}/#{image}") })
121
113
  end
122
114
 
123
115
  def self.qr_code(installation_link)
124
116
  qr_code_path = "/tmp/qr_code.png"
125
- QRGenerator.new(installation_link, false, ::ChunkyPNG::Color.rgb(103, 103, 103)).generate(qr_code_path)
117
+ QRGenerator.new(installation_link, false, ::ChunkyPNG::Color.rgb(21, 18, 126)).generate(qr_code_path)
126
118
  File.new(qr_code_path)
127
119
  end
128
120
 
@@ -150,25 +142,27 @@ module Fastlane
150
142
  app_version: options[:app_version],
151
143
  build_number: options[:build_number],
152
144
  installation_link: options[:installation_link],
153
- release_notes: (options[:release_notes] || "").split("\n"),
145
+ release_notes: options[:release_notes],
154
146
  platform: options[:platform],
155
147
  release_date: DateTime.now.strftime('%b %d, %Y'),
156
- binary_size: (options[:binary_size] / 1024.0 / 1024.0).round(2).to_s
148
+ binary_size: (options[:binary_size] / 1024.0 / 1024.0).round(2).to_s,
149
+ qr_code: "qr_code.png"
157
150
  }
158
151
  hash[:success] = options[:success]
159
152
  hash[:ci_build_link] = options[:ci_build_link]
160
153
 
161
- # grabs module
162
- eth = Fastlane::ErbTemplateHelper
163
154
  # create html from template
164
155
  html_template_path = options[:template_path]
165
156
  if html_template_path && File.exist?(html_template_path)
157
+ eth = Fastlane::ErbTemplateHelper
166
158
  html_template = eth.load_from_path(html_template_path)
159
+ mail_html = eth.render(html_template, hash)
167
160
  else
168
- html_template = eth.load_from_path("#{__dir__}/../templates/mailgun_template.erb")
161
+ mail_html = PageGenerator.mail(hash)
169
162
  end
163
+
170
164
  premailer = Premailer.new(
171
- eth.render(html_template, hash),
165
+ mail_html,
172
166
  { warn_level: Premailer::Warnings::SAFE, with_html_string: true }
173
167
  )
174
168
  premailer.to_inline_css
@@ -164,7 +164,7 @@ module Fastlane
164
164
  icon_url = self.upload_icon(icon_file, url_part, bucket, acl, treat_bucket_as_domain_name)
165
165
 
166
166
  # Creates html from template
167
- html_render = PageGenerator.generate({
167
+ html_render = PageGenerator.installation_page({
168
168
  url: "itms-services://?action=download-manifest&url=#{URI.encode_www_form_component(plist_url)}",
169
169
  installation_password: installation_password,
170
170
  app_version: bundle_version,
@@ -278,7 +278,7 @@ module Fastlane
278
278
  icon_url = self.upload_icon(icon_file, url_part, bucket, acl, treat_bucket_as_domain_name)
279
279
 
280
280
  # Creates html from template
281
- html_render = PageGenerator.generate({
281
+ html_render = PageGenerator.installation_page({
282
282
  url: apk_url,
283
283
  installation_password: installation_password,
284
284
  app_version: app_version,
@@ -348,7 +348,7 @@ module Fastlane
348
348
  key: file_name,
349
349
  body: file_data,
350
350
  acl: acl,
351
- content_type: content_type_for_file(file_name)
351
+ content_type: Mime.content_type_for_file(file_name)
352
352
  })
353
353
 
354
354
  # When you enable versioning on a S3 bucket,
@@ -378,7 +378,7 @@ module Fastlane
378
378
  key: s3_path,
379
379
  body: File.open(local_path),
380
380
  acl: acl,
381
- content_type: content_type_for_file(local_path)
381
+ content_type: Mime.content_type_for_file(local_path)
382
382
  })
383
383
  end
384
384
  end
@@ -399,25 +399,6 @@ module Fastlane
399
399
  return files
400
400
  end
401
401
 
402
- def self.content_type_for_file(file)
403
- file_extension = File.extname(file)
404
- extensions_to_type = {
405
- ".html" => "text/html",
406
- ".png" => "image/png",
407
- ".jpg" => "text/jpeg",
408
- ".gif" => "image/gif",
409
- ".svg" => "image/svg+xml",
410
- ".log" => "text/plain",
411
- ".css" => "text/css",
412
- ".js" => "application/javascript"
413
- }
414
- if extensions_to_type[file_extension].nil?
415
- "application/octet-stream"
416
- else
417
- extensions_to_type[file_extension]
418
- end
419
- end
420
-
421
402
  #
422
403
  # NOT a fan of this as this was taken straight from Shenzhen
423
404
  # https://github.com/nomad/shenzhen/blob/986792db5d4d16a80c865a2748ee96ba63644821/lib/shenzhen/plugins/s3.rb#L32
@@ -539,9 +520,9 @@ module Fastlane
539
520
  FastlaneCore::ConfigItem.new(key: :release_notes,
540
521
  env_name: "S3_RELEASE_NOTES",
541
522
  description: "Release notes",
542
- type: Array,
523
+ type: String,
543
524
  optional: true,
544
- default_value: Actions.lane_context[SharedValues::RELEASE_NOTES] ? Actions.lane_context[SharedValues::RELEASE_NOTES].split("\n") : nil),
525
+ default_value: Actions.lane_context[SharedValues::RELEASE_NOTES]),
545
526
  FastlaneCore::ConfigItem.new(key: :treat_bucket_as_domain_name,
546
527
  description: "If it's true, it transforms all urls from https://s3.amazonaws.com/BUCKET_NAME to https://BUCKET_NAME",
547
528
  is_string: false,
@@ -0,0 +1,22 @@
1
+ module Fastlane
2
+ module Mime
3
+ def self.content_type_for_file(file)
4
+ file_extension = File.extname(file)
5
+ extensions_to_type = {
6
+ ".html" => "text/html",
7
+ ".png" => "image/png",
8
+ ".jpg" => "image/jpeg",
9
+ ".gif" => "image/gif",
10
+ ".svg" => "image/svg+xml",
11
+ ".log" => "text/plain",
12
+ ".css" => "text/css",
13
+ ".js" => "application/javascript"
14
+ }
15
+ if extensions_to_type[file_extension].nil?
16
+ "application/octet-stream"
17
+ else
18
+ extensions_to_type[file_extension]
19
+ end
20
+ end
21
+ end
22
+ end
@@ -4,7 +4,28 @@ require 'json'
4
4
 
5
5
  module Fastlane
6
6
  module PageGenerator
7
- def self.generate(config)
7
+ def self.mail(config)
8
+ UI.message("Generating e-mail...")
9
+ eth = Fastlane::ErbTemplateHelper
10
+ html_template = eth.load_from_path("#{__dir__}/../templates/download.erb")
11
+ eth.render(html_template, {
12
+ author: config[:author],
13
+ last_commit: config[:last_commit],
14
+ is_android: config[:is_android],
15
+ app_icon: config[:app_icon] ? "cid:#{config[:app_icon]}" : "https://s3.eu-central-1.amazonaws.com/fota.polidea.com/mails/images/icon-placeholder.png",
16
+ app_name: config[:app_name],
17
+ app_version: config[:app_version],
18
+ build_number: config[:build_number],
19
+ installation_link: config[:installation_link],
20
+ release_notes: parse_release_notes(config[:release_notes]),
21
+ platform: config[:platform],
22
+ release_date: config[:release_date],
23
+ binary_size: config[:binary_size],
24
+ qr_code: "cid:#{config[:qr_code]}"
25
+ })
26
+ end
27
+
28
+ def self.installation_page(config)
8
29
  if config[:installation_password]
9
30
  generate_private(config)
10
31
  else
@@ -26,7 +47,7 @@ module Fastlane
26
47
  app_name: config[:app_name],
27
48
  app_icon: config[:app_icon],
28
49
  platform: config[:platform],
29
- release_notes: config[:release_notes]
50
+ release_notes: parse_release_notes(config[:release_notes])
30
51
  })
31
52
  end
32
53
  private_class_method :generate_private
@@ -42,7 +63,7 @@ module Fastlane
42
63
  app_name: config[:app_name],
43
64
  app_icon: config[:app_icon],
44
65
  platform: config[:platform],
45
- release_notes: config[:release_notes]
66
+ release_notes: parse_release_notes(config[:release_notes])
46
67
  })
47
68
  end
48
69
  private_class_method :generate_public
@@ -67,5 +88,20 @@ module Fastlane
67
88
  return installation_link, salt, iv
68
89
  end
69
90
  private_class_method :encrypt
91
+
92
+ def self.parse_release_notes(release_notes)
93
+ renderer = Redcarpet::Render::HTML.new({
94
+ filter_html: true,
95
+ no_styles: true
96
+ })
97
+ markdown = Redcarpet::Markdown.new(
98
+ renderer,
99
+ fenced_code_blocks: true,
100
+ autolink: false,
101
+ tables: false
102
+ )
103
+ markdown.render(release_notes || "No release notes.")
104
+ end
105
+ private_class_method :parse_release_notes
70
106
  end
71
107
  end
@@ -10,7 +10,7 @@ module Fastlane
10
10
  @margin = 20
11
11
  @image = ::ChunkyPNG::Image.new(2 * @margin + @qr_code.qrcode.module_count * 5, 2 * @margin + @qr_code.qrcode.module_count * 5, ::ChunkyPNG::Color::WHITE)
12
12
 
13
- @logo = ::ChunkyPNG::Image.from_file("#{path_to_resources}/logo.png")
13
+ @logo = ::ChunkyPNG::Image.from_file("#{path_to_resources}/polidea-logo.png")
14
14
  @logo = @logo.resize(2 * @margin + @qr_code.qrcode.module_count * 5, 2 * @margin + @qr_code.qrcode.module_count * 5)
15
15
  end
16
16