fastlane-plugin-taiwan_number_one 0.2.0 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c476927219f7b1a3dcc7a6b5028143512ade17422dabd2068c1e17ed3694e9d3
4
- data.tar.gz: c68e731269bfaa3dbe968aa439bc3259d2dfde16967ad3b7ebfa190eae36369e
3
+ metadata.gz: 38998812e7cb61b9ab73987cd633e0a1a8eef8ef10b1ce12724316112e7ffc4f
4
+ data.tar.gz: 50a7d3caf5a59ced69c251792d8c5a6aa5d1f0710ec37d66dc5b16a424360e35
5
5
  SHA512:
6
- metadata.gz: bf4d2fc1e683b7f2d7c39cedea1952342a89aae659c40095310ea1b6ba7cf6dc93febcc861157431229271a5727ffc48e2647299154ca5a84e4ca21b38a8c319
7
- data.tar.gz: 6f8868bbdad6f94983f435816ecd3f8fef9475f90e87a3ece2f49584538655fa53f81d63b38159105a03eb30d655962958e823248e724b864261d4afe766fb02
6
+ metadata.gz: 2964c997b6f0e2b438f28ecae85f41d60e0bbb5dcf0019c983efc59b8003f14e5f5404fc45d32382b2703b27840869e9ccb3af9b566cabd9e618b68f6a2f9329
7
+ data.tar.gz: ef10e5896baeb418ea40dacac2ef93a8bc279a872d29816ae41058085bbe5ede053690e381cf1cf1d09466a2ffbd50f40256fff56ae2cfb1b483a818ff0e5a16
data/README.md CHANGED
@@ -12,7 +12,7 @@ fastlane add_plugin taiwan_number_one
12
12
 
13
13
  ## About taiwan_number_one
14
14
 
15
- To approve or reject if status is Pending Developer Release.
15
+ To approve or reject if status is `Pending Developer Release`, otherwise do nothing.
16
16
 
17
17
  #### This feature is requsted for a while:
18
18
 
@@ -33,10 +33,10 @@ https://github.com/fastlane/fastlane/issues/17539
33
33
 
34
34
  ## Usage
35
35
 
36
- ##### install plugin for fastlane
36
+ ##### Install plugin for fastlane
37
37
  [install instructions](https://docs.fastlane.tools/plugins/using-plugins/)
38
38
  ```
39
- bundle exce fastlane add_plugin taiwan_number_one
39
+ bundle exec fastlane add_plugin taiwan_number_one
40
40
  ```
41
41
  but I personally prefer adding plugin in `Gemfile` like this to avoid additional `Pluginfile` in ~'your_ios_project_dir'/fastlane
42
42
 
@@ -59,11 +59,23 @@ lane :release_decision do |options|
59
59
  taiwan_number_one(
60
60
  username: username,
61
61
  app_identifier: app_identifier,
62
- app_decision: options[:app_decision]
62
+ app_decision: options[:app_decision],
63
+ api_key: api_key
63
64
  )
64
65
  end
65
66
  ```
66
67
 
68
+ and this:
69
+ ```
70
+ desc "release App store version"
71
+ lane :release_app do
72
+ result = release_decision(app_decision: Fastlane::Actions::TaiwanNumberOneAction::DicisionType::RELEASE)
73
+ if result == Fastlane::Actions::TaiwanNumberOneAction::ActionResult::SUCCESS
74
+ # do your thing here!
75
+ end
76
+ end
77
+ ```
78
+
67
79
  or this:
68
80
  ```
69
81
  desc "reject App store version"
@@ -73,10 +85,7 @@ lane :reject_app do
73
85
  issuer_id: ENV["ISSUER_ID"],
74
86
  key_content: ENV["ASC_API_KEY"]
75
87
  )
76
- release_decision(
77
- app_decision: Fastlane::Actions::TaiwanNumberOneAction::DicisionType::REJECT,
78
- api_key: api_key
79
- )
88
+ release_decision(app_decision: Fastlane::Actions::TaiwanNumberOneAction::DicisionType::REJECT)
80
89
  end
