underway 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/CHANGELOG.md +11 -1
- data/README.md +9 -3
- data/lib/underway/api.rb +15 -1
- data/lib/underway/settings.rb +20 -0
- data/lib/underway/version.rb +1 -1
- data/underway.gemspec +2 -1
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea67c9db9aa37c2b89c6b4e6c5d70c96808a0628
|
4
|
+
data.tar.gz: 2e44144648905e30991c8e561f2b6e86073804e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 940689feca04bf0f6eaa358920d22b60039b1e001fb10da571171ca9547693eda20427b83854ff56757e696f1dc4d9cba28bb969e4815817cf8875d18b3643d3
|
7
|
+
data.tar.gz: '020818b8d5c4a3b06aca9e77efecc4c04a2ac5a0e1eec7bf05f4bda408c77e385d89737e7a7c545c6f462928e8d11f01fb3a9d06404b57c8c0ac9784503a4ad6'
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,15 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
5
5
|
## [Unreleased][unreleased]
|
6
6
|
- Nothing
|
7
7
|
|
8
|
+
## [1.1.0] - 2019-05-21
|
9
|
+
### Added
|
10
|
+
- `Underway::Api.client_for` helper that returns a configured `Octokit` client
|
11
|
+
for a given installation ID or access token
|
12
|
+
|
13
|
+
### Fixed
|
14
|
+
- Make Underway work for GHES
|
15
|
+
[#7](https://github.com/jamesmartin/underway/pulls/7)
|
16
|
+
|
8
17
|
## [1.0.1] - 2018-05-09
|
9
18
|
### Fixed
|
10
19
|
- No longer require Sinatra to be installed
|
@@ -14,6 +23,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
14
23
|
### Added
|
15
24
|
- First release
|
16
25
|
|
17
|
-
[unreleased]: https://github.com/jamesmartin/underway/compare/v1.0
|
26
|
+
[unreleased]: https://github.com/jamesmartin/underway/compare/v1.1.0...HEAD
|
27
|
+
[1.1.0]: https://github.com/jamesmartin/underway/compare/v1.0.1...v1.1.0
|
18
28
|
[1.0.1]: https://github.com/jamesmartin/underway/compare/v1.0.0...v1.0.1
|
19
29
|
[1.0.0]: https://github.com/jamesmartin/underway/compare/5c7f4d7d3bfc...v1.0.0
|
data/README.md
CHANGED
@@ -16,6 +16,12 @@ access token for your App and its installations. Starting with a Sinatra
|
|
16
16
|
application is a fast way to build a GitHub App prototype and explore how
|
17
17
|
GitHub Apps work with the GitHub REST API.
|
18
18
|
|
19
|
+
## Changelog
|
20
|
+
|
21
|
+
This project adheres to [Semantic Versioning](http://semver.org). All notable
|
22
|
+
changes are documented in the
|
23
|
+
[CHANGELOG](https://github.com/jamesmartin/underway/blob/master/CHANGELOG.md).
|
24
|
+
|
19
25
|
## Installation
|
20
26
|
|
21
27
|
Add this line to your application's Gemfile:
|
@@ -90,7 +96,7 @@ Underway::Api.generate_jwt
|
|
90
96
|
You can get an access token for a given installation of your App:
|
91
97
|
|
92
98
|
```ruby
|
93
|
-
installations = Underway::Api.invoke("
|
99
|
+
installations = Underway::Api.invoke("app/installations")
|
94
100
|
access_token = Underway::Api.installation_token(id: installations.first.id)
|
95
101
|
```
|
96
102
|
|
@@ -101,7 +107,7 @@ To get a list of repositories to which an installation of your App has access,
|
|
101
107
|
try this:
|
102
108
|
|
103
109
|
```ruby
|
104
|
-
installations = Underway::Api.invoke("
|
110
|
+
installations = Underway::Api.invoke("app/installations")
|
105
111
|
access_token = Underway::Api.installation_token(id: installations.first.id)
|
106
|
-
repositories = Underway::Api.invoke("
|
112
|
+
repositories = Underway::Api.invoke("installation/repositories", headers: { authorization: "token #{access_token}" })
|
107
113
|
```
|
data/lib/underway/api.rb
CHANGED
@@ -28,6 +28,20 @@ module Underway
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
+
def self.client_for(installation_id: nil, access_token: nil)
|
32
|
+
token = access_token
|
33
|
+
if !installation_id.nil?
|
34
|
+
token = installation_token(id: installation_id)
|
35
|
+
end
|
36
|
+
|
37
|
+
return if token.nil?
|
38
|
+
|
39
|
+
client = Octokit::Client.new(
|
40
|
+
api_endpoint: Underway::Settings.config.raw["github_api_host"],
|
41
|
+
access_token: token
|
42
|
+
)
|
43
|
+
end
|
44
|
+
|
31
45
|
def self.generate_jwt
|
32
46
|
payload = {
|
33
47
|
# Issued at time:
|
@@ -49,7 +63,7 @@ module Underway
|
|
49
63
|
else
|
50
64
|
log("token cache: miss")
|
51
65
|
res = invoke(
|
52
|
-
"
|
66
|
+
"app/installations/#{id}/access_tokens",
|
53
67
|
method: :post
|
54
68
|
)
|
55
69
|
|
data/lib/underway/settings.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require "addressable/uri"
|
1
2
|
require "pathname"
|
2
3
|
require "json"
|
3
4
|
|
@@ -74,6 +75,25 @@ module Underway
|
|
74
75
|
def token_cache
|
75
76
|
@token_cache ||= Underway::TokenCache.new(db)
|
76
77
|
end
|
78
|
+
|
79
|
+
def oauth_authorize_url
|
80
|
+
uri = Addressable::URI.parse(config["github_api_host"])
|
81
|
+
"#{uri.scheme}://#{uri.domain}/login/oauth/authorize?client_id=#{config["client_id"]}"
|
82
|
+
end
|
83
|
+
|
84
|
+
def oauth_access_token_url(code)
|
85
|
+
api_host = Addressable::URI.parse(config["github_api_host"])
|
86
|
+
template = Addressable::Template.new(
|
87
|
+
"{scheme}://{host}/login/oauth/access_token{?code,client_id,client_secret}"
|
88
|
+
)
|
89
|
+
template.expand(
|
90
|
+
"scheme" => api_host.scheme,
|
91
|
+
"host" => api_host.domain,
|
92
|
+
"code" => code,
|
93
|
+
"client_id" => config["client_id"],
|
94
|
+
"client_secret" => config["client_secret"]
|
95
|
+
)
|
96
|
+
end
|
77
97
|
end
|
78
98
|
|
79
99
|
@configuration = Configuration.new
|
data/lib/underway/version.rb
CHANGED
data/underway.gemspec
CHANGED
@@ -18,13 +18,14 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_development_dependency "bundler", "~>
|
21
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
22
22
|
spec.add_development_dependency "minitest"
|
23
23
|
spec.add_development_dependency "pry"
|
24
24
|
spec.add_development_dependency "rake"
|
25
25
|
spec.add_development_dependency "sinatra"
|
26
26
|
spec.add_development_dependency "timecop"
|
27
27
|
|
28
|
+
spec.add_runtime_dependency "addressable", "~> 2.3"
|
28
29
|
spec.add_runtime_dependency "jwt", "~> 2.1"
|
29
30
|
spec.add_runtime_dependency "octokit", "~> 4.0"
|
30
31
|
spec.add_runtime_dependency "sequel"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: underway
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Martin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: minitest
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: addressable
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '2.3'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '2.3'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: jwt
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|