avm-eac_ruby_base1 0.20.1 → 0.22.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/lib/avm/eac_ruby_base1/runners/base/lib_rename.rb +77 -0
- data/lib/avm/eac_ruby_base1/sources/namespace_replacer.rb +55 -0
- data/lib/avm/eac_ruby_base1/sources/runners/bundler/gemfile_local.rb +21 -4
- data/lib/avm/eac_ruby_base1/sources/runners/bundler/gemfile_lock/git.rb +60 -0
- data/lib/avm/eac_ruby_base1/sources/runners/bundler/gemfile_lock.rb +89 -0
- data/lib/avm/eac_ruby_base1/sources/runners/update_dependencies_requirements.rb +21 -7
- data/lib/avm/eac_ruby_base1/version.rb +1 -1
- metadata +10 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3dbe022e931d72a6273d17350c232661bb943b57a7b69f432e43fba5083088cf
|
4
|
+
data.tar.gz: 6315d5afaff312e6a410e1f06cfa13f064e1f2a571c4e4d8362d1622154aa378
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d005ee107b7eadcfd496e76ec2a88afeefdba7443f819d9a8b3d2f96c3d27d37bacde960ce9e44055dc847cfc1a68df457b161a6a407d14db0d4109cf5d3bc58
|
7
|
+
data.tar.gz: 228237474272dbc10f48062e96fa9adafce13709607d32e36d4fe195ce04456bce87fcf476d8693b74b5df73817dd5e35da0f644b9d96cf73ef7eb5b81f74ce6
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_cli/core_ext'
|
4
|
+
require 'avm/eac_ruby_base1/sources/namespace_replacer'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
module EacRubyBase1
|
8
|
+
module Runners
|
9
|
+
class Base
|
10
|
+
class LibRename
|
11
|
+
runner_with :help, :file_replacer do
|
12
|
+
desc 'Rename Ruby modules classes Ruby.'
|
13
|
+
arg_opt '-f', '--from', 'Rename "from".'
|
14
|
+
arg_opt '-t', '--to', 'Rename "to".'
|
15
|
+
end
|
16
|
+
|
17
|
+
def run
|
18
|
+
start_banner
|
19
|
+
validate
|
20
|
+
replacements_banner
|
21
|
+
run_filesystem_traverser
|
22
|
+
success 'Done!'
|
23
|
+
end
|
24
|
+
|
25
|
+
def validate
|
26
|
+
%w[from to].each do |opt|
|
27
|
+
fatal_error "No \"#{opt}\" option" if send(opt).blank?
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def start_banner
|
32
|
+
infov 'From', from
|
33
|
+
infov 'To', to
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def namespace_replacer_uncached
|
39
|
+
::Avm::EacRubyBase1::Sources::NamespaceReplacer.new(from, to)
|
40
|
+
end
|
41
|
+
|
42
|
+
def text_replacer
|
43
|
+
@text_replacer ||= super.gsub(from, to).gsub(from_path, to_path)
|
44
|
+
.gsub(namespace_replacer.from_result, namespace_replacer.to_result)
|
45
|
+
end
|
46
|
+
|
47
|
+
def replace_file?(file)
|
48
|
+
file.extname == '.rb'
|
49
|
+
end
|
50
|
+
|
51
|
+
def replacements_banner
|
52
|
+
infov 'Replacements', text_replacer.replacements.count
|
53
|
+
text_replacer.replacements.each do |rep|
|
54
|
+
infov ' * ', rep
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def from
|
59
|
+
parsed.from.to_s
|
60
|
+
end
|
61
|
+
|
62
|
+
def to
|
63
|
+
parsed.to.to_s
|
64
|
+
end
|
65
|
+
|
66
|
+
def from_path
|
67
|
+
from.underscore
|
68
|
+
end
|
69
|
+
|
70
|
+
def to_path
|
71
|
+
to.underscore
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Avm
|
4
|
+
module EacRubyBase1
|
5
|
+
module Sources
|
6
|
+
class NamespaceReplacer
|
7
|
+
common_constructor :from, :to
|
8
|
+
|
9
|
+
def concat_regex(regexes)
|
10
|
+
r = regexes.first
|
11
|
+
regexes[1..-1].each do |x|
|
12
|
+
r = ::Regexp.new(r.source + x.source)
|
13
|
+
end
|
14
|
+
r
|
15
|
+
end
|
16
|
+
|
17
|
+
def from_result
|
18
|
+
/\n#{from_open.source}(.+)#{from_close.source}/m
|
19
|
+
end
|
20
|
+
|
21
|
+
def from_open
|
22
|
+
concat_regex(from.split('::')
|
23
|
+
.map { |v| / *(?:class|module) +#{::Regexp.quote(v)} *\n/m })
|
24
|
+
end
|
25
|
+
|
26
|
+
def from_close
|
27
|
+
concat_regex(from.split('::').count.times.map { / *end *\n/m })
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_result
|
31
|
+
"\n\n#{to_open}\\1#{to_close}"
|
32
|
+
end
|
33
|
+
|
34
|
+
def to_open
|
35
|
+
s = ''
|
36
|
+
to.split('::').each_with_index do |part, index|
|
37
|
+
s += (' ' * index) + "module #{part}\n"
|
38
|
+
end
|
39
|
+
s
|
40
|
+
end
|
41
|
+
|
42
|
+
def to_close
|
43
|
+
parts = to.split('::')
|
44
|
+
s = ''
|
45
|
+
parts.each_with_index do |_part, index|
|
46
|
+
tabc = (parts.count - 1 - index)
|
47
|
+
tabc -= 1 if index.zero?
|
48
|
+
s += (' ' * tabc) + "end\n"
|
49
|
+
end
|
50
|
+
s
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -29,17 +29,34 @@ module Avm
|
|
29
29
|
siblings.map { |s| sibling_gemfile_local_line(s) }.join
|
30
30
|
end
|
31
31
|
|
32
|
+
def on_unexisting_gemfile_local
|
33
|
+
return yield unless gemfile_local_path.exist?
|
34
|
+
|
35
|
+
::EacRubyUtils::Fs::Temp.on_file do |temp_file|
|
36
|
+
::FileUtils.cp(gemfile_local_path, temp_file)
|
37
|
+
begin
|
38
|
+
::FileUtils.rm_f(gemfile_local_path)
|
39
|
+
yield
|
40
|
+
ensure
|
41
|
+
::FileUtils.cp(temp_file, gemfile_local_path)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
32
46
|
def run_bundle
|
33
|
-
|
34
|
-
|
35
|
-
|
47
|
+
on_unexisting_gemfile_local do
|
48
|
+
the_source.bundle.execute!
|
49
|
+
rescue ::RuntimeError
|
50
|
+
the_source.bundle('update').execute!
|
51
|
+
end
|
36
52
|
end
|
37
53
|
|
38
54
|
def sibling_gemfile_local_line(sibling)
|
39
55
|
["gem '#{sibling.gem_name}'",
|
40
56
|
"path: ::File.expand_path('" +
|
41
57
|
sibling.path.relative_path_from(the_source.path).to_path +
|
42
|
-
"', __dir__)"
|
58
|
+
"', __dir__)",
|
59
|
+
'require: false'].join(', ') + "\n"
|
43
60
|
end
|
44
61
|
|
45
62
|
def start_banner
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module Avm
|
6
|
+
module EacRubyBase1
|
7
|
+
module Sources
|
8
|
+
module Runners
|
9
|
+
class Bundler
|
10
|
+
class GemfileLock
|
11
|
+
module Git
|
12
|
+
private
|
13
|
+
|
14
|
+
def git_continue
|
15
|
+
infom "Adding \"#{gemfile_lock}\"..."
|
16
|
+
git_repo.command('add', gemfile_lock).execute!
|
17
|
+
if rebase_conflict?
|
18
|
+
git_continue_run('rebase')
|
19
|
+
elsif cherry_conflict?
|
20
|
+
git_continue_run('cherry-pick')
|
21
|
+
else
|
22
|
+
raise 'Unknown how to continue'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def git_continue_run(command)
|
27
|
+
infom "\"#{command}\" --continue..."
|
28
|
+
cmd = git_repo.command(command, '--continue')
|
29
|
+
.envvar('GIT_EDITOR', 'true')
|
30
|
+
return unless !cmd.system && !conflict?
|
31
|
+
|
32
|
+
fatal_error "\"#{cmd}\" failed and there is no conflict"
|
33
|
+
end
|
34
|
+
|
35
|
+
def git_repo
|
36
|
+
instance.scm.git_repo
|
37
|
+
end
|
38
|
+
|
39
|
+
def git_reset_checkout
|
40
|
+
git_reset_gemfile_lock
|
41
|
+
git_checkout_gemfile_lock
|
42
|
+
end
|
43
|
+
|
44
|
+
def git_checkout_gemfile_lock
|
45
|
+
infom 'Checkouting...'
|
46
|
+
git_repo.command('checkout', '--', gemfile_lock).system!
|
47
|
+
end
|
48
|
+
|
49
|
+
def git_reset_gemfile_lock
|
50
|
+
infom 'Reseting...'
|
51
|
+
git_repo.command('reset', gemfile_lock).system! if
|
52
|
+
::File.exist?(gemfile_lock)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_cli/core_ext'
|
4
|
+
|
5
|
+
module Avm
|
6
|
+
module EacRubyBase1
|
7
|
+
module Sources
|
8
|
+
module Runners
|
9
|
+
class Bundler
|
10
|
+
class GemfileLock
|
11
|
+
require_sub __FILE__, include_modules: true
|
12
|
+
runner_with :help do
|
13
|
+
desc 'Manipulage a "Gemfile.lock" file.'
|
14
|
+
bool_opt '-c', '--continue', 'Continue Git rebase/cherry-pick.'
|
15
|
+
bool_opt '-i', '--install', 'Run "bundle install".'
|
16
|
+
bool_opt '-u', '--update', 'Run "bundle update".'
|
17
|
+
bool_opt '-r', '--recursive', 'Run until Git rebase/cherry-pick is finished.'
|
18
|
+
bool_opt '-a', '--all', 'Same as "-cirud".'
|
19
|
+
bool_opt '-d', '--delete', 'Delete Gemfile.lock'
|
20
|
+
end
|
21
|
+
|
22
|
+
def run
|
23
|
+
loop do
|
24
|
+
git_reset_checkout
|
25
|
+
delete_gemfile_lock
|
26
|
+
bundle_update
|
27
|
+
bundle_install
|
28
|
+
git_continue
|
29
|
+
break if complete?
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def complete?
|
36
|
+
!option_or_all?(:recursive) || !conflict?
|
37
|
+
end
|
38
|
+
|
39
|
+
def delete_gemfile_lock
|
40
|
+
::FileUtils.rm_f(gemfile_lock)
|
41
|
+
end
|
42
|
+
|
43
|
+
def rebasing?
|
44
|
+
git_repo.root_path.join('.git', 'rebase-merge').exist?
|
45
|
+
end
|
46
|
+
|
47
|
+
def bundle_install
|
48
|
+
infom '"bundle install"...'
|
49
|
+
bundle_run('install')
|
50
|
+
end
|
51
|
+
|
52
|
+
def bundle_update
|
53
|
+
infom '"bundle update"...'
|
54
|
+
bundle_run('update')
|
55
|
+
end
|
56
|
+
|
57
|
+
def gemfile_lock
|
58
|
+
'Gemfile.lock'
|
59
|
+
end
|
60
|
+
|
61
|
+
def bundle_run(*args)
|
62
|
+
instance.bundle(*args).system!
|
63
|
+
end
|
64
|
+
|
65
|
+
def conflict?
|
66
|
+
rebase_conflict? || cherry_conflict?
|
67
|
+
end
|
68
|
+
|
69
|
+
def rebase_conflict?
|
70
|
+
git_repo.root_path.join('.git', 'REBASE_HEAD').exist?
|
71
|
+
end
|
72
|
+
|
73
|
+
def cherry_conflict?
|
74
|
+
git_repo.root_path.join('.git', 'CHERRY_PICK_HEAD').exist?
|
75
|
+
end
|
76
|
+
|
77
|
+
def option_or_all?(option)
|
78
|
+
parsed[option] || parsed.all?
|
79
|
+
end
|
80
|
+
|
81
|
+
def instance
|
82
|
+
runner_context.call(:subject)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -16,13 +16,9 @@ module Avm
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def run
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
infov 'Gem to update', gem_name
|
23
|
-
::Avm::EacRubyBase1::Sources::UpdateDependencyRequirements
|
24
|
-
.new(runner_context.call(:source), gem_name).perform
|
25
|
-
end
|
19
|
+
start_banner
|
20
|
+
update_gemfile_lock
|
21
|
+
process_all_gems
|
26
22
|
end
|
27
23
|
|
28
24
|
def gemspec
|
@@ -47,6 +43,24 @@ module Avm
|
|
47
43
|
|
48
44
|
gemspec.dependencies.map(&:gem_name)
|
49
45
|
end
|
46
|
+
|
47
|
+
def process_all_gems
|
48
|
+
gem_names.each do |gem_name|
|
49
|
+
infov 'Gem to update', gem_name
|
50
|
+
::Avm::EacRubyBase1::Sources::UpdateDependencyRequirements
|
51
|
+
.new(runner_context.call(:source), gem_name).perform
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def start_banner
|
56
|
+
runner_context.call(:source_banner)
|
57
|
+
infov 'Gems to update', gem_names.count
|
58
|
+
end
|
59
|
+
|
60
|
+
def update_gemfile_lock
|
61
|
+
infom 'Updating Gemfile\'s lock...'
|
62
|
+
runner_context.call(:source).bundle('update').execute!
|
63
|
+
end
|
50
64
|
end
|
51
65
|
end
|
52
66
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: avm-eac_ruby_base1
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.22.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Put here the authors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: avm
|
@@ -16,20 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
20
|
-
- - ">="
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: 0.41.1
|
19
|
+
version: '0.45'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
24
|
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: '0.
|
30
|
-
- - ">="
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: 0.41.1
|
26
|
+
version: '0.45'
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: avm-eac_generic_base0
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -50,14 +44,14 @@ dependencies:
|
|
50
44
|
requirements:
|
51
45
|
- - "~>"
|
52
46
|
- !ruby/object:Gem::Version
|
53
|
-
version: '0.
|
47
|
+
version: '0.104'
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
51
|
requirements:
|
58
52
|
- - "~>"
|
59
53
|
- !ruby/object:Gem::Version
|
60
|
-
version: '0.
|
54
|
+
version: '0.104'
|
61
55
|
- !ruby/object:Gem::Dependency
|
62
56
|
name: aranha-parsers
|
63
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,6 +117,7 @@ files:
|
|
123
117
|
- lib/avm/eac_ruby_base1/rubygems/version_file.rb
|
124
118
|
- lib/avm/eac_ruby_base1/runners.rb
|
125
119
|
- lib/avm/eac_ruby_base1/runners/base.rb
|
120
|
+
- lib/avm/eac_ruby_base1/runners/base/lib_rename.rb
|
126
121
|
- lib/avm/eac_ruby_base1/runners/base/rubocop.rb
|
127
122
|
- lib/avm/eac_ruby_base1/source_generators.rb
|
128
123
|
- lib/avm/eac_ruby_base1/source_generators/base.rb
|
@@ -134,9 +129,12 @@ files:
|
|
134
129
|
- lib/avm/eac_ruby_base1/sources/base/rubygems.rb
|
135
130
|
- lib/avm/eac_ruby_base1/sources/base/version_bump.rb
|
136
131
|
- lib/avm/eac_ruby_base1/sources/bundle_update.rb
|
132
|
+
- lib/avm/eac_ruby_base1/sources/namespace_replacer.rb
|
137
133
|
- lib/avm/eac_ruby_base1/sources/runners.rb
|
138
134
|
- lib/avm/eac_ruby_base1/sources/runners/bundler.rb
|
139
135
|
- lib/avm/eac_ruby_base1/sources/runners/bundler/gemfile_local.rb
|
136
|
+
- lib/avm/eac_ruby_base1/sources/runners/bundler/gemfile_lock.rb
|
137
|
+
- lib/avm/eac_ruby_base1/sources/runners/bundler/gemfile_lock/git.rb
|
140
138
|
- lib/avm/eac_ruby_base1/sources/runners/bundler/incompatible.rb
|
141
139
|
- lib/avm/eac_ruby_base1/sources/runners/update_dependencies_requirements.rb
|
142
140
|
- lib/avm/eac_ruby_base1/sources/tests.rb
|