bump-cli 0.4.1 → 0.5.0
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/.gitignore +1 -0
- data/README.md +11 -5
- data/bump-cli.gemspec +2 -2
- data/lib/bump/cli.rb +3 -3
- data/lib/bump/cli/commands/base.rb +52 -7
- data/lib/bump/cli/commands/deploy.rb +10 -6
- data/lib/bump/cli/commands/preview.rb +2 -2
- data/lib/bump/cli/commands/validate.rb +10 -6
- data/lib/bump/cli/tools/uuid.rb +13 -0
- data/lib/bump/cli/version.rb +1 -1
- metadata +12 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7f6a735076725944a751da14fdcf7dab5dafcaea84cf1b18d433d05bb23be71
|
4
|
+
data.tar.gz: d8ee9a2b87963ba54ea9bdc373ba02a1a85b23b6255dd58d9291d0855b927ce8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3fc376b3b9b123f0b70ed488a49b651e2ed17ba95888bd07fcb9e7fb793663bea97d0f36d1e0508f2c4619b28186f568f607264c806ede9983a34e323d5fd7c8
|
7
|
+
data.tar.gz: b2f9e4d90a99813e03e6a46f2d7ecd43d43c449c238c89a1a3bf4eb70c79f1be7f09df7b1a2b0b70d6e816800e2135bf141a32422c97fce24ecf72cac591497d
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -29,25 +29,31 @@ Bump tries to identify your file specification and format automatically. You can
|
|
29
29
|
* `asyncapi/v2/json`
|
30
30
|
* `asyncapi/v2/yaml`
|
31
31
|
|
32
|
-
|
32
|
+
`doc` and `token` options used below can be found in your documentation settings page on https://bump.sh. Note that you can replace the token option by an environment variable, to keep it secret: `--token` can by replaced by `BUMP_TOKEN`.
|
33
33
|
|
34
34
|
### Preview
|
35
35
|
|
36
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.
|
37
37
|
|
38
|
+
Preview a documentation:
|
39
|
+
|
38
40
|
$ bundle exec bump preview path/to/your/file.yml
|
39
41
|
|
40
42
|
### Validate
|
41
43
|
|
42
|
-
Validate your file against its specification
|
44
|
+
Validate your file against its specification:
|
43
45
|
|
44
|
-
$ bundle exec bump validate path/to/your/file.yml --
|
46
|
+
$ bundle exec bump validate path/to/your/file.yml --doc DOC_ID_OR_SLUG --token DOC_TOKEN
|
45
47
|
|
46
48
|
### Deploy
|
47
49
|
|
48
|
-
Deploy the file as the current version of the documentation
|
50
|
+
Deploy the file as the current version of the documentation:
|
51
|
+
|
52
|
+
$ bundle exec bump deploy path/to/your/file.yml --doc DOC_ID_OR_SLUG --token DOC_TOKEN
|
53
|
+
|
54
|
+
Automatically create a documentation inside a hub and deploy it:
|
49
55
|
|
50
|
-
$ bundle exec bump deploy path/to/your/file.yml --
|
56
|
+
$ bundle exec bump deploy path/to/your/file.yml --auto-create --doc DOC_SLUG --hub HUB_ID_OR_SLUG --token HUB_TOKEN
|
51
57
|
|
52
58
|
## Development
|
53
59
|
|
data/bump-cli.gemspec
CHANGED
@@ -26,10 +26,10 @@ Gem::Specification.new do |spec|
|
|
26
26
|
|
27
27
|
spec.required_ruby_version = '>= 2.3'
|
28
28
|
|
29
|
-
spec.add_dependency "
|
29
|
+
spec.add_dependency "dry-cli", '~> 0'
|
30
30
|
spec.add_dependency "http", '>= 3'
|
31
31
|
|
32
|
-
spec.add_development_dependency "bundler", "
|
32
|
+
spec.add_development_dependency "bundler", ">= 1", "< 3"
|
33
33
|
spec.add_development_dependency "byebug", "~> 11"
|
34
34
|
spec.add_development_dependency "climate_control", '~> 0'
|
35
35
|
spec.add_development_dependency "rake", "~> 13"
|
data/lib/bump/cli.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require "bump/cli/version"
|
2
|
-
require "
|
2
|
+
require "dry/cli"
|
3
3
|
require "http"
|
4
4
|
|
5
5
|
module Bump
|
@@ -9,11 +9,11 @@ module Bump
|
|
9
9
|
API_URL = ROOT_URL + API_PATH
|
10
10
|
|
11
11
|
def call(*args)
|
12
|
-
|
12
|
+
Dry::CLI.new(Commands).call(*args)
|
13
13
|
end
|
14
14
|
|
15
15
|
module Commands
|
16
|
-
extend
|
16
|
+
extend Dry::CLI::Registry
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -1,9 +1,10 @@
|
|
1
1
|
require 'open-uri'
|
2
|
+
require 'bump/cli/tools/uuid'
|
2
3
|
|
3
4
|
module Bump
|
4
5
|
class CLI
|
5
6
|
module Commands
|
6
|
-
class Base <
|
7
|
+
class Base < Dry::CLI::Command
|
7
8
|
USER_AGENT = "bump-cli/#{VERSION}".freeze
|
8
9
|
|
9
10
|
private
|
@@ -14,12 +15,56 @@ module Bump
|
|
14
15
|
.post(url, body: body)
|
15
16
|
end
|
16
17
|
|
17
|
-
def body(file,
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
def body(file, **options)
|
19
|
+
deprecation_warning(options)
|
20
|
+
|
21
|
+
compact(
|
22
|
+
{
|
23
|
+
definition: open(file).read,
|
24
|
+
specification: options[:specification],
|
25
|
+
validation: options[:validation],
|
26
|
+
auto_create_documentation: options[:'auto-create']
|
27
|
+
}.merge(documentation_or_hub(options))
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
def deprecation_warning(options)
|
32
|
+
if !options[:id].nil?
|
33
|
+
puts "[DEPRECATION WARNING] --id option is deprecated. Please use --doc instead."
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def compact(hash)
|
38
|
+
hash.delete_if { |key, value| value.nil? }
|
39
|
+
end
|
40
|
+
|
41
|
+
def documentation_or_hub(options)
|
42
|
+
result = {}
|
43
|
+
|
44
|
+
result[:documentation_id] = options[:id]
|
45
|
+
result[:documentation_id] = options[:doc] if documentation_uuid?(options)
|
46
|
+
result[:documentation_slug] = options[:doc] if documentation_slug?(options)
|
47
|
+
result[:documentation_name] = options[:'doc-name']
|
48
|
+
result[:hub_id] = options[:hub] if hub_uuid?(options)
|
49
|
+
result[:hub_slug] = options[:hub] if hub_slug?(options)
|
50
|
+
|
51
|
+
compact(result)
|
52
|
+
end
|
53
|
+
|
54
|
+
def documentation_uuid?(options)
|
55
|
+
Bump::CLI::Tools::UUID.valid?(options[:doc])
|
56
|
+
end
|
57
|
+
|
58
|
+
def documentation_slug?(options)
|
59
|
+
!options[:doc].nil? && !documentation_uuid?(options)
|
60
|
+
end
|
61
|
+
|
62
|
+
def hub_uuid?(options)
|
63
|
+
Bump::CLI::Tools::UUID.valid?(options[:hub])
|
64
|
+
end
|
65
|
+
|
66
|
+
def hub_slug?(options)
|
67
|
+
!options[:hub].nil? && !hub_uuid?(options)
|
23
68
|
end
|
24
69
|
|
25
70
|
def with_errors_rescued
|
@@ -6,17 +6,21 @@ module Bump
|
|
6
6
|
class Deploy < Base
|
7
7
|
desc "Create a new version"
|
8
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
|
-
option :id, default: ENV.fetch("BUMP_ID", ""), desc: "Documentation
|
10
|
-
option :
|
9
|
+
option :id, default: ENV.fetch("BUMP_ID", ""), desc: "[DEPRECATED] Documentation id. Use `documentation` option instead"
|
10
|
+
option :doc, default: ENV.fetch("BUMP_ID", ""), desc: "Documentation id or slug"
|
11
|
+
option :'doc-name', desc: "Documentation name. Used with --auto-create flag."
|
12
|
+
option :hub, default: ENV.fetch("BUMP_HUB_ID", ""), desc: "Hub id or slug"
|
13
|
+
option :token, default: ENV.fetch("BUMP_TOKEN", ""), desc: "Documentation or Hub token"
|
11
14
|
option :specification, desc: "Specification of the definition"
|
12
15
|
option :validation, desc: "Validation mode", values: %w(basic strict), default: 'basic'
|
16
|
+
option :'auto-create', type: :boolean, default: false, desc: 'Automatically create the documentation if needed (only available with a hub and when specifying a slug for documentation)'
|
13
17
|
|
14
|
-
def call(file:,
|
18
|
+
def call(file:, **options)
|
15
19
|
with_errors_rescued do
|
16
20
|
response = post(
|
17
|
-
url: API_URL + "/
|
18
|
-
body: body(file,
|
19
|
-
token: token
|
21
|
+
url: API_URL + "/versions",
|
22
|
+
body: body(file, options).to_json,
|
23
|
+
token: options[:token]
|
20
24
|
)
|
21
25
|
|
22
26
|
if response.code == 201
|
@@ -7,11 +7,11 @@ module Bump
|
|
7
7
|
option :specification, desc: "Specification of the definition"
|
8
8
|
option :validation, desc: "Validation mode", values: %w(basic strict), default: 'basic'
|
9
9
|
|
10
|
-
def call(file:,
|
10
|
+
def call(file:, **options)
|
11
11
|
with_errors_rescued do
|
12
12
|
response = post(
|
13
13
|
url: API_URL + "/previews",
|
14
|
-
body: body(file,
|
14
|
+
body: body(file, options).to_json
|
15
15
|
)
|
16
16
|
|
17
17
|
if response.code == 201
|
@@ -6,17 +6,21 @@ module Bump
|
|
6
6
|
class Validate < Base
|
7
7
|
desc "Validate a given file against its schema definition"
|
8
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
|
-
option :id, default: ENV.fetch("BUMP_ID", ""), desc: "Documentation
|
10
|
-
option :
|
9
|
+
option :id, default: ENV.fetch("BUMP_ID", ""), desc: "[DEPRECATED] Documentation id. Use `documentation` option instead"
|
10
|
+
option :doc, default: ENV.fetch("BUMP_ID", ""), desc: "Documentation public id or slug"
|
11
|
+
option :'doc-name', desc: "Documentation name. Used with --auto-create flag."
|
12
|
+
option :hub, desc: "Hub id or slug"
|
13
|
+
option :token, default: ENV.fetch("BUMP_TOKEN", ""), desc: "Documentation or Hub token"
|
11
14
|
option :specification, desc: "Specification of the definition"
|
12
15
|
option :validation, desc: "Validation mode", values: %w(basic strict), default: 'basic'
|
16
|
+
option :'auto-create', type: :boolean, default: false, desc: 'Automatically create the documentation if needed (only available with a hub and when specifying a slug for documentation)'
|
13
17
|
|
14
|
-
def call(file:,
|
18
|
+
def call(file:, **options)
|
15
19
|
with_errors_rescued do
|
16
20
|
response = post(
|
17
|
-
url: API_URL + "/
|
18
|
-
body: body(file,
|
19
|
-
token: token
|
21
|
+
url: API_URL + "/validations",
|
22
|
+
body: body(file, options).to_json,
|
23
|
+
token: options[:token]
|
20
24
|
)
|
21
25
|
|
22
26
|
if response.code == 200
|
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.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mehdi Lahmam
|
@@ -9,10 +9,10 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-
|
12
|
+
date: 2020-04-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
15
|
+
name: dry-cli
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
@@ -43,16 +43,22 @@ dependencies:
|
|
43
43
|
name: bundler
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- - "
|
46
|
+
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '1'
|
49
|
+
- - "<"
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '3'
|
49
52
|
type: :development
|
50
53
|
prerelease: false
|
51
54
|
version_requirements: !ruby/object:Gem::Requirement
|
52
55
|
requirements:
|
53
|
-
- - "
|
56
|
+
- - ">="
|
54
57
|
- !ruby/object:Gem::Version
|
55
58
|
version: '1'
|
59
|
+
- - "<"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3'
|
56
62
|
- !ruby/object:Gem::Dependency
|
57
63
|
name: byebug
|
58
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -149,6 +155,7 @@ files:
|
|
149
155
|
- lib/bump/cli/commands/deploy.rb
|
150
156
|
- lib/bump/cli/commands/preview.rb
|
151
157
|
- lib/bump/cli/commands/validate.rb
|
158
|
+
- lib/bump/cli/tools/uuid.rb
|
152
159
|
- lib/bump/cli/version.rb
|
153
160
|
homepage: https://bump.sh
|
154
161
|
licenses:
|