81
90
  ```
82
91
 
@@ -126,6 +135,11 @@ team_name |The name of your App Store Connect team if you're in multiple tea
126
135
  api_key_path |Path to your App Store Connect API Key JSON file (https://docs.fastlane.tools/app-store-connect-api/#using-fastlane-api-key-json-file) |
127
136
  api_key |Your App Store Connect API Key information (https://docs.fastlane.tools/app-store-connect-api/#use-return-value-and-pass-in-as-an-option) |
128
137
 
138
+ ## Action Return
139
+ `Fastlane::Actions::TaiwanNumberOneAction::ActionResult::SUCCESS`
140
+ or
141
+ `Fastlane::Actions::TaiwanNumberOneAction::ActionResult::DO_NOTHING`
142
+
129
143
  ## Run tests for this plugin
130
144
 
131
145
  Not supported right now.
@@ -1,5 +1,4 @@
1
1
  require "fastlane/action"
2
- require "Spaceship"
3
2
  require_relative "../helper/taiwan_number_one_helper"
4
3
 
5
4
  module Fastlane
@@ -10,77 +9,98 @@ module Fastlane
10
9
  REJECT = "reject"
11
10
  end
12
11
 
13
- def self.run(params)
14
- params[:api_key] ||= Actions.lane_context[SharedValues::APP_STORE_CONNECT_API_KEY]
15
-
16
- app_id = params.fetch(:app_identifier)
17
- username = params.fetch(:username)
18
- unless app_id && username
19
- UI.message("Could not find app_id and username.")
20
- return
21
- end
12
+ module ActionResult
13
+ SUCCESS = "Success"
14
+ DO_NOTHING = "Nothing has changed"
15
+ end
22
16
 
23
- token = self.api_token(params)
24
- if token
25
- UI.message("Using App Store Connect API token...")
26
- Spaceship::ConnectAPI.token = token
27
- else
28
- UI.message("Login to App Store Connect (#{params[:username]})")
29
- Spaceship::ConnectAPI.login(
30
- params[:username],
31
- use_portal: false,
32
- use_tunes: true,
33
- tunes_team_id: params[:team_id],
34
- team_name: params[:team_name]
35
- )
36
- UI.message("Login successful")
37
- end
17
+ def self.run(params)
18
+ require 'spaceship'
19
+ begin
20
+ params[:api_key] ||= Actions.lane_context[SharedValues::APP_STORE_CONNECT_API_KEY]
38
21
 
39
- app = Spaceship::ConnectAPI::App.find(app_id)
40
- version = app.get_app_store_versions.first
41
- UI.message("app_store_state is #{version.app_store_state}")
42
- client ||= Spaceship::ConnectAPI
43
- platform ||= Spaceship::ConnectAPI::Platform::IOS
44
- filter = {
45
- appStoreState: [
46
- Spaceship::ConnectAPI::AppStoreVersion::AppStoreState::PENDING_DEVELOPER_RELEASE
47
- ].join(","),
48
- platform: platform
49
- }
50
- app_store_version = app.get_app_store_versions(client: client, filter: filter, includes: "appStoreVersionSubmission")
51
- .sort_by { |v| Gem::Version.new(v.version_string) }
52
- .last
53
- if app_store_version
54
- version_string = app_store_version.version_string
55
- state = app_store_version.app_store_state
56
- UI.message("version #{version_string} is #{state}")
57
- unless state == Spaceship::ConnectAPI::AppStoreVersion::AppStoreState::PENDING_DEVELOPER_RELEASE
58
- UI.message("AppStoreState is not PENDING_DEVELOPER_RELEASE")
22
+ app_id = params.fetch(:app_identifier)
23
+ username = params.fetch(:username)
24
+ unless app_id && username
25
+ UI.message("Could not find app_id and username.")
59
26
  return
60
27
  end
61
- decision = params[:app_decision]
62
- decision ||= fetch_decision
63
- case decision
64
- when DicisionType::RELEASE
65
- UI.message("decision is release")
66
- release_version_if_possible(app: app, app_store_version: app_store_version)
67
- when DicisionType::REJECT
68
- UI.message("decision is reject")
69
- reject_version_if_possible(app: app, app_store_version: app_store_version)
28
+
29
+ token = self.api_token(params)
30
+ if token
31
+ UI.message("Using App Store Connect API token...")
32
+ Spaceship::ConnectAPI.token = token
33
+ else
34
+ UI.message("Login to App Store Connect (#{params[:username]})")
35
+ Spaceship::ConnectAPI.login(
36
+ params[:username],
37
+ use_portal: false,
38
+ use_tunes: true,
39
+ tunes_team_id: params[:team_id],
40
+ team_name: params[:team_name]
41
+ )
42
+ UI.message("Login successful")
43
+ end
44
+
45
+ app = Spaceship::ConnectAPI::App.find(app_id)
46
+ version = app.get_app_store_versions.first
47
+ UI.message("app_store_state is #{version.app_store_state}")
48
+ client ||= Spaceship::ConnectAPI
49
+ platform ||= Spaceship::ConnectAPI::Platform::IOS
50
+ filter = {
51
+ appStoreState: [
52
+ Spaceship::ConnectAPI::AppStoreVersion::AppStoreState::PENDING_DEVELOPER_RELEASE
53
+ ].join(","),
54
+ platform: platform
55
+ }
56
+ app_store_version = app.get_app_store_versions(client: client, filter: filter, includes: "appStoreVersionSubmission")
57
+ .sort_by { |v| Gem::Version.new(v.version_string) }
58
+ .last
59
+ if app_store_version
60
+ version_string = app_store_version.version_string
61
+ state = app_store_version.app_store_state
62
+ UI.message("version #{version_string} is #{state}")
63
+ unless state == Spaceship::ConnectAPI::AppStoreVersion::AppStoreState::PENDING_DEVELOPER_RELEASE
64
+ UI.message("AppStoreState is not PENDING_DEVELOPER_RELEASE")
65
+ UI.message("🇹🇼 Taiwan helps you do nothing!")
66
+ return
67
+ end
68
+ decision ||= fetch_decision(params)
69
+
70
+ result = ActionResult::DO_NOTHING
71
+ case decision
72
+ when DicisionType::RELEASE
73
+ UI.message("decision is release")
74
+ result = release_version_if_possible(app: app, app_store_version: app_store_version)
75
+ when DicisionType::REJECT
76
+ UI.message("decision is reject")
77
+ result = reject_version_if_possible(app: app, app_store_version: app_store_version)
78
+ else
79
+ UI.user_error!("App's decision must be release or reject")
80
+ result = ActionResult::DO_NOTHING
81
+ end
82
+
83
+ UI.message("The taiwan_number_one plugin action is finished!")
84
+ UI.message("🇹🇼 Taiwan can help!")
85
+ return result
70
86
  else
71
- decision ||= fetch_decision
87
+ UI.message("no pending release version exist.")
88
+ UI.message("The taiwan_number_one plugin action is finished!")
89
+ UI.message("🇹🇼 Taiwan can help!")
90
+ return ActionResult::DO_NOTHING
72
91
  end
73
- else
74
- UI.message("no pending release version exist.")
92
+ rescue => error
93
+ UI.message("🇹🇼 Taiwan might not be able to help you with this...")
94
+ UI.user_error!("The taiwan_number_one plugin action is finished with error: #{error.message}!")
95
+ return ActionResult::DO_NOTHING
75
96
  end
76
- UI.message("The taiwan_number_one plugin action is finished!")
77
97
  end
78
98
 
79
- def self.fetch_decision
80
- decision = nil
99
+ def self.fetch_decision(params)
100
+ decision = params[:app_decision]
81
101
  until ["release", "reject"].include?(decision)
82
- decision = UI.input("Please enter the app's release decision (release, reject): ")
83
- UI.message("App's decision must be release or reject")
102
+ UI.user_error!("App's decision must be release or reject.")
103
+ return
84
104
  end
85
105
  # return decision
86
106
  UI.message("return type #{decision}")
@@ -94,26 +114,31 @@ module Fastlane
94
114
  def self.release_version_if_possible(app: nil, app_store_version: Spaceship::ConnectAPI::AppStoreVersion)
95
115
  unless app
96
116
  UI.user_error!("Could not find app with bundle identifier '#{params[:app_identifier]}' on account #{params[:username]}")
117
+ return ActionResult::DO_NOTHING
97
118
  end
98
119
 
99
120
  begin
100
121
  app_store_version.create_app_store_version_release_request
101
122
  UI.message("release version #{app_store_version.version_string} successfully!")
123
+ return ActionResult::SUCCESS
102
124
  rescue => e
103
- UI.user_error!("An error occurred while releasing version #{app_store_version}")
104
- UI.error("#{e.message}\n#{e.backtrace.join("\n")}") if FastlaneCore::Globals.verbose?
125
+ UI.user_error!("An error occurred while releasing version #{app_store_version}, #{e.message}\n#{e.backtrace.join("\n")}")
126
+ return ActionResult::DO_NOTHING
105
127
  end
106
128
  end
107
129
 
108
130
  def self.reject_version_if_possible(app: nil, app_store_version: Spaceship::ConnectAPI::AppStoreVersion)
109
131
  unless app
110
132
  UI.user_error!("Could not find app with bundle identifier '#{params[:app_identifier]}' on account #{params[:username]}")
133
+ return ActionResult::DO_NOTHING
111
134
  end
112
135
 
113
136
  if app_store_version.reject!
114
137
  UI.success("rejected version #{app_store_version.version_string} Successfully!")
138
+ return ActionResult::SUCCESS
115
139
  else
116
140
  UI.user_error!("An error occurred while rejected version #{app_store_version}")
141
+ return ActionResult::DO_NOTHING
117
142
  end
118
143
  end
119
144
 
@@ -133,14 +158,20 @@ module Fastlane
133
158
  end
134
159
 
135
160
  def self.return_value
136
- # If your method provides a return value, you can describe here what it does
161
+ return "'Success' if action passes, else, 'Nothing has changed'"
137
162
  end
138
163
 
139
164
  def self.details
140
- # Optional:
141
165
  "use fastlane to release or reject reviewed version"
142
166
  end
143
167
 
168
+ def self.output
169
+ [
170
+ [ActionResult::SUCCESS, 'Successfully release or reject.'],
171
+ [ActionResult::DO_NOTHING, 'Do nothing.']
172
+ ]
173
+ end
174
+
144
175
  def self.available_options
145
176
  user = CredentialsManager::AppfileConfig.try_fetch_value(:itunes_connect_id)
146
177
  user ||= CredentialsManager::AppfileConfig.try_fetch_value(:apple_id)
@@ -218,7 +249,7 @@ module Fastlane
218
249
  [
219
250
  'taiwan_number_one(
220
251
  app_decision: "release",
221
- api_key: "api_key" # your app_store_connect_api_key
252
+ api_key: "api_key" # your app_store_connect_api_key
222
253
  )'
223
254
  ]
224
255
  end
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module TaiwanNumberOne
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.5"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-taiwan_number_one
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - andrew54068
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-22 00:00:00.000000000 Z
11
+ date: 2021-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry