verto 0.6.0 → 0.10.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: 768852b8be876572bb72068a3865eaeee672d20baa976923758c9634b901a52d
4
- data.tar.gz: 98339f920377dd25299a8240d5e10da2f5161fd749f5753d593d1878de4e6e9c
3
+ metadata.gz: ec5d303284b7d17001dacb3f3daa72ba1d47601dffb325790e61ec941f2f2b84
4
+ data.tar.gz: f078471b8bb4cb5243cfdb5748332a7582a8d26f3da17a19d6b3777757b8a2d0
5
5
  SHA512:
6
- metadata.gz: 8532433e33edc4061b286d8ab409c70d668d231eed44a20b245243f94de4cdf794754c39b588212c71a10ec8522aa02f5b76ee21b6f636f2e283c2219989da66
7
- data.tar.gz: c04e86927b7edcece876e739fc149743e99f972d86bbab755f86b0c006abf90caa255be1f35bdd6366e0e0387b6c9dbe80d97475394c7263c979cd86d89492d8
6
+ metadata.gz: 21e6d0f0e89edcb6f0ec6b2892ad0a8c71d81623f602daacc9103b2d51508c570273e05151e0143f2e7915678faa4e598eab10efd369058041bf892112fdc38b
7
+ data.tar.gz: 534cc6aecfd85f5e027d0fd6e31dcfe4b41e88c33aedff39b5f66919826005a8bab6ced748fc70471086a9b4eabadf6ebde208b591b2d08b633a482e548730b2
@@ -1,3 +1,18 @@
1
+ ## 0.10.0 - 14/10/2020
2
+ * [FEATURE] Adds update_changelog in DSL
3
+
4
+ ## 0.9.0 - 08/08/2020
5
+ * [FEATURE] Custom Default Pre-Release Identifier
6
+
7
+ ## 0.8.0 - 05/05/2020
8
+ * [PATCH] Handles Ctrl-C / SIGINT in CLI
9
+
10
+ ## 0.7.0 - 29/04/2020
11
+ * [FEATURE Built In Git Hooks]
12
+
13
+ ## 0.6.1 - 15/04/2020
14
+ * [FIX] Fix Vertofile to add Gemfile.lock before release
15
+
1
16
  ## 0.6.0 - 14/04/2020
2
17
  * [FEATURE] Adds Version Prefix
3
18
 
@@ -1,10 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- verto (0.5.0)
4
+ verto (0.10.0)
5
5
  dry-auto_inject (~> 0.7)
6
6
  dry-configurable (~> 0.8)
7
7
  dry-container (~> 0.7)
8
+ mustache (~> 1.1.1)
8
9
  thor (~> 1.0.1)
9
10
  vseries (~> 0.2)
10
11
 
@@ -12,12 +13,12 @@ GEM
12
13
  remote: https://rubygems.org/
13
14
  specs:
14
15
  byebug (11.1.1)
15
- concurrent-ruby (1.1.6)
16
+ concurrent-ruby (1.1.7)
16
17
  diff-lcs (1.3)
17
18
  docile (1.3.2)
18
19
  dry-auto_inject (0.7.0)
19
20
  dry-container (>= 0.3.4)
20
- dry-configurable (0.11.5)
21
+ dry-configurable (0.11.6)
21
22
  concurrent-ruby (~> 1.0)
22
23
  dry-core (~> 0.4, >= 0.4.7)
23
24
  dry-equalizer (~> 0.2)
@@ -27,6 +28,7 @@ GEM
27
28
  dry-core (0.4.9)
28
29
  concurrent-ruby (~> 1.0)
29
30
  dry-equalizer (0.3.0)
31
+ mustache (1.1.1)
30
32
  rake (13.0.1)
31
33
  rspec (3.9.0)
32
34
  rspec-core (~> 3.9.0)
data/README.md CHANGED
@@ -32,28 +32,20 @@ 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
  ```shell
35
- alias verto='docker run -v $(pwd):/usr/src/project -it catks/verto:0.6.0'
35
+ alias verto='docker run -v $(pwd):/usr/src/project -it catks/verto:0.10.0'
36
36
  ```
37
37
 
38
38
  If you want you can share your git configuration and known_hosts with:
39
39
 
40
40
  ```shell
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.6.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.10.0'
42
42
 
43
43
  ```
44
44
 
45
- You can also use your ssh keys with verto container (for git push):
45
+ You can also use your ssh keys, know_hosts and git config with verto container (for git push):
46
46
 
