avm-tools 0.58.0 → 0.62.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/lib/avm/cached_download.rb +39 -0
  3. data/lib/avm/eac_redmine_base0/core_update.rb +110 -0
  4. data/lib/avm/eac_redmine_base0/data_unit.rb +27 -0
  5. data/lib/avm/eac_redmine_base0/deploy.rb +36 -0
  6. data/lib/avm/eac_redmine_base0/instance.rb +38 -0
  7. data/lib/avm/local_projects.rb +9 -0
  8. data/lib/avm/local_projects/instance.rb +35 -0
  9. data/lib/avm/local_projects/jobs/update.rb +29 -0
  10. data/lib/avm/projects.rb +9 -0
  11. data/lib/avm/projects/stereotype.rb +62 -0
  12. data/lib/avm/projects/stereotypes.rb +20 -0
  13. data/lib/avm/projects/stereotypes/git.rb +25 -0
  14. data/lib/avm/projects/stereotypes/git/local_project_mixin.rb +19 -0
  15. data/lib/avm/projects/stereotypes/git/publish.rb +15 -0
  16. data/lib/avm/projects/stereotypes/git/warp.rb +27 -0
  17. data/lib/avm/projects/stereotypes/git_subrepo.rb +34 -0
  18. data/lib/avm/projects/stereotypes/git_subrepo/publish.rb +14 -0
  19. data/lib/avm/projects/stereotypes/git_subrepo/warp.rb +87 -0
  20. data/lib/avm/projects/stereotypes/git_subtree.rb +51 -0
  21. data/lib/avm/projects/stereotypes/git_subtree/publish.rb +12 -0
  22. data/lib/avm/projects/stereotypes/git_subtree/warp.rb +29 -0
  23. data/lib/avm/projects/stereotypes/rails_application.rb +23 -0
  24. data/lib/avm/projects/stereotypes/redmine_plugin.rb +23 -0
  25. data/lib/avm/projects/stereotypes/ruby_gem.rb +30 -0
  26. data/lib/avm/projects/stereotypes/ruby_gem/local_project_mixin.rb +19 -0
  27. data/lib/avm/projects/stereotypes/ruby_gem/publish.rb +129 -0
  28. data/lib/avm/projects/stereotypes/ruby_gem/update.rb +59 -0
  29. data/lib/avm/sync.rb +94 -0
  30. data/lib/avm/tools/runner/eac_redmine_base0.rb +2 -2
  31. data/lib/avm/tools/runner/eac_redmine_base0/core_update.rb +67 -0
  32. data/lib/avm/tools/runner/eac_redmine_base0/deploy.rb +1 -1
  33. data/lib/avm/tools/runner/git/issue.rb +43 -4
  34. data/lib/avm/tools/runner/launcher.rb +10 -2
  35. data/lib/avm/tools/runner/launcher/instances.rb +45 -0
  36. data/lib/avm/tools/runner/launcher/projects.rb +50 -0
  37. data/lib/avm/tools/runner/launcher/publish.rb +65 -0
  38. data/lib/avm/tools/runner/local_project.rb +32 -0
  39. data/lib/avm/tools/runner/local_project/info.rb +25 -0
  40. data/lib/avm/tools/runner/local_project/update.rb +26 -0
  41. data/lib/avm/tools/version.rb +1 -1
  42. data/lib/eac_launcher.rb +1 -2
  43. data/lib/eac_launcher/context/instance_manager.rb +1 -0
  44. data/lib/eac_launcher/git/base/dirty_files.rb +5 -14
  45. data/lib/eac_launcher/git/publish_base.rb +1 -0
  46. data/lib/eac_launcher/git/sub_warp_base.rb +1 -1
  47. data/lib/eac_launcher/git/warp_base.rb +2 -2
  48. data/lib/eac_launcher/instances/base.rb +2 -2
  49. data/lib/eac_launcher/instances/runner_helper.rb +1 -1
  50. data/lib/eac_launcher/paths/logical.rb +2 -2
  51. data/vendor/eac_git/lib/eac_git/local.rb +1 -1
  52. data/vendor/eac_git/lib/eac_git/local/dirty_files.rb +38 -0
  53. data/vendor/eac_git/lib/eac_git/version.rb +1 -1
  54. data/vendor/eac_git/vendor/git-subrepo/lib/git-subrepo.d/bash+.bash +1 -1
  55. data/vendor/eac_ruby_gems_utils/LICENCE +16 -674
  56. data/vendor/eac_ruby_gems_utils/eac_ruby_gems_utils.gemspec +10 -2
  57. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/gem.rb +2 -1
  58. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/version.rb +1 -1
  59. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/boolean.rb +31 -0
  60. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner/_class_methods.rb +1 -1
  61. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env.rb +10 -18
  62. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env/dasho_options.rb +53 -0
  63. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env/identity_file.rb +25 -0
  64. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env/quiet.rb +24 -0
  65. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env/terminal.rb +34 -0
  66. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/list.rb +5 -0
  67. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/require_sub.rb +8 -8
  68. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  69. metadata +52 -28
  70. data/lib/avm/stereotypes/eac_redmine_base0/data_unit.rb +0 -29
  71. data/lib/avm/stereotypes/eac_redmine_base0/deploy.rb +0 -38
  72. data/lib/avm/stereotypes/eac_redmine_base0/instance.rb +0 -40
  73. data/lib/eac_launcher/runner.rb +0 -21
  74. data/lib/eac_launcher/runner/instances.rb +0 -41
  75. data/lib/eac_launcher/runner/projects.rb +0 -46
  76. data/lib/eac_launcher/runner/publish.rb +0 -59
  77. data/lib/eac_launcher/stereotype.rb +0 -52
  78. data/lib/eac_launcher/stereotypes.rb +0 -14
  79. data/lib/eac_launcher/stereotypes/git.rb +0 -21
  80. data/lib/eac_launcher/stereotypes/git/publish.rb +0 -13
  81. data/lib/eac_launcher/stereotypes/git/warp.rb +0 -25
  82. data/lib/eac_launcher/stereotypes/git_subrepo.rb +0 -30
  83. data/lib/eac_launcher/stereotypes/git_subrepo/publish.rb +0 -12
  84. data/lib/eac_launcher/stereotypes/git_subrepo/warp.rb +0 -85
  85. data/lib/eac_launcher/stereotypes/git_subtree.rb +0 -47
  86. data/lib/eac_launcher/stereotypes/git_subtree/publish.rb +0 -10
  87. data/lib/eac_launcher/stereotypes/git_subtree/warp.rb +0 -27
  88. data/lib/eac_launcher/stereotypes/rails.rb +0 -21
  89. data/lib/eac_launcher/stereotypes/redmine_plugin.rb +0 -21
  90. data/lib/eac_launcher/stereotypes/ruby_gem.rb +0 -27
  91. data/lib/eac_launcher/stereotypes/ruby_gem/publish.rb +0 -127
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Projects
7
+ module Stereotypes
8
+ class RubyGem
9
+ class Update
10
+ enable_console_speaker
11
+ common_constructor :instance
12
+
13
+ def run
14
+ gemfile_lock_checkout
15
+ bundle_update
16
+ gemfile_lock_commit
17
+ end
18
+
19
+ private
20
+
21
+ def bundle_update
22
+ infom 'Running "bundle update"...'
23
+ instance.ruby_gem.bundle('update').execute!
24
+ infom 'Running "bundle install"...'
25
+ instance.ruby_gem.bundle('install').execute!
26
+ end
27
+
28
+ def gemfile_lock_checkout
29
+ return unless instance.respond_to?(:git_repo)
30
+
31
+ infom 'Checkouting Gemfile.lock...'
32
+ instance.git_repo.command('checkout', '--',
33
+ instance.ruby_gem.gemfile_lock_path.to_path).execute!
34
+ end
35
+
36
+ def gemfile_lock_commit
37
+ return unless instance.respond_to?(:git_repo)
38
+
39
+ if gemfile_lock_changed?
40
+ infom 'Commiting Gemfile.lock...'
41
+ instance.git_repo.command('commit', '-m', gemfile_lock_commit_message, '--',
42
+ instance.ruby_gem.gemfile_lock_path).execute!
43
+ else
44
+ infom 'Gemfile.lock did not change'
45
+ end
46
+ end
47
+
48
+ def gemfile_lock_commit_message
49
+ 'Todas as gems: atualiza.'
50
+ end
51
+
52
+ def gemfile_lock_changed?
53
+ instance.git_repo.dirty_file?(instance.ruby_gem.gemfile_lock_path)
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,94 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ class Sync
7
+ attr_reader :excludes, :includes
8
+
9
+ common_constructor :source_path, :target_path do
10
+ self.source_path = source_path.to_pathname
11
+ self.target_path = target_path.to_pathname
12
+ @excludes = []
13
+ @includes = []
14
+ end
15
+
16
+ def run
17
+ clear_target
18
+ copy
19
+ end
20
+
21
+ def add_exclude(exclude)
22
+ excludes << exclude
23
+
24
+ self
25
+ end
26
+
27
+ def add_excludes(*excludes)
28
+ excludes.each { |exclude| add_exclude(exclude) }
29
+
30
+ self
31
+ end
32
+
33
+ def add_include(include)
34
+ includes << include
35
+
36
+ self
37
+ end
38
+
39
+ def add_includes(*includes)
40
+ includes.each { |include| add_include(include) }
41
+
42
+ self
43
+ end
44
+
45
+ def move_mode(value)
46
+ @move_mode = value
47
+
48
+ self
49
+ end
50
+
51
+ def move_mode?
52
+ @move_mode ? true : false
53
+ end
54
+
55
+ private
56
+
57
+ def clear_target
58
+ target_remove(target_path)
59
+ target_path.children.each { |tchild| target_remove(tchild) }
60
+ end
61
+
62
+ def copy
63
+ source_path.children.each do |schild|
64
+ ::FileUtils.cp_r(schild.to_path, target_path.to_path)
65
+ schild.rmtree if move_mode?
66
+ end
67
+ end
68
+
69
+ def source_to_target_path(source_path)
70
+ source_path.relative_path_from(self.source_path).expand_path(target_path)
71
+ end
72
+
73
+ def target_remove(tpath)
74
+ return if skip_target_path?(tpath)
75
+
76
+ if tpath.directory?
77
+ tpath.children.each { |tchild| target_remove(tchild) }
78
+ tpath.rmdir if tpath.children.empty?
79
+ elsif tpath.file?
80
+ tpath.unlink
81
+ end
82
+ end
83
+
84
+ def skip_target_path?(tpath)
85
+ skip_path?(tpath.relative_path_from(target_path))
86
+ end
87
+
88
+ def skip_path?(relpath)
89
+ relpath = relpath.expand_path('/')
90
+ excludes.any? { |exclude| relpath.fnmatch?(exclude) } &&
91
+ includes.none? { |include| relpath.fnmatch?(include) }
92
+ end
93
+ end
94
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'eac_ruby_utils/console/docopt_runner'
4
4
  require 'eac_ruby_utils/simple_cache'
