fastlane-plugin-debug_file 0.1.1 → 0.2.1

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: 95fe7394552b5dd55525ec8b8877bea26c813796dcaf766d6fc758541ba3187d
4
- data.tar.gz: 821dcabcffa00f87ddbee2bc188c1f617d2783cd7c3c818de64b149a2544a781
3
+ metadata.gz: '079226ebaba880735af3cabaed19276177316c093b6db6d81ddaa9c89279bd81'
4
+ data.tar.gz: 2c8c6d1e32ca4d7cb468bd8b16339d8e91d5f2074c15efad70c1ac8475b18e10
5
5
  SHA512:
6
- metadata.gz: 358f041fa3750ce46f4f2272a6568f27c02c20ee909d8f5995235a6ecf9ea6f52ac256bfea58d3a70e088d53189b5a0e71c63c682f0a024ad724d13093fcff35
7
- data.tar.gz: '0280f0d169433438a4a57651a982fb3151b3175a0dc6c63a91a52f230bd10bde20259c2b42c0c3437349b3610ee0f918d87b7ac99f47041dc405eca959c5427c'
6
+ metadata.gz: 5375e5d39b154be40cc1e58712bed9d0dce3417f85c3ef0a6abfc0690979e8e342cd484101bc407307120f0955b5ebea87f0d01728a41d339fd6b0e064b64171
7
+ data.tar.gz: a5e53a19cdf77e09f4f4328a3f18c5e2f8ac8a2bc0618190c012b3b0273c914a584cfc4f9ce3b50a3d2a70df5f12796ff40ae25dfbd9c2b3b1ffe2cea981f126
@@ -10,7 +10,7 @@ module Fastlane
10
10
  end
11
11
 
12
12
  class DsymAction < Action
13
- ARCHIVE_PATH = File.expand_path('~/Library/Developer/Xcode/Archives')
13
+ ARCHIVE_PATH = ::DebugFile::Runner::ARCHIVE_PATH
14
14
  OUTPUT_PATH = '.'
15
15
 
16
16
  def self.run(params)
@@ -30,7 +30,11 @@ module Fastlane
30
30
  UI.user_error! "Not matched any archive with scheme: #{scheme}"
31
31
  end
32
32
 
33
- UI.success "Selected dSYM archive path: #{File.basename(File.dirname(archive_dsym_path))}"
33
+ xcarchive_file = File.basename(File.dirname(archive_dsym_path))
34
+ xcarchive_info_file = File.join(File.expand_path('../', archive_dsym_path), 'Info.plist')
35
+ xcarchive_info = Helper::DebugFileHelper.xcarchive_metadata(xcarchive_info_file)
36
+ release_version, build_version, created_at = version_info(xcarchive_info)
37
+ UI.success "Selected dSYM archive: #{release_version} (#{build_version}) [#{xcarchive_file}] #{created_at}"
34
38
 
35
39
  extra_dsym = params[:extra_dsym] || []
36
40
  dsym_files = [app_dsym_filename].concat(extra_dsym).uniq
@@ -45,39 +49,43 @@ module Fastlane
45
49
  UI.success "Prepare #{dsym_files.size} dSYM file(s) compressing"
46
50
  Helper::DebugFileHelper.compress(dsym_files, output_file)
47
51
 
48
- UI.success "Compressed proguard files: #{output_file}"
52
+ UI.success "Compressed dSYM file: #{output_file}"
49
53
  Helper::DebugFileHelper.store_shard_value SharedValues::DF_DSYM_ZIP_PATH, output_file
50
54
  end
51
55
 
52
56
  def self.last_created_dsym(scheme, archive_path)
53
57
  info_path = File.join(archive_path, '**', '*.xcarchive', 'Info.plist')
54
58
  matched_paths = []
59
+
60
+ UI.verbose "Finding #{scheme} xcarchive in #{archive_path} ..."
55
61
  Dir.glob(info_path) do |path|
56
- name = get_plist_value(path, 'Name')
62
+ info = Helper::DebugFileHelper.xcarchive_metadata(path)
63
+ name = Helper::DebugFileHelper.fetch_key(info, 'Name')
57
64
  if scheme == name
65
+ xcarchive = File.basename(File.dirname(path))
66
+ release_version, build_version, created_at = version_info(info)
67
+ UI.verbose " => #{release_version} (#{build_version}) [#{xcarchive}] was created at #{created_at}"
68
+
58
69
  matched_paths << path
