avm-tools 0.76.1 → 0.81.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/lib/avm/eac_rails_base1/runner/code_runner.rb +1 -2
  3. data/lib/avm/eac_rails_base1/runner/rails_server.rb +33 -0
  4. data/lib/avm/patches/class/i18n.rb +31 -0
  5. data/lib/avm/patches/object/i18n.rb +2 -10
  6. data/lib/avm/projects/stereotypes/ruby_gem/update.rb +4 -1
  7. data/lib/avm/projects/stereotypes/ruby_gem/version_bump.rb +1 -2
  8. data/lib/avm/tools/runner/git/subrepo/clone.rb +84 -0
  9. data/lib/avm/tools/runner/git/subrepo/fix.rb +65 -0
  10. data/lib/avm/tools/version.rb +1 -1
  11. data/template/avm/eac_redmine_base0/deploy/config/install.sh.template +12 -0
  12. data/vendor/eac_cli/eac_cli.gemspec +1 -1
  13. data/vendor/eac_cli/lib/eac_cli/definition.rb +34 -39
  14. data/vendor/eac_cli/lib/eac_cli/definition/alternative.rb +83 -0
  15. data/vendor/eac_cli/lib/eac_cli/docopt/doc_builder.rb +18 -40
  16. data/vendor/eac_cli/lib/eac_cli/docopt/doc_builder/alternative.rb +50 -0
  17. data/vendor/eac_cli/lib/eac_cli/parser.rb +23 -3
  18. data/vendor/eac_cli/lib/eac_cli/parser/alternative.rb +92 -0
  19. data/vendor/eac_cli/lib/eac_cli/parser/alternative/argv.rb +17 -0
  20. data/vendor/eac_cli/lib/eac_cli/parser/alternative/double_dash.rb +24 -0
  21. data/vendor/eac_cli/lib/eac_cli/parser/alternative/options.rb +58 -0
  22. data/vendor/eac_cli/lib/eac_cli/parser/alternative/positionals.rb +30 -0
  23. data/vendor/eac_cli/lib/eac_cli/runner.rb +12 -4
  24. data/vendor/eac_cli/lib/eac_cli/runner/exit.rb +13 -0
  25. data/vendor/eac_cli/lib/eac_cli/runner_with/help.rb +16 -1
  26. data/vendor/eac_cli/lib/eac_cli/runner_with/output_file.rb +5 -1
  27. data/vendor/eac_cli/lib/eac_cli/runner_with/subcommands.rb +1 -1
  28. data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
  29. data/vendor/eac_cli/spec/lib/eac_cli/definition/alternative_spec.rb +14 -0
  30. data/vendor/eac_cli/spec/lib/eac_cli/docopt/runner_extension_spec.rb +10 -0
  31. data/vendor/eac_cli/spec/lib/eac_cli/parser/alternative_spec.rb +140 -0
  32. data/vendor/eac_cli/spec/lib/eac_cli/runner_spec.rb +17 -5
  33. data/vendor/eac_cli/spec/lib/eac_cli/runner_with/help_spec.rb +42 -0
  34. data/vendor/eac_cli/spec/lib/eac_cli/runner_with/output_file_spec.rb +53 -0
  35. data/vendor/eac_cli/spec/lib/eac_cli/runner_with/subcommands_spec.rb +0 -1
  36. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/application.rb +32 -1
  37. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner.rb +1 -1
  38. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/version.rb +1 -1
  39. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/abstract_methods.rb +60 -0
  40. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern.rb +2 -50
  41. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern/class_setup.rb +52 -0
  42. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern/module_setup.rb +31 -0
  43. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor.rb +53 -0
  44. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs.rb +4 -69
  45. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/entry_reader.rb +81 -0
  46. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/password_entry_reader.rb +18 -0
  47. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/read_entry_options.rb +7 -2
  48. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/store_passwords_entry_reader.rb +27 -0
  49. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command.rb +4 -6
  50. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command/concat.rb +33 -0
  51. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command/envvars.rb +24 -0
  52. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command/extra_options.rb +0 -21
  53. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/abstract_methods.rb +10 -0
  54. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/struct.rb +7 -1
  55. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  56. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/yaml.rb +3 -2
  57. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/abstract_methods_spec.rb +28 -0
  58. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb +30 -17
  59. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_constructor_spec.rb +66 -8
  60. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/struct_spec.rb +12 -1
  61. metadata +28 -7
  62. data/lib/avm/tools/runner/eac_rails_base0/rails_server.rb +0 -36
  63. data/lib/avm/tools/runner/eac_rails_base0/runner.rb +0 -14
  64. data/vendor/eac_cli/lib/eac_cli/parser/options_collection.rb +0 -68
  65. data/vendor/eac_cli/lib/eac_cli/parser/parse_result.rb +0 -38
  66. data/vendor/eac_cli/lib/eac_cli/parser/positional_collection.rb +0 -77
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cd41b3c790de4a2264c78b5daa5afbd469de6ba2e74b616f096619d0a7bc5460
4
- data.tar.gz: 0a1890b253e90debb2951fe90193fef541df4c4d0701dcf82712696377b1adbe
3
+ metadata.gz: a429748d11abc010cc9622597d60e36016b008c88e6e95e8efd52bd03b8318ae
4
+ data.tar.gz: f126c1dd4af4370ad13f398d4aaefc9252ae8b1580e87ea08aed0debeaea652e
5
5
  SHA512:
