flappy-cli 0.3.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.
Files changed (52) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/CODE_OF_CONDUCT.md +74 -0
  4. data/Gemfile +12 -0
  5. data/LICENSE.txt +21 -0
  6. data/README.md +41 -0
  7. data/Rakefile +2 -0
  8. data/bin/console +14 -0
  9. data/bin/flappy +14 -0
  10. data/bin/setup +8 -0
  11. data/flappy-cli.gemspec +50 -0
  12. data/lib/flappy/api.yml +7 -0
  13. data/lib/flappy/cli.rb +145 -0
  14. data/lib/flappy/patches/blank.rb +131 -0
  15. data/lib/flappy/patches/concern.rb +146 -0
  16. data/lib/flappy/patches/default_headers.rb +9 -0
  17. data/lib/flappy/patches/hash.rb +79 -0
  18. data/lib/flappy/patches/instance_variables.rb +30 -0
  19. data/lib/flappy/patches/native_patch.rb +28 -0
  20. data/lib/flappy/patches/os_patch.rb +28 -0
  21. data/lib/flappy/patches/try.rb +102 -0
  22. data/lib/flappy/patches.rb +12 -0
  23. data/lib/flappy/util/archive_ipa.rb +55 -0
  24. data/lib/flappy/util/build_apk.rb +104 -0
  25. data/lib/flappy/util/build_common.rb +90 -0
  26. data/lib/flappy/util/build_ipa.rb +331 -0
  27. data/lib/flappy/util/config.rb +41 -0
  28. data/lib/flappy/util/http.rb +30 -0
  29. data/lib/flappy/util/iOS_check.rb +29 -0
  30. data/lib/flappy/util/iOS_env_config.rb +54 -0
  31. data/lib/flappy/util/iOS_logger.rb +113 -0
  32. data/lib/flappy/util/info.rb +39 -0
  33. data/lib/flappy/util/ipa_info.rb +198 -0
  34. data/lib/flappy/util/mapping.rb +84 -0
  35. data/lib/flappy/util/multi_io.rb +27 -0
  36. data/lib/flappy/util/parser/apk.rb +42 -0
  37. data/lib/flappy/util/parser/bin/pngcrush +0 -0
  38. data/lib/flappy/util/parser/common.rb +24 -0
  39. data/lib/flappy/util/parser/pngcrush.rb +23 -0
  40. data/lib/flappy/util/publish.rb +185 -0
  41. data/lib/flappy/util/update_pod.rb +264 -0
  42. data/lib/flappy/util.rb +105 -0
  43. data/lib/flappy/version.rb +3 -0
  44. data/lib/flappy-cli.rb +3 -0
  45. data/lib/flappy.rb +28 -0
  46. data/output/Flappy-Archives/iOS/WorkspaceForPackageTest/20170103000308/20170103000308_WorkspaceForPackageTest.json +1 -0
  47. data/output/Flappy-Archives/iOS/WorkspaceForPackageTest/20170103000308/20170103000308_WorkspaceForPackageTest_Podfile +16 -0
  48. data/output/Flappy-Archives/iOS/WorkspaceForPackageTest/20170103000308/20170103000308_WorkspaceForPackageTest_Podfile_lock +40 -0
  49. data/output/Flappy-Archives/iOS/WorkspaceForPackageTest/20170103000314/20170103000314_WorkspaceForPackageTest.json +1 -0
  50. data/output/Flappy-Archives/iOS/WorkspaceForPackageTest/20170103000314/20170103000314_WorkspaceForPackageTest_Podfile +16 -0
  51. data/output/Flappy-Archives/iOS/WorkspaceForPackageTest/20170103000314/20170103000314_WorkspaceForPackageTest_Podfile_lock +40 -0
  52. metadata +223 -0
