avm-tools 0.90.0 → 0.94.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/lib/avm/eac_asciidoctor_base0/apache_path.rb +10 -0
  3. data/lib/avm/eac_asciidoctor_base0/build.rb +3 -1
  4. data/lib/avm/eac_asciidoctor_base0/build/file.rb +3 -3
  5. data/lib/avm/eac_rails_base0/apache_path.rb +6 -38
  6. data/lib/avm/eac_webapp_base0/apache_host.rb +7 -31
  7. data/lib/avm/eac_webapp_base0/apache_path.rb +51 -0
  8. data/lib/avm/eac_webapp_base0/deploy.rb +12 -30
  9. data/lib/avm/eac_webapp_base0/runner/apache_host.rb +7 -10
  10. data/lib/avm/eac_webapp_base0/runner/apache_path.rb +40 -0
  11. data/lib/avm/eac_webapp_base0/runner/data.rb +6 -15
  12. data/lib/avm/eac_webapp_base0/runner/data/dump.rb +18 -24
  13. data/lib/avm/eac_webapp_base0/runner/data/load.rb +12 -23
  14. data/lib/avm/executables.rb +1 -1
  15. data/lib/avm/git/auto_commit/commit_info.rb +23 -0
  16. data/lib/avm/git/auto_commit/rules.rb +31 -0
  17. data/lib/avm/git/auto_commit/rules/base.rb +39 -0
  18. data/lib/avm/git/auto_commit/rules/last.rb +19 -0
  19. data/lib/avm/git/auto_commit/rules/manual.rb +45 -0
  20. data/lib/avm/git/auto_commit/rules/new.rb +24 -0
  21. data/lib/avm/git/auto_commit/rules/nth.rb +31 -0
  22. data/lib/avm/git/auto_commit/rules/unique.rb +21 -0
  23. data/lib/avm/git/auto_commit_path.rb +0 -21
  24. data/lib/avm/git/file_auto_fixup.rb +26 -57
  25. data/lib/avm/tools/runner/eac_redmine_base0/core_update.rb +7 -11
  26. data/lib/avm/tools/runner/git/auto_commit.rb +30 -31
  27. data/lib/avm/tools/runner/git/commit.rb +11 -20
  28. data/lib/avm/tools/runner/git/subrepo/fix.rb +1 -1
  29. data/lib/avm/tools/runner/local_project/ruby.rb +3 -7
  30. data/lib/avm/tools/runner/local_project/ruby/bundler.rb +1 -1
  31. data/lib/avm/tools/runner/local_project/ruby/bundler/gemfile_lock.rb +1 -1
  32. data/lib/avm/tools/runner/ruby.rb +6 -14
  33. data/lib/avm/tools/runner/ruby/gems.rb +4 -7
  34. data/lib/avm/tools/runner/ruby/gems/generate.rb +12 -23
  35. data/lib/avm/tools/runner/ruby/rubocop.rb +1 -1
  36. data/lib/avm/tools/version.rb +1 -1
  37. data/template/avm/eac_rails_base0/apache_path/extra_content.conf +5 -0
  38. data/template/avm/eac_webapp_base0/apache_path/default.conf +9 -0
  39. data/vendor/avm-apps/Gemfile +5 -0
  40. data/vendor/avm-apps/avm-apps.gemspec +18 -0
  41. data/vendor/avm-apps/lib/avm/apps.rb +9 -0
  42. data/vendor/avm-apps/lib/avm/apps/jobs.rb +11 -0
  43. data/vendor/avm-apps/lib/avm/apps/jobs/base.rb +64 -0
  44. data/vendor/avm-apps/lib/avm/apps/jobs/variables_source.rb +24 -0
  45. data/vendor/avm-apps/lib/avm/apps/version.rb +7 -0
  46. data/vendor/avm-apps/spec/rubocop_spec.rb +7 -0
  47. data/vendor/avm-apps/spec/spec_helper.rb +100 -0
  48. data/vendor/eac_cli/lib/eac_cli/core_ext.rb +2 -0
  49. data/vendor/eac_cli/lib/eac_cli/definition/alternative.rb +4 -7
  50. data/vendor/eac_cli/lib/eac_cli/definition/argument_option.rb +8 -0
  51. data/vendor/eac_cli/lib/eac_cli/definition/base_option.rb +21 -9
  52. data/vendor/eac_cli/lib/eac_cli/definition/base_option/initialize_args_parser.rb +47 -0
  53. data/vendor/eac_cli/lib/eac_cli/definition/boolean_option.rb +8 -0
  54. data/vendor/eac_cli/lib/eac_cli/definition/positional_argument.rb +12 -0
  55. data/vendor/eac_cli/lib/eac_cli/docopt/doc_builder.rb +15 -1
  56. data/vendor/eac_cli/lib/eac_cli/parser/alternative/short_options.rb +4 -2
  57. data/vendor/eac_cli/lib/eac_cli/parser/collector.rb +3 -17
  58. data/vendor/eac_cli/lib/eac_cli/patches/object/runner_with.rb +2 -1
  59. data/vendor/eac_cli/lib/eac_cli/runner_with_set.rb +50 -0
  60. data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
  61. data/vendor/eac_cli/spec/lib/eac_cli/definition/alternative_spec.rb +4 -0
  62. data/vendor/eac_cli/spec/lib/eac_cli/runner_spec.rb +21 -3
  63. data/vendor/eac_git/lib/eac_git/local/dirty_files.rb +2 -3
  64. data/vendor/eac_git/lib/eac_git/version.rb +1 -1
  65. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/core_ext.rb +4 -0
  66. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/jobs_runner.rb +31 -0
  67. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/patches.rb +4 -0
  68. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/patches/class.rb +4 -0
  69. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/patches/class/jobs_runner.rb +10 -0
  70. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/patches/object.rb +5 -0
  71. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/patches/object/runner_with.rb +5 -0
  72. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner_with.rb +9 -0
  73. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner_with/confirmation.rb +36 -0
  74. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner_with/filesystem_traverser.rb +52 -0
  75. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/version.rb +1 -1
  76. data/vendor/eac_ruby_base0/spec/lib/eac_ruby_base0/runner_with/confirmation_spec.rb +42 -0
  77. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/local_time_zone.rb +8 -2
  78. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/class/settings_provider.rb +10 -0
  79. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/if_nil.rb +17 -0
  80. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/time/required_zone.rb +11 -0
  81. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  82. metadata +60 -5
  83. data/lib/avm/tools/runner/eac_rails_base0/apache_path.rb +0 -38
  84. data/lib/avm/tools/runner/git/auto_fixup.rb +0 -53
  85. data/template/avm/eac_rails_base0/apache_path/default.conf +0 -13
