verto 0.2.1 → 0.3.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: 64c9144a82db733e9ba2674535dee22d4615a2a2d4301879b7425295a83820c4
4
- data.tar.gz: dd4d498454b23175bb96f514462aab03bed1c9fc3c669ba0cb522204189bf67a
3
+ metadata.gz: 63e5795954f1a3e1fe31e041a36a6203c9334560fb1257989a10d629d93e0aba
4
+ data.tar.gz: 7c8210f02f712baed8dfdcdce3028df208734cf20bdc067022444cb4b4bdd472
5
5
  SHA512:
6
- metadata.gz: d8389934d204774aa1d9effe6db7b00f7b6730fc2ff440985dddecec5a00b2f6f374fed8ffe5d7fef292ff60d090695ae7e264e123d1be4bd950bd181a0e6b70
7
- data.tar.gz: 35275e3adc8c853e0064ac4039eb89005f36abe0d63b08a8207aeb9c995507ba103729fa40563d4bcdd20d701af31e36ff93aa24f2f3860eb210f5ac39dfb0f3
6
+ metadata.gz: 35c5171078261719b1c1f0746aac6542656e98a960eff6db56ebc9b2cfa907ed61e41d41363ebd5613779e4f8e6d2c5a9d7afeb7d629d071fd10e6d0f3c288a4
7
+ data.tar.gz: 32062358949fcc88c8a74803aae2e9e0e9d12ed913ce9729c83ca215dfefcfe104b13ddf464259c47b1f4d125f6f993352bec04caaec8fa151ac06bd6d03c0c2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- verto (0.2.1)
4
+ verto (0.3.0)
5
5
  dry-auto_inject (~> 0.6)
6
6
  dry-configurable (~> 0.8)
7
7
  dry-container (~> 0.7)
data/README.md CHANGED
@@ -21,7 +21,7 @@ If you use Rbenv you can install verto only once and create a alias in your .bas
21
21
  #### ZSH
22
22
  $ RBENV_VERSION=$(rbenv global) gem install verto && echo "alias verto='RBENV_VERSION=$(rbenv global) verto'" >> ~/.zshrc
23
23
 
24
- ### Bash
24
+ #### Bash
25
25
  $ RBENV_VERSION=$(rbenv global) gem install verto && echo "alias verto='RBENV_VERSION=$(rbenv global) verto'" >> ~/.bashrc
26
26
 
27
27
 
@@ -32,23 +32,31 @@ You don't need to install verto in your machine, you can run verto via the docke
32
32
  To use verto in the same way that you use any other cli, you can set an alias in your `.bashrc`, `.zshrc`, etc:
33
33
 
34
34
  ```
35
- alias verto='docker run -v $(pwd):/usr/src/project -it catks/verto:0.2.0'
35
+ alias verto='docker run -v $(pwd):/usr/src/project -it catks/verto:0.3.0'
36
36
  ```
37
37
 
38
- If you want to use your ssh keys with verto container (for git push) you can set the alias sharing the ssh key file:
38
+ If you want you can share your git configuration and known_hosts with:
39
39
 
40
40
  ```
41
- alias verto='docker run -v $(pwd):/usr/src/project -v $HOME/.ssh/known_hosts:/root/.ssh/known_hosts -v $HOME/.ssh/id_rsa:/root/.ssh/id_rsa -e SSH_PRIVATE_KEY=/root/.ssh/id_rsa -it catks/verto:0.2.0'
41
+ alias verto='docker run -v ~/.gitconfig:/etc/gitconfig -v $(pwd):/usr/src/project -v $HOME/.ssh/known_hosts:/root/.ssh/known_hosts -it catks/verto:0.3.0'
42
42
 
43
43
  ```
44
44
 
45
- You can also share the git config file with:
45
+ You can also use your ssh keys with verto container (for git push):
46
+
47
+ ```
48
+ alias verto='docker run -v $(pwd):/usr/src/project -v $HOME/.ssh/known_hosts:/root/.ssh/known_hosts -v $HOME/.ssh/id_rsa:/root/.ssh/id_rsa -e SSH_PRIVATE_KEY=/root/.ssh/id_rsa -it catks/verto:0.3.0'
49
+
50
+ ```
51
+
52
+ Or share the git config, known_hosts and ssh_keys:
46
53
 
47
54
 
