vump 2.0.0.pre.alpha.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ec1748a44dde478e47b682e58b26b93acd5576b1943b190f6d51273503bdb41b
4
- data.tar.gz: 15ca18dc809e13ccd90e93fa213b2428931a2005353bbf8c40b608993ac8183c
3
+ metadata.gz: 9f02945e44f4f83779a9cad49ec9c57f1f3bef719f072e53cb795d2c69030f97
4
+ data.tar.gz: e6d702152984f02d78828d6200e6089fccbae43f1891302ef8dee6dce65b0dbc
5
5
  SHA512:
6
- metadata.gz: e8318b5ea233fed11cf79c570ef1748f5fc98a6393065246f6dbfd29dbe28cb87e83bd35de3b6bc21426e71b2472c96cc00e0fd4fa327b7f44bd1d01efd82236
7
- data.tar.gz: 92bbad25ecf6116304382d3097b98191dc841914593b8a8ad85f950466735343ff081d73b063d6586e4e1a7b110963e036393af77f3e7e97c347e4b3974d0fec
6
+ metadata.gz: 874d16aad24498b659d27ba99b2e3a01631cc53dda1c469fb46d98754de79e28d4b824c25317cd8660b48f9aff859d4215919dbad930e22ab1febbae387ef6d0
7
+ data.tar.gz: 3257dbcf0ac6558fadeafdd44c6981c95f0af0cce4f986ce5218de7e8cb8063dff8b61d8ce8b24d20cb778ed319564a177494580ec4f888bbfc524aea95d69a2
data/README.md CHANGED
@@ -1,6 +1,5 @@
1
- <p align="center">
1
+ <div align="center">
2
2
  <img src="https://i.imgur.com/ZH8ftR9.png" height="170">
3
- </p>
4
3
 
5
4
  # Vump
6
5
 
