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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ddf50651ee57b760d253bb3e7d275d8bd382636d
4
- data.tar.gz: 4461847a7d0f909d2be997f825606211b7b5328b
3
+ metadata.gz: 990244b97a22582412b854aeef90bd9ec4098a79
4
+ data.tar.gz: 91f01973dac745680d3c2a482e47c4baf39fbf7c
5
5
  SHA512:
6
- metadata.gz: cc0ad79e813e7fae4bb8e91f151bae7cf07187e533e3eb612c71ad5a258f59c067cd493f5eecac84153b52724a05ad9101cfd104229ac7010ae6e357f7064c27
7
- data.tar.gz: 6a17f0eaba6a2233e182ed14412e628447aa19db2bffe268d3b2fcb876ba19d843458866aeb5e5366eff0afacc9b64d8e8ebd95842a26bb163ef6bad5b20d590
6
+ metadata.gz: acbd123ad551512a014ce37772d7da580212b1fba0e0e1e5dd6784f56bda7d8845d976cd86a3488093ae57e9b51343b1e95765e4e7138f3fa72e9f9fdbd24473
7
+ data.tar.gz: 973123c4bc4d3210f82d3d2bd8e5c57e342d2eb461e98e2d4d21faf7cc5b4ccad6cb74d148433d88482ea3991ff770f5246350f2525f8ef5213230375c6037a5
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- incr (0.3.0)
4
+ incr (0.4.0)
5
5
  git (= 1.3.0)
6
6
  gli (= 2.17.1)
7
7
  sem_version (= 2.0.1)
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
@@ -1,14 +1,14 @@
1
1
  module Incr
2
2
  module Command
3
3
  class Mix
4
- MIXFILE_FILENAME = 'mix.exs'.freeze
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(MIXFILE_FILENAME)
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(MIXFILE_FILENAME, version_pattern(old_version.to_s), version_pattern(new_version.to_s))
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 "v#{new_version.to_s}"
23
+ puts new_tag
22
24
 
23
25
  repository = Incr::Service::Repository.new('.')
24
- repository.add(MIXFILE_FILENAME)
25
- repository.commit(new_version.to_s)
26
- repository.tag("v#{new_version.to_s}")
26
+ repository.add(@mix_file_filename)
27
+ repository.commit(new_tag)
28
+ repository.tag(new_tag)
27
29
  end
28
30
 
29
31
  private
@@ -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(PACKAGE_JSON_FILENAME)
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(PACKAGE_JSON_FILENAME, version_pattern(old_version.to_s), version_pattern(new_version.to_s))
25
- Incr::Service::FileHelper.replace_once(PACKAGE_LOCK_JSON_FILENAME, version_pattern(old_version.to_s), version_pattern(new_version.to_s))
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 "v#{new_version.to_s}"
31
+ puts new_tag
28
32
 
29
33
  repository = Incr::Service::Repository.new('.')
30
- repository.add(PACKAGE_JSON_FILENAME)
31
- repository.add(PACKAGE_LOCK_JSON_FILENAME)
32
- repository.commit(new_version.to_s)
33
- repository.tag("v#{new_version.to_s}")
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
@@ -1,3 +1,3 @@
1
1
  module Incr
2
- VERSION = '0.3.0'
2
+ VERSION = '0.4.0'
3
3
  end
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.3.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-03-09 00:00:00.000000000 Z
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.14
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