48
55
  ```
49
- alias verto='docker run -v ~/.gitconfig:/etc/gitconfig -v $(pwd):/usr/src/project -v $HOME/.ssh/known_hosts:/root/.ssh/known_hosts -v $HOME/.ssh/id_rsa:/root/.ssh/id_rsa -e SSH_PRIVATE_KEY=/root/.ssh/id_rsa -it catks/verto:0.2.0'
56
+ alias verto='docker run -v ~/.gitconfig:/etc/gitconfig -v $(pwd):/usr/src/project -v $HOME/.ssh/known_hosts:/root/.ssh/known_hosts -v $HOME/.ssh/id_rsa:/root/.ssh/id_rsa -e SSH_PRIVATE_KEY=/root/.ssh/id_rsa -it catks/verto:0.3.0'
50
57
 
51
58
  ```
59
+
52
60
  Now you can run any verto command! :)
53
61
 
54
62
  ## Usage
@@ -67,6 +75,9 @@ If you need a more specific configuration or want to reflect your development pr
67
75
 
68
76
  ```ruby
69
77
  # Vertofile
78
+
79
+ verto_version "0.3.0"
80
+
70
81
  config {
71
82
  pre_release.initial_number = 0
72
83
  project.path = "my/repo/path"
data/exe/verto CHANGED
@@ -8,7 +8,8 @@ begin
8
8
  Verto::DSL.load_file(vertofile_path) if File.exists?(vertofile_path)
9
9
 
10
10
  Verto::MainCommand.start(ARGV)
11
- rescue Verto::ExitError
11
+ rescue Verto::ExitError => ex
12
+ Verto.stderr.puts ex.message
12
13
  Verto.stderr.puts 'Exiting Verto...'
13
14
  exit 1
14
15
  end
@@ -11,7 +11,7 @@ module Verto
11
11
  end
12
12
 
13
13
  def options
14
- super.merge Verto.config.command_options
14
+ Verto.config.command_options.merge(super)
15
15
  end
16
16
 
17
17
  def call_hooks(moments = [], with_attributes: {})
@@ -9,7 +9,7 @@ module Verto
9
9
  option :filter, type: :string
10
10
 
11
11
  def up
12
- call_hooks(%i[before before_tag_up])
12
+ call_hooks(%i[before before_tag_up], with_attributes: { command_options: options} )
13
13
 
14
14
  validate_version_option_presence!
15
15
 
@@ -19,18 +19,11 @@ module Verto
19
19
 
20
20
  latest_version = SemanticVersion.new(latest_tag)
21
21
 
22
- version_up_options = options.select { |key,value| value == true }.keys.map(&:to_sym) & [:major, :minor, :patch]
23
-
24
- new_version = version_up_options.reduce(latest_version) { |version, up_option| version.up(up_option) }
25
-
26
- if options[:pre_release]
27
- identifier = pre_release_configured? ? options[:pre_release] : latest_version.pre_release.name
28
- new_version = new_version.with_pre_release(identifier)
29
- new_version = new_version.up(:pre_release) if new_version.pre_release.name == latest_version.pre_release.name
30
- end
22
+ new_version = up_version(latest_version, options)
31
23
 
32
24
  validate_new_version!(new_version, latest_version)
33
- call_hooks(:before_tag_creation, with_attributes: { new_version: new_version, latest_version: latest_version } )
25
+
26
+ call_hooks(:before_tag_creation, with_attributes: { new_version: new_version } )
34
27
  tag_repository.create!(new_version.to_s)
35
28
 
36
29
  call_hooks(:after_tag_up, with_attributes: { new_version: new_version })
@@ -41,6 +34,20 @@ module Verto
41
34
 
42
35
  include Verto.import['tag_repository']
43
36
 
37
+ def up_version(version, options)
38
+ version_up_options = options.select { |key,value| value == true }.keys.map(&:to_sym) & [:major, :minor, :patch]
39
+
40
+ new_version = version_up_options.reduce(version) { |version, up_option| version.up(up_option) }
41
+
42
+ if options[:pre_release]
43
+ identifier = pre_release_configured? ? options[:pre_release] : version.pre_release.name
44
+ new_version = new_version.with_pre_release(identifier)
45
+ new_version = new_version.up(:pre_release) if new_version.pre_release.name == version.pre_release.name
46
+ end
47
+
48
+ new_version
49
+ end
50
+
44
51
  def pre_release_configured?
45
52
  options[:pre_release] != 'pre_release'
46
53
  end
@@ -1,12 +1,33 @@
1
1
  module Verto
2
2
  module DSL
3
3
  module Syntax
4
+ def verto_version(expected_version_string)
5
+ expected_version = Verto::SemanticVersion.new(expected_version_string)
6
+
7
+ verto_version = Verto::SemanticVersion.new(Verto::VERSION)
8
+
9
+ error_message = "Current Verto version is #{verto_version}, required version is #{expected_version} or higher"
10
+ raise Verto::ExitError, error_message unless expected_version <= verto_version
11
+ end
12
+
4
13
  def config(&block)
5
14
  Verto.config.instance_eval(&block)
6
15
  end
7
16
 
17
+ def latest_version
18
+ @latest_version ||= latest_semantic_version_for(:all)
19
+ end
20
+
21
+ def latest_release_version
22
+ @latest_release_version ||= latest_semantic_version_for(:release_only)
23
+ end
24
+
25
+ def latest_pre_release_version
26
+ @latest_pre_release_version ||= latest_semantic_version_for(:pre_release_only)
27
+ end
28
+
8
29
  def current_branch
9
- git('rev-parse --abbrev-ref HEAD').output.chomp.strip
30
+ git('rev-parse --abbrev-ref HEAD', stdout_output: false).output.chomp.strip
10
31
  end
11
32
 
12
33
  def branch(*branch_names)
@@ -21,16 +42,16 @@ module Verto
21
42
  block.call if condition
22
43
  end
23
44
 
24
- def git(subcommand)
25
- sh("git #{subcommand}")
45
+ def git(subcommand, stdout_output: :from_config)
46
+ sh("git #{subcommand}", stdout_output: stdout_output)
26
47
  end
27
48
 
28
- def sh(command)
29
- command_executor.run command
49
+ def sh(command, stdout_output: :from_config)
50
+ command_executor(stdout_output: stdout_output).run command
30
51
  end
31
52
 
32
- def sh!(command)
33
- raise Verto::ExitError unless sh(command).success?
53
+ def sh!(command, stdout_output: :from_config)
54
+ raise Verto::ExitError unless sh(command, stdout_output: stdout_output).success?
34
55
  end
35
56
 
36
57
  def command_options
@@ -81,8 +102,14 @@ module Verto
81
102
 
82
103
  private
83
104
 
84
- def command_executor
85
- @command_executor ||= SystemCommandExecutor.new
105
+ def command_executor(stdout_output: :from_config)
106
+ @executors ||= {
107
+ from_config: SystemCommandExecutor.new,
108
+ true => SystemCommandExecutor.new(stdout: $stdout),
109
+ false => SystemCommandExecutor.new(stdout: nil)
110
+ }
111
+
112
+ @executors[stdout_output]
86
113
  end
87
114
 
88
115
  def shell_basic
@@ -92,6 +119,18 @@ module Verto
92
119
  def stderr
93
120
  Verto.stderr
94
121
  end
122
+
123
+ def tag_repository
124
+ @tag_repository ||= TagRepository.new
125
+ end
126
+
127
+ def latest_semantic_version_for(filter)
128
+ tag_version = tag_repository.latest(filter: TagFilter.for(filter))
129
+
130
+ return SemanticVersion.new('0.0.0') unless tag_version
131
+
132
+ SemanticVersion.new(tag_version)
133
+ end
95
134
  end
96
135
  end
97
136
  end
@@ -0,0 +1,9 @@
1
+ module Verto
2
+ class CommandOptions < Thor::CoreExt::HashWithIndifferentAccess
3
+ alias_method :add, :merge!
4
+
5
+ def except(*keys)
6
+ self.reject { |key, v| keys.include?(key) }
7
+ end
8
+ end
9
+ end
@@ -5,6 +5,7 @@ module TagFilter
5
5
  FILTERS = {
6
6
  release_only: REALEASE_ONLY,
7
7
  pre_release_only: PRE_REALEASE_ONLY,
8
+ all: nil
8
9
  }
9
10
 
10
11
  def self.for(tag_key)
data/lib/verto/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Verto
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
data/lib/verto.rb CHANGED
@@ -5,6 +5,7 @@ require "dry-auto_inject"
5
5
  require "pathname"
6
6
 
7
7
  require "verto/version"
8
+ require "verto/utils/command_options"
8
9
 
9
10
  module Verto
10
11
  extend Dry::Configurable
@@ -23,7 +24,7 @@ module Verto
23
24
  end
24
25
 
25
26
  setting :hooks, []
26
- setting :command_options, Class.new(Hash) { alias_method :add, :merge! }.new
27
+ setting :command_options, CommandOptions.new
27
28
 
28
29
  ExitError = Class.new(Thor::Error)
29
30
  CommandError = Class.new(ExitError)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: verto
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carlos Atkinson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-16 00:00:00.000000000 Z
11
+ date: 2020-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -168,6 +168,7 @@ files:
168
168
  - lib/verto/dsl/interpreter.rb
169
169
  - lib/verto/dsl/syntax.rb
170
170
  - lib/verto/repositories/tag_repository.rb
171
+ - lib/verto/utils/command_options.rb
171
172
  - lib/verto/utils/semantic_version.rb
172
173
  - lib/verto/utils/system_command_executor.rb
173
174
  - lib/verto/utils/tag_filter.rb