fastlane-plugin-ipa_info 0.5.0 → 0.8.2

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: a177420149a8dc188416e4c618551a9a114d9115824a294dbc09bec18650d4fa
4
- data.tar.gz: d850c8413099d685eec3d782a5bbb95611cdf1ebf808b1aa8b361a58e4133123
3
+ metadata.gz: 01742d4f12328334684ce676dd4d347a8728c00d66cbdb5868cd493a275d0947
4
+ data.tar.gz: 95ef95fa5b756e0b4242c608eb1d467aed2525a2379b5597b8bb89b13a7a91b6
5
5
  SHA512:
6
- metadata.gz: 1730872be8e7ecf0ff66f51ddd0ef445b22ddbf368729f0116d079637319518ec0b9e7e165c507be678c8a722bf9501ecae75d02709e003385322bc09c607704
7
- data.tar.gz: 3e8c1737e343fa7865de72d9ba1be0688c8e046b42bb083a503904b37e632d4f1e92fb35970a9d8b9218718b3b947b43a4297e2d2b26323c2b07a035f044e1d4
6
+ metadata.gz: 8e54eebcf53a0885e570df99541156fd3dc43549abfca176879a96c7e8ad13903890db463aae1f6d0ded0e95cfe155b6a1b83e5b1cc0441b9253842543882791
7
+ data.tar.gz: 95aedea9818581710484f8d3cece34c54d7390ad1d37b1803768c64fc1dbaaf51c26d6fbb35968d2ebf0d9da45fab3fd2492355691dd506d74905ee6a84014ef
data/README.md CHANGED
@@ -11,8 +11,7 @@ fastlane add_plugin ipa_info
11
11
  ```
12
12
 
13
13
  ## About ipa_info
14
-
15
- show information of the info.plist file in the ipa file.
14
+ show the Provisioning Profile and Certificate information in the ipa file.
16
15
 
17
16
  ## Action
18
17
 
@@ -22,6 +21,14 @@ ipa_info(
22
21
  )
23
22
  ```
24
23
 
24
+
25
+ ```
26
+ ipa_info(
27
+ ipa_file: ${your_ipa_file_path},
28
+ add_extract_info_plist_params: [[ "CFBundleIdentifier", "BundleIdentifier" ]]
29
+ )
30
+ ```
31
+
25
32
  ```
26
33
  lane :build do
27
34
  gym
@@ -48,6 +55,9 @@ end
48
55
  ```
49
56
 
50
57
  ### Example Result
58
+ Info.plist Information is optional.
59
+
60
+ When use add_extract_info_plist_params, display Info.plist Information.
51
61
 
52
62
  ```
53
63
  +------------+-----------------------------------+
@@ -70,6 +80,14 @@ end
70
80
  | BuildVersion | 37 |
71
81
  +--------------+-------+
72
82
 
83
+ +------------------+------------------------------------+
84
+ | Info.plist Information |
85
+ +------------------+------------------------------------+
86
+ | Name | Value |
87
+ +------------------+------------------------------------+
88
+ | BundleIdentifier | com.example.tarappo |
89
+ +------------------+------------------------------------+
90
+
73
91
  +-------------------------+---------------------------+
74
92
  | Mobile Provision |
75
93
  +-------------------------+---------------------------+
@@ -80,8 +98,31 @@ end
80
98
  | ExpirationDate | 2019-03-08T00:11:53+00:00 |
81
99
  | DeadLine | 230 day |
82
100
  +-------------------------+---------------------------+
101
+
102
+ +------------+-------+
103
+ | Certificate |
104
+ +------------+-------+
105
+ | Name | Value |
106
+ +------------+-------+
107
+ | CodeSigned | true |
108
+ +------------+-------+
83
109
  ```
84
110
 
111
+ ### Environment
112
+ All values are set in environment variables.
113
+
114
+ - FL_XCODE
115
+ - FL_XCODEBUILD
116
+ - FL_MACOS
117
+ - FL_BUNDLENAME
118
+ - FL_VERSION
119
+ - FL_BUILDVERSION
120
+ - FL_TEAMNAME
121
+ - FL_PROVISIONINGPROFILENAME
122
+ - FL_COUNT_DAY
123
+ - FL_CODESIGNED
124
+
125
+
85
126
  ## Run tests for this plugin
86
127
 
87
128
  To run both the tests, and code style validation, run
