avm-tools 0.87.1 → 0.92.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.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/lib/avm/{eac_writings_base1.rb → eac_asciidoctor_base0.rb} +1 -1
  3. data/lib/avm/{eac_writings_base1 → eac_asciidoctor_base0}/apache_host.rb +1 -1
  4. data/lib/avm/{eac_writings_base1 → eac_asciidoctor_base0}/build.rb +5 -3
  5. data/lib/avm/{eac_writings_base1 → eac_asciidoctor_base0}/build/file.rb +4 -4
  6. data/lib/avm/{eac_writings_base1 → eac_asciidoctor_base0}/deploy.rb +6 -6
  7. data/lib/avm/{eac_writings_base1 → eac_asciidoctor_base0}/instance.rb +1 -1
  8. data/lib/avm/{eac_writings_base1 → eac_asciidoctor_base0}/project.rb +1 -1
  9. data/lib/avm/eac_rails_base1/runner/log.rb +43 -0
  10. data/lib/avm/eac_rails_base1/runner_with/bundle.rb +2 -32
  11. data/lib/avm/eac_rails_base1/runner_with/rails_environment.rb +47 -0
  12. data/lib/avm/eac_webapp_base0/deploy.rb +16 -4
  13. data/lib/avm/eac_webapp_base0/deploy/appended_directories.rb +1 -1
  14. data/lib/avm/eac_webapp_base0/deploy/git_info.rb +1 -1
  15. data/lib/avm/eac_webapp_base0/instance.rb +2 -0
  16. data/lib/avm/eac_webapp_base0/runner/deploy.rb +13 -21
  17. data/lib/avm/executables.rb +1 -1
  18. data/lib/avm/git/auto_commit/commit_info.rb +22 -0
  19. data/lib/avm/git/auto_commit/rules.rb +31 -0
  20. data/lib/avm/git/auto_commit/rules/base.rb +39 -0
  21. data/lib/avm/git/auto_commit/rules/last.rb +19 -0
  22. data/lib/avm/git/auto_commit/rules/manual.rb +45 -0
  23. data/lib/avm/git/auto_commit/rules/nth.rb +23 -0
  24. data/lib/avm/git/auto_commit/rules/unique.rb +21 -0
  25. data/lib/avm/git/file_auto_fixup.rb +15 -62
  26. data/lib/avm/instances/runner.rb +1 -1
  27. data/lib/avm/tools/runner/{eac_writings_base1.rb → eac_asciidoctor_base0.rb} +2 -2
  28. data/lib/avm/tools/runner/eac_webapp_base0.rb +14 -0
  29. data/lib/avm/tools/runner/git/auto_commit.rb +12 -13
  30. data/lib/avm/tools/runner/git/auto_fixup.rb +9 -9
  31. data/lib/avm/tools/runner/git/commit.rb +11 -20
  32. data/lib/avm/tools/runner/instance.rb +3 -6
  33. data/lib/avm/tools/runner/instance/info.rb +4 -7
  34. data/lib/avm/tools/runner/local_project/{eac_writings_base1.rb → eac_asciidoctor_base0.rb} +2 -2
  35. data/lib/avm/tools/runner/local_project/{eac_writings_base1 → eac_asciidoctor_base0}/build.rb +5 -9
  36. data/lib/avm/tools/version.rb +1 -1
  37. data/vendor/eac_cli/lib/eac_cli/definition/argument_option.rb +8 -0
  38. data/vendor/eac_cli/lib/eac_cli/definition/base_option.rb +6 -1
  39. data/vendor/eac_cli/lib/eac_cli/definition/boolean_option.rb +8 -0
  40. data/vendor/eac_cli/lib/eac_cli/definition/positional_argument.rb +12 -0
  41. data/vendor/eac_cli/lib/eac_cli/parser/collector.rb +3 -17
  42. data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
  43. data/vendor/eac_cli/spec/lib/eac_cli/runner_spec.rb +21 -3
  44. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/local_time_zone.rb +4 -0
  45. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  46. metadata +42 -13
  47. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/time/default_time_zone_set.rb +0 -6
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Git
7
+ module AutoCommit
8
+ module Rules
9
+ class Base
10
+ class << self
11
+ def keys
12
+ [long_key, short_key]
13
+ end
14
+
15
+ def long_key
16
+ name.demodulize.variableize
17
+ end
18
+
19
+ def short_key
20
+ long_key[0, 1]
21
+ end
22
+ end
23
+
24
+ def with_file(file)
25
+ self.class.const_get('WithFile').new(self, file)
26
+ end
27
+
28
+ class WithFile
29
+ common_constructor :rule, :file
30
+
31
+ def new_commit_info
32
+ ::Avm::Git::AutoCommit::CommitInfo.new
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/git/auto_commit/rules/base'
4
+
5
+ module Avm
6
+ module Git
7
+ module AutoCommit
8
+ module Rules
9
+ class Last < ::Avm::Git::AutoCommit::Rules::Base
10
+ class WithFile < ::Avm::Git::AutoCommit::Rules::Base::WithFile
11
+ def commit_info
12
+ file.commits.last.if_present { |v| new_commit_info.fixup(v) }
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/git/auto_commit/rules/base'
4
+
5
+ module Avm
6
+ module Git
7
+ module AutoCommit
8
+ module Rules
9
+ class Manual < ::Avm::Git::AutoCommit::Rules::Base
10
+ class WithFile < ::Avm::Git::AutoCommit::Rules::Base::WithFile
11
+ enable_console_speaker
12
+
13
+ COMMIT_FORMAT = '%h - %s (%cr)'
14
+ SKIP_OPTION = 's'
15
+
16
+ def commit_info
17
+ return nil unless file.commits.any?
18
+
19
+ commits_banner
20
+ request_input('Which commit?', list: commits_by_position).if_present do |v|
21
+ new_commit_info.fixup(v)
22
+ end
23
+ end
24
+
25
+ def commits_banner
26
+ file.commits.each_with_index do |commit, _index|
27
+ infov " #{commit.position}", format_commit(commit)
28
+ end
29
+ infov " #{SKIP_OPTION}", 'skip'
30
+ end
31
+
32
+ def commits_by_position
33
+ (file.commits.map { |commit| [commit.position.to_s, commit] } + [[SKIP_OPTION, nil]])
34
+ .to_h
35
+ end
36
+
37
+ def format_commit(commit)
38
+ commit.format(COMMIT_FORMAT)
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/git/auto_commit/rules/base'
4
+
5
+ module Avm
6
+ module Git
7
+ module AutoCommit
8
+ module Rules
9
+ class Nth < ::Avm::Git::AutoCommit::Rules::Base
10
+ common_constructor :number do
11
+ self.number = number.to_i
12
+ end
13
+
14
+ class WithFile < ::Avm::Git::AutoCommit::Rules::Base::WithFile
15
+ def commit_info
16
+ file.commits(number - 1).if_present { |v| new_commit_info.fixup(v) }
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/git/auto_commit/rules/base'
4
+
5
+ module Avm
6
+ module Git
7
+ module AutoCommit
8
+ module Rules
9
+ class Unique < ::Avm::Git::AutoCommit::Rules::Base
10
+ class WithFile < ::Avm::Git::AutoCommit::Rules::Base::WithFile
11
+ def commit_info
12
+ return nil unless file.commits.count == 1
13
+
14
+ new_commit_info.fixup(file.commits.first)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'avm/git/auto_commit/commit_info'
3
4
  require 'eac_ruby_utils/core_ext'
