pprof 0.4.1 → 0.5.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 +4 -4
- data/bin/pprof +8 -2
- data/lib/pprof/output_formatter.rb +80 -4
- data/lib/pprof/provisioning_profile.rb +1 -1
- data/lib/pprof/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7691660bb69c7c6f6f4fedb4722dc0e647183378e5aa79cfa0ce2a80f7e4cef
|
4
|
+
data.tar.gz: ae54346cc1d76c10a89468b605a698727ff38909f683bed7ff8a6d779c6605b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b2490137336562c025610bbfc7de8b0fe1a177005b9a7c7cfea21310fedb3f77164745303dc08b1816d3e8dd5a0f7a5aaa71373a71c784921982d36da4e876f
|
7
|
+
data.tar.gz: 22665cd4ba32a996577a8ed8099348f29193fb88589a32b1faaf8ca03298a971902373d23cdad568c59a1b6e23f59f81e3c0a3e543e8173c18ddd71f098379a5
|
data/bin/pprof
CHANGED
@@ -64,6 +64,9 @@ parser = OptionParser.new do |opts|
|
|
64
64
|
opts.on('-p', '--path', 'Print only the paths, one per line (instead of an ASCII table)') do
|
65
65
|
list_options[:mode] = :path
|
66
66
|
end
|
67
|
+
opts.on('-j', '--json', 'Print the output information as a JSON') do
|
68
|
+
list_options[:mode] = :json
|
69
|
+
end
|
67
70
|
opts.on('-0', '--print0', 'Separate each found entry by \\0, to be used by `xargs -0`') do
|
68
71
|
list_options[:zero] = true
|
69
72
|
end
|
@@ -156,9 +159,12 @@ else
|
|
156
159
|
begin
|
157
160
|
# Print info about given profile path/UUID
|
158
161
|
p = PProf::ProvisioningProfile.new(ARGV[0])
|
159
|
-
|
160
162
|
options = { info: true } if options.empty?
|
161
|
-
|
163
|
+
if list_options[:mode] == :json
|
164
|
+
o.print_json(p, options)
|
165
|
+
else
|
166
|
+
o.print_info(p, options)
|
167
|
+
end
|
162
168
|
rescue StandardError => e
|
163
169
|
o.print_error(e, ARGV[0])
|
164
170
|
end
|
@@ -1,9 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'json'
|
4
|
+
|
3
5
|
# Module for the pprof tool to manipulate Provisioning Profiles
|
4
6
|
module PProf
|
5
7
|
# A helper tool to pretty-print Provisioning Profile informations
|
6
8
|
class OutputFormatter
|
9
|
+
# List of properties of a `PProf::ProvisioningProfile` to print when using the `-i` flag
|
10
|
+
MAIN_PROFILE_KEYS = %i[name uuid app_id_name app_id_prefix creation_date expiration_date ttl team_ids team_name]
|
11
|
+
|
7
12
|
# Initialize a new OutputFormatter
|
8
13
|
#
|
9
14
|
# @param [IO] output
|
@@ -63,8 +68,7 @@ module PProf
|
|
63
68
|
def print_info(profile, options = nil)
|
64
69
|
options ||= { info: true }
|
65
70
|
if options[:info]
|
66
|
-
keys =
|
67
|
-
team_name]
|
71
|
+
keys = MAIN_PROFILE_KEYS
|
68
72
|
keys.each do |key|
|
69
73
|
@output.puts "- #{key}: #{profile.send(key.to_sym)}"
|
70
74
|
end
|
@@ -93,6 +97,49 @@ module PProf
|
|
93
97
|
# rubocop:enable Style/GuardClause
|
94
98
|
end
|
95
99
|
|
100
|
+
# Returns a Provisioning Profile hash ready to be printed as a JSON output
|
101
|
+
#
|
102
|
+
# @param [Array<PProf::ProvisioningProfile>] profile
|
103
|
+
# List of provisioning profiles to include in the JSON output
|
104
|
+
# @param [Hash] options
|
105
|
+
# Options to indicate what to include in the generated JSON.
|
106
|
+
# `:certs`: if set to `true`, output will also include the info about `DeveloperCertificates` in each profile
|
107
|
+
# `:devices`: if set to `true`, output will also include the list of `ProvisionedDevices` for each profile
|
108
|
+
#
|
109
|
+
# @return [Hash] The hash ready to be `JSON.pretty_generate`'d
|
110
|
+
#
|
111
|
+
def as_json(profile, options = {})
|
112
|
+
hash = profile.to_hash.dup
|
113
|
+
hash.delete 'DER-Encoded-Profile'
|
114
|
+
hash.delete 'ProvisionedDevices' unless options[:devices]
|
115
|
+
if options[:certs]
|
116
|
+
hash['DeveloperCertificates'] = developer_certificates.map do |cert|
|
117
|
+
{
|
118
|
+
subject: cert.subject,
|
119
|
+
issuer: cert.issuer,
|
120
|
+
serial: cert.serial,
|
121
|
+
expires: cert.not_after
|
122
|
+
}
|
123
|
+
end
|
124
|
+
else
|
125
|
+
hash.delete 'DeveloperCertificates'
|
126
|
+
end
|
127
|
+
hash
|
128
|
+
end
|
129
|
+
|
130
|
+
# Prints a Provisioning Profile as JSON
|
131
|
+
#
|
132
|
+
# @param [Array<PProf::ProvisioningProfile>] profile
|
133
|
+
# List of provisioning profiles to include in the JSON output
|
134
|
+
# @param [Hash] options
|
135
|
+
# Options to indicate what to include in the generated JSON.
|
136
|
+
# `:certs`: if set to `true`, output will also include the info about `DeveloperCertificates` in each profile
|
137
|
+
# `:devices`: if set to `true`, output will also include the list of `ProvisionedDevices` for each profile
|
138
|
+
#
|
139
|
+
def print_json(profile, options = {})
|
140
|
+
@output.puts JSON.pretty_generate(as_json(profile, options))
|
141
|
+
end
|
142
|
+
|
96
143
|
# Prints the filtered list of Provisioning Profiles
|
97
144
|
#
|
98
145
|
# Convenience method. Calls self.print_list with a filter block build from a filter hash
|
@@ -129,6 +176,8 @@ module PProf
|
|
129
176
|
case list_options[:mode]
|
130
177
|
when :table
|
131
178
|
print_table(dir, &filter_func)
|
179
|
+
when :json
|
180
|
+
print_json_list(dir, list_options, &filter_func)
|
132
181
|
else
|
133
182
|
print_list(dir, list_options, &filter_func)
|
134
183
|
end
|
@@ -181,7 +230,7 @@ module PProf
|
|
181
230
|
# Defaults to '~/Library/MobileDevice/Provisioning Profiles'
|
182
231
|
# @param [Hash] options
|
183
232
|
# The options hash typically filled while parsing the command line arguments.
|
184
|
-
# - :mode: will print the UUIDs if set to `:
|
233
|
+
# - :mode: will print the UUIDs if set to `:list`, the file path otherwise
|
185
234
|
# - :zero: will concatenate the entries with `\0` instead of `\n` if set
|
186
235
|
#
|
187
236
|
# @yield each provisioning profile for filtering/validation
|
@@ -195,7 +244,7 @@ module PProf
|
|
195
244
|
p = PProf::ProvisioningProfile.new(file)
|
196
245
|
next if block_given? && !yield(p)
|
197
246
|
|
198
|
-
@output.print options[:mode] == :
|
247
|
+
@output.print options[:mode] == :list ? p.uuid.chomp : file.chomp
|
199
248
|
@output.print options[:zero] ? "\0" : "\n"
|
200
249
|
rescue StandardError => e
|
201
250
|
errors << { message: e, file: file }
|
@@ -203,6 +252,33 @@ module PProf
|
|
203
252
|
errors.each { |e| print_error(e[:message], e[:file]) } unless errors.empty?
|
204
253
|
end
|
205
254
|
|
255
|
+
# Prints the filtered list of profiles as a JSON array
|
256
|
+
#
|
257
|
+
# @param [String] dir
|
258
|
+
# The directory containing the mobileprovision files to list.
|
259
|
+
# Defaults to '~/Library/MobileDevice/Provisioning Profiles'
|
260
|
+
# @param [Hash] options
|
261
|
+
# The options hash typically filled while parsing the command line arguments.
|
262
|
+
# - :mode: will print the UUIDs if set to `:list`, the file path otherwise
|
263
|
+
# - :zero: will concatenate the entries with `\0` instead of `\n` if set
|
264
|
+
#
|
265
|
+
# @yield each provisioning profile for filtering/validation
|
266
|
+
# The block is given ProvisioningProfile object and should
|
267
|
+
# return true to display the row, false to filter it out
|
268
|
+
#
|
269
|
+
def print_json_list(dir = PProf::ProvisioningProfile::DEFAULT_DIR, options) # rubocop:disable Style/OptionalArguments
|
270
|
+
errors = []
|
271
|
+
profiles = Dir['*.mobileprovision', base: dir].map do |file_name|
|
272
|
+
file = File.join(dir, file_name)
|
273
|
+
p = PProf::ProvisioningProfile.new(file)
|
274
|
+
as_json(p, options) unless block_given? && !yield(p)
|
275
|
+
rescue StandardError => e
|
276
|
+
errors << { message: e, file: file }
|
277
|
+
end.compact
|
278
|
+
errors.each { |e| print_error(e[:message], e[:file]) } unless errors.empty?
|
279
|
+
@output.puts JSON.pretty_generate(profiles)
|
280
|
+
end
|
281
|
+
|
206
282
|
def self.match_aps_env(actual, expected)
|
207
283
|
return false if actual.nil? # false if no Push entitlements
|
208
284
|
return true if expected == true # true if Push present but we don't filter on specific env
|
data/lib/pprof/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pprof
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Olivier Halligon
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: plist
|
@@ -44,7 +44,7 @@ licenses:
|
|
44
44
|
- MIT
|
45
45
|
metadata:
|
46
46
|
rubygems_mfa_required: 'true'
|
47
|
-
post_install_message:
|
47
|
+
post_install_message:
|
48
48
|
rdoc_options: []
|
49
49
|
require_paths:
|
50
50
|
- lib
|
@@ -59,8 +59,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '0'
|
61
61
|
requirements: []
|
62
|
-
rubygems_version: 3.
|
63
|
-
signing_key:
|
62
|
+
rubygems_version: 3.0.3
|
63
|
+
signing_key:
|
64
64
|
specification_version: 4
|
65
65
|
summary: A Provisioning Profiles library
|
66
66
|
test_files: []
|