@@ -20,10 +20,22 @@ module Fastlane
20
20
  summary_table = Helper::IpaInfoHelper.summary_table(title: "ipa Information", rows: rows)
21
21
  puts(summary_table)
22
22
 
23
- # certificate info
24
- rows = Helper::IpaInfoHelper.certificate_information(provision_info_result: info_result[:provisiong_info])
23
+ # show customize info extract Info.plist
24
+ unless params[:add_extract_info_plist_params].empty?
25
+ rows = Helper::IpaInfoHelper.customize_information(ipa_info_result: info_result[:plist_info], add_extract_info_plist_params: params[:add_extract_info_plist_params])
26
+ summary_table = Helper::IpaInfoHelper.summary_table(title: "Info.plist Information", rows: rows)
27
+ puts(summary_table)
28
+ end
29
+
30
+ # mobile provisioning info
31
+ rows = Helper::IpaInfoHelper.mobileprovisioning_information(provision_info_result: info_result[:provisiong_info])
25
32
  summary_table = Helper::IpaInfoHelper.summary_table(title: "Mobile Provision", rows: rows)
26
33
  puts(summary_table)
34
+
35
+ # certificate info
36
+ rows = Helper::IpaInfoHelper.certificate_information(certificate_info_result: info_result[:certificate_info])
37
+ summary_table = Helper::IpaInfoHelper.summary_table(title: "Certificate", rows: rows)
38
+ puts(summary_table)
27
39
  end
28
40
 
29
41
  def self.description
@@ -50,7 +62,13 @@ module Fastlane
50
62
  optional: true,
51
63
  verify_block: proc do |value|
52
64
  raise "Couldn't find ipa file".red unless File.exist?(value)
53
- end)
65
+ end),
66
+ FastlaneCore::ConfigItem.new(key: :add_extract_info_plist_params,
67
+ env_name: 'ADD_EXTRACT_INFO_PLIST_PARAMS',
68
+ description: 'extract customize params for Info.plist. ',
69
+ default_value: [],
70
+ is_string: false,
71
+ optional: true)
54
72
  ]
55
73
  end
56
74
 
@@ -1,40 +1,30 @@
1
1
  require 'tempfile'
2
- require 'zip'
3
- require 'zip/filesystem'
2
+ require 'tmpdir'
3
+ require 'fileutils'
4
4
  require 'plist'
5
+ require 'open3'
5
6
  require 'fastlane_core/ui/ui'
7
+ require "securerandom"
6
8
 
7
9
  module Fastlane
8
10
  module Helper
9
11
  class IpaAnalyzeHelper
10
12
  def self.analyze(ipa_path)
11
- ipa_zipfile = Zip::File.open(ipa_path)
12
- app_folder_path = find_app_folder_path_in_ipa(ipa_path)
13
- ipa_zipfile.close
14
-
15
- # path
16
- mobileprovision_entry = ipa_zipfile.find_entry("#{app_folder_path}/embedded.mobileprovision")
17
- UI.user_error!("mobileprovision not found in #{ipa_path}") unless mobileprovision_entry
18
- info_plist_entry = ipa_zipfile.find_entry("#{app_folder_path}/Info.plist")
19
- UI.user_error!("Info.plist not found in #{ipa_path}") unless info_plist_entry
20
-
21
13
  return {
22
- provisiong_info: self.analyze_mobileprovisioning(mobileprovision_entry, ipa_zipfile),
23
- plist_info: self.analyze_info_plist(info_plist_entry, ipa_zipfile)
14
+ provisiong_info: self.analyze_file_with_unzip(ipa_path, "embedded.mobileprovision"),
15
+ plist_info: self.analyze_file_with_unzip(ipa_path, "Info.plist"),
16
+ certificate_info: analyze_file_with_unzip(ipa_path, "")
24
17
  }
25
18
  end
26
19
 
27
20
  # Info plist
28
- def self.analyze_info_plist(info_plist_entry, ipa_zipfile)
21
+ def self.analyze_info_plist(tempfile)
29
22
  result = {}
30
23
 
31
- tempfile = Tempfile.new(::File.basename(info_plist_entry.name))
32
24
  begin
33
- ipa_zipfile.extract(info_plist_entry, tempfile.path) { true }
34
- UI.user_error!("Failed to convert binary Plist to XML") unless system("plutil -convert xml1 '#{tempfile.path}'")
35
-
36
- plist = Plist.parse_xml(tempfile.path)
25
+ UI.user_error!("Failed to convert binary Plist to XML") unless system("plutil -convert xml1 '#{tempfile}'")
37
26
 