@@ -0,0 +1,331 @@
1
+ # encoding: utf-8
2
+
3
+ module Flappy
4
+ module BuildIpa
5
+
6
+ def build_ipa(*args, options)
7
+ initialize_output_path(options)
8
+ initialize_app_output_archive_info_path(args)
9
+ initialize_iOS_logger(options)
10
+ initialize_work_dir(args, options)
11
+
12
+ update_pod_if_needed(args, options)
13
+ writeEnvToPlist(args, options)
14
+
15
+ @build_cmd = initialize_ipa_build_cmd(args, options)
16
+
17
+ unless @build_cmd.blank?
18
+ remove_build_cache
19
+
20
+ log_iOS('>>>>>>>>>>>>>>>>>>>>>>>>>>>> Build......')
21
+ log_iOS("build cmd: #{@build_cmd}")
22
+
23
+ log_iOS_build(@build_cmd)
24
+
25
+ if $?.to_i != 0
26
+ log_iOS('>>>>>>>>>>>>>>>>>>>>>>>>>>>> Build failed')
27
+ exit 1
28
+ else
29
+ log_iOS('>>>>>>>>>>>>>>>>>>>>>>>>>>>> Build succeed')
30
+ end
31
+ end
32
+
33
+
34
+ initialize_ipa_output_path
35
+ @xcrun_cmd = archive_ipa_with_path(@build_dir, @temp_ipa_path)
36
+
37
+ unless @xcrun_cmd.blank?
38
+ log_iOS('>>>>>>>>>>>>>>>>>>>>>>>>>>>> Archiving......')
39
+ log_iOS("archive cmd: #{@xcrun_cmd}")
40
+
41
+ log_iOS_archive(@xcrun_cmd)
42
+ if $?.to_i != 0
43
+ log_iOS('>>>>>>>>>>>>>>>>>>>>>>>>>>>> Archive failed')
44
+ exit 1
45
+ else
46
+ log_iOS('>>>>>>>>>>>>>>>>>>>>>>>>>>>> Archive succeed')
47
+ end
48
+
49
+ rename_ipa # 重命名
50
+ end
51
+
52
+
53
+ log_iOS('>>>>>>>>>>>>>>>>>>>>>>>>>>>> Saving dSYM file...')
54
+ save_dSYM_file
55
+ log_iOS('>>>>>>>>>>>>>>>>>>>>>>>>>>>> Saving dSYM file Succeed')
56
+
57
+ if options[:open]
58
+ system("open -R \"#{@app_output_archive_info_path}\"") if File.exists?(@app_output_archive_info_path)
59
+ end
60
+
61
+ unless options[:firToken].blank?
62
+ log_iOS('>>>>>>>>>>>>>>>>>>>>>>>>>>>> Uploading app to fir...')
63
+ publish(@ipa_path, options)
64
+
65
+ if $?.to_i != 0
66
+ log_iOS('>>>>>>>>>>>>>>>>>>>>>>>>>>>> Upload app failed')
67
+ else
68
+ log_iOS('>>>>>>>>>>>>>>>>>>>>>>>>>>>> Upload app succeed')
69
+ end
70
+ end
71
+ end
72
+
73
+
74
+ def initialize_output_path(options)
75
+ output_path = File.expand_path(options[:output]) unless options[:output].blank?
76
+ default_output_path = File.expand_path('~/Documents/Flappy-Archives/iOS')
77
+
78
+ unless output_path.blank?
79
+ @output_path = File.join(output_path, 'Flappy-Archives', 'iOS')
80
+ else
81
+ log_iOS("Output path is empty, use default output path #{default_output_path}")
82
+ @output_path = default_output_path
83
+ end
84
+
85
+ FileUtils.mkdir_p(@output_path) unless File.exist?(@output_path)
86
+ end
87
+
88
+ def initialize_app_output_archive_info_path(args)
89
+ @start_time = Time.now.strftime('%Y%m%d%H%M%S')
90
+
91
+ work_dir = args.first.to_s
92
+ if File.extname(work_dir) == '.git' # git地址
93
+ @app_dir_name = File.basename(work_dir, '.git') # git名字
94
+ elsif work_dir.blank? || !File.exist?(work_dir) # 为空
95
+ @app_dir_name = File.basename(Dir.pwd) # 当前目录
96
+ else
97
+ @app_dir_name = File.basename(work_dir)
98
+ end
99
+
100
+ @app_output_archive_info_path = File.join(@output_path, @app_dir_name, @start_time)
101
+ @app_output_archive_log_path = File.join(@app_output_archive_info_path, "#{@start_time}_Log")
102
+ FileUtils.mkdir_p(@app_output_archive_info_path) unless File.exist?(@app_output_archive_info_path) # 创建本次打包的存储目录
103
+ FileUtils.mkdir_p(@app_output_archive_log_path) unless File.exist?(@app_output_archive_log_path) # 创建本次打包的logger目录
104
+ end
105
+
106
+
107
+ def initialize_work_dir(args, options)
108
+ work_dir = args.first.to_s
109
+
110
+ if File.extname(work_dir) == '.git' # git地址
111
+ @work_dir = git_clone_work_dir(args, options) # clone好work dir即为clone后的项目路径
112
+ elsif work_dir.blank? || !File.exist?(work_dir) # 为空
113
+ @work_dir = Dir.pwd # 当前目录
114
+ else
115
+ @work_dir = File.expand_path(work_dir)
116
+ end
117
+ end
118
+
119
+
120
+ def git_clone_work_dir(args, options)
121
+ git_url = args.first.to_s
122
+ branch = options[:branch].blank? ? 'master' : options[:branch] # 分支名不指定则默认为master
123
+
124
+ repo_path = File.join(@app_output_archive_info_path, @start_time + "_#{@app_dir_name}")
125
+ git_cmd = "git clone --depth=50 --branch=#{branch} #{git_url} #{repo_path}"
126
+
127
+ log_iOS('>>>>>>>>>>>>>>>>>>>>>>>>>>>> Cloning......')
128
+ log_iOS("git cmd: #{git_cmd}")
129
+
130
+ system(git_cmd)
131
+ if $?.to_i != 0
132
+ log_iOS('>>>>>>>>>>>>>>>>>>>>>>>>>>>> Clone failed')
133
+ exit 1
134
+ else
135
+ log_iOS('>>>>>>>>>>>>>>>>>>>>>>>>>>>> Clone succeed')
136
+ repo_path
137
+ end
138
+
139
+ end
140
+
141
+
142
+ def initialize_ipa_output_path
143
+ @temp_ipa_path = "#{@app_output_archive_info_path}/#{@start_time}.ipa" # ipa包路径
144
+ end
145
+
146
+ def ipa_info(ipa_path, options = {})
147
+ ipa = Flappy::IpaInfo::Ipa.new(ipa_path)
148
+ app = ipa.app
149
+ info = app.full_info(options)
150
+
151
+ ipa.cleanup
152
+ info
153
+ end
154
+
155
+
156
+ def save_dSYM_file
157
+ dSYM_file_to_copy = ''
158
+ Dir.glob("#{@build_dir}/**/*.app.dSYM").each do |path|
159
+ dSYM_file_to_copy = path
160
+ basename = File.basename(dSYM_file_to_copy)
161
+ @dSYM_file_path = File.join(@app_output_archive_info_path, "#{@start_time}_#{basename}")
162
+ end
163
+
164
+ FileUtils.cp_r(dSYM_file_to_copy, @dSYM_file_path) if File.exists?(dSYM_file_to_copy)
165
+ end
166
+
167
+
168
+ def rename_ipa
169
+ ipa_info = ipa_info(@temp_ipa_path)
170
+
171
+ @ipa_name = "#{@start_time}_#{ipa_info[:name]}.ipa"
172
+ @ipa_path = File.join(@app_output_archive_info_path, "#{@ipa_name}")
173
+
174
+ if File.exist?(@temp_ipa_path)
175
+ FileUtils.mv(@temp_ipa_path, @ipa_path, force: true)
176
+ end
177
+ end
178
+
179
+ def remove_build_cache
180
+ FileUtils.rm_rf(@build_SYMROOT_dir) if File.exists?(@build_SYMROOT_dir)
181
+ end
182
+
183
+
184
+ def initialize_ipa_build_cmd(args, options)
185
+ @workspace_path = ''
186
+ @workspace_name = ''
187
+ @workspace = ''
188
+
189
+ @project_path = ''
190
+ @project_name = ''
191
+ @project = ''
192
+
193
+ @build_scheme_name = options[:scheme]
194
+ @build_target_name = options[:target]
195
+ @build_configuration = options[:configuration]
196
+
197
+ @build_dir = ''
198
+ @build_SYMROOT_dir = ''
199
+
200
+ @codesign = options[:codesign]
201
+ @provision_name = options[:provision]
202
+
203
+ if check_and_find_ios_xcworkspace(@work_dir)
204
+ check_condition(@build_dir, 'build dir is empty!')
205
+
206
+ unless @workspace.blank?
207
+ if @build_scheme_name.blank?
208
+ log_iOS('该工程为workspace,编译workspace必须同时指定一个scheme,可以使用`xcodebuild --list`来查看该workspace的scheme列表')
209
+ exit 1
210
+ end
211
+ end
212
+
213
+ build_cmd = "cd #{@build_dir}; xcodebuild"
214
+ build_cmd += " -workspace '#{@workspace}'" unless @workspace.blank?
215
+ build_cmd += " -scheme '#{@build_scheme_name}'" unless @build_scheme_name.blank?
216
+
217
+ elsif check_and_find_ios_xcodeproj(@work_dir)
218
+ check_condition(@build_dir, 'build dir is empty!')
219
+
220
+ build_cmd = "cd #{@build_dir}; xcodebuild"
221
+ build_cmd += " -target '#{@build_target_name}'" unless @build_target_name.blank?
222
+ else
223
+ log_iOS('No xcworkspace or xcodeproj found')
224
+ exit 1
225
+ end
226
+
227
+ build_cmd += " -configuration '#{@build_configuration}'" unless @build_configuration.blank?
228
+
229
+ check_condition(@build_SYMROOT_dir, 'SYMROOT_dir is empty!')
230
+ build_cmd += " clean build SYMROOT=\"#{@build_SYMROOT_dir}\""
231
+
232
+ unless @codesign.blank?
233
+ logger_iOS.info 'Use custom certificate'
234
+ build_cmd += " CODE_SIGN_IDENTITY=\"#{@codesign}\" PROVISIONING_PROFILE=\"#{@provision_name}\""
235
+ else
236
+ log_iOS('Use project certificate')
237
+ end
238
+
239
+ build_cmd
240
+ end
241
+
242
+
243
+ %w(xcodeproj xcworkspace).each do |workplace|
244
+ define_method "check_and_find_ios_#{workplace}" do |path|
245
+ unless File.exist?(path)
246
+ log_iOS('The path not exists')
247
+ exit 1
248
+ end
249
+
250
+ Dir.glob(["#{path}/**/*.xcworkspace", "#{path}/**/*.xcodeproj"]).each do |path|
251
+ if !path.end_with?("project.xcworkspace") && !path.end_with?("Pods.xcodeproj")
252
+
253
+ if File.extname(path) == ".#{workplace}"
254
+ @build_dir = File.dirname(path)
255
+ @build_SYMROOT_dir = "#{@build_dir}/flappy_build"
256
+ if "#{workplace}" == 'xcworkspace'
257
+
258
+ @workspace_path = path
259
+ @workspace_name = File.basename(path, File.extname(path))
260
+ @workspace = File.basename(path)
261
+
262
+ log_iOS("Found #{workplace} name: #{File.basename(path, File.extname(path))}, path: #{path}")
263
+ return true
264
+ elsif "#{workplace}" == 'xcodeproj'
265
+
266
+ @project_path = path
267
+ @project_name = File.basename(path, File.extname(path))
268
+ @project = File.basename(path)
269
+
270
+ log_iOS("Found #{workplace} name: #{File.basename(path, File.extname(path))}, path: #{path}")
271
+ return true
272
+ else
273
+ exit 1
274
+ end
275
+ else
276
+ return false
277
+ end
278
+ end
279
+ end
280
+ return false
281
+ end
282
+ end
283
+
284
+
285
+
286
+ # def check_build_info(args, options)
287
+ # self.codesign = options[:codesign].to_s
288
+ # if self.codesign.nil? || self.codesign.empty?
289
+ # logger_iOS.info 'No codesign or provision file! use xcode project configuration'
290
+ # else
291
+ # plist_buddy_cmd = "/usr/libexec/PlistBuddy -c 'Print UUID' /dev/stdin <<< $(security cms -D -i \"#{@provision_path}\""
292
+ # uuid = system(plist_buddy_cmd)
293
+ #
294
+ # if uuid.nil? || uuid.empty?
295
+ # logger_iOS.info 'export UUID error! use project configuration!'
296
+ # self.codesign = ''
297
+ # else
298
+ # self.mobile_provision = uuid
299
+ # logger_iOS.info "codesign: #{@codesign} UUID: #{uuid} mobileprovision: #{@mobile_provision}"
300
+ # end
301
+ # end
302
+ # end
303
+
304
+
305
+ # def ipa_custom_settings(args)
306
+ # custom_settings = split_assignment_array_to_hash(args)
307
+ #
308
+ # setting_str = convert_hash_to_assignment_string(custom_settings)
309
+ # setting_str += " TARGET_BUILD_DIR='#{@build_tmp_dir}'" unless custom_settings['TARGET_BUILD_DIR']
310
+ # setting_str += " CONFIGURATION_BUILD_DIR='#{@build_tmp_dir}'" unless custom_settings['CONFIGURATION_BUILD_DIR']
311
+ # setting_str += " DWARF_DSYM_FOLDER_PATH='#{@output_path}'" unless custom_settings['DWARF_DSYM_FOLDER_PATH']
312
+ # setting_str
313
+ # end
314
+ #
315
+
316
+ # def upload_build_dsym_mapping_file
317
+ # logger_info_blank_line
318
+ #
319
+ # @app_info = ipa_info(@builded_app_path)
320
+ # @mapping_file = Dir["#{@output_path}/#{@ipa_name}.app.dSYM/Contents/Resources/DWARF/*"].first
321
+ #
322
+ # mapping @mapping_file, proj: @proj,
323
+ # build: @app_info[:build],
324
+ # version: @app_info[:version],
325
+ # token: @token
326
+ # end
327
+
328
+
329
+ end
330
+ end
331
+
@@ -0,0 +1,41 @@
1
+ # encoding: utf-8
2
+
3
+ module Flappy
4
+ module Config
5
+ CONFIG_PATH = "#{ENV['HOME']}/.flappy-cli"
6
+ APP_INFO_PATH = "#{ENV['HOME']}/.flappy-cli-app"
7
+ API_YML_PATH = File.expand_path('../../', __FILE__) + '/api.yml'
8
+ APP_FILE_TYPE = %w(.ipa .apk).freeze
9
+
10
+ def fir_api
11
+ @fir_api ||= YAML.load_file(API_YML_PATH).deep_symbolize_keys[:fir]
12
+ end
13
+ #
14
+ # def bughd_api
15
+ # @bughd_api ||= YAML.load_file(API_YML_PATH).deep_symbolize_keys[:bughd]
16
+ # end
17
+
18
+ def config
19
+ return unless File.exist?(CONFIG_PATH)
20
+ @config ||= YAML.load_file(CONFIG_PATH).deep_symbolize_keys
21
+ end
22
+
23
+ def reload_config
24
+ @config = YAML.load_file(CONFIG_PATH).deep_symbolize_keys
25
+ end
26
+
27
+ def write_config(hash)
28
+ File.open(CONFIG_PATH, 'w+') { |f| f << YAML.dump(hash) }
29
+ end
30
+
31
+ def write_app_info(hash)
32
+ File.open(APP_INFO_PATH, 'w+') { |f| f << YAML.dump(hash) }
33
+ end
34
+
35
+ def current_token
36
+ @token ||= config[:token] if config
37
+ end
38
+
39
+ alias_method :a, :exit
40
+ end
41
+ end
@@ -0,0 +1,30 @@
1
+ # encoding: utf-8
2
+
3
+ module Flappy
4
+ module Http
5
+ MAX_RETRIES = 5
6
+
7
+ %w(get post patch put).each do |_m|
8
+ class_eval <<-METHOD, __FILE__, __LINE__ + 1
9
+ def #{_m}(url, params = {})
10
+ query = :#{_m} == :get ? { params: params } : params
11
+ begin
12
+ res = ::RestClient.#{_m}(url, query)
13
+ rescue => e
14
+ @retries ||= 0
15
+ logger.error(e.message.to_s)
16
+ if @retries < MAX_RETRIES
17
+ @retries += 1
18
+ logger.info("Retry \#{@retries} times......")
19
+ sleep 2
20
+ retry
21
+ else
22
+ exit 1
23
+ end
24
+ end
25
+ JSON.parse(res.body.force_encoding('UTF-8'), symbolize_names: true)
26
+ end
27
+ METHOD
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,29 @@
1
+ # encoding: utf-8
2
+
3
+ module Flappy
4
+ module IOSChecking
5
+ def check_condition(variable, description)
6
+ if variable.blank?
7
+ log_iOS(description)
8
+ exit 1
9
+ end
10
+ end
11
+
12
+
13
+ def check_no_output_app(apps)
14
+ if apps.length == 0
15
+ log_iOS('Builded has no output app, Can not be packaged')
16
+ exit 1
17
+ end
18
+ end
19
+
20
+ def check_archived_ipa_is_exist
21
+ unless File.exist?(@ipa_path)
22
+ log_iOS('Archive failed')
23
+ exit 1
24
+ end
25
+ end
26
+ end
27
+ end
28
+
29
+
@@ -0,0 +1,54 @@
1
+ # encoding: utf-8
2
+
3
+ module Flappy
4
+ module IOSEnvConfig
5
+
6
+ def writeEnvToPlist(args, options)
7
+ plist_path = check_and_find_plist_file
8
+
9
+ unless plist_path.blank?
10
+ https = options[:https]
11
+ env = options[:env]
12
+ env_port = options[:port]
13
+ pay_env = options[:'pay-env']
14
+ load_env_from_plist = 'N'
15
+
16
+ if !https.blank? || !env.blank? || !env_port.blank? || !pay_env.blank?
17
+ load_env_from_plist = 'Y'
18
+ end
19
+
20
+
21
+ log_iOS('更新配置文件前')
22
+ log_iOS(`/usr/libexec/PlistBuddy -c 'Print' \"#{plist_path}\"`)
23
+
24
+ system("/usr/libexec/PlistBuddy -c 'Set :LoadConfigFromPlist #{load_env_from_plist}' \"#{plist_path}\"") unless load_env_from_plist.blank?
25
+ system("/usr/libexec/PlistBuddy -c 'Set :HTTPS #{https}' \"#{plist_path}\"") unless https.blank?
26
+ system("/usr/libexec/PlistBuddy -c 'Set :SCC_ENV:env #{env}' \"#{plist_path}\"") unless env.blank?
27
+ system("/usr/libexec/PlistBuddy -c 'Set :SCC_ENV:port #{env_port}' \"#{plist_path}\"") unless env_port.blank?
28
+ system("/usr/libexec/PlistBuddy -c 'Set :SCC_PAY_ENV:payEnv #{pay_env}' \"#{plist_path}\"") unless pay_env.blank?
29
+
30
+ log_iOS('更新配置文件后')
31
+ log_iOS(`/usr/libexec/PlistBuddy -c \"Print\" \"#{plist_path}\"`)
32
+ end
33
+ end
34
+
35
+ def check_and_find_plist_file
36
+ plist_path = ''
37
+
38
+ Dir.glob("#{@work_dir}/**/SCCURLConfigFormat.plist").each do |name|
39
+ unless File.directory?(name)
40
+ plist_path = name
41
+ end
42
+ end
43
+
44
+ if plist_path.blank?
45
+ log_iOS('No Plist Found')
46
+ else
47
+ log_iOS("Found PlistPath: #{plist_path}")
48
+ end
49
+
50
+ plist_path
51
+ end
52
+
53
+ end
54
+ end
@@ -0,0 +1,113 @@
1
+ # encoding: utf-8
2
+
3
+ module Flappy
4
+ module IOSLogger
5
+
6
+ attr_accessor :logger_iOS
7
+ attr_accessor :logger_iOS_build
8
+ attr_accessor :logger_iOS_archive
9
+ attr_accessor :logger_iOS_pod
10
+
11
+ def initialize_iOS_logger(options)
12
+ @options = options
13
+
14
+ #### common
15
+ log_file = File.open(File.join(@app_output_archive_log_path, "#{@start_time}_log.txt"), 'a')
16
+ if options[:quiet] || options[:'no-savelog']
17
+ log_file = '/dev/null' if options[:'no-savelog']
18
+ Flappy.logger_iOS = Logger.new(log_file)
19
+ else
20
+ Flappy.logger_iOS = Logger.new Flappy::MultiIO::MultiDelegator.delegate(:write, :close).to(STDOUT, log_file)
21
+ end
22
+ Flappy.logger_iOS.level = options[:verbose] ? Logger::INFO : Logger::ERROR
23
+
24
+
25
+ ##### build
26
+ log_file = File.open(File.join(@app_output_archive_log_path, "#{@start_time}_log_build.txt"), "a")
27
+ if options[:quiet] || options[:'no-savelog']
28
+ log_file = '/dev/null' if options[:'no-savelog']
29
+ Flappy.logger_iOS_build = Logger.new(log_file)
30
+ else
31
+ Flappy.logger_iOS_build = Logger.new Flappy::MultiIO::MultiDelegator.delegate(:write, :close).to(STDOUT, log_file)
32
+ end
33
+ Flappy.logger_iOS_build.level = options[:verbose] ? Logger::INFO : Logger::ERROR
34
+
35
+
36
+ ##### archive
37
+ log_file = File.open(File.join(@app_output_archive_log_path, "#{@start_time}_log_archive.txt"), "a")
38
+ if options[:quiet] || options[:'no-savelog']
39
+ log_file = '/dev/null' if options[:'no-savelog']
40
+ Flappy.logger_iOS_archive = Logger.new(log_file)
41
+ else
42
+ Flappy.logger_iOS_archive = Logger.new Flappy::MultiIO::MultiDelegator.delegate(:write, :close).to(STDOUT, log_file)
43
+ end
44
+ Flappy.logger_iOS_archive.level = options[:verbose] ? Logger::INFO : Logger::ERROR
45
+
46
+
47
+ ##### pod
48
+ log_file = File.open(File.join(@app_output_archive_log_path, "#{@start_time}_log_pod.txt"), "a")
49
+ if options[:quiet] || options[:'no-savelog']
50
+ log_file = '/dev/null' if options[:'no-savelog']
51
+ Flappy.logger_iOS_pod = Logger.new(log_file)
52
+ else
53
+ Flappy.logger_iOS_pod = Logger.new Flappy::MultiIO::MultiDelegator.delegate(:write, :close).to(STDOUT, log_file)
54
+ end
55
+ Flappy.logger_iOS_pod.level = options[:verbose] ? Logger::INFO : Logger::ERROR
56
+ end
57
+
58
+
59
+ def log_iOS(expression)
60
+ if logger_iOS.nil?
61
+ return
62
+ end
63
+ logger_iOS.info "#{expression}"
64
+ puts "#{expression}"
65
+ end
66
+
67
+ def log_iOS_build(command)
68
+ if logger_iOS_build.nil?
69
+ return
70
+ end
71
+ if @options[:quiet] || @options[:'no-savelog']
72
+ if @options[:quiet]
73
+ logger_iOS_build.info `#{command}`
74
+ else
75
+ system(command)
76
+ end
77
+ else
78
+ logger_iOS_build.info `#{command}`
79
+ end
80
+ end
81
+
82
+ def log_iOS_archive(command)
83
+ if logger_iOS_archive.nil?
84
+ return
85
+ end
86
+ if @options[:quiet] || @options[:'no-savelog']
87
+ if @options[:quiet]
88
+ logger_iOS_archive.info `#{command}`
89
+ else
90
+ system(command)
91
+ end
92
+ else
93
+ logger_iOS_archive.info `#{command}`
94
+ end
95
+ end
96
+
97
+ def log_iOS_pod(command)
98
+ if logger_iOS_pod.nil?
99
+ return
100
+ end
101
+ if @options[:quiet] || @options[:'no-savelog']
102
+ if @options[:quiet]
103
+ logger_iOS_pod.info `#{command}`
104
+ else
105
+ system(command)
106
+ end
107
+ else
108
+ logger_iOS_pod.info `#{command}`
109
+ end
110
+ end
111
+
112
+ end
113
+ end
@@ -0,0 +1,39 @@
1
+ # encoding: utf-8
2
+
3
+ module Flappy
4
+ module Info
5
+
6
+ def info(*args, options)
7
+ file_path = File.absolute_path(args.first.to_s)
8
+ is_all = !options[:all].blank?
9
+
10
+ check_file_exist file_path
11
+ check_supported_file file_path
12
+
13
+ file_type = File.extname(file_path).delete('.')
14
+
15
+ logger.info "Analyzing #{file_type} file......"
16
+ logger_info_dividing_line
17
+
18
+ app_info = send("#{file_type}_info", file_path, full_info: is_all)
19
+ app_info.each { |k, v| logger.info "#{k}: #{v}" }
20
+
21
+ logger_info_blank_line
22
+ end
23
+
24
+ # def ipa_info(ipa_path, options = {})
25
+ # ipa = FIR::Parser::Ipa.new(ipa_path)
26
+ # app = ipa.app
27
+ # info = app.full_info(options)
28
+ #
29
+ # ipa.cleanup
30
+ # info
31
+ # end
32
+
33
+ def apk_info(apk_path, options = {})
34
+ apk = Flappy::Parser::Apk.new(apk_path)
35
+ info = apk.full_info(options)
36
+ info
37
+ end
38
+ end
39
+ end