lhj-tools 0.2.21 → 0.2.24

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5d92373d88f6e90f29c2308e3fbe6fd42903d5c7947f42828fbec672443b3b1c
4
- data.tar.gz: '09ed5835f82cd5637fdf7b2c14e472f0db006f6ba27d2eff64573b8c1d8b0826'
3
+ metadata.gz: 253e532b62ca8fd6c1b10281d9dfc87cb2f1a40abbd185f66066abc72b7cd72d
4
+ data.tar.gz: 3b67e5cfb736805d1b078b72efe4cab2d8f28848c77e8b3d049fbf6dfc227648
5
5
  SHA512:
6
- metadata.gz: 3d85f58abacfc19ce29a04e413a01342878e0a554e6cd676c6d66c7086385150d61fc37a2d98bc9414f364b8d1f6059a82fed1e03df3fd8d16802009039768dd
7
- data.tar.gz: 04cac72389288dd69c0b88ed1cfa5e66a42e633829c6b2ccaf073afea1e4385fad401a35529d15d6cfd5e12ea89ef09a067ef25fddf3332b5de91f1abcc89224
6
+ metadata.gz: f23ae53bdd2047b055f1baec787b67a21684b42f23f1004c503ebcfc157670fd6d09c58f774a7a3fad374371ae474b534cc616835da73ea53595a40047fa321f
7
+ data.tar.gz: 7ddab83f382970b112d558ec7b410def3530281cc321dc3f77af73d5c342ade9f600779870e9ced7bfe78c6d3c6c15c58d205e4b1ef3a5f0c34f2f013258f5f3
@@ -30,11 +30,34 @@ module Lhj
30
30
  end
31
31
 
32
32
  def handle
33
- client = JenkinsApi::Client.new(server_ip: '47.97.61.232', server_port: 8080, username: 'aomi', password: '11e5ddb4c71a61abf66ed0ab4c08090794')
33
+ d = {
34
+ "data": {
35
+ "attributes": {
36
+ "email": "878943972@qq.com",
37
+ "firstName": "li",
38
+ "lastName": "haijian"
39
+ },
40
+ "relationships": {
41
+ "builds": {
42
+ "data": [
43
+ {
44
+ "id": "0cd7ac82-b2d9-4772-bfa1-0ff6e8037f7d",
45
+ "type": "builds"
46
+ }
47
+ ]
48
+ }
49
+ },
50
+ "type": "betaTesters"
51
+ }
52
+ }
53
+ res = Lhj::ConnectAPI.post('https://api.appstoreconnect.apple.com/v1/betaTesters', d)
54
+ puts res.read_body
55
+
56
+ # client = JenkinsApi::Client.new(server_ip: 'ip', server_port: 0, username: 'xx', password: 'xx')
34
57
  # puts client.user.get('aomi')
35
58
  # puts client.job.list_all
36
59
  # client.job.build('aomi_uat')
37
- puts client.job.get_console_output('aomi_uat', 253)
60
+ # puts client.job.get_console_output('aomi_uat', 253)
38
61
  end
39
62
  end
40
63
  end
@@ -66,7 +66,7 @@ module Lhj
66
66
  end
67
67
  end
68
68
  unless res_body['errcode'].to_i.zero?
69
- puts '请执行 lhj yapi-init 初始化配置'.red
69
+ Actions.sh('lhj yapi-init', log: false)
70
70
  return
71
71
  end
72
72
  return unless res_body && !res_body.empty?