5
- require 'avm/stereotypes/eac_redmine_base0/instance'
5
+ require 'avm/eac_redmine_base0/instance'
6
6
  require 'eac_ruby_utils/require_sub'
7
7
  ::EacRubyUtils.require_sub(__FILE__)
8
8
 
@@ -26,7 +26,7 @@ module Avm
26
26
  private
27
27
 
28
28
  def instance_uncached
29
- ::Avm::Stereotypes::EacRedmineBase0::Instance.by_id(options['<instance_id>'])
29
+ ::Avm::EacRedmineBase0::Instance.by_id(options['<instance_id>'])
30
30
  end
31
31
  end
32
32
  end
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/eac_redmine_base0/core_update'
4
+ require 'eac_cli/default_runner'
5
+ require 'eac_ruby_utils/console/docopt_runner'
6
+ require 'eac_ruby_utils/core_ext'
7
+
8
+ module Avm
9
+ module Tools
10
+ class Runner < ::EacRubyUtils::Console::DocoptRunner
11
+ class EacRedmineBase0 < ::EacRubyUtils::Console::DocoptRunner
12
+ class CoreUpdate < ::EacRubyUtils::Console::DocoptRunner
13
+ include ::EacCli::DefaultRunner
14
+
15
+ runner_definition do
16
+ arg_opt '-u', '--url', 'Core\'s package URL.'
17
+ arg_opt '-v', '--version', 'Core\'s version.'
18
+ desc 'Update instance\' core.'
19
+ end
20
+
21
+ def run
22
+ start_banner
23
+ validate
24
+ update
25
+ end
26
+
27
+ private
28
+
29
+ def start_banner
30
+ infov 'URL', url
31
+ infov 'Version', version
32
+ end
33
+
34
+ def update
35
+ ::Avm::EacRedmineBase0::CoreUpdate.new(context(:instance), version, url).run
36
+ end
37
+
38
+ def url
39
+ options.fetch('--url') || url_by_version
40
+ end
41
+
42
+ def url_by_version
43
+ options.fetch('--version').if_present do |v|
44
+ "https://www.redmine.org/releases/redmine-#{v}.tar.gz"
45
+ end
46
+ end
47
+
48
+ def validate
49
+ %w[url version].each do |attr|
50
+ fatal_error "\"#{attr}\" is blank. See avaiable options." if send(attr).blank?
51
+ end
52
+ end
53
+
54
+ def version
55
+ options.fetch('--version') || version_by_url
56
+ end
57
+
58
+ def version_by_url
59
+ options.fetch('--url').if_present do |v|
60
+ /(\d+.\d+.\d+)/.if_match(v, false) { |m| m[1] }
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avm/stereotypes/eac_redmine_base0/deploy'
3
+ require 'avm/eac_redmine_base0/deploy'
4
4
  require 'avm/stereotypes/eac_webapp_base0/runner/deploy'
