changefu 0.1.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +119 -0
- data/LICENSE +21 -0
- data/README.md +43 -0
- data/Rakefile +6 -0
- data/exe/changefu +10 -0
- data/lib/changefu.rb +21 -0
- data/lib/changefu/actions.rb +25 -0
- data/lib/changefu/change.rb +47 -0
- data/lib/changefu/changelog.rb +125 -0
- data/lib/changefu/changes_group.rb +18 -0
- data/lib/changefu/cli.rb +133 -0
- data/lib/changefu/configuration.rb +27 -0
- data/lib/changefu/release.rb +54 -0
- data/lib/changefu/version.rb +24 -0
- metadata +124 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0e130e4e913c1a0c929e67fd7e2d4a85a25ff090bfd05a7a48f227eb64d4d879
|
4
|
+
data.tar.gz: c5dc08b554faf036c7e2df33fe52ac9c678aa556ff193b677ebea9bf81ab8cff
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 273c50756265b7a443659eddb805ebdc508f802eb7b691dd8b91b88060140f8f674a33793edf92d6b1ab6c9bca7015977b1191f5ec352595f64d89568797d8b7
|
7
|
+
data.tar.gz: 9548ee2737546d5acb0ac8243e449c8dedc4a2a0c8f3639982273f2d40c2ed75738803c118a2819f9ad171ac7e79d96edb7ab20c18fdddf2e59262ab83d206e2
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
changefu (0.1.0.rc1)
|
5
|
+
activesupport (> 5.0, < 7)
|
6
|
+
thor (~> 1.0, >= 1.0.1)
|
7
|
+
tty-table (~> 0.11, >= 0.11.0)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
activesupport (6.0.2.1)
|
13
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
14
|
+
i18n (>= 0.7, < 2)
|
15
|
+
minitest (~> 5.1)
|
16
|
+
tzinfo (~> 1.1)
|
17
|
+
zeitwerk (~> 2.2)
|
18
|
+
ast (2.4.0)
|
19
|
+
awesome_print (1.8.0)
|
20
|
+
coderay (1.1.2)
|
21
|
+
concurrent-ruby (1.1.5)
|
22
|
+
diff-lcs (1.3)
|
23
|
+
docile (1.3.2)
|
24
|
+
equatable (0.6.1)
|
25
|
+
i18n (1.8.2)
|
26
|
+
concurrent-ruby (~> 1.0)
|
27
|
+
jaro_winkler (1.5.4)
|
28
|
+
json (2.3.0)
|
29
|
+
method_source (0.9.2)
|
30
|
+
minitest (5.14.0)
|
31
|
+
necromancer (0.5.1)
|
32
|
+
parallel (1.19.1)
|
33
|
+
parser (2.6.5.0)
|
34
|
+
ast (~> 2.4.0)
|
35
|
+
pastel (0.7.3)
|
36
|
+
equatable (~> 0.6)
|
37
|
+
tty-color (~> 0.5)
|
38
|
+
pry (0.12.2)
|
39
|
+
coderay (~> 1.1.0)
|
40
|
+
method_source (~> 0.9.0)
|
41
|
+
rack (2.0.7)
|
42
|
+
rainbow (3.0.0)
|
43
|
+
rake (12.3.3)
|
44
|
+
rspec (3.9.0)
|
45
|
+
rspec-core (~> 3.9.0)
|
46
|
+
rspec-expectations (~> 3.9.0)
|
47
|
+
rspec-mocks (~> 3.9.0)
|
48
|
+
rspec-core (3.9.0)
|
49
|
+
rspec-support (~> 3.9.0)
|
50
|
+
rspec-expectations (3.9.0)
|
51
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
52
|
+
rspec-support (~> 3.9.0)
|
53
|
+
rspec-mocks (3.9.0)
|
54
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
55
|
+
rspec-support (~> 3.9.0)
|
56
|
+
rspec-support (3.9.0)
|
57
|
+
rubocop (0.77.0)
|
58
|
+
jaro_winkler (~> 1.5.1)
|
59
|
+
parallel (~> 1.10)
|
60
|
+
parser (>= 2.6)
|
61
|
+
rainbow (>= 2.2.2, < 4.0)
|
62
|
+
ruby-progressbar (~> 1.7)
|
63
|
+
unicode-display_width (>= 1.4.0, < 1.7)
|
64
|
+
rubocop-nosolosoftware (0.1.0)
|
65
|
+
rubocop (~> 0.77.0)
|
66
|
+
rubocop-performance (~> 1.5.1)
|
67
|
+
rubocop-rails (~> 2.4.0)
|
68
|
+
rubocop-rake (~> 0.5.0)
|
69
|
+
rubocop-rspec (~> 1.37.0)
|
70
|
+
rubocop-performance (1.5.1)
|
71
|
+
rubocop (>= 0.71.0)
|
72
|
+
rubocop-rails (2.4.0)
|
73
|
+
rack (>= 1.1)
|
74
|
+
rubocop (>= 0.72.0)
|
75
|
+
rubocop-rake (0.5.0)
|
76
|
+
rubocop
|
77
|
+
rubocop-rspec (1.37.0)
|
78
|
+
rubocop (>= 0.68.1)
|
79
|
+
ruby-progressbar (1.10.1)
|
80
|
+
simplecov (0.17.1)
|
81
|
+
docile (~> 1.1)
|
82
|
+
json (>= 1.8, < 3)
|
83
|
+
simplecov-html (~> 0.10.0)
|
84
|
+
simplecov-html (0.10.2)
|
85
|
+
strings (0.1.8)
|
86
|
+
strings-ansi (~> 0.1)
|
87
|
+
unicode-display_width (~> 1.5)
|
88
|
+
unicode_utils (~> 1.4)
|
89
|
+
strings-ansi (0.2.0)
|
90
|
+
thor (1.0.1)
|
91
|
+
thread_safe (0.3.6)
|
92
|
+
tty-color (0.5.1)
|
93
|
+
tty-screen (0.7.1)
|
94
|
+
tty-table (0.11.0)
|
95
|
+
equatable (~> 0.6)
|
96
|
+
necromancer (~> 0.5)
|
97
|
+
pastel (~> 0.7.2)
|
98
|
+
strings (~> 0.1.5)
|
99
|
+
tty-screen (~> 0.7)
|
100
|
+
tzinfo (1.2.6)
|
101
|
+
thread_safe (~> 0.1)
|
102
|
+
unicode-display_width (1.6.0)
|
103
|
+
unicode_utils (1.4.0)
|
104
|
+
zeitwerk (2.2.2)
|
105
|
+
|
106
|
+
PLATFORMS
|
107
|
+
ruby
|
108
|
+
|
109
|
+
DEPENDENCIES
|
110
|
+
awesome_print
|
111
|
+
changefu!
|
112
|
+
pry
|
113
|
+
rake
|
114
|
+
rspec
|
115
|
+
rubocop-nosolosoftware
|
116
|
+
simplecov
|
117
|
+
|
118
|
+
BUNDLED WITH
|
119
|
+
2.1.4
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Javier Aranda
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# Changefu
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/changefu`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'changefu'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install changefu
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/changefu. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
40
|
+
|
41
|
+
## Code of Conduct
|
42
|
+
|
43
|
+
Everyone interacting in the Changefu project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/changefu/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/exe/changefu
ADDED
data/lib/changefu.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require 'active_support/core_ext/object'
|
3
|
+
require 'active_support/core_ext/string'
|
4
|
+
require 'active_support/json'
|
5
|
+
|
6
|
+
module Changefu
|
7
|
+
def self.path_helper(path)
|
8
|
+
Pathname.pwd.join(path)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.path_helper!(path)
|
12
|
+
path = path_helper(path)
|
13
|
+
|
14
|
+
return path if path.exist?
|
15
|
+
|
16
|
+
abort "#{path} cannot be found!"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
require 'changefu/cli'
|
21
|
+
require 'changefu/version'
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Changefu
|
2
|
+
module Actions
|
3
|
+
def cf_root(path=nil)
|
4
|
+
@cf_root ||= begin
|
5
|
+
if path.nil?
|
6
|
+
cf_root(Pathname.pwd)
|
7
|
+
elsif path.join('changelog').exist?
|
8
|
+
path
|
9
|
+
else
|
10
|
+
path.root? ? nil : cf_root(path.parent)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def require_changefu!
|
16
|
+
if !cf_root
|
17
|
+
abort <<~TEXT
|
18
|
+
This project does not use ChangeFu. Please run `changefu setup` first on the project root!
|
19
|
+
TEXT
|
20
|
+
elsif cf_root && cf_root != Pathname.pwd
|
21
|
+
abort 'You must run this command from the root folder of the project!'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module Changefu
|
4
|
+
class Change
|
5
|
+
attr_accessor :timestamp, :type, :title, :username, :issue, :path
|
6
|
+
|
7
|
+
def self.from_file(path)
|
8
|
+
data = YAML.safe_load(File.read(path), symbolize_names: true)
|
9
|
+
timestamp = path.basename('.yml').to_s.split('_').first
|
10
|
+
|
11
|
+
new(
|
12
|
+
type: data.fetch(:type),
|
13
|
+
title: data.fetch(:title),
|
14
|
+
username: data.fetch(:username),
|
15
|
+
issue: data.fetch(:issue),
|
16
|
+
timestamp: timestamp,
|
17
|
+
path: path
|
18
|
+
)
|
19
|
+
end
|
20
|
+
|
21
|
+
def initialize(attributes={})
|
22
|
+
attributes.each_pair do |key, value|
|
23
|
+
send("#{key}=", value)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def issue_to_markdown
|
28
|
+
url = Changefu::Configuration.issue_url
|
29
|
+
|
30
|
+
return unless url
|
31
|
+
|
32
|
+
"[##{issue}](#{url.sub('{issue}', issue.to_s)})"
|
33
|
+
end
|
34
|
+
|
35
|
+
def username_to_markdown
|
36
|
+
url = Changefu::Configuration.username_url
|
37
|
+
|
38
|
+
return unless url
|
39
|
+
|
40
|
+
"([#{username}](#{url.sub('{username}', username)}))"
|
41
|
+
end
|
42
|
+
|
43
|
+
def to_hash
|
44
|
+
{title: title, username: username, issue: issue}
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
require 'erb'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'ostruct'
|
4
|
+
require 'pathname'
|
5
|
+
require 'yaml'
|
6
|
+
require 'changefu/configuration'
|
7
|
+
require 'changefu/changes_group'
|
8
|
+
require 'changefu/release'
|
9
|
+
|
10
|
+
module Changefu
|
11
|
+
class Changelog
|
12
|
+
# Generate the changelog
|
13
|
+
def self.generate!(format, filename)
|
14
|
+
new.send("generate_#{format}", filename)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.release!(version, date=nil, tag=nil)
|
18
|
+
date ||= Time.now.strftime('%Y-%m-%d')
|
19
|
+
tag ||= "v#{version}"
|
20
|
+
|
21
|
+
new.release(version, date, tag)
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.releases
|
25
|
+
new.releases
|
26
|
+
end
|
27
|
+
|
28
|
+
# List of releases
|
29
|
+
def releases
|
30
|
+
@releases ||= (
|
31
|
+
YAML.safe_load(
|
32
|
+
File.read(Changefu.path_helper!('changelog/releases.yml')),
|
33
|
+
symbolize_names: true, permitted_classes: [Date]
|
34
|
+
) || []
|
35
|
+
).map { |release|
|
36
|
+
Changefu::Release.new(release[:version], release[:date], release[:tag])
|
37
|
+
}.sort_by(&:date).reverse
|
38
|
+
end
|
39
|
+
|
40
|
+
# List of unreleased changes
|
41
|
+
def unreleased_changes
|
42
|
+
unreleased_path.glob('*.yml').map { |f| Changefu::Change.from_file(f) }.sort_by(&:timestamp)
|
43
|
+
end
|
44
|
+
|
45
|
+
# List of unreleased changes group by type
|
46
|
+
def unreleased_changes_by_type
|
47
|
+
unreleased_changes.group_by(&:type).map { |g|
|
48
|
+
ChangesGroup.new(g.first, g.last)
|
49
|
+
}.sort_by(&:type)
|
50
|
+
end
|
51
|
+
|
52
|
+
# Release a new version
|
53
|
+
def release(version, date, tag)
|
54
|
+
abort "Version #{version} already exists!" if releases.any? { |r| r.version == version }
|
55
|
+
|
56
|
+
# create new release
|
57
|
+
new_release = Changefu::Release.new(version, date, tag)
|
58
|
+
|
59
|
+
# create new release directory
|
60
|
+
new_release.create_dir
|
61
|
+
|
62
|
+
# compose new releases array
|
63
|
+
new_releases_list = (releases + [new_release]).map(&:to_yaml_hash)
|
64
|
+
|
65
|
+
# update releases.yml file
|
66
|
+
save_file(new_releases_list.to_yaml, 'changelog/releases.yml')
|
67
|
+
|
68
|
+
# move changes files from unreleased
|
69
|
+
Changefu.path_helper('changelog/unreleased').glob('*.yml').each do |file|
|
70
|
+
move_file(file, new_release.path)
|
71
|
+
end
|
72
|
+
|
73
|
+
# reset releases list to force reload next time
|
74
|
+
@releases = nil
|
75
|
+
end
|
76
|
+
|
77
|
+
def generate_markdown(filename)
|
78
|
+
template = ERB.new(File.read(templates_path.join('changelog.markdown.erb')), trim_mode: '>')
|
79
|
+
output = template.result(context.instance_eval { binding })
|
80
|
+
save_file(output, filename)
|
81
|
+
end
|
82
|
+
|
83
|
+
def generate_json(filename)
|
84
|
+
template = ERB.new(File.read(templates_path.join('changelog.json.erb')), trim_mode: '>')
|
85
|
+
output = template.result(context.instance_eval { binding })
|
86
|
+
save_file(output, filename)
|
87
|
+
end
|
88
|
+
|
89
|
+
private
|
90
|
+
|
91
|
+
def move_file(origin, destination)
|
92
|
+
if Changefu::Configuration.use_git_mv
|
93
|
+
system("git mv #{origin} #{destination} 2> /dev/null")
|
94
|
+
|
95
|
+
return if $?.success?
|
96
|
+
end
|
97
|
+
|
98
|
+
FileUtils.mv(origin, destination)
|
99
|
+
end
|
100
|
+
|
101
|
+
def save_file(content, path)
|
102
|
+
File.open(Changefu.path_helper(path), 'w') do |file|
|
103
|
+
file.write(content)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def templates_path
|
108
|
+
Pathname.new(__dir__).join('../../templates')
|
109
|
+
end
|
110
|
+
|
111
|
+
def unreleased_path
|
112
|
+
Changefu.path_helper('changelog/unreleased')
|
113
|
+
end
|
114
|
+
|
115
|
+
def context
|
116
|
+
OpenStruct.new(
|
117
|
+
header: Changefu::Configuration.header,
|
118
|
+
footer: Changefu::Configuration.footer,
|
119
|
+
unreleased: unreleased_changes_by_type,
|
120
|
+
include_unreleased: Changefu::Configuration.include_unreleased,
|
121
|
+
releases: releases
|
122
|
+
)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Changefu
|
2
|
+
class ChangesGroup
|
3
|
+
attr_reader :type, :changes
|
4
|
+
|
5
|
+
def initialize(type, changes=[])
|
6
|
+
@type = type
|
7
|
+
@changes = changes
|
8
|
+
end
|
9
|
+
|
10
|
+
def humanized_name
|
11
|
+
if Changefu::Configuration.respond_to?(:types)
|
12
|
+
Changefu::Configuration.types[type.to_sym] || type.capitalize
|
13
|
+
else
|
14
|
+
type.capitalize
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/changefu/cli.rb
ADDED
@@ -0,0 +1,133 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'tty-table'
|
3
|
+
require 'changefu/actions'
|
4
|
+
require 'changefu/changelog'
|
5
|
+
require 'changefu/configuration'
|
6
|
+
|
7
|
+
module Changefu
|
8
|
+
class CLI < Thor
|
9
|
+
include Thor::Actions
|
10
|
+
include Actions
|
11
|
+
|
12
|
+
package_name 'Changefu'
|
13
|
+
default_task :help
|
14
|
+
|
15
|
+
def self.source_root
|
16
|
+
File.expand_path('../../templates', __dir__)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.exit_on_failure?
|
20
|
+
true
|
21
|
+
end
|
22
|
+
|
23
|
+
desc 'add TITLE', 'Adds a new entry to changelog using this title'
|
24
|
+
option :type, type: :string, default: 'added'
|
25
|
+
option :username, type: :string
|
26
|
+
option :issue, type: :string
|
27
|
+
def add(title)
|
28
|
+
require_changefu!
|
29
|
+
|
30
|
+
timestamp = Time.now.strftime('%Y%m%d%H%M%S')
|
31
|
+
template 'change.tt',
|
32
|
+
"changelog/unreleased/#{timestamp}_#{title.parameterize(separator: '_')}.yml",
|
33
|
+
options.merge(title: title, username: username, issue: issue)
|
34
|
+
end
|
35
|
+
|
36
|
+
desc 'generate', 'Generates changelog files'
|
37
|
+
option :markdown, type: :boolean
|
38
|
+
option :json, type: :boolean
|
39
|
+
option 'markdown-filename', type: :string
|
40
|
+
option 'json-filename', type: :string
|
41
|
+
def generate
|
42
|
+
require_changefu!
|
43
|
+
generate_changelog!
|
44
|
+
end
|
45
|
+
|
46
|
+
desc 'release VERSION', 'Releases a new version and generates changelog files'
|
47
|
+
option :date, type: :string
|
48
|
+
option :tag, type: :string
|
49
|
+
option :generate, type: :boolean, default: true
|
50
|
+
option :markdown, type: :boolean
|
51
|
+
option :json, type: :boolean
|
52
|
+
option 'markdown-filename', type: :string
|
53
|
+
option 'json-filename', type: :string
|
54
|
+
def release(version)
|
55
|
+
require_changefu!
|
56
|
+
|
57
|
+
# release new version
|
58
|
+
Changefu::Changelog.release!(version, options[:date], options[:tag])
|
59
|
+
|
60
|
+
# generate changelog
|
61
|
+
generate_changelog! if options[:generate]
|
62
|
+
end
|
63
|
+
|
64
|
+
desc 'releases', 'List of releases'
|
65
|
+
def releases
|
66
|
+
require_changefu!
|
67
|
+
|
68
|
+
list = Changefu::Changelog.releases.map(&:to_table_row)
|
69
|
+
|
70
|
+
if list.count.positive?
|
71
|
+
$stdout.puts TTY::Table.new(
|
72
|
+
%w[Release Date Tag], list
|
73
|
+
).render(:ascii, padding: [0, 1, 0, 1])
|
74
|
+
else
|
75
|
+
warn 'No releases found in `changelog/releases.yml` file'
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
desc 'setup', 'Installs Changefu in this folder'
|
80
|
+
def setup
|
81
|
+
# create the changelog directory
|
82
|
+
empty_directory 'changelog'
|
83
|
+
empty_directory 'changelog/releases'
|
84
|
+
empty_directory 'changelog/unreleased'
|
85
|
+
create_file 'changelog/releases/.keep'
|
86
|
+
create_file 'changelog/unreleased/.keep'
|
87
|
+
create_file 'changelog/releases.yml', '---'
|
88
|
+
|
89
|
+
# add the configuration file
|
90
|
+
copy_file 'changefu.yml', '.changefu.yml'
|
91
|
+
end
|
92
|
+
|
93
|
+
map %w[--version -v] => :app_version
|
94
|
+
desc '--version, -v', 'Prints the version'
|
95
|
+
def app_version
|
96
|
+
$stdout.puts Changefu.version
|
97
|
+
end
|
98
|
+
|
99
|
+
private
|
100
|
+
|
101
|
+
def generate_changelog!
|
102
|
+
if option_markdown
|
103
|
+
Changefu::Changelog.generate!(:markdown, option_markdown_filename)
|
104
|
+
say_status :created, option_markdown_filename
|
105
|
+
end
|
106
|
+
|
107
|
+
return unless option_json
|
108
|
+
|
109
|
+
Changefu::Changelog.generate!(:json, option_json_filename)
|
110
|
+
say_status :created, option_json_filename
|
111
|
+
end
|
112
|
+
|
113
|
+
def option_markdown
|
114
|
+
default = Changefu::Configuration.formats.try(:[], :markdown) || false
|
115
|
+
options.key?('markdown') ? options['markdown'] : default
|
116
|
+
end
|
117
|
+
|
118
|
+
def option_json
|
119
|
+
default = Changefu::Configuration.formats.try(:[], :json) || false
|
120
|
+
options.key?('json') ? options['json'] : default
|
121
|
+
end
|
122
|
+
|
123
|
+
def option_markdown_filename
|
124
|
+
default = Changefu::Configuration.filenames.try(:[], :markdown) || 'CHANGELOG.md'
|
125
|
+
options.key?('markdown-filename') ? options['markdown-filename'] : default
|
126
|
+
end
|
127
|
+
|
128
|
+
def option_json_filename
|
129
|
+
default = Changefu::Configuration.filenames.try(:[], :json) || '.changelog.json'
|
130
|
+
options.key?('json-filename') ? options['json-filename'] : default
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module Changefu
|
4
|
+
class Configuration
|
5
|
+
class << self
|
6
|
+
def method_missing(method)
|
7
|
+
if config.key?(method)
|
8
|
+
config[method]
|
9
|
+
else
|
10
|
+
abort "You must set `#{method}` directive in `.changefu.yml` file!"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def respond_to_missing?(method, include_private=false)
|
15
|
+
config.key?(method) || super
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def config
|
21
|
+
@config ||= YAML.safe_load(
|
22
|
+
File.read(Changefu.path_helper!('.changefu.yml')), symbolize_names: true
|
23
|
+
)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'changefu/change'
|
3
|
+
require 'changefu/changes_group'
|
4
|
+
|
5
|
+
module Changefu
|
6
|
+
class Release
|
7
|
+
attr_accessor :version, :date, :tag
|
8
|
+
|
9
|
+
def initialize(version, date, tag)
|
10
|
+
@version = version
|
11
|
+
@date = date.is_a?(Date) ? date.strftime('%Y-%m-%d') : date
|
12
|
+
@tag = tag
|
13
|
+
end
|
14
|
+
|
15
|
+
# List of changes for this release
|
16
|
+
def changes
|
17
|
+
@changes ||= path.glob('*.yml').map { |f| Changefu::Change.from_file(f) }.sort_by(&:timestamp)
|
18
|
+
end
|
19
|
+
|
20
|
+
# List of changes grouped by type
|
21
|
+
def changes_by_type
|
22
|
+
@changes_by_type ||= changes.group_by(&:type).map { |g|
|
23
|
+
ChangesGroup.new(g.first, g.last)
|
24
|
+
}.sort_by(&:type)
|
25
|
+
end
|
26
|
+
|
27
|
+
# Path to the release folder with the changes
|
28
|
+
def path
|
29
|
+
Changefu.path_helper("changelog/releases/#{version}")
|
30
|
+
end
|
31
|
+
|
32
|
+
def to_table_row
|
33
|
+
[version, date, tag]
|
34
|
+
end
|
35
|
+
|
36
|
+
def create_dir
|
37
|
+
FileUtils.mkdir(path) unless path.exist?
|
38
|
+
end
|
39
|
+
|
40
|
+
def to_yaml_hash
|
41
|
+
{'version' => version, 'date' => date, 'tag' => tag}
|
42
|
+
end
|
43
|
+
|
44
|
+
def to_hash
|
45
|
+
changes_hash = {}
|
46
|
+
|
47
|
+
changes_by_type.each do |group|
|
48
|
+
changes_hash[group.type] = group.changes.map(&:to_hash)
|
49
|
+
end
|
50
|
+
|
51
|
+
{version: version, date: date, tag: tag, changes: changes_hash}
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
module Changefu
|
4
|
+
module VERSION
|
5
|
+
MAJOR = 0
|
6
|
+
MINOR = 1
|
7
|
+
TINY = 0
|
8
|
+
PRE = 'rc1'
|
9
|
+
|
10
|
+
STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.version
|
14
|
+
VERSION::STRING
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.gem_version
|
18
|
+
Gem::Version.new VERSION::STRING
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.required_ruby_version
|
22
|
+
Gem::Requirement.new('>= 2.5.0')
|
23
|
+
end
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: changefu
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0.rc1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Javier Aranda
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-02-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5.0'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '7.0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '5.0'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '7.0'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: thor
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '1.0'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 1.0.1
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '1.0'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 1.0.1
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: tty-table
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: 0.11.0
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0.11'
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 0.11.0
|
70
|
+
- - "~>"
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0.11'
|
73
|
+
description: Command-line utility that help you to keep a good changelog
|
74
|
+
email: javier.aranda.varo@gmail.com
|
75
|
+
executables:
|
76
|
+
- changefu
|
77
|
+
extensions: []
|
78
|
+
extra_rdoc_files:
|
79
|
+
- LICENSE
|
80
|
+
- README.md
|
81
|
+
files:
|
82
|
+
- Gemfile
|
83
|
+
- Gemfile.lock
|
84
|
+
- LICENSE
|
85
|
+
- README.md
|
86
|
+
- Rakefile
|
87
|
+
- exe/changefu
|
88
|
+
- lib/changefu.rb
|
89
|
+
- lib/changefu/actions.rb
|
90
|
+
- lib/changefu/change.rb
|
91
|
+
- lib/changefu/changelog.rb
|
92
|
+
- lib/changefu/changes_group.rb
|
93
|
+
- lib/changefu/cli.rb
|
94
|
+
- lib/changefu/configuration.rb
|
95
|
+
- lib/changefu/release.rb
|
96
|
+
- lib/changefu/version.rb
|
97
|
+
homepage: https://github.com/javierav/changefu
|
98
|
+
licenses:
|
99
|
+
- MIT
|
100
|
+
metadata:
|
101
|
+
source_code_uri: https://github.com/javierav/changefu/tree/v0.1.0.rc1
|
102
|
+
changelog_uri: https://github.com/javierav/changefu/blob/v0.1.0.rc1/CHANGELOG.md
|
103
|
+
homepage_uri: https://github.com/javierav/changefu
|
104
|
+
post_install_message:
|
105
|
+
rdoc_options:
|
106
|
+
- "--charset=UTF-8"
|
107
|
+
require_paths:
|
108
|
+
- lib
|
109
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: 2.5.0
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">"
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: 1.3.1
|
119
|
+
requirements: []
|
120
|
+
rubygems_version: 3.0.3
|
121
|
+
signing_key:
|
122
|
+
specification_version: 4
|
123
|
+
summary: A tool for keep a changelog
|
124
|
+
test_files: []
|