47
47
  ```shell
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.6.0'
49
-
50
- ```
51
-
52
- Or share the git config, known_hosts and ssh_keys:
53
-
54
-
55
- ```shell
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.6.0'
48
+ 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.10.0'
57
49
 
58
50
  ```
59
51
 
@@ -93,72 +85,75 @@ You can create a new Vertofile with `verto init` or following the next example:
93
85
  ```ruby
94
86
  # Vertofile
95
87
 
96
- verto_version '0.6.0'
88
+ verto_version '0.10.0'
97
89
 
98
90
  config {
99
91
  # version.prefix = 'v' # Adds a version_prefix
92
+ # pre_release.default_identifier = 'alpha' } # Defaults to 'rc'
93
+ git.pull_before_tag_creation = true # Pull Changes before tag creation
94
+ git.push_after_tag_creation = true # Push changes after tag creation
95
+
96
+ ## CHANGELOG FORMAT
97
+ ## Verto uses Mustache template rendering to render changelog updates, the default value is:
98
+ ##
99
+ ## ## {{new_version}} - #{Time.now.strftime('%d/%m/%Y')}
100
+ ## {{#version_changes}}
101
+ ## * {{.}}
102
+ ## {{/version_changes}}
103
+ ##
104
+ ## A custom format can be specified, eg:
105
+ # changelog.format = <<~CHANGELOG
106
+ # ## {{new_version}}
107
+ # {{#version_changes}}
108
+ # * {{.}}
109
+ # {{/version_changes}}
110
+ # CHANGELOG
100
111
  }
101
112
 
102
113
  context(branch('master')) {
103
- before_command('tag_up') {
104
- git!('origin master')
114
+ before_command_tag_up {
105
115
  command_options.add(filter: 'release_only')
106
116
  }
107
117
 
108
- on('before_tag_creation') {
109
-
110
- version_changes = sh(
111
- %q#git log --oneline --decorate | grep -B 100 -m 1 "tag:" | grep "pull request" | awk '{print $1}' | xargs git show --format='%b' | grep -v Approved | grep -v "^$" | grep -E "^[[:space:]]*\[.*\]" | sed 's/^[[:space:]]*\(.*\)/ * \1/'#, output: false
112
- ).output
113
-
114
- puts "---------------------------"
115
- version_changes = "## #{new_version} - #{Time.now.strftime('%d/%m/%Y')}\n#{version_changes}\n"
116
- exit unless confirm("Create new Realease?\n" \
117
- "---------------------------\n" \
118
- "#{version_changes}" \
119
- "---------------------------\n"
118
+ before_tag_creation {
119
+ update_changelog(
120
+ with: :merged_pull_requests_with_bracketed_labels, # Optional, defines the strategy to retrive the changes, default: :merged_pull_requests_with_bracketed_labels
121
+ confirmation: true, # Optional, asks for confirmation before updating the changelog, default: true
122
+ filename: 'CHANGELOG.md' # Optional, defines the filename of the CHANGELOG file, default: 'CHANGELOG.md'
120
123
  )
121
-
122
- # CHANGELOG
123
- file('CHANGELOG.md').prepend(version_changes)
124
124
  git('add CHANGELOG.md')
125
125
 
126
126
  # Uncomment to update the version in other files, like package.json
127
127
  # file('package.json').replace(/"(\d+)\.(\d+)\.(\d+)(-?.*)"/, %Q{"#{new_version}"})
128
128
  # git('add package.json')
129
129
 
130
- git('commit -m "Updates CHANGELOG"')
130
+ git!('commit -m "Updates CHANGELOG"')
131
131
  }
132
132
 
133
- after_command('tag_up') {
134
- git('push --tags')
135
- git('push origin master')
136
- }
133
+ # After Hooks
134
+ # after_command_tag_up {
135
+ # git('push --tags')
136
+ # git('push origin master')
137
+ # }
137
138
  }
138
139
 
139
140
  context(branch('staging')) {
140
- before_command('tag_up') {
141
+ before_command_tag_up {
141
142
  git!('pull origin staging')
142
143
  command_options.add(pre_release: 'rc')
143
144
  }
144
145
 
145
- on('before_tag_creation') {
146
+ before_tag_creation {
146
147
  # file('package.json').replace(/"(\d+)\.(\d+)\.(\d+)(-?.*)"/, %Q{"#{new_version}"})
147
148
  # git('add package.json')
148
149
 
149
- git('commit -m "Release QA"')
150
- git('commit --allow-empty -m "Staging Release"')
151
- }
152
-
153
- after_command('tag_up') {
154
- git('push --tags')
155
- git('push origin staging')
150
+ git!('commit --allow-empty -m "Staging Release"')
156
151
  }
157
152
  }
158
153
 
159
154
  # Block tag creation in other branchs
160
155
  context(!branch('master', 'staging')) {
161
- error "Tags only can be created in master or staging branch"
156
+ error "Tags can only be created in master or staging branch"
162
157
  exit
163
158
  }
164
159
  ```
