Skip to content

Commit

Permalink
Merge 0829314 into bf4f3b2
Browse files Browse the repository at this point in the history
  • Loading branch information
smolijar committed Mar 12, 2019
2 parents bf4f3b2 + 0829314 commit 5a95df5
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 20 deletions.
103 changes: 92 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<p align="center">
<div align="center">
<img src="https://i.imgur.com/ZH8ftR9.png" height="170">
</p>

# Vump

Expand All @@ -9,20 +8,58 @@
[![Gem](https://img.shields.io/gem/v/vump.svg?style=flat-square)](https://rubygems.org/gems/vump)
[![Maintainability](https://img.shields.io/codeclimate/maintainability/grissius/vump.svg?style=flat-square)](https://codeclimate.com/github/grissius/vump)
[![License](https://img.shields.io/github/license/grissius/vump.svg?style=flat-square)](https://github.com/grissius/vump/blob/master/LICENSE)
[![vump](https://img.shields.io/static/v1.svg?label=versions&message=well-behaved&color=f39c12&style=flat-square&logo=data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iTGF5ZXJfMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeD0iMHB4IiB5PSIwcHgiIHdpZHRoPSI4Ny42ODNweCIgaGVpZ2h0PSIxMDYuMTgzcHgiIHZpZXdCb3g9IjAgMCA4Ny42ODMgMTA2LjE4MyIgZW5hYmxlLWJhY2tncm91bmQ9Im5ldyAwIDAgODcuNjgzIDEwNi4xODMiIHhtbDpzcGFjZT0icHJlc2VydmUiPjxwYXRoIGZpbGw9IiN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wyLjM2OSwyLjIyOSwzLjk4NC0wLjg3OSw2LjE2N0MtNS4yMTQsNjQuNzA0LTQuNDYsODYuNjUzLDE1LjM1OCw5OC42MmMxNC44MDMsOC45MzYsMzAuNjA0LDkuMzM2LDQ2Ljc0NCw0LjQxNGMxMC4xMDctMy4wODIsMTguMjgxLTguODIyLDIzLjAyOS0xOC41OUM4Ny4xMTgsODAuMzYsODguNDczLDc2LjA3Nyw4Ny4xNjcsNzEuNDIxeiBNNTguNDM2LDM2LjU4N2MyLjM0OCwwLDQuMjUsMS45MDMsNC4yNSw0LjI1cy0xLjkwMiw0LjI1LTQuMjUsNC4yNXMtNC4yNS0xLjkwMy00LjI1LTQuMjVTNTYuMDg4LDM2LjU4Nyw1OC40MzYsMzYuNTg3eiBNNDMuMzczLDQ3LjU4N2MyLjAxNiwwLDMuNjQ5LDAuMjczLDMuNjQ5LDEuMTY4YzAsMi4wMTUtMS42MzQsMy42NDktMy42NDksMy42NDlzLTMuNjQ5LTEuNjM0LTMuNjQ5LTMuNjQ5QzM5LjcyMyw0Ny44Niw0MS4zNTcsNDcuNTg3LDQzLjM3Myw0Ny41ODd6IE0yOS4zNzQsMzYuNTg3YzIuMzQ4LDAsNC4yNSwxLjkwMyw0LjI1LDQuMjVzLTEuOTAyLDQuMjUtNC4yNSw0LjI1cy00LjI1LTEuOTAzLTQuMjUtNC4yNVMyNy4wMjYsMzYuNTg3LDI5LjM3NCwzNi41ODd6Ii8+PC9zdmc+)](https://github.com/grissius/vump)

CLI semantic verison bumper for every project. With a kitty inside.

CLI semantic version bumper for every project. With a kitty inside.

</div>

## Demo
:construction: TODO

## Motivation
Do you like when projects use semantic versioning a keep a maintained changelog? I bet you do.
Yet it is not rare that a patch version change breaks your app.
Versions of a random maintained project are a mess.
Most of the time, developers use version, because they are forced to, not because they want to.

Here is why:

1. Some people don't know or understand the benefits, for those there are projects like [semver](https://semver.org/), [keep-a-changelog](https://keepachangelog.com) etc.
2. The others are lazy. It is hard. The routine is boring, menial and frustrating if you make a mistake, since you cannot usually republish with the same version tag. For those, I made [vump](https://github.com/grissius/vump).

### Vump do I do?

I try to understand you project. You decide which semver update best describes the unreleased changes and I will snoop your project, do all the file writes in the current directory and then stage them, commit and tag.

If it sounds simple, it's because it is. You might argue that there are many CLI tools doing just the same (find them bellow), even more. That might be true. But very few have ambition to handle different platforms under one hood, and hang on fast to existing standards!

### Features

- :package: Modular and generic approach
- :mortar_board: Opinionated, based on standards
- :ledger: Changelog management
- :cop: Synced, controlled version
- :heavy_check_mark: Solid test coverage
- :information_source: User documentation
- :speech_balloon: Helpful output
- :wrench: Handful of options


## Getting started

```
```bash
gem install vump
```

:gem: Don't like ruby? There are likely to be prebundled packages for Linux, Windows and Mac in the future.

```bash
cd my-project
vump patch
```

## Usage

```
Expand All @@ -41,14 +78,58 @@ vump [<major|minor|patch|<semver-string>>] [...options]
| `--date` , | `2020-12-20` | Modify date of committing release. Used by changelog. (default now) |
| `--dry` , `-d` | - | Dry run (no writes or CSV manipulation) |
| `--path` , `-p` | `/foo/bar` | Path to the repo (default pwd) |

### Examples

- Bump minor version (`mi` is a prefix that cannot be confused with semver or other bumps)
```ps
vump mi
```
- Bump patch version of project in `~/Projects/foo`. Ommit all git operations.
```ps
vump patch -p=~/Projects/foo --no-git
```
- Set version of the projet on `1.1.1-beta-3` (use semver's [pre-release](https://semver.org/#spec-item-9))
```ps
vump 1.1.1 --pre=beta-3
```


## How to use for your project
Vump finds which modules are relevant for your project, asks them for version and if all relevent modules align, it bumps each of them. There are some modules, you can use no matter the project:

**Changelog** module manipulates with `CHANGELOG.md` file according to [keep-a-changelog](https://keepachangelog.com) standard. Using Vump you get changelog maintanance for free, all you need to do is to track your changes in _Unreleased_ section.

**Version file** is probably the simplest module of all. It keeps just the version string followed by a newline in `VERSION` text file. You can use it along with other modules, or if you have no other place to keep your version.
This module also comes handy, when your metadata are stored in a non-static file (meaning, it is interpreted via any runtime). This is the case for ruby for instance. Vump cannot parse interpret the complexity of ruby runtime. But you can read version from the `VERSION` file in your gemspec.

- **JavaScript / Node.js**
- :rainbow: **npm** Native module for npm's `package.json` and `package-lock.json`
- :construction: **bower** - native module coming soon
- :construction: **component** - native module coming soon

- **Ruby**
- :sunny: **rubygems** - Dynamic specification, you can [use](https://stackoverflow.com/a/23135266) `VERSION` file
- **PHP**
- :construction: **composer** - native module coming soon
- **Python**
- :sunny: **PyPI** - Dynamic specification, you can use `VERSION` file

Are you missing something? Please let me know and I will gladly implement new module!

## Related projects
https://github.com/warner/python-versioneer
https://www.npmjs.com/package/version-bump-prompt
https://www.npmjs.com/package/npm-bump
https://github.com/fabiospampinato/bump
https://packagist.org/packages/quazardous/php-bump-version
https://metacpan.org/pod/release/DBOOK/App-RewriteVersion-0.003/script/perl-bump-version
https://github.com/killwort/dotnet-bump
- [python-versioneer](https://github.com/warner/python-versioneer)
- [version-bump-prompt](https://www.npmjs.com/package/version-bump-prompt)
- [npm-bump](https://www.npmjs.com/package/npm-bump)
- [bump](https://github.com/fabiospampinato/bump)
- [php-bump-version](https://packagist.org/packages/quazardous/php-bump-version)
- [perl-bump-version](https://metacpan.org/pod/release/DBOOK/App-RewriteVersion-0.003/script/perl-bump-version)
- [dotnet-bump](https://github.com/killwort/dotnet-bump)
- [release-it](https://www.npmjs.com/package/release-it)
- [bumped](https://github.com/bumped/bumped)

Are there any other good alternatives? Please let me know and I will update the list!

## License

Licensed under [MIT](./LICENSE)
4 changes: 4 additions & 0 deletions lib/vump/cli/reporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def add_read_version(mod, version)
# rubocop:disable Metrics/MethodLength
# rubocop:disable Metrics/AbcSize
# rubocop:disable Metrics/LineLength
# rubocop:disable Metrics/CyclomaticComplexity
def help
puts 'vump'.bold.yellow + ' [<major|minor|patch|<semver-string>>] [...options]'.yellow
header title: 'Available options:'
Expand Down Expand Up @@ -99,6 +100,8 @@ def report_module_overview
column('READ VERSION', width: 20)
end
@modules.each do |name, data|
next if !data[:relevant] && @level > ::Logger::DEBUG

row do
rel = data[:relevant]
column(name)
Expand All @@ -112,5 +115,6 @@ def report_module_overview
# rubocop:enable Metrics/AbcSize
# rubocop:enable Metrics/MethodLength
# rubocop:enable Metrics/LineLength
# rubocop:enable Metrics/CyclomaticComplexity
end
end
4 changes: 2 additions & 2 deletions lib/vump/git/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def commit(version)
result = @options[:dry] ? 'Dry run success' : @git.commit(message)
if @logger
if result != ''
@logger.info("Created commit #{message}")
@logger.info("Created commit #{message.yellow}")
else
@logger.error('Could not commit files. Perhaps the hook failed.')
end
Expand All @@ -36,7 +36,7 @@ def commit(version)

def tag(version_tag)
@git.add_tag(version_tag) unless @options[:dry]
@logger.info("Created tag #{version_tag}") if @logger
@logger.info("Created tag #{version_tag.yellow}") if @logger
end
end
end
3 changes: 2 additions & 1 deletion lib/vump/logger/logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class Logger

def initialize(options = {})
@logger = ::Logger.new(options[:out] || STDOUT)
@logger.level = ::Logger::INFO
@logger.level = ::Logger::DEBUG if options[:verbose]
@logger.level = ::Logger::UNKNOWN if options[:silent]
@logger.formatter = proc do |_severity, _datetime, progname, msg|
Expand All @@ -28,7 +29,7 @@ def warn(message, module_name = nil)
end

def error(message, module_name = nil)
@logger.add(::Logger::ERROR, message, module_name)
@logger.add(::Logger::ERROR, message.red, module_name)
end
end
end
10 changes: 6 additions & 4 deletions lib/vump/vump.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ def read_versions(modules)
def select_version(versions)
@reporter.report_module_overview
if versions.uniq.length > 1
@logger.warn("Inconsitent version records: #{versions}")
@logger.error("Inconsitent version records: #{versions}")
return false
end
@logger.info(
"Single version extracted from all modules: #{versions.first}"
"Version extracted #{versions.first.yellow}"
)
versions.first
end
Expand All @@ -64,7 +64,7 @@ def write_versions(modules, version)
mod.write(version)
@logger.debug("Writing new version \"#{version}\"", mod.class)
end
@logger.info("All relevant modules written \"#{version}\"")
@logger.info("Relevant modules have written #{version.yellow}")

if @git.loaded?
commit(modules, version) unless @options[:no_git]
Expand Down Expand Up @@ -92,11 +92,13 @@ def compose_version(latest, arg, pre, build)
def bump(arg = nil, pre = nil, build = nil)
modules = load_modules
version = select_version(read_versions(modules))
return unless version

semver = compose_version(version, arg, pre, build)
if semver.valid?
write_versions(modules, semver.to_s)
else
@logger.error('Provided version is not a valid semver string')
@logger.error("Provided version #{arg} is not a valid semver string")
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/vump/cli/reporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class FooModule; end
class BarModule; end

reporter = Vump::Reporter.new({})
reporter = Vump::Reporter.new(verbose: true)

RSpec.describe Vump::Reporter do
context 'report_preamble' do
Expand Down
12 changes: 11 additions & 1 deletion spec/vump/logger/logger_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,17 @@
end
it 'outputs' do
logger.error('foo')
expect(io.string).to eq("foo\n")
expect(io.string).to match(/foo/)
end
end
context 'warn' do
after(:each) do
logger.level = ::Logger::DEBUG
io.reopen('')
end
it 'outputs' do
logger.warn('foo')
expect(io.string).to match(/foo/)
end
end
end

0 comments on commit 5a95df5

Please sign in to comment.