lhj-tools 0.1.6 → 0.1.10
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/lib/lhj/action/sh_helper.rb +138 -0
- data/lib/lhj/command/config/info.rb +67 -0
- data/lib/lhj/command/config.rb +11 -0
- data/lib/lhj/command/file_path.rb +20 -0
- data/lib/lhj/command/head_import.rb +19 -3
- data/lib/lhj/command/http.rb +14 -0
- data/lib/lhj/command/init.rb +38 -16
- data/lib/lhj/command/local/fetch.rb +1 -1
- data/lib/lhj/command/local/filter.rb +1 -1
- data/lib/lhj/command/local/local.rb +1 -1
- data/lib/lhj/command/local/local_upload.rb +1 -1
- data/lib/lhj/command/local/micro_service.rb +1 -1
- data/lib/lhj/command/oss/del.rb +1 -1
- data/lib/lhj/command/oss/list.rb +1 -1
- data/lib/lhj/command/oss/upload.rb +1 -1
- data/lib/lhj/command/refactor_rename.rb +1 -1
- data/lib/lhj/command/rename_image.rb +1 -1
- data/lib/lhj/command/sync_pod_repo.rb +153 -0
- data/lib/lhj/command/trans.rb +1 -1
- data/lib/lhj/command/yapi/formatters/base.rb +15 -0
- data/lib/lhj/command/yapi/formatters/command_context.rb +23 -0
- data/lib/lhj/command/yapi/formatters/service.rb +23 -0
- data/lib/lhj/command/yapi.rb +136 -98
- data/lib/lhj/command.rb +27 -5
- data/lib/lhj/tools/version.rb +1 -1
- data/lib/lhj/tools.rb +1 -0
- data/lib/lhj/tree/hash_walker.rb +1 -1
- data/lib/lhj/tree/path_walker.rb +1 -2
- data/lib/lhj/tree/tree.rb +5 -5
- data/lib/lhj/ui/errors/lhj_common_error.rb +19 -0
- data/lib/lhj/ui/errors/lhj_crash.rb +11 -0
- data/lib/lhj/ui/errors/lhj_error.rb +25 -0
- data/lib/lhj/ui/errors/lhj_exception.rb +19 -0
- data/lib/lhj/ui/errors/lhj_shell_error.rb +11 -0
- data/lib/lhj/ui/errors.rb +1 -0
- data/lib/lhj/ui/implementations/shell.rb +148 -0
- data/lib/lhj/ui/interface.rb +205 -0
- data/lib/lhj/ui/ui.rb +26 -0
- metadata +54 -2
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Lhj
|
4
|
+
module ErbFormatter
|
5
|
+
# context
|
6
|
+
class Context
|
7
|
+
def initialize(target)
|
8
|
+
@target = target
|
9
|
+
end
|
10
|
+
|
11
|
+
def fetch_binding
|
12
|
+
@target.instance_eval { binding }.tap do |bind|
|
13
|
+
decorate_binding(bind)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# 空方法
|
18
|
+
def decorate_binding(bind)
|
19
|
+
bind.eval('save = 1')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'erb'
|
2
|
+
require_relative 'base'
|
3
|
+
require_relative 'command_context'
|
4
|
+
|
5
|
+
module Lhj
|
6
|
+
module ErbFormatter
|
7
|
+
# service
|
8
|
+
class Service < Base
|
9
|
+
# @param [String] name
|
10
|
+
def render(name = 'yapi')
|
11
|
+
template(name).result(Context.new(@runner).fetch_binding)
|
12
|
+
end
|
13
|
+
|
14
|
+
def template(name)
|
15
|
+
if RUBY_VERSION < '2.6'
|
16
|
+
ERB.new(File.read(File.join(File.dirname(__FILE__), 'template', "#{name}.erb")), nil, '-')
|
17
|
+
else
|
18
|
+
ERB.new(File.read(File.join(File.dirname(__FILE__), 'template', "#{name}.erb")), trim_mode: '-')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/lhj/command/yapi.rb
CHANGED
@@ -2,9 +2,11 @@ require 'net/https'
|
|
2
2
|
require 'uri'
|
3
3
|
require 'json'
|
4
4
|
require 'yaml'
|
5
|
+
require 'lhj/command/yapi/formatters/service'
|
5
6
|
|
6
7
|
module Lhj
|
7
8
|
class Command
|
9
|
+
# generate model from yapi
|
8
10
|
class Yapi < Command
|
9
11
|
self.summary = '通过yapi接口生成请求'
|
10
12
|
self.description = '更新 ~/.lhj/yapi.yml 文件配置后执行`lhj api`生成接口模型'
|
@@ -21,23 +23,53 @@ module Lhj
|
|
21
23
|
@id = argv.option('id')
|
22
24
|
@model_pre_name = argv.option('model-pre')
|
23
25
|
@save = argv.flag?('save', false)
|
26
|
+
@debug = argv.flag?('debug', false)
|
24
27
|
@http_url = ''
|
25
28
|
@http_headers = []
|
26
|
-
@data_json = {}
|
27
|
-
@models = []
|
28
29
|
@config_id = ''
|
29
30
|
@config_model_pre = 'ML'
|
30
31
|
@model_default_suffix = 'Model'
|
31
32
|
@type_trans = {}
|
32
33
|
@config_model_names = []
|
33
34
|
@model_names = []
|
35
|
+
# <<<===== model for template
|
36
|
+
@result_model_name = ''
|
37
|
+
@param_model_name = ''
|
38
|
+
@model_template = ''
|
39
|
+
@desc = ''
|
40
|
+
@path = ''
|
41
|
+
@path_name = ''
|
42
|
+
@path_key = ''
|
43
|
+
@method = 'GET'
|
44
|
+
@title = ''
|
45
|
+
@username = ''
|
46
|
+
@req_body_is_json_schema = false
|
47
|
+
# =====>>>
|
34
48
|
super
|
35
49
|
end
|
36
50
|
|
37
|
-
def
|
38
|
-
|
39
|
-
|
40
|
-
|
51
|
+
def begin_title
|
52
|
+
'读取配置文件~/.lhj/yapi.yml'
|
53
|
+
end
|
54
|
+
|
55
|
+
def handle
|
56
|
+
process(yml_file) if File.exist?(yml_file)
|
57
|
+
end
|
58
|
+
|
59
|
+
def process(config_file)
|
60
|
+
load_config(config_file)
|
61
|
+
res_body = req_api_model
|
62
|
+
return unless res_body && res_body['errcode'].to_i.zero? && !res_body.empty?
|
63
|
+
|
64
|
+
# 1.print request result
|
65
|
+
print_res_body_model(res_body)
|
66
|
+
# 2.print request json body
|
67
|
+
print_req_body_model(res_body)
|
68
|
+
# 3.print request param
|
69
|
+
print_req_query(res_body['data'])
|
70
|
+
# 4.print request method
|
71
|
+
print_http_method(res_body['data'])
|
72
|
+
# 5.save to file
|
41
73
|
save_to_file if @save
|
42
74
|
end
|
43
75
|
|
@@ -49,13 +81,19 @@ module Lhj
|
|
49
81
|
end
|
50
82
|
|
51
83
|
def puts_h(str)
|
52
|
-
puts str
|
84
|
+
puts str.magenta
|
85
|
+
@h_file_array ||= []
|
86
|
+
@h_file_array << str
|
87
|
+
end
|
88
|
+
|
89
|
+
def puts_h_red(str)
|
90
|
+
puts str.red
|
53
91
|
@h_file_array ||= []
|
54
92
|
@h_file_array << str
|
55
93
|
end
|
56
94
|
|
57
95
|
def puts_m(str)
|
58
|
-
puts str
|
96
|
+
puts str.blue
|
59
97
|
@m_file_array ||= []
|
60
98
|
@m_file_array << str
|
61
99
|
end
|
@@ -65,20 +103,23 @@ module Lhj
|
|
65
103
|
file_name = gen_model_name('')
|
66
104
|
h_file = File.join('.', "#{file_name}.h")
|
67
105
|
m_file = File.join('.', "#{file_name}.m")
|
68
|
-
File.write(h_file, @h_file_array.join("\n")) if @h_file_array.count
|
69
|
-
File.write(m_file, @m_file_array.join("\n")) if @m_file_array.count
|
70
|
-
puts "\n\n生成文件成功!所在路径:\n#{File.expand_path(h_file)} \n#{File.expand_path(m_file)}"
|
106
|
+
File.write(h_file, @h_file_array.join("\n")) if @h_file_array.count.positive?
|
107
|
+
File.write(m_file, @m_file_array.join("\n")) if @m_file_array.count.positive?
|
108
|
+
puts "\n\n生成文件成功!所在路径:\n#{File.expand_path(h_file)} \n#{File.expand_path(m_file)}".green
|
71
109
|
end
|
72
110
|
|
73
111
|
def url_str
|
74
112
|
"#{@http_url}#{api_id}"
|
75
113
|
end
|
76
114
|
|
77
|
-
def
|
78
|
-
|
79
|
-
|
115
|
+
def yml_file
|
116
|
+
File.join(Lhj::Config.instance.home_dir, 'yapi.yml')
|
117
|
+
end
|
118
|
+
|
119
|
+
def load_config(file)
|
120
|
+
config = YAML.load_file(file)
|
80
121
|
config.each do |k, v|
|
81
|
-
@http_headers << "#{k}=#{v}" if
|
122
|
+
@http_headers << "#{k}=#{v}" if k.eql?('__wpkreporterwid_') || k.eql?('_yapi_token') || k.eql?('_yapi_uid')
|
82
123
|
end
|
83
124
|
@http_url = config['url']
|
84
125
|
@config_id = config['id']
|
@@ -100,79 +141,81 @@ module Lhj
|
|
100
141
|
@config_model_suffix || @model_default_suffix
|
101
142
|
end
|
102
143
|
|
103
|
-
def
|
144
|
+
def req_api_model
|
104
145
|
uri = URI.parse(url_str)
|
105
146
|
req = Net::HTTP::Get.new(uri)
|
106
147
|
req['Cookie'] = @http_headers.join('; ')
|
107
148
|
res = Net::HTTP.start(uri.hostname, uri.port) do |http|
|
108
149
|
http.request(req)
|
109
150
|
end
|
110
|
-
|
111
|
-
|
151
|
+
res_json = JSON.parse(res.body)
|
152
|
+
puts res.body unless res_json['errcode'].to_i.zero?
|
153
|
+
puts res.body if @debug
|
154
|
+
res_json
|
112
155
|
end
|
113
156
|
|
114
|
-
def
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
157
|
+
def print_res_body_model(res_json)
|
158
|
+
res_body = fetch_res_boy(res_json)
|
159
|
+
return unless res_body
|
160
|
+
|
161
|
+
puts "\n<===============打印返回数据模型-Begin=====================>\n".green
|
162
|
+
models = []
|
163
|
+
handle_model(res_body) do |model|
|
164
|
+
models << model
|
122
165
|
end
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
166
|
+
print_models(models)
|
167
|
+
print_models_impl(models)
|
168
|
+
@result_model_name = models.last[:name]
|
169
|
+
puts "\n<===============打印返回数据模型-End=====================>\n".green
|
170
|
+
end
|
171
|
+
|
172
|
+
def print_req_body_model(res_json)
|
173
|
+
req_body = fetch_req_body(res_json)
|
174
|
+
return unless req_body
|
175
|
+
|
176
|
+
puts "\n<===============打印请求模型-Begin=====================>\n".green
|
177
|
+
models = []
|
178
|
+
handle_model(req_body) do |model|
|
179
|
+
models << model
|
131
180
|
end
|
181
|
+
print_models(models)
|
182
|
+
print_models_impl(models)
|
183
|
+
@param_model_name = models.last[:name]
|
184
|
+
puts "\n<===============打印请求模型-End=====================>\n".green
|
132
185
|
end
|
133
186
|
|
134
187
|
def fetch_res_boy(res_json)
|
135
|
-
if res_json
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
end
|
146
|
-
end
|
147
|
-
end
|
188
|
+
return if !res_json || !res_json['data'] || !res_json['data']['res_body']
|
189
|
+
|
190
|
+
res_body = JSON.parse(res_json['data']['res_body'])
|
191
|
+
return if !res_body['properties'] || !res_body['properties']['detailMsg']
|
192
|
+
|
193
|
+
result = res_body['properties']['detailMsg']
|
194
|
+
return unless result['type'] == 'object' || result['type'] == 'array'
|
195
|
+
|
196
|
+
result['name'] = gen_model_name('')
|
197
|
+
result
|
148
198
|
end
|
149
199
|
|
150
200
|
def fetch_req_body(res_json)
|
151
|
-
if res_json
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
res_body['name'] = gen_model_name('')
|
157
|
-
handle_model(res_body)
|
158
|
-
rescue => ex
|
159
|
-
puts ex
|
160
|
-
end
|
161
|
-
end
|
162
|
-
end
|
201
|
+
return if !res_json || !res_json['data'] || !res_json['data']['req_body_other']
|
202
|
+
|
203
|
+
result = JSON.parse(res_json['data']['req_body_other'])
|
204
|
+
result['name'] = gen_model_name('')
|
205
|
+
result
|
163
206
|
end
|
164
207
|
|
165
208
|
def gen_model_name(name)
|
166
209
|
n = name.gsub(/vo|model|list/i, '').gsub(/(.*)s$/, '\1').gsub(/^\w/) { $&.upcase }
|
167
210
|
if n.length <= 0
|
168
|
-
n = @config_model_names.detect { |c|
|
211
|
+
n = @config_model_names.detect { |c| @model_names.none? { |na| na.gsub(/#{model_pre}(.*)Model/, '\1').eql?(c) } }
|
169
212
|
end
|
170
213
|
model_name = "#{model_pre}#{n}#{model_suffix}"
|
171
214
|
@model_names << model_name
|
172
215
|
model_name
|
173
216
|
end
|
174
217
|
|
175
|
-
def handle_model(model)
|
218
|
+
def handle_model(model, &block)
|
176
219
|
p_type = model['type']
|
177
220
|
p_name = model['name']
|
178
221
|
p_properties = model['properties']
|
@@ -191,22 +234,22 @@ module Lhj
|
|
191
234
|
c_model[:type_name] = 'NSString'
|
192
235
|
else
|
193
236
|
c_model[:type_name] = o['name']
|
194
|
-
handle_model(o)
|
237
|
+
handle_model(o, &block)
|
195
238
|
end
|
196
239
|
end
|
197
240
|
properties << c_model
|
198
241
|
end
|
199
242
|
p_model[:properties] = properties
|
200
|
-
|
243
|
+
block[p_model] if block_given?
|
201
244
|
when 'array'
|
202
245
|
t = model['items']
|
203
246
|
t['name'] = p_name
|
204
|
-
handle_model(t)
|
247
|
+
handle_model(t, &block)
|
205
248
|
end
|
206
249
|
end
|
207
250
|
|
208
|
-
def print_models
|
209
|
-
|
251
|
+
def print_models(models)
|
252
|
+
models.each do |model|
|
210
253
|
model_name = model[:name] || ''
|
211
254
|
model_properties = model[:properties]
|
212
255
|
puts_h "@interface #{model_name} : NSObject"
|
@@ -217,11 +260,11 @@ module Lhj
|
|
217
260
|
end
|
218
261
|
end
|
219
262
|
|
220
|
-
def
|
221
|
-
|
263
|
+
def print_models_impl(models)
|
264
|
+
models.each do |model|
|
222
265
|
puts_m "@implementation #{model[:name]}"
|
223
266
|
str = model[:properties].filter { |p| p[:type].eql?('array') && !p[:type_name].eql?('NSString') }.map { |p| "@\"#{p[:key]}\": #{p[:type_name]}.class" }.join(', ')
|
224
|
-
if str && str.length
|
267
|
+
if str && str.length.positive?
|
225
268
|
puts_m '+(NSDictionary *)modelContainerPropertyGenericClass {'
|
226
269
|
puts_m " return @{#{str}};"
|
227
270
|
puts_m '}'
|
@@ -242,9 +285,9 @@ module Lhj
|
|
242
285
|
case type
|
243
286
|
when 'integer'
|
244
287
|
puts_h "@property (nonatomic, assign) NSInteger #{key};"
|
245
|
-
if des.include?('分')
|
246
|
-
|
247
|
-
|
288
|
+
if des.include?('分') || des.include?('0.01')
|
289
|
+
puts_h_red '/////////==========删掉其中一个属性'
|
290
|
+
puts_h_red "@property (nonatomic, strong) MLCentNumber *#{key};"
|
248
291
|
end
|
249
292
|
when 'cent'
|
250
293
|
puts_h "@property (nonatomic, strong) MLCentNumber *#{key};"
|
@@ -267,39 +310,34 @@ module Lhj
|
|
267
310
|
end
|
268
311
|
end
|
269
312
|
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
puts_m ' */'
|
275
|
-
key_str = @data_json['path'].split('/').map { |s| s.gsub(/[^A-Za-z0-9]/, '').gsub(/^\w/) { $&.upcase } }.join('')
|
276
|
-
key = "k#{key_str}URL"
|
277
|
-
puts_m "static NSString * const #{key} = @\"#{@data_json['path']}\";"
|
278
|
-
puts_m "\n\n"
|
313
|
+
# @param [Object] data
|
314
|
+
def print_req_query(data)
|
315
|
+
return unless data && data['req_query']
|
316
|
+
|
279
317
|
puts_h '@interface MLParamModel : NSObject'
|
280
|
-
|
318
|
+
data['req_query'].each do |h|
|
281
319
|
des = h['desc']
|
282
320
|
puts_h "///#{des} #{h['example']}"
|
283
321
|
puts_h "@property (nonatomic, copy) NSString *#{h['name']};"
|
284
322
|
end
|
285
323
|
puts_h '@end'
|
286
324
|
puts "\n\n"
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
325
|
+
end
|
326
|
+
|
327
|
+
def print_http_method(data)
|
328
|
+
return unless data
|
329
|
+
|
330
|
+
@path = data['path']
|
331
|
+
@method = data['method']
|
332
|
+
@title = data['title']
|
333
|
+
@username = data['username']
|
334
|
+
@desc = data['desc']
|
335
|
+
@method = 'JSON' if data['req_body_is_json_schema']
|
336
|
+
@path_name = @path.split('/').map { |s| s.gsub(/[^A-Za-z0-9]/, '').gsub(/^\w/) { $&.upcase } }.join('') if @path
|
337
|
+
@path_key = "k#{@path_name}URL"
|
338
|
+
puts "\n<===============方法调用=====================>\n".green
|
339
|
+
@model_template = Lhj::ErbFormatter::Service.new(self).render('model')
|
340
|
+
puts Lhj::ErbFormatter::Service.new(self).render('yapi').blue
|
303
341
|
end
|
304
342
|
end
|
305
343
|
end
|
data/lib/lhj/command.rb
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
require 'claide'
|
2
2
|
require "tty-spinner"
|
3
|
+
require 'lhj/action/sh_helper'
|
4
|
+
require 'lhj/ui/ui'
|
3
5
|
|
4
6
|
module Lhj
|
5
7
|
# command plugin
|
6
8
|
class Command < CLAide::Command
|
7
9
|
require 'lhj/command/init'
|
10
|
+
require 'lhj/command/config'
|
8
11
|
require 'lhj/command/head_import'
|
9
12
|
require 'lhj/command/refactor_rename'
|
10
13
|
require 'lhj/command/local/fetch'
|
@@ -20,21 +23,40 @@ module Lhj
|
|
20
23
|
require 'lhj/command/rename_image'
|
21
24
|
require 'lhj/command/trans'
|
22
25
|
require 'lhj/command/yapi'
|
26
|
+
require 'lhj/command/file_path'
|
27
|
+
require 'lhj/command/http'
|
28
|
+
require 'lhj/command/sync_pod_repo'
|
23
29
|
|
24
30
|
self.abstract_command = true
|
25
31
|
self.command = 'lhj'
|
26
32
|
|
27
|
-
def
|
28
|
-
|
33
|
+
def begin_title
|
34
|
+
'开始处理...'
|
29
35
|
end
|
30
36
|
|
31
37
|
def auto_spin
|
32
|
-
|
33
|
-
|
38
|
+
puts begin_title.green
|
39
|
+
# @spinner.auto_spin
|
34
40
|
end
|
35
41
|
|
36
42
|
def stop
|
37
|
-
|
43
|
+
puts '处理完成'.green
|
44
|
+
# @spinner.success('Done!')
|
45
|
+
end
|
46
|
+
|
47
|
+
def initialize(argv)
|
48
|
+
super(argv)
|
49
|
+
@spinner = TTY::Spinner.new('[:spinner]...', output: $stdout, format: :dots, clear: true)
|
50
|
+
end
|
51
|
+
|
52
|
+
def run
|
53
|
+
auto_spin
|
54
|
+
handle
|
55
|
+
stop
|
56
|
+
end
|
57
|
+
|
58
|
+
def handle
|
59
|
+
raise 'A subclass should override the `Lhj::Command#run` method'
|
38
60
|
end
|
39
61
|
|
40
62
|
end
|
data/lib/lhj/tools/version.rb
CHANGED
data/lib/lhj/tools.rb
CHANGED
data/lib/lhj/tree/hash_walker.rb
CHANGED
data/lib/lhj/tree/path_walker.rb
CHANGED
data/lib/lhj/tree/tree.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
require_relative 'node'
|
4
|
+
require_relative 'directory_renderer'
|
5
|
+
require_relative 'number_renderer'
|
6
|
+
require_relative 'hash_walker'
|
7
|
+
require_relative 'path_walker'
|
8
8
|
|
9
9
|
module Lhj
|
10
10
|
class Tree
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require_relative 'lhj_exception'
|
2
|
+
|
3
|
+
module Lhj
|
4
|
+
class Interface
|
5
|
+
# Super class for exception types that we do not want to record
|
6
|
+
# explicitly as crashes or user errors
|
7
|
+
class LhjCommonException < LhjException; end
|
8
|
+
|
9
|
+
# Raised when there is a build failure in xcodebuild
|
10
|
+
class LhjBuildFailure < LhjCommonException; end
|
11
|
+
|
12
|
+
# Raised when a test fails when being run by tools such as scan or snapshot
|
13
|
+
class LhjTestFailure < LhjCommonException; end
|
14
|
+
|
15
|
+
# Raise this type of exception when a failure caused by a third party
|
16
|
+
# dependency (i.e. xcodebuild, gradle, slather) happens.
|
17
|
+
class LhjDependencyCausedException < LhjCommonException; end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require_relative 'lhj_exception'
|
2
|
+
|
3
|
+
module Lhj
|
4
|
+
class Interface
|
5
|
+
class LhjError < LhjException
|
6
|
+
attr_reader :show_github_issues
|
7
|
+
attr_reader :error_info
|
8
|
+
|
9
|
+
def initialize(show_github_issues: false, error_info: nil)
|
10
|
+
@show_github_issues = show_github_issues
|
11
|
+
@error_info = error_info
|
12
|
+
end
|
13
|
+
|
14
|
+
def prefix
|
15
|
+
'[USER_ERROR]'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class Exception
|
22
|
+
# def fastlane_should_report_metrics?
|
23
|
+
# return false
|
24
|
+
# end
|
25
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Lhj
|
2
|
+
class Interface
|
3
|
+
class LhjException < StandardError
|
4
|
+
def prefix
|
5
|
+
'[LHJ_EXCEPTION]'
|
6
|
+
end
|
7
|
+
|
8
|
+
def caused_by_calling_ui_method?(method_name: nil)
|
9
|
+
return false if backtrace.nil? || backtrace[0].nil? || method_name.nil?
|
10
|
+
first_frame = backtrace[0]
|
11
|
+
if first_frame.include?(method_name) && first_frame.include?('interface.rb')
|
12
|
+
true
|
13
|
+
else
|
14
|
+
false
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
Dir[File.dirname(__FILE__) + "/errors/*.rb"].each { |f| require_relative f }
|