bump-cli 0.2.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +13 -6
- data/bump-cli.gemspec +4 -3
- data/lib/bump/cli/commands/base.rb +38 -13
- data/lib/bump/cli/commands/deploy.rb +8 -6
- data/lib/bump/cli/commands/preview.rb +7 -6
- data/lib/bump/cli/commands/validate.rb +8 -6
- data/lib/bump/cli/version.rb +1 -1
- metadata +22 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00a05336bed7f3a4f81e5b59a102950d067acb25cfe6d4bbdb057c0bf83f2265
|
4
|
+
data.tar.gz: 2f08c89b6ec3fbad5a85e1325309cf85da94cd7ded892ae06615c440c4623df5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4686dc55a271061d849af7a4aa778c7e6f4a93a3c7bfd38667f0f72dab7dc137e050aa73fe3ba1062c838193accc0613bbc5452ab55e949bf85a99aa8258b60
|
7
|
+
data.tar.gz: 34c42d4756f1dc1199af1a16d706298f07f8dc01723988322f58131d4312b8ffd624b25464152e294a999f870f9bea7499aa19f494b72f957fde9c098f41f857
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -20,27 +20,34 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
|
23
|
+
Bump tries to identify your file specification and format automatically. You can force it by using the `--specification` option. Here are the supported values:
|
24
24
|
|
25
|
-
|
25
|
+
* `openapi/v2/json`
|
26
|
+
* `openapi/v2/yaml`
|
27
|
+
* `openapi/v3/json`
|
28
|
+
* `openapi/v3/yaml`
|
29
|
+
* `asyncapi/v2/json`
|
30
|
+
* `asyncapi/v2/yaml`
|
31
|
+
|
32
|
+
The doc `id` and `token` options used below can be found in your documentation settings page on https://bump.sh. Note that you can replace these options by environments variables: `--id` can be replaced by `BUMP_ID`, and `--token` can by replaced by `BUMP_TOKEN`. This is useful to keep your private token secret.
|
26
33
|
|
27
34
|
### Preview
|
28
35
|
|
29
36
|
You can preview your documentation by calling the `preview` command. A temporary preview will be created, with a unique URL. This preview will be available for 30 minutes. You don't need any credentials to use this command.
|
30
37
|
|
31
|
-
$ bundle exec bump preview path/to/your/
|
38
|
+
$ bundle exec bump preview path/to/your/file.yml
|
32
39
|
|
33
40
|
### Validate
|
34
41
|
|
35
|
-
Validate your file against
|
42
|
+
Validate your file against its specification.
|
36
43
|
|
37
|
-
$ bundle exec bump validate path/to/your/
|
44
|
+
$ bundle exec bump validate path/to/your/file.yml --id DOC_ID --token DOC_TOKEN
|
38
45
|
|
39
46
|
### Deploy
|
40
47
|
|
41
48
|
Deploy the file as the current version of the documentation.
|
42
49
|
|
43
|
-
$ bundle exec bump deploy path/to/your/
|
50
|
+
$ bundle exec bump deploy path/to/your/file.yml --id DOC_ID --token DOC_TOKEN
|
44
51
|
|
45
52
|
## Development
|
46
53
|
|
data/bump-cli.gemspec
CHANGED
@@ -27,11 +27,12 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.required_ruby_version = '>= 2.3'
|
28
28
|
|
29
29
|
spec.add_dependency "hanami-cli", '~> 0'
|
30
|
-
spec.add_dependency "http", '
|
30
|
+
spec.add_dependency "http", '>= 3'
|
31
31
|
|
32
|
-
spec.add_development_dependency "bundler", "~> 1
|
32
|
+
spec.add_development_dependency "bundler", "~> 1"
|
33
|
+
spec.add_development_dependency "byebug", "~> 11"
|
33
34
|
spec.add_development_dependency "climate_control", '~> 0'
|
34
|
-
spec.add_development_dependency "rake", "~>
|
35
|
+
spec.add_development_dependency "rake", "~> 13"
|
35
36
|
spec.add_development_dependency "rspec", "~> 3"
|
36
37
|
spec.add_development_dependency "webmock", "~> 3"
|
37
38
|
end
|
@@ -4,8 +4,16 @@ module Bump
|
|
4
4
|
class CLI
|
5
5
|
module Commands
|
6
6
|
class Base < Hanami::CLI::Command
|
7
|
+
USER_AGENT = "bump-cli/#{VERSION}".freeze
|
8
|
+
|
7
9
|
private
|
8
10
|
|
11
|
+
def post(url:, body:, token: nil)
|
12
|
+
HTTP
|
13
|
+
.headers(headers(token: token))
|
14
|
+
.post(url, body: body)
|
15
|
+
end
|
16
|
+
|
9
17
|
def body(file, specification)
|
10
18
|
{
|
11
19
|
definition: open(file).read,
|
@@ -20,22 +28,22 @@ module Bump
|
|
20
28
|
end
|
21
29
|
|
22
30
|
def headers(token: '')
|
31
|
+
headers = {
|
32
|
+
'Content-Type' => 'application/json',
|
33
|
+
'User-Agent' => USER_AGENT
|
34
|
+
}
|
35
|
+
|
23
36
|
if token
|
24
|
-
{
|
25
|
-
"Content-Type" => "application/json",
|
26
|
-
"Authorization" => "Basic #{Base64.strict_encode64(token + ':')}"
|
27
|
-
}
|
28
|
-
else
|
29
|
-
{
|
30
|
-
"Content-Type" => "application/json"
|
31
|
-
}
|
37
|
+
headers['Authorization'] = "Basic #{Base64.strict_encode64(token + ':')}"
|
32
38
|
end
|
39
|
+
|
40
|
+
headers
|
33
41
|
end
|
34
42
|
|
35
43
|
def display_error(response)
|
36
44
|
if response.code == 422
|
37
45
|
body = JSON.parse(response.body)
|
38
|
-
|
46
|
+
display_validation_errors(body)
|
39
47
|
elsif response.code == 401
|
40
48
|
abort "Invalid credentials (status: 401)"
|
41
49
|
else
|
@@ -46,13 +54,30 @@ module Bump
|
|
46
54
|
abort "Unknown error (status: #{response.code})"
|
47
55
|
end
|
48
56
|
|
49
|
-
def
|
50
|
-
|
51
|
-
|
52
|
-
|
57
|
+
def display_validation_errors(body)
|
58
|
+
errors = body.dig('errors') || []
|
59
|
+
|
60
|
+
$stderr.puts "Invalid request:"
|
61
|
+
errors.each do |attribute, messages|
|
62
|
+
display_attribute_errors(attribute, messages)
|
53
63
|
end
|
64
|
+
|
54
65
|
abort
|
55
66
|
end
|
67
|
+
|
68
|
+
def display_attribute_errors(attribute, messages)
|
69
|
+
case
|
70
|
+
when messages.is_a?(String)
|
71
|
+
$stderr.puts "- #{attribute}: #{messages}"
|
72
|
+
when messages.is_a?(Array) && messages.count == 1
|
73
|
+
$stderr.puts "- #{attribute}: #{messages[0]}"
|
74
|
+
when messages.is_a?(Array)
|
75
|
+
$stderr.puts "- #{attribute}:"
|
76
|
+
messages.each do |message|
|
77
|
+
$stderr.puts " #{message}"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
56
81
|
end
|
57
82
|
end
|
58
83
|
end
|
@@ -5,16 +5,18 @@ module Bump
|
|
5
5
|
module Commands
|
6
6
|
class Deploy < Base
|
7
7
|
desc "Create a new version"
|
8
|
-
argument :file, required: true, desc: "Path or URL to your API documentation file.
|
8
|
+
argument :file, required: true, desc: "Path or URL to your API documentation file. OpenAPI (2.0 to 3.0.2) and AsyncAPI (2.0) specifications are currently supported."
|
9
9
|
option :id, default: ENV.fetch("BUMP_ID", ""), desc: "Documentation public id"
|
10
10
|
option :token, default: ENV.fetch("BUMP_TOKEN", ""), desc: "Documentation private token"
|
11
|
-
option :specification,
|
11
|
+
option :specification, desc: "Specification of the definition"
|
12
12
|
|
13
|
-
def call(file:,
|
13
|
+
def call(file:, id:, token:, specification: nil)
|
14
14
|
with_errors_rescued do
|
15
|
-
response =
|
16
|
-
|
17
|
-
|
15
|
+
response = post(
|
16
|
+
url: API_URL + "/docs/#{id}/versions",
|
17
|
+
body: body(file, specification).to_json,
|
18
|
+
token: token
|
19
|
+
)
|
18
20
|
|
19
21
|
if response.code == 201
|
20
22
|
puts "New version has been successfully deployed."
|
@@ -3,14 +3,15 @@ module Bump
|
|
3
3
|
module Commands
|
4
4
|
class Preview < Base
|
5
5
|
desc "Create a documentation preview for the given file"
|
6
|
-
argument :file, required: true, desc: "Path or URL to your API documentation file.
|
7
|
-
option :specification,
|
6
|
+
argument :file, required: true, desc: "Path or URL to your API documentation file. OpenAPI (2.0 to 3.0.2) and AsyncAPI (2.0) specifications are currently supported."
|
7
|
+
option :specification, desc: "Specification of the definition"
|
8
8
|
|
9
|
-
def call(file:, specification:)
|
9
|
+
def call(file:, specification: nil)
|
10
10
|
with_errors_rescued do
|
11
|
-
response =
|
12
|
-
|
13
|
-
|
11
|
+
response = post(
|
12
|
+
url: API_URL + "/previews",
|
13
|
+
body: body(file, specification).to_json
|
14
|
+
)
|
14
15
|
|
15
16
|
if response.code == 201
|
16
17
|
body = JSON.parse(response.body)
|
@@ -5,16 +5,18 @@ module Bump
|
|
5
5
|
module Commands
|
6
6
|
class Validate < Base
|
7
7
|
desc "Validate a given file against its schema definition"
|
8
|
-
argument :file, required: true, desc: "Path or URL to your API documentation file.
|
8
|
+
argument :file, required: true, desc: "Path or URL to your API documentation file. OpenAPI (2.0 to 3.0.2) and AsyncAPI (2.0) specifications are currently supported."
|
9
9
|
option :id, default: ENV.fetch("BUMP_ID", ""), desc: "Documentation public id"
|
10
10
|
option :token, default: ENV.fetch("BUMP_TOKEN", ""), desc: "Documentation private token"
|
11
|
-
option :specification,
|
11
|
+
option :specification, desc: "Specification of the definition"
|
12
12
|
|
13
|
-
def call(file:,
|
13
|
+
def call(file:, id:, token:, specification: nil)
|
14
14
|
with_errors_rescued do
|
15
|
-
response =
|
16
|
-
|
17
|
-
|
15
|
+
response = post(
|
16
|
+
url: API_URL + "/docs/#{id}/validations",
|
17
|
+
body: body(file, specification).to_json,
|
18
|
+
token: token
|
19
|
+
)
|
18
20
|
|
19
21
|
if response.code == 200
|
20
22
|
puts "Definition is valid."
|
data/lib/bump/cli/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bump-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mehdi Lahmam
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2019-10-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: hanami-cli
|
@@ -29,14 +29,14 @@ dependencies:
|
|
29
29
|
name: http
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- - "
|
32
|
+
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '3'
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- - "
|
39
|
+
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '3'
|
42
42
|
- !ruby/object:Gem::Dependency
|
@@ -45,14 +45,28 @@ dependencies:
|
|
45
45
|
requirements:
|
46
46
|
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '1
|
48
|
+
version: '1'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '1'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: byebug
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '11'
|
49
63
|
type: :development
|
50
64
|
prerelease: false
|
51
65
|
version_requirements: !ruby/object:Gem::Requirement
|
52
66
|
requirements:
|
53
67
|
- - "~>"
|
54
68
|
- !ruby/object:Gem::Version
|
55
|
-
version: '
|
69
|
+
version: '11'
|
56
70
|
- !ruby/object:Gem::Dependency
|
57
71
|
name: climate_control
|
58
72
|
requirement: !ruby/object:Gem::Requirement
|
@@ -73,14 +87,14 @@ dependencies:
|
|
73
87
|
requirements:
|
74
88
|
- - "~>"
|
75
89
|
- !ruby/object:Gem::Version
|
76
|
-
version: '
|
90
|
+
version: '13'
|
77
91
|
type: :development
|
78
92
|
prerelease: false
|
79
93
|
version_requirements: !ruby/object:Gem::Requirement
|
80
94
|
requirements:
|
81
95
|
- - "~>"
|
82
96
|
- !ruby/object:Gem::Version
|
83
|
-
version: '
|
97
|
+
version: '13'
|
84
98
|
- !ruby/object:Gem::Dependency
|
85
99
|
name: rspec
|
86
100
|
requirement: !ruby/object:Gem::Requirement
|