avm-tools 0.47.0 → 0.48.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ea5ddc3be43fde36ddae9da599013e75bb0eeeab41960f449bc98665479df692
4
- data.tar.gz: d7521c7d54d213a99a8786672c2c5252ed9ab0055f2704111b9c9995ebadbc7f
3
+ metadata.gz: 7ebefeec62ed2a18b49480f8da27d9582ab7c4bf6f71e19d0c2c2a82a7ec87ec
4
+ data.tar.gz: 1616f697714aecc0ea58b6695a8d7672b79e384c352a9e0ec1ece91daf88667c
5
5
  SHA512:
6
- metadata.gz: 8446d752260be60ebffdda5226ec06fc0c01c4bdd07f5696188cbf0a062b00632544e26283e73cd499d37a3f6e9f701fe687dfe2a07fad674cb07fdd12f19f50
7
- data.tar.gz: 5264f44597c53a062537a84ebf5ee740ec5eb62aeabc1c3171601f513bc8494055ad9ac62780b6dec5c7b50006bee64039455fd308a07d882b114ade74d25d7a
6
+ metadata.gz: 17fbb28c4bdaf19ca33c1db1cb3f0d9678dd476f5804f972c19fff2e0ab0aae151568b2e82ce46a6da6b524682de4df11b0d231606d61ce0a1fe67c089490262
7
+ data.tar.gz: 8fda39f66fb0d7e2108245b33e76d7f7053223572b0571534f57cdc5f1632ddd595b1f0a510bfc453a61286f2fee2b5fc3e8d786ce9f587bd16a6334e1f84833
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avm/patches/eac_launcher_git_base'
3
+ require 'eac_launcher/git/base'
4
4
  require 'eac_ruby_utils/console/speaker'
5
5
  require 'eac_ruby_utils/options_consumer'
6
6
  require 'eac_ruby_utils/require_sub'
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'avm/fs_cache'
4
- require 'avm/ruby'
5
4
  require 'eac_ruby_utils/core_ext'
5
+ require 'eac_ruby_utils/ruby'
6
6
 
7
7
  module Avm
8
8
  module Git
@@ -57,7 +57,7 @@ module Avm
57
57
  def run_test
58
58
  infom "Running test command \"#{::Shellwords.join(test_command_args)}\"" \
59
59
  " on \"#{git_absolute_path}\"..."
60
- result = ::Avm::Ruby.on_clean_environment { test_command.execute }
60
+ result = ::EacRubyUtils::Ruby.on_clean_environment { test_command.execute }
61
61
  infom 'Test done'
62
62
  write_result_cache(result)
63
63
  end
data/lib/avm/rails.rb ADDED
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Rails
7
+ require_sub __FILE__
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Rails
7
+ module Runners
8
+ require_sub __FILE__
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'eac_ruby_utils/console/docopt_runner'
5
+ require 'shellwords'
6
+
7
+ module Avm
8
+ module Rails
9
+ module Runners
10
+ class Bundle < ::EacRubyUtils::Console::DocoptRunner
11
+ enable_console_speaker
12
+
13
+ DOC = <<~DOCOPT
14
+ Runs "bundle ...".
15
+
16
+ Usage:
17
+ __PROGRAM__ [<bundle-args>...]
18
+ __PROGRAM__ -h | --help
19
+
20
+ Options:
21
+ -h --help Show this screen.
22
+ DOCOPT
23
+
24
+ def run
25
+ infov 'Bundle arguments', ::Shellwords.join(bundle_args)
26
+ context(:instance).bundle(*bundle_args).system!
27
+ end
28
+
29
+ def bundle_args
30
+ options.fetch('<bundle-args>').reject { |arg| arg == '--' }
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
data/lib/avm/ruby.rb CHANGED
@@ -5,25 +5,5 @@ require 'eac_ruby_utils/core_ext'
5
5
  module Avm
6
6
  module Ruby
7
7
  require_sub __FILE__
8
-
9
- class << self
10
- def on_clean_environment
11
- on_clean_envvars('BUNDLE', 'RUBY') { yield }
12
- end
13
-
14
- private
15
-
16
- def on_clean_envvars(*start_with_vars)
17
- old_values = envvars_starting_with(start_with_vars)
18
- old_values.keys.each { |k| ENV.delete(k) } # rubocop:disable Style/HashEachMethods
19
- yield
20
- ensure
21
- old_values&.each { |k, v| ENV[k] = v }
22
- end
23
-
24
- def envvars_starting_with(start_with_vars)
25
- ENV.select { |k, _v| start_with_vars.any? { |var| k.start_with?(var) } }
26
- end
27
- end
28
8
  end