6
- metadata.gz: 2ebb73966071bb959e16f10f37b784971f65b3f2cfede241fe4b02c127f24d057bbaedec098e900b8b69edf55e5951637f905a07d5a242d0b7bfd7b51907a3be
7
- data.tar.gz: 510d2e7625a10c523269684a6e269212a5d8b027d671dc38e337be9c1015d9c69d4ba8f78049ee13090a9e6c733fabfd6b5d40541b6ddbd1e86cd8b4e524ba7c
6
+ metadata.gz: 5ee2c425e977acaded7b64f05088817765b523f4459a3dcac1fed0b0be4d85d8b25b34843a824c2cff3c7446a06319835b73fbcaff05b1d36f4ec45b37496bf7
7
+ data.tar.gz: 6687e21a992f5bbc6e992ceb4fa74900d16b1a16dba9d71400dd1c61d4e5e9e66e4265706b161bf9b0ae896354b292bf64361c531da3d01034e3b9d4bd2c4f85
@@ -8,8 +8,7 @@ module Avm
8
8
  module EacRailsBase1
9
9
  class Runner < ::Avm::EacWebappBase0::Runner
10
10
  class CodeRunner
11
- runner_with ::Avm::EacRailsBase1::RunnerWith::Bundle
12
- runner_definition do
11
+ runner_with :help, ::Avm::EacRailsBase1::RunnerWith::Bundle do
13
12
  desc 'Runs a Ruby code with "rails runner".'
14
13
  pos_arg :code
15
14
  end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/eac_rails_base1/runner_with/bundle'
4
+ require 'avm/instances/entry_keys'
5
+ require 'eac_cli/core_ext'
6
+ require 'eac_ruby_utils/console/docopt_runner'
7
+ require 'shellwords'
8
+
9
+ module Avm
10
+ module EacRailsBase1
11
+ class Runner < ::Avm::EacWebappBase0::Runner
12
+ class RailsServer
13
+ DEFAULT_RAILS_ENVIRONMENT = 'development'
14
+ runner_with :help, ::Avm::EacRailsBase1::RunnerWith::Bundle do
15
+ desc 'Run the embbeded Rails web server.'
16
+ end
17
+
18
+ def run
19
+ infov 'Environment', rails_environment
20
+ infov 'Bundle args', ::Shellwords.join(bundle_args)
21
+ infov 'Result', bundle_command.system
22
+ end
23
+
24
+ protected
25
+
26
+ def bundle_args
27
+ ['exec', 'rails', 'server', '--port',
28
+ runner_context.call(:instance).read_entry(::Avm::Instances::EntryKeys::WEB_PORT)]
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/patches/i18n'
4
+
5
+ class Class
6
+ TRANSLATE_LOCALE_KEY = :__locale
7
+
8
+ def translate(entry_suffix, values = {})
9
+ on_i18n_locale(values.delete(TRANSLATE_LOCALE_KEY)) do
10
+ ::I18n.translate(translate_entry_full(entry_suffix), values)
11
+ end
12
+ end
13
+
14
+ def translate_entry_full(entry_suffix)
15
+ "#{translate_entry_self_prefix}.#{entry_suffix}"
16
+ end
17
+
18
+ def translate_entry_self_prefix
19
+ name.underscore.gsub('/', '.')
20
+ end
21
+
22
+ def on_i18n_locale(locale)
23
+ old_locale = ::I18n.locale
24
+ begin
25
+ ::I18n.locale = locale
26
+ yield
27
+ ensure
28
+ ::I18n.locale = old_locale
29
+ end
30
+ end
31
+ end
@@ -1,17 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avm/patches/i18n'
3
+ require 'avm/patches/class/i18n'
4
4
 