27
+ plist = Plist.parse_xml(tempfile)
38
28
  plist.each do |key, value|
39
29
  parse_value = value.class == Hash || value.class == Array ? value : value.to_s
40
30
 
@@ -43,21 +33,19 @@ module Fastlane
43
33
  rescue StandardError => e
44
34
  UI.user_error!(e.message)
45
35
  ensure
46
- tempfile.close && tempfile.unlink
36
+ FileUtils.rm_r(tempfile)
47
37
  end
48
- return result
38
+
39
+ result
49
40
  end
50
41
 
51
42
  # mobileprovisioning
52
- def self.analyze_mobileprovisioning(mobileprovision_entry, ipa_zipfile)
43
+ def self.analyze_mobileprovisioning(tempfile)
53
44
  result = {}
54
45
 
55
- tempfile = Tempfile.new(::File.basename(mobileprovision_entry.name))
56
46
  begin
57
- ipa_zipfile.extract(mobileprovision_entry, tempfile.path) { true }
58
- plist = Plist.parse_xml(`security cms -D -i #{tempfile.path}`)
59
-
60
- plist.each do |key, value|
47
+ mobileprovisioning = Plist.parse_xml(`security cms -D -i #{tempfile}`)
48
+ mobileprovisioning.each do |key, value|
61
49
  next if key == 'DeveloperCertificates'
62
50
 
63
51
  parse_value = value.class == Hash || value.class == Array ? value : value.to_s
@@ -67,14 +55,66 @@ module Fastlane
67
55
  rescue StandardError => e
68
56
  UI.user_error!(e.message)
69
57
  ensure
70
- tempfile.close && tempfile.unlink
58
+ FileUtils.rm_r(tempfile)
71
59
  end
60
+
61
+ result
62
+ end
63
+
64
+ # certificate
65
+ def self.codesigned(temp_file_path)
66
+ result = {}
67
+
68
+ cmd = "codesign -dv #{temp_file_path}"
69
+ _stdout, stderr, _status = Open3.capture3(cmd)
70
+ codesigned_flag = stderr.include?("Signed Time")
71
+ result["CodeSigned"] = codesigned_flag
72
+
72
73
  return result
73
74
  end
74
75
 
76
+ # unzip ipa file and analyze file
77
+ def self.analyze_file_with_unzip(ipa_path, target_file_name)
78
+ tempdir = Dir.pwd + "/tmp-#{SecureRandom.hex(10)}"
79
+ target_file_path = find_app_folder_path_in_ipa(ipa_path) + "/#{target_file_name}"
80
+ temp_file_path = "#{tempdir}/#{target_file_name}"
81
+
82
+ begin
83
+ _, error, = Open3.capture3("unzip -o -d #{tempdir} #{ipa_path}")
84
+ UI.user_error!(error) unless error.empty?
85
+
86
+ copy_cmd = "#{tempdir}/#{target_file_path} #{temp_file_path}"
87
+
88
+ case target_file_name
89
+ when "Info.plist" then
90
+ self.copy_file(copy_cmd)
91
+ return self.analyze_info_plist(temp_file_path)
92
+ when "embedded.mobileprovision" then
93
+ self.copy_file(copy_cmd)
94
+ return self.analyze_mobileprovisioning(temp_file_path)
95
+ when "" then
96
+ return self.codesigned(target_file_path)
97
+ end
98
+ rescue StandardError => e
99
+ FileUtils.rm_r(tempdir)
100
+ UI.user_error!(e.message)
101
+ ensure
102
+ FileUtils.rm_r(tempdir)
103
+ end
104
+
105
+ return nil
106
+ end
107
+
108
+ # copy
109
+ def self.copy_file(cmd)
110
+ cmd = "cp #{cmd}"
111
+ _, error, = Open3.capture3(cmd)
112
+ UI.user_error!(error) unless error.empty?
113
+ end
114
+
75
115
  # return app folder path
76
116
  def self.find_app_folder_path_in_ipa(ipa_path)
77
- return "Payload/#{File.basename(ipa_path, File.extname(ipa_path))}.app"
117
+ return "Payload/*.app"
78
118
  end
79
119
 
80
120
  private_class_method :find_app_folder_path_in_ipa
@@ -1,4 +1,5 @@
1
1
  require 'fastlane_core/ui/ui'
