LoginSignup
0
0

More than 5 years have passed since last update.

Fastlane を使ってPush通知のpemファイルの有効期限が切れているアプリの情報をリストで出す

Posted at

表題通りのTIPS。
Fastlaneのソースコードを見れば分かるんだけどドキュメントに載って無くて面倒なのでメモ。

version

Fastlane 2.59.0

lane

これ。

Fastfile.rb
lane :fetch_should_update_pem_apps do
  rows = []
  index = 0
  Spaceship::Portal.login('YOUR_ID', 'YOUR_PW')
  Spaceship::Portal.select_team
  Spaceship::Portal.app.all.collect do |app|
    next if app.details.prod_push_enabled == true
    next if app.details.features['push'] == false
    p app.details.name
    p "> app.details.bundle_id: #{app.details.bundle_id}"
    p "> app.details.prod_push_enabled: #{app.details.prod_push_enabled}"
    p "> app.details.features[push]: #{app.details.features['push']}"
    p '------------'
    index += 1
    rows << [index, app.details.name, app.details.bundle_id]
  end
  table = Terminal::Table.new headings: %w[Index Target BI], rows: rows
  if rows.count != 0
    puts "\n #{table}".red
  end
end

説明

app.details.prod_push_enabled はPush通知のCertificateが設定されていないなどであればfalse
app.details.features['push'] はPush通知の設定がONであればtrue。
つまり、 Certificateが設定されていないけどPush設定がされてて、Push通知の送信をしたそうに見えるアプリ一覧が以下の様に出力されます。

 +-------+----------------------------------------------------------------------------+-------------------------------------------------------------------------+
| Index | Target                                                                     | BI                                                                      |
+-------+----------------------------------------------------------------------------+-------------------------------------------------------------------------+
| 1     | hogeho hogeh                                                               | ffff.f.f..f                                                |
| 2     | hogehoge                                                                   | your.host                                                         
| 3     | aaaaaaa                                                                    | your domain                                                          |

メモ

処理模索方法

spaceship exposes both the Apple Developer Center and the iTunes Connect API.

より、Spaeshipを使えば情報の一括取得が出来る。
必要な処理は、ソースコードとドキュメントを見ながら処理を模索できる。
今回のでいえば、

$ fastlane spaceship 
Username: XXXXXXXXXXXXXXXXXXXx
[1] pry(#<Spaceship::Playground>)> all_apps = Spaceship::Portal.app.all
The current user is in 41 teams. Pass a team ID or call `select_team` to choose a team. Using the first one for now.
=> [#<Spaceship::Portal::App:0x2345524e5768>,
 #<Spaceship::Portal::App:0x3fa26ef334fd4>,
...
[2] pry(#<Spaceship::Playground>)> app = Spaceship::Portal.app.find("me.aaaaa.fccccc")

な感じで、 Spaceship::Portal::App のObject1であることが分かる。
で、ドキュメントから安全そうなメソッドを呼びまくる。
すると、ファイル名がついてエラーがでる。

[3] pry(#<Spaceship::Playground>)> app.update_service
ArgumentError: wrong number of arguments (given 0, expected 1)
from /Users/hogehoge/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/fastlane-2.59.0/spaceship/lib/spaceship/portal/app.rb:156:in `update_service'

あとはそのソースコードを見れば何を隠し持ってるかすぐわかる。
この方法でファイル探しまくってるけど、ググった方が早そうであればググっても良いと思います。

Gemfileを利用している場合は

これが必要な場合がある。

gem 'pry'
gem 'rb-readline'

  1. RubyってObjectっていうんでいいんですかね? 

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0