@@ -171,7 +166,7 @@ context(!branch('master', 'staging')) {
171
166
 
172
167
  1. Complete README.md description
173
168
  2. Add a configuration to enable, disable or specify the number of tags that a single commit can have(eg: only one release and one pre-release)
174
- 5. Adds more specs and test coverage in CI
169
+ 3. Adds more specs and test coverage in CI
175
170
 
176
171
  ## Contributing
177
172
 
data/Vertofile CHANGED
@@ -1,32 +1,18 @@
1
- verto_version '0.5.0'
1
+ verto_version '0.10.0'
2
2
 
3
3
  config {
4
- version.prefix = 'v' # Adds a version_prefix
4
+ version.prefix = 'v' # Adds a version_prefix
5
+ git.pull_before_tag_creation = true
6
+ git.push_after_tag_creation = true
5
7
  }
6
8
 
7
9
  context(branch('master')) {
8
- before_command('tag_up') {
9
- git!('pull origin master')
10
+ before_command_tag_up {
10
11
  command_options.add(filter: 'release_only')
11
12
  }
12
13
 
13
- on('before_tag_creation') {
14
- version_changes = ""
15
- bitbucket_changes = sh(
16
- %q#git log --oneline --decorate | grep -B 100 -m 1 "tag:" | grep "pull request" | awk '{print $1}' | xargs git show --format='%b' | grep -v Approved | grep -v "^$" | grep -E "^[[:space:]]*\[.*\]" | sed 's/^[[:space:]]*\(.*\)/ * \1/'#, output: false
17
- ).output
18
- version_changes = bitbucket_changes
19
-
20
- puts "---------------------------"
21
- version_changes = "## #{new_version} - #{Time.now.strftime('%d/%m/%Y')}\n#{version_changes}\n"
22
- exit unless confirm("Create new Realease?\n" \
23
- "---------------------------\n" \
24
- "#{version_changes}" \
25
- "---------------------------\n"
26
- )
27
-
28
- # CHANGELOG
29
- file('CHANGELOG.md').prepend(version_changes)
14
+ before_tag_creation {
15
+ update_changelog
30
16
  git!('add CHANGELOG.md')
31
17
 
32
18
  file('lib/verto/version.rb').replace(latest_version.to_s, new_version.to_s)
@@ -36,18 +22,14 @@ context(branch('master')) {
36
22
  git!('add README.md')
37
23
 
38
24
  file('lib/verto/utils/templates/Vertofile').replace(latest_version.to_s, new_version.to_s)
39
- git!('add lib/verto/utils/templates/Vertofile')
25
+ file('Vertofile').replace(latest_version.to_s, new_version.to_s)
40
26
 
27
+ git!('add Vertofile lib/verto/utils/templates/Vertofile')
28
+
29
+ sh!('bundle install')
41
30
  sh!('rake install')
42
31
  git!('add Gemfile.lock')
43
32
 
44
33
  git!('commit -m "Bumps Version"')
45
34
  }
46
-
47
- after_command('tag_up') {
48
- git!('push --tags')
49
- git!('push origin master')
50
- sh!('rake release')
51
- }
52
35
  }
53
-
@@ -0,0 +1,8 @@
1
+ djin_version: '0.6.0'
2
+
3
+ tasks:
4
+ release:
5
+ local:
6
+ run:
7
+ - verto tag up {{args}}
8
+ - bundle exec rake release
data/exe/verto CHANGED
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
+ Signal.trap("INT") { exit 2 }
2
3
 
3
4
  require_relative '../lib/verto'
4
5
 
5
6
  vertofile_path = ENV['VERTOFILE_PATH'] || Pathname.new(Dir.pwd).join('Vertofile').to_s
6
-
7
7
  begin
8
8
  Verto::DSL.load_file(vertofile_path) if File.exists?(vertofile_path)
9
9
 
@@ -3,6 +3,7 @@ require "dry-container"
3
3
  require "dry-configurable"
4
4
  require "dry-auto_inject"
5
5
  require "vseries"
6
+ require "mustache"
6
7
  require "pathname"
7
8
 
8
9
  require "verto/version"
@@ -13,6 +14,7 @@ module Verto
13
14
 
14
15
  setting :pre_release do
15
16
  setting :initial_number, 1
17
+ setting :default_identifier, 'rc'
16
18
  end
17
19
 
18
20
  setting :project do
@@ -26,6 +28,24 @@ module Verto
26
28
 
27
29
  setting :version do
28
30
  setting :prefix, ''
31
+ setting :validations do
32
+ setting :new_version_must_be_bigger, true
33
+ end
34
+ end
35
+
36
+ setting :git do
37
+ setting :pull_before_tag_creation, false
38
+ setting :push_after_tag_creation, false
39
+ end
40
+
41
+ setting :changelog do
42
+ setting :format,
43
+ <<~CHANGELOG
44
+ ## {{new_version}} - #{Time.now.strftime('%d/%m/%Y')}
45
+ {{#version_changes}}
46
+ * {{.}}
47
+ {{/version_changes}}
48
+ CHANGELOG
29
49
  end
30
50
 
31
51
  setting :hooks, []
@@ -46,6 +66,7 @@ module Verto
46
66
  @container ||= Dry::Container.new.tap do |container|
47
67
  container.register('system_command_executor') { SystemCommandExecutor.new }
48
68
  container.register('system_command_executor_without_output') { SystemCommandExecutor.new(stdout: nil, stderr: nil) }
69
+ container.register('cli_helpers') { CliHelpers }
49
70
 
50
71
  container.register('tag_repository') { TagRepository.new }
51
72
 
@@ -63,6 +84,10 @@ module Verto
63
84
  container.namespace('project') do
64
85
  register('path') { Verto.config.project.path }
65
86
  end
87
+
88
+ container.namespace('changelog') do
89
+ register('format') { Verto.config.changelog.format }
90
+ end
66
91
  end
67
92
  end
68
93
 
@@ -77,17 +102,29 @@ module Verto
77
102
  def self.stderr
78
103
  Verto.container.resolve('stderr')
79
104
  end
105
+
106
+ def self.current_moment
107
+ @current_moment
108
+ end
109
+
110
+ def self.current_moment=(moment)
111
+ @current_moment = moment
112
+ end
80
113
  end
81
114
 
82
115
  require "verto/utils/semantic_version.rb"
83
116
  require "verto/utils/system_command_executor"
84
117
  require "verto/utils/tag_filter"
85
118
  require "verto/utils/template"
119
+ require "verto/utils/cli_helpers"
120
+ require "verto/utils/strict_hash"
86
121
  require "verto/dsl"
87
122
  require "verto/dsl/syntax"
88
123
  require "verto/dsl/interpreter"
89
124
  require "verto/dsl/hook"
90
125
  require "verto/dsl/file"
126
+ require "verto/dsl/update_changelog"
127
+ require "verto/dsl/built_in_hooks"
91
128
  require "verto/commands/base_command"
92
129
  require "verto/commands/tag_command"
93
130
  require "verto/commands/main_command"
@@ -24,7 +24,10 @@ module Verto
24
24
  moments_to_call.each do |moment|
25
25
  Verto.config.hooks
26
26
  .select { |hook| hook.moment == moment.to_sym }
27
- .each { |hook| hook.call(with_attributes: with_attributes) }
27
+ .each do |hook|
28
+ Verto.current_moment = hook.moment
29
+ hook.call(with_attributes: with_attributes)
30
+ end
28
31
  end
29
32
  end
30
33
  end
@@ -11,6 +11,8 @@ module Verto
11
11
  option :version_prefix, type: :string, default: nil
12
12
 
13
13
  def up
14
+ load_config_hooks!
15
+
14
16
  call_hooks(%i[before before_tag_up], with_attributes: { command_options: options} )
15
17
 
16
18
  validate_version_option_presence!
@@ -40,13 +42,13 @@ module Verto
40
42
  include Verto.import['tag_repository']
41
43
 
42
44
  def up_version(version, options)
43
- up_options = options.select { |key,value| value == true }.keys.map(&:to_sym) & [:major, :minor, :patch]
44
- up_option = up_options.sort.first
45
+ up_options = options.select { |_, value| value == true }.keys.map(&:to_sym) & [:major, :minor, :patch]
46
+ up_option = up_options.min
45
47
 
46
48
  new_version = version.up(up_option)
47
49
 
48
50
  if options[:pre_release]
49
- identifier = pre_release_configured? ? options[:pre_release] : version.pre_release.name
51
+ identifier = pre_release_configured? ? options[:pre_release] : version.pre_release.name || default_identifier
50
52
  new_version = new_version.with_pre_release(identifier)
51
53
  new_version = new_version.up(:pre_release) if new_version.pre_release.name == version.pre_release.name && new_version == version
52
54
  end
@@ -75,11 +77,11 @@ module Verto
75
77
  command_error!(
76
78
  <<~TEXT
77
79
  New version(#{new_version}) can't be equal or lower than latest version(#{latest_version})
78
- run up --pre-release with --patch, --minor or --major (eg: verto tag up --pre-release --patch),
80
+ run up --pre-release with --patch, --minor or --major (eg: verto tag up --patch --pre-release=rc),
79
81
  add filters (eg: verto tag up --pre-release --filter=pre_release_only)
80
82
  or disable tag validation in Vertofile with config.version.validations.new_version_must_be_bigger = false
81
83
  TEXT
82
- ) if new_version < latest_version
84
+ ) if new_version < latest_version && Verto.config.version.validations.new_version_must_be_bigger
83
85
  end
84
86
 
85
87
  def validate_version_option_presence!
@@ -104,5 +106,14 @@ module Verto
104
106
  def version_prefix
105
107
  options[:version_prefix] || Verto.config.version.prefix
106
108
  end
109
+
110
+ def load_config_hooks!
111
+ Verto.config.hooks.prepend Verto::DSL::BuiltInHooks::GitPullCurrentBranch if Verto.config.git.pull_before_tag_creation
112
+ Verto.config.hooks << Verto::DSL::BuiltInHooks::GitPushCurrentBranch if Verto.config.git.push_after_tag_creation
113
+ end
114
+
115
+ def default_identifier
116
+ Verto.config.pre_release.default_identifier
117
+ end
107
118
  end
108
119
  end
@@ -0,0 +1,22 @@
1
+ module Verto
2
+ module DSL
3
+ module BuiltInHooks
4
+ GitPullCurrentBranch = DSL::Hook.new(moment: :before) do
5
+ git!("pull origin #{current_branch}")
6
+ end
7
+
8
+ GitPushTags = DSL::Hook.new(moment: :after) do
9
+ git!("push --tags")
10
+ end
11
+
12
+ GitPushCurrentBranchCommits = DSL::Hook.new(moment: :after) do
13
+ git!("push origin #{current_branch}")
14
+ end
15
+
16
+ GitPushCurrentBranch = DSL::Hook.new(moment: :after) do
17
+ GitPushTags.call
18
+ GitPushCurrentBranchCommits.call
19
+ end
20
+ end
21
+ end
22
+ end
@@ -55,17 +55,13 @@ module Verto
55
55
  end
56
56
 
57
57
  def sh!(command, output: :from_config)
58
- raise Verto::ExitError unless sh(command, output: output).success?
58
+ raise Verto::ExitError, command unless sh(command, output: output).success?
59
59
  end
60
60
 
61
61
  def command_options
62
62
  Verto.config.command_options
63
63
  end
64
64
 
65
- def on(moment, &block)
66
- Verto.config.hooks << Hook.new(moment: moment, &block)
67
- end
68
-
69
65
  def before(&block)
70
66
  Verto.config.hooks << Hook.new(moment: :before, &block)
71
67
  end
@@ -74,14 +70,48 @@ module Verto
74
70
  Verto.config.hooks << Hook.new(moment: :after, &block)
75
71
  end
76
72
 
73
+ def on(moment, &block)
74
+ deprecate('on', use: 'before_tag_creation')
75
+
76
+ Verto.config.hooks << Hook.new(moment: moment, &block)
77
+ end
78
+
77
79
  def before_command(command_name, &block)
80
+ deprecate('before_command', use: 'before_command_tag_up')
81
+
78
82
  Verto.config.hooks << Hook.new(moment: "before_#{command_name}", &block)
79
83
  end
80
84
 
81
85
  def after_command(command_name, &block)
86
+ deprecate('after_command', use: 'after_command_tag_up')
87
+
82
88
  Verto.config.hooks << Hook.new(moment: "after_#{command_name}", &block)
83
89
  end
84
90
 
91
+ def before_command_tag_up(&block)
92
+ Verto.config.hooks << Hook.new(moment: 'before_tag_up', &block)
93
+ end
94
+
95
+ def after_command_tag_up(&block)
96
+ Verto.config.hooks << Hook.new(moment: 'after_tag_up', &block)
97
+ end
98
+
99
+ def before_tag_creation(&block)
100
+ Verto.config.hooks << Hook.new(moment: 'before_tag_creation', &block)
101
+ end
102
+
103
+ def update_changelog(with: :merged_pull_requests_with_bracketed_labels, confirmation: true, filename: 'CHANGELOG.md')
104
+ permitted_moments = %w[before_tag_creation after_tag_up]
105
+ unless permitted_moments.include? Verto.current_moment.to_s
106
+ raise ExitError, 'update_changelog is only supported in before_tag_creation or after_command_tag_up'
107
+ end
108
+
109
+ UpdateChangelog.new.call(with: with,
110
+ new_version: new_version,
111
+ confirmation: confirmation,
112
+ filename: filename)
113
+ end
114
+
85
115
  def file(filepath)
86
116
  DSL::File.new(filepath)
87
117
  end
@@ -90,8 +120,9 @@ module Verto
90
120
  ENV[environment_name]
91
121
  end
92
122
 
123
+ # TODO: Use delegator
93
124
  def confirm(text)
94
- shell_basic.yes?("#{text} (y/n)")
125
+ CliHelpers.confirm(text)
95
126
  end
96
127
 
97
128
  def error(text)
@@ -110,16 +141,12 @@ module Verto
110
141
  @executors ||= {
111
142
  from_config: Verto::SystemCommandExecutor.new,
112
143
  true => Verto::SystemCommandExecutor.new(stdout: $stdout, stderr: $stderr),
113
- false => Verto::SystemCommandExecutor.new(stdout: nil, stderr: nil),
144
+ false => Verto::SystemCommandExecutor.new(stdout: nil, stderr: nil)
114
145
  }
115
146
 
116
147
  @executors[output]
117
148
  end
118
149
 
119
- def shell_basic
120
- @shell_basic ||= Thor::Shell::Basic.new
121
- end
122
-
123
150
  def stderr
124
151
  Verto.stderr
125
152
  end
@@ -135,6 +162,10 @@ module Verto
135
162
 
136
163
  SemanticVersion.new(tag_version)
137
164
  end
165
+
166
+ def deprecate(current, use:)
167
+ warn "[DEPRECATED] `#{current}` is deprecated and will be removed in a future release, use `#{use}` instead"
168
+ end
138
169
  end
139
170
  end
140
171
  end
@@ -0,0 +1,56 @@
1
+ module Verto
2
+ module DSL
3
+ class UpdateChangelog
4
+ include Verto.import[:cli_helpers, :stdout,
5
+ executor: 'system_command_executor_without_output', changelog_format: 'changelog.format']
6
+
7
+ InvalidChangelogSource = Class.new(Verto::ExitError)
8
+
9
+ SOURCES = StrictHash.new(
10
+ {
11
+ merged_pull_requests_with_bracketed_labels: lambda do |executor|
12
+ executor.run(
13
+ %q#git log --oneline --decorate | grep -B 100 -m 1 "tag:" | grep "pull request" | awk '{print $1}' | xargs git show --format='%b' | grep -v Approved | grep -v "^$" | grep -E "^[[:space:]]*\[.*\]"#
14
+ ).output.split('\n').map(&:strip)
15
+ end
16
+ },
17
+ default_proc: ->(hash, _) { raise InvalidChangelogSource, "Invalid CHANGELOG Source, avaliable options: '#{hash.keys.join(',')}'" }
18
+ )
19
+
20
+ def call(new_version:, confirmation: true, filename: 'CHANGELOG.md', with: :merged_pull_requests_with_bracketed_labels)
21
+ verify_file_presence!(filename)
22
+
23
+ stdout.puts separator
24
+ changelog_changes = format_changes(new_version, version_changes(with))
25
+
26
+ exit if confirmation && !cli_helpers.confirm("Create new Realease?\n" \
27
+ "#{separator}\n" \
28
+ "#{changelog_changes}" \
29
+ "#{separator}\n")
30
+ update_file(filename, changelog_changes)
31
+ end
32
+
33
+ private
34
+
35
+ def verify_file_presence!(filename)
36
+ raise Verto::ExitError, "changelog file '#{filename}' doesnt exist" unless Verto.project_path.join(filename).exist?
37
+ end
38
+
39
+ def version_changes(with)
40
+ SOURCES[with].call(executor)
41
+ end
42
+
43
+ def update_file(filename, changelog_changes)
44
+ DSL::File.new(filename).prepend(changelog_changes)
45
+ end
46
+
47
+ def format_changes(new_version, version_changes)
48
+ Mustache.render(changelog_format, { new_version: new_version, version_changes: version_changes }) + "\n"
49
+ end
50
+
51
+ def separator
52
+ '---------------------------'
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,13 @@
1
+ module CliHelpers
2
+ class << self
3
+ def confirm(text)
4
+ shell_basic.yes?("#{text} (y/n)")
5
+ end
6
+
7
+ private
8
+
9
+ def shell_basic
10
+ @shell_basic ||= Thor::Shell::Basic.new
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,7 @@
1
+ class StrictHash < Hash
2
+ def initialize(hash, default_proc: nil)
3
+ super()
4
+ self.default_proc = default_proc if default_proc
5
+ merge!(hash)
6
+ end
7
+ end
@@ -1,36 +1,40 @@
1
- verto_version '0.6.0'
1
+ verto_version '0.10.0'
2
2
 
3
3
  config {
4
4
  # version.prefix = 'v' # Adds a version_prefix
5
5
  # pre_release.initial_number = 0 # Configures pre_release initial number, defaults to 1
6
6
  # project.path = "#{project_path}" # Configures a custom project path
7
+ # git.pull_before_tag_creation = true # Pull Changes before tag creation
8
+ # git.push_after_tag_creation = true # Push changes after tag creation
9
+
10
+ ## CHANGELOG FORMAT
11
+ ## Verto uses Mustache template rendering to render changelog updates, the default value is:
12
+ ##
13
+ ## ## {{new_version}} - #{Time.now.strftime('%d/%m/%Y')}
14
+ ## {{#version_changes}}
15
+ ## * {{.}}
16
+ ## {{/version_changes}}
17
+ ##
18
+ ## A custom format can be specified, eg:
19
+ # changelog.format = <<~CHANGELOG
20
+ # ## {{new_version}}
21
+ # {{#version_changes}}
22
+ # * {{.}}
23
+ # {{/version_changes}}
24
+ # CHANGELOG}
7
25
  }
8
26
 
9
27
  context(branch('master')) {
10
- before_command('tag_up') {
11
- git!('pull origin master')
28
+ before_command_tag_up {
12
29
  command_options.add(filter: 'release_only')
13
30
  }
14
31
 
15
- on('before_tag_creation') {
16
-
17
- version_changes = ""
18
- # Uncomment to get Merged PRs Titles as changes to add in CHANGELOG.
19
- # version_changes = sh(
20
- # %q#git log --oneline --decorate | grep -B 100 -m 1 "tag:" | grep "pull request" | awk '{print $1}' | xargs git show --format='%b' | grep -v Approved | grep -v "^$" | grep -E "^[[:space:]]*\[.*\]" | sed 's/^[[:space:]]*\(.*\)/ * \1/'#, output: false
21
- # ).output
22
-
23
- puts "---------------------------"
24
- version_changes = "## #{new_version} - #{Time.now.strftime('%d/%m/%Y')}\n#{version_changes}\n"
25
- exit unless confirm("Create new Realease?\n" \
26
- "---------------------------\n" \
27
- "#{version_changes}" \
28
- "---------------------------\n"
29
- )
30
-
31
- # CHANGELOG
32
- file('CHANGELOG.md').prepend(version_changes)
33
- git('add CHANGELOG.md')
32
+ before_tag_creation{
33
+ # Uncomment to update CHANGELOG file
34
+ # update_changelog(with: :merged_pull_requests_with_bracketed_labels,
35
+ # confirmation: true,
36
+ # filename: 'CHANGELOG.md')
37
+ # git('add CHANGELOG.md')
34
38
 
35
39
  # Uncomment to update the version in other files, like package.json
36
40
  # file('package.json').replace(/"(\d+)\.(\d+)\.(\d+)(-?.*)"/, %Q{"#{new_version}"})
@@ -38,29 +42,23 @@ context(branch('master')) {
38
42
 
39
43
  git('commit -m "Updates CHANGELOG"')
40
44
  }
41
-
42
- after_command('tag_up') {
43
- git('push --tags')
44
- git('push origin master')
45
- }
46
45
  }
47
46
 
48
47
  # Uncomment to get a specific pre_release proccess, like a staging or qa branch
49
48
  # context(branch('staging')) {
50
- # before_command('tag_up') {
49
+ # before_command_tag_up {
51
50
  # git!('pull origin staging')
52
51
  # command_options.add(pre_release: 'rc')
53
52
  # }
54
53
  #
55
- # on('before_tag_creation') {
54
+ # before_tag_creation {
56
55
  # file('package.json').replace(/"(\d+)\.(\d+)\.(\d+)(-?.*)"/, %Q{"#{new_version}"}) # Atualiza versão do package.json
57
56
  # git('add package.json')
58
57
  # git('commit --allow-empty -m "Staging Release"')
59
58
  # }
60
59
 
61
- # after_command('tag_up') {
62
- # git('push --tags')
63
- # git('push origin staging')
60
+ # after_command_tag_up {
61
+ # sh('some command')
64
62
  # }
65
63
  #}
66
64
 
@@ -1,3 +1,3 @@
1
1
  module Verto
2
- VERSION = "0.6.0"
2
+ VERSION = "0.10.0"
3
3
  end
@@ -13,9 +13,9 @@ Gem::Specification.new do |spec|
13
13
  spec.license = "MIT"
14
14
 
15
15
 
16
- # spec.metadata["homepage_uri"] = spec.homepage
17
- # spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
18
- # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
16
+ spec.metadata["homepage_uri"] = spec.homepage
17
+ spec.metadata["source_code_uri"] = "https://github.com/catks/verto"
18
+ spec.metadata["changelog_uri"] = "https://github.com/catks/verto/blob/master/CHANGELOG.md"
19
19
 
20
20
  # Specify which files should be added to the gem when it is released.
21
21
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -31,6 +31,7 @@ Gem::Specification.new do |spec|
31
31
  spec.add_dependency "dry-container", "~> 0.7"
32
32
  spec.add_dependency "dry-auto_inject", "~> 0.7"
33
33
  spec.add_dependency "vseries", "~> 0.2"
34
+ spec.add_dependency "mustache", "~> 1.1.1"
34
35
 
35
36
  spec.add_development_dependency "byebug"
36
37
  spec.add_development_dependency "bundler", "~> 2.0"
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.6.0
4
+ version: 0.10.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-04-15 00:00:00.000000000 Z
11
+ date: 2021-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0.2'
83
+ - !ruby/object:Gem::Dependency
84
+ name: mustache
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 1.1.1
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 1.1.1
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: byebug
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -172,6 +186,7 @@ files:
172
186
  - Vertofile
173
187
  - bin/console
174
188
  - bin/setup
189
+ - djin.yml
175
190
  - docker-entrypoint.sh
176
191
  - exe/verto
177
192
  - lib/verto.rb
@@ -179,13 +194,17 @@ files:
179
194
  - lib/verto/commands/main_command.rb
180
195
  - lib/verto/commands/tag_command.rb
181
196
  - lib/verto/dsl.rb
197
+ - lib/verto/dsl/built_in_hooks.rb
182
198
  - lib/verto/dsl/file.rb
183
199
  - lib/verto/dsl/hook.rb
184
200
  - lib/verto/dsl/interpreter.rb
185
201
  - lib/verto/dsl/syntax.rb
202
+ - lib/verto/dsl/update_changelog.rb
186
203
  - lib/verto/repositories/tag_repository.rb
204
+ - lib/verto/utils/cli_helpers.rb
187
205
  - lib/verto/utils/command_options.rb
188
206
  - lib/verto/utils/semantic_version.rb
207
+ - lib/verto/utils/strict_hash.rb
189
208
  - lib/verto/utils/system_command_executor.rb
190
209
  - lib/verto/utils/tag_filter.rb
191
210
  - lib/verto/utils/template.rb
@@ -195,7 +214,10 @@ files:
195
214
  homepage: https://github.com/catks/verto
196
215
  licenses:
197
216
  - MIT
198
- metadata: {}
217
+ metadata:
218
+ homepage_uri: https://github.com/catks/verto
219
+ source_code_uri: https://github.com/catks/verto
220
+ changelog_uri: https://github.com/catks/verto/blob/master/CHANGELOG.md
199
221
  post_install_message:
200
222
  rdoc_options: []
201
223
  require_paths: