lhj-tools 0.1.13 → 0.1.16

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: 9899645c85f8e5b8b2163954f95949dafaa7be4730ae80cf8db25a9a9a1523a3
4
- data.tar.gz: bdbb99bb2a141216e287f856d54c8f812e29fa45133ffd0af54374f48dada496
3
+ metadata.gz: 17511d36f2ccbd99a885442c54373a7a032cc014552855a33b2c326dccf34688
4
+ data.tar.gz: ba65a5faa5f83e351935bdb7a7f0b221bd8ea405f1788acd2c29e85d2d0d6fe6
5
5
  SHA512:
6
- metadata.gz: 145eecc8706741b98073e87390c56a818e718f13e7ea6cd7f8b0aafc2c346f5b219ca075c1516db22cb438cb52cf5c2210f5ebd5c51f12ae9dabdc5db979c6aa
7
- data.tar.gz: 83d61d33a01c96d897227e692b60ef2c56d920172193f8d9754daa2db47b7a0edc5ea8f4ea1bf26a623d110e4066b11509b7676075b4d03dd100895246eb43d3
6
+ metadata.gz: 4396cb85f10adeb732be7038d061b3188536e4a47113d5426ee9e2c02a35f4271562a2c6655c3c8773ec7633a976c9f51310a9640fca0a37b79848749cc9cf7a
7
+ data.tar.gz: b401b9f5e196b7ed835bce7bb363876203b3f987b6314517b5f168b15d20d25cf64082b7b18ab3c2c1c10bffd12fa45100678234975a07f4160c1b5bbd476ed3
@@ -39,6 +39,7 @@ module Lhj
39
39
  FileUtils.mkdir_p(target_folder) unless File.exist?(target_folder)
40
40
  if @url
41
41
  file_path = file_name_from_url(@url)
42
+ File.delete(file_path) if File.exist?(file_path)
42
43
  save_url_to_file(@url, file_path)
43
44
  else
44
45
  file_path = File.join(target_folder, 'config_file.yml')
@@ -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
@@ -8,14 +8,23 @@ module Lhj
8
8
  class Service < Base
9
9
  # @param [String] name
10
10
  def render(name = 'yapi')
11
- template(name).result(Context.new(@runner).fetch_binding)
11
+ temp_str = template_str(name)
12
+ render_template(temp_str)
12
13
  end
13
14
 
14
- def template(name)
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(File.read(File.join(File.dirname(__FILE__), 'template', "#{name}.erb")), nil, '-')
25
+ ERB.new(template_str, nil, '-')
17
26
  else
18
- ERB.new(File.read(File.join(File.dirname(__FILE__), 'template', "#{name}.erb")), trim_mode: '-')
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'] %>)
@@ -279,7 +279,7 @@ module Lhj
279
279
  models.each do |model|
280
280
  model_name = model[:name] || ''
281
281
  model_properties = model[:properties]
282
- puts_h "public class #{model_name} extends BaseModel implements BusinessEvent.PorductDataCollect {"
282
+ puts_h "public class #{model_name} extends BaseModel implements BusinessEvent.ProductDataCollect {"
283
283
  model_properties.each do |m|
284
284
  print_model_for_java(m)
285
285
  end
@@ -291,7 +291,7 @@ module Lhj
291
291
  models.each do |model|
292
292
  puts_m "@implementation #{model[:name]}"
293
293
  str = model[:properties].filter { |p| p[:type].eql?('array') && !p[:type_name].eql?('NSString') }.map { |p| "@\"#{p[:key]}\": #{p[:type_name]}.class" }.join(', ')
294
- if str && str.length.positive?
294
+ if str&.length&.positive?
295
295
  puts_m '+(NSDictionary *)modelContainerPropertyGenericClass {'
296
296
  puts_m " return @{#{str}};"
297
297
  puts_m '}'
@@ -364,7 +364,7 @@ module Lhj
364
364
  when 'array'
365
365
  puts_h "#{type_name}[] #{key};//#{des} #{default}"
366
366
  else
367
- puts_h "@property (nonatomic, copy) NSString *#{key};//#{des} #{default}"
367
+ puts_h "String #{key};//#{des} #{default}"
368
368
  end
369
369
  end
370
370
 
data/lib/lhj/command.rb CHANGED
@@ -26,6 +26,7 @@ module Lhj
26
26
  require 'lhj/command/file_path'
27
27
  require 'lhj/command/http'
28
28
  require 'lhj/command/sync_pod_repo'
29
+ require 'lhj/command/pgyer_upload'
29
30
 
30
31
  self.abstract_command = true
31
32
  self.command = 'lhj'
@@ -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
@@ -0,0 +1,7 @@
1
+ require 'lhj/helper/tb_config'
2
+
3
+ module Lhj
4
+ # pgyer upload
5
+ class Tb
6
+ end
7
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Lhj
4
4
  module Tools
5
- VERSION = "0.1.13"
5
+ VERSION = "0.1.16"
6
6
  end
7
7
  end
data/lib/lhj/tools.rb CHANGED
@@ -4,6 +4,9 @@ require 'colored'
4
4
 
5
5
  module Lhj
6
6
  require 'lhj/config'
7
+ require 'lhj/helper/pgyer_helper'
8
+ require 'lhj/helper/dingtalk_helper'
9
+
7
10
  class Error < StandardError; end
8
11
 
9
12
  autoload :Command, 'lhj/command'
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.13
4
+ version: 0.1.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - lihaijian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-07 00:00:00.000000000 Z
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