4
5
 
5
6
  module Avm
@@ -8,31 +9,24 @@ module Avm
8
9
  enable_console_speaker
9
10
  enable_simple_cache
10
11
  enable_listable
11
- lists.add_symbol :option, :select, :unique
12
12
 
13
- common_constructor :git, :path, :options, default: [{}] do
14
- self.options = self.class.lists.option.hash_keys_validate!(options.symbolize_keys)
15
- end
13
+ common_constructor :git, :path, :rules
16
14
 
17
- COMMIT_FORMAT = '%h - %s (%cr)'
18
15
  COMMITS_SEARCH_INTERVAL = 'origin/master..HEAD'
19
- SKIP_OPTION = 's'
20
16
 
21
17
  def run
22
18
  start_banner
23
- if commits.count.zero?
24
- run_no_commits_found
25
- elsif auto_selected_commit.present?
26
- fixup_commit(auto_selected_commit)
27
- else
28
- run_commits_selection
29
- end
19
+ run_commit || warn("No rule returned commit information for \"#{path}\"")
30
20
  end
31
21
 
32
22
  private
33
23
 
34
- def auto_selected_commit_uncached
35
- selected_commit_by_unique || select_commit_by_select
24
+ def commit_args
25
+ commit_info.if_present([], &:git_commit_args) + ['--', path]
26
+ end
27
+
28
+ def commit_info_uncached
29
+ rules.lazy.map { |rule| rule.with_file(self).commit_info }.find(&:present?)
36
30
  end
37
31
 
38
32
  def start_banner
@@ -40,50 +34,13 @@ module Avm
40
34
  infov ' Commits found', commits.count
41
35
  end
42
36
 
