lhj-tools 0.1.11 → 0.1.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lhj/command/config/info.rb +54 -23
- data/lib/lhj/command/init.rb +12 -3
- data/lib/lhj/command/pgyer_upload.rb +20 -0
- data/lib/lhj/command/view.rb +69 -53
- data/lib/lhj/command/yapi/formatters/service.rb +13 -4
- data/lib/lhj/command/yapi/formatters/template/pgyer.erb +6 -0
- data/lib/lhj/command/yapi/formatters/template/yapi.erb +3 -3
- data/lib/lhj/command/yapi.rb +83 -16
- data/lib/lhj/command.rb +1 -0
- data/lib/lhj/config.rb +2 -0
- data/lib/lhj/helper/dingtalk_config.rb +23 -0
- data/lib/lhj/helper/dingtalk_helper.rb +14 -0
- data/lib/lhj/helper/pgyer_config.rb +31 -0
- data/lib/lhj/helper/pgyer_helper.rb +62 -0
- data/lib/lhj/helper/tb_config.rb +36 -0
- data/lib/lhj/helper/tb_helper.rb +7 -0
- data/lib/lhj/tools/version.rb +1 -1
- data/lib/lhj/tools.rb +3 -0
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d279af86ce6121812a429c8a66a5ed03aedbcd73920ced2ebe44626faf93874b
|
4
|
+
data.tar.gz: 9ac889862bddcf8a55fc8798baf6c7e4a5f8a88d4bdd22d3a14f7212b8826331
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4b04462de1a18640901b53f7ead9047ed7f2013e2cdc52682369bbd6a176426886d9f314b0caa6efcbb047ef41502a68751ba61459f263060c12ac8bfc9a983
|
7
|
+
data.tar.gz: d4f4c30604e837e07c374e491f9416db1f41bada18a62c6090c993a606953826a1f16051e8a9e32fd053e8ee29cc6f1db1b76cd22775520ce5cc25afd3d96bd8
|
@@ -3,29 +3,44 @@ require 'lhj/config'
|
|
3
3
|
|
4
4
|
module Lhj
|
5
5
|
class Command
|
6
|
+
# config
|
6
7
|
class Config < Command
|
8
|
+
def initialize(argv)
|
9
|
+
@cli = HighLine.new
|
10
|
+
super
|
11
|
+
end
|
12
|
+
|
13
|
+
def show_config
|
14
|
+
config_arr = Dir.glob("#{config_dir}/**/*.yml")
|
15
|
+
config_arr.each_index { |i| puts "#{i}.#{File.basename(config_arr[i])}".yellow }
|
16
|
+
idx = ask_which_one
|
17
|
+
config_file = config_arr[idx]
|
18
|
+
handle_yaml(config_file)
|
19
|
+
end
|
20
|
+
|
21
|
+
def handle_yaml(file)
|
22
|
+
'子类实现'
|
23
|
+
end
|
24
|
+
|
25
|
+
def handle
|
26
|
+
show_config
|
27
|
+
end
|
28
|
+
|
29
|
+
def config_dir
|
30
|
+
Lhj::Config.instance.home_dir
|
31
|
+
end
|
32
|
+
|
33
|
+
def print_table(title, table_rows)
|
34
|
+
table = Terminal::Table.new title: title, headings: %w[键 值], rows: table_rows
|
35
|
+
puts table
|
36
|
+
end
|
37
|
+
|
7
38
|
# show config info
|
8
39
|
class Info < Config
|
9
40
|
self.summary = '查看配置信息'
|
10
41
|
|
11
|
-
def initialize(argv)
|
12
|
-
@cli = HighLine.new
|
13
|
-
super
|
14
|
-
end
|
15
|
-
|
16
|
-
def handle
|
17
|
-
show_config
|
18
|
-
end
|
19
|
-
|
20
|
-
def show_config
|
21
|
-
config_arr = Dir.glob("#{config_dir}/**/*.yml")
|
22
|
-
config_arr.each_index { |i| puts "#{i}.#{File.basename(config_arr[i])}".yellow }
|
23
|
-
idx = ask_which_one
|
24
|
-
config_file = config_arr[idx]
|
25
|
-
show_yaml(config_file)
|
26
|
-
end
|
27
42
|
|
28
|
-
def
|
43
|
+
def handle_yaml(file)
|
29
44
|
table_rows = []
|
30
45
|
content = YAML.load_file(file)
|
31
46
|
|
@@ -49,17 +64,33 @@ module Lhj
|
|
49
64
|
print_table(title, table_rows) if table_rows.count.positive?
|
50
65
|
end
|
51
66
|
|
52
|
-
def
|
53
|
-
|
54
|
-
puts table
|
67
|
+
def ask_which_one
|
68
|
+
@cli.ask('查看哪个配置: '.green).strip.to_i
|
55
69
|
end
|
70
|
+
end
|
71
|
+
|
72
|
+
class Update < Config
|
56
73
|
|
57
74
|
def ask_which_one
|
58
|
-
@cli.ask('
|
75
|
+
@cli.ask('更新哪个配置: '.green).strip.to_i
|
59
76
|
end
|
60
77
|
|
61
|
-
def
|
62
|
-
|
78
|
+
def handle_yaml(file)
|
79
|
+
table_rows = []
|
80
|
+
content = YAML.load_file(file)
|
81
|
+
|
82
|
+
if content.is_a?(Hash)
|
83
|
+
content.each do |key, value|
|
84
|
+
table_rows << [key, value]
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
title = File.basename(file).to_s
|
89
|
+
print_table(title, table_rows) if table_rows.count.positive?
|
90
|
+
|
91
|
+
cmd = ['open']
|
92
|
+
cmd << file
|
93
|
+
Actions.sh(cmd.join(' '))
|
63
94
|
end
|
64
95
|
end
|
65
96
|
end
|
data/lib/lhj/command/init.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'faraday'
|
2
3
|
require 'faraday_middleware'
|
3
4
|
require 'net/http'
|
@@ -23,7 +24,10 @@ module Lhj
|
|
23
24
|
|
24
25
|
def validate!
|
25
26
|
super
|
26
|
-
|
27
|
+
unless @url
|
28
|
+
path = File.join(target_folder, 'config_file.yml')
|
29
|
+
help! '配置url必须输入' unless File.exist?(path)
|
30
|
+
end
|
27
31
|
end
|
28
32
|
|
29
33
|
def initialize(argv)
|
@@ -33,8 +37,13 @@ module Lhj
|
|
33
37
|
|
34
38
|
def handle
|
35
39
|
FileUtils.mkdir_p(target_folder) unless File.exist?(target_folder)
|
36
|
-
|
37
|
-
|
40
|
+
if @url
|
41
|
+
file_path = file_name_from_url(@url)
|
42
|
+
File.delete(file_path) if File.exist?(file_path)
|
43
|
+
save_url_to_file(@url, file_path)
|
44
|
+
else
|
45
|
+
file_path = File.join(target_folder, 'config_file.yml')
|
46
|
+
end
|
38
47
|
content = YAML.load_file(file_path)
|
39
48
|
download_file(content) if content.is_a?(Array)
|
40
49
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'lhj/helper/pgyer_helper'
|
2
|
+
require 'lhj/helper/dingtalk_config'
|
3
|
+
require 'lhj/helper/pgyer_config'
|
4
|
+
require 'lhj/helper/tb_config'
|
5
|
+
|
6
|
+
|
7
|
+
module Lhj
|
8
|
+
class Command
|
9
|
+
class Pgyer < Command
|
10
|
+
|
11
|
+
def handle
|
12
|
+
client = Lhj::Pgyer.new
|
13
|
+
file = File.expand_path('/Users/lihaijian/**/*.ipa')
|
14
|
+
client.upload_file(file, 'test....')
|
15
|
+
output = client.render_template
|
16
|
+
puts output.blue
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/lhj/command/view.rb
CHANGED
@@ -47,102 +47,118 @@ module Lhj
|
|
47
47
|
print_value
|
48
48
|
end
|
49
49
|
|
50
|
+
def puts_d(str)
|
51
|
+
puts str.blue
|
52
|
+
end
|
53
|
+
|
54
|
+
def puts_i(str)
|
55
|
+
puts str.blue
|
56
|
+
end
|
57
|
+
|
58
|
+
def puts_l(str)
|
59
|
+
puts str.blue
|
60
|
+
end
|
61
|
+
|
62
|
+
def puts_v(str)
|
63
|
+
puts str.blue
|
64
|
+
end
|
65
|
+
|
50
66
|
def print_declare
|
51
67
|
names.each do |name|
|
52
|
-
|
53
|
-
|
68
|
+
puts_d '///'
|
69
|
+
puts_d "@property (nonatomic, strong) #{type} *#{name};"
|
54
70
|
end
|
55
71
|
end
|
56
72
|
|
57
73
|
def print_instance
|
58
74
|
names.each do |name|
|
59
|
-
|
60
|
-
|
61
|
-
|
75
|
+
puts_i "-(#{type} *)#{name}"
|
76
|
+
puts_i '{'
|
77
|
+
puts_i " if(!_#{name}){"
|
62
78
|
print_alloc(name)
|
63
|
-
|
79
|
+
puts_i " _#{name}.translatesAutoresizingMaskIntoConstraints = NO;"
|
64
80
|
print_property(name)
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
81
|
+
puts_i ' }'
|
82
|
+
puts_i " return _#{name};"
|
83
|
+
puts_i '}'
|
84
|
+
puts_i "\n"
|
69
85
|
end
|
70
86
|
end
|
71
87
|
|
72
88
|
def print_alloc(name)
|
73
89
|
case type
|
74
90
|
when 'UIImageView'
|
75
|
-
|
91
|
+
puts_i " _#{name} = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@\"xxxx\"]];"
|
76
92
|
when 'UIButton'
|
77
|
-
|
93
|
+
puts_i " _#{name} = [UIButton buttonWithType:UIButtonTypeCustom];"
|
78
94
|
when 'UITableView'
|
79
|
-
|
95
|
+
puts_i " _#{name} = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];"
|
80
96
|
else
|
81
|
-
|
97
|
+
puts_i " _#{name} = [[#{type} alloc] init];"
|
82
98
|
end
|
83
99
|
end
|
84
100
|
|
85
101
|
def print_property(name)
|
86
102
|
case type
|
87
103
|
when 'UILabel'
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
104
|
+
puts_i " _#{name}.textColor = kSetCOLOR(0x333333);"
|
105
|
+
puts_i " _#{name}.text = @\"xxxxxxxx\";"
|
106
|
+
puts_i " _#{name}.font = [UIFont systemFontOfSize:12.0 weight:UIFontWeightRegular];"
|
107
|
+
puts_i " _#{name}.textAlignment = NSTextAlignmentCenter;"
|
92
108
|
when 'UIImageView'
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
109
|
+
puts_i " _#{name}.backgroundColor = kBackgroundColor;"
|
110
|
+
puts_i " _#{name}.contentMode = UIViewContentModeScaleAspectFit;"
|
111
|
+
puts_i " _#{name}.clipsToBounds = YES;"
|
112
|
+
puts_i " _#{name}.layer.cornerRadius = 6.0f;"
|
113
|
+
puts_i " _#{name}.layer.borderColor = kLineColor.CGColor;"
|
114
|
+
puts_i " _#{name}.layer.borderWidth = 0.5;"
|
99
115
|
when 'UITextField'
|
100
|
-
|
101
|
-
|
116
|
+
puts_i " _#{name}.textColor = kSetCOLOR(0x333333);"
|
117
|
+
puts_i " _#{name}.font = [UIFont systemFontOfSize:12.0 weight:UIFontWeightRegular];"
|
102
118
|
when 'UIView'
|
103
|
-
|
119
|
+
puts_i " _#{name}.backgroundColor = kBackgroundColor;"
|
104
120
|
when 'UIStackView'
|
105
|
-
|
106
|
-
|
121
|
+
puts_i " _#{name}.axis = UILayoutConstraintAxisHorizontal;"
|
122
|
+
puts_i " _#{name}.distribution = UIStackViewDistributionFillEqually;"
|
107
123
|
when 'UITableView'
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
124
|
+
puts_i " _#{name}.backgroundColor = kBackgroundColor;"
|
125
|
+
puts_i " _#{name}.delegate = self;"
|
126
|
+
puts_i " _#{name}.delegate = self;"
|
127
|
+
puts_i " _#{name}.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, CGFLOAT_MIN)];"
|
128
|
+
puts_i " _#{name}.tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, CGFLOAT_MIN)];"
|
129
|
+
puts_i " _#{name}.separatorStyle = UITableViewCellSeparatorStyleNone;"
|
114
130
|
when 'UIButton'
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
131
|
+
puts_i " _#{name}.backgroundColor = kBackgroundColor;"
|
132
|
+
puts_i " [_#{name} setTitle:@\"xxx\" forState:UIControlStateNormal];"
|
133
|
+
puts_i " [_#{name} setTitleColor:kSetCOLOR(0x999999) forState:UIControlStateNormal];"
|
134
|
+
puts_i " _#{name}.titleLabel.font = [UIFont systemFontOfSize:14.0 weight:UIFontWeightRegular];"
|
135
|
+
puts_i " [_#{name} setImage:[UIImage imageNamed:@\"xx\"] forState:UIControlStateNormal];"
|
136
|
+
puts_i " [_#{name} setImage:[UIImage imageNamed:@\"xx\"] forState:UIControlStateSelected];"
|
137
|
+
puts_i " [_#{name} addTarget:self action:@selector(actionHandler:) forControlEvents:UIControlEventTouchUpInside];"
|
122
138
|
end
|
123
139
|
end
|
124
140
|
|
125
141
|
def print_layout
|
126
142
|
names.each do |name|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
143
|
+
puts_l "[contentView addSubview:self.#{name}];"
|
144
|
+
puts_l "[self.#{name}.leadingAnchor constraintEqualToAnchor:contentView.leadingAnchor constant:0].active = YES;"
|
145
|
+
puts_l "[self.#{name}.trailingAnchor constraintEqualToAnchor:contentView.trailingAnchor constant:0].active = YES;"
|
146
|
+
puts_l "[self.#{name}.topAnchor constraintEqualToAnchor:contentView.topAnchor].active = YES;"
|
147
|
+
puts_l "[self.#{name}.bottomAnchor constraintEqualToAnchor:contentView.bottomAnchor].active = YES;"
|
148
|
+
puts_l "[self.#{name}.widthAnchor constraintEqualToConstant:80].active = YES;"
|
149
|
+
puts_l "[self.#{name}.heightAnchor constraintEqualToConstant:80].active = YES;"
|
134
150
|
if type.eql?('UILabel')
|
135
|
-
|
136
|
-
|
151
|
+
puts_l "[self.#{name} setContentHuggingPriority:300 forAxis:UILayoutConstraintAxisHorizontal];"
|
152
|
+
puts_l "[self.#{name} setContentCompressionResistancePriority:300 forAxis:UILayoutConstraintAxisHorizontal];"
|
137
153
|
end
|
138
|
-
|
154
|
+
puts_l "\n\n"
|
139
155
|
end
|
140
156
|
end
|
141
157
|
|
142
158
|
def print_value
|
143
159
|
names.each do |name|
|
144
160
|
if type.eql?('UILabel')
|
145
|
-
|
161
|
+
puts_v "self.#{name}.text = @\"xxxxx\";"
|
146
162
|
end
|
147
163
|
end
|
148
164
|
end
|
@@ -8,14 +8,23 @@ module Lhj
|
|
8
8
|
class Service < Base
|
9
9
|
# @param [String] name
|
10
10
|
def render(name = 'yapi')
|
11
|
-
|
11
|
+
temp_str = template_str(name)
|
12
|
+
render_template(temp_str)
|
12
13
|
end
|
13
14
|
|
14
|
-
def
|
15
|
+
def render_template(temp_str)
|
16
|
+
template(temp_str).result(Context.new(@runner).fetch_binding)
|
17
|
+
end
|
18
|
+
|
19
|
+
def template_str(name)
|
20
|
+
File.read(File.join(File.dirname(__FILE__), 'template', "#{name}.erb"))
|
21
|
+
end
|
22
|
+
|
23
|
+
def template(template_str)
|
15
24
|
if RUBY_VERSION < '2.6'
|
16
|
-
ERB.new(
|
25
|
+
ERB.new(template_str, nil, '-')
|
17
26
|
else
|
18
|
-
ERB.new(
|
27
|
+
ERB.new(template_str, trim_mode: '-')
|
19
28
|
end
|
20
29
|
end
|
21
30
|
end
|
@@ -0,0 +1,6 @@
|
|
1
|
+
#### 应用名称:<%= @result['data']['appName'] %>
|
2
|
+
#### 版本信息:<%= @result['data']['appVersion'] %>(Build <%= @result['data']['appBuildVersion'] %>)
|
3
|
+
#### 更新时间:<%= @result['data']['appCreated'] %>
|
4
|
+
#### 更新内容:<%= @result['data']['appUpdateDescription'] %>
|
5
|
+
> ![screenshot](<%= @result['data']['appQRCodeURL'] %>)
|
6
|
+
> [下载](https://www.pgyer.com/<%= @result['data']['appShortcutUrl'] %>)
|
@@ -5,21 +5,21 @@
|
|
5
5
|
static NSString * const <%= @path_key %> = @"<%= @path %>";
|
6
6
|
|
7
7
|
<% if @method == 'GET' -%>
|
8
|
-
+(void)get<%= @path_name %>:(<%= @param_model_name %> *)param callback:(void (^)(
|
8
|
+
+(void)get<%= @path_name %>:(<%= @param_model_name %> *)param callback:(void (^)(<% unless @result_model_name.empty? -%><%= @result_model_name %> *model, <% end -%>MLResponseMessage *response))callback
|
9
9
|
{
|
10
10
|
[MLNetworkingManager getWithUrl:<%= @path_key %> params:params response:^(MLResponseMessage *responseMessage) {
|
11
11
|
<%= @model_template %>
|
12
12
|
}];
|
13
13
|
}
|
14
14
|
<% elsif @method == 'JSON' -%>
|
15
|
-
+(void)postJson<%= @path_name %>:(<%= @param_model_name %> *)param callback:(void (^)(
|
15
|
+
+(void)postJson<%= @path_name %>:(<%= @param_model_name %> *)param callback:(void (^)(<% unless @result_model_name.empty? -%><%= @result_model_name %> *model, <% end -%>MLResponseMessage *response))callback
|
16
16
|
{
|
17
17
|
[MLNetworkingManager requestJsonWithUrl:<%= @path_key %> httpMedth:kRequestMethodPOST params:param response:^(MLResponseMessage *responseMessage) {
|
18
18
|
<%= @model_template %>
|
19
19
|
}];
|
20
20
|
}
|
21
21
|
<% else -%>
|
22
|
-
+(void)
|
22
|
+
+(void)post<%= @path_name %>:(<%= @param_model_name %> *)param callback:(void (^)(<% unless @result_model_name.empty? -%><%= @result_model_name %> *model, <% end -%>MLResponseMessage *response))callback
|
23
23
|
{
|
24
24
|
[MLNetworkingManager postWithUrl:<%= @path_key %> params:params response:^(MLResponseMessage *response) {
|
25
25
|
<%= @model_template %>
|
data/lib/lhj/command/yapi.rb
CHANGED
@@ -24,6 +24,7 @@ module Lhj
|
|
24
24
|
@model_pre_name = argv.option('model-pre')
|
25
25
|
@save = argv.flag?('save', false)
|
26
26
|
@debug = argv.flag?('debug', false)
|
27
|
+
@language = argv.option('lan', 'oc')
|
27
28
|
@http_url = ''
|
28
29
|
@http_headers = []
|
29
30
|
@config_id = ''
|
@@ -59,7 +60,11 @@ module Lhj
|
|
59
60
|
def process(config_file)
|
60
61
|
load_config(config_file)
|
61
62
|
res_body = req_api_model
|
62
|
-
|
63
|
+
unless res_body['errcode'].to_i.zero?
|
64
|
+
puts '请修改 ~/.lhj/yapi.yml文件的对应的__wpkreporterwid_,_yapi_token,_yapi_uid这三个值'.red
|
65
|
+
return
|
66
|
+
end
|
67
|
+
return unless res_body && !res_body.empty?
|
63
68
|
|
64
69
|
# 1.print request result
|
65
70
|
print_res_body_model(res_body)
|
@@ -163,8 +168,13 @@ module Lhj
|
|
163
168
|
handle_model(res_body) do |model|
|
164
169
|
models << model
|
165
170
|
end
|
166
|
-
|
167
|
-
|
171
|
+
case @language
|
172
|
+
when 'oc'
|
173
|
+
print_models(models)
|
174
|
+
print_models_impl(models)
|
175
|
+
when 'java'
|
176
|
+
print_models_for_java(models)
|
177
|
+
end
|
168
178
|
@result_model_name = models.last[:name]
|
169
179
|
puts "\n<===============打印返回数据模型-End=====================>\n".green
|
170
180
|
end
|
@@ -178,8 +188,13 @@ module Lhj
|
|
178
188
|
handle_model(req_body) do |model|
|
179
189
|
models << model
|
180
190
|
end
|
181
|
-
|
182
|
-
|
191
|
+
case @language
|
192
|
+
when 'oc'
|
193
|
+
print_models(models)
|
194
|
+
print_models_impl(models)
|
195
|
+
when 'java'
|
196
|
+
print_models_for_java(models)
|
197
|
+
end
|
183
198
|
@param_model_name = models.last[:name]
|
184
199
|
puts "\n<===============打印请求模型-End=====================>\n".green
|
185
200
|
end
|
@@ -260,11 +275,23 @@ module Lhj
|
|
260
275
|
end
|
261
276
|
end
|
262
277
|
|
278
|
+
def print_models_for_java(models)
|
279
|
+
models.each do |model|
|
280
|
+
model_name = model[:name] || ''
|
281
|
+
model_properties = model[:properties]
|
282
|
+
puts_h "public class #{model_name} extends BaseModel implements BusinessEvent.ProductDataCollect {"
|
283
|
+
model_properties.each do |m|
|
284
|
+
print_model_for_java(m)
|
285
|
+
end
|
286
|
+
puts_h "}\n\n\n"
|
287
|
+
end
|
288
|
+
end
|
289
|
+
|
263
290
|
def print_models_impl(models)
|
264
291
|
models.each do |model|
|
265
292
|
puts_m "@implementation #{model[:name]}"
|
266
293
|
str = model[:properties].filter { |p| p[:type].eql?('array') && !p[:type_name].eql?('NSString') }.map { |p| "@\"#{p[:key]}\": #{p[:type_name]}.class" }.join(', ')
|
267
|
-
if str
|
294
|
+
if str&.length&.positive?
|
268
295
|
puts_m '+(NSDictionary *)modelContainerPropertyGenericClass {'
|
269
296
|
puts_m " return @{#{str}};"
|
270
297
|
puts_m '}'
|
@@ -310,18 +337,54 @@ module Lhj
|
|
310
337
|
end
|
311
338
|
end
|
312
339
|
|
340
|
+
def print_model_for_java(m)
|
341
|
+
key = m[:key]
|
342
|
+
type_name = m[:type_name]
|
343
|
+
type = m[:type]
|
344
|
+
des = m[:description] || ''
|
345
|
+
des.gsub!(/\n/, ' ')
|
346
|
+
default = m[:default]
|
347
|
+
case type
|
348
|
+
when 'integer'
|
349
|
+
puts_h "int #{key};//#{des} #{default}"
|
350
|
+
when 'cent'
|
351
|
+
puts_h "int #{key};//#{des} #{default}"
|
352
|
+
when 'string'
|
353
|
+
puts_h "String #{key};//#{des} #{default}"
|
354
|
+
when 'number'
|
355
|
+
puts_h "double #{key};//#{des} #{default}"
|
356
|
+
when 'float'
|
357
|
+
puts_h "double #{key};//#{des} #{default}"
|
358
|
+
when 'double'
|
359
|
+
puts_h "double #{key};//#{des} #{default}"
|
360
|
+
when 'boolean'
|
361
|
+
puts_h "boolean #{key};//#{des} #{default}"
|
362
|
+
when 'object'
|
363
|
+
puts_h "#{type_name} #{key};//#{des} #{default}"
|
364
|
+
when 'array'
|
365
|
+
puts_h "#{type_name}[] #{key};//#{des} #{default}"
|
366
|
+
else
|
367
|
+
puts_h "String #{key};//#{des} #{default}"
|
368
|
+
end
|
369
|
+
end
|
370
|
+
|
313
371
|
# @param [Object] data
|
314
372
|
def print_req_query(data)
|
315
373
|
return unless data && data['req_query']
|
316
374
|
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
375
|
+
case @language
|
376
|
+
when 'oc'
|
377
|
+
puts_h '@interface MLParamModel : NSObject'
|
378
|
+
data['req_query'].each do |h|
|
379
|
+
des = h['desc']
|
380
|
+
puts_h "///#{des} #{h['example']}"
|
381
|
+
puts_h "@property (nonatomic, copy) NSString *#{h['name']};"
|
382
|
+
end
|
383
|
+
puts_h '@end'
|
384
|
+
puts "\n\n"
|
385
|
+
when 'java'
|
322
386
|
end
|
323
|
-
|
324
|
-
puts "\n\n"
|
387
|
+
@param_model_name = 'MLParamModel' if @param_model_name.empty?
|
325
388
|
end
|
326
389
|
|
327
390
|
def print_http_method(data)
|
@@ -335,9 +398,13 @@ module Lhj
|
|
335
398
|
@method = 'JSON' if data['req_body_is_json_schema']
|
336
399
|
@path_name = @path.split('/').map { |s| s.gsub(/[^A-Za-z0-9]/, '').gsub(/^\w/) { $&.upcase } }.join('') if @path
|
337
400
|
@path_key = "k#{@path_name}URL"
|
338
|
-
|
339
|
-
|
340
|
-
|
401
|
+
case @language
|
402
|
+
when 'oc'
|
403
|
+
puts "\n<===============方法调用=====================>\n".green
|
404
|
+
@model_template = Lhj::ErbFormatter::Service.new(self).render('model')
|
405
|
+
puts Lhj::ErbFormatter::Service.new(self).render('yapi').blue
|
406
|
+
when 'java'
|
407
|
+
end
|
341
408
|
end
|
342
409
|
end
|
343
410
|
end
|
data/lib/lhj/command.rb
CHANGED
data/lib/lhj/config.rb
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'yaml'
|
3
|
+
require 'lhj/config'
|
4
|
+
|
5
|
+
module Lhj
|
6
|
+
# Ding Talk Config
|
7
|
+
class DingTalkConfig
|
8
|
+
|
9
|
+
CONFIG_NAME = 'dingtalk_config.yml'
|
10
|
+
|
11
|
+
def self.config_file
|
12
|
+
File.join(Lhj::Config.instance.home_dir, CONFIG_NAME)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.config
|
16
|
+
@yaml ||= YAML.load_file(config_file)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.dingtalk_robot
|
20
|
+
config['dingtalk_robot']
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'lhj/helper/dingtalk_config'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module Lhj
|
5
|
+
# pgyer upload
|
6
|
+
class Dingtalk
|
7
|
+
|
8
|
+
def self.post_message(title, message)
|
9
|
+
robot_url = Lhj::DingTalkConfig.dingtalk_robot
|
10
|
+
http_body = { 'msgtype' => 'markdown', 'markdown' => { 'title' => title, 'text' => message } }.to_json
|
11
|
+
Net::HTTP.post(URI(robot_url), http_body, 'Content-Type' => 'application/json')
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'yaml'
|
3
|
+
require 'lhj/config'
|
4
|
+
|
5
|
+
module Lhj
|
6
|
+
# pgyer config
|
7
|
+
class PgyerConfig
|
8
|
+
|
9
|
+
CONFIG_NAME = 'pgyer_config.yml'
|
10
|
+
|
11
|
+
def self.config_file
|
12
|
+
File.join(Lhj::Config.instance.home_dir, CONFIG_NAME)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.config
|
16
|
+
@yaml ||= YAML.load_file(config_file)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.api_key
|
20
|
+
config['api_key']
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.user_key
|
24
|
+
config['user_key']
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.password
|
28
|
+
config['password']
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'faraday_middleware'
|
3
|
+
require 'lhj/helper/pgyer_config'
|
4
|
+
require 'lhj/command/yapi/formatters/service'
|
5
|
+
require 'lhj/config'
|
6
|
+
|
7
|
+
module Lhj
|
8
|
+
# pgyer upload
|
9
|
+
class Pgyer
|
10
|
+
|
11
|
+
API_HOST = 'https://upload.pgyer.com/apiv1/app/upload'.freeze
|
12
|
+
|
13
|
+
attr_reader :api_key, :user_key, :password, :result
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
@api_key = Lhj::PgyerConfig.api_key
|
17
|
+
@user_key = Lhj::PgyerConfig.user_key
|
18
|
+
@password = Lhj::PgyerConfig.password
|
19
|
+
@result = { 'data' => {} }
|
20
|
+
end
|
21
|
+
|
22
|
+
# @return [Faraday::Connection]
|
23
|
+
def http_client
|
24
|
+
conn_options = {
|
25
|
+
request: {
|
26
|
+
timeout: 1000,
|
27
|
+
open_timeout: 300
|
28
|
+
}
|
29
|
+
}
|
30
|
+
Faraday.new(nil, conn_options) do |builder|
|
31
|
+
builder.request :multipart
|
32
|
+
builder.request :url_encoded
|
33
|
+
builder.response :json, content_type: /\bjson$/
|
34
|
+
builder.adapter :net_http
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def upload_file(file, des)
|
39
|
+
params = {
|
40
|
+
'_api_key' => @api_key,
|
41
|
+
'uKey' => @user_key,
|
42
|
+
'password' => @password,
|
43
|
+
'updateDescription' => des,
|
44
|
+
'installType' => 2,
|
45
|
+
'file' => Faraday::UploadIO.new(file, 'application/octet-stream')
|
46
|
+
}
|
47
|
+
begin
|
48
|
+
puts 'begin upload'
|
49
|
+
response = http_client.post API_HOST, params
|
50
|
+
@result = response.body
|
51
|
+
puts ''
|
52
|
+
rescue Faraday::TimeoutError
|
53
|
+
puts 'upload fail'
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def render_template
|
58
|
+
temp_str = File.read(File.join(Lhj::Config.instance.home_dir, 'pgyer.erb'))
|
59
|
+
Lhj::ErbFormatter::Service.new(self).render_template(temp_str)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'yaml'
|
3
|
+
require 'lhj/config'
|
4
|
+
|
5
|
+
module Lhj
|
6
|
+
# tb config
|
7
|
+
class TBConfig
|
8
|
+
|
9
|
+
CONFIG_NAME = 'tb_config.yml'
|
10
|
+
|
11
|
+
def self.config_file
|
12
|
+
File.join(Lhj::Config.instance.home_dir, CONFIG_NAME)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.config
|
16
|
+
@yaml ||= YAML.load_file(config_file)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.tb_app_id
|
20
|
+
config['tb_app_id']
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.tb_app_key
|
24
|
+
config['tb_app_key']
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.tb_tenant_id
|
28
|
+
config['tb_tenant_id']
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.projectId
|
32
|
+
config['projectId']
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
data/lib/lhj/tools/version.rb
CHANGED
data/lib/lhj/tools.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lhj-tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- lihaijian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: claide
|
@@ -289,6 +289,7 @@ files:
|
|
289
289
|
- lib/lhj/command/oss/del.rb
|
290
290
|
- lib/lhj/command/oss/list.rb
|
291
291
|
- lib/lhj/command/oss/upload.rb
|
292
|
+
- lib/lhj/command/pgyer_upload.rb
|
292
293
|
- lib/lhj/command/refactor_rename.rb
|
293
294
|
- lib/lhj/command/rename_image.rb
|
294
295
|
- lib/lhj/command/reverse_import.rb
|
@@ -301,11 +302,18 @@ files:
|
|
301
302
|
- lib/lhj/command/yapi/formatters/command_context.rb
|
302
303
|
- lib/lhj/command/yapi/formatters/service.rb
|
303
304
|
- lib/lhj/command/yapi/formatters/template/model.erb
|
305
|
+
- lib/lhj/command/yapi/formatters/template/pgyer.erb
|
304
306
|
- lib/lhj/command/yapi/formatters/template/yapi.erb
|
305
307
|
- lib/lhj/config.rb
|
308
|
+
- lib/lhj/helper/dingtalk_config.rb
|
309
|
+
- lib/lhj/helper/dingtalk_helper.rb
|
306
310
|
- lib/lhj/helper/local_config.rb
|
307
311
|
- lib/lhj/helper/oss_config.rb
|
308
312
|
- lib/lhj/helper/oss_helper.rb
|
313
|
+
- lib/lhj/helper/pgyer_config.rb
|
314
|
+
- lib/lhj/helper/pgyer_helper.rb
|
315
|
+
- lib/lhj/helper/tb_config.rb
|
316
|
+
- lib/lhj/helper/tb_helper.rb
|
309
317
|
- lib/lhj/helper/trans_helper.rb
|
310
318
|
- lib/lhj/tools.rb
|
311
319
|
- lib/lhj/tools/version.rb
|