fastlane-plugin-wpmreleasetoolkit 2.0.0 → 2.1.0

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: ebad531acd982b1354116d3f924974a8376da07fc7014646c19d40097fb0ca6e
4
- data.tar.gz: 6594d0af0ddd193cb12007d7cc145c11c519129e3df226091b1fae6f608f8c3a
3
+ metadata.gz: ccdaad31840825f4e31a868d02be5bd94a50b8dfe08905b75a07d9c2de187158
4
+ data.tar.gz: 679d9fe6250aeadd808ddbd2d5baf23ce8ff0f920dd52a99cabf1b751ec74fc2
5
5
  SHA512:
6
- metadata.gz: 81278eaaa129a68388f06f55b125254a5464ba146af61c8f8f4a6dc6905bd4ede2774950ee7b4d045e3e88d202e38b57e093bda8ce3ccae0a712ca346a79e68d
7
- data.tar.gz: fab14969f2a2063c6b0a5ee451dd72220416355b93c66b55e9c80656f247de8bbba8e67f4b455f46d6636950139a57e0a86d6cbbbee6065d52113757d3d8e233
6
+ metadata.gz: f972a9987b33dad7bf2eee79e378fb40ba5ed174c4885b983dccd1ee86ddb1ca3cdc998c50c3ce0d7dddaec5d0c4508d4baab3a81ef62f5e3e6759b70f68954f
7
+ data.tar.gz: bf06d3515cd1994574d4b0e0d01b67c4554106c342d86cf87dd7e72d572b5b1e6129cc7757a7d64b42adaab0c791185b9d3544f244cf338bf77cb10de0ac99da
@@ -0,0 +1,93 @@
1
+ require 'fastlane_core'
2
+
3
+ # The features in this file are controlled by the following ENV vars:
4
+ #
5
+ # @env `FASTLANE_PROMPT_REMINDER_DISABLE_AUTO_PATCH`
6
+ # If this variable is set, it will disable the auto-application of the monkey patch. In such case,
7
+ # `UI.input`, `UI.confirm`, `UI.select` and `UI.password` methods won't be automatically patched
8
+ # unless you explicitly call `monkey_patch_interactive_prompts_with_reminder` yourself.
9
+ #
10
+ # @env `FASTLANE_PROMPT_REMINDER_MESSAGE`
11
+ # - If not set, then while auto-patching the `UI.…` methods, it will NOT make the patched methods
12
+ # speak any vocal message – and instead will only emit a beep and make your Terminal icon jump in the Dock.
13
+ # - If set to `default`, `true`, `yes` or `1`, then while auto-patching the `UI.…` methods, it will
14
+ # make the patched methods announce the default message.
15
+ # - If set to any other string, it will make the patched methods use that string as the message to announce
16
+ # during the reminders
17
+ # - NOTE: This env var only has an effect if the other `FASTLANE_PROMPT_REMINDER_DISABLE_AUTO_PATCH` env var
18
+ # is _not_ set (and thus the `UI.…` methods _are_ auto-patched), because it only affects how auto-patching is done.
19
+ #
20
+ # @env `FASTLANE_PROMPT_REMINDER_DELAYS`
21
+ # The delays (in seconds) to use when monkey-patching the `UI.…` methods to wrap them around `with_reminder`,
22
+ # separated by a comma (e.g. `60,300,900`). If unset, will use the default delays of `30,180,600`.
23
+
24
+ module FastlaneCore
25
+ # NOTE: FastlaneCore::UI delegates to the FastlaneCore::Shell implementation when output is the terminal
26
+ class Shell
27
+ DEFAULT_PROMPT_REMINDER_MESSAGE = 'An interactive prompt is waiting for you in the Terminal!'.freeze
28
+ DEFAULT_PROMPT_REMINDER_DELAYS = [30, 180, 600].freeze
29
+
30
+ # Calls the block given and remind the user with a vocal message if the block does not return after specific delays.
31
+ #
32
+ # Especially useful when using a block which calls methods that are interactive, in order to remind the user
33
+ # to answer the interactive prompt if they forgot about it after some delays.
34
+ #
35
+ # Example usage:
36
+ #
37
+ # text = with_reminder do
38
+ # puts "Enter some text:"
39
+ # $stdout.getch
40
+ # end
41
+ #
42
+ # @param [Double,Array<Double>] after
43
+ # Delay or list of delays to wait for before pronouncing the reminder message.
44
+ # If an array of values is passed, the message will be pronounced multiple times, after having waited for the subsequent delays in turn.
45
+ # Defaults to reminding after 30s, then 3mn, then 10mn.
46
+ # @param [String] message
47
+ # The message to pronounce out loud after the delay has passed, if the block hasn't returned beforehand.
48
+ # @return The same value that the blocks might return
49
+ #
50
+ def self.with_reminder(after: DEFAULT_PROMPT_REMINDER_DELAYS, message: DEFAULT_PROMPT_REMINDER_MESSAGE)
51
+ delays_list = Array(after.dup)
52
+ thread = Thread.new do
53
+ until delays_list.empty?
54
+ sleep(delays_list.shift)
55
+ $stdout.beep
56
+ system('say', message) unless message.nil?
57
+ end
58
+ end
59
+ # execute the interactive code
60
+ res = yield
61
+ # if we replied before the timeout, kill the thread so message won't be triggered
62
+ thread.kill
63
+ # If the block given returned a value, pass it
64
+ return res
65
+ end
66
+
67
+ # Monkey-Patch fastlane's `UI.input`, `UI.confirm`, `UI.select` and `UI.password` interactive methods
68
+ # (which delegate to `FastlaneCore::Shell` when output is the terminal)
69
+ #
70
+ # Once you call this method, any invocation of `UI.input`, `UI.confirm`, `UI.select` or `UI.password`
71
+ # anywhere in Fastlane (by your Fastfile, an action, …) will be wrapped in a call to with_reminder automatically.
72
+ #
73
+ def self.monkey_patch_interactive_prompts_with_reminder(after: DEFAULT_PROMPT_REMINDER_DELAYS, message: DEFAULT_PROMPT_REMINDER_MESSAGE)
74
+ %i[input confirm select password].each do |method_name|
75
+ old_method = instance_method(method_name)
76
+
77
+ define_method(method_name) do |*args|
78
+ FastlaneCore::Shell.with_reminder(after: after, message: message) { old_method.bind(self).call(*args) }
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end
84
+
85
+ # Apply Monkey patch
86
+ unless ENV['FASTLANE_PROMPT_REMINDER_DISABLE_AUTO_PATCH']
87
+ message = ENV['FASTLANE_PROMPT_REMINDER_MESSAGE']
88
+ message = FastlaneCore::Shell::DEFAULT_PROMPT_REMINDER_MESSAGE if %w[default true yes 1].include?(message&.downcase)
89
+ delays = ENV['FASTLANE_PROMPT_REMINDER_DELAYS']&.split(',')&.map(&:to_i) || FastlaneCore::Shell::DEFAULT_PROMPT_REMINDER_DELAYS
90
+
91
+ FastlaneCore::UI.verbose("Monkey-patching the UI interactive methods to add a reminder (#{delays.inspect}, #{message.inspect})")
92
+ FastlaneCore::Shell.monkey_patch_interactive_prompts_with_reminder(after: delays, message: message)
93
+ end
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module Wpmreleasetoolkit
3
- VERSION = '2.0.0'
3
+ VERSION = '2.1.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-wpmreleasetoolkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lorenzo Mattei
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-20 00:00:00.000000000 Z
11
+ date: 2021-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: diffy
@@ -462,6 +462,7 @@ files:
462
462
  - lib/fastlane/plugin/wpmreleasetoolkit/helper/git_helper.rb
463
463
  - lib/fastlane/plugin/wpmreleasetoolkit/helper/github_helper.rb
464
464
  - lib/fastlane/plugin/wpmreleasetoolkit/helper/glotpress_helper.rb
465
+ - lib/fastlane/plugin/wpmreleasetoolkit/helper/interactive_prompt_reminder.rb
465
466
  - lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_adc_app_sizes_helper.rb
466
467
  - lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_git_helper.rb
467
468
  - lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_l10n_helper.rb