5
5
  class Object
6
6
  def translate(entry_suffix, values = {})
7
- ::I18n.translate(translate_entry_full(entry_suffix), values)
8
- end
9
-
10
- def translate_entry_full(entry_suffix)
11
- "#{translate_entry_self_prefix}.#{entry_suffix}"
12
- end
13
-
14
- def translate_entry_self_prefix
15
- self.class.name.underscore.gsub('/', '.')
7
+ self.class.translate(entry_suffix, values)
16
8
  end
17
9
  end
@@ -1,12 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'eac_ruby_utils/core_ext'
4
+ require 'avm/patches/class/i18n'
4
5
 
5
6
  module Avm
6
7
  module Projects
7
8
  module Stereotypes
8
9
  class RubyGem
9
10
  class Update
11
+ TRANSLATE_CLASS = self
12
+
10
13
  enable_console_speaker
11
14
  common_constructor :instance
12
15
 
@@ -46,7 +49,7 @@ module Avm
46
49
  end
47
50
 
48
51
  def gemfile_lock_commit_message
49
- 'Todas as gems: atualiza.'
52
+ TRANSLATE_CLASS.translate(__method__, __locale: instance.locale)
50
53
  end
51
54
 
52
55
  def gemfile_lock_changed?
@@ -47,8 +47,7 @@ module Avm
47
47
  end
48
48
 
49
49
  def git_commit_message
50
- ::I18n.default_locale = instance.locale
51
- translate(__method__, version: target_version)
50
+ translate(__method__, version: target_version, __locale: instance.locale)
52
51
  end
53
52
 
54
53
  def changing_files
