bump-cli 0.4.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 037f50e1dc85f791e29b7d04610c536d5c5de55465129218036508f7dc9b4f23
4
- data.tar.gz: a88fcc165c82445b31447194f4156479793294519327b7a37e0f253a532043d3
3
+ metadata.gz: 00d797137b0dae0f38a0a9106badd11c90ffacd37648eb7d2bdcdc4370e0e2b0
4
+ data.tar.gz: 1cd3d2d72d423284a9a0ffc3c0f86fd577b2ece23acf68f0fa36e43896aae730
5
5
  SHA512:
6
- metadata.gz: 62985d280a33db74d42a6afafde570231aca07a18fbae7a492756352f9315ea38b7fc7fa97b188d0dd2823d65a82e6cc8b639449b1064746f831d7c3de1a5e2f
7
- data.tar.gz: 6179fc9f2b65c33c4416f869a1c7c1e41b825d81a1e77533bb3d84e6a319f870c79ffbd45b5ac53b4d4a9f54fd23d841959fd40f83cac77457124dd82defa438
6
+ metadata.gz: 0e2a0eaa1fb62b4f9b7b5f88883e8f00ded7653467d80f3776a8aadf6f0190e32fdb620acc3e8568e30be88fa4e7f5370ec7e777137ecda72cc7e77a6cdd5576
7
+ data.tar.gz: c3f88a2d70ff4f893a13b985beb3f8198f349a02fed67f93e7949527867acc9655409a586db8f13a364b145b467c70d5cede4c4f74e3aa42b92c558140afc5a5
data/.circleci/config.yml CHANGED
@@ -3,7 +3,7 @@ jobs:
3
3
  build-latest: &common-build
4
4
  working_directory: ~/bump-cli
5
5
  docker:
6
- - image: circleci/ruby:2.5.0-node
6
+ - image: circleci/ruby:latest
7
7
  steps:
8
8
  - checkout
9
9
  - run:
@@ -29,20 +29,30 @@ jobs:
29
29
 
30
30
  - run:
31
31
  name: Run tests
32
- command: rake
32
+ command: bundle exec rspec
33
+ build-2-6:
34
+ <<: *common-build
35
+ docker:
36
+ - image: circleci/ruby:2.6
37
+ build-2-5:
38
+ <<: *common-build
39
+ docker:
40
+ - image: circleci/ruby:2.5
33
41
  build-2-4:
34
42
  <<: *common-build
35
43
  docker:
36
- - image: circleci/ruby:2.4.3-node
44
+ - image: circleci/ruby:2.4
37
45
  build-2-3:
38
46
  <<: *common-build
39
47
  docker:
40
- - image: circleci/ruby:2.3.6-node
48
+ - image: circleci/ruby:2.3
41
49
 
42
50
  workflows:
43
51
  version: 2
44
52
  build:
45
53
  jobs:
46
54
  - build-latest
55
+ - build-2-6
56
+ - build-2-5
47
57
  - build-2-4
48
58
  - build-2-3
@@ -0,0 +1,26 @@
1
+ ---
2
+ name: CLI runtime error
3
+ about: Create a report of an exception happening when running a CLI command
4
+ title: "[ERROR MESSAGE]"
5
+ labels: ""
6
+ assignees: ""
7
+ ---
8
+
9
+ **Describe the bug**
10
+ A clear and concise description of what the bug is.
11
+
12
+ **Command**
13
+ Paste here the exact command executed (with arguments and options) which led to the bug.
14
+
15
+ **Stack trace**
16
+ Paste here the stack trace displayed by the CLI, if available.
17
+
18
+ **Screenshots**
19
+ If applicable, add screenshots to help explain your problem.
20
+
21
+ **Desktop (please complete the following information):**
22
+ - OS: [e.g. macOS Catalina 10.15.7]
23
+ - Ruby version [e.g. 2.7]
24
+
25
+ **Additional context**
26
+ Add any other context about the problem here. If publishable, do not hesitate to join the specification you were trying to deploy/preview on Bump.
data/.gitignore CHANGED
@@ -1,4 +1,5 @@
1
1
  .byebug_history
2
+ .ruby-version
2
3
  /.bundle/
3
4
  /.yardoc
4
5
  /Gemfile.lock
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
4
 
5
5
  # Specify your gem's dependencies in bump-cli.gemspec