43
- def run_no_commits_found
44
- infom ' No commits found'
45
- end
46
-
47
- def fixup_commit(commit)
48
- infov ' Commit selected/found', format_commit(commit)
49
- git.execute!('commit', '--fixup', commit.sha1, '--', path)
50
- success " Fixup with \"#{format_commit(commit)}\""
51
- end
52
-
53
- def run_commits_selection
54
- selected_commit = select_commit
55
- if selected_commit
56
- fixup_commit(selected_commit)
57
- else
58
- infom ' Skipped'
59
- end
60
- end
61
-
62
- def select_commit
63
- commits_banner
64
- request_input('Which commit?', list: commits_by_position)
65
- end
66
-
67
- def selected_commit_by_unique
68
- return unless options[OPTION_UNIQUE]
69
- return commits.first if commits.first
70
- end
37
+ def run_commit
38
+ return false if commit_info.blank?
71
39
 
72
- def select_commit_by_select
73
- options[OPTION_SELECT].if_present(&:to_i).if_present do |v|
74
- commits.find { |commit| commit.position == v }
75
- end
76
- end
77
-
78
- def commits_banner
79
- commits.each_with_index do |commit, _index|
80
- infov " #{commit.position}", format_commit(commit)
81
- end
82
- infov " #{SKIP_OPTION}", 'skip'
83
- end
84
-
85
- def commits_by_position
86
- (commits.map { |commit| [commit.position.to_s, commit] } + [[SKIP_OPTION, nil]]).to_h
40
+ infov ' Commit arguments', ::Shellwords.join(commit_args)
41
+ git.execute!('commit', *commit_args)
42
+ success ' Commited'
43
+ true
87
44
  end
88
45
 
89
46
  def commits_uncached
@@ -93,10 +50,6 @@ module Avm
93
50
  .each_with_index.map { |commit, index| CommitDelegator.new(commit, index) }
94
51
  end
95
52
 
96
- def format_commit(commit)
97
- commit.format(COMMIT_FORMAT)
98
- end
99
-
100
53
  class CommitDelegator < ::SimpleDelegator
101
54
  attr_reader :index
102
55
 
@@ -31,7 +31,7 @@ module Avm
31
31
  private
32
32
 
33
33
  def instance_uncached
34
- self.class.instance_class.by_id(options.fetch('<instance-id>'))
34
+ self.class.instance_class.by_id(parsed.instance_id)
35
35
  end
36
36
  end
37
37
  end
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'avm/eac_webapp_base0/runner'
4
- require 'avm/eac_writings_base1'
4
+ require 'avm/eac_asciidoctor_base0'
5
5
  require 'eac_ruby_utils/console/docopt_runner'
6
6
 
7
7
  module Avm
8
8
  module Tools
9
9
  class Runner
10
- class EacWritingsBase1 < ::Avm::EacWebappBase0::Runner
10
+ class EacAsciidoctorBase0 < ::Avm::EacWebappBase0::Runner
11
11
  require_sub __FILE__
12
12
  end
13
13
  end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/eac_webapp_base0/runner'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module Tools
8
+ class Runner
9
+ class EacWebappBase0 < ::Avm::EacWebappBase0::Runner
10
+ require_sub __FILE__
11
+ end
12
+ end
13
+ end
14
+ end
@@ -2,16 +2,14 @@
2
2
 
3
3
  require 'avm/git/auto_commit_path'
4
4
  require 'avm/files/formatter'
5
- require 'eac_cli/default_runner'
5
+ require 'eac_cli/core_ext'
6
6
 
7
7
  module Avm
8
8
  module Tools
9
9
  class Runner
10
10
  class Git
11
- class AutoCommit < ::EacRubyUtils::Console::DocoptRunner
12
- include ::EacCli::DefaultRunner
13
-
14
- runner_definition do
11
+ class AutoCommit
12
+ runner_with :help do
15
13
  desc 'Commit with message based in content commited.'
16
14
  bool_opt '-d', '--dirty', 'Select dirty files.'
17
15
  bool_opt '-f', '--format', 'Format files before commit.'
@@ -33,17 +31,19 @@ module Avm
33
31
 
34
32
  def clear_stage
35
33
  infom 'Clearing stage...'
36
- context(:git).system!('reset', 'HEAD')
34
+ runner_context.call(:git).system!('reset', 'HEAD')
37
35
  end
38
36
 
39
37
  def dirty_paths
40
- return [] unless options.fetch('--dirty')
38
+ return [] unless parsed.dirty?
41
39
 
42
- context(:git).dirty_files.map { |d| context(:git).root_path.join / d.path }
40
+ runner_context.call(:git).dirty_files.map do |d|
41
+ runner_context.call(:git).root_path.join / d.path
42
+ end
43
43
  end
44
44
 
45
45
  def format_files
46
- return unless options.fetch('--format')
46
+ return unless parsed.format?
47
47
 
48
48
  infom 'Formating files...'
