asca 0.1.0 → 0.1.1

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: eb99fd99b67a5d8440d6aa5cdc76e1a5b2626f1791a552a997e739639c2cef24
4
- data.tar.gz: b6f522bd18d8cec13379bbe6cb5dd12eb7bea4d33df66c9536aee2f9c2cf95f0
3
+ metadata.gz: bc9b810b18682238d1c5f99d0a623e99463e9160adc17d785b9fa63212dd0f0b
4
+ data.tar.gz: 0d735db64772cde9d62c447fe1e7dd60f7c19b26472b6168d75b5d05992278e7
5
5
  SHA512:
6
- metadata.gz: 5662fe1aa8eea3b3b60d78f95f4dbe83faf5b514c435c7718da8a7502ff2e9dbd8b739ccd29f611a017cca5495f38c8eedc0cfc14f6408c28b737d8f05b8cb9b
7
- data.tar.gz: 811fed53802b08427f50dc1d5b365d403b05afcc5522dc366b3fb3425ebb70abbce13fb0673132dc1cb05af5004d4ee19925524514c21e594e3d4594a80864c5
6
+ metadata.gz: b7435d44fe5e5f51b17e5694b1e1014079b7261e646bfa4717ebf2db8a695b04151e6bab12030819325fe781b9abe8e4f75676803dca3a2a4d3f6c669a70f826
7
+ data.tar.gz: 04b5f0cbe2485bf6a3f3b04253c0629ea5e3860efe02de6c1f8614e11d2642b3ed925d0ca7aee8bf642bba4740b1654b5b4f45d92ec8569537e27942b16cacac
data/.gitignore CHANGED
@@ -6,3 +6,4 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ *.gem
@@ -2,18 +2,39 @@ PATH
2
2
  remote: .
3
3
  specs:
4
4
  asca (0.1.0)
5
- curb
5
+ http
6
6
  json
7
7
  jwt
8
8
 
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- curb (0.9.10)
12
+ addressable (2.7.0)
13
+ public_suffix (>= 2.0.2, < 5.0)
14
+ domain_name (0.5.20190701)
15
+ unf (>= 0.0.5, < 1.0.0)
16
+ ffi (1.13.1)
17
+ ffi-compiler (1.0.1)
18
+ ffi (>= 1.0.0)
19
+ rake
20
+ http (4.4.1)
21
+ addressable (~> 2.3)
22
+ http-cookie (~> 1.0)
23
+ http-form_data (~> 2.2)
24
+ http-parser (~> 1.2.0)
25
+ http-cookie (1.0.3)
26
+ domain_name (~> 0.5)
27
+ http-form_data (2.3.0)
28
+ http-parser (1.2.1)
29
+ ffi-compiler (>= 1.0, < 2.0)
13
30
  json (2.3.1)
14
31
  jwt (2.2.2)
15
32
  minitest (5.14.1)
33
+ public_suffix (4.0.5)
16
34
  rake (10.5.0)
35
+ unf (0.1.4)
36
+ unf_ext
37
+ unf_ext (0.0.7.7)
17
38
 
18
39
  PLATFORMS
19
40
  ruby
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Asca
2
2
 