6
6
  gemspec
data/README.md CHANGED
@@ -29,25 +29,34 @@ 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
- 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.
32
+ Both the `--doc` and `--token` options used below can be found in your documentation settings page on https://bump.sh. Note that you can replace both the `--doc` and `--token` option by an environment variable. This will help to keep those values secret:
33
+
34
+ - `--doc` can by replaced by `BUMP_ID`.
35
+ - `--token` can by replaced by `BUMP_TOKEN`.
33
36
 
34
37
  ### Preview
35
38
 
36
39
  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
40
 
41
+ Preview a documentation:
42
+
38
43
  $ bundle exec bump preview path/to/your/file.yml
39
44
 
40
45
  ### Validate
41
46
 
42
- Validate your file against its specification.
47
+ Validate your file against its specification:
43
48
 
44
- $ bundle exec bump validate path/to/your/file.yml --id DOC_ID --token DOC_TOKEN
49
+ $ bundle exec bump validate path/to/your/file.yml --doc DOC_ID_OR_SLUG --token DOC_TOKEN
45
50
 
46
51
  ### Deploy
47
52
 
48
- Deploy the file as the current version of the documentation.
53
+ Deploy the file as the current version of the documentation:
54
+
55
+ $ bundle exec bump deploy path/to/your/file.yml --doc DOC_ID_OR_SLUG --token DOC_TOKEN
56
+
57
+ Automatically create a documentation inside a hub and deploy it:
49
58
 
50
- $ bundle exec bump deploy path/to/your/file.yml --id DOC_ID --token DOC_TOKEN
59
+ $ bundle exec bump deploy path/to/your/file.yml --auto-create --doc DOC_SLUG --hub HUB_ID_OR_SLUG --token HUB_TOKEN
51
60
 
52
61
  ## Development
53
62
 