@@ -0,0 +1,84 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/core_ext'
4
+ require 'eac_git/local'
5
+ require 'eac_ruby_utils/console/docopt_runner'
6
+
7
+ module Avm
8
+ module Tools
9
+ class Runner < ::EacRubyUtils::Console::DocoptRunner
10
+ class Git < ::EacRubyUtils::Console::DocoptRunner
11
+ class Subrepo < ::EacRubyUtils::Console::DocoptRunner
12
+ class Clone
13
+ runner_with :help do
14
+ desc 'Clone git-subrepo repositories.'
15
+ arg_opt '-b', '--branch', 'Branch.'
16
+ arg_opt '-d', '--parent-dir', 'Target path\'s parent directory.'
17
+ pos_arg :url
18
+ pos_arg :target_path, optional: true
19
+ end
20
+
21
+ def run
22
+ start_banner
23
+ clean
24
+ clone
25
+ end
26
+
27
+ private
28
+
29
+ def start_banner
30
+ infov 'URL', url
31
+ infov 'Subpath', target_path
32
+ infov 'Branch', branch
33
+ end
34
+
35
+ def clean
36
+ infom 'Cleaning...'
37
+ git.command('subrepo', 'clean', '--all', '--force').system!
38
+ end
39
+
40
+ def clone
41
+ infom 'Cloning...'
42
+ infov 'Clone arguments', clone_args
43
+ git.command(*clone_args).system!
44
+ end
45
+
46
+ delegate :branch, :url, to: :parsed
47
+
48
+ def git_uncached
49
+ ::EacGit::Local.new('.')
50
+ end
51
+
52
+ def clone_args
53
+ ['subrepo'] + branch.if_present([]) { |v| ['--branch', v] } +
54
+ if ::File.exist?(target_path)
55
+ ['init', target_path, '--remote', url]
56
+ else
57
+ ['clone', url, target_path, '--message', clone_message, '--force']
58
+ end
59
+ end
60
+
61
+ def clone_message
62
+ "Subrepo \"#{target_path}\" (#{url})."
63
+ end
64
+
65
+ def repos_name_from_url
66
+ %r{/([^/]+)\z}.if_match(url, false) { |m| m[1].gsub(/\.git\z/, '') }
67
+ end
68
+
69
+ def target_path
70
+ parsed.target_path || target_path_from_parent_dir ||
71
+ fatal_error('No target path specified')
72
+ end
73
+
74
+ def target_path_from_parent_dir
75
+ return nil unless parsed.parent_dir && repos_name_from_url
76
+
77
+ ::File.join(parsed.parent_dir, repos_name_from_url)
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/core_ext'
4
+ require 'eac_git/local'
5
+ require 'eac_ruby_utils/console/docopt_runner'
6
+
7
+ module Avm
8
+ module Tools
9
+ class Runner < ::EacRubyUtils::Console::DocoptRunner
10
+ class Git < ::EacRubyUtils::Console::DocoptRunner
11
+ class Subrepo < ::EacRubyUtils::Console::DocoptRunner
12
+ class Fix
13
+ runner_with :help do
14
+ desc 'Fix git-subrepos\' parent property.'
15
+ end
16
+
17
+ def run
18
+ loop do
19
+ break if fix
20
+
21
+ amend_each
22
+ rebase_fixup
23
+ end
24
+ end
25
+
26
+ private
27
+
28
+ def amend_each
29
+ infov 'Dirty files', local_repos.dirty_files.count
30
+ local_repos.dirty_files.each do |file|
31
+ infov ' * Ammending', file.path
32
+ ::Avm::Git::FileAutoFixup.new(runner_context.call(:git), file.path).run
33
+ end
34
+ end
35
+
36
+ def fix
37
+ infom 'Checking/fixing...'
38
+ c = new_check(true)
39
+ c.show_result
40
+ !c.result.error?
41
+ end
42
+
43
+ def new_check(fix_parent = false)
44
+ r = ::Avm::Git::SubrepoChecks.new(local_repos).add_all_subrepos
45
+ r.fix_parent = fix_parent
46
+ r
47
+ end
48
+
49
+ def local_repos_uncached
50
+ ::EacGit::Local.new(runner_context.call(:git))
51
+ end
52
+
53
+ def rebase_fixup
54
+ local_repos.command('rebase', '-i', 'origin/master', '--autosquash').envvar(
55
+ 'GIT_SEQUENCE_EDITOR', 'true'
56
+ ).or(
57
+ local_repos.command('rebase', '--continue').envvar('GIT_SEQUENCE_EDITOR', 'true')
58
+ ).system!
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module Tools
5
- VERSION = '0.76.1'
5
+ VERSION = '0.81.0'
6
6
  end
7
7
  end
@@ -12,3 +12,15 @@ fi
12
12
  export address_host='%%WEB.AUTHORITY%%'
13
13
  export address_path='%%WEB.PATH%%'
14
14
  export git_repositories_hierarchical_organisation=false
15
+
16
+ # Mail settings
17
+ export smtp_server='%%MAILER.SMTP.ADDRESS%%'
18
+ export smtp_port='%%MAILER.SMTP.PORT%%'
19
+ export smtp_domain='%%MAILER.SMTP.DOMAIN%%'
20
+ export smtp_tls='%%MAILER_SMTP_TLS%%'
21
+ export smtp_enable_starttls_auto='%%MAILER_SMTP_STARTTLS_AUTO%%'
22
+ export smtp_openssl_verify_mode='%%MAILER_SMTP_OPENSSL_VERIFY_MODE%%'
23
+ export smtp_authentication='%%MAILER.SMTP.AUTHENTICATION%%'
24
+ export smtp_username='%%MAILER.SMTP.USERNAME%%'
25
+ export smtp_password='%%MAILER.SMTP.PASSWORD%%'
26
+ export mail_from='%%MAILER.FROM%%'
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
 
13
13
  s.files = Dir['{lib}/**/*', 'Gemfile']
14
14
 
15
- s.add_dependency 'eac_ruby_utils', '~> 0.50'
15
+ s.add_dependency 'eac_ruby_utils', '~> 0.55'
16
16
 
17
17
  s.add_development_dependency 'eac_ruby_gem_support', '~> 0.1', '>= 0.1.2'
18
18
  end