5
5
 
6
6
  module Avm
@@ -9,6 +9,7 @@ module Avm
9
9
  class Runner < ::EacRubyUtils::Console::DocoptRunner
10
10
  class Git < ::EacRubyUtils::Console::DocoptRunner
11
11
  class Issue < ::EacRubyUtils::Console::DocoptRunner
12
+ enable_simple_cache
12
13
  include ::EacRubyUtils::Console::Speaker
13
14
 
14
15
  DOC = <<~DOCOPT
@@ -20,6 +21,8 @@ module Avm
20
21
 
21
22
  Options:
22
23
  -h --help Show this screen.
24
+ -f --uncomplete-unfail Do not exit with error if issue is not completed
25
+ or is invalid.
23
26
  -s --skip-validations=<validations> Does not validate conditions on <validations>
24
27
  (Comma separated value).
25
28
  -y --yes Does not ask for user confirmation.
@@ -28,11 +31,30 @@ module Avm
28
31
  %%VALIDATIONS%%
29
32
  DOCOPT
30
33
 
31
- def run
32
- complete = ::Avm::Git::Issue::Complete.new(git_complete_issue_options)
34
+ UNCOMPLETE_MESSAGE =
35
+
36
+ def run
37
+ banner
38
+ return unless validate
39
+
40
+ run_complete if options.fetch('complete')
41
+ success('Done!')
42
+ end
43
+
44
+ def banner
33
45
  complete.start_banner