29
9
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avm/ruby'
4
3
  require 'avm/stereotypes/eac_webapp_base0/deploy'
4
+ require 'eac_ruby_utils/ruby'
5
5
 
6
6
  module Avm
7
7
  module Stereotypes
@@ -11,7 +11,7 @@ module Avm
11
11
 
12
12
  def run_installer
13
13
  infom 'Running installer'
14
- ::Avm::Ruby.on_clean_environment do
14
+ ::EacRubyUtils::Ruby.on_clean_environment do
15
15
  installer_command.system!
16
16
  end
17
17
  end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/rails/runners/bundle'
4
+
5
+ module Avm
6
+ module Tools
7
+ class Runner < ::EacRubyUtils::Console::DocoptRunner
8
+ class EacRailsBase0 < ::EacRubyUtils::Console::DocoptRunner
9
+ class Bundle < ::Avm::Rails::Runners::Bundle
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -1,34 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avm/stereotypes/eac_redmine_base0/deploy'
4
- require 'avm/stereotypes/eac_webapp_base0/runner/deploy'
3
+ require 'avm/rails/runners/bundle'
5
4
 
6
5
  module Avm
7
6
  module Tools
8
7
  class Runner < ::EacRubyUtils::Console::DocoptRunner
9
8
  class EacRedmineBase0 < ::EacRubyUtils::Console::DocoptRunner
10
- class Bundle < ::EacRubyUtils::Console::DocoptRunner
11
- enable_console_speaker
12
-
13
- DOC = <<~DOCOPT
14
- Runs "bundle ...".
15
-
16
- Usage:
17
- __PROGRAM__ [<bundle-args>...]
18
- __PROGRAM__ -h | --help
19
-
20
- Options:
21
- -h --help Show this screen.
22
- DOCOPT
23
-
24
- def run
25
- infov 'Bundle arguments', ::Shellwords.join(bundle_args)
26
- context(:instance).bundle(*bundle_args).system!
27
- end
28
-
29
- def bundle_args
30
- options.fetch('<bundle-args>').reject { |arg| arg == '--' }
31
- end
9
+ class Bundle < ::Avm::Rails::Runners::Bundle
32
10
  end
33
11
  end
34
12
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'avm/files/formatter'
4
- require 'avm/patches/eac_launcher_git_base'
4
+ require 'eac_launcher/git/base'
5
5
  require 'eac_ruby_utils/console/docopt_runner'
6
6
  require 'eac_ruby_utils/core_ext'
7
7
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'eac_ruby_utils/console/docopt_runner'
4
4
  require 'eac_ruby_utils/require_sub'
5
- require 'avm/patches/eac_launcher_git_base'
5
+ require 'eac_launcher/git/base'
6
6
  ::EacRubyUtils.require_sub(__FILE__)
7
7
 
8
8
  module Avm
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module Tools
5
- VERSION = '0.47.0'
5
+ VERSION = '0.48.0'
6
6
  end
7
7
  end
@@ -1,19 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils/simple_cache'
3
+ require 'eac_ruby_utils/core_ext'
4
4
  require 'eac_ruby_utils/envs'
5
5
  require 'eac_launcher/paths/real'
6
- require 'eac_launcher/git/base/underlying'
7
- require 'eac_launcher/git/base/subrepo'
8
6
  require 'eac_launcher/git/error'
9
7
 
10
8
  module EacLauncher
11
9
  module Git
12
10
  class Base < ::EacLauncher::Paths::Real
13
- include ::EacRubyUtils::SimpleCache
11
+ require_sub __FILE__
12
+ enable_simple_cache
13
+ extend ::EacLauncher::Git::Base::ClassMethods
14
+ include ::EacLauncher::Git::Base::DirtyFiles
15
+ include ::EacLauncher::Git::Base::Remotes
14
16
  include ::EacLauncher::Git::Base::Subrepo
15
17
  include ::EacLauncher::Git::Base::Underlying
16
- require_relative ::File.join(__dir__, 'base', '_remotes')
17
18
 
18
19
  def init_bare
19
20
  FileUtils.mkdir_p(self)
@@ -30,6 +31,11 @@ module EacLauncher
30
31
  raise "Reference \"#{ref}\" not found"
31
32
  end
32
33
 
34
+ # @return [Pathname]
35
+ def root_path
36
+ @root_path ||= self.class.find_root(to_s)
37
+ end
38
+
33
39
  def descendant?(descendant, ancestor)
34
40
  base = merge_base(descendant, ancestor)
35
41
  return false if base.blank?
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacLauncher
4
+ module Git
5
+ class Base < ::EacLauncher::Paths::Real
6
+ module ClassMethods
7
+ # @return [EacLauncher::Git::Base]
8
+ def by_root(search_base_path)
9
+ new(find_root(search_base_path).to_path)
10
+ end
11
+
12
+ # Searches the root path for the Git repository which includes +search_base_path+.
13
+ # @return [Pathname]
14
+ def find_root(search_base_path)
15
+ path = search_base_path.to_pathname.expand_path
16
+ loop do
17
+ return path if path.join('.git').exist?
18
+ raise "\".git\" not found for \"#{search_base_path}\"" if path.parent.root?
19
+
20
+ path = path.parent
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/core_ext/object'
4
+
5
+ module EacLauncher
6
+ module Git
7
+ class Base < ::EacLauncher::Paths::Real
8
+ module DirtyFiles
9
+ def dirty?
10
+ dirty_files.any?
11
+ end
12
+
13
+ def dirty_files
14
+ execute!('status', '--porcelain', '--untracked-files').each_line.map do |line|
15
+ parse_status_line(line.gsub(/\n\z/, ''))
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ def parse_status_line(line)
22
+ m = /\A(.)(.)\s(.+)\z/.match(line)
23
+ ::Kernel.raise "Status pattern does not match \"#{line}\"" unless m
24
+ ::OpenStruct.new(index: m[1], worktree: m[2], path: m[3],
25
+ absolute_path: ::File.expand_path(m[3], self))
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'eac_launcher/git/remote'
5
+
6
+ module EacLauncher
7
+ module Git
8
+ class Base < ::EacLauncher::Paths::Real
9
+ module Remotes
10
+ # @return [EacLauncher::Git::Remote]
11
+ def remote(name)
12
+ ::EacLauncher::Git::Remote.new(self, name)
13
+ end
14
+
15
+ def remote_hashs(remote_name)
16
+ remote(remote_name).ls
17
+ end
18
+
19
+ def remote_exist?(remote_name)
20
+ remote(remote_name).exist?
21
+ end
22
+
23
+ def assert_remote_url(remote_name, url)
24
+ r = git.remote(remote_name)
25
+ if !r.url || r.url != url
26
+ r.remove if r.url
27
+ git.add_remote(remote_name, url)
28
+ end
29
+ r
30
+ end
31
+
32
+ def remote_branch_sha(remote_name, branch_name)
33
+ remote_hashs(remote_name)["refs/heads/#{branch_name}"]
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -8,6 +8,16 @@ module EacLauncher
8
8
  module Git
9
9
  class Base < ::EacLauncher::Paths::Real
10
10
  module Underlying
11
+ def command(*args)
12
+ args, _options = build_args(args)
13
+ ::EacRubyUtils::Envs.local.command(*args)
14
+ end
15
+
16
+ def execute(*args)
17
+ args, options = build_args(args)
18
+ ::EacRubyUtils::Envs.local.command(*args).execute(options)
19
+ end
20
+
11
21
  def execute!(*args)
12
22
  args, options = build_args(args)
13
23
  ::EacRubyUtils::Envs.local.command(*args).execute!(options)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avm-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.47.0
4
+ version: 0.48.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esquilo Azul Company
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-16 00:00:00.000000000 Z
11
+ date: 2020-05-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aranha-parsers
@@ -303,9 +303,11 @@ files:
303
303
  - lib/avm/instances/entries/entry_reader.rb
304
304
  - lib/avm/instances/entry_keys.rb
305
305
  - lib/avm/patches.rb
306
- - lib/avm/patches/eac_launcher_git_base.rb
307
306
  - lib/avm/patches/object/template.rb
308
307
  - lib/avm/path_string.rb
308
+ - lib/avm/rails.rb
309
+ - lib/avm/rails/runners.rb
310
+ - lib/avm/rails/runners/bundle.rb
309
311
  - lib/avm/result.rb
310
312
  - lib/avm/ruby.rb
311
313
  - lib/avm/ruby/rubocop.rb
@@ -352,6 +354,7 @@ files:
352
354
  - lib/avm/tools/runner.rb
353
355
  - lib/avm/tools/runner/eac_rails_base0.rb
354
356
  - lib/avm/tools/runner/eac_rails_base0/apache_host.rb