@@ -7,22 +7,13 @@ require 'eac_ruby_utils/simple_cache'
7
7
  module Avm
8
8
  module EacWebappBase0
9
9
  class Runner < ::Avm::Instances::Runner
10
- class Data < ::EacRubyUtils::Console::DocoptRunner
11
- class Load < ::EacRubyUtils::Console::DocoptRunner
12
- include ::EacRubyUtils::SimpleCache
13
- include ::EacRubyUtils::Console::Speaker
14
-
15
- DOC = <<~DOCUMENT
16
- Load utility for EacRailsBase instance.
17
-
18
- Usage:
19
- __PROGRAM__ (<dump-path>|--source-instance=<source-instance>)
20
- __PROGRAM__ -h | --help
21
-
22
- Options:
23
- -h --help Show this screen.
24
- -S --source-instance=<source-instance> Informa a instância a ser extraída o dump.
25
- DOCUMENT
10
+ class Data
11
+ class Load
12
+ runner_with :ĥelp do
13
+ desc 'Load utility for EacRailsBase instance.'
14
+ arg_opt '-S', '--source-instance', 'Informa a instância a ser extraída o dump.'
15
+ pos_arg :dump_path, optional: true
16
+ end
26
17
 
27
18
  def run
28
19
  return ::Dev::Result.error("Dump \"#{dump_path}\" does not exist") unless
