fastlane-plugin-ipa_info 0.6.0 → 0.7.0

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: 477ddb7083b35228565294f91a6663f8a28bb6be9c12d9c388385e09479a78c3
4
- data.tar.gz: 30c246417a944bf11deaad3bf1154822179cd4cb7a4499ce4bad037c412d5d9e
3
+ metadata.gz: b1f62b0d7e6c8bdd7c5cc220230db3b89e1ff4db74b7f0d6d9bb04e5960152a7
4
+ data.tar.gz: b9fcbdbc8ce50d2cb634f2068b1dea22a79331595242a476ccf199894c046ce9
5
5
  SHA512:
6
- metadata.gz: decf9c25b01271d3dd0f5908c4f11f3ab3443dcd82c93a523291916b77de18f94790d616471e579962bd59949d5e52852040de6b91510a44eaba56e35f532050
7
- data.tar.gz: 2598004e5d4c87742065854f45a0848599f632449e616453601c8b7a97d192fc116401a75c3dfeed25fabe2b1c0f931223e16e934439fc5b602773a3a7074ead
6
+ metadata.gz: 994167e35df5b86846550df1eab3e6ec4d521ec3abfeb980bbbdf42852ea7a180a61166ffaa9b0de5049b13ec1a121fb3db66fa14c8fc1e2108efd3795207ca2
7
+ data.tar.gz: 1d1f284971cb79cb423952226d321d0edc6beb7c26f25cad1d3a1389010cce8503222096ade8186a5daece3deb7232e06f1ac4fb482cfe8ea798e1dfd131f05e
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,6 +20,13 @@ module Fastlane
20
20
  summary_table = Helper::IpaInfoHelper.summary_table(title: "ipa Information", rows: rows)
21
21
  puts(summary_table)
22
22
 
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
+
23
30
  # mobile provisioning info
24
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)
@@ -55,7 +62,13 @@ module Fastlane
55
62
  optional: true,
56
63
  verify_block: proc do |value|
57
64
  raise "Couldn't find ipa file".red unless File.exist?(value)
58
- 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)
59
72
  ]
60
73
  end
61
74
 
@@ -86,7 +86,7 @@ module Fastlane
86
86
  entry_first.extract(tempdir + "/" + entry_first.name) { true }
87
87
  end
88
88
 
89
- app_path = tempdir + "/Payload/ios.app"
89
+ app_path = tempdir + "/Payload/*.app"
90
90
  cmd = "codesign -dv #{app_path}"
91
91
  _stdout, stderr, _status = Open3.capture3(cmd)
92
92
  codesigned_flag = stderr.include?("Signed Time")