59
70
  end
60
71
  end
61
72
 
62
73
  return if matched_paths.empty?
63
74
 
64
- UI.verbose "Found #{matched_paths.size} matched dSYM archive(s)"
75
+ UI.verbose "Found #{matched_paths.size} matched dSYM archive(s) of #{scheme}"
65
76
  last_created_path = matched_paths.size == 1 ? matched_paths.first : matched_paths.max_by { |p| File.stat(p).mtime }
66
77
  File.join(File.dirname(last_created_path), 'dSYMs')
67
78
  end
68
79
  private_class_method :last_created_dsym
69
80
 
70
- def self.get_plist_value(file, key)
71
- plist = read_plist(file)
72
- plist[key.to_s]
73
- end
74
- private_class_method :get_plist_value
81
+ def self.version_info(info)
82
+ release_version = Helper::DebugFileHelper.fetch_key(info, 'ApplicationProperties', 'CFBundleShortVersionString')
83
+ build = Helper::DebugFileHelper.fetch_key(info, 'ApplicationProperties', 'CFBundleVersion')
84
+ created_at = Helper::DebugFileHelper.fetch_key(info, 'CreationDate')
75
85
 
76
- def self.read_plist(file)
77
- require 'plist'
78
- Plist.parse_xml(file)
86
+ [release_version, build, created_at]
79
87
  end
80
- private_class_method :read_plist
88
+ private_class_method :version_info
81
89
 
82
90
  #####################################################
83
91
  # @!group Documentation
@@ -93,7 +101,7 @@ module Fastlane
93
101
  env_name: 'DF_DSYM_ARCHIVE_PATH',
94
102
  description: 'The archive path of xcode',
95
103
  type: String,
96
- default_value: Actions.lane_context[SharedValues::XCODEBUILD_ARCHIVE] || ARCHIVE_PATH,
104
+ default_value: Actions.lane_context[SharedValues::XCODEBUILD_ARCHIVE] || ::DebugFile::Runner::ARCHIVE_PATH,
97
105
  optional: true),
98
106
  FastlaneCore::ConfigItem.new(key: :scheme,
99
107
  env_name: 'DF_DSYM_SCHEME',
@@ -105,6 +113,16 @@ module Fastlane
105
113
  optional: true,
106
114
  default_value: [],
107
115
  type: Array),
