lhj-tools 0.2.20 → 0.2.23

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: 69527af7e6d31836627134b3476c1edb79e592cc1563618470fc9555c2a9278a
4
- data.tar.gz: bb04571a3ea807688bc5c740eac5ff7002fb8482e62a1aab26a4bdecb9a2996a
3
+ metadata.gz: 913995d83466a643c887e8ffe02fa7789b36992f53db19188711f845ad81c1e0
4
+ data.tar.gz: e21d8840c06763330eac1878bc823cac0fb678826feaea7ff76ce2c662043c06
5
5
  SHA512:
6
- metadata.gz: 1ca7a1305f8c7409180e51b9d844e64f082fc798ce9cec6dc4e751dae395699da10e2e6024ea284819fe98e356ebc1046dbfd73b3a24e729dc678a966b3423ff
7
- data.tar.gz: 25e245b12c8ab42bf98e317cb5c61c6842729cbef8460386c2e6543f54c2f160e88cb7dcf0da237b12da245cd427148e0ed7a3913996804287bacab33c36ddea
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.20'
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.20
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-13 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
@@ -252,16 +252,16 @@ dependencies:
252
252
  name: json
253
253
  requirement: !ruby/object:Gem::Requirement
254
254
  requirements:
255
- - - "<"
255
+ - - '='
256
256
  - !ruby/object:Gem::Version
257
- version: 3.0.0
257
+ version: 2.3.0
258
258
  type: :runtime
259
259
  prerelease: false
260
260
  version_requirements: !ruby/object:Gem::Requirement
261
261
  requirements:
262
- - - "<"
262
+ - - '='
263
263
  - !ruby/object:Gem::Version
264
- version: 3.0.0
264
+ version: 2.3.0
265
265
  - !ruby/object:Gem::Dependency
266
266
  name: bundler
267
267
  requirement: !ruby/object:Gem::Requirement
@@ -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