changelogko 1.4.0
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 +7 -0
 - data/CHANGELOG.md +8 -0
 - data/LICENSE +21 -0
 - data/README.md +55 -0
 - data/bin/changelogko +4 -0
 - data/bin/cko +4 -0
 - data/bin/releaseko +4 -0
 - data/bin/rko +4 -0
 - data/changelogko.gemspec +22 -0
 - data/changelogs/archive-Feb-16-2024-10-21-04.md +6 -0
 - data/changelogs/archive-Nov-07-2022-09-15-11.md +6 -0
 - data/lib/changelog/creator.rb +10 -0
 - data/lib/changelog/option_parser.rb +70 -0
 - data/lib/changelog/writer.rb +62 -0
 - data/lib/changelog.rb +128 -0
 - data/lib/changelogko.rb +66 -0
 - data/lib/releaseko/app_version.rb +62 -0
 - data/lib/releaseko/changelog_wrapper.rb +12 -0
 - data/lib/releaseko/custom_error.rb +18 -0
 - data/lib/releaseko/repository_updater.rb +17 -0
 - data/lib/releaseko.rb +35 -0
 - data/metadata/app-version +1 -0
 - metadata +71 -0
 
    
        checksums.yaml
    ADDED
    
    | 
         @@ -0,0 +1,7 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ---
         
     | 
| 
      
 2 
     | 
    
         
            +
            SHA256:
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: e7b9995971aca753b65bffc71a01aadee292c46aed27ad716ba8ef492c8f0a1b
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: a0e464be952384d50313a3e90cf5da8191bd81eb043cb2bfa39270e9158c9000
         
     | 
| 
      
 5 
     | 
    
         
            +
            SHA512:
         
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 5ee4277bc2f2dc2c0f719ebff07c9b0109b070999773aadbbed905eac715bcf5c7b799fab1a1efbcd6cb7abcc7d0532d037b7608d8e7e02afb0acc649a57317d
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 27273766de8752067b222baa6cbbee6c26a26310ad5f7f5f0b4f0888a4b9772f420fba279f5f344474f924c0cf3cbc122d2a0f79c0c692d2e7de321ad3c8fbf6
         
     | 
    
        data/CHANGELOG.md
    ADDED
    
    | 
         @@ -0,0 +1,8 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Changelogs 
         
     | 
| 
      
 2 
     | 
    
         
            +
            ## Added (3 count/s)
         
     | 
| 
      
 3 
     | 
    
         
            +
              + No archive option for releasing - tieeeeen1994 (tieeeeen1994@gmail.com)
         
     | 
| 
      
 4 
     | 
    
         
            +
              + To automatically append command options through .changelogko file - tieeeeen1994 (tieeeeen1994@gmail.com)
         
     | 
| 
      
 5 
     | 
    
         
            +
              + changelogko and releaseko aliases cko and rko - tieeeeen1994 (tieeeeen1994@gmail.com)
         
     | 
| 
      
 6 
     | 
    
         
            +
            ## Fixed (1 count/s)
         
     | 
| 
      
 7 
     | 
    
         
            +
              + Help format of changelogko - tieeeeen1994 (tieeeeen1994@gmail.com)
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
    
        data/LICENSE
    ADDED
    
    | 
         @@ -0,0 +1,21 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            MIT License
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            Copyright (c) 2022 Tien
         
     | 
| 
      
 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 all
         
     | 
| 
      
 13 
     | 
    
         
            +
            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 THE
         
     | 
| 
      
 21 
     | 
    
         
            +
            SOFTWARE.
         
     | 
    
        data/README.md
    ADDED
    
    | 
         @@ -0,0 +1,55 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Changelogko
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            This gem provides the ability to easily manage your change logs. Commit changes alongside change log files to easily track them without worry, then just release them whenever to automatically create a new CHANGELOG.md file.
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            As an additional feature, *Releaseko is integrated into the gem as it feels like Releaseko is very coupled with Changelogko.* It is also just a simple feature that just automatically updates `metadata/app-version`, releases change logs through Changelogko, then push.
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            ## Installation
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            Use `bundler` to install the gem.
         
     | 
| 
      
 10 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 11 
     | 
    
         
            +
            gem 'changelogko', git: 'https://github.com/tieeeeen1994/changelogko'
         
     | 
| 
      
 12 
     | 
    
         
            +
            ```
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            Then:
         
     | 
| 
      
 15 
     | 
    
         
            +
            ```
         
     | 
| 
      
 16 
     | 
    
         
            +
            $ bundle install
         
     | 
| 
      
 17 
     | 
    
         
            +
            ```
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            ## Usage
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
            ### Changelogko
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            Refer to:
         
     | 
| 
      
 24 
     | 
    
         
            +
            ```
         
     | 
| 
      
 25 
     | 
    
         
            +
            $ bundle exec changelogko -h
         
     | 
| 
      
 26 
     | 
    
         
            +
            ```
         
     | 
| 
      
 27 
     | 
    
         
            +
            or
         
     | 
| 
      
 28 
     | 
    
         
            +
            ```
         
     | 
| 
      
 29 
     | 
    
         
            +
            $ bundle exec cko -h
         
     | 
| 
      
 30 
     | 
    
         
            +
            ```
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
            Adding a `.changelogko` file in the root of the working directory will allow to automatically append the contents of the file as options to every `changelogko` (or `cko`) command. For example, assume the `.changelogko` file contains:
         
     | 
| 
      
 33 
     | 
    
         
            +
            ```
         
     | 
| 
      
 34 
     | 
    
         
            +
            --no-archive
         
     | 
| 
      
 35 
     | 
    
         
            +
            ```
         
     | 
| 
      
 36 
     | 
    
         
            +
            For every `changelogko` command, it will automatically append `--no-archive`, as such: `bundle exec changelogko -r --no-archive`.
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
            Changelogko will create the needed files if they don't exist yet.
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
            ### Releaseko
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
            Refer to:
         
     | 
| 
      
 43 
     | 
    
         
            +
            ```
         
     | 