34
- fatal_error('Some validation did not pass') unless complete.valid?
35
- complete.run if options.fetch('complete') && confirm?
46
+ end
47
+
48
+ def validate
49
+ return true if complete.valid?
50
+
51
+ uncomplete_message('Some validation did not pass')
52
+ end
53
+
54
+ def run_complete
55
+ return complete.run if confirm?
56
+
57
+ uncomplete_message('Issue was not completed')
36
58
  end
37
59
 
38
60
  def doc
@@ -41,6 +63,10 @@ module Avm
41
63
 
42
64
  private
43
65
 
66
+ def complete_uncached
67
+ ::Avm::Git::Issue::Complete.new(git_complete_issue_options)
68
+ end
69
+
44
70
  def confirm?
45
71
  options.fetch('--yes') || request_input('Confirm issue completion?', bool: true)
46
72
  end
@@ -56,6 +82,19 @@ module Avm
56
82
  def doc_validations_list
57
83
  ::Avm::Git::Issue::Complete::VALIDATIONS.keys.map { |k| " * #{k}" }.join("\n")
58
84
  end
85
+
86
+ def uncomplete_unfail?
87
+ options.fetch('--uncomplete-unfail')
88
+ end
89
+
90
+ def uncomplete_message(message)
91
+ if uncomplete_unfail?
92
+ warn(message)
93
+ else
94
+ fatal_error(message)
95
+ end
96
+ false
97
+ end
59
98
  end