data/bump-cli.gemspec CHANGED
@@ -1,38 +1,38 @@
1
- # coding: utf-8
2
1
  lib = File.expand_path("../lib", __FILE__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require "bump/cli/version"
5
4
 
6
5
  Gem::Specification.new do |spec|
7
- spec.name = "bump-cli"
8
- spec.version = Bump::CLI::VERSION
9
- spec.authors = ["Mehdi Lahmam", "Sébastien Charrier"]
10
- spec.email = ["mehdi@lahmam.com", "sebastien@bump.sh"]
6
+ spec.name = "bump-cli"
7
+ spec.version = Bump::CLI::VERSION
8
+ spec.authors = ["Mehdi Lahmam", "Sébastien Charrier"]
9
+ spec.email = ["mehdi@lahmam.com", "sebastien@bump.sh"]
11
10
 
12
- spec.summary = %q{Bump.sh CLI}
13
- spec.description = %q{Bump.sh CLI to interact with the API}
14
- spec.homepage = "https://bump.sh"
15
- spec.license = "MIT"
11
+ spec.summary = "Bump.sh CLI"
12
+ spec.description = "Bump.sh CLI to interact with the API"
13
+ spec.homepage = "https://bump.sh"
14
+ spec.license = "MIT"
16
15
 
17
16
  spec.metadata["allowed_push_host"] = "https://rubygems.org"
18
- spec.metadata["source_code_uri"] = "https://github.com/bump-sh/bump-cli"
17
+ spec.metadata["source_code_uri"] = "https://github.com/bump-sh/bump-cli"
19
18
 
20
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
19
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
21
20
  f.match(%r{^(test|spec|features)/})
22
21
  end
23
- spec.bindir = "exe"
24
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.bindir = "exe"
23
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
24
  spec.require_paths = ["lib"]
26
25
 
27
- spec.required_ruby_version = '>= 2.3'
26
+ spec.required_ruby_version = ">= 2.3"
28
27
 
29
- spec.add_dependency "hanami-cli", '~> 0'
30
- spec.add_dependency "http", '>= 3'
28
+ spec.add_dependency "dry-cli", "~> 0"
29
+ spec.add_dependency "http", ">= 3"
31
30
 
32
- spec.add_development_dependency "bundler", "~> 1"
31
+ spec.add_development_dependency "bundler", ">= 1", "< 3"
33
32
  spec.add_development_dependency "byebug", "~> 11"
34
- spec.add_development_dependency "climate_control", '~> 0'
33
+ spec.add_development_dependency "climate_control", "~> 0"
35
34
  spec.add_development_dependency "rake", "~> 13"
36
35
  spec.add_development_dependency "rspec", "~> 3"
36
+ spec.add_development_dependency "standard"
37
37
  spec.add_development_dependency "webmock", "~> 3"
38
38
  end
data/lib/bump/cli.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require "bump/cli/version"
2
- require "hanami/cli"
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
- Hanami::CLI.new(Commands).call(*args)
12
+ Dry::CLI.new(Commands).call(*args)
13
13
  end
14
14
 
15
15
  module Commands
16
- extend Hanami::CLI::Registry
16
+ extend Dry::CLI::Registry
17
17
  end
18
18
  end
19
19
  end
@@ -1,9 +1,10 @@
1
- require 'open-uri'
1
+ require "bump/cli/definition"
2
+ require "bump/cli/uuid"
2
3
 
3
4
  module Bump
4
5
  class CLI
5
6
  module Commands
6
- class Base < Hanami::CLI::Command
7
+ class Base < Dry::CLI::Command
7
8
  USER_AGENT = "bump-cli/#{VERSION}".freeze
8
9
 
9
10
  private
@@ -14,28 +15,90 @@ module Bump
14
15
  .post(url, body: body)
15
16
  end
16
17
 
17
- def body(file, specification, validation)
18
- {
19
- definition: open(file).read,
20
- specification: specification,
21
- validation: validation
18
+ def body(file, **options)
19
+ deprecation_warning(options)
20
+
21
+ definition = Definition.new(file, import_external_references: !options[:'no-external-references'])
22
+ definition.prepare!
23
+
24
+ compact(
25
+ {
26
+ definition: definition.content,
27
+ references: prepare_references(definition.external_references),
28
+ specification: options[:specification],
29
+ validation: options[:validation],
30
+ auto_create_documentation: options[:'auto-create']
31
+ }.merge(documentation_or_hub(options))
32
+ )
33
+ end
34
+
35
+ def prepare_references(references)
36
+ references.reduce([]) { |references, (location, content)|
37
+ references << {location: location, content: content}
22
38
  }
23
39
  end
24
40
 
41
+ def deprecation_warning(options)
42
+ if options[:"import-external-references"]
43
+ puts "[DEPRECATION WARNING] --import-external-references option is deprecated. External references are imported by default."
44
+ end
45
+ end
46
+
47
+ def compact(hash)
48
+ hash.delete_if { |key, value| value.nil? }
49
+ end
50
+
51
+ def documentation_or_hub(options)
52
+ result = {}
53
+
54
+ result[:documentation_id] = options[:id]
55
+ result[:documentation_id] = options[:doc] if documentation_uuid?(options)
56
+ result[:documentation_slug] = options[:doc] if documentation_slug?(options)
57
+ result[:documentation_name] = options[:'doc-name']
58
+ result[:hub_id] = options[:hub] if hub_uuid?(options)
59
+ result[:hub_slug] = options[:hub] if hub_slug?(options)
60
+
61
+ compact(result)
62
+ end
63
+
64
+ def documentation_uuid?(options)
65
+ Bump::CLI::UUID.valid?(options[:doc])
66
+ end
67
+
68
+ def documentation_slug?(options)
69
+ !options[:doc].nil? && !documentation_uuid?(options)
70
+ end
71
+
72
+ def hub_uuid?(options)
73
+ Bump::CLI::UUID.valid?(options[:hub])
74
+ end
75
+
76
+ def hub_slug?(options)
77
+ !options[:hub].nil? && !hub_uuid?(options)
78
+ end
79
+
25
80
  def with_errors_rescued
26
81
  yield
27
82
  rescue HTTP::Error, Errno::ENOENT, SocketError => error
28
83
  abort "Error: #{error.message}"
84
+ rescue => error
85
+ warn "An unexpected error occurred. Sorry about that!"
86
+ warn "We don't monitor errors raised by the CLI running on your computer, so we have not been notified."
87
+ warn "You can help us fix this by creating an issue on https://github.com/bump-sh/bump-cli/issues/new?template=cli-runtime-error.md."
88
+ warn "\n"
89
+ warn "#{error.class}: #{error.message}"
90
+ warn error.backtrace.take(10).join("\n")
91
+ exit(1)
29
92
  end
30
93
 
31
- def headers(token: '')
94
+ def headers(token: "")
32
95
  headers = {
33
- 'Content-Type' => 'application/json',
34
- 'User-Agent' => USER_AGENT
96
+ "Content-Type" => "application/json",
97
+ "User-Agent" => USER_AGENT
35
98
  }
36
99
 
37
100
  if token
38
- headers['Authorization'] = "Basic #{Base64.strict_encode64(token + ':')}"
101
+ headers["Authorization"] = "Basic #{Base64.strict_encode64(token + ":")}"
39
102
  end
40
103
 
41
104
  headers
@@ -56,9 +119,9 @@ module Bump
56
119
  end
57
120
 
58
121
  def display_validation_errors(body)
59
- errors = body.dig('errors') || []
122
+ errors = body.dig("errors") || []
60
123
 
61
- $stderr.puts "Invalid request:"
124
+ warn "Invalid request:"
62
125
  errors.each do |attribute, messages|
63
126
  display_attribute_errors(attribute, messages)
64
127
  end
@@ -67,15 +130,14 @@ module Bump
67
130
  end
68
131
 
69
132
  def display_attribute_errors(attribute, messages)
70
- case
71
- when messages.is_a?(String)
72
- $stderr.puts "- #{attribute}: #{messages}"
73
- when messages.is_a?(Array) && messages.count == 1
74
- $stderr.puts "- #{attribute}: #{messages[0]}"
75
- when messages.is_a?(Array)
76
- $stderr.puts "- #{attribute}:"
133
+ if messages.is_a?(String)
134
+ warn "- #{attribute}: #{messages}"
135
+ elsif messages.is_a?(Array) && messages.count == 1
136
+ warn "- #{attribute}: #{messages[0]}"
137
+ elsif messages.is_a?(Array)
138
+ warn "- #{attribute}:"
77
139
  messages.each do |message|
78
- $stderr.puts " #{message}"
140
+ warn " #{message}"
79
141
  end
80
142
  end
81
143
  end
@@ -1,4 +1,4 @@
1
- require 'base64'
1
+ require "base64"
2
2
 
3
3
  module Bump
4
4
  class CLI
@@ -6,23 +6,28 @@ 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 public id"
10
- option :token, default: ENV.fetch("BUMP_TOKEN", ""), desc: "Documentation private token"
9
+ option :doc, default: ENV.fetch("BUMP_ID", ""), desc: "Documentation id or slug"
10
+ option :'doc-name', desc: "Documentation name. Used with --auto-create flag."
11
+ option :hub, default: ENV.fetch("BUMP_HUB_ID", ""), desc: "Hub id or slug"
12
+ option :token, default: ENV.fetch("BUMP_TOKEN", ""), desc: "Documentation or Hub token"
11
13
  option :specification, desc: "Specification of the definition"
12
- option :validation, desc: "Validation mode", values: %w(basic strict), default: 'basic'
14
+ option :validation, desc: "Validation mode", values: %w[basic strict], default: "basic"
15
+ 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)"
16
+ option :'no-external-references', type: :boolean, default: false, desc: "Do not import external references ($ref)"
17
+ option :'import-external-references', type: :boolean, default: false, desc: "[DEPRECATED] External references are imported by default"
13
18
 
14
- def call(file:, id:, token:, validation:, specification: nil)
19
+ def call(file:, **options)
15
20
  with_errors_rescued do
16
21
  response = post(
17
- url: API_URL + "/docs/#{id}/versions",
18
- body: body(file, specification, validation).to_json,
19
- token: token
22
+ url: API_URL + "/versions",
23
+ body: body(file, **options).to_json,
24
+ token: options[:token]
20
25
  )
21
26
 
22
27
  if response.code == 201
23
- puts "New version has been successfully deployed."
28
+ puts "The new version is currently being processed."
24
29
  elsif response.code == 204
25
- puts "Version was already deployed."
30
+ puts "This version has already been deployed."
26
31
  else
27
32
  display_error(response)
28
33
  end
@@ -5,18 +5,20 @@ module Bump
5
5
  desc "Create a documentation preview for the given file"
6
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
7
  option :specification, desc: "Specification of the definition"
8
- option :validation, desc: "Validation mode", values: %w(basic strict), default: 'basic'
8
+ option :validation, desc: "Validation mode", values: %w[basic strict], default: "basic"
9
+ option :'no-external-references', type: :boolean, default: false, desc: "Do not import external references ($ref)"
10
+ option :'import-external-references', type: :boolean, default: false, desc: "[DEPRECATED] External references are imported by default"
9
11
 
10
- def call(file:, validation:, specification: nil)
12
+ def call(file:, **options)
11
13
  with_errors_rescued do
12
14
  response = post(
13
15
  url: API_URL + "/previews",
14
- body: body(file, specification, validation).to_json
16
+ body: body(file, **options).to_json
15
17
  )
16
18
 
17
19
  if response.code == 201
18
20
  body = JSON.parse(response.body)
19
- puts "Preview created : #{ROOT_URL + '/preview/' + body['id']} (expires at #{body['expires_at']})"
21
+ puts "Preview created : #{ROOT_URL + "/preview/" + body["id"]} (expires at #{body["expires_at"]})"
20
22
  else
21
23
  display_error(response)
22
24
  end
@@ -1,4 +1,4 @@
1
- require 'base64'
1
+ require "base64"
2
2
 
3
3
  module Bump
4
4
  class CLI
@@ -6,17 +6,22 @@ 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 public id"
10
- option :token, default: ENV.fetch("BUMP_TOKEN", ""), desc: "Documentation private token"
9
+ option :doc, default: ENV.fetch("BUMP_ID", ""), desc: "Documentation public id or slug"
10
+ option :'doc-name', desc: "Documentation name. Used with --auto-create flag."
11
+ option :hub, desc: "Hub id or slug"
12
+ option :token, default: ENV.fetch("BUMP_TOKEN", ""), desc: "Documentation or Hub token"
11
13
  option :specification, desc: "Specification of the definition"
12
- option :validation, desc: "Validation mode", values: %w(basic strict), default: 'basic'
14
+ option :validation, desc: "Validation mode", values: %w[basic strict], default: "basic"
15
+ 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)"
16
+ option :'no-external-references', type: :boolean, default: false, desc: "Do not import external references ($ref)"
17
+ option :'import-external-references', type: :boolean, default: false, desc: "[DEPRECATED] External references are imported by default"
13
18
 