@@ -9,24 +8,62 @@
9
8
  [![Gem](https://img.shields.io/gem/v/vump.svg?style=flat-square)](https://rubygems.org/gems/vump)
10
9
  [![Maintainability](https://img.shields.io/codeclimate/maintainability/grissius/vump.svg?style=flat-square)](https://codeclimate.com/github/grissius/vump)
11
10
  [![License](https://img.shields.io/github/license/grissius/vump.svg?style=flat-square)](https://github.com/grissius/vump/blob/master/LICENSE)
11
+ [![vump](https://img.shields.io/static/v1.svg?label=versions&message=well-behaved&color=f39c12&style=flat-square&logo=data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iTGF5ZXJfMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeD0iMHB4IiB5PSIwcHgiIHdpZHRoPSI4Ny42ODNweCIgaGVpZ2h0PSIxMDYuMTgzcHgiIHZpZXdCb3g9IjAgMCA4Ny42ODMgMTA2LjE4MyIgZW5hYmxlLWJhY2tncm91bmQ9Im5ldyAwIDAgODcuNjgzIDEwNi4xODMiIHhtbDpzcGFjZT0icHJlc2VydmUiPjxwYXRoIGZpbGw9IiNGRkZGRkYiIGQ9Ik04Ny4xNjcsNzEuNDIxYy0wLjk5Mi0zLjUzNS0zLjEwNy01LjgxOC02Ljg2My02LjM1Yy0zLjcyNy0wLjUyOS02LjYwNywwLjgyNC04LjMyOCw0LjEzN2MtMS4xNDUsMi4yMDEtMS45ODgsNC41Ny0yLjgzMiw2LjkxNGMtMS40ODQsNC4xMTktMy40MzksNy44OTMtNi42MDcsMTEuMDM3Yy0xMC45MzIsMTAuODQ2LTM0Ljk2MSwxMi4wMzctNDYuODA3LDIuMTdjLTEuNDUxLTEuMjA5LTMuMzQtMi4yMzYtMy41NzgtNC40MzljMC45OTItMC45MywxLjk3OS0wLjMwNSwyLjkyNi0wLjI3MWM5LjEzNywwLjMxMywxOC4zNDIsMS41NzIsMjcuMzQ4LTAuODI4YzcuOTA2LTIuMTA3LDEwLjAzMy05LjU4Ni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LDMuNjQ5LDEuMTY4YzAsMi4wMTUtMS42MzQsMy42NDktMy42NDksMy42NDlzLTMuNjQ5LTEuNjM0LTMuNjQ5LTMuNjQ5QzM5LjcyMyw0Ny44Niw0MS4zNTcsNDcuNTg3LDQzLjM3Myw0Ny41ODd6IE0yOS4zNzQsMzYuNTg3YzIuMzQ4LDAsNC4yNSwxLjkwMyw0LjI1LDQuMjVzLTEuOTAyLDQuMjUtNC4yNSw0LjI1cy00LjI1LTEuOTAzLTQuMjUtNC4yNVMyNy4wMjYsMzYuNTg3LDI5LjM3NCwzNi41ODd6Ii8+PC9zdmc+)](https://github.com/grissius/vump)
12
12
 
13
- CLI semantic verison bumper for every project. With a kitty inside.
13
+
14
+ CLI semantic version bumper for every project. With a kitty inside.
15
+
16
+ </div>
14
17
 
15
18
  ## Demo
16
19
  :construction: TODO
17
20
 
21
+ ## Motivation
22
+ Do you like when projects use semantic versioning a keep a maintained changelog? I bet you do.
23
+ Yet it is not rare that a patch version change breaks your app.
24
+ Versions of a random maintained project are a mess.
25
+ Most of the time, developers use version, because they are forced to, not because they want to.
26
+
27
+ Here is why:
28
+
29
+ 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.
30
+ 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).
31
+
32
+ ### Vump do I do?
33
+
34
+ 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.
35
+
36
+ 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!
37
+
38
+ ### Features
39
+
40
+ - :package: Modular and generic approach
41
+ - :mortar_board: Opinionated, based on standards
42
+ - :ledger: Changelog management
43
+ - :cop: Synced, controlled version
44
+ - :heavy_check_mark: Solid test coverage
45
+ - :information_source: User documentation
46
+ - :speech_balloon: Helpful output
47
+ - :wrench: Handful of options
48
+
49
+
18
50
  ## Getting started
19
51
 
20
- ```
52
+ ```bash
21
53
  gem install vump
22
54
  ```
23
55
 
24
56
  :gem: Don't like ruby? There are likely to be prebundled packages for Linux, Windows and Mac in the future.
25
57
 
58
+ ```bash
59
+ cd my-project
60
+ vump patch
61
+ ```
62
+
26
63
  ## Usage
27
64
 
28
65
  ```
29
- vump <major|minor|patch> [...options]
66
+ vump [<major|minor|patch|<semver-string>>] [...options]
30
67
  ```
31
68
 
32
69
  | Option | Example value | Explanation |
@@ -42,6 +79,57 @@ vump <major|minor|patch> [...options]
42
79
  | `--dry` , `-d` | - | Dry run (no writes or CSV manipulation) |
43
80
  | `--path` , `-p` | `/foo/bar` | Path to the repo (default pwd) |
44
81
 
82
+ ### Examples
83
+
84
+ - Bump minor version (`mi` is a prefix that cannot be confused with semver or other bumps)
85
+ ```ps
86
+ vump mi
87
+ ```
88
+ - Bump patch version of project in `~/Projects/foo`. Ommit all git operations.
89
+ ```ps
90
+ vump patch -p=~/Projects/foo --no-git
91
+ ```
92
+ - Set version of the projet on `1.1.1-beta-3` (use semver's [pre-release](https://semver.org/#spec-item-9))
93
+ ```ps
94
+ vump 1.1.1 --pre=beta-3
95
+ ```
96
+
97
+
98
+ ## How to use for your project
99
+ 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:
100
+
101
+ **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.
102
+
103
+ **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.
104
+ 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.
105
+
106
+ - **JavaScript / Node.js**
107
+ - :rainbow: **npm** Native module for npm's `package.json` and `package-lock.json`
108
+ - :construction: **bower** - native module coming soon
109
+ - :construction: **component** - native module coming soon
110
+
111
+ - **Ruby**
112
+ - :sunny: **rubygems** - Dynamic specification, you can [use](https://stackoverflow.com/a/23135266) `VERSION` file
113
+ - **PHP**
114
+ - :construction: **composer** - native module coming soon
115
+ - **Python**
116
+ - :sunny: **PyPI** - Dynamic specification, you can use `VERSION` file
117
+
118
+ Are you missing something? Please let me know and I will gladly implement new module!
119
+
120
+ ## Related projects
121
+ - [python-versioneer](https://github.com/warner/python-versioneer)
122
+ - [version-bump-prompt](https://www.npmjs.com/package/version-bump-prompt)
123
+ - [npm-bump](https://www.npmjs.com/package/npm-bump)
124
+ - [bump](https://github.com/fabiospampinato/bump)
125
+ - [php-bump-version](https://packagist.org/packages/quazardous/php-bump-version)
126
+ - [perl-bump-version](https://metacpan.org/pod/release/DBOOK/App-RewriteVersion-0.003/script/perl-bump-version)
127
+ - [dotnet-bump](https://github.com/killwort/dotnet-bump)
128
+ - [release-it](https://www.npmjs.com/package/release-it)
129
+ - [bumped](https://github.com/bumped/bumped)
130
+
131
+ Are there any other good alternatives? Please let me know and I will update the list!
132
+
45
133
  ## License
46
134
 
47
135
  Licensed under [MIT](./LICENSE)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.0-alpha.1
1
+ 2.0.0
@@ -31,8 +31,10 @@ module Vump
31
31
  :major
32
32
  when /^mi.*/
33
33
  :minor
34
- else
34
+ when /^p/
35
35
  :patch
36
+ else
37
+ args.first
36
38
  end
37
39
  end
38
40
 
@@ -49,6 +51,8 @@ module Vump
49
51
  verbose: false,
50
52
  version: false,
51
53
  tag_prefix: 'v',
54
+ build: nil,
55
+ pre: nil,
52
56
  path: Dir.pwd,
53
57
  }
54
58
  options.keys.each_with_object(defaults) do |k, acc|
@@ -38,8 +38,9 @@ module Vump
38
38
  # rubocop:disable Metrics/MethodLength
39
39
  # rubocop:disable Metrics/AbcSize
40
40
  # rubocop:disable Metrics/LineLength
41
+ # rubocop:disable Metrics/CyclomaticComplexity
41
42
  def help
42
- puts 'vump'.bold.yellow + ' <major|minor|patch> [...options]'.yellow
43
+ puts 'vump'.bold.yellow + ' [<major|minor|patch|<semver-string>>] [...options]'.yellow
43
44
  header title: 'Available options:'
44
45
  table(border: false) do
45
46
  [
@@ -99,6 +100,8 @@ module Vump
99
100
  column('READ VERSION', width: 20)
100
101
  end
101
102
  @modules.each do |name, data|
103
+ next if !data[:relevant] && @level > ::Logger::DEBUG
104
+
102
105
  row do
103
106
  rel = data[:relevant]
104
107
  column(name)
@@ -112,5 +115,6 @@ module Vump
112
115
  # rubocop:enable Metrics/AbcSize
113
116
  # rubocop:enable Metrics/MethodLength
114
117
  # rubocop:enable Metrics/LineLength
118
+ # rubocop:enable Metrics/CyclomaticComplexity
115
119
  end
116
120
  end
@@ -26,7 +26,7 @@ module Vump
26
26
  result = @options[:dry] ? 'Dry run success' : @git.commit(message)
27
27
  if @logger
28
28
  if result != ''
29
- @logger.info("Created commit #{message}")
29
+ @logger.info("Created commit #{message.yellow}")
30
30
  else
31
31
  @logger.error('Could not commit files. Perhaps the hook failed.')
32
32
  end
@@ -36,7 +36,7 @@ module Vump
36
36
 
37
37
  def tag(version_tag)
38
38
  @git.add_tag(version_tag) unless @options[:dry]
39
- @logger.info("Created tag #{version_tag}") if @logger
39
+ @logger.info("Created tag #{version_tag.yellow}") if @logger
40
40
  end
41
41
  end
42
42
  end
@@ -8,6 +8,7 @@ module Vump
8
8
 
9
9
  def initialize(options = {})
10
10
  @logger = ::Logger.new(options[:out] || STDOUT)
11
+ @logger.level = ::Logger::INFO
11
12
  @logger.level = ::Logger::DEBUG if options[:verbose]
12
13
  @logger.level = ::Logger::UNKNOWN if options[:silent]
13
14
  @logger.formatter = proc do |_severity, _datetime, progname, msg|
@@ -28,7 +29,7 @@ module Vump
28
29
  end
29
30
 
30
31
  def error(message, module_name = nil)
31
- @logger.add(::Logger::ERROR, message, module_name)
32
+ @logger.add(::Logger::ERROR, message.red, module_name)
32
33
  end
33
34
  end
34
35
  end
@@ -1,4 +1,5 @@
1
1
  require 'vump/modules/base_file_module'
2
+ require 'json'
2
3
 
3
4
  module Vump
4
5
  class PackageJson < BaseFileModule
@@ -11,14 +12,14 @@ module Vump
11
12
  end
12
13
 
13
14
  def select(contents)
14
- @parsed = JSON.parse(contents)
15
+ @parsed = ::JSON.parse(contents)
15
16
  @parsed['version']
16
17
  end
17
18
 
18
19
  def compose(_contents, version)
19
20
  json = @parsed.clone
20
21
  json['version'] = version
21
- JSON.pretty_generate(json) + "\n"
22
+ ::JSON.pretty_generate(json) + "\n"
22
23
  end
23
24
  end
24
25
  end
@@ -9,19 +9,23 @@ module Vump
9
9
  end
10
10
 
11
11
  def load(string)
12
- # <numeral>[-<sufix>]
13
- version, sufix = string
14
- .match(/([\d\.]+)(?:\-)?(.*)?/)
15
- .captures
16
- # <sufix>:= [<pre>][+<build>]
17
- @pre, @build = sufix.split('+', 2).map { |s| s.empty? ? false : s }
12
+ # <numeral>[-<pre>][+<build>]
13
+ version, @pre, @build = string
14
+ .match(/([\d\.]+)(?:\-)?([^\+]*)(?:\+)?(.*)?/)
15
+ .to_a
16
+ .drop(1)
18
17
  # <numeral>:= <major>.<minor>.<patch>
19
18
  @major, @minor, @patch = version
20
19
  .match(/(\d+)\.(\d+)\.(\d+)/)
21
- .captures
20
+ .to_a
21
+ .drop(1)
22
22
  .map(&:to_i)
23
23
  end
24
24
 
25
+ def valid?
26
+ [@major, @minor, @patch].all? { |v| v.is_a?(Numeric) }
27
+ end
28
+
25
29
  def reset(what)
26
30
  levels = %i[@build @pre @patch @minor @major]
27
31
  # tag to false, version to 0
@@ -59,8 +63,8 @@ module Vump
59
63
 
60
64
  def to_s
61
65
  str = "#{@major}.#{@minor}.#{@patch}"
62
- str << "-#{@pre}" if @pre
63
- str << "+#{@build}" if @build
66
+ str << "-#{@pre}" if @pre && @pre != ''
67
+ str << "+#{@build}" if @build && @build != ''
64
68
  str
65
69
  end
66
70
  end
@@ -50,11 +50,11 @@ module Vump
50
50
  def select_version(versions)
51
51
  @reporter.report_module_overview
52
52
  if versions.uniq.length > 1
53
- @logger.warn("Inconsitent version records: #{versions}")
53
+ @logger.error("Inconsitent version records: #{versions}")
54
54
  return false
55
55
  end
56
56
  @logger.info(
57
- "Single version extracted from all modules: #{versions.first}"
57
+ "Version extracted #{versions.first.yellow}"
58
58
  )
59
59
  versions.first
60
60
  end
@@ -64,7 +64,7 @@ module Vump
64
64
  mod.write(version)
65
65
  @logger.debug("Writing new version \"#{version}\"", mod.class)
66
66
  end
67
- @logger.info("All relevant modules written \"#{version}\"")
67
+ @logger.info("Relevant modules have written #{version.yellow}")
68
68
 
69
69
  if @git.loaded?
70
70
  commit(modules, version) unless @options[:no_git]
@@ -76,17 +76,30 @@ module Vump
76
76
  def commit(modules, version)
77
77
  files_to_stage = modules.map(&:to_stage).flatten
78
78
  @git.stage(files_to_stage)
79
- @git.tag(version) if @git.commit(version)
79
+ @git.tag("#{@options[:tag_prefix]}#{version}") if @git.commit(version)
80
80
  end
81
81
 
82
- def bump(arg = false, pre = false, build = false)
82
+ def compose_version(latest, arg, pre, build)
83
+ semver = Semver.new(latest)
84
+ semver.bump(arg) if arg
85
+ # if arg is string, overwrite
86
+ semver = Semver.new(arg) if arg.is_a?(String)
87
+ semver.pre = pre
88
+ semver.build = build
89
+ semver
90
+ end
91
+
92
+ def bump(arg = nil, pre = nil, build = nil)
83
93
  modules = load_modules
84
94
  version = select_version(read_versions(modules))
85
- semver = Semver.new(version)
86
- semver.bump(arg) if arg
87
- semver.pre = pre if pre
88
- semver.build = build if build
89
- write_versions(modules, semver.to_s)
95
+ return unless version
96
+
97
+ semver = compose_version(version, arg, pre, build)
98
+ if semver.valid?
99
+ write_versions(modules, semver.to_s)
100
+ else
101
+ @logger.error("Provided version #{arg} is not a valid semver string")
102
+ end
90
103
  end
91
104
 
92
105
  def help
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vump
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.pre.alpha.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jaroslav Šmolík
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-28 00:00:00.000000000 Z
11
+ date: 2019-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: command_line_reporter
@@ -205,11 +205,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
205
205
  version: '2.2'
206
206
  required_rubygems_version: !ruby/object:Gem::Requirement
207
207
  requirements:
208
- - - ">"
208
+ - - ">="
209
209
  - !ruby/object:Gem::Version
210
- version: 1.3.1
210
+ version: '0'
211
211
  requirements: []
212
- rubygems_version: 3.0.2
212
+ rubygems_version: 3.0.3
213
213
  signing_key:
214
214
  specification_version: 4
215
215
  summary: Raise version version in root of semver project.