60
99
  end
61
100
  end
@@ -1,11 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_launcher/runner'
3
+ require 'eac_cli/default_runner'
4
+ require 'eac_ruby_utils/core_ext'
4
5
 
5
6
  module Avm
6
7
  module Tools
7
8
  class Runner < ::EacRubyUtils::Console::DocoptRunner
8
- class Launcher < ::EacLauncher::Runner
9
+ class Launcher < ::EacRubyUtils::Console::DocoptRunner
10
+ require_sub __FILE__
11
+ include ::EacCli::DefaultRunner
12
+
13
+ runner_definition do
14
+ desc 'Utilities to deploy applications and libraries.'
15
+ subcommands
16
+ end
9
17
  end
10
18
  end
11
19
  end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_launcher/instances/runner_helper'
4
+
5
+ module Avm
6
+ module Tools
7
+ class Runner < ::EacRubyUtils::Console::DocoptRunner
8
+ class Launcher < ::EacRubyUtils::Console::DocoptRunner
9
+ class Instances < ::EacLauncher::Instances::RunnerHelper
10
+ DOC = <<~DOCOPT
11
+ Mostra informações sobre instâncias.
12
+
13
+ Usage:
14
+ __PROGRAM__ [options] [<instance_path>...]
15
+ __PROGRAM__ -h | --help
16
+
17
+ Options:
18
+ -h --help Show this screen.
19
+ --all Get all instances.
20
+ --recache Rewrite instances cache.
21
+
22
+ DOCOPT
23
+
24
+ def run
25
+ ::EacLauncher::Context.current.recache = options['--recache']
26
+ instances.each { |i| show_instance(i) }
27
+ end
28
+
29
+ private
30
+
31
+ def show_instance(instance)
32
+ puts instance_label(instance)
33
+ infov(' * Parent', (instance.parent ? instance_label(instance.parent) : '-'))
34
+ infov(' * Git current revision', instance.options.git_current_revision)
35
+ infov(' * Git publish remote', instance.options.git_publish_remote)
36
+ end
37
+
38
+ def instance_path
39
+ options['<instance_path>']
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_launcher/context'
4
+ require 'eac_launcher/instances/runner_helper'
5
+
6
+ module Avm
7
+ module Tools
8
+ class Runner < ::EacRubyUtils::Console::DocoptRunner
9
+ class Launcher < ::EacRubyUtils::Console::DocoptRunner
10
+ class Projects < ::EacLauncher::Instances::RunnerHelper
11
+ DOC = <<~DOCOPT
12
+ Shows available projects.
13
+
14
+ Usage:
15
+ __PROGRAM__ [options]
16
+ __PROGRAM__ -h | --help
17
+
18
+ Options:
19
+ -h --help Show this screen.
20
+ -i --instances Show instances.
21
+ --recache Rewrite instances cache.
22
+
23
+ DOCOPT
24
+
25
+ def run
26
+ ::EacLauncher::Context.current.recache = options['--recache']
27
+ ::EacLauncher::Context.current.projects.each do |p|
28
+ show_project(p)
29
+ end
30
+ end
31
+
32
+ private
33
+
34
+ def show_project(project)
35
+ puts project_label(project)
36
+ return unless options['--instances']
37
+
38
+ project.instances.each do |i|
39
+ puts " * #{instance_label(i)}"
40
+ end
41
+ end
42
+
43
+ def project_label(project)
44
+ project.to_s.cyan.to_s
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end