verto 0.6.1 → 0.10.1
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/.github/workflows/ruby.yml +51 -0
- data/.rubocop.yml +23 -0
- data/.rubocop_todo.yml +50 -0
- data/.ruby-version +1 -1
- data/CHANGELOG.md +17 -0
- data/Gemfile +3 -1
- data/Gemfile.lock +34 -11
- data/README.md +42 -47
- data/Rakefile +7 -5
- data/Vertofile +10 -30
- data/bin/console +4 -3
- data/djin.yml +37 -0
- data/exe/verto +6 -4
- data/lib/verto.rb +63 -22
- data/lib/verto/commands/base_command.rb +7 -2
- data/lib/verto/commands/main_command.rb +10 -6
- data/lib/verto/commands/tag_command.rb +44 -23
- data/lib/verto/dsl.rb +2 -0
- data/lib/verto/dsl/built_in_hooks.rb +24 -0
- data/lib/verto/dsl/file.rb +4 -2
- data/lib/verto/dsl/hook.rb +2 -0
- data/lib/verto/dsl/interpreter.rb +8 -7
- data/lib/verto/dsl/syntax.rb +44 -11
- data/lib/verto/dsl/update_changelog.rb +60 -0
- data/lib/verto/repositories/tag_repository.rb +2 -0
- data/lib/verto/utils/cli_helpers.rb +15 -0
- data/lib/verto/utils/command_options.rb +4 -2
- data/lib/verto/utils/semantic_version.rb +2 -0
- data/lib/verto/utils/strict_hash.rb +9 -0
- data/lib/verto/utils/system_command_executor.rb +4 -2
- data/lib/verto/utils/tag_filter.rb +5 -3
- data/lib/verto/utils/template.rb +2 -0
- data/lib/verto/utils/templates/Vertofile +31 -33
- data/lib/verto/version.rb +3 -1
- data/verto.gemspec +29 -25
- metadata +61 -23
- data/.travis.yml +0 -13
data/bin/console
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
require
|
4
|
-
require
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'verto'
|
5
6
|
|
6
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
8
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +11,5 @@ require "verto"
|
|
10
11
|
# require "pry"
|
11
12
|
# Pry.start
|
12
13
|
|
13
|
-
require
|
14
|
+
require 'irb'
|
14
15
|
IRB.start(__FILE__)
|
data/djin.yml
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
djin_version: '0.10.0'
|
2
|
+
|
3
|
+
tasks:
|
4
|
+
run:
|
5
|
+
local:
|
6
|
+
run:
|
7
|
+
- {{args}}
|
8
|
+
|
9
|
+
set_verto_version:
|
10
|
+
local:
|
11
|
+
run:
|
12
|
+
- VERTO_BUILD_VERSION=$(cat lib/verto/version.rb | grep -ohE '\d+\.\d+\.\d+')
|
13
|
+
|
14
|
+
tag_up:
|
15
|
+
docker:
|
16
|
+
image: "catks/verto:0.10.0"
|
17
|
+
run:
|
18
|
+
commands:
|
19
|
+
- "verto tag up {{args}}"
|
20
|
+
options: |
|
21
|
+
-v ~/.gitconfig:/etc/gitconfig -v $(pwd):/usr/src/project \
|
22
|
+
-v $HOME/.ssh/known_hosts:/root/.ssh/known_hosts -v $HOME/.ssh/id_rsa:/root/.ssh/id_rsa \
|
23
|
+
-e SSH_PRIVATE_KEY=/root/.ssh/id_rsa \
|
24
|
+
--entrypoint='' \
|
25
|
+
depends_on:
|
26
|
+
- set_verto_version
|
27
|
+
|
28
|
+
release:
|
29
|
+
local:
|
30
|
+
run:
|
31
|
+
- bundle exec rake release
|
32
|
+
- docker build . -t verto
|
33
|
+
- docker tag verto catks/verto:$VERTO_BUILD_VERSION
|
34
|
+
- docker push catks/verto:$VERTO_BUILD_VERSION
|
35
|
+
depends_on:
|
36
|
+
- set_verto_version
|
37
|
+
- tag_up
|
data/exe/verto
CHANGED
@@ -1,17 +1,19 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
Signal.trap('INT') { exit 2 }
|
2
5
|
|
3
6
|
require_relative '../lib/verto'
|
4
7
|
|
5
8
|
vertofile_path = ENV['VERTOFILE_PATH'] || Pathname.new(Dir.pwd).join('Vertofile').to_s
|
6
|
-
|
7
9
|
begin
|
8
|
-
Verto::DSL.load_file(vertofile_path) if File.
|
10
|
+
Verto::DSL.load_file(vertofile_path) if File.exist?(vertofile_path)
|
9
11
|
|
10
12
|
Verto::MainCommand.start(ARGV)
|
11
13
|
|
12
14
|
# TODO: Improve error Message Handling
|
13
|
-
rescue Verto::ExitError =>
|
14
|
-
Verto.stderr.puts
|
15
|
+
rescue Verto::ExitError => e
|
16
|
+
Verto.stderr.puts e.message
|
15
17
|
Verto.stderr.puts 'Exiting Verto...'
|
16
18
|
exit 1
|
17
19
|
end
|
data/lib/verto.rb
CHANGED
@@ -1,18 +1,22 @@
|
|
1
|
-
|
2
|
-
require "dry-container"
|
3
|
-
require "dry-configurable"
|
4
|
-
require "dry-auto_inject"
|
5
|
-
require "vseries"
|
6
|
-
require "pathname"
|
1
|
+
# frozen_string_literal: true
|
7
2
|
|
8
|
-
require
|
9
|
-
require
|
3
|
+
require 'thor'
|
4
|
+
require 'dry-container'
|
5
|
+
require 'dry-configurable'
|
6
|
+
require 'dry-auto_inject'
|
7
|
+
require 'vseries'
|
8
|
+
require 'mustache'
|
9
|
+
require 'pathname'
|
10
|
+
|
11
|
+
require 'verto/version'
|
12
|
+
require 'verto/utils/command_options'
|
10
13
|
|
11
14
|
module Verto
|
12
15
|
extend Dry::Configurable
|
13
16
|
|
14
17
|
setting :pre_release do
|
15
18
|
setting :initial_number, 1
|
19
|
+
setting :default_identifier, 'rc'
|
16
20
|
end
|
17
21
|
|
18
22
|
setting :project do
|
@@ -26,6 +30,24 @@ module Verto
|
|
26
30
|
|
27
31
|
setting :version do
|
28
32
|
setting :prefix, ''
|
33
|
+
setting :validations do
|
34
|
+
setting :new_version_must_be_bigger, true
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
setting :git do
|
39
|
+
setting :pull_before_tag_creation, false
|
40
|
+
setting :push_after_tag_creation, false
|
41
|
+
end
|
42
|
+
|
43
|
+
setting :changelog do
|
44
|
+
setting :format,
|
45
|
+
<<~CHANGELOG
|
46
|
+
## {{new_version}} - #{Time.now.strftime('%d/%m/%Y')}
|
47
|
+
{{#version_changes}}
|
48
|
+
* {{.}}
|
49
|
+
{{/version_changes}}
|
50
|
+
CHANGELOG
|
29
51
|
end
|
30
52
|
|
31
53
|
setting :hooks, []
|
@@ -45,7 +67,10 @@ module Verto
|
|
45
67
|
def self.container
|
46
68
|
@container ||= Dry::Container.new.tap do |container|
|
47
69
|
container.register('system_command_executor') { SystemCommandExecutor.new }
|
48
|
-
container.register('system_command_executor_without_output')
|
70
|
+
container.register('system_command_executor_without_output') do
|
71
|
+
SystemCommandExecutor.new(stdout: nil, stderr: nil)
|
72
|
+
end
|
73
|
+
container.register('cli_helpers') { CliHelpers }
|
49
74
|
|
50
75
|
container.register('tag_repository') { TagRepository.new }
|
51
76
|
|
@@ -63,6 +88,10 @@ module Verto
|
|
63
88
|
container.namespace('project') do
|
64
89
|
register('path') { Verto.config.project.path }
|
65
90
|
end
|
91
|
+
|
92
|
+
container.namespace('changelog') do
|
93
|
+
register('format') { Verto.config.changelog.format }
|
94
|
+
end
|
66
95
|
end
|
67
96
|
end
|
68
97
|
|
@@ -77,18 +106,30 @@ module Verto
|
|
77
106
|
def self.stderr
|
78
107
|
Verto.container.resolve('stderr')
|
79
108
|
end
|
109
|
+
|
110
|
+
def self.current_moment
|
111
|
+
@current_moment
|
112
|
+
end
|
113
|
+
|
114
|
+
def self.current_moment=(moment)
|
115
|
+
@current_moment = moment
|
116
|
+
end
|
80
117
|
end
|
81
118
|
|
82
|
-
require
|
83
|
-
require
|
84
|
-
require
|
85
|
-
require
|
86
|
-
require
|
87
|
-
require
|
88
|
-
require
|
89
|
-
require
|
90
|
-
require
|
91
|
-
require
|
92
|
-
require
|
93
|
-
require
|
94
|
-
require
|
119
|
+
require 'verto/utils/semantic_version.rb'
|
120
|
+
require 'verto/utils/system_command_executor'
|
121
|
+
require 'verto/utils/tag_filter'
|
122
|
+
require 'verto/utils/template'
|
123
|
+
require 'verto/utils/cli_helpers'
|
124
|
+
require 'verto/utils/strict_hash'
|
125
|
+
require 'verto/dsl'
|
126
|
+
require 'verto/dsl/syntax'
|
127
|
+
require 'verto/dsl/interpreter'
|
128
|
+
require 'verto/dsl/hook'
|
129
|
+
require 'verto/dsl/file'
|
130
|
+
require 'verto/dsl/update_changelog'
|
131
|
+
require 'verto/dsl/built_in_hooks'
|
132
|
+
require 'verto/commands/base_command'
|
133
|
+
require 'verto/commands/tag_command'
|
134
|
+
require 'verto/commands/main_command'
|
135
|
+
require 'verto/repositories/tag_repository'
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Verto
|
2
4
|
class BaseCommand < Thor
|
3
5
|
def self.exit_on_failure?
|
@@ -23,8 +25,11 @@ module Verto
|
|
23
25
|
|
24
26
|
moments_to_call.each do |moment|
|
25
27
|
Verto.config.hooks
|
26
|
-
|
27
|
-
|
28
|
+
.select { |hook| hook.moment == moment.to_sym }
|
29
|
+
.each do |hook|
|
30
|
+
Verto.current_moment = hook.moment
|
31
|
+
hook.call(with_attributes: with_attributes)
|
32
|
+
end
|
28
33
|
end
|
29
34
|
end
|
30
35
|
end
|
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Verto
|
2
4
|
class MainCommand < BaseCommand
|
3
|
-
desc
|
5
|
+
desc 'tag SUBCOMMAND ...ARGS', 'manage the repository tags'
|
4
6
|
subcommand 'tag', Verto::TagCommand
|
5
7
|
|
6
|
-
desc
|
8
|
+
desc 'init', 'Initialize a Vertofile in your repository'
|
7
9
|
|
8
10
|
option :path, type: :string, default: nil
|
9
11
|
def init
|
@@ -14,7 +16,7 @@ module Verto
|
|
14
16
|
Template.render('Vertofile', to: path)
|
15
17
|
end
|
16
18
|
|
17
|
-
desc
|
19
|
+
desc 'version', 'Shows Verto version'
|
18
20
|
|
19
21
|
def version
|
20
22
|
Verto.stdout.puts Verto::VERSION
|
@@ -23,12 +25,14 @@ module Verto
|
|
23
25
|
private
|
24
26
|
|
25
27
|
def validate_current_vertofile!(path)
|
28
|
+
return unless Pathname.new(path).join('Vertofile').exist?
|
29
|
+
|
26
30
|
command_error!(
|
27
31
|
<<~ERROR
|
28
|
-
|
29
|
-
|
32
|
+
Project already have a Vertofile.
|
33
|
+
If you want to generate a new with verto init, delete the current one with: `rm Vertofile`
|
30
34
|
ERROR
|
31
|
-
)
|
35
|
+
)
|
32
36
|
end
|
33
37
|
end
|
34
38
|
end
|
@@ -1,6 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Verto
|
2
4
|
class TagCommand < BaseCommand
|
3
|
-
desc
|
5
|
+
desc 'up', "Create's a new tag"
|
4
6
|
|
5
7
|
option :major, type: :boolean, default: false
|
6
8
|
option :minor, type: :boolean, default: false
|
@@ -11,7 +13,9 @@ module Verto
|
|
11
13
|
option :version_prefix, type: :string, default: nil
|
12
14
|
|
13
15
|
def up
|
14
|
-
|
16
|
+
load_config_hooks!
|
17
|
+
|
18
|
+
call_hooks(%i[before before_tag_up], with_attributes: { command_options: options })
|
15
19
|
|
16
20
|
validate_version_option_presence!
|
17
21
|
|
@@ -25,7 +29,7 @@ module Verto
|
|
25
29
|
|
26
30
|
validate_new_version!(new_version, latest_version)
|
27
31
|
|
28
|
-
call_hooks(:before_tag_creation, with_attributes: { new_version: new_version }
|
32
|
+
call_hooks(:before_tag_creation, with_attributes: { new_version: new_version })
|
29
33
|
|
30
34
|
stderr.puts "Creating Tag #{version_prefix}#{new_version}..."
|
31
35
|
tag_repository.create!("#{version_prefix}#{new_version}")
|
@@ -40,20 +44,20 @@ module Verto
|
|
40
44
|
include Verto.import['tag_repository']
|
41
45
|
|
42
46
|
def up_version(version, options)
|
43
|
-
up_options = options.select { |
|
44
|
-
up_option = up_options.
|
47
|
+
up_options = options.select { |_, value| value == true }.keys.map(&:to_sym) & %i[major minor patch]
|
48
|
+
up_option = up_options.min
|
45
49
|
|
46
50
|
new_version = version.up(up_option)
|
47
51
|
|
48
52
|
if options[:pre_release]
|
49
|
-
identifier = pre_release_configured? ? options[:pre_release] : version.pre_release.name
|
53
|
+
identifier = pre_release_configured? ? options[:pre_release] : version.pre_release.name || default_identifier
|
50
54
|
new_version = new_version.with_pre_release(identifier)
|
51
|
-
|
55
|
+
if new_version.pre_release.name == version.pre_release.name && new_version == version
|
56
|
+
new_version = new_version.up(:pre_release)
|
57
|
+
end
|
52
58
|
end
|
53
59
|
|
54
|
-
if options[:release]
|
55
|
-
new_version = new_version.release_version
|
56
|
-
end
|
60
|
+
new_version = new_version.release_version if options[:release]
|
57
61
|
|
58
62
|
new_version
|
59
63
|
end
|
@@ -63,38 +67,44 @@ module Verto
|
|
63
67
|
end
|
64
68
|
|
65
69
|
def validate_latest_tag!(latest_tag)
|
70
|
+
return if latest_tag
|
71
|
+
|
66
72
|
command_error!(
|
67
73
|
<<~TEXT
|
68
74
|
Project doesn't have a previous tag version, create a new tag with git.
|
69
75
|
eg: `git tag #{version_prefix}0.1.0`
|
70
76
|
TEXT
|
71
|
-
)
|
77
|
+
)
|
72
78
|
end
|
73
79
|
|
74
80
|
def validate_new_version!(new_version, latest_version)
|
81
|
+
return unless new_version < latest_version && Verto.config.version.validations.new_version_must_be_bigger
|
82
|
+
|
75
83
|
command_error!(
|
76
84
|
<<~TEXT
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
85
|
+
New version(#{new_version}) can't be equal or lower than latest version(#{latest_version})
|
86
|
+
run up --pre-release with --patch, --minor or --major (eg: verto tag up --patch --pre-release=rc),
|
87
|
+
add filters (eg: verto tag up --pre-release --filter=pre_release_only)
|
88
|
+
or disable tag validation in Vertofile with config.version.validations.new_version_must_be_bigger = false
|
81
89
|
TEXT
|
82
|
-
)
|
90
|
+
)
|
83
91
|
end
|
84
92
|
|
85
93
|
def validate_version_option_presence!
|
94
|
+
return if options[:major] || options[:minor] || options[:patch] || options[:pre_release] || options[:release]
|
95
|
+
|
86
96
|
command_error!(
|
87
97
|
<<~TEXT
|
88
|
-
|
89
|
-
|
98
|
+
You must specify the version number to be increased, use the some of the options(eg: --major, --minor, --patch, --pre_release=rc)
|
99
|
+
or configure a Vertofile to specify a default option for current context, eg:
|
90
100
|
|
91
|
-
|
92
|
-
|
93
|
-
|
101
|
+
context('qa') {
|
102
|
+
before_command('tag_up') {
|
103
|
+
command_options.add(pre_release: 'rc')
|
104
|
+
}
|
94
105
|
}
|
95
|
-
}
|
96
106
|
TEXT
|
97
|
-
)
|
107
|
+
)
|
98
108
|
end
|
99
109
|
|
100
110
|
def load_filter
|
@@ -104,5 +114,16 @@ module Verto
|
|
104
114
|
def version_prefix
|
105
115
|
options[:version_prefix] || Verto.config.version.prefix
|
106
116
|
end
|
117
|
+
|
118
|
+
def load_config_hooks!
|
119
|
+
if Verto.config.git.pull_before_tag_creation
|
120
|
+
Verto.config.hooks.prepend Verto::DSL::BuiltInHooks::GitPullCurrentBranch
|
121
|
+
end
|
122
|
+
Verto.config.hooks << Verto::DSL::BuiltInHooks::GitPushCurrentBranch if Verto.config.git.push_after_tag_creation
|
123
|
+
end
|
124
|
+
|
125
|
+
def default_identifier
|
126
|
+
Verto.config.pre_release.default_identifier
|
127
|
+
end
|
107
128
|
end
|
108
129
|
end
|
data/lib/verto/dsl.rb
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Verto
|
4
|
+
module DSL
|
5
|
+
module BuiltInHooks
|
6
|
+
GitPullCurrentBranch = DSL::Hook.new(moment: :before) do
|
7
|
+
git!("pull origin #{current_branch}")
|
8
|
+
end
|
9
|
+
|
10
|
+
GitPushTags = DSL::Hook.new(moment: :after) do
|
11
|
+
git!('push --tags')
|
12
|
+
end
|
13
|
+
|
14
|
+
GitPushCurrentBranchCommits = DSL::Hook.new(moment: :after) do
|
15
|
+
git!("push origin #{current_branch}")
|
16
|
+
end
|
17
|
+
|
18
|
+
GitPushCurrentBranch = DSL::Hook.new(moment: :after) do
|
19
|
+
GitPushTags.call
|
20
|
+
GitPushCurrentBranchCommits.call
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/verto/dsl/file.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Verto
|
2
4
|
module DSL
|
3
5
|
class File
|
@@ -36,8 +38,8 @@ module Verto
|
|
36
38
|
end
|
37
39
|
end
|
38
40
|
|
39
|
-
|
40
|
-
|
41
|
+
alias gsub replace_all
|
42
|
+
alias sub replace
|
41
43
|
|
42
44
|
private
|
43
45
|
|