@@ -33,16 +24,14 @@ module Avm
33
24
  end
34
25
 
35
26
  def dump_path_uncached
36
- return options.fetch('<dump-path>').to_s if options.fetch('<dump-path>').present?
37
- return source_instance_dump_path if options.fetch('--source-instance').present?
27
+ return parsed.dump_path.to_s if parsed.dump_path.present?
28
+ return source_instance_dump_path if parsed.source_instance.present?
38
29
 
39
- raise "Dump path unknown (Options: #{options})"
30
+ raise "Dump path unknown (Options: #{parsed})"
40
31
  end
41
32
 
42
33
  def source_instance_dump_path
43
- context(:instance).class.by_id(
44
- options.fetch('--source-instance')
45
- ).data_dump
34
+ runner_context.call(:instance).class.by_id(parsed.source_instance).data_dump
46
35
  end
47
36
 
48
37
  def load_dump
@@ -57,7 +46,7 @@ module Avm
57
46
  private
58
47
 
59
48
  def package_load_uncached
60
- context(:instance).data_package.load(dump_path)
49
+ runner_context.call(:instance).data_package.load(dump_path)
61
50
  end
62
51
  end
63
52
  end
@@ -14,7 +14,7 @@ module Avm
14
14
 
15
15
  private
16
16
 
17
- %w[asciidoc docker file git latex php-cs-fixer tidy yapf xdg-open].each do |program|
17
+ %w[docker file git latex php-cs-fixer tidy yapf xdg-open].each do |program|
18
18
  define_method(program.underscore + '_uncached') do
19
19
  env.executable(program, '--version')
20
20
  end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Git
7
+ module AutoCommit
8
+ class CommitInfo
9
+ enable_immutable
10
+
11
+ immutable_accessor :fixup, :message
12
+
13
+ def git_commit_args
14
+ r = fixup.if_present([]) { |v| ['--fixup', v.sha1] }
15
+ r += message.if_present([]) { |v| ['--message', v] }
16
+ return r if r.any?
17
+
18
+ raise 'Argument list is empty'
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ ::EacRubyUtils.require_sub __FILE__
6
+
7
+ module Avm
8
+ module Git
9
+ module AutoCommit
10
+ module Rules
11
+ RULES_CLASSES = %w[last manual new nth unique]
12
+ .map { |key| ::Avm::Git::AutoCommit::Rules.const_get(key.camelcase) }
13
+
14
+ class << self
15
+ def parse(string)
16
+ parts = string.split(':')
17
+
18
+ klass = rule_class_by_key(parts.shift)
19
+ klass.new(*parts)
20
+ end
21
+
22
+ def rule_class_by_key(key)
23
+ RULES_CLASSES.find { |klass| klass.keys.include?(key) } ||
24
+ raise("Rule not find with key \"#{key}\" (Available: " +
25
+ RULES_CLASSES.flat_map(&:keys).join(', ') + ')')
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -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,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/git/auto_commit/rules/base'
4
+ require 'avm/git/auto_commit_path'
5
+
6
+ module Avm
7
+ module Git
8
+ module AutoCommit
9
+ module Rules
10
+ class New < ::Avm::Git::AutoCommit::Rules::Base
11
+ class WithFile < ::Avm::Git::AutoCommit::Rules::Base::WithFile
12
+ def auto_commit_path
13
+ ::Avm::Git::AutoCommitPath.new(file.git, file.path)
14
+ end
15
+
16
+ def commit_info
17
+ new_commit_info.message(auto_commit_path.commit_message)
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,31 @@
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
+ SHORT_KEY = 't'
11
+
12
+ class << self
13
+ def short_key
14
+ SHORT_KEY
15
+ end
16
+ end
17
+
18
+ common_constructor :number do
19
+ self.number = number.to_i
20
+ end
21
+
22
+ class WithFile < ::Avm::Git::AutoCommit::Rules::Base::WithFile
23
+ def commit_info
24
+ file.commits(number - 1).if_present { |v| new_commit_info.fixup(v) }
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ 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
@@ -6,31 +6,10 @@ module Avm
6
6
  module Git