49
49
  ::Avm::Files::Formatter.new(paths.map(&:path),
@@ -51,10 +51,9 @@ module Avm
51
51
  end
52
52
 
53
53
  def paths_uncached
54
- (options.fetch('<paths>')
55
- .map { |p| p.to_pathname.expand_path } + dirty_paths)
56
- .reject(&:directory?)
57
- .sort.uniq.map { |path| ::Avm::Git::AutoCommitPath.new(context(:git), path) }
54
+ (parsed.paths.map { |p| p.to_pathname.expand_path } + dirty_paths)
55
+ .reject(&:directory?).sort.uniq
56
+ .map { |path| ::Avm::Git::AutoCommitPath.new(runner_context.call(:git), path) }
58
57
  end
59
58
 
60
59
  def run_paths
@@ -3,6 +3,7 @@
3
3
  require 'eac_cli/core_ext'
4
4
  require 'eac_ruby_utils/console/docopt_runner'
5
5
  require 'avm/git/file_auto_fixup'
6
+ require 'avm/git/auto_commit/rules'
6
7
 
7
8
  module Avm
8
9
  module Tools
@@ -11,25 +12,18 @@ module Avm
11
12
  class AutoFixup
12
13
  runner_with :help do
13
14
  desc 'Auto fixup files.'
14
- bool_opt '-l', '--last', 'Equivalent to "--select=1".'
15
- arg_opt '-s', '--select', 'Automatically select de <value>-th commit.'
16
- bool_opt '-u', '--unique', 'Automatically select the first commit if it is unique.'
15
+ arg_opt '-r', '--rule', 'Apply a rule in the specified order.', repeat: true
17
16
  pos_arg :files, repeat: true, optional: true
18
17
  end
19
18
 
20
19
  def run
21
20
  files.each do |file|
22
- ::Avm::Git::FileAutoFixup.new(runner_context.call(:git), file, file_options).run
21
+ ::Avm::Git::FileAutoFixup.new(runner_context.call(:git), file, rules).run
23
22
  end
24
23
  end
25
24
 
26
25
  private
27
26
 
28
- def file_options
29
- { Avm::Git::FileAutoFixup::OPTION_SELECT => select,
30
- Avm::Git::FileAutoFixup::OPTION_UNIQUE => parsed.unique? }
31
- end
32
-
33
27
  def files
34
28
  files_from_option || dirty_files
35
29
  end
@@ -43,6 +37,12 @@ module Avm
43
37
  runner_context.call(:git).dirty_files.map(&:path)
44
38
  end
45
39
 
40
+ def rules
41
+ parsed.rule.map do |rule_string|
42
+ ::Avm::Git::AutoCommit::Rules.parse(rule_string)
43
+ end
44
+ end
45
+
46
46
  def select
47
47
  parsed.last? ? 1 : parsed.select
48
48
  end
@@ -11,22 +11,13 @@ module Avm
11
11
  module Tools
12
12
  class Runner
13
13
  class Git
14
- class Commit < ::EacRubyUtils::Console::DocoptRunner
15
- include ::EacRubyUtils::SimpleCache
16
- include ::EacRubyUtils::Console::Speaker
17
-
18
- DOC = <<~DOCOPT
19
- Mostra informações de um commit.
20
-
21
- Usage:
22
- __PROGRAM__ [options] <ref>
23
- __PROGRAM__ -h | --help
24
-
25
- Options:
26
- -h --help Mostra esta ajuda.
27
- -f --files Mostra os arquivos.
28
- -s --size Mostra o tamanho de arquivos.
29
- DOCOPT
14
+ class Commit
15
+ runner_with :help do
16
+ desc 'Mostra informações de um commit.'
17
+ bool_opt '-f', '--files', 'Mostra os arquivos.'
18
+ bool_opt '-s', '--size', 'Mostra o tamanho de arquivos.'
19
+ pos_arg :ref
20
+ end
30
21
 
31
22
  def run
32
23
  input_banner
@@ -64,7 +55,7 @@ module Avm
64
55
  end
65
56
 
66
57
  def files_banner
67
- return unless options.fetch('--files')
58
+ return unless parsed.files?
68
59
 
69
60
  commit.files.each do |file|
70
61
  infov " #{file.path}", file_value(file)
@@ -82,11 +73,11 @@ module Avm
82
73
  end
83
74
 
84
75
  def reference
85
- options.fetch('<ref>')
76
+ parsed.ref
86
77
  end
87
78
 
88
79
  def git_uncached
89
- ::EacLauncher::Git::Base.new(context(:repository_path))
80
+ ::EacLauncher::Git::Base.new(runner_context.call(:repository_path))
90
81
  end
91
82
 
92
83
  def commit_uncached
@@ -103,7 +94,7 @@ module Avm
103
94
  end
104
95
 
105
96
  def show_size?
106
- options.fetch('--size')
97
+ parsed.size?
107
98
  end
108
99
  end
109
100
  end