@@ -0,0 +1,48 @@
1
+ require 'jwt'
2
+ require 'openssl'
3
+
4
+ module Lhj
5
+ class ConnectAPI
6
+
7
+ def self.token
8
+ key_file = File.binread(Lhj::AppleJWTConfig.private_key_file)
9
+ key = OpenSSL::PKey::EC.new(key_file)
10
+ expiration = Time.now + 500
11
+ header = { kid: Lhj::AppleJWTConfig.key_id }
12
+ payload = {
13
+ iss: Lhj::AppleJWTConfig.issuer_id,
14
+ exp: expiration.to_i,
15
+ aud: 'appstoreconnect-v1'
16
+ }
17
+ JWT.encode(payload, key, 'ES256', header)
18
+ end
19
+
20
+ def self.get(url)
21
+ uri = URI(url)
22
+
23
+ https = Net::HTTP.new(uri.host, uri.port)
24
+ https.use_ssl = true
25
+
26
+ request = Net::HTTP::Get.new(uri)
27
+ jwt_token = token
28
+ request['authorization'] = "Bearer #{jwt_token}"
29
+
30
+ https.request(request)
31
+ end
32
+
33
+ def self.post(url, data = {})
34
+ uri = URI(url)
35
+
36
+ https = Net::HTTP.new(uri.host, uri.port)
37
+ https.use_ssl = true
38
+
39
+ request = Net::HTTP::Post.new(uri)
40
+ jwt_token = token
41
+ request['authorization'] = "Bearer #{jwt_token}"
42
+ request['Content-Type'] = 'application/json'
43
+ request.body = JSON.dump(data)
44
+
45
+ https.request(request)
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+ require 'yaml'
3
+
4
+ module Lhj
5
+ # Apple jwt Config
6
+ class AppleJWTConfig
7
+
8
+ CONFIG_NAME = 'apple_jwt_config.yml'
9
+
10
+ def self.config_file
11
+ File.join(Lhj::Config.instance.home_dir, CONFIG_NAME)
12
+ end
13
+
14
+ def self.config
15
+ @yaml ||= YAML.load_file(config_file)
16
+ end
17
+
18
+ def self.login_email
19
+ config['login_email']
20
+ end
21
+
22
+ def self.login_password
23
+ config['login_password']
24
+ end
25
+
26
+ def self.issuer_id
27
+ config['issuer_id']
28
+ end
29
+
30
+ def self.key_id
31
+ config['key_id']
32
+ end
33
+
34
+ def self.private_key
35
+ config['private_key']
36
+ end
37
+
38
+ def self.private_key_url
39
+ config['private_key_url']
40
+ end
41
+
42
+ def self.private_key_file
43
+ File.expand_path(File.join(Lhj::Config.instance.home_dir, "AuthKey_#{key_id}.p8"))
44
+ end
45
+ end
46
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  module Lhj
3
4
  # bugly helper
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+ require 'yaml'
3
+
4
+ module Lhj
5
+ # chat gpt Config
6
+ class ChatGptConfig
7
+
8
+ CONFIG_NAME = 'chat_gpt_config.yml'
9
+
10
+ def self.config_file
11
+ File.join(Lhj::Config.instance.home_dir, CONFIG_NAME)
12
+ end
13
+
14
+ def self.config
15
+ @yaml ||= YAML.load_file(config_file)
16
+ end
17
+
18
+ def self.api_key(idx)
19
+ i = idx % config.length
20
+ config[i]['api_key']
21
+ end
22
+
23
+ def self.org_id(idx)
24
+ i = idx % config.length
25
+ config[i]['org_id']
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+ require 'yaml'
3
+
4
+ module Lhj
5
+ # ios Robot Config
6
+ class IOSRobotConfig
7
+
8
+ CONFIG_NAME = 'robot_notify_config.yml'
9
+
10
+ def self.config_file
11
+ File.join(Lhj::Config.instance.home_dir, CONFIG_NAME)
12
+ end
13
+
14
+ def self.config
15
+ @yaml ||= YAML.load_file(config_file)
16
+ end
17
+
18
+ def self.fetch_robot_url(conversation)
19
+ url = config[0]['robot_url']
20
+ robot = config.find { |r| r['conversation_title'].eql?(conversation) } if conversation
21
+ url = robot['robot_url'] if robot && robot['robot_url']
22
+ url
23
+ end
24
+
25
+ def self.fetch_robot_title(conversation)
26
+ title = '信息来自iOS机器人'
27
+ robot = config.find { |r| r['conversation_title'].eql?(conversation) } if conversation
28
+ title = robot['message_title'] if robot && robot['message_title']
29
+ title
30
+ end
31
+
32
+ def self.fetch_robot_message_type(conversation)
33
+ type = :markdown
34
+ robot = config.find { |r| r['conversation_title'].eql?(conversation) } if conversation
35
+ type = :text if robot && robot['message_type'] && robot['message_type'].eql?('text')
36
+ type
37
+ end
38
+ end
39
+ end
data/lib/lhj/lhj.rb CHANGED
@@ -8,6 +8,10 @@ module Lhj
8
8
  require 'lhj/ui/ui'
9
9
  require 'lhj/config'
10
10
  require 'lhj/helper/jenkins_config'
11
+ require 'lhj/helper/apple/apple_jwt_config'
12
+ require 'lhj/helper/apple/apple_connect_api'
13
+ require 'lhj/helper/ios_robot_config'
14
+ require 'lhj/helper/chat_gpt_config'
11
15
  require 'lhj/helper/pod_repo_config'
12
16
  require 'lhj/helper/git_branch_feature_config'
13
17
  require 'lhj/helper/erb_template_helper'
data/lib/lhj/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Lhj
4
- VERSION = '0.2.21'
4
+ VERSION = '0.2.24'
5
5
  end
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.2.21
4
+ version: 0.2.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - lihaijian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-14 00:00:00.000000000 Z
11
+ date: 2023-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xcodeproj
@@ -381,12 +381,16 @@ files:
381
381
  - lib/lhj/config.rb
382
382
  - lib/lhj/env.rb
383
383
  - lib/lhj/helper/app_version_info.rb
384
+ - lib/lhj/helper/apple/apple_connect_api.rb
385
+ - lib/lhj/helper/apple/apple_jwt_config.rb
384
386
  - lib/lhj/helper/bugly_helper.rb
387
+ - lib/lhj/helper/chat_gpt_config.rb
385
388
  - lib/lhj/helper/dingtalk_config.rb
386
389
  - lib/lhj/helper/dingtalk_helper.rb
387
390
  - lib/lhj/helper/erb_template_helper.rb
388
391
  - lib/lhj/helper/git_branch_feature_config.rb
389
392
  - lib/lhj/helper/git_helper.rb
393
+ - lib/lhj/helper/ios_robot_config.rb
390
394
  - lib/lhj/helper/jenkins_config.rb
391
395
  - lib/lhj/helper/local_config.rb
392
396
  - lib/lhj/helper/log_helper.rb