3
+ [![GitHub license](https://img.shields.io/github/license/xueminghao/appstoreconnectapi)](https://github.com/xueminghao/appstoreconnectapi/blob/master/LICENSE.txt)
4
+ [![npm](https://img.shields.io/npm/v/asca)](https://rubygems.org/gems/asca)
5
+
3
6
  An apple app store connect api wrapper based on ruby!!!
4
7
 
5
8
  Why ruby?
@@ -8,13 +11,27 @@ Every mac's ready for ruby out of the box!!!
8
11
 
9
12
  ## Installation
10
13
 
11
- Add this line to your application's Gemfile:
14
+ Install from rubygem.org
12
15
 
13
- ```ruby
16
+ ``` sh
17
+ gem install asca
18
+ ```
19
+
20
+ Install from github
21
+
22
+ ``` sh
14
23
  gem install specific_install
15
24
  gem specific_install https://github.com/xueminghao/appstoreconnectapi.git
16
25
  ```
17
26
 
27
+ ## What you need
28
+
29
+ 1. App store connect key id
30
+ 1. App store connect issuer ID
31
+ 1. App store connect private key
32
+
33
+ For more details for how and where to get these info, you can refer to the [App Store Connect API](https://developer.apple.com/documentation/appstoreconnectapi/generating_tokens_for_api_requests)
34
+
18
35
  ## Usage
19
36
 
20
37
  * Download provisioning files by name from developer account
@@ -31,6 +31,6 @@ Gem::Specification.new do |spec|
31
31
  spec.add_development_dependency "rake", "~> 10.0"
32
32
  spec.add_development_dependency "minitest", "~> 5.0"
33
33
  spec.add_dependency "json"
34
- spec.add_dependency "curb"
34
+ spec.add_dependency "http"
35
35
  spec.add_dependency 'jwt'
36
36
  end
data/exe/asca CHANGED
@@ -12,19 +12,29 @@ options = {}
12
12
  option_parser = OptionParser.new do |opts|
13
13
  opts.banner = 'This is an apple connect api wrapper cli.'
14
14
 
15
- opts.on('-a action-name', '--action action-name', 'profile-install, profile-download') do |value|
15
+ opts.on('-a action-name', '--action action-name', 'version, profile-install, profile-download') do |value|
16
16
  options[:action] = value
17
17
  end
18
18
  opts.on('-n name', '--name name', 'Profile name') do |value|
19
19
  options[:profile_name] = value
20
20
  end
21
+ opts.on('-v', '--version', 'Get current version') do |value|
22
+ options[:action] = 'version'
23
+ end
21
24
  end.parse!
22
25
 
23
26
  case options[:action]
27
+ when 'version'
28
+ Asca::Log.info(Asca::VERSION)
24
29
  when 'profile-download'
25
- Asca::Profiles.download_profile options[:profile_name]
30
+ Asca::Profiles.download_profile options[:profile_name]
26
31
  when 'profile-install'
27
- Asca::Profiles.install_profile options[:profile_name]
32
+ Asca::Profiles.install_profile options[:profile_name]
28
33
  else
34
+ if options[:action]
29
35
  puts "Unsupported action: " + options[:action]
36
+ else
37
+ puts Asca::Log.error('Wrong parameters')
38
+ end
39
+
30
40
  end
@@ -1,4 +1,5 @@
1
1
  require "asca/version"
2
+ require "asca/log.rb"
2
3
  require "asca/consts.rb"
3
4
  require "asca/configuration.rb"
4
5
  require "asca/token"
@@ -0,0 +1,53 @@
1
+ module Asca
2
+ class Log
3
+ class Color
4
+ class << self
5
+ def time
6
+ "\e[37m"
7
+ end
8
+
9
+ def warn
10
+ "\e[33;1m"
11
+ end
12
+
13
+ def info
14
+ "\e[32m"
15
+ end
16
+
17
+ def error
18
+ "\e[31;1m"
19
+ end
20
+
21
+ def reset
22
+ "\e[0m"
23
+ end
24
+
25
+ def command
26
+ "\e[34m"
27
+ end
28
+ end
29
+ end
30
+
31
+ class << self
32
+ def warn message
33
+ puts "#{Color.warn}WARN: #{message}#{Color.reset}"
34
+ end
35
+
36
+ def info message
37
+ puts "#{Color.info}INFO: #{message}#{Color.reset}"
38
+ end
39
+
40
+ def error message
41
+ puts "#{Color.error}ERROR: #{message}#{Color.reset}", STDERR
42
+ end
43
+
44
+ def command message
45
+ puts "#{Color.command}RUN: \e[4m#{message}#{Color.reset}"
46
+ end
47
+
48
+ def puts message, io = STDOUT
49
+ io.puts "#{Color.time}[#{Time.new}]#{Color.reset} #{message}"
50
+ end
51
+ end
52
+ end
53
+ end
@@ -1,4 +1,4 @@
1
- require 'curb'
1
+ require 'http'
2
2
  require 'json'
3
3
  require "base64"
4
4
 
@@ -14,13 +14,15 @@ module Asca
14
14
  Asca::Configuration.update_config('out_put_dir', out_put_dir)
15
15
  end
16
16
  end
17
- http = Curl.get(URI_PROFILES, { 'filter[name]' => profile_name}) do |http|
18
- http.headers['Authorization'] = ' Bearer ' + Asca::Token.new_token
19
- end
20
- profile_obj = JSON.parse(http.body_str)
21
- profile_content = profile_obj["data"][0]["attributes"]['profileContent']
22
- File.open(File.expand_path(profile_name + ".mobileprovision", out_put_dir), 'w') do |file|
23
- file.write(Base64.decode64(profile_content))
17
+ response = HTTP.auth('Bearer ' + Asca::Token.new_token).get(URI_PROFILES, :params => { 'filter[name]' => profile_name })
18
+ if response.status.success?
19
+ profile_obj = JSON.parse(response.body)
20
+ profile_content = profile_obj["data"][0]["attributes"]['profileContent']
21
+ File.open(File.expand_path(profile_name + ".mobileprovision", out_put_dir), 'w') do |file|
22
+ file.write(Base64.decode64(profile_content))
23
+ end
24
+ else
25
+ Log.error(response.body)
24
26
  end
25
27
  end
26
28
 
@@ -77,15 +77,15 @@ module Asca
77
77
  end
78
78
 
79
79
  def get_token_from_cache
80
- cached_token_time = Asca::Configuration.get_config('cache_token_time')
81
- if !cached_token_time
80
+ token_valid_max_time = Asca::Configuration.get_config('cache_token_time')
81
+ if !token_valid_max_time
82
82
  return nil
83
83
  end
84
84
  current = Time.now.to_i
85
- if cached_token_time - current > EXPIRE_DURATION
86
- return nil
85
+ if token_valid_max_time > current
86
+ return Asca::Configuration.get_config('cache_token')
87
87
  end
88
- return Asca::Configuration.get_config('cache_token')
88
+ return nil
89
89
  end
90
90
  end
91
91
  end
@@ -1,3 +1,3 @@
1
1
  module Asca
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asca
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - xueminghao
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-08-18 00:00:00.000000000 Z
11
+ date: 2020-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -67,7 +67,7 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: curb
70
+ name: http
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -118,6 +118,7 @@ files:
118
118
  - lib/asca.rb
119
119
  - lib/asca/configuration.rb
120
120
  - lib/asca/consts.rb
121
+ - lib/asca/log.rb
121
122
  - lib/asca/profiles.rb
122
123
  - lib/asca/token.rb
123
124
  - lib/asca/version.rb