@@ -9,36 +9,30 @@ module EacCli
9
9
  class Definition
10
10
  require_sub __FILE__
11
11
 
12
+ MAIN_ALTERNATIVE_KEY = :main
12
13
  SUBCOMMAND_NAME_ARG = 'subcommand'
13
14
  SUBCOMMAND_ARGS_ARG = 'subcommand_args'
14
15
 
15
16
  attr_accessor :description
16
- attr_accessor :options_argument
17
17
 
18
18
  def initialize
19
19
  self.description = '-- NO DESCRIPTION SET --'
20
- self.options_argument = true
20
+ alternatives_set[MAIN_ALTERNATIVE_KEY] = main_alternative
21
21
  end
22
22
 
23
23
  def alt(&block)
24
- r = ::EacCli::Definition.new
24
+ r = ::EacCli::Definition::Alternative.new
25
25
  r.instance_eval(&block)
26
- alternatives << r
26
+ alternatives_set[new_alternative_key] = r
27
27
  r
28
28
  end
29
29
 
30
30
  def alternatives
31
- @alternatives ||= []
31
+ alternatives_set.values
32
32
  end
33
33
 
34
- def arg_opt(short, long, description, option_options = {})
35
- options << ::EacCli::Definition::ArgumentOption.new(
36
- short, long, description, option_options
37
- )
38
- end
39
-
40
- def bool_opt(short, long, description, option_options = {})
41
- options << ::EacCli::Definition::BooleanOption.new(short, long, description, option_options)
34
+ def alternative(key)
35
+ alternatives_set.fetch(key)
42
36
  end
43
37
 
44
38
  def desc(description)
@@ -49,42 +43,31 @@ module EacCli
49
43
  @help_formatter ||= ::EacCli::Definition::HelpFormatter.new(self)
50
44
  end
51
45
 
52
- def options_arg(options_argument)
53
- self.options_argument = options_argument
54
- end
55
-
56
- def options
57
- @options ||= []
46
+ def main_alternative
47
+ @main_alternative ||= begin
48
+ r = ::EacCli::Definition::Alternative.new
49
+ r.options_argument(true)
50
+ r
51
+ end
58
52
  end
59
53
 
60
- def pos_arg(name, arg_options = {})
61
- new_pos_arg = ::EacCli::Definition::PositionalArgument.new(name, arg_options)
62
- raise 'Positional arguments are blocked' if positional_arguments_blocked?(new_pos_arg)
63
-
64
- pos_set << new_pos_arg
54
+ def options_arg(options_argument)
55
+ self.options_argument = options_argument
65
56
  end
66
57
 
67
- def positional
68
- pos_set.to_a
58
+ def options_argument
59
+ main_alternative.options_argument?
69
60
  end
70
61
 
71
- def positional_arguments_blocked?(new_pos_arg)
72
- last = pos_set.last
73
- return false unless last
74
- return true if last.repeat?
75
- return true if last.optional? && new_pos_arg.required?
76
-
77
- false
62
+ def options_argument=(enable)
63
+ main_alternative.options_argument(enable)
78
64
  end
79
65
 
80
- def subcommands
81
- pos_arg(SUBCOMMAND_NAME_ARG, subcommand: true)
82
- pos_set << ::EacCli::Definition::PositionalArgument.new(SUBCOMMAND_ARGS_ARG,
83
- optional: true, repeat: true)
84
- end
66
+ delegate :arg_opt, :bool_opt, :options, :pos_arg,
67
+ :positional, :subcommands, to: :main_alternative
85
68
 
86
69
  def subcommands?
87
- pos_set.any?(&:subcommand?)
70
+ alternatives.any?(&:subcommands?)
88
71
  end
89
72
 
90
73
  def options_first(enable = true)
@@ -97,6 +80,18 @@ module EacCli
97
80
 
98
81
  private
99
82
 
83
+ def alternatives_set
84
+ @alternatives_set ||= ::ActiveSupport::HashWithIndifferentAccess.new
85
+ end
86
+
87
+ def new_alternative_key
88
+ @last_key ||= 0
89
+ loop do
90
+ @last_key += 1
91
+ break @last_key unless alternatives_set.key?(@last_key)
92
+ end
93
+ end
94
+
100
95
  def pos_set
101
96
  @pos_set ||= []
102
97
  end