357
+ - lib/avm/tools/runner/eac_rails_base0/bundle.rb
355
358
  - lib/avm/tools/runner/eac_rails_base0/data.rb
356
359
  - lib/avm/tools/runner/eac_rails_base0/deploy.rb
357
360
  - lib/avm/tools/runner/eac_redmine_base0.rb
@@ -388,7 +391,9 @@ files:
388
391
  - lib/eac_launcher/context/settings.rb
389
392
  - lib/eac_launcher/git.rb
390
393
  - lib/eac_launcher/git/base.rb
391
- - lib/eac_launcher/git/base/_remotes.rb
394
+ - lib/eac_launcher/git/base/class_methods.rb
395
+ - lib/eac_launcher/git/base/dirty_files.rb
396
+ - lib/eac_launcher/git/base/remotes.rb
392
397
  - lib/eac_launcher/git/base/subrepo.rb
393
398
  - lib/eac_launcher/git/base/underlying.rb
394
399
  - lib/eac_launcher/git/error.rb
@@ -1,77 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_launcher/git/base'
4
- require 'eac_launcher/git/error'
5
- require 'eac_ruby_utils/patch'
6
- require 'eac_ruby_utils/require_sub'
7
- ::EacRubyUtils.require_sub(__FILE__)
8
-
9
- module Avm
10
- module Patches
11
- module EacLauncherGitBase
12
- extend ::ActiveSupport::Concern
13
-
14
- included do
15
- extend ClassMethods
16
- include InstanceMethods
17
- end
18
-
19
- module ClassMethods
20
- # @return [EacLauncher::Git::Base]
21
- def by_root(search_base_path)
22
- new(find_root(search_base_path).to_path)
23
- end
24
-
25
- # Searches the root path for the Git repository which includes +search_base_path+.
26
- # @return [Pathname]
27
- def find_root(search_base_path)
28
- path = search_base_path.to_pathname.expand_path
29
- loop do
30
- return path if path.join('.git').exist?
31
- raise "\".git\" not found for \"#{search_base_path}\"" if path.parent.root?
32
-
33
- path = path.parent
34
- end
35
- end
36
- end
37
-
38
- module InstanceMethods
39
- def execute(*args)
40
- args, options = build_args(args)
41
- ::EacRubyUtils::Envs.local.command(*args).execute(options)
42
- end
43
-
44
- def command(*args)
45
- args, _options = build_args(args)
46
- ::EacRubyUtils::Envs.local.command(*args)
47
- end
48
-
49
- def dirty?
50
- dirty_files.any?
51
- end
52
-
53
- def dirty_files
54
- execute!('status', '--porcelain', '--untracked-files').each_line.map do |line|
55
- parse_status_line(line.gsub(/\n\z/, ''))
56
- end
57
- end
58
-
59
- # @return [Pathname]
60
- def root_path
61
- @root_path ||= self.class.find_root(to_s)
62
- end
63
-
64
- private
65
-
66
- def parse_status_line(line)
67
- m = /\A(.)(.)\s(.+)\z/.match(line)
68
- ::Kernel.raise "Status pattern does not match \"#{line}\"" unless m
69
- ::OpenStruct.new(index: m[1], worktree: m[2], path: m[3],
70
- absolute_path: ::File.expand_path(m[3], self))
71
- end
72
- end
73
- end
74
- end
75
- end
76
-
77
- ::EacRubyUtils.patch(::EacLauncher::Git::Base, ::Avm::Patches::EacLauncherGitBase)
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
- require 'eac_launcher/git/remote'
5
-
6
- module EacLauncher
7
- module Git
8
- class Base < ::EacLauncher::Paths::Real
9
- # @return [EacLauncher::Git::Remote]
10
- def remote(name)
11
- ::EacLauncher::Git::Remote.new(self, name)
12
- end
13
-
14
- def remote_hashs(remote_name)
15
- remote(remote_name).ls
16
- end
17
-
18
- def remote_exist?(remote_name)
19
- remote(remote_name).exist?
20
- end
21
-
22
- def assert_remote_url(remote_name, url)
23
- r = git.remote(remote_name)
24
- if !r.url || r.url != url
25
- r.remove if r.url
26
- git.add_remote(remote_name, url)
27
- end
28
- r
29
- end
30
-
31
- def remote_branch_sha(remote_name, branch_name)
32
- remote_hashs(remote_name)["refs/heads/#{branch_name}"]
33
- end
34
- end
35
- end
36
- end