incr 0.5.0 → 0.7.1
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 +4 -4
- data/Gemfile.lock +2 -2
- data/README.md +2 -3
- data/lib/incr/command/mix.rb +15 -4
- data/lib/incr/command/npm.rb +15 -4
- data/lib/incr/service/file_helper.rb +6 -2
- data/lib/incr/version.rb +1 -1
- metadata +7 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: beae18538716cd3443ecea4076ee9d05c0192c97cbbcf92e8c2b9e775b70bbf9
|
4
|
+
data.tar.gz: 8e02e3fe88c0b370bc48091efb75f15e0e288e8f11635bf7c036bc0d7b06ea81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75ebb280db2da0b09bcbb9f0e73fb806f05386af61ac2d76b8c907a256576e024b99b97844ffbf5a5d42a68857f647f071a92b587bd8cc43815e86e461a53fd0
|
7
|
+
data.tar.gz: f1a1d70c6159aafbec950b02220a4af567675d8c270c7dfc973c2a1a6da498af6e2163ce40d1607452b2f712205b4eaa1bb058f893489b80821d8ff85d34a7b5
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -6,8 +6,7 @@
|
|
6
6
|
Incr is a tool to help you easily increment the version number of your NPM or Mix packages.
|
7
7
|
<br /><br />
|
8
8
|
<a href="https://rubygems.org/gems/incr"><img src="http://img.shields.io/gem/v/incr.svg" /></a>
|
9
|
-
|
10
|
-
<a href="https://gemnasium.com/jcouture/incr"><img src="http://img.shields.io/gemnasium/jcouture/incr.svg" /></a>
|
9
|
+
|
11
10
|
<a href="https://travis-ci.org/jcouture/incr"><img src="http://img.shields.io/travis/jcouture/incr.svg" /></a>
|
12
11
|
</p>
|
13
12
|
|
@@ -51,7 +50,7 @@ Here are some arguments that can be used with `incr`:
|
|
51
50
|
|
52
51
|
Example:
|
53
52
|
```shell
|
54
|
-
~> incr --no-tag
|
53
|
+
~> incr --no-tag -d ./subprojects/web/ -t MyCustomTagPrefix/%s npm patch
|
55
54
|
```
|
56
55
|
|
57
56
|
This will :
|
data/lib/incr/command/mix.rb
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
module Incr
|
2
2
|
module Command
|
3
3
|
class Mix
|
4
|
+
VERSION_REGEX = /@?version:?\W*\"(\d*.\d*.\d*)"/
|
5
|
+
VERSION_REPLACEMENT_PATTERNS = [
|
6
|
+
"version: \"%s\"",
|
7
|
+
"@version \"%s\""
|
8
|
+
]
|
9
|
+
|
4
10
|
def initialize(args, global_options)
|
5
11
|
@segment = args[0]
|
6
12
|
@mix_file_filename = File.join('.', global_options[:versionFileDirectory], 'mix.exs')
|
@@ -15,10 +21,10 @@ module Incr
|
|
15
21
|
return
|
16
22
|
end
|
17
23
|
|
18
|
-
file_version = file_content.match(
|
24
|
+
file_version = file_content.match(VERSION_REGEX)[1]
|
19
25
|
old_version = SemVersion.new(file_version)
|
20
26
|
new_version = Incr::Service::Version.increment_segment(old_version, @segment)
|
21
|
-
|
27
|
+
replace_file_version(old_version, new_version)
|
22
28
|
|
23
29
|
new_tag = @tag_pattern % new_version.to_s
|
24
30
|
|
@@ -41,8 +47,13 @@ module Incr
|
|
41
47
|
IO.read(filename)
|
42
48
|
end
|
43
49
|
|
44
|
-
def
|
45
|
-
|
50
|
+
def replace_file_version(old_version, new_version)
|
51
|
+
VERSION_REPLACEMENT_PATTERNS.each do |pattern|
|
52
|
+
old_version_pattern = format(pattern, old_version.to_s)
|
53
|
+
new_version_pattern = format(pattern, new_version.to_s)
|
54
|
+
|
55
|
+
Incr::Service::FileHelper.replace_string_once(@mix_file_filename, old_version_pattern, new_version_pattern)
|
56
|
+
end
|
46
57
|
end
|
47
58
|
end
|
48
59
|
end
|
data/lib/incr/command/npm.rb
CHANGED
@@ -4,6 +4,14 @@ require 'sem_version'
|
|
4
4
|
module Incr
|
5
5
|
module Command
|
6
6
|
class Npm
|
7
|
+
# pattern for any semver version, including pre-release label (ie. 1.0.0-alpha)
|
8
|
+
VERSION_PATTERN = "[\\w\\.\\-]*"
|
9
|
+
|
10
|
+
# pattern preceding the version in package.json and package-lock.json (v1 and v2)
|
11
|
+
LOOKBEHIND_PATTERNS = [
|
12
|
+
"\\A{[^{}]*\"version\": \"\\K",
|
13
|
+
"\"\": {[^{}]*\"version\": \"\\K"
|
14
|
+
]
|
7
15
|
|
8
16
|
def initialize(args, global_options)
|
9
17
|
@segment = args[0]
|
@@ -25,8 +33,8 @@ module Incr
|
|
25
33
|
old_version = SemVersion.new(file_version)
|
26
34
|
new_version = Incr::Service::Version.increment_segment(old_version, @segment)
|
27
35
|
|
28
|
-
|
29
|
-
|
36
|
+
replace_file_version(@package_json_filename, new_version.to_s)
|
37
|
+
replace_file_version(@package_json_lock_filename, new_version.to_s)
|
30
38
|
|
31
39
|
new_tag = @tag_pattern % new_version.to_s
|
32
40
|
|
@@ -50,8 +58,11 @@ module Incr
|
|
50
58
|
JSON.parse(IO.read(filename))
|
51
59
|
end
|
52
60
|
|
53
|
-
def
|
54
|
-
|
61
|
+
def replace_file_version(filename, new_version)
|
62
|
+
LOOKBEHIND_PATTERNS.each do |lookbehind_pattern|
|
63
|
+
pattern = /#{lookbehind_pattern}#{VERSION_PATTERN}/
|
64
|
+
Incr::Service::FileHelper.replace_regexp_once(filename, pattern, new_version)
|
65
|
+
end
|
55
66
|
end
|
56
67
|
end
|
57
68
|
end
|
@@ -1,9 +1,13 @@
|
|
1
1
|
module Incr
|
2
2
|
module Service
|
3
3
|
class FileHelper
|
4
|
-
def self.
|
4
|
+
def self.replace_string_once(filename, old_text, new_text)
|
5
|
+
replace_regexp_once(filename, /#{Regexp.escape(old_text)}/, new_text)
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.replace_regexp_once(filename, pattern, replacement_text)
|
5
9
|
old_content = File.read(filename)
|
6
|
-
new_content = old_content.sub(
|
10
|
+
new_content = old_content.sub(pattern, replacement_text)
|
7
11
|
File.open(filename, 'w') { |file| file << new_content }
|
8
12
|
end
|
9
13
|
end
|
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.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jean-Philippe Couture
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gli
|
@@ -52,7 +52,7 @@ dependencies:
|
|
52
52
|
- - '='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 1.3.0
|
55
|
-
description:
|
55
|
+
description:
|
56
56
|
email:
|
57
57
|
- jcouture@gmail.com
|
58
58
|
executables:
|
@@ -79,7 +79,7 @@ homepage: https://github.com/jcouture/incr
|
|
79
79
|
licenses:
|
80
80
|
- MIT
|
81
81
|
metadata: {}
|
82
|
-
post_install_message:
|
82
|
+
post_install_message:
|
83
83
|
rdoc_options: []
|
84
84
|
require_paths:
|
85
85
|
- lib
|
@@ -95,9 +95,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
requirements: []
|
98
|
-
|
99
|
-
|
100
|
-
signing_key:
|
98
|
+
rubygems_version: 3.3.3
|
99
|
+
signing_key:
|
101
100
|
specification_version: 4
|
102
101
|
summary: Tasteful utility to increment the version number and create a corresponding
|
103
102
|
git tag.
|