lhj-tools 0.2.21 → 0.2.23

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: 913995d83466a643c887e8ffe02fa7789b36992f53db19188711f845ad81c1e0
4
+ data.tar.gz: e21d8840c06763330eac1878bc823cac0fb678826feaea7ff76ce2c662043c06
5
5
  SHA512:
6
- metadata.gz: 3d85f58abacfc19ce29a04e413a01342878e0a554e6cd676c6d66c7086385150d61fc37a2d98bc9414f364b8d1f6059a82fed1e03df3fd8d16802009039768dd
7
- data.tar.gz: 04cac72389288dd69c0b88ed1cfa5e66a42e633829c6b2ccaf073afea1e4385fad401a35529d15d6cfd5e12ea89ef09a067ef25fddf3332b5de91f1abcc89224
6
+ metadata.gz: 8b8ea86ee8c5ffb0f40e9ee60f39d1ee73713420fa5e31462ab067c3fbc2fed1057dfaa446762bda09c379306a1095ee14abf9e06a46ed4fad6d59ba6d83ef96
7
+ data.tar.gz: 9d978201993f562cdda911ba7662ac19000f83a4b5af3e0f8e69484f6c9fec7026b4294a44a69f03e03105dfdc9d6cd7308ef691e684f4eb01eb73de2a94217d
@@ -1,4 +1,5 @@
1
1
  require 'jenkins_api_client'
2
+ require 'lhj/helper/apple/token'
2
3
 
3
4
  module Lhj
4
5
  class Command
@@ -30,11 +31,14 @@ module Lhj
30
31
  end
31
32
 
32
33
  def handle
33
- client = JenkinsApi::Client.new(server_ip: '47.97.61.232', server_port: 8080, username: 'aomi', password: '11e5ddb4c71a61abf66ed0ab4c08090794')
34
+ res = Lhj::ConnectAPI.get('https://api.appstoreconnect.apple.com/v1/apps')
35
+ puts res.read_body
36
+
37
+ # client = JenkinsApi::Client.new(server_ip: 'ip', server_port: 0, username: 'xx', password: 'xx')
34
38
  # puts client.user.get('aomi')
35
39
  # puts client.job.list_all
36
40
  # client.job.build('aomi_uat')
37
- puts client.job.get_console_output('aomi_uat', 253)
41
+ # puts client.job.get_console_output('aomi_uat', 253)
38
42
  end
39
43
  end
40
44
  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,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
@@ -0,0 +1,33 @@
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
+ end
33
+ end
data/lib/lhj/lhj.rb CHANGED
@@ -8,6 +8,7 @@ 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'
11
12
  require 'lhj/helper/pod_repo_config'
12
13
  require 'lhj/helper/git_branch_feature_config'
13
14
  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.23'
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.23
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,6 +381,8 @@ 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_jwt_config.rb
385
+ - lib/lhj/helper/apple/token.rb
384
386
  - lib/lhj/helper/bugly_helper.rb
385
387
  - lib/lhj/helper/dingtalk_config.rb
386
388
  - lib/lhj/helper/dingtalk_helper.rb