@@ -0,0 +1,124 @@
1
+ require 'tempfile'
2
+ require 'tmpdir'
3
+ require 'zip'
4
+ require 'zip/filesystem'
5
+ require 'fileutils'
6
+ require 'plist'
7
+ require 'open3'
8
+ require 'fastlane_core/ui/ui'
9
+
10
+ module Fastlane
11
+ module Helper
12
+ class IpaAnalyzeHelper2
13
+ def self.analyze(ipa_path)
14
+ app_folder_path = find_app_folder_path_in_ipa(ipa_path)
15
+ plist_data = self.fetch_file_with_unzip(ipa_path, "#{app_folder_path}/Info.plist")
16
+ mobileprovisioning_data = self.fetch_file_with_unzip(ipa_path, "#{app_folder_path}/embedded.mobileprovision")
17
+
18
+ return {
19
+ provisiong_info: self.analyze_mobileprovisioning(mobileprovisioning_data),
20
+ plist_info: self.analyze_info_plist(plist_data),
21
+ certificate_info: self.codesigned(ipa_path, app_folder_path)
22
+ }
23
+ end
24
+
25
+ # Info plist
26
+ def self.analyze_info_plist(data)
27
+ tempfile = Tempfile.new(::File.basename("info_plist"))
28
+ result = {}
29
+
30
+ begin
31
+ File.open(tempfile.path, 'w') do |output|
32
+ output.puts(data)
33
+ end
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)
37
+ plist.each do |key, value|
38
+ parse_value = value.class == Hash || value.class == Array ? value : value.to_s
39
+
40
+ result[key] = parse_value
41
+ end
42
+ rescue StandardError => e
43
+ UI.user_error!(e.message)
44
+ ensure
45
+ tempfile.close && tempfile.unlink
46
+ end
47
+
48
+ result
49
+ end
50
+
51
+ # mobileprovisioning
52
+ def self.analyze_mobileprovisioning(data)
53
+ tempfile = Tempfile.new(::File.basename("mobile_provisioning"))
54
+ result = {}
55
+
56
+ begin
57
+ File.open(tempfile.path, 'w') do |output|
58
+ output.puts(data)
59
+ end
60
+ mobileprovisioning = Plist.parse_xml(`security cms -D -i #{tempfile.path}`)
61
+ mobileprovisioning.each do |key, value|
62
+ next if key == 'DeveloperCertificates'
63
+
64
+ parse_value = value.class == Hash || value.class == Array ? value : value.to_s
65
+
66
+ result[key] = parse_value
67
+ end
68
+ rescue StandardError => e
69
+ UI.user_error!(e.message)
70
+ ensure
71
+ tempfile.close && tempfile.unlink
72
+ end
73
+
74
+ result
75
+ end
76
+
77
+ # certificate
78
+ def self.codesigned(ipa_path, app_folder_path)
79
+ tempdir = Dir.pwd + "/tmp"
80
+ result = {}
81
+
82
+ begin
83
+ data, error, = Open3.capture3("unzip -d #{tempdir} #{ipa_path}")
84
+
85
+ cmd = "codesign -dv #{tempdir}/#{app_folder_path}"
86
+ _stdout, stderr, _status = Open3.capture3(cmd)
87
+ codesigned_flag = stderr.include?("Signed Time")
88
+ result["CodeSigned"] = codesigned_flag
89
+ rescue StandardError => e
90
+ UI.user_error!(e.message)
91
+ ensure
92
+ FileUtils.rm_r(tempdir)
93
+ end
94
+
95
+ return result
96
+ end
97
+
98
+ # extract file
99
+ def self.fetch_file_with_unzip(path, target_file)
100
+ list, error, = Open3.capture3("unzip", "-Z", "-1", path)
101
+ UI.user_error!(error) unless error.empty?
102
+
103
+ return nil if list.empty?
104
+ entry = list.chomp.split("\n").find do |e|
105
+ File.fnmatch(target_file, e, File::FNM_PATHNAME)
106
+ end
107
+
108
+ data, error, = Open3.capture3("unzip", "-p", path, entry)
109
+ UI.user_error!(error) unless error.empty?
110
+ UI.user_error!("not exits data for #{target_file}") if data.empty?
111
+
112
+ data
113
+ end
114
+
115
+ private
116
+
117
+ # return app folder path
118
+ def self.find_app_folder_path_in_ipa(ipa_path)
119
+ return "Payload/#{File.basename(ipa_path, File.extname(ipa_path))}.app"
120
+ end
121
+
122
+ end
123
+ end
124
+ end
@@ -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,30 @@ 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?
40
+ ENV["FL_#{name.upcase}"] = ipa_info_result[key]
41
+
42
+ rows << [name, ipa_info_result[key]]
43
+ end
44
+
45
+ rows
46
+ end
47
+
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?
33
57
  ENV["FL_#{name.upcase}"] = ipa_info_result[key]
34
58
 
35
59
  rows << [name, ipa_info_result[key]]
@@ -75,87 +99,7 @@ module Fastlane
75
99
  rows
76
100
  end
77
101
 
