verto 0.2.1 → 0.3.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/Gemfile.lock +1 -1
- data/README.md +17 -6
- data/exe/verto +2 -1
- data/lib/verto/commands/base_command.rb +1 -1
- data/lib/verto/commands/tag_command.rb +18 -11
- data/lib/verto/dsl/syntax.rb +48 -9
- data/lib/verto/utils/command_options.rb +9 -0
- data/lib/verto/utils/tag_filter.rb +1 -0
- data/lib/verto/version.rb +1 -1
- data/lib/verto.rb +2 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63e5795954f1a3e1fe31e041a36a6203c9334560fb1257989a10d629d93e0aba
|
4
|
+
data.tar.gz: 7c8210f02f712baed8dfdcdce3028df208734cf20bdc067022444cb4b4bdd472
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35c5171078261719b1c1f0746aac6542656e98a960eff6db56ebc9b2cfa907ed61e41d41363ebd5613779e4f8e6d2c5a9d7afeb7d629d071fd10e6d0f3c288a4
|
7
|
+
data.tar.gz: 32062358949fcc88c8a74803aae2e9e0e9d12ed913ce9729c83ca215dfefcfe104b13ddf464259c47b1f4d125f6f993352bec04caaec8fa151ac06bd6d03c0c2
|
data/Gemfile.lock
CHANGED
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
|
-
|
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.
|
35
|
+
alias verto='docker run -v $(pwd):/usr/src/project -it catks/verto:0.3.0'
|
36
36
|
```
|
37
37
|
|
38
|
-
If you want
|
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 -
|
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
|
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.
|
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
@@ -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
|
-
|
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
|
-
|
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
|
data/lib/verto/dsl/syntax.rb
CHANGED
@@ -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
|
-
@
|
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
|
data/lib/verto/version.rb
CHANGED
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,
|
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.
|
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-
|
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
|