devcenter 1.1.0rc1 → 1.1.0rc2
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 +4 -4
- data/README.md +1 -1
- data/devcenter.gemspec +1 -0
- data/lib/devcenter/client.rb +5 -0
- data/lib/devcenter/commands/push.rb +19 -17
- data/lib/devcenter/helpers.rb +13 -0
- data/lib/devcenter/version.rb +1 -1
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d403c3e7157b49680864b829b6aab2c6426da2f
|
4
|
+
data.tar.gz: 9de7f63f1e099b45b62e38620c1f515e09ae7021
|
5
5
|
!binary "U0hBNTEy":
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd23a4e4416512cee66e406348456ade33641d22850559d03b54018ec3b7997008cdae278835d6f7ba880cab5eab5498f3c1e27f18a1dff4c4858952b4c055f0
|
7
|
+
data.tar.gz: f1f7ef0ad66419c3eea4ad748d3d5ba39d9332339623f2e606b5abc8a14f80924acae5753ad810215dfefc2cb89749f28c2d8e684fa640837288a7b9690a6653
|
data/README.md
CHANGED
@@ -34,7 +34,7 @@ This will open a preview in your default browser and get it refreshed when you s
|
|
34
34
|
|
35
35
|
$ devcenter push dynos
|
36
36
|
|
37
|
-
This will save the title and content from your local article in Dev Center
|
37
|
+
This will save the title and content from your local article in Dev Center, using your Heroku credentials from `~/.netrc`, which you can set by doing `heroku auth:login`.
|
38
38
|
|
39
39
|
### Help
|
40
40
|
|
data/devcenter.gemspec
CHANGED
data/lib/devcenter/client.rb
CHANGED
@@ -49,6 +49,11 @@ module Devcenter
|
|
49
49
|
auth_request(:put, token, path: update_article_path(article_id), body: form, :headers => { "Content-Type" => "application/x-www-form-urlencoded" })
|
50
50
|
end
|
51
51
|
|
52
|
+
def check_broken_links(token, content, parser)
|
53
|
+
form = URI.encode_www_form({content: content, parser: parser})
|
54
|
+
auth_request(:post, token, path: broken_link_checks_path, body: form, :headers => { "Content-Type" => "application/x-www-form-urlencoded" })
|
55
|
+
end
|
56
|
+
|
52
57
|
def response(request_call)
|
53
58
|
Response.new request_call
|
54
59
|
end
|
@@ -23,18 +23,12 @@ module Devcenter::Commands
|
|
23
23
|
if @article.parsing_error
|
24
24
|
abort "The content of #{@md_path} can't be parsed properly, fix it and try again."
|
25
25
|
end
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
elsif response.ok?
|
33
|
-
token = response.body['access_token']['token']
|
34
|
-
push_article(token) if validate_article(token)
|
35
|
-
else
|
36
|
-
abort "Authentication error: #{response.body['message']}"
|
37
|
-
end
|
26
|
+
if token = get_oauth_token
|
27
|
+
display_broken_links(token)
|
28
|
+
if validate_article(token)
|
29
|
+
push_article(token)
|
30
|
+
end
|
31
|
+
end
|
38
32
|
end
|
39
33
|
|
40
34
|
def validate_article(token)
|
@@ -47,14 +41,22 @@ module Devcenter::Commands
|
|
47
41
|
response = Devcenter::Client.validate_article(token, article_id, article_params)
|
48
42
|
errors = response.body
|
49
43
|
if errors.any?
|
50
|
-
say "The article \"#{@slug}\"
|
44
|
+
say "The article \"#{@slug}\" can't be saved:"
|
51
45
|
abort errors.to_yaml.gsub(/\A(\-+)\n-/, '')
|
52
|
-
else
|
53
|
-
say "The article \"#{@slug}\" is valid."
|
54
46
|
end
|
55
47
|
errors.empty?
|
56
48
|
end
|
57
49
|
|
50
|
+
def display_broken_links(token)
|
51
|
+
response = Devcenter::Client.check_broken_links(token, @article.content, @article.metadata.markdown_flavour)
|
52
|
+
broken_links = response.body
|
53
|
+
if broken_links.any?
|
54
|
+
say "The article \"#{@slug}\" contains broken link/s:"
|
55
|
+
broken_links.each{ |link| say("- [#{link['text']}](#{link['url']})") }
|
56
|
+
say "\n"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
58
60
|
def push_article(token)
|
59
61
|
article_id = @article.metadata.id
|
60
62
|
article_params = {
|
@@ -64,11 +66,11 @@ module Devcenter::Commands
|
|
64
66
|
}
|
65
67
|
response = Devcenter::Client.update_article(token, article_id, article_params)
|
66
68
|
if response.ok?
|
67
|
-
say "\"#{@slug}\" pushed successfully."
|
69
|
+
say "\"Article #{@slug}\" pushed successfully."
|
68
70
|
else
|
69
71
|
error = response.body['error']
|
70
72
|
abort "Error pushing \"#{@slug}\": #{error}"
|
71
73
|
end
|
72
|
-
end
|
74
|
+
end
|
73
75
|
end
|
74
76
|
end
|
data/lib/devcenter/helpers.rb
CHANGED
@@ -1,9 +1,15 @@
|
|
1
|
+
require 'netrc'
|
2
|
+
|
1
3
|
module Devcenter::Helpers
|
2
4
|
|
3
5
|
def devcenter_base_url
|
4
6
|
ENV['DEVCENTER_BASE_URL'] || 'https://devcenter.heroku.com'
|
5
7
|
end
|
6
8
|
|
9
|
+
def broken_link_checks_path
|
10
|
+
'/api/v1/private/broken-link-checks.json'
|
11
|
+
end
|
12
|
+
|
7
13
|
def article_path(slug)
|
8
14
|
"/articles/#{slug}"
|
9
15
|
end
|
@@ -47,4 +53,11 @@ module Devcenter::Helpers
|
|
47
53
|
File.open(filename, 'w'){ |f| f.write(content) }
|
48
54
|
end
|
49
55
|
|
56
|
+
def get_oauth_token
|
57
|
+
netrc = Netrc.read
|
58
|
+
user, token = netrc['api.heroku.com']
|
59
|
+
abort 'Heroku credentials not found. Execute "heroku login" to create them.' unless token
|
60
|
+
token
|
61
|
+
end
|
62
|
+
|
50
63
|
end
|
data/lib/devcenter/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devcenter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.0rc2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Raul Murciano
|
@@ -193,6 +193,20 @@ dependencies:
|
|
193
193
|
- - ~>
|
194
194
|
- !ruby/object:Gem::Version
|
195
195
|
version: 1.3.4
|
196
|
+
- !ruby/object:Gem::Dependency
|
197
|
+
name: netrc
|
198
|
+
requirement: !ruby/object:Gem::Requirement
|
199
|
+
requirements:
|
200
|
+
- - ~>
|
201
|
+
- !ruby/object:Gem::Version
|
202
|
+
version: 0.7.7
|
203
|
+
type: :runtime
|
204
|
+
prerelease: false
|
205
|
+
version_requirements: !ruby/object:Gem::Requirement
|
206
|
+
requirements:
|
207
|
+
- - ~>
|
208
|
+
- !ruby/object:Gem::Version
|
209
|
+
version: 0.7.7
|
196
210
|
description: CLI to interact with Heroku's Dev Center
|
197
211
|
email:
|
198
212
|
- raul@heroku.com
|