78
- # macOS build number to macOS version
79
- # @return macOS version(High Sierra or higher)
80
- def self.macos_build_to_macos_version(build:)
81
- case build
82
- # macOS Big Sur
83
- when "20B29", "20B50" then
84
- "11.0.1"
85
- # macOS Catalina
86
- when "19H2", "19H15" then
87
- "10.15.7"
88
- when "19G73", "19G2021" then
89
- "10.15.6"
90
- when "19F101", "19F96" then
91
- "10.15.5"
92
- when "19E266" then
93
- "10.15.4"
94
- when "19D76" then
95
- "10.15.3"
96
- when "19C57" then
97
- "10.15.2"
98
- when "19B88" then
99
- "10.15.1"
100
- when "19A583", "19A602", "19A603" then
101
- "10.15"
102
- # macOS Mojave
103
- when "18G84", "18G103", "18G1012", "18G95" then
104
- "10.14.6"
105
- when "18F132", "18F203" then
106
- "10.14.5"
107
- when "18E226", "18E227" then
108
- "10.14.4"
109
- when "18D42", "18D43", "18D109" then
110
- "10.14.3"
111
- when "18C54" then
112
- "10.14.2"
113
- when "18B75", "18B2107", "18B3094" then
114
- "10.14.1"
115
- when "18A391" then
116
- "10.14"
117
- # macOS High Sierra
118
- when "17G65", "17G6029" then
119
- "10.13.6"
120
- when "17F77" then
121
- "10.13.5"
122
- when "17E199", "17E201", "17E202" then
123
- "10.13.4"
124
- when "17D47", "17D102", "17D2047", "17D2102" then
125
- "10.13.3"
126
- when "17C88", "17C89", "17C205", "17C2205" then
127
- "10.13.2"
128
- when "17B48", "17B1002", "17B1003" then
129
- "10.13.1"
130
- when "17A365", "17A405" then
131
- "10.13"
132
- else
133
- "UnKnown"
134
- end
135
- end
136
-
137
- def self.macos_version_to_os_name(version:)
138
- major_version = version.split(".")[0].to_i
139
- minor_version = version.split(".")[1].to_i
140
- # reference https://support.apple.com/ja-jp/HT201260
141
- case major_version
142
- when 11
143
- return "macOS Big Sur"
144
- end
145
- case minor_version
146
- when 15
147
- "macOS Catalina"
148
- when 14
149
- "macOS Mojave"
150
- when 13
151
- "macOS High Sierra"
152
- when 12
153
- "macOS Sierra"
154
- else
155
- "UnKnown"
156
- end
157
- end
158
-
102
+ # create summary table
159
103
  def self.summary_table(title:, rows:)
160
104
  Terminal::Table.new(
161
105
  title: title,
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module IpaInfo
3
- VERSION = "0.6.0"
3
+ VERSION = "0.7.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-ipa_info
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - tarappo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-08 00:00:00.000000000 Z
11
+ date: 2021-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: plist
@@ -50,6 +50,20 @@ dependencies:
50
50
  - - ">="
51
51
  - !ruby/object:Gem::Version
52
52
  version: 1.1.7
53
+ - !ruby/object:Gem::Dependency
54
+ name: mac_ios_info
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ type: :runtime
61
+ prerelease: false
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
53
67
  - !ruby/object:Gem::Dependency
54
68
  name: pry
55
69
  requirement: !ruby/object:Gem::Requirement
@@ -187,6 +201,7 @@ files:
187
201
  - lib/fastlane/plugin/ipa_info.rb
188
202
  - lib/fastlane/plugin/ipa_info/actions/ipa_info_action.rb
189
203
  - lib/fastlane/plugin/ipa_info/helper/ipa_analyze_helper.rb
204
+ - lib/fastlane/plugin/ipa_info/helper/ipa_analyze_helper2.rb
190
205
  - lib/fastlane/plugin/ipa_info/helper/ipa_info_helper.rb
191
206
  - lib/fastlane/plugin/ipa_info/version.rb
192
207
  homepage: https://github.com/tarappo/fastlane-plugin-ipa_info