116
+ FastlaneCore::ConfigItem.new(key: :release_version,
117
+ env_name: 'DF_DSYM_RELEASE_VERSION',
118
+ description: 'Use the given release version of app',
119
+ optional: true,
120
+ type: String),
121
+ FastlaneCore::ConfigItem.new(key: :build,
122
+ env_name: 'DF_DSYM_BUILD',
123
+ description: 'Use the given build version of app',
124
+ optional: true,
125
+ type: String),
108
126
  FastlaneCore::ConfigItem.new(key: :output_path,
109
127
  env_name: 'DF_DSYM_OUTPUT_PATH',
110
128
  description: "The output path of compressed dSYM file",
@@ -0,0 +1,105 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'fastlane/action'
4
+ require_relative '../helper/debug_file_helper'
5
+
6
+ module Fastlane
7
+ module Actions
8
+ module SharedValues
9
+ DF_DSYMS_LIST = :DF_DSYMS_LIST
10
+ end
11
+
12
+ class ListDsymAction < Action
13
+ def self.run(params)
14
+ archive_path = params[:archive_path]
15
+ scheme = params[:scheme]
16
+ Fastlane::UI.verbose "Finding #{scheme || 'all' } xcarchive in #{archive_path} ..."
17
+
18
+ runner = ::DebugFile::Runner.new({
19
+ archive_path: archive_path,
20
+ scheme: scheme
21
+ })
22
+
23
+ dsyms = runner.list_dsym
24
+
25
+ Fastlane::UI.success "Found #{dsyms.size} dSYM files"
26
+ dsyms.each do |dsym|
27
+ Fastlane::UI.success "• #{dsym[:name]} #{dsym[:release_version]} (#{dsym[:build]}) - #{dsym[:created_at]}"
28
+ dsym[:machos].each do |macho|
29
+ Fastlane::UI.message " #{macho[:uuid]} (#{macho[:arch]})"
30
+ end
31
+ end
32
+
33
+ Helper::DebugFileHelper.store_shard_value SharedValues::DF_DSYMS_LIST, dsyms
34
+
35
+ dsyms
36
+ end
37
+
38
+ #####################################################
39
+ # @!group Documentation
40
+ #####################################################
41
+
42
+ def self.description
43
+ 'Find and generate iOS/MacOS dSYM file(s) to zip file'
44
+ end
45
+
46
+ def self.available_options
47
+ [
48
+ FastlaneCore::ConfigItem.new(key: :archive_path,
49
+ env_name: 'DF_DSYM_ARCHIVE_PATH',
50
+ description: 'The archive path of xcode',
51
+ type: String,
52
+ default_value: Actions.lane_context[SharedValues::XCODEBUILD_ARCHIVE] || ::DebugFile::Runner::ARCHIVE_PATH,
53
+ optional: true),
54
+ FastlaneCore::ConfigItem.new(key: :scheme,
55
+ env_name: 'DF_DSYM_SCHEME',
56
+ description: 'The scheme name of app',
57
+ optional: true,
58
+ type: String),
59
+ FastlaneCore::ConfigItem.new(key: :release_version,
60
+ env_name: 'DF_DSYM_RELEASE_VERSION',
61
+ description: 'Use the given release version of app',
62
+ optional: true,
63
+ type: String),
64
+ FastlaneCore::ConfigItem.new(key: :build,
65
+ env_name: 'DF_DSYM_BUILD',
66
+ description: 'Use the given build version of app',
67
+ optional: true,
68
+ type: String)
69
+ ]
70
+ end
71
+
72
+ def self.example_code
73
+ [
74
+ 'list_dsym',
75
+ 'list_dsym(
76
+ archive_path: "~/Library/Developer/Xcode/Archives",
77
+ scheme: "AppName"
78
+ )'
79
+ ]
80
+ end
81
+
82
+ def self.category
83
+ :misc
84
+ end
85
+
86
+ def self.return_value
87
+ Array
88
+ end
89
+
90
+ def self.output
91
+ [
92
+ ['DF_DSYMS_LIST', 'the array of dSYMs metadata']
93
+ ]
94
+ end
95
+
96
+ def self.authors
97
+ ['icyleaf']
98
+ end
99
+
100
+ def self.is_supported?(platform)
101
+ [:ios, :mac].include?(platform)
102
+ end
103
+ end
104
+ end
105
+ end
@@ -35,9 +35,52 @@ module Fastlane
35
35
  end
36
36
  end
37
37
 
38
+ def self.macho_metadata(file)
39
+ require 'macho'
40
+
41
+ macho_type = MachO.open(file)
42
+ case macho_type
43
+ when ::MachO::MachOFile
44
+ [macho_type]
45
+ else
46
+ size = macho_type.fat_archs.each_with_object([]) do |arch, obj|
47
+ obj << arch.size
48
+ end
49
+
50
+ machos = []
51
+ macho_type.machos.each do |file|
52
+ machos << file
53
+ end
54
+ machos
55
+ end
56
+ end
57
+
38
58
  def self.store_shard_value(key, value)
39
59
  Actions.lane_context[key] = value
40
- ENV[key.to_s] = value
60
+ ENV[key.to_s] = case value
61
+ when String
62
+ value
63
+ else
64
+ JSON.dump(value)
65
+ end
66
+ end
67
+
68
+ def self.xcarchive_metadata(path)
69
+ file = File.directory?(path) ? File.join(path, 'Info.plist') : path
70
+ UI.user_error! "Can not read Info.plist in #{file}" unless File.file?(file)
71
+
72
+ require 'plist'
73
+ Plist.parse_xml(file)
74
+ end
75
+
76
+ def self.fetch_key(plist, *keys)
77
+ UI.crash! 'Missing keys' if keys.empty?
78
+
79
+ if keys.size == 1
80
+ plist[keys[0]]
81
+ else
82
+ plist.dig(*keys)
83
+ end
41
84
  end
42
85
  end
43
86
  end