| 
      
 44 
     | 
    
         
            +
            $ bundle exec releaseko -h
         
     | 
| 
      
 45 
     | 
    
         
            +
            ```
         
     | 
| 
      
 46 
     | 
    
         
            +
            or
         
     | 
| 
      
 47 
     | 
    
         
            +
            ```
         
     | 
| 
      
 48 
     | 
    
         
            +
            $ bundle exec rko -h
         
     | 
| 
      
 49 
     | 
    
         
            +
            ```
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
            Releaseko looks for `metadata/app-version` for the project's versioning. It will automatically increment this file based on mode.
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
            ## Credits
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
            The original author of this gem is [@neume](https://github.com/neume), then further enhanced by [@tieeeeen1994](https://github.com/tieeeeen1994).
         
     | 
    
        data/bin/changelogko
    ADDED
    
    
    
        data/bin/cko
    ADDED
    
    
    
        data/bin/releaseko
    ADDED
    
    
    
        data/bin/rko
    ADDED
    
    
    
        data/changelogko.gemspec
    ADDED
    
    | 
         @@ -0,0 +1,22 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            Gem::Specification.new do |s|
         
     | 
| 
      
 4 
     | 
    
         
            +
              s.name = 'changelogko'
         
     | 
| 
      
 5 
     | 
    
         
            +
              s.version = File.read('metadata/app-version').strip
         
     | 
| 
      
 6 
     | 
    
         
            +
              s.summary = 'Manage changelogs easily!'
         
     | 
| 
      
 7 
     | 
    
         
            +
              s.description = 'This is a gem that can manage changelogs very easily.'
         
     | 
| 
      
 8 
     | 
    
         
            +
              s.authors = ['Joseph Nelson Valeros', 'Jenek Michael Sarte']
         
     | 
| 
      
 9 
     | 
    
         
            +
              s.email = ['valerosjoseph@gmail.com', 'tieeeeen1994@gmail.com']
         
     | 
| 
      
 10 
     | 
    
         
            +
              s.files = Dir.chdir(__dir__) do
         
     | 
| 
      
 11 
     | 
    
         
            +
                `git ls-files -z`.split("\x0").reject do |f|
         
     | 
| 
      
 12 
     | 
    
         
            +
                  (File.expand_path(f) == __FILE__) ||
         
     | 
| 
      
 13 
     | 
    
         
            +
                    f.start_with?(*%w[.git .github Gemfile .vscode]) ||
         
     | 
| 
      
 14 
     | 
    
         
            +
                    f.end_with?(*%w[.gem .yml .gitignore])
         
     | 
| 
      
 15 
     | 
    
         
            +
                end
         
     | 
| 
      
 16 
     | 
    
         
            +
              end
         
     | 
| 
      
 17 
     | 
    
         
            +
              s.homepage = 'https://github.com/tieeeeen1994/changelogko'
         
     | 
| 
      
 18 
     | 
    
         
            +
              s.license = 'MIT'
         
     | 
| 
      
 19 
     | 
    
         
            +
              s.executables = %w[changelogko releaseko cko rko]
         
     | 
| 
      
 20 
     | 
    
         
            +
              s.required_ruby_version = '>= 3.2.2'
         
     | 
| 
      
 21 
     | 
    
         
            +
              s.metadata['rubygems_mfa_required'] = 'true'
         
     | 
| 
      
 22 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,70 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            # Class responsible for parsing options and detecting arguments passed for Changelogko.
         
     | 
| 
      
 4 
     | 
    
         
            +
            class Changelog::OptionParser
         
     | 
| 
      
 5 
     | 
    
         
            +
              Options = Struct.new(:release, :title, :type, :no_archive)
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
              def self.parse(argv)
         
     | 
| 
      
 8 
     | 
    
         
            +
                options = Options.new
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                parser = option_parser(options)
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                argv = ['-h'] if argv.empty?
         
     | 
| 
      
 13 
     | 
    
         
            +
                parser.parse!(argv)
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                options.title = argv.join(' ').strip.squeeze(' ').tr("\r\n", '') unless options.release
         
     | 
| 
      
 16 
     | 
    
         
            +
                options
         
     | 
| 
      
 17 
     | 
    
         
            +
              end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
              def self.option_parser(options)
         
     | 
| 
      
 20 
     | 
    
         
            +
                ::OptionParser.new do |opts|
         
     | 
| 
      
 21 
     | 
    
         
            +
                  opts.banner = "Usage: (changelogko|cko) [options]\nOptions:\n"
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                  release_option(opts, options)
         
     | 
| 
      
 24 
     | 
    
         
            +
                  type_option(opts, options)
         
     | 
| 
      
 25 
     | 
    
         
            +
                  types_option(opts)
         
     | 
| 
      
 26 
     | 
    
         
            +
                  no_archive_option(opts, options)
         
     | 
| 
      
 27 
     | 
    
         
            +
                  help_option(opts)
         
     | 
| 
      
 28 
     | 
    
         
            +
                end
         
     | 
| 
      
 29 
     | 
    
         
            +
              end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
              def self.release_option(opts, options)
         
     | 
| 
      
 32 
     | 
    
         
            +
                opts.on('-r', '--release', 'Create release from unreleased directory.') do
         
     | 
| 
      
 33 
     | 
    
         
            +
                  options.release = true
         
     | 
| 
      
 34 
     | 
    
         
            +
                end
         
     | 
| 
      
 35 
     | 
    
         
            +
              end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
              def self.type_option(opts, options)
         
     | 
| 
      
 38 
     | 
    
         
            +
                type_desc = 'Type of changelog. Use -T, --types to display all available types.'
         
     | 
| 
      
 39 
     | 
    
         
            +
                opts.on('-t', '--type [title]', String, type_desc) do |value|
         
     | 
| 
      
 40 
     | 
    
         
            +
                  options.type = value
         
     | 
| 
      
 41 
     | 
    
         
            +
                end
         
     | 
| 
      
 42 
     | 
    
         
            +
              end
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
              def self.types_option(opts)
         
     | 
| 
      
 45 
     | 
    
         
            +
                opts.on('-T', '--types', 'List available types.') do
         
     | 
| 
      
 46 
     | 
    
         
            +
                  TYPES.each do |type|
         
     | 
| 
      
 47 
     | 
    
         
            +
                    $stdout.puts "#{type.name}#{type.description}"
         
     | 
| 
      
 48 
     | 
    
         
            +
                  end
         
     | 
| 
      
 49 
     | 
    
         
            +
                  raise ProcessEnded
         
     | 
| 
      
 50 
     | 
    
         
            +
                end
         
     | 
| 
      
 51 
     | 
    
         
            +
              end
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
              def self.no_archive_option(opts, options)
         
     | 
| 
      
 54 
     | 
    
         
            +
                opts.on('-A', '--no-archive', 'Do not archive the release after creating it.') do
         
     | 
| 
      
 55 
     | 
    
         
            +
                  options.no_archive = true
         
     | 
| 
      
 56 
     | 
    
         
            +
                end
         
     | 
| 
      
 57 
     | 
    
         
            +
              end
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
              def self.help_option(opts)
         
     | 
| 
      
 60 
     | 
    
         
            +
                opts.on('-h', '--help', 'Show help.') do
         
     | 
| 
      
 61 
     | 
    
         
            +
                  $stdout.puts opts
         
     | 
| 
      
 62 
     | 
    
         
            +
                  $stdout.puts 'Adding a .changelogko file in the root of the working directory will allow to automatically ' \
         
     | 
| 
      
 63 
     | 
    
         
            +
                               'append the contents of the file as options to every `changelogko` (or `cko`) command. ' \
         
     | 
| 
      
 64 
     | 
    
         
            +
                               'For example, assume the .changelogko file contains "--no-archive". ' \
         
     | 
| 
      
 65 
     | 
    
         
            +
                               'For every changelogko command, it will automatically append --no-archive, ' \
         
     | 
| 
      
 66 
     | 
    
         
            +
                               'as such: bundle exec changelogko -r --no-archive.'
         
     | 
| 
      
 67 
     | 
    
         
            +
                  raise ProcessEnded
         
     | 
| 
      
 68 
     | 
    
         
            +
                end
         
     | 
| 
      
 69 
     | 
    
         
            +
              end
         
     | 
| 
      
 70 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,62 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            # Class responsible for writing the change logs and collating them.
         
     | 
| 
      
 4 
     | 
    
         
            +
            class Changelog::Writer
         
     | 
| 
      
 5 
     | 
    
         
            +
              def self.call(collection, no_archive = false)
         
     | 
| 
      
 6 
     | 
    
         
            +
                generate_change_log(collection)
         
     | 
| 
      
 7 
     | 
    
         
            +
                archive_old_change_log unless no_archive
         
     | 
| 
      
 8 
     | 
    
         
            +
                publish_change_log
         
     | 
| 
      
 9 
     | 
    
         
            +
                clear_unreleased_logs
         
     | 
| 
      
 10 
     | 
    
         
            +
              end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              def self.generate_change_log(collection)
         
     | 
| 
      
 13 
     | 
    
         
            +
                File.open(TEMP_CHANGE_LOG_NAME, 'w') do |file|
         
     | 
| 
      
 14 
     | 
    
         
            +
                  write_title(file)
         
     | 
| 
      
 15 
     | 
    
         
            +
                  TYPES.each do |type|
         
     | 
| 
      
 16 
     | 
    
         
            +
                    write_collection(type, collection, file)
         
     | 
| 
      
 17 
     | 
    
         
            +
                  end
         
     | 
| 
      
 18 
     | 
    
         
            +
                  file.puts ''
         
     | 
| 
      
 19 
     | 
    
         
            +
                end
         
     | 
| 
      
 20 
     | 
    
         
            +
                puts "Creating temporary file  #{::TEMP_CHANGE_LOG_NAME}"
         
     | 
| 
      
 21 
     | 
    
         
            +
              end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
              def self.archive_old_change_log
         
     | 
| 
      
 24 
     | 
    
         
            +
                system('mkdir -p changelogs')
         
     | 
| 
      
 25 
     | 
    
         
            +
                date_str = Time.now.strftime('%b-%d-%Y-%H-%M-%S')
         
     | 
| 
      
 26 
     | 
    
         
            +
                old_change_log_location = "changelogs/archive-#{date_str}.md"
         
     | 
| 
      
 27 
     | 
    
         
            +
                system("mv #{::CHANGE_LOG_NAME} #{old_change_log_location}")
         
     | 
| 
      
 28 
     | 
    
         
            +
                puts 'Archive old Changelog'
         
     | 
| 
      
 29 
     | 
    
         
            +
              end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
              def self.publish_change_log
         
     | 
| 
      
 32 
     | 
    
         
            +
                system("mv #{::TEMP_CHANGE_LOG_NAME} #{::CHANGE_LOG_NAME}")
         
     | 
| 
      
 33 
     | 
    
         
            +
                puts "Renamed #{::TEMP_CHANGE_LOG_NAME} to #{::CHANGE_LOG_NAME}"
         
     | 
| 
      
 34 
     | 
    
         
            +
              end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
              def self.clear_unreleased_logs
         
     | 
| 
      
 37 
     | 
    
         
            +
                puts 'Clearing changelogs/unreleased'
         
     | 
| 
      
 38 
     | 
    
         
            +
                system('rm changelogs/unreleased/*')
         
     | 
| 
      
 39 
     | 
    
         
            +
                system('rmdir changelogs/unreleased')
         
     | 
| 
      
 40 
     | 
    
         
            +
              end
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
              def self.write_title(file)
         
     | 
| 
      
 43 
     | 
    
         
            +
                file.puts("# Changelogs \n")
         
     | 
| 
      
 44 
     | 
    
         
            +
              end
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
              def self.write_collection(type, collection, file)
         
     | 
| 
      
 47 
     | 
    
         
            +
                lines = collection[type.name]
         
     | 
| 
      
 48 
     | 
    
         
            +
                size = lines.size
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
                return if size.zero?
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
                file.puts("## #{type.name.capitalize} (#{size} count/s)\n")
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
                write_lines(lines, file)
         
     | 
| 
      
 55 
     | 
    
         
            +
              end
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
              def self.write_lines(lines, file)
         
     | 
| 
      
 58 
     | 
    
         
            +
                lines.each do |line|
         
     | 
| 
      
 59 
     | 
    
         
            +
                  file.puts("  + #{line.title} - #{line.author}")
         
     | 
| 
      
 60 
     | 
    
         
            +
                end
         
     | 
| 
      
 61 
     | 
    
         
            +
              end
         
     | 
| 
      
 62 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/changelog.rb
    ADDED
    
    | 
         @@ -0,0 +1,128 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            # Main class that manages the set of actions for managing change logs.
         
     | 
| 
      
 4 
     | 
    
         
            +
            class Changelog
         
     | 
| 
      
 5 
     | 
    
         
            +
              attr_reader :file_path, :errors, :type, :title, :options, :source, :author
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
              def initialize(params, source = :file)
         
     | 
| 
      
 8 
     | 
    
         
            +
                @source = source
         
     | 
| 
      
 9 
     | 
    
         
            +
                @errors = []
         
     | 
| 
      
 10 
     | 
    
         
            +
                if source == :file
         
     | 
| 
      
 11 
     | 
    
         
            +
                  @file_path = params
         
     | 
| 
      
 12 
     | 
    
         
            +
                else
         
     | 
| 
      
 13 
     | 
    
         
            +
                  @options = params
         
     | 
| 
      
 14 
     | 
    
         
            +
                end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                load_data
         
     | 
| 
      
 17 
     | 
    
         
            +
              end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
              def valid?
         
     | 
| 
      
 20 
     | 
    
         
            +
                clear_errors
         
     | 
| 
      
 21 
     | 
    
         
            +
                load_data
         
     | 
| 
      
 22 
     | 
    
         
            +
                check_data
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                errors.empty?
         
     | 
| 
      
 25 
     | 
    
         
            +
              end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
              def validate!
         
     | 
| 
      
 28 
     | 
    
         
            +
                return true if valid?
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                raise InvalidLogFile, error_full_messages.join(".\n")
         
     | 
| 
      
 31 
     | 
    
         
            +
              end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
              def file
         
     | 
| 
      
 34 
     | 
    
         
            +
                @file ||= File.read(file_path)
         
     | 
| 
      
 35 
     | 
    
         
            +
              end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
              def load_data
         
     | 
| 
      
 38 
     | 
    
         
            +
                @title = data[:title]
         
     | 
| 
      
 39 
     | 
    
         
            +
                @type = data[:type]
         
     | 
| 
      
 40 
     | 
    
         
            +
                @author = data[:author]
         
     | 
| 
      
 41 
     | 
    
         
            +
              end
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
              def check_data
         
     | 
| 
      
 44 
     | 
    
         
            +
                add_error 'Missing Title' if @title.nil?
         
     | 
| 
      
 45 
     | 
    
         
            +
                add_error 'Missing Type' if @type.nil?
         
     | 
| 
      
 46 
     | 
    
         
            +
                validate_type
         
     | 
| 
      
 47 
     | 
    
         
            +
              end
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
              def validate_type
         
     | 
| 
      
 50 
     | 
    
         
            +
                type = TYPES.find { |t| t.name == @type }
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
                add_error "Invalid Type '#{@type}'" unless type
         
     | 
| 
      
 53 
     | 
    
         
            +
              end
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
              def clear_errors
         
     | 
| 
      
 56 
     | 
    
         
            +
                @errors = []
         
     | 
| 
      
 57 
     | 
    
         
            +
              end
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
              def data
         
     | 
| 
      
 60 
     | 
    
         
            +
                @data ||= load_from_source
         
     | 
| 
      
 61 
     | 
    
         
            +
              end
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
              def load_from_source
         
     | 
| 
      
 64 
     | 
    
         
            +
                if source == :file
         
     | 
| 
      
 65 
     | 
    
         
            +
                  yaml = YAML.safe_load(file)
         
     | 
| 
      
 66 
     | 
    
         
            +
                  initialize_props_from_yaml(yaml)
         
     | 
| 
      
 67 
     | 
    
         
            +
                else
         
     | 
| 
      
 68 
     | 
    
         
            +
                  initialize_props_from_options
         
     | 
| 
      
 69 
     | 
    
         
            +
                end
         
     | 
| 
      
 70 
     | 
    
         
            +
              end
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
              def initialize_props_from_yaml(yaml)
         
     | 
| 
      
 73 
     | 
    
         
            +
                {
         
     | 
| 
      
 74 
     | 
    
         
            +
                  title: yaml.fetch('title', nil),
         
     | 
| 
      
 75 
     | 
    
         
            +
                  type: yaml.fetch('type', nil),
         
     | 
| 
      
 76 
     | 
    
         
            +
                  author: yaml.fetch('author', nil)
         
     | 
| 
      
 77 
     | 
    
         
            +
                }
         
     | 
| 
      
 78 
     | 
    
         
            +
              end
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
              def initialize_props_from_options
         
     | 
| 
      
 81 
     | 
    
         
            +
                {
         
     | 
| 
      
 82 
     | 
    
         
            +
                  title: options.title,
         
     | 
| 
      
 83 
     | 
    
         
            +
                  type: options.type,
         
     | 
| 
      
 84 
     | 
    
         
            +
                  author: author_name
         
     | 
| 
      
 85 
     | 
    
         
            +
                }
         
     | 
| 
      
 86 
     | 
    
         
            +
              end
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
      
 88 
     | 
    
         
            +
              def to_s
         
     | 
| 
      
 89 
     | 
    
         
            +
                "Title: #{@title} | Type: #{@type}"
         
     | 
| 
      
 90 
     | 
    
         
            +
              end
         
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
      
 92 
     | 
    
         
            +
              def author_name
         
     | 
| 
      
 93 
     | 
    
         
            +
                name = "#{`git config user.name`[0..-2]} (#{`git config user.email`[0..-2]})"
         
     | 
| 
      
 94 
     | 
    
         
            +
                name = "#{`git config --global user.name`[0..-2]} (#{`git config --global user.email`[0..-2]})" if name =~ /\A\s*\Z/
         
     | 
| 
      
 95 
     | 
    
         
            +
                name
         
     | 
| 
      
 96 
     | 
    
         
            +
              end
         
     | 
| 
      
 97 
     | 
    
         
            +
             
     | 
| 
      
 98 
     | 
    
         
            +
              def show_errors
         
     | 
| 
      
 99 
     | 
    
         
            +
                errors_full_messages.each { |message| puts message }
         
     | 
| 
      
 100 
     | 
    
         
            +
              end
         
     | 
| 
      
 101 
     | 
    
         
            +
             
     | 
| 
      
 102 
     | 
    
         
            +
              def error_full_messages
         
     | 
| 
      
 103 
     | 
    
         
            +
                if source == :file
         
     | 
| 
      
 104 
     | 
    
         
            +
                  errors.collect { |error| "#{error} at #{file_path}" }
         
     | 
| 
      
 105 
     | 
    
         
            +
                else
         
     | 
| 
      
 106 
     | 
    
         
            +
                  errors
         
     | 
| 
      
 107 
     | 
    
         
            +
                end
         
     | 
| 
      
 108 
     | 
    
         
            +
              end
         
     | 
| 
      
 109 
     | 
    
         
            +
             
     | 
| 
      
 110 
     | 
    
         
            +
              def add_error(message)
         
     | 
| 
      
 111 
     | 
    
         
            +
                errors << message
         
     | 
| 
      
 112 
     | 
    
         
            +
              end
         
     | 
| 
      
 113 
     | 
    
         
            +
             
     | 
| 
      
 114 
     | 
    
         
            +
              def save
         
     | 
| 
      
 115 
     | 
    
         
            +
                File.open(generate_file_name, 'w') do |file|
         
     | 
| 
      
 116 
     | 
    
         
            +
                  file.puts("title: #{title}")
         
     | 
| 
      
 117 
     | 
    
         
            +
                  file.puts("author: #{author}")
         
     | 
| 
      
 118 
     | 
    
         
            +
                  file.puts("type: #{type}")
         
     | 
| 
      
 119 
     | 
    
         
            +
                end
         
     | 
| 
      
 120 
     | 
    
         
            +
              end
         
     | 
| 
      
 121 
     | 
    
         
            +
             
     | 
| 
      
 122 
     | 
    
         
            +
              def generate_file_name
         
     | 
| 
      
 123 
     | 
    
         
            +
                base_path = 'changelogs/unreleased'
         
     | 
| 
      
 124 
     | 
    
         
            +
                FileUtils.mkdir_p(base_path)
         
     | 
| 
      
 125 
     | 
    
         
            +
                safe_name = title.gsub(/[^\w-]/, '-')
         
     | 
| 
      
 126 
     | 
    
         
            +
                "#{base_path}/#{safe_name}.yml"
         
     | 
| 
      
 127 
     | 
    
         
            +
              end
         
     | 
| 
      
 128 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/changelogko.rb
    ADDED
    
    | 
         @@ -0,0 +1,66 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require 'yaml'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'fileutils'
         
     | 
| 
      
 5 
     | 
    
         
            +
            require 'optparse'
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            CHANGE_LOGS_PATH = './changelogs'
         
     | 
| 
      
 8 
     | 
    
         
            +
            CHANGE_LOG_NAME = './CHANGELOG.md'
         
     | 
| 
      
 9 
     | 
    
         
            +
            TEMP_CHANGE_LOG_NAME = './CHANGELOG.md.temp'
         
     | 
| 
      
 10 
     | 
    
         
            +
            InvalidLogFile = Class.new(StandardError)
         
     | 
| 
      
 11 
     | 
    
         
            +
            NoLogsFound = Class.new(StandardError)
         
     | 
| 
      
 12 
     | 
    
         
            +
            ProcessEnded = Class.new(StandardError)
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            Type = Struct.new(:name, :description)
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            TYPES = [
         
     | 
| 
      
 17 
     | 
    
         
            +
              Type.new('added', "\t\tAdd something new like a new feature."),
         
     | 
| 
      
 18 
     | 
    
         
            +
              Type.new('changed', "\t\tAlter something that already exists."),
         
     | 
| 
      
 19 
     | 
    
         
            +
              Type.new('deprecated', "\tDepreciate an existing feature."),
         
     | 
| 
      
 20 
     | 
    
         
            +
              Type.new('enhanced', "\tImprove an existing feature."),
         
     | 
| 
      
 21 
     | 
    
         
            +
              Type.new('fixed', "\t\tFix a bug."),
         
     | 
| 
      
 22 
     | 
    
         
            +
              Type.new('optimized', "\tRender a feature efficient and effective."),
         
     | 
| 
      
 23 
     | 
    
         
            +
              Type.new('other', "\t\tEtc."),
         
     | 
| 
      
 24 
     | 
    
         
            +
              Type.new('removed', "\t\tDelete a feature."),
         
     | 
| 
      
 25 
     | 
    
         
            +
              Type.new('secured', "\t\tEstablish a security layer.")
         
     | 
| 
      
 26 
     | 
    
         
            +
            ].freeze
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
            require 'changelog'
         
     | 
| 
      
 29 
     | 
    
         
            +
            require 'changelog/option_parser'
         
     | 
| 
      
 30 
     | 
    
         
            +
            require 'changelog/writer'
         
     | 
| 
      
 31 
     | 
    
         
            +
            require 'changelog/creator'
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
            begin
         
     | 
| 
      
 34 
     | 
    
         
            +
              changelogko_command_file_path = "#{FileUtils.pwd}/.changelogko"
         
     | 
| 
      
 35 
     | 
    
         
            +
              ARGV << File.read(changelogko_command_file_path).strip if File.exist?(changelogko_command_file_path)
         
     | 
| 
      
 36 
     | 
    
         
            +
              options = Changelog::OptionParser.parse(ARGV)
         
     | 
| 
      
 37 
     | 
    
         
            +
              if options.release
         
     | 
| 
      
 38 
     | 
    
         
            +
                log_collection = {}
         
     | 
| 
      
 39 
     | 
    
         
            +
                TYPES.each do |type|
         
     | 
| 
      
 40 
     | 
    
         
            +
                  log_collection[type.name] = []
         
     | 
| 
      
 41 
     | 
    
         
            +
                end
         
     | 
| 
      
 42 
     | 
    
         
            +
                files = 0
         
     | 
| 
      
 43 
     | 
    
         
            +
                Dir.glob('./changelogs/unreleased/*.yml') do |file|
         
     | 
| 
      
 44 
     | 
    
         
            +
                  changelog = Changelog.new(file, :file)
         
     | 
| 
      
 45 
     | 
    
         
            +
                  changelog.validate!
         
     | 
| 
      
 46 
     | 
    
         
            +
                  log_collection[changelog.type] << changelog
         
     | 
| 
      
 47 
     | 
    
         
            +
                  files += 1
         
     | 
| 
      
 48 
     | 
    
         
            +
                rescue InvalidLogFile => e
         
     | 
| 
      
 49 
     | 
    
         
            +
                  puts e.message
         
     | 
| 
      
 50 
     | 
    
         
            +
                  exit(1)
         
     | 
| 
      
 51 
     | 
    
         
            +
                end
         
     | 
| 
      
 52 
     | 
    
         
            +
                if files.positive?
         
     | 
| 
      
 53 
     | 
    
         
            +
                  Changelog::Writer.call(log_collection, options.no_archive)
         
     | 
| 
      
 54 
     | 
    
         
            +
                else
         
     | 
| 
      
 55 
     | 
    
         
            +
                  puts 'No logs found at changelogs/unreleased/'
         
     | 
| 
      
 56 
     | 
    
         
            +
                end
         
     | 
| 
      
 57 
     | 
    
         
            +
              elsif options.title && options.type
         
     | 
| 
      
 58 
     | 
    
         
            +
                Changelog::Creator.call(options)
         
     | 
| 
      
 59 
     | 
    
         
            +
                # Changelog creation
         
     | 
| 
      
 60 
     | 
    
         
            +
              end
         
     | 
| 
      
 61 
     | 
    
         
            +
            rescue InvalidLogFile => e
         
     | 
| 
      
 62 
     | 
    
         
            +
              puts e.message
         
     | 
| 
      
 63 
     | 
    
         
            +
              exit(1)
         
     | 
| 
      
 64 
     | 
    
         
            +
            rescue ProcessEnded
         
     | 
| 
      
 65 
     | 
    
         
            +
              exit
         
     | 
| 
      
 66 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,62 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module Releaseko
         
     | 
| 
      
 4 
     | 
    
         
            +
              # Class responsible for managing the file ./metadata/app-version.
         
     | 
| 
      
 5 
     | 
    
         
            +
              class AppVersion
         
     | 
| 
      
 6 
     | 
    
         
            +
                METHODS = %w[major minor build].freeze
         
     | 
| 
      
 7 
     | 
    
         
            +
                FILE_PATH = File.join(Dir.pwd, 'metadata', 'app-version').freeze
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                attr_reader :method, :breakdown
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                def initialize(method)
         
     | 
| 
      
 12 
     | 
    
         
            +
                  @method = method
         
     | 
| 
      
 13 
     | 
    
         
            +
                  validate!
         
     | 
| 
      
 14 
     | 
    
         
            +
                end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                def perform
         
     | 
| 
      
 17 
     | 
    
         
            +
                  breakdown_version
         
     | 
| 
      
 18 
     | 
    
         
            +
                  increment_on_method
         
     | 
| 
      
 19 
     | 
    
         
            +
                  build_version!
         
     | 
| 
      
 20 
     | 
    
         
            +
                end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                private
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                def validate!
         
     | 
| 
      
 25 
     | 
    
         
            +
                  CustomError.new("Unknown method: #{method}").complain unless METHODS.include?(method)
         
     | 
| 
      
 26 
     | 
    
         
            +
                  CustomError.new("#{FILE_PATH} not found", 2).complain unless File.exist?(FILE_PATH)
         
     | 
| 
      
 27 
     | 
    
         
            +
                end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                def app_version
         
     | 
| 
      
 30 
     | 
    
         
            +
                  @app_version ||= File.read(FILE_PATH).strip
         
     | 
| 
      
 31 
     | 
    
         
            +
                end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                def build_version!
         
     | 
| 
      
 34 
     | 
    
         
            +
                  puts "Overwriting #{FILE_PATH} with new version"
         
     | 
| 
      
 35 
     | 
    
         
            +
                  new_version = "#{breakdown['major']}.#{breakdown['minor']}.#{breakdown['build']}"
         
     | 
| 
      
 36 
     | 
    
         
            +
                  File.write(FILE_PATH, new_version)
         
     | 
| 
      
 37 
     | 
    
         
            +
                end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                def breakdown_version
         
     | 
| 
      
 40 
     | 
    
         
            +
                  puts 'Breaking down version numbers'
         
     | 
| 
      
 41 
     | 
    
         
            +
                  version_numbers = app_version.split('.')
         
     | 
| 
      
 42 
     | 
    
         
            +
                  @breakdown = {
         
     | 
| 
      
 43 
     | 
    
         
            +
                    'major' => version_numbers[0],
         
     | 
| 
      
 44 
     | 
    
         
            +
                    'minor' => version_numbers[1],
         
     | 
| 
      
 45 
     | 
    
         
            +
                    'build' => version_numbers[2],
         
     | 
| 
      
 46 
     | 
    
         
            +
                    'other' => version_numbers[3..].join('.')
         
     | 
| 
      
 47 
     | 
    
         
            +
                  }
         
     | 
| 
      
 48 
     | 
    
         
            +
                end
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
                def increment_on_method
         
     | 
| 
      
 51 
     | 
    
         
            +
                  puts "Incrementing #{method} number"
         
     | 
| 
      
 52 
     | 
    
         
            +
                  breakdown[method] = breakdown[method].next
         
     | 
| 
      
 53 
     | 
    
         
            +
                  reset_trailing_version_numbers
         
     | 
| 
      
 54 
     | 
    
         
            +
                end
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
                def reset_trailing_version_numbers
         
     | 
| 
      
 57 
     | 
    
         
            +
                  ((METHODS.find_index(method) + 1)..(METHODS.length - 1)).each do |i|
         
     | 
| 
      
 58 
     | 
    
         
            +
                    breakdown[METHODS[i]] = 0
         
     | 
| 
      
 59 
     | 
    
         
            +
                  end
         
     | 
| 
      
 60 
     | 
    
         
            +
                end
         
     | 
| 
      
 61 
     | 
    
         
            +
              end
         
     | 
| 
      
 62 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,12 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module Releaseko
         
     | 
| 
      
 4 
     | 
    
         
            +
              # Wrapper for Changelogko.
         
     | 
| 
      
 5 
     | 
    
         
            +
              class ChangelogWrapper
         
     | 
| 
      
 6 
     | 
    
         
            +
                def self.perform
         
     | 
| 
      
 7 
     | 
    
         
            +
                  puts 'Running changelogko -r'
         
     | 
| 
      
 8 
     | 
    
         
            +
                  return_value = system("#{'bundle exec ' if defined? Bundler}changelogko -r")
         
     | 
| 
      
 9 
     | 
    
         
            +
                  CustomError.new('changelogko crashed', $CHILD_STATUS.exitstatus).complain unless return_value
         
     | 
| 
      
 10 
     | 
    
         
            +
                end
         
     | 
| 
      
 11 
     | 
    
         
            +
              end
         
     | 
| 
      
 12 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,18 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module Releaseko
         
     | 
| 
      
 4 
     | 
    
         
            +
              # Custom Error object for Releaseko
         
     | 
| 
      
 5 
     | 
    
         
            +
              class CustomError
         
     | 
| 
      
 6 
     | 
    
         
            +
                attr_reader :message, :code
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                def initialize(message, code = 1)
         
     | 
| 
      
 9 
     | 
    
         
            +
                  @message = message
         
     | 
| 
      
 10 
     | 
    
         
            +
                  @code = code
         
     | 
| 
      
 11 
     | 
    
         
            +
                end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                def complain
         
     | 
| 
      
 14 
     | 
    
         
            +
                  puts "Error occurred!\n#{message}\nExit code #{code}"
         
     | 
| 
      
 15 
     | 
    
         
            +
                  exit(code)
         
     | 
| 
      
 16 
     | 
    
         
            +
                end
         
     | 
| 
      
 17 
     | 
    
         
            +
              end
         
     | 
| 
      
 18 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,17 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module Releaseko
         
     | 
| 
      
 4 
     | 
    
         
            +
              # Class that is responsible for updating the repository.
         
     | 
| 
      
 5 
     | 
    
         
            +
              class RepositoryUpdater
         
     | 
| 
      
 6 
     | 
    
         
            +
                def self.perform
         
     | 
| 
      
 7 
     | 
    
         
            +
                  puts 'Updating remote repository'
         
     | 
| 
      
 8 
     | 
    
         
            +
                  system('git add CHANGELOG.md metadata/app-version changelogs/*')
         
     | 
| 
      
 9 
     | 
    
         
            +
                  system('git commit -m "Bump app version and release changelogs"')
         
     | 
| 
      
 10 
     | 
    
         
            +
                  system('git push')
         
     | 
| 
      
 11 
     | 
    
         
            +
                end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                def self.set_to_push
         
     | 
| 
      
 14 
     | 
    
         
            +
                  ['-p', '--push'].include?(ARGV[2])
         
     | 
| 
      
 15 
     | 
    
         
            +
                end
         
     | 
| 
      
 16 
     | 
    
         
            +
              end
         
     | 
| 
      
 17 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/releaseko.rb
    ADDED
    
    | 
         @@ -0,0 +1,35 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require 'English'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'fileutils'
         
     | 
| 
      
 5 
     | 
    
         
            +
            require 'releaseko/custom_error'
         
     | 
| 
      
 6 
     | 
    
         
            +
            require 'releaseko/app_version'
         
     | 
| 
      
 7 
     | 
    
         
            +
            require 'releaseko/changelog_wrapper'
         
     | 
| 
      
 8 
     | 
    
         
            +
            require 'releaseko/repository_updater'
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            begin
         
     | 
| 
      
 11 
     | 
    
         
            +
              case ARGV[0]
         
     | 
| 
      
 12 
     | 
    
         
            +
              when '-m', '--method'
         
     | 
| 
      
 13 
     | 
    
         
            +
                Releaseko::AppVersion.new(ARGV[1]).perform
         
     | 
| 
      
 14 
     | 
    
         
            +
                Releaseko::ChangelogWrapper.perform
         
     | 
| 
      
 15 
     | 
    
         
            +
                Releaseko::RepositoryUpdater.perform if Releaseko::RepositoryUpdater.set_to_push
         
     | 
| 
      
 16 
     | 
    
         
            +
                puts 'Release operation is a success!!!'
         
     | 
| 
      
 17 
     | 
    
         
            +
              when '-h', '--help'
         
     | 
| 
      
 18 
     | 
    
         
            +
                puts 'Usage: (releaseko|rko) [options]'
         
     | 
| 
      
 19 
     | 
    
         
            +
                puts 'Options:'
         
     | 
| 
      
 20 
     | 
    
         
            +
                puts '  -m, --method [major, minor, build] [-p, --push]'
         
     | 
| 
      
 21 
     | 
    
         
            +
                puts '    Method of release so app version is updated accordingly.'
         
     | 
| 
      
 22 
     | 
    
         
            +
                puts '    Extra option -p, --push will automatically commit and push the release to working branch.'
         
     | 
| 
      
 23 
     | 
    
         
            +
                puts '    It will only push if the branch has a set upstream remote.'
         
     | 
| 
      
 24 
     | 
    
         
            +
                puts '  -h, --help'
         
     | 
| 
      
 25 
     | 
    
         
            +
                puts '    Display help. Duh.'
         
     | 
| 
      
 26 
     | 
    
         
            +
                puts 'Methods:'
         
     | 
| 
      
 27 
     | 
    
         
            +
                puts '  major  Increments major version number'
         
     | 
| 
      
 28 
     | 
    
         
            +
                puts '  minor  Increments minor version number'
         
     | 
| 
      
 29 
     | 
    
         
            +
                puts '  build  Increments build version number'
         
     | 
| 
      
 30 
     | 
    
         
            +
              else
         
     | 
| 
      
 31 
     | 
    
         
            +
                puts 'Use --help (-h) option for usage details'
         
     | 
| 
      
 32 
     | 
    
         
            +
              end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
              exit(0)
         
     | 
| 
      
 35 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            1.4.0
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,71 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: changelogko
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.4.0
         
     | 
| 
      
 5 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 6 
     | 
    
         
            +
            authors:
         
     | 
| 
      
 7 
     | 
    
         
            +
            - Joseph Nelson Valeros
         
     | 
| 
      
 8 
     | 
    
         
            +
            - Jenek Michael Sarte
         
     | 
| 
      
 9 
     | 
    
         
            +
            autorequire:
         
     | 
| 
      
 10 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 11 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2024-04-03 00:00:00.000000000 Z
         
     | 
| 
      
 13 
     | 
    
         
            +
            dependencies: []
         
     | 
| 
      
 14 
     | 
    
         
            +
            description: This is a gem that can manage changelogs very easily.
         
     | 
| 
      
 15 
     | 
    
         
            +
            email:
         
     | 
| 
      
 16 
     | 
    
         
            +
            - valerosjoseph@gmail.com
         
     | 
| 
      
 17 
     | 
    
         
            +
            - tieeeeen1994@gmail.com
         
     | 
| 
      
 18 
     | 
    
         
            +
            executables:
         
     | 
| 
      
 19 
     | 
    
         
            +
            - changelogko
         
     | 
| 
      
 20 
     | 
    
         
            +
            - releaseko
         
     | 
| 
      
 21 
     | 
    
         
            +
            - cko
         
     | 
| 
      
 22 
     | 
    
         
            +
            - rko
         
     | 
| 
      
 23 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 24 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 25 
     | 
    
         
            +
            files:
         
     | 
| 
      
 26 
     | 
    
         
            +
            - CHANGELOG.md
         
     | 
| 
      
 27 
     | 
    
         
            +
            - LICENSE
         
     | 
| 
      
 28 
     | 
    
         
            +
            - README.md
         
     | 
| 
      
 29 
     | 
    
         
            +
            - bin/changelogko
         
     | 
| 
      
 30 
     | 
    
         
            +
            - bin/cko
         
     | 
| 
      
 31 
     | 
    
         
            +
            - bin/releaseko
         
     | 
| 
      
 32 
     | 
    
         
            +
            - bin/rko
         
     | 
| 
      
 33 
     | 
    
         
            +
            - changelogko.gemspec
         
     | 
| 
      
 34 
     | 
    
         
            +
            - changelogs/archive-Feb-16-2024-10-21-04.md
         
     | 
| 
      
 35 
     | 
    
         
            +
            - changelogs/archive-Nov-07-2022-09-15-11.md
         
     | 
| 
      
 36 
     | 
    
         
            +
            - lib/changelog.rb
         
     | 
| 
      
 37 
     | 
    
         
            +
            - lib/changelog/creator.rb
         
     | 
| 
      
 38 
     | 
    
         
            +
            - lib/changelog/option_parser.rb
         
     | 
| 
      
 39 
     | 
    
         
            +
            - lib/changelog/writer.rb
         
     | 
| 
      
 40 
     | 
    
         
            +
            - lib/changelogko.rb
         
     | 
| 
      
 41 
     | 
    
         
            +
            - lib/releaseko.rb
         
     | 
| 
      
 42 
     | 
    
         
            +
            - lib/releaseko/app_version.rb
         
     | 
| 
      
 43 
     | 
    
         
            +
            - lib/releaseko/changelog_wrapper.rb
         
     | 
| 
      
 44 
     | 
    
         
            +
            - lib/releaseko/custom_error.rb
         
     | 
| 
      
 45 
     | 
    
         
            +
            - lib/releaseko/repository_updater.rb
         
     | 
| 
      
 46 
     | 
    
         
            +
            - metadata/app-version
         
     | 
| 
      
 47 
     | 
    
         
            +
            homepage: https://github.com/tieeeeen1994/changelogko
         
     | 
| 
      
 48 
     | 
    
         
            +
            licenses:
         
     | 
| 
      
 49 
     | 
    
         
            +
            - MIT
         
     | 
| 
      
 50 
     | 
    
         
            +
            metadata:
         
     | 
| 
      
 51 
     | 
    
         
            +
              rubygems_mfa_required: 'true'
         
     | 
| 
      
 52 
     | 
    
         
            +
            post_install_message:
         
     | 
| 
      
 53 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 54 
     | 
    
         
            +
            require_paths:
         
     | 
| 
      
 55 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 56 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 57 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 58 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 59 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 60 
     | 
    
         
            +
                  version: 3.2.2
         
     | 
| 
      
 61 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 62 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 63 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 64 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 65 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 66 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 67 
     | 
    
         
            +
            rubygems_version: 3.4.10
         
     | 
| 
      
 68 
     | 
    
         
            +
            signing_key:
         
     | 
| 
      
 69 
     | 
    
         
            +
            specification_version: 4
         
     | 
| 
      
 70 
     | 
    
         
            +
            summary: Manage changelogs easily!
         
     | 
| 
      
 71 
     | 
    
         
            +
            test_files: []
         
     |