2
+ require 'mac_ios_info'
2
3
 
3
4
  module Fastlane
4
5
  module Helper
@@ -6,8 +7,10 @@ module Fastlane
6
7
  # build environment
7
8
  def self.build_environment_information(ipa_info_result:)
8
9
  rows = []
9
- [%w[DTXcode Xcode],
10
- %w[DTXcodeBuild XcodeBuild]].each do |key, name|
10
+ list = [%w[DTXcode Xcode],
11
+ %w[DTXcodeBuild XcodeBuild]]
12
+
13
+ list.each do |key, name|
11
14
  ENV["FL_#{name.upcase}"] = ipa_info_result[key]
12
15
  rows << [name, ipa_info_result[key]]
13
16
  end
@@ -16,8 +19,8 @@ module Fastlane
16
19
  [%w[BuildMachineOSBuild MacOS]].each do |key, name|
17
20
  mac_os_build = ipa_info_result[key]
18
21
 
19
- mac_os_version = self.macos_build_to_macos_version(build: mac_os_build)
20
- mac_os_name = self.macos_version_to_os_name(version: mac_os_version)
22
+ mac_os_version = MacIosInfo.macos_build_to_macos_version(build_number: mac_os_build)
23
+ mac_os_name = MacIosInfo.macos_version_to_os_name(version: mac_os_version)
21
24
  rows << [name, "#{mac_os_name} #{mac_os_version} (#{mac_os_build})"]
22
25
  end
23
26
 
@@ -27,9 +30,13 @@ module Fastlane
27
30
  # ipa info
28
31
  def self.ipa_information(ipa_info_result:)
29
32
  rows = []
30
- [%w[CFBundleName BundleName],
31
- %w[CFBundleShortVersionString Version],
32
- %w[CFBundleVersion BuildVersion]].each do |key, name|
33
+ list = [%w[CFBundleName BundleName],
34
+ %w[CFBundleShortVersionString Version],
35
+ %w[CFBundleVersion BuildVersion]]
36
+
37
+ list.each do |key, name|
38
+ next if key.nil?
39
+ next if ipa_info_result[key].nil?
33
40
  ENV["FL_#{name.upcase}"] = ipa_info_result[key]
34
41
 
35
42
  rows << [name, ipa_info_result[key]]
@@ -38,10 +45,41 @@ module Fastlane
38
45
  rows
39
46
  end
40
47
 
41
- def self.certificate_information(provision_info_result:)
48
+ # customize info
49
+ # @param add_extract_info_plist_params Info.plist key and display name
50
+ # example: [[ "CFBundleIdentifier", "BundleIdentifier" ]]
51
+ def self.customize_information(ipa_info_result:, add_extract_info_plist_params: nil)
52
+ rows = []
53
+
54
+ add_extract_info_plist_params.each do |key, name|
55
+ next if key.nil?
56
+ next if ipa_info_result[key].nil?
57
+ ENV["FL_#{name.upcase}"] = ipa_info_result[key]
58
+
59
+ rows << [name, ipa_info_result[key]]
60
+ end
61
+
62
+ rows
63
+ end
64
+
65
+ # certificate info
66
+ def self.certificate_information(certificate_info_result:)
67
+ rows = []
68
+ [%w[CodeSigned CodeSigned]].each do |key, name|
69
+ ENV["FL_#{name.upcase}"] = certificate_info_result[key].to_s
70
+
71
+ rows << [name, certificate_info_result[key].to_s]
72
+ end
73
+
74
+ rows
75
+ end
76
+
77
+ # mobileprovisioning info
78
+ def self.mobileprovisioning_information(provision_info_result:)
42
79
  rows = []
43
80
  [%w[TeamName TeamName],
44
81
  %w[Name ProvisioningProfileName]].each do |key, name|
82
+ ENV["FL_#{name.upcase}"] = provision_info_result[key]
45
83
  rows << [name, provision_info_result[key]]
46
84
  end
47
85
 
@@ -51,6 +89,9 @@ module Fastlane
51
89
  expire_date = Date.parse(provision_info_result[key].to_s)
52
90
  count_day = (expire_date - today).numerator
53
91
 
92
+ ENV["FL_#{name.upcase}"] = provision_info_result[key]
93
+ ENV["FL_COUNT_DAY"] = count_day.to_s
94
+
54
95
  rows << [name, provision_info_result[key]]