14
- def call(file:, id:, token:, validation:, specification: nil)
19
+ def call(file:, **options)
15
20
  with_errors_rescued do
16
21
  response = post(
17
- url: API_URL + "/docs/#{id}/validations",
18
- body: body(file, specification, validation).to_json,
19
- token: token
22
+ url: API_URL + "/validations",
23
+ body: body(file, **options).to_json,
24
+ token: options[:token]
20
25
  )
21
26
 
22
27
  if response.code == 200
@@ -0,0 +1,32 @@
1
+ require "bump/cli/references"
2
+ require "bump/cli/resource"
3
+
4
+ module Bump
5
+ class CLI
6
+ class Definition
7
+ attr_reader :content, :external_references
8
+
9
+ def initialize(path, import_external_references: false)
10
+ @path = path
11
+ @import_external_references = import_external_references
12
+ @external_references = References.new(root_path: find_base_path(path))
13
+ end
14
+
15
+ def prepare!
16
+ @content = Resource.read(path)
17
+
18
+ if import_external_references
19
+ external_references.load(Resource.parse(content))
20
+ end
21
+ end
22
+
23
+ private
24
+
25
+ attr_reader :path, :import_external_references
26
+
27
+ def find_base_path(path)
28
+ Pathname.new(path.to_s).dirname.to_s + Pathname::SEPARATOR_LIST
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,68 @@
1
+ require "open-uri"
2
+ require "pathname"
3
+
4
+ module Bump
5
+ class CLI
6
+ class References < Hash
7
+ def initialize(root_path: "")
8
+ @root_path = root_path
9
+ end
10
+
11
+ def load(definition)
12
+ traverse_and_load_external_references(definition) if definition.is_a?(Enumerable)
13
+ end
14
+
15
+ private
16
+
17
+ attr_reader :root_path
18
+
19
+ def traverse_and_load_external_references(current)
20
+ current.each do |key, value|
21
+ if key == "$ref"
22
+ load_external_reference(value) if external?(value)
23
+ elsif value.is_a?(Hash)
24
+ traverse_and_load_external_references(value)
25
+ elsif value.is_a?(Array)
26
+ value.each do |array_value|
27
+ if array_value.is_a?(Hash)
28
+ traverse_and_load_external_references(array_value)
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+
35
+ def load_external_reference(reference)
36
+ if self[reference].nil?
37
+ base_reference = cleanup_reference(reference)
38
+ location = prepare_location(base_reference)
39
+ self[base_reference] = Resource.read(location)
40
+ end
41
+ end
42
+
43
+ def cleanup_reference(reference)
44
+ reference.sub(/#.*/, "")
45
+ end
46
+
47
+ def prepare_location(reference)
48
+ if url?(reference) || absolute_path?(reference)
49
+ reference
50
+ else
51
+ root_path + reference
52
+ end
53
+ end
54
+
55
+ def external?(reference)
56
+ !reference.start_with?("#")
57
+ end
58
+
59
+ def url?(path)
60
+ path.start_with?("http")
61
+ end
62
+
63
+ def absolute_path?(path)
64
+ path.start_with?("/")
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,26 @@
1
+ require "json"
2
+ require "yaml"
3
+
4
+ module Bump
5
+ class CLI
6
+ class Resource
7
+ def self.read(location)
8
+ if location.start_with?("http")
9
+ ::HTTP.get(location).to_s
10
+ else
11
+ ::File.read(location).force_encoding(Encoding::UTF_8)
12
+ end
13
+ end
14
+
15
+ def self.parse(content)
16
+ ::JSON.parse(content)
17
+ rescue ::JSON::ParserError
18
+ begin
19
+ ::YAML.safe_load(content, [Date, Time])
20
+ rescue ::Psych::SyntaxError
21
+ content
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,11 @@
1
+ module Bump
2
+ class CLI
3
+ class UUID
4
+ REGEXP = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/
5
+
6
+ def self.valid?(string)
7
+ string.to_s =~ REGEXP
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,5 +1,5 @@
1
1
  module Bump
2
2
  class CLI
3
- VERSION = "0.4.1"
3
+ VERSION = "0.7.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,18 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bump-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mehdi Lahmam
8
8
  - Sébastien Charrier
9
- autorequire:
9
+ autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2020-02-11 00:00:00.000000000 Z
12
+ date: 2021-03-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: hanami-cli
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
@@ -109,6 +115,20 @@ dependencies:
109
115
  - - "~>"
110
116
  - !ruby/object:Gem::Version
111
117
  version: '3'
118
+ - !ruby/object:Gem::Dependency
119
+ name: standard
120
+ requirement: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ type: :development
126
+ prerelease: false
127
+ version_requirements: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
112
132
  - !ruby/object:Gem::Dependency
113
133
  name: webmock
114
134
  requirement: !ruby/object:Gem::Requirement
@@ -133,6 +153,7 @@ extensions: []
133
153
  extra_rdoc_files: []
134
154
  files:
135
155
  - ".circleci/config.yml"
156
+ - ".github/ISSUE_TEMPLATE/cli-runtime-error.md"
136
157
  - ".gitignore"
137
158
  - ".travis.yml"
138
159
  - CODE_OF_CONDUCT.md
@@ -149,6 +170,10 @@ files:
149
170
  - lib/bump/cli/commands/deploy.rb
150
171
  - lib/bump/cli/commands/preview.rb
151
172
  - lib/bump/cli/commands/validate.rb
173
+ - lib/bump/cli/definition.rb
174
+ - lib/bump/cli/references.rb
175
+ - lib/bump/cli/resource.rb
176
+ - lib/bump/cli/uuid.rb
152
177
  - lib/bump/cli/version.rb
153
178
  homepage: https://bump.sh
154
179
  licenses:
@@ -156,7 +181,7 @@ licenses:
156
181
  metadata:
157
182
  allowed_push_host: https://rubygems.org
158
183
  source_code_uri: https://github.com/bump-sh/bump-cli
159
- post_install_message:
184
+ post_install_message:
160
185
  rdoc_options: []
161
186
  require_paths:
162
187
  - lib
@@ -171,9 +196,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
171
196
  - !ruby/object:Gem::Version
172
197
  version: '0'
173
198
  requirements: []
174
- rubyforge_project:
175
- rubygems_version: 2.7.4
176
- signing_key:
199
+ rubygems_version: 3.1.2
200
+ signing_key:
177
201
  specification_version: 4
178
202
  summary: Bump.sh CLI
179
203
  test_files: []