incr 0.7.1 → 1.1.0
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/.github/dependabot.yml +6 -0
- data/.github/workflows/ci.yml +25 -0
- data/.github/workflows/gem-push.yml +39 -0
- data/.rspec +3 -0
- data/.rubocop.yml +8 -0
- data/.tool-versions +1 -0
- data/Gemfile.lock +61 -6
- data/README.md +12 -9
- data/Rakefile +9 -0
- data/bin/incr +14 -5
- data/incr.gemspec +9 -2
- data/lib/incr/command/laravel.rb +58 -0
- data/lib/incr/command/mix.rb +16 -17
- data/lib/incr/command/npm.rb +23 -19
- data/lib/incr/service/file_helper.rb +1 -5
- data/lib/incr/service/repository.rb +1 -1
- data/lib/incr/version.rb +1 -1
- data/lib/incr.rb +1 -0
- data/spec/fixtures/laravel/app.php +6 -0
- data/spec/fixtures/mix/mix.exs +30 -0
- data/spec/fixtures/npmv6/package-lock.json +13 -0
- data/spec/fixtures/npmv6/package.json +7 -0
- data/spec/fixtures/npmv7/package-lock.json +30 -0
- data/spec/fixtures/npmv7/package.json +7 -0
- data/spec/incr/command/laravel_spec.rb +76 -0
- data/spec/incr/command/mix_spec.rb +97 -0
- data/spec/incr/command/npm_spec.rb +197 -0
- data/spec/incr/service/file_helper_spec.rb +72 -0
- data/spec/incr/service/version_spec.rb +53 -0
- data/spec/spec_helper.rb +122 -0
- metadata +88 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f794ed99e6baff884b2fdd079ae1334033be211256cd9503454be27370d9833
|
4
|
+
data.tar.gz: f1e68068b5466c44aad7203846cb25c009101282565debe53129e684a8c2dd22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aeb104c81ddd8ec4894a510bc848972cd96bb6e58ab4e533a61adec1de7dfa2c8dd86dc3d6a3ba89601c36a9ef994391223612040b72e7825691fd2b2c0269dd
|
7
|
+
data.tar.gz: ca773d11bc8758a98ead0cb9f43278f2c6923992c7ba9c33920aa68aa9bdbef1b473bc8e153a5592bb0d149215875747c6da8c3c9f0be8827179798e0e3713a1
|
@@ -0,0 +1,25 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- main
|
7
|
+
pull_request:
|
8
|
+
branches:
|
9
|
+
- '**'
|
10
|
+
|
11
|
+
permissions:
|
12
|
+
contents: read
|
13
|
+
|
14
|
+
jobs:
|
15
|
+
ci:
|
16
|
+
runs-on: ubuntu-22.04
|
17
|
+
|
18
|
+
steps:
|
19
|
+
- uses: actions/checkout@v3
|
20
|
+
- uses: ruby/setup-ruby@v1
|
21
|
+
with:
|
22
|
+
ruby-version: .tool-versions
|
23
|
+
bundler-cache: true
|
24
|
+
|
25
|
+
- run: bundle exec rake
|
@@ -0,0 +1,39 @@
|
|
1
|
+
name: Publish RubyGem
|
2
|
+
|
3
|
+
on: workflow_dispatch
|
4
|
+
|
5
|
+
permissions:
|
6
|
+
contents: read
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
test:
|
10
|
+
runs-on: ubuntu-22.04
|
11
|
+
|
12
|
+
steps:
|
13
|
+
- uses: actions/checkout@v3
|
14
|
+
- uses: ruby/setup-ruby@v1
|
15
|
+
with:
|
16
|
+
ruby-version: '2.7'
|
17
|
+
bundler-cache: true
|
18
|
+
|
19
|
+
- run: bundle exec rake
|
20
|
+
|
21
|
+
publish:
|
22
|
+
runs-on: ubuntu-22.04
|
23
|
+
|
24
|
+
steps:
|
25
|
+
- uses: actions/checkout@v3
|
26
|
+
- uses: ruby/setup-ruby@v1
|
27
|
+
with:
|
28
|
+
ruby-version: '2.7'
|
29
|
+
bundler-cache: true
|
30
|
+
|
31
|
+
- run: |
|
32
|
+
mkdir -p $HOME/.gem
|
33
|
+
touch $HOME/.gem/credentials
|
34
|
+
chmod 0600 $HOME/.gem/credentials
|
35
|
+
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
36
|
+
gem build *.gemspec
|
37
|
+
gem push *.gem
|
38
|
+
env:
|
39
|
+
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 3.2.2
|
data/Gemfile.lock
CHANGED
@@ -1,23 +1,78 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
incr (0.
|
5
|
-
git (= 1.
|
6
|
-
gli (= 2.
|
4
|
+
incr (1.0.0)
|
5
|
+
git (= 1.19.1)
|
6
|
+
gli (= 2.21.1)
|
7
7
|
sem_version (= 2.0.1)
|
8
8
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
|
13
|
-
|
12
|
+
addressable (2.8.6)
|
13
|
+
public_suffix (>= 2.0.2, < 6.0)
|
14
|
+
ast (2.4.2)
|
15
|
+
diff-lcs (1.5.1)
|
16
|
+
git (1.19.1)
|
17
|
+
addressable (~> 2.8)
|
18
|
+
rchardet (~> 1.8)
|
19
|
+
gli (2.21.1)
|
20
|
+
json (2.7.2)
|
21
|
+
language_server-protocol (3.17.0.3)
|
22
|
+
meowcop (3.2.0)
|
23
|
+
rubocop (>= 1.13.0, < 2.0.0)
|
24
|
+
parallel (1.24.0)
|
25
|
+
parser (3.3.1.0)
|
26
|
+
ast (~> 2.4.1)
|
27
|
+
racc
|
28
|
+
public_suffix (5.0.5)
|
29
|
+
racc (1.8.0)
|
30
|
+
rainbow (3.1.1)
|
31
|
+
rake (13.2.1)
|
32
|
+
rchardet (1.8.0)
|
33
|
+
regexp_parser (2.9.2)
|
34
|
+
rexml (3.2.8)
|
35
|
+
strscan (>= 3.0.9)
|
36
|
+
rspec (3.13.0)
|
37
|
+
rspec-core (~> 3.13.0)
|
38
|
+
rspec-expectations (~> 3.13.0)
|
39
|
+
rspec-mocks (~> 3.13.0)
|
40
|
+
rspec-core (3.13.0)
|
41
|
+
rspec-support (~> 3.13.0)
|
42
|
+
rspec-expectations (3.13.0)
|
43
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
44
|
+
rspec-support (~> 3.13.0)
|
45
|
+
rspec-mocks (3.13.1)
|
46
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
47
|
+
rspec-support (~> 3.13.0)
|
48
|
+
rspec-support (3.13.1)
|
49
|
+
rubocop (1.63.5)
|
50
|
+
json (~> 2.3)
|
51
|
+
language_server-protocol (>= 3.17.0)
|
52
|
+
parallel (~> 1.10)
|
53
|
+
parser (>= 3.3.0.2)
|
54
|
+
rainbow (>= 2.2.2, < 4.0)
|
55
|
+
regexp_parser (>= 1.8, < 3.0)
|
56
|
+
rexml (>= 3.2.5, < 4.0)
|
57
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
58
|
+
ruby-progressbar (~> 1.7)
|
59
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
60
|
+
rubocop-ast (1.31.3)
|
61
|
+
parser (>= 3.3.1.0)
|
62
|
+
ruby-progressbar (1.13.0)
|
14
63
|
sem_version (2.0.1)
|
64
|
+
strscan (3.1.0)
|
65
|
+
unicode-display_width (2.5.0)
|
15
66
|
|
16
67
|
PLATFORMS
|
17
68
|
ruby
|
18
69
|
|
19
70
|
DEPENDENCIES
|
20
71
|
incr!
|
72
|
+
meowcop (= 3.2.0)
|
73
|
+
rake (= 13.2.1)
|
74
|
+
rspec (= 3.13.0)
|
75
|
+
rubocop (= 1.63.5)
|
21
76
|
|
22
77
|
BUNDLED WITH
|
23
|
-
|
78
|
+
2.4.21
|
data/README.md
CHANGED
@@ -1,13 +1,11 @@
|
|
1
1
|
<p align="center">
|
2
2
|
<a href="https://github.com/jcouture/incr">
|
3
|
-
<img src="https://
|
3
|
+
<img src="https://user-images.githubusercontent.com/5007/160249855-dc0eb32f-f77d-4c5a-a995-93ac46408a68.png" alt="incr" />
|
4
4
|
</a>
|
5
5
|
<br />
|
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://travis-ci.org/jcouture/incr"><img src="http://img.shields.io/travis/jcouture/incr.svg" /></a>
|
11
9
|
</p>
|
12
10
|
|
13
11
|
## What does `incr` do?
|
@@ -19,7 +17,7 @@ The process is detailed as follow:
|
|
19
17
|
* Increment the specified segment. If you increment the minor segment, the patch segment is set to 0 and the same goes for the major segment, the minor and patch segments are set to 0.
|
20
18
|
* Write the newly incremented version number in the relevant file(s).
|
21
19
|
* Create a new `git commit` with the relevant file with the version number as the default message (e.g.: 0.2.1).
|
22
|
-
* Create a new `git tag` pointing to the new `git commit` with the version number prefixed by a 'v' as the name (e.g.: v0.2.1).
|
20
|
+
* Create a new annotated `git tag` pointing to the new `git commit` with the version number prefixed by a 'v' as the name (e.g.: v0.2.1).
|
23
21
|
* 💥
|
24
22
|
|
25
23
|
## Installation
|
@@ -31,31 +29,38 @@ The process is detailed as follow:
|
|
31
29
|
```
|
32
30
|
|
33
31
|
## Usage
|
32
|
+
|
34
33
|
To increment the patch segment of your NPM package version number:
|
34
|
+
|
35
35
|
```shell
|
36
36
|
~> incr npm patch
|
37
37
|
```
|
38
38
|
|
39
39
|
To increment the minor segment of your Mix package version number:
|
40
|
+
|
40
41
|
```shell
|
41
42
|
~> incr mix minor
|
42
43
|
```
|
43
44
|
|
44
45
|
### Arguments
|
46
|
+
|
45
47
|
Here are some arguments that can be used with `incr`:
|
48
|
+
|
46
49
|
- `-d` : Directory where to search for the version files (default: `.`)
|
47
50
|
- `-t` : Tag name pattern, where `%s` will be replaced with the new version (default: `v%s`)
|
48
51
|
- `--[no-]commit` : Commit changes. (default: enabled)
|
49
52
|
- `--[no-]tag` : Create a git tag. (default: enabled)
|
50
53
|
|
51
54
|
Example:
|
55
|
+
|
52
56
|
```shell
|
53
|
-
~> incr --no-tag -d ./subprojects/web/ -t
|
57
|
+
~> incr --no-tag -d ./subprojects/web/ -t my-custom-tag-prefix/%s npm patch
|
54
58
|
```
|
55
59
|
|
56
60
|
This will :
|
61
|
+
|
57
62
|
- Search for `package.json` and `package-lock.json` files inside `./subprojects/web/` and update the patch version
|
58
|
-
- Commit the changes under the message `
|
63
|
+
- Commit the changes under the message `my-custom-tag-prefix/2.3.4`
|
59
64
|
- Not create a tag with the new version
|
60
65
|
|
61
66
|
## Contributing
|
@@ -65,5 +70,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/jcoutu
|
|
65
70
|
## License
|
66
71
|
|
67
72
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
68
|
-
|
69
|
-
The incr shield logo is based on [this icon](https://thenounproject.com/term/increment/621415/) by [blackspike](https://thenounproject.com/blackspike/), from the Noun Project. Used under a [Creative Commons BY 3.0](http://creativecommons.org/licenses/by/3.0/) license.
|
data/Rakefile
ADDED
data/bin/incr
CHANGED
@@ -10,15 +10,15 @@ 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
|
14
|
-
flag
|
13
|
+
flag([:d, :version_file_dir], default_value: '.', desc: 'Directory where to search for version file')
|
14
|
+
flag([:t, :tag_name_pattern], default_value: 'v%s', desc: 'Pattern for the tag name')
|
15
15
|
|
16
|
-
switch
|
17
|
-
switch
|
16
|
+
switch(:commit, default_value: true, desc: 'Commit changes')
|
17
|
+
switch(:tag, default_value: true, desc: 'Create a git tag')
|
18
18
|
|
19
19
|
pre do |global, command, options, args|
|
20
20
|
if args.length != 1 || !['major', 'minor', 'patch'].any? {|segment| args.include?(segment)}
|
21
|
-
|
21
|
+
warn('expecting a single argument: major, minor or patch.')
|
22
22
|
return false
|
23
23
|
end
|
24
24
|
true
|
@@ -42,4 +42,13 @@ command :mix do |cmd|
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
+
# Laravel Support
|
46
|
+
desc('Increment the version of your config/app.php.')
|
47
|
+
command :laravel do |cmd|
|
48
|
+
cmd.action do |global_options, options, args|
|
49
|
+
mix = Incr::Command::Laravel.new(args, global_options)
|
50
|
+
mix.execute
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
45
54
|
exit(run(ARGV))
|
data/incr.gemspec
CHANGED
@@ -18,7 +18,14 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.executables << 'incr'
|
19
19
|
spec.require_paths << 'lib'
|
20
20
|
|
21
|
-
spec.
|
21
|
+
spec.required_ruby_version = '>= 3.2'
|
22
|
+
|
23
|
+
spec.add_runtime_dependency('gli', '2.21.1')
|
22
24
|
spec.add_runtime_dependency('sem_version', '2.0.1')
|
23
|
-
spec.add_runtime_dependency('git', '1.
|
25
|
+
spec.add_runtime_dependency('git', '1.19.1')
|
26
|
+
|
27
|
+
spec.add_development_dependency('rake', '13.2.1')
|
28
|
+
spec.add_development_dependency('rspec', '3.13.0')
|
29
|
+
spec.add_development_dependency('rubocop', '1.63.5')
|
30
|
+
spec.add_development_dependency('meowcop', '3.2.0')
|
24
31
|
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module Incr
|
2
|
+
module Command
|
3
|
+
class Laravel
|
4
|
+
VERSION_REGEX = /'version' => '(\d*.\d*.\d*)'/
|
5
|
+
VERSION_REPLACEMENT_PATTERNS = [
|
6
|
+
"'version' => '%s",
|
7
|
+
]
|
8
|
+
|
9
|
+
def initialize(args, global_options)
|
10
|
+
@segment = args[0]
|
11
|
+
@config_file_filename = File.join('.', global_options[:version_file_dir], 'config', 'app.php')
|
12
|
+
@tag_pattern = global_options[:tag_name_pattern]
|
13
|
+
@commit = global_options[:commit]
|
14
|
+
@tag = global_options[:tag]
|
15
|
+
@noop = global_options[:noop]
|
16
|
+
end
|
17
|
+
|
18
|
+
def execute
|
19
|
+
if !File.exist?(@config_file_filename)
|
20
|
+
warn("'#{@config_file_filename}': file not found.")
|
21
|
+
return
|
22
|
+
end
|
23
|
+
|
24
|
+
file_content = IO.read(@config_file_filename)
|
25
|
+
if file_content == nil
|
26
|
+
return
|
27
|
+
end
|
28
|
+
|
29
|
+
file_version = file_content.match(VERSION_REGEX)[1]
|
30
|
+
old_version = SemVersion.new(file_version)
|
31
|
+
new_version = Incr::Service::Version.increment_segment(old_version, @segment)
|
32
|
+
replace_file_version(old_version, new_version)
|
33
|
+
|
34
|
+
new_tag = @tag_pattern % new_version.to_s
|
35
|
+
|
36
|
+
puts new_tag
|
37
|
+
|
38
|
+
if not @noop
|
39
|
+
repository = Incr::Service::Repository.new('.')
|
40
|
+
repository.add(@config_file_filename)
|
41
|
+
repository.commit(new_tag) if @commit
|
42
|
+
repository.tag(new_tag) if @tag
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def replace_file_version(old_version, new_version)
|
49
|
+
VERSION_REPLACEMENT_PATTERNS.each do |pattern|
|
50
|
+
old_version_pattern = format(pattern, old_version.to_s)
|
51
|
+
new_version_pattern = format(pattern, new_version.to_s)
|
52
|
+
|
53
|
+
Incr::Service::FileHelper.replace(@config_file_filename, old_version_pattern, new_version_pattern)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
data/lib/incr/command/mix.rb
CHANGED
@@ -9,14 +9,20 @@ module Incr
|
|
9
9
|
|
10
10
|
def initialize(args, global_options)
|
11
11
|
@segment = args[0]
|
12
|
-
@mix_file_filename = File.join('.', global_options[:
|
13
|
-
@tag_pattern = global_options[:
|
12
|
+
@mix_file_filename = File.join('.', global_options[:version_file_dir], 'mix.exs')
|
13
|
+
@tag_pattern = global_options[:tag_name_pattern]
|
14
14
|
@commit = global_options[:commit]
|
15
15
|
@tag = global_options[:tag]
|
16
|
+
@noop = global_options[:noop]
|
16
17
|
end
|
17
18
|
|
18
19
|
def execute
|
19
|
-
|
20
|
+
if !File.exist?(@mix_file_filename)
|
21
|
+
warn("'#{@mix_file_filename}': file not found.")
|
22
|
+
return
|
23
|
+
end
|
24
|
+
|
25
|
+
file_content = IO.read(@mix_file_filename)
|
20
26
|
if file_content == nil
|
21
27
|
return
|
22
28
|
end
|
@@ -30,29 +36,22 @@ module Incr
|
|
30
36
|
|
31
37
|
puts new_tag
|
32
38
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
39
|
+
if not @noop
|
40
|
+
repository = Incr::Service::Repository.new('.')
|
41
|
+
repository.add(@mix_file_filename)
|
42
|
+
repository.commit(new_tag) if @commit
|
43
|
+
repository.tag(new_tag) if @tag
|
44
|
+
end
|
37
45
|
end
|
38
46
|
|
39
47
|
private
|
40
48
|
|
41
|
-
def parse_content(filename)
|
42
|
-
if !File.exist?(filename)
|
43
|
-
STDERR.puts("[Err] '#{filename}' not found.")
|
44
|
-
return nil
|
45
|
-
end
|
46
|
-
|
47
|
-
IO.read(filename)
|
48
|
-
end
|
49
|
-
|
50
49
|
def replace_file_version(old_version, new_version)
|
51
50
|
VERSION_REPLACEMENT_PATTERNS.each do |pattern|
|
52
51
|
old_version_pattern = format(pattern, old_version.to_s)
|
53
52
|
new_version_pattern = format(pattern, new_version.to_s)
|
54
53
|
|
55
|
-
Incr::Service::FileHelper.
|
54
|
+
Incr::Service::FileHelper.replace(@mix_file_filename, old_version_pattern, new_version_pattern)
|
56
55
|
end
|
57
56
|
end
|
58
57
|
end
|
data/lib/incr/command/npm.rb
CHANGED
@@ -16,15 +16,26 @@ module Incr
|
|
16
16
|
def initialize(args, global_options)
|
17
17
|
@segment = args[0]
|
18
18
|
|
19
|
-
@package_json_filename = File.join('.', global_options[:
|
20
|
-
@package_json_lock_filename = File.join('.', global_options[:
|
21
|
-
@tag_pattern = global_options[:
|
19
|
+
@package_json_filename = File.join('.', global_options[:version_file_dir], 'package.json')
|
20
|
+
@package_json_lock_filename = File.join('.', global_options[:version_file_dir], 'package-lock.json')
|
21
|
+
@tag_pattern = global_options[:tag_name_pattern]
|
22
22
|
@commit = global_options[:commit]
|
23
23
|
@tag = global_options[:tag]
|
24
|
+
@noop = global_options[:noop]
|
24
25
|
end
|
25
26
|
|
26
27
|
def execute
|
27
|
-
|
28
|
+
if !File.exist?(@package_json_filename)
|
29
|
+
warn("'#{@package_json_filename}': file not found.")
|
30
|
+
return
|
31
|
+
end
|
32
|
+
|
33
|
+
if !File.exist?(@package_json_lock_filename)
|
34
|
+
warn("'#{@package_json_lock_filename}': file not found.")
|
35
|
+
return
|
36
|
+
end
|
37
|
+
|
38
|
+
package_json = JSON.parse(IO.read(@package_json_filename))
|
28
39
|
if package_json == nil
|
29
40
|
return
|
30
41
|
end
|
@@ -40,28 +51,21 @@ module Incr
|
|
40
51
|
|
41
52
|
puts new_tag
|
42
53
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
54
|
+
if not @noop
|
55
|
+
repository = Incr::Service::Repository.new('.')
|
56
|
+
repository.add(@package_json_filename)
|
57
|
+
repository.add(@package_json_lock_filename)
|
58
|
+
repository.commit(new_tag) if @commit
|
59
|
+
repository.tag(new_tag) if @tag
|
60
|
+
end
|
48
61
|
end
|
49
62
|
|
50
63
|
private
|
51
64
|
|
52
|
-
def parse_content(filename)
|
53
|
-
if !File.exist?(filename)
|
54
|
-
STDERR.puts("[Err] '#{filename}' not found.")
|
55
|
-
return nil
|
56
|
-
end
|
57
|
-
|
58
|
-
JSON.parse(IO.read(filename))
|
59
|
-
end
|
60
|
-
|
61
65
|
def replace_file_version(filename, new_version)
|
62
66
|
LOOKBEHIND_PATTERNS.each do |lookbehind_pattern|
|
63
67
|
pattern = /#{lookbehind_pattern}#{VERSION_PATTERN}/
|
64
|
-
Incr::Service::FileHelper.
|
68
|
+
Incr::Service::FileHelper.replace(filename, pattern, new_version)
|
65
69
|
end
|
66
70
|
end
|
67
71
|
end
|
@@ -1,11 +1,7 @@
|
|
1
1
|
module Incr
|
2
2
|
module Service
|
3
3
|
class FileHelper
|
4
|
-
def self.
|
5
|
-
replace_regexp_once(filename, /#{Regexp.escape(old_text)}/, new_text)
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.replace_regexp_once(filename, pattern, replacement_text)
|
4
|
+
def self.replace(filename, pattern, replacement_text)
|
9
5
|
old_content = File.read(filename)
|
10
6
|
new_content = old_content.sub(pattern, replacement_text)
|
11
7
|
File.open(filename, 'w') { |file| file << new_content }
|
data/lib/incr/version.rb
CHANGED
data/lib/incr.rb
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
defmodule Foobar.MixProject do
|
2
|
+
use Mix.Project
|
3
|
+
|
4
|
+
@version "1.0.0"
|
5
|
+
|
6
|
+
def project do
|
7
|
+
[
|
8
|
+
app: :foobar,
|
9
|
+
version: @version,
|
10
|
+
elixir: "~> 1.13",
|
11
|
+
start_permanent: Mix.env() == :prod,
|
12
|
+
deps: deps()
|
13
|
+
]
|
14
|
+
end
|
15
|
+
|
16
|
+
# Run "mix help compile.app" to learn about applications.
|
17
|
+
def application do
|
18
|
+
[
|
19
|
+
extra_applications: [:logger]
|
20
|
+
]
|
21
|
+
end
|
22
|
+
|
23
|
+
# Run "mix help deps" to learn about dependencies.
|
24
|
+
defp deps do
|
25
|
+
[
|
26
|
+
# {:dep_from_hexpm, "~> 0.3.0"},
|
27
|
+
# {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"}
|
28
|
+
]
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
{
|
2
|
+
"name": "foobar",
|
3
|
+
"version": "7.0.0",
|
4
|
+
"lockfileVersion": 1,
|
5
|
+
"requires": true,
|
6
|
+
"dependencies": {
|
7
|
+
"is-number": {
|
8
|
+
"version": "7.0.0",
|
9
|
+
"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
|
10
|
+
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng=="
|
11
|
+
}
|
12
|
+
}
|
13
|
+
}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
{
|
2
|
+
"name": "foobar",
|
3
|
+
"version": "7.0.0",
|
4
|
+
"lockfileVersion": 2,
|
5
|
+
"requires": true,
|
6
|
+
"packages": {
|
7
|
+
"": {
|
8
|
+
"name": "foobar",
|
9
|
+
"version": "7.0.0",
|
10
|
+
"dependencies": {
|
11
|
+
"is-number": "^7.0.0"
|
12
|
+
}
|
13
|
+
},
|
14
|
+
"node_modules/is-number": {
|
15
|
+
"version": "7.0.0",
|
16
|
+
"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
|
17
|
+
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
|
18
|
+
"engines": {
|
19
|
+
"node": ">=0.12.0"
|
20
|
+
}
|
21
|
+
}
|
22
|
+
},
|
23
|
+
"dependencies": {
|
24
|
+
"is-number": {
|
25
|
+
"version": "7.0.0",
|
26
|
+
"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
|
27
|
+
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng=="
|
28
|
+
}
|
29
|
+
}
|
30
|
+
}
|