55
96
  rows << ["DeadLine", "#{count_day} day"]
56
97
  end
@@ -58,73 +99,7 @@ module Fastlane
58
99
  rows
59
100
  end
60
101
 
61
- # macOS build number to macOS version
62
- # @return macOS version(High Sierra or higher)
63
- def self.macos_build_to_macos_version(build:)
64
- case build
65
- # macOS Catalina
66
- when "19E266" then
67
- "10.15.4"
68
- when "19D76" then
69
- "10.15.3"
70
- when "19C57" then
71
- "10.15.2"
72
- when "19B88" then
73
- "10.15.1"
74
- when "19A583", "19A602", "19A603" then
75
- "10.15"
76
- # macOS Mojave
77
- when "18G84", "18G103", "18G1012", "18G95" then
78
- "10.14.6"
79
- when "18F132", "18F203" then
80
- "10.14.5"
81
- when "18E226", "18E227" then
82
- "10.14.4"
83
- when "18D42", "18D43", "18D109" then
84
- "10.14.3"
85
- when "18C54" then
86
- "10.14.2"
87
- when "18B75", "18B2107", "18B3094" then
88
- "10.14.1"
89
- when "18A391" then
90
- "10.14"
91
- # macOS High Sierra
92
- when "17G65", "17G6029" then
93
- "10.13.6"
94
- when "17F77" then
95
- "10.13.5"
96
- when "17E199", "17E201", "17E202" then
97
- "10.13.4"
98
- when "17D47", "17D102", "17D2047", "17D2102" then
99
- "10.13.3"
100
- when "17C88", "17C89", "17C205", "17C2205" then
101
- "10.13.2"
102
- when "17B48", "17B1002", "17B1003" then
103
- "10.13.1"
104
- when "17A365", "17A405" then
105
- "10.13"
106
- else
107
- "UnKnown"
108
- end
109
- end
110
-
111
- def self.macos_version_to_os_name(version:)
112
- minor_version = version.split(".")[1].to_i
113
- # reference https://support.apple.com/ja-jp/HT201260
114
- case minor_version
115
- when 15
116
- "macOS Catalina"
117
- when 14
118
- "macOS Mojave"
119
- when 13
120
- "macOS High Sierra"
121
- when 12
122
- "macOS Sierra"
123
- else
124
- "UnKnown"
125
- end
126
- end
127
-
102
+ # create summary table
128
103
  def self.summary_table(title:, rows:)
129
104
  Terminal::Table.new(
130
105
  title: title,
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module IpaInfo
3
- VERSION = "0.5.0"
3
+ VERSION = "0.8.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,55 +1,49 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-ipa_info
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - tarappo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-02 00:00:00.000000000 Z
11
+ date: 2021-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: plist
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '3.1'
20
17
  - - ">="
21
18
  - !ruby/object:Gem::Version
22
19
  version: 3.1.0
20
+ - - "~>"
21
+ - !ruby/object:Gem::Version
22
+ version: '3.1'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - "~>"
28
- - !ruby/object:Gem::Version
29
- version: '3.1'
30
27
  - - ">="
31
28
  - !ruby/object:Gem::Version
32
29
  version: 3.1.0
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '3.1'
33
33
  - !ruby/object:Gem::Dependency
34
- name: rubyzip
34
+ name: mac_ios_info
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - "~>"
38
- - !ruby/object:Gem::Version
39
- version: '1.1'
40
37
  - - ">="
41
38
  - !ruby/object:Gem::Version
42
- version: 1.1.7
39
+ version: '0'
43
40
  type: :runtime
44
41
  prerelease: false
45
42
  version_requirements: !ruby/object:Gem::Requirement
46
43
  requirements:
47
- - - "~>"
48
- - !ruby/object:Gem::Version
49
- version: '1.1'
50
44
  - - ">="
51
45
  - !ruby/object:Gem::Version
52
- version: 1.1.7
46
+ version: '0'
53
47
  - !ruby/object:Gem::Dependency
54
48
  name: pry
55
49
  requirement: !ruby/object:Gem::Requirement
@@ -208,8 +202,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
208
202
  - !ruby/object:Gem::Version
209
203
  version: '0'
210
204
  requirements: []
211
- rubyforge_project:
212
- rubygems_version: 2.7.6
205
+ rubygems_version: 3.0.3
213
206
  signing_key:
214
207
  specification_version: 4
215
208
  summary: show ipa info