@@ -0,0 +1,70 @@
1
+ module DebugFile
2
+ class Runner
3
+ ARCHIVE_PATH = File.expand_path('~/Library/Developer/Xcode/Archives')
4
+
5
+ attr_accessor :options
6
+
7
+ def initialize(options = {})
8
+ @options = options
9
+ end
10
+
11
+ def latest_dsym(filter: :date)
12
+ dsyms = list_dsym
13
+ case filter
14
+ when :version
15
+ dsyms.max_by {|v| Gem::Version.new(v[:release_version])}
16
+ else
17
+ dsyms.max_by {|v| v[:created_at]}
18
+ end
19
+ end
20
+
21
+ def list_dsym
22
+ archive_path = File.expand_path(options.fetch(:archive_path, ARCHIVE_PATH))
23
+ search_dsym(archive_path, options[:scheme])
24
+ end
25
+
26
+ private
27
+
28
+ def search_dsym(path, scheme = nil)
29
+ info_path = File.join(path, '**', '*.xcarchive', 'Info.plist')
30
+ matched_paths = []
31
+
32
+ obj = []
33
+ Dir.glob(info_path) do |path|
34
+ info = Fastlane::Helper::DebugFileHelper.xcarchive_metadata(path)
35
+ name = Fastlane::Helper::DebugFileHelper.fetch_key(info, 'Name')
36
+ next unless scheme.to_s.empty? || scheme == name
37
+
38
+ release_version = Fastlane::Helper::DebugFileHelper.fetch_key(info, 'ApplicationProperties', 'CFBundleShortVersionString')
39
+ build = Fastlane::Helper::DebugFileHelper.fetch_key(info, 'ApplicationProperties', 'CFBundleVersion')
40
+ dsym_path = Dir.glob(File.join(File.dirname(path), 'dSYMs', "#{name}.app.dSYM", '**', '*', name)).first
41
+ created_at = Fastlane::Helper::DebugFileHelper.fetch_key(info, 'CreationDate')
42
+
43
+ machos = []
44
+ Fastlane::Helper::DebugFileHelper.macho_metadata(dsym_path).each do |macho|
45
+ machos << {
46
+ arch: macho.cpusubtype,
47
+ uuid: macho[:LC_UUID][0].uuid_string
48
+ }
49
+ end
50
+
51
+ item = {
52
+ root_path: File.basename(File.dirname(path)),
53
+ dsym_path: dsym_path,
54
+ machos: machos,
55
+ info: info,
56
+ name: name,
57
+ release_version: release_version,
58
+ build: build,
59
+ created_at: created_at,
60
+ }
61
+
62
+ yield item if block_given?
63
+
64
+ obj << item
65
+ end
66
+
67
+ obj
68
+ end
69
+ end
70
+ end
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module DebugFile
3
- VERSION = "0.1.1"
3
+ VERSION = "0.2.1"
4
4
  end
5
5
  end
@@ -1,4 +1,5 @@
1
1
  require 'fastlane/plugin/debug_file/version'
2
+ require 'fastlane/plugin/debug_file/runner'
2
3
 
3
4
  module Fastlane
4
5
  module DebugFile
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-debug_file
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - icyleaf
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-17 00:00:00.000000000 Z
11
+ date: 2020-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ruby-macho
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 2.2.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 2.2.0
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: pry
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -136,7 +150,7 @@ dependencies:
136
150
  - - ">="
137
151
  - !ruby/object:Gem::Version
138
152
  version: 2.139.0
139
- description:
153
+ description:
140
154
  email: icyleaf.cn@gmail.com
141
155
  executables: []
142
156
  extensions: []
@@ -146,14 +160,16 @@ files:
146
160
  - README.md
147
161
  - lib/fastlane/plugin/debug_file.rb
148
162
  - lib/fastlane/plugin/debug_file/actions/dsym_action.rb
163
+ - lib/fastlane/plugin/debug_file/actions/list_dsym_action.rb
149
164
  - lib/fastlane/plugin/debug_file/actions/proguard_action.rb
150
165
  - lib/fastlane/plugin/debug_file/helper/debug_file_helper.rb
166
+ - lib/fastlane/plugin/debug_file/runner.rb
151
167
  - lib/fastlane/plugin/debug_file/version.rb
152
168
  homepage: https://github.com/icyleaf/fastlane-plugin-debug_file
153
169
  licenses:
154
170
  - MIT
155
171
  metadata: {}
156
- post_install_message:
172
+ post_install_message:
157
173
  rdoc_options: []
158
174
  require_paths:
159
175
  - lib
@@ -168,8 +184,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
168
184
  - !ruby/object:Gem::Version
169
185
  version: '0'
170
186
  requirements: []
171
- rubygems_version: 3.0.6
172
- signing_key:
187
+ rubygems_version: 3.1.2
188
+ signing_key:
173
189
  specification_version: 4
174
190
  summary: Compress iOS/macApp dSYM or Android Proguard(mapping/R/AndroidManifest) to
175
191
  zip file