7
7
  class AutoCommitPath
8
8
  require_sub __FILE__, include_modules: true
9
- enable_console_speaker
10
9
  common_constructor :git, :path do
11
10
  self.path = path.to_pathname
12
11
  end
13
12
 
14
- CLASS_NAME_PATTERNS = [%r{lib/((?!.*/lib/).+)\.rb\z}, %r{app/[^/]+/(.+)\.rb\z}].freeze
15
-
16
- def run
17
- banner
18
- commit
19
- end
20
-
21
- def banner
22
- infom "Checking \"#{relative_path}\""
23
- infov ' * Class name', class_name
24
- infov ' * Commit message', commit_message
25
- end
26
-
27
- def commit
28
- infom ' * Commiting...'
29
- git.system!('reset', 'HEAD')
30
- git.system!('add', '--', relative_path.to_path)
31
- git.system!('commit', '-m', commit_message, '--', relative_path.to_path)
32
- end
33
-
34
13
  def class_name
35
14
  ruby_class_name || relative_path.to_path
36
15
  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,30 @@ 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)
13
+ common_constructor :git, :path, :rules do
14
+ self.path = path.to_pathname.expand_path(git.root_path)
15
15
  end
16
16
 
17
- COMMIT_FORMAT = '%h - %s (%cr)'
18
17
  COMMITS_SEARCH_INTERVAL = 'origin/master..HEAD'
19
- SKIP_OPTION = 's'
18
+
19
+ def git_relative_path
20
+ path.to_pathname.relative_path_from(git.root_path)
21
+ end
20
22
 
21
23
  def run
22
24
  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
25
+ run_commit || warn("No rule returned commit information for \"#{path}\"")
30
26
  end
31
27
 
32
28
  private
33
29
 
34
- def auto_selected_commit_uncached
35
- selected_commit_by_unique || select_commit_by_select
30
+ def commit_args
31
+ commit_info.if_present([], &:git_commit_args) + ['--', git_relative_path]
32
+ end
33
+
34
+ def commit_info_uncached
35
+ rules.lazy.map { |rule| rule.with_file(self).commit_info }.find(&:present?)
36
36
  end
37
37
 
38
38
  def start_banner
@@ -40,50 +40,23 @@ module Avm
40
40
  infov ' Commits found', commits.count
41
41
  end
42
42
 
43
- def run_no_commits_found
44
- infom ' No commits found'
45
- end
43
+ def run_commit
44
+ return false if commit_info.blank?
46
45
 
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)}\""
46
+ infov ' Commit arguments', ::Shellwords.join(commit_args)
47
+ run_git_add_and_commit
48
+ success ' Commited'
49
+ true
51
50
  end
52
51
 
53
- def run_commits_selection
54
- selected_commit = select_commit
55
- if selected_commit
56
- fixup_commit(selected_commit)
52
+ def run_git_add_and_commit
53
+ git.execute!('reset', '--soft', 'HEAD')
54
+ if path.exist?
55
+ git.execute!('add', git_relative_path)
57
56
  else
58
- infom ' Skipped'
57
+ git.execute!('rm', '-f', git_relative_path)
59
58
  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
71
-
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
59
+ git.execute!('commit', *commit_args)
87
60
  end
88
61
 
89
62
  def commits_uncached
@@ -93,10 +66,6 @@ module Avm
93
66
  .each_with_index.map { |commit, index| CommitDelegator.new(commit, index) }
94
67
  end
95
68
 
96
- def format_commit(commit)
97
- commit.format(COMMIT_FORMAT)
98
- end
99
-
100
69
  class CommitDelegator < ::SimpleDelegator
101
70
  attr_reader :index
102
71