incr 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +15 -0
- data/bin/incr +5 -2
- data/lib/incr/command/mix.rb +11 -9
- data/lib/incr/command/npm.rb +15 -11
- data/lib/incr/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 990244b97a22582412b854aeef90bd9ec4098a79
|
4
|
+
data.tar.gz: 91f01973dac745680d3c2a482e47c4baf39fbf7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: acbd123ad551512a014ce37772d7da580212b1fba0e0e1e5dd6784f56bda7d8845d976cd86a3488093ae57e9b51343b1e95765e4e7138f3fa72e9f9fdbd24473
|
7
|
+
data.tar.gz: 973123c4bc4d3210f82d3d2bd8e5c57e342d2eb461e98e2d4d21faf7cc5b4ccad6cb74d148433d88482ea3991ff770f5246350f2525f8ef5213230375c6037a5
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -42,6 +42,21 @@ To increment the minor segment of your Mix package version number:
|
|
42
42
|
~> incr mix minor
|
43
43
|
```
|
44
44
|
|
45
|
+
### Arguments
|
46
|
+
Here are some arguments that can be used with `incr`:
|
47
|
+
- `-d` : Directory where to search for the version files (default: `.`)
|
48
|
+
- `-t` : Tag name pattern, where `%s` will be replaced with the new version (default: `v%s`)
|
49
|
+
|
50
|
+
Example:
|
51
|
+
```shell
|
52
|
+
~> incr npm patch -d ./subprojects/web/ -t MyCustomTagPrefix/%s
|
53
|
+
```
|
54
|
+
|
55
|
+
This will :
|
56
|
+
- Search for `package.json` and `package-lock.json` files inside `./subprojects/web/` and update the patch version
|
57
|
+
- Create a tag named `MyCustomTagPrefix/2.3.4`
|
58
|
+
- Commit the changes under the message `MyCustomTagPrefix/2.3.4`
|
59
|
+
|
45
60
|
## Contributing
|
46
61
|
|
47
62
|
Bug reports and pull requests are welcome on GitHub at https://github.com/jcouture/incr. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
data/bin/incr
CHANGED
@@ -10,6 +10,9 @@ include GLI::App
|
|
10
10
|
program_desc('Tasteful utility to increment the version number and create a corresponding git tag.')
|
11
11
|
version(Incr::VERSION)
|
12
12
|
|
13
|
+
flag [:d, :versionFileDirectory], :default_value => '.', :desc => 'Directory where to search for version file.'
|
14
|
+
flag [:t, :tagNamePattern], :default_value => 'v%s'
|
15
|
+
|
13
16
|
pre do |global, command, options, args|
|
14
17
|
if args.length != 1 || !['major', 'minor', 'patch'].any? {|segment| args.include?(segment)}
|
15
18
|
STDERR.puts('Expecting a single argument: major, minor or patch.')
|
@@ -22,7 +25,7 @@ end
|
|
22
25
|
desc('Increment the version of your NPM package.')
|
23
26
|
command :npm do |cmd|
|
24
27
|
cmd.action do |global_options, options, args|
|
25
|
-
npm = Incr::Command::Npm.new(args)
|
28
|
+
npm = Incr::Command::Npm.new(args, global_options)
|
26
29
|
npm.execute
|
27
30
|
end
|
28
31
|
end
|
@@ -31,7 +34,7 @@ end
|
|
31
34
|
desc('Increment the version of your Mix package.')
|
32
35
|
command :mix do |cmd|
|
33
36
|
cmd.action do |global_options, options, args|
|
34
|
-
mix = Incr::Command::Mix.new(args)
|
37
|
+
mix = Incr::Command::Mix.new(args, global_options)
|
35
38
|
mix.execute
|
36
39
|
end
|
37
40
|
end
|
data/lib/incr/command/mix.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
module Incr
|
2
2
|
module Command
|
3
3
|
class Mix
|
4
|
-
|
5
|
-
|
6
|
-
def initialize(args)
|
4
|
+
def initialize(args, global_options)
|
7
5
|
@segment = args[0]
|
6
|
+
@mix_file_filename = File.join('.', global_options[:versionFileDirectory], 'mix.exs')
|
7
|
+
@tag_pattern = global_options[:tagNamePattern]
|
8
8
|
end
|
9
9
|
|
10
10
|
def execute
|
11
|
-
file_content = parse_content(
|
11
|
+
file_content = parse_content(@mix_file_filename)
|
12
12
|
if file_content == nil
|
13
13
|
return
|
14
14
|
end
|
@@ -16,14 +16,16 @@ module Incr
|
|
16
16
|
file_version = file_content.match(/version:\W*\"(\d*.\d*.\d*)",/)[1]
|
17
17
|
old_version = SemVersion.new(file_version)
|
18
18
|
new_version = Incr::Service::Version.increment_segment(old_version, @segment)
|
19
|
-
Incr::Service::FileHelper.replace_once(
|
19
|
+
Incr::Service::FileHelper.replace_once(@mix_file_filename, version_pattern(old_version.to_s), version_pattern(new_version.to_s))
|
20
|
+
|
21
|
+
new_tag = @tag_pattern % new_version.to_s
|
20
22
|
|
21
|
-
puts
|
23
|
+
puts new_tag
|
22
24
|
|
23
25
|
repository = Incr::Service::Repository.new('.')
|
24
|
-
repository.add(
|
25
|
-
repository.commit(
|
26
|
-
repository.tag(
|
26
|
+
repository.add(@mix_file_filename)
|
27
|
+
repository.commit(new_tag)
|
28
|
+
repository.tag(new_tag)
|
27
29
|
end
|
28
30
|
|
29
31
|
private
|
data/lib/incr/command/npm.rb
CHANGED
@@ -4,15 +4,17 @@ require 'sem_version'
|
|
4
4
|
module Incr
|
5
5
|
module Command
|
6
6
|
class Npm
|
7
|
-
PACKAGE_JSON_FILENAME = 'package.json'.freeze
|
8
|
-
PACKAGE_LOCK_JSON_FILENAME = 'package-lock.json'.freeze
|
9
7
|
|
10
|
-
def initialize(args)
|
8
|
+
def initialize(args, global_options)
|
11
9
|
@segment = args[0]
|
10
|
+
|
11
|
+
@package_json_filename = File.join('.', global_options[:versionFileDirectory], 'package.json')
|
12
|
+
@package_json_lock_filename = File.join('.', global_options[:versionFileDirectory], 'package-lock.json')
|
13
|
+
@tag_pattern = global_options[:tagNamePattern]
|
12
14
|
end
|
13
15
|
|
14
16
|
def execute
|
15
|
-
package_json = parse_content(
|
17
|
+
package_json = parse_content(@package_json_filename)
|
16
18
|
if package_json == nil
|
17
19
|
return
|
18
20
|
end
|
@@ -21,16 +23,18 @@ module Incr
|
|
21
23
|
old_version = SemVersion.new(file_version)
|
22
24
|
new_version = Incr::Service::Version.increment_segment(old_version, @segment)
|
23
25
|
|
24
|
-
Incr::Service::FileHelper.replace_once(
|
25
|
-
Incr::Service::FileHelper.replace_once(
|
26
|
+
Incr::Service::FileHelper.replace_once(@package_json_filename, version_pattern(old_version.to_s), version_pattern(new_version.to_s))
|
27
|
+
Incr::Service::FileHelper.replace_once(@package_json_lock_filename, version_pattern(old_version.to_s), version_pattern(new_version.to_s))
|
28
|
+
|
29
|
+
new_tag = @tag_pattern % new_version.to_s
|
26
30
|
|
27
|
-
puts
|
31
|
+
puts new_tag
|
28
32
|
|
29
33
|
repository = Incr::Service::Repository.new('.')
|
30
|
-
repository.add(
|
31
|
-
repository.add(
|
32
|
-
repository.commit(
|
33
|
-
repository.tag(
|
34
|
+
repository.add(@package_json_filename)
|
35
|
+
repository.add(@package_json_lock_filename)
|
36
|
+
repository.commit(new_tag)
|
37
|
+
repository.tag(new_tag)
|
34
38
|
end
|
35
39
|
|
36
40
|
private
|
data/lib/incr/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: incr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jean-Philippe Couture
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gli
|
@@ -96,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
96
|
version: '0'
|
97
97
|
requirements: []
|
98
98
|
rubyforge_project:
|
99
|
-
rubygems_version: 2.6.
|
99
|
+
rubygems_version: 2.6.13
|
100
100
|
signing_key:
|
101
101
|
specification_version: 4
|
102
102
|
summary: Tasteful utility to increment the version number and create a corresponding
|