codelog 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +12 -3
- data/lib/codelog.rb +3 -0
- data/lib/codelog/cli.rb +12 -4
- data/lib/codelog/command/bump.rb +8 -4
- data/lib/codelog/command/preview.rb +14 -0
- data/lib/codelog/command/release.rb +4 -1
- data/lib/codelog/command/step/version.rb +19 -20
- data/lib/codelog/output/log.rb +13 -0
- data/lib/codelog/output/release_file.rb +21 -0
- data/lib/codelog/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9fd159ca76edb63f2a839baec37d89232d902edff3bc6ccdd7b4d57d97679090
|
4
|
+
data.tar.gz: d8bb75225596663caa438ec42293222de1555305186022e96b2a22bf024411e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d42fca0648b5eb83c9cb6d52c38ba692bc253afaa50e964561e967b87db5c0f47a2dbb90f07c94f4f3de356f57c66366bcf27451d872093547d9f17c5e045714
|
7
|
+
data.tar.gz: '079daac82645810755408249ebc81ebe2feaef4ccbdddec7bdabfc0cd14b2569f20ea5b7e8eea2db3abdb59e1d61ee360fc5093ccb5034ed09ad809a93085ddd'
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file.
|
|
3
3
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
4
4
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
5
5
|
|
6
|
+
## 0.8.0
|
7
|
+
### Added
|
8
|
+
- Preview option for changelogs on the `release` and `bump` command
|
9
|
+
|
10
|
+
### Fixed
|
11
|
+
- Test file (`version_spec`), previously, this test would fail if you run it alone
|
12
|
+
|
13
|
+
---
|
6
14
|
## 0.7.0
|
7
15
|
### Added
|
8
16
|
- Command `codelog bump [major|minor|patch]` that automatically sets the next version
|
data/README.md
CHANGED
@@ -76,9 +76,9 @@ After the initial setup every time a change is made, the developer should run th
|
|
76
76
|
$ codelog new <NAME>
|
77
77
|
```
|
78
78
|
|
79
|
-
This will generate a change file, in `YAML` format, on `changelogs/unreleased/` from the `template.yml`, named with a timestamp value followed by the
|
79
|
+
This will generate a change file, in `YAML` format, on `changelogs/unreleased/` from the `template.yml`, named with a timestamp value followed by the given `NAME`, converted to snake case, or the default name(`change`).
|
80
80
|
|
81
|
-
The new change file should be filled with
|
81
|
+
The new change file should be filled with information about the implemented change, all unused topics should be erased and the file committed.
|
82
82
|
|
83
83
|
Additionally, you can pass some extra options to the `new` command. Type `codelog help new` in your console for more information.
|
84
84
|
|
@@ -95,7 +95,7 @@ No conflicts to resolve. All changes documented.
|
|
95
95
|
|
96
96
|
It will execute 3 steps:
|
97
97
|
|
98
|
-
-
|
98
|
+
- Generates a new release file at `changelogs/releases/` by merging all change files at `changelogs/unreleased/`
|
99
99
|
- Deletes the change files at `changelogs/unreleased/` because they now compose the new release. If it was not deleted, the change would appear repeated in the next release.
|
100
100
|
- Updates the `CHANGELOG.md` file by merging all the releases at `changelogs/releases/`.
|
101
101
|
|
@@ -105,6 +105,15 @@ $ codelog bump [major|minor|patch] <RELEASE_DATE>
|
|
105
105
|
```
|
106
106
|
Where the first mandatory parameter is the desired release type, i.e: If you don't have any release, `codelog bump patch` will release the 0.0.1 version.
|
107
107
|
|
108
|
+
### Preview a Release
|
109
|
+
|
110
|
+
Sometimes, you just want to check the developed changes or preview how the next release will look like. To do so, you can pass the `[-p|--preview]` option on the `release` and `bump` commands. For instance, the following:
|
111
|
+
|
112
|
+
``` bash
|
113
|
+
$ codelog release 1.0.0 --preview
|
114
|
+
```
|
115
|
+
Will display a preview of your changes on your console as if the version **1.0.0** has been released.
|
116
|
+
|
108
117
|
## Configuring
|
109
118
|
|
110
119
|
Since version 0.3.0, there are a few configurations that are possible. You can choose:
|
data/lib/codelog.rb
CHANGED
@@ -2,9 +2,12 @@ require 'codelog/cli'
|
|
2
2
|
require 'codelog/config'
|
3
3
|
require 'codelog/message'
|
4
4
|
require 'codelog/version'
|
5
|
+
require 'codelog/output/release_file'
|
6
|
+
require 'codelog/output/log'
|
5
7
|
require 'codelog/command/setup'
|
6
8
|
require 'codelog/command/new'
|
7
9
|
require 'codelog/command/release'
|
10
|
+
require 'codelog/command/preview'
|
8
11
|
require 'codelog/command/bump'
|
9
12
|
require 'codelog/command/step/changelog'
|
10
13
|
require 'codelog/command/step/delete'
|
data/lib/codelog/cli.rb
CHANGED
@@ -19,16 +19,24 @@ module Codelog
|
|
19
19
|
end
|
20
20
|
|
21
21
|
desc 'release [VERSION] <RELEASE_DATE>', 'Generate new release updating changelog'
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
method_option :preview, desc: 'Prints the preview of the specified version release',
|
23
|
+
aliases: ['-p', '--preview'], type: :boolean
|
24
|
+
def release(version_number,
|
25
|
+
release_date = Date.today.strftime(Codelog::Config.date_input_format))
|
26
|
+
if options[:preview]
|
27
|
+
Codelog::Command::Preview.run version_number, release_date
|
28
|
+
else
|
29
|
+
Codelog::Command::Release.run version_number, release_date
|
30
|
+
end
|
25
31
|
end
|
26
32
|
|
27
33
|
desc 'bump [VERSION_TYPE] <RELEASE_DATE>', 'Bumps the next version,
|
28
34
|
being it major, minor or patch'
|
35
|
+
method_option :preview, desc: 'Prints the preview of the next version',
|
36
|
+
aliases: ['-p', '--preview'], type: :boolean
|
29
37
|
def bump(version_type, release_date =
|
30
38
|
Date.today.strftime(Codelog::Config.date_input_format))
|
31
|
-
Codelog::Command::Bump.run version_type, release_date
|
39
|
+
Codelog::Command::Bump.run version_type, release_date, options
|
32
40
|
end
|
33
41
|
end
|
34
42
|
end
|
data/lib/codelog/command/bump.rb
CHANGED
@@ -6,16 +6,20 @@ module Codelog
|
|
6
6
|
VALID_VERSION_TYPES = ['major', 'minor', 'patch'].freeze
|
7
7
|
INITIAL_RELEASE_VERSION = '0.0.0'.freeze
|
8
8
|
|
9
|
-
def self.run(version_type, release_date)
|
10
|
-
Codelog::Command::Bump.new.run version_type, release_date
|
9
|
+
def self.run(version_type, release_date, options)
|
10
|
+
Codelog::Command::Bump.new.run version_type, release_date, options
|
11
11
|
end
|
12
12
|
|
13
|
-
def run(version_type, release_date)
|
13
|
+
def run(version_type, release_date, options)
|
14
14
|
unless VALID_VERSION_TYPES.include?(version_type.downcase)
|
15
15
|
abort(Codelog::Message::Error.invalid_version_type(version_type))
|
16
16
|
end
|
17
17
|
|
18
|
-
|
18
|
+
if options[:preview]
|
19
|
+
Codelog::Command::Preview.run(next_version(version_type), release_date)
|
20
|
+
else
|
21
|
+
Codelog::Command::Release.run(next_version(version_type), release_date)
|
22
|
+
end
|
19
23
|
end
|
20
24
|
|
21
25
|
private
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Codelog
|
2
|
+
module Command
|
3
|
+
class Preview
|
4
|
+
def self.run(version_number, release_date)
|
5
|
+
Codelog::Command::Preview.new.run version_number, release_date
|
6
|
+
end
|
7
|
+
|
8
|
+
def run(version_number, release_date)
|
9
|
+
outputter = Codelog::Output::Log.new
|
10
|
+
Codelog::Command::Step::Version.run version_number, release_date, outputter
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -1,12 +1,15 @@
|
|
1
1
|
module Codelog
|
2
2
|
module Command
|
3
3
|
class Release
|
4
|
+
RELEASES_PATH = 'changelogs/releases'.freeze
|
5
|
+
|
4
6
|
def self.run(version_number, release_date)
|
5
7
|
Codelog::Command::Release.new.run version_number, release_date
|
6
8
|
end
|
7
9
|
|
8
10
|
def run(version_number, release_date)
|
9
|
-
Codelog::
|
11
|
+
outputter = Codelog::Output::ReleaseFile.new("#{RELEASES_PATH}/#{version_number}.md")
|
12
|
+
Codelog::Command::Step::Version.run version_number, release_date, outputter
|
10
13
|
Codelog::Command::Step::Delete.run
|
11
14
|
Codelog::Command::Step::Changelog.run
|
12
15
|
puts "\n== Changelog updated to version #{version_number} =="
|
@@ -7,34 +7,45 @@ module Codelog
|
|
7
7
|
module Step
|
8
8
|
class Version
|
9
9
|
include FileUtils
|
10
|
-
|
11
|
-
RELEASES_PATH = 'changelogs/releases'.freeze
|
12
10
|
UNRELEASED_LOGS_PATH = 'changelogs/unreleased'.freeze
|
13
11
|
CONFIG_FILE_PATH = 'changelogs/codelog.yml'.freeze
|
12
|
+
RELEASES_PATH = 'changelogs/releases'.freeze
|
14
13
|
|
15
|
-
def initialize(version, release_date)
|
14
|
+
def initialize(version, release_date, outputter)
|
16
15
|
abort(Codelog::Message::Error.missing_config_file) unless config_file_exists?
|
17
16
|
@version = version
|
18
17
|
@release_date = Date.strptime(release_date, Codelog::Config.date_input_format).to_s
|
18
|
+
@outputter = outputter
|
19
19
|
rescue ArgumentError
|
20
20
|
abort(Codelog::Message::Error.invalid_date_format)
|
21
21
|
end
|
22
22
|
|
23
|
-
def self.run(version, release_date)
|
24
|
-
Codelog::Command::Step::Version.new(version, release_date).run
|
23
|
+
def self.run(version, release_date, outputter)
|
24
|
+
Codelog::Command::Step::Version.new(version, release_date, outputter).run
|
25
25
|
end
|
26
26
|
|
27
27
|
def run
|
28
28
|
abort(Codelog::Message::Error.missing_version_number) if @version.nil?
|
29
29
|
abort(Codelog::Message::Error.already_existing_version(@version)) if version_exists?
|
30
30
|
abort(Codelog::Message::Error.no_detected_changes(@version)) unless unreleased_changes?
|
31
|
-
|
32
|
-
|
33
|
-
end
|
31
|
+
|
32
|
+
@outputter.print generate_changelog_content_from(changes_hash)
|
34
33
|
end
|
35
34
|
|
36
35
|
private
|
37
36
|
|
37
|
+
def generate_changelog_content_from(changes_hash)
|
38
|
+
file_content = StringIO.new
|
39
|
+
file_content.puts "## #{Codelog::Config.version_tag(@version, @release_date)}"
|
40
|
+
changes_hash.each do |category, changes|
|
41
|
+
file_content.puts "### #{category}"
|
42
|
+
add_entry(file_content, changes)
|
43
|
+
file_content.puts "\n"
|
44
|
+
end
|
45
|
+
file_content.puts "---\n"
|
46
|
+
file_content.string
|
47
|
+
end
|
48
|
+
|
38
49
|
def changes_hash
|
39
50
|
change_files_paths = Dir["#{UNRELEASED_LOGS_PATH}/*.yml"]
|
40
51
|
change_files_paths.inject({}) do |all_changes, change_file|
|
@@ -60,18 +71,6 @@ module Codelog
|
|
60
71
|
end
|
61
72
|
end
|
62
73
|
|
63
|
-
def create_version_changelog_from(changes_hash)
|
64
|
-
File.open("#{RELEASES_PATH}/#{@version}.md", 'a') do |line|
|
65
|
-
line.puts "## #{Codelog::Config.version_tag(@version, @release_date)}"
|
66
|
-
changes_hash.each do |category, changes|
|
67
|
-
line.puts "### #{category}"
|
68
|
-
add_entry(line, changes)
|
69
|
-
line.puts "\n"
|
70
|
-
end
|
71
|
-
line.puts "---\n"
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
74
|
def version_exists?
|
76
75
|
File.file?("#{RELEASES_PATH}/#{@version}.md")
|
77
76
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Codelog
|
2
|
+
module Output
|
3
|
+
class ReleaseFile
|
4
|
+
def initialize(file_path)
|
5
|
+
@file_path = file_path
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.print(content, file_path)
|
9
|
+
new(file_path).print(content)
|
10
|
+
end
|
11
|
+
|
12
|
+
def print(content)
|
13
|
+
Dir.chdir Dir.pwd do
|
14
|
+
File.open(@file_path, 'a') do |line|
|
15
|
+
line.puts content
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/codelog/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: codelog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luís Bevilacqua
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2018-
|
15
|
+
date: 2018-07-23 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: thor
|
@@ -120,6 +120,7 @@ files:
|
|
120
120
|
- lib/codelog/clis/interactive.rb
|
121
121
|
- lib/codelog/command/bump.rb
|
122
122
|
- lib/codelog/command/new.rb
|
123
|
+
- lib/codelog/command/preview.rb
|
123
124
|
- lib/codelog/command/release.rb
|
124
125
|
- lib/codelog/command/setup.rb
|
125
126
|
- lib/codelog/command/step/changelog.rb
|
@@ -127,6 +128,8 @@ files:
|
|
127
128
|
- lib/codelog/command/step/version.rb
|
128
129
|
- lib/codelog/config.rb
|
129
130
|
- lib/codelog/message.rb
|
131
|
+
- lib/codelog/output/log.rb
|
132
|
+
- lib/codelog/output/release_file.rb
|
130
133
|
- lib/codelog/version.rb
|
131
134
|
- lib/fixtures/codelog.yml
|
132
135
|
- lib/fixtures/header.txt
|