codelog 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +11 -0
- data/README.md +11 -3
- data/lib/codelog.rb +1 -0
- data/lib/codelog/cli.rb +5 -3
- data/lib/codelog/clis/interactive.rb +51 -0
- data/lib/codelog/command/new.rb +37 -8
- data/lib/codelog/command/step/version.rb +2 -0
- data/lib/codelog/message.rb +4 -0
- data/lib/codelog/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b871029a453ff73c21adb12c5656b9be50049096a852e9c6e31ba7599023ddbf
|
4
|
+
data.tar.gz: 2aa614de8b36eddbeae04dd34efc1e7716f7a24aa3cbee1ded0d171f768aacf8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cffe89ed35c63814b810949a3ba02bc48d4228e1cff2e941e214e54cf5c6a48c8e01059abadfed11917c0a1dff4fc838ad712bd37f90aba911e780860b36b0ed
|
7
|
+
data.tar.gz: db61fc1fa5114692bf10f9998211d66c91b02975ffc10489369412f4e60a17e8c617e0c0045044d620234555bed29d97015e7f565d74c1ca8ff40dd22611e98d
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,17 @@ 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.6.0
|
7
|
+
### Added
|
8
|
+
- The `new` command receives a `NAME` parameter that will be converted to the unreleased file name
|
9
|
+
- Tests to verify if changes subcategories are properly tabulated on markdown file
|
10
|
+
- Tests to verify if `release` command is properly aborted if no `codelog.yml` file is found
|
11
|
+
- Interactive creation of the change files
|
12
|
+
|
13
|
+
### Fixed
|
14
|
+
- When an unreleased file is not parseable to yml, the user will get a friendly message, saying both file and line that are wrong.
|
15
|
+
|
16
|
+
---
|
6
17
|
## 0.5.0
|
7
18
|
### Added
|
8
19
|
- Ability to edit the created changefile by running `codelog new <-e|--edit>`
|
data/README.md
CHANGED
@@ -68,21 +68,29 @@ The template can be as the following example:
|
|
68
68
|
|
69
69
|
## Usage
|
70
70
|
|
71
|
+
### Creating a new change file
|
72
|
+
|
71
73
|
After the initial setup every time a change is made, the developer should run the following command in the project root path:
|
72
74
|
|
73
75
|
``` bash
|
74
|
-
$ codelog new
|
76
|
+
$ codelog new <NAME>
|
75
77
|
```
|
76
78
|
|
77
|
-
This will generate a change file on `changelogs/unreleased/` from the `template.yml
|
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 the given `NAME`, converted to snake case, or the default name(`change`).
|
78
80
|
|
79
81
|
The new change file should be filled with informations about the implemented change, all unused topics should be erased and the file committed.
|
80
82
|
|
83
|
+
Additionally, you can pass some extra options to the `new` command. Type `codelog help new` in your console for more information.
|
84
|
+
|
85
|
+
### Releasing a version
|
86
|
+
|
81
87
|
Once all changes were merged and the release is ready to be packed, all that must be done is to run the following command:
|
82
88
|
|
83
89
|
``` bash
|
84
|
-
$ codelog release
|
90
|
+
$ codelog release [VERSION] <RELEASE_DATE>
|
85
91
|
```
|
92
|
+
Where the `VERSION` is mandatory and represents the number of the next version of the system. An additional parameter `RELEASE_DATE` can be used, and if so, the release date of the version will be that value. You can configure the format of this parameter in the configuration file, under `changelogs/codelog.yml`.
|
93
|
+
|
86
94
|
No conflicts to resolve. All changes documented.
|
87
95
|
|
88
96
|
It will execute 3 steps:
|
data/lib/codelog.rb
CHANGED
data/lib/codelog/cli.rb
CHANGED
@@ -9,11 +9,13 @@ module Codelog
|
|
9
9
|
Codelog::Command::Setup.run
|
10
10
|
end
|
11
11
|
|
12
|
-
desc 'new', 'Generate a file from the template for the unreleased changes'
|
12
|
+
desc 'new <NAME>', 'Generate a file from the template for the unreleased changes'
|
13
13
|
method_option :edit, desc: 'Opens the default system editor after creating a changefile',
|
14
14
|
aliases: '-e', type: :boolean
|
15
|
-
|
16
|
-
|
15
|
+
method_option :interactive, desc: 'Add contents interactively to change file',
|
16
|
+
aliases: '-i', type: :boolean
|
17
|
+
def new(name = 'change')
|
18
|
+
Codelog::Command::New.run name, options
|
17
19
|
end
|
18
20
|
|
19
21
|
desc 'release [VERSION] <RELEASE_DATE>', 'Generate new release updating changelog'
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'thor'
|
2
|
+
|
3
|
+
module Codelog
|
4
|
+
module CLIs
|
5
|
+
class Interactive < Thor
|
6
|
+
include Thor::Actions
|
7
|
+
|
8
|
+
no_commands do
|
9
|
+
def initialize
|
10
|
+
@sections = YAML.load_file('changelogs/template.yml').keys
|
11
|
+
end
|
12
|
+
|
13
|
+
def run
|
14
|
+
changes_hash = Hash.new([])
|
15
|
+
loop do
|
16
|
+
change_category = ask_for_type
|
17
|
+
say "\nType the entries for #{set_color(change_category, :yellow)}(ENTER to stop):"
|
18
|
+
changes_hash[change_category] += ask_for_changes
|
19
|
+
break if no? "\nWould you like to add a new log(Y|N)?"
|
20
|
+
end
|
21
|
+
|
22
|
+
changes_hash
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def ask_for_type
|
28
|
+
say 'Enter a change type number:'
|
29
|
+
@sections.each_with_index do |section, index|
|
30
|
+
say "#{index + 1}. #{section}"
|
31
|
+
end
|
32
|
+
@sections[ask('>').to_i - 1]
|
33
|
+
end
|
34
|
+
|
35
|
+
def ask_for_changes(changes = [], level = 1)
|
36
|
+
change = ask('>' * level)
|
37
|
+
|
38
|
+
return changes if change.empty?
|
39
|
+
|
40
|
+
change = { change.chomp(':') => ask_for_changes([], level + 1) } if subcategory?(change)
|
41
|
+
|
42
|
+
ask_for_changes(changes.push(change), level)
|
43
|
+
end
|
44
|
+
|
45
|
+
def subcategory?(change)
|
46
|
+
change.end_with?(':')
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/lib/codelog/command/new.rb
CHANGED
@@ -5,24 +5,43 @@ module Codelog
|
|
5
5
|
class New
|
6
6
|
include FileUtils
|
7
7
|
|
8
|
-
def
|
9
|
-
|
8
|
+
def initialize(name, options)
|
9
|
+
@name = name
|
10
|
+
@options = options
|
10
11
|
end
|
11
12
|
|
12
|
-
def run(options)
|
13
|
+
def self.run(name, options)
|
14
|
+
new(name, options).run
|
15
|
+
end
|
16
|
+
|
17
|
+
def run
|
13
18
|
chdir Dir.pwd do
|
14
19
|
# This script create a change file for the changelog documentation.
|
15
20
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
+
@file_name = "changelogs/unreleased/#{change_file_timestamp}_#{change_file_name}.yml"
|
22
|
+
if @options[:interactive]
|
23
|
+
build_from_hash Codelog::CLIs::Interactive.new.run
|
24
|
+
else
|
25
|
+
build_from_template
|
26
|
+
end
|
27
|
+
system! "#{default_editor} #{@file_name}" if @options[:edit]
|
21
28
|
end
|
22
29
|
end
|
23
30
|
|
24
31
|
private
|
25
32
|
|
33
|
+
def build_from_template
|
34
|
+
puts "== Creating #{@file_name} change file based on example =="
|
35
|
+
system! "cp changelogs/template.yml #{@file_name}"
|
36
|
+
end
|
37
|
+
|
38
|
+
def build_from_hash(changes_hash)
|
39
|
+
puts "== Creating #{@file_name} change file from the provided changes =="
|
40
|
+
File.open(@file_name, 'a') do |file|
|
41
|
+
file.puts changes_hash.to_yaml
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
26
45
|
def default_editor
|
27
46
|
# Looks for the default editor in VISUAL and EDITOR system variables
|
28
47
|
# if no variable is set it defaults to nano
|
@@ -30,6 +49,16 @@ module Codelog
|
|
30
49
|
'${VISUAL:-${EDITOR:-nano}}'
|
31
50
|
end
|
32
51
|
|
52
|
+
def change_file_timestamp
|
53
|
+
Time.now.strftime('%Y%m%d%H%M%S%L')
|
54
|
+
end
|
55
|
+
|
56
|
+
def change_file_name
|
57
|
+
# Converts the name to snake case
|
58
|
+
|
59
|
+
@name.gsub(/(.)([A-Z])/, '\1_\2').downcase
|
60
|
+
end
|
61
|
+
|
33
62
|
def system!(*args)
|
34
63
|
system(*args) || abort("\n== Command #{args} failed ==")
|
35
64
|
end
|
data/lib/codelog/message.rb
CHANGED
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.6.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-03-31 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: thor
|
@@ -117,6 +117,7 @@ files:
|
|
117
117
|
- bin/setup
|
118
118
|
- lib/codelog.rb
|
119
119
|
- lib/codelog/cli.rb
|
120
|
+
- lib/codelog/clis/interactive.rb
|
120
121
|
- lib/codelog/command/new.rb
|
121
122
|
- lib/codelog/command/release.rb
|
122
123
|
- lib/codelog/command/setup.rb
|
@@ -150,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
151
|
version: '0'
|
151
152
|
requirements: []
|
152
153
|
rubyforge_project:
|
153
|
-
rubygems_version: 2.
|
154
|
+
rubygems_version: 2.7.3
|
154
155
|
signing_key:
|
155
156
|
specification_version: 4
|
156
157
|
summary: A gem to help with changelog management
|