avm-tools 0.73.0 → 0.76.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. checksums.yaml +4 -4
  2. data/lib/avm/{stereotypes/eac_rails_base0.rb → eac_rails_base0.rb} +1 -3
  3. data/lib/avm/eac_rails_base0/instance.rb +2 -5
  4. data/lib/avm/{rails/runners.rb → eac_rails_base1.rb} +2 -4
  5. data/lib/avm/{rails → eac_rails_base1}/instance.rb +8 -3
  6. data/lib/avm/eac_rails_base1/runner.rb +12 -0
  7. data/lib/avm/eac_rails_base1/runner/bundle.rb +28 -0
  8. data/lib/avm/eac_rails_base1/runner/code_runner.rb +28 -0
  9. data/lib/avm/eac_rails_base1/runner_with/bundle.rb +57 -0
  10. data/lib/avm/{stereotypes/rails.rb → eac_redmine_base0.rb} +2 -4
  11. data/lib/avm/eac_redmine_base0/instance.rb +2 -4
  12. data/lib/avm/{stereotypes/eac_ubuntu_base0.rb → eac_ubuntu_base0.rb} +1 -3
  13. data/lib/avm/{stereotypes/eac_webapp_base0.rb → eac_webapp_base0.rb} +1 -3
  14. data/lib/avm/eac_webapp_base0/deploy.rb +17 -40
  15. data/lib/avm/eac_webapp_base0/deploy/build.rb +48 -0
  16. data/lib/avm/eac_webapp_base0/deploy/git_info.rb +13 -0
  17. data/lib/avm/eac_webapp_base0/deploy/version.rb +4 -0
  18. data/lib/avm/eac_webapp_base0/deploy/write_on_target.rb +18 -0
  19. data/lib/avm/eac_webapp_base0/instance.rb +2 -2
  20. data/lib/avm/eac_webapp_base0/runner.rb +12 -0
  21. data/lib/avm/eac_webapp_base0/runner/apache_host.rb +2 -3
  22. data/lib/avm/eac_webapp_base0/runner/data.rb +1 -1
  23. data/lib/avm/eac_webapp_base0/runner/data/dump.rb +1 -1
  24. data/lib/avm/eac_webapp_base0/runner/data/load.rb +1 -1
  25. data/lib/avm/eac_webapp_base0/runner/deploy.rb +4 -16
  26. data/lib/avm/eac_wordpress_base0.rb +9 -0
  27. data/lib/avm/eac_wordpress_base0/apache_host.rb +25 -0
  28. data/lib/avm/eac_wordpress_base0/deploy.rb +10 -0
  29. data/lib/avm/eac_wordpress_base0/instance.rb +24 -0
  30. data/lib/avm/eac_writings_base0.rb +9 -0
  31. data/lib/avm/eac_writings_base0/apache_host.rb +17 -0
  32. data/lib/avm/eac_writings_base0/commons.rb +12 -0
  33. data/lib/avm/eac_writings_base0/deploy.rb +36 -0
  34. data/lib/avm/eac_writings_base0/file_build.rb +45 -0
  35. data/lib/avm/eac_writings_base0/file_build/base_stereotype.rb +19 -0
  36. data/lib/avm/eac_writings_base0/file_build/chapter_index.rb +23 -0
  37. data/lib/avm/eac_writings_base0/file_build/tex_source.rb +33 -0
  38. data/lib/avm/eac_writings_base0/instance.rb +11 -0
  39. data/lib/avm/eac_writings_base0/project.rb +33 -0
  40. data/lib/avm/eac_writings_base0/project_build.rb +117 -0
  41. data/lib/avm/eac_writings_base0/project_build/chapters_content.rb +47 -0
  42. data/lib/avm/eac_writings_base0/project_build/copy_files.rb +42 -0
  43. data/lib/avm/executables.rb +1 -1
  44. data/lib/avm/files/appendable.rb +55 -0
  45. data/lib/avm/files/appendable/file_content.rb +24 -0
  46. data/lib/avm/files/appendable/plain_directory.rb +25 -0
  47. data/lib/avm/files/appendable/resource_base.rb +13 -0
  48. data/lib/avm/files/appendable/tar_output_command.rb +26 -0
  49. data/lib/avm/files/appendable/templatized_directory.rb +28 -0
  50. data/lib/avm/files/appender.rb +11 -0
  51. data/lib/avm/files/deploy.rb +72 -0
  52. data/lib/avm/files/formatter.rb +8 -4
  53. data/lib/avm/git/auto_commit_path.rb +2 -4
  54. data/lib/avm/git/auto_commit_path/ruby.rb +20 -0
  55. data/lib/avm/git/commit/deploy.rb +8 -61
  56. data/lib/avm/instances/runner.rb +40 -0
  57. data/lib/avm/{stereotypes/postgresql.rb → postgresql.rb} +1 -3
  58. data/lib/avm/postgresql/instance.rb +63 -0
  59. data/lib/avm/postgresql/instance/data_unit.rb +39 -0
  60. data/lib/avm/postgresql/instance_with.rb +18 -0
  61. data/lib/avm/projects/stereotypes/git_subtree/publish.rb +2 -0
  62. data/lib/avm/projects/stereotypes/git_subtree/warp.rb +3 -0
  63. data/lib/avm/tools/runner.rb +3 -3
  64. data/lib/avm/tools/runner/eac_rails_base0.rb +5 -18
  65. data/lib/avm/tools/runner/eac_rails_base0/apache_path.rb +1 -1
  66. data/lib/avm/tools/runner/eac_rails_base0/rails_server.rb +7 -12
  67. data/lib/avm/tools/runner/eac_rails_base0/runner.rb +3 -3
  68. data/lib/avm/tools/runner/eac_redmine_base0.rb +5 -23
  69. data/lib/avm/tools/runner/eac_redmine_base0/core_update.rb +1 -1
  70. data/lib/avm/tools/runner/eac_redmine_base0/docker.rb +1 -1
  71. data/lib/avm/tools/runner/eac_redmine_base0/project_rename.rb +3 -3
  72. data/lib/avm/tools/runner/eac_wordpress_base0.rb +5 -24
  73. data/lib/avm/tools/runner/{eac_rails_base0/data.rb → eac_writings_base0.rb} +4 -4
  74. data/lib/avm/tools/runner/files/format.rb +3 -2
  75. data/lib/avm/tools/runner/git/auto_commit.rb +11 -0
  76. data/lib/avm/tools/runner/git/deploy.rb +1 -1
  77. data/lib/avm/tools/runner/local_project/eac_writings_base0.rb +35 -0
  78. data/lib/avm/tools/runner/local_project/eac_writings_base0/build_chapters.rb +48 -0
  79. data/lib/avm/tools/runner/local_project/eac_writings_base0/build_single.rb +37 -0
  80. data/lib/avm/tools/runner/local_project/eac_writings_base0/info.rb +36 -0
  81. data/lib/avm/tools/version.rb +1 -1
  82. data/template/avm/{stereotypes/eac_ubuntu_base0 → eac_ubuntu_base0}/docker_image/Dockerfile +0 -0
  83. data/template/avm/{stereotypes/eac_wordpress_base0 → eac_wordpress_base0}/deploy/wp-config.php.template +0 -0
  84. data/template/avm/eac_writings_base0/commons/all.tex +5 -0
  85. data/template/avm/eac_writings_base0/commons/ebook.tex +11 -0
  86. data/template/avm/eac_writings_base0/commons/images.tex +11 -0
  87. data/template/avm/eac_writings_base0/commons/links.tex +2 -0
  88. data/template/avm/eac_writings_base0/commons/portuguese.tex +8 -0
  89. data/template/avm/eac_writings_base0/commons/source_code.tex +21 -0
  90. data/template/avm/eac_writings_base0/commons/source_code/java.tex +15 -0
  91. data/template/avm/eac_writings_base0/commons/utils.tex +6 -0
  92. data/template/avm/eac_writings_base0/deploy/index.html.template +9 -0
  93. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs.rb +4 -39
  94. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/read_entry_options.rb +41 -0
  95. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/clearable_directory.rb +57 -0
  96. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/struct.rb +4 -0
  97. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  98. metadata +64 -36
  99. data/lib/avm/git/commit/deploy/appended.rb +0 -37
  100. data/lib/avm/git/commit/deploy/appended/base.rb +0 -17
  101. data/lib/avm/git/commit/deploy/appended/directory.rb +0 -32
  102. data/lib/avm/git/commit/deploy/appended/file_content.rb +0 -28
  103. data/lib/avm/rails/runners/bundle.rb +0 -35
  104. data/lib/avm/rails/runners/runner.rb +0 -48
  105. data/lib/avm/stereotypes/eac_redmine_base0.rb +0 -11
  106. data/lib/avm/stereotypes/eac_wordpress_base0/apache_host.rb +0 -27
  107. data/lib/avm/stereotypes/eac_wordpress_base0/deploy.rb +0 -12
  108. data/lib/avm/stereotypes/eac_wordpress_base0/instance.rb +0 -26
  109. data/lib/avm/stereotypes/postgresql/instance.rb +0 -65
  110. data/lib/avm/stereotypes/postgresql/instance/data_unit.rb +0 -41
  111. data/lib/avm/stereotypes/postgresql/instance_with.rb +0 -20
  112. data/lib/avm/tools/runner/eac_rails_base0/apache_host.rb +0 -16
  113. data/lib/avm/tools/runner/eac_rails_base0/bundle.rb +0 -14
  114. data/lib/avm/tools/runner/eac_rails_base0/deploy.rb +0 -15
  115. data/lib/avm/tools/runner/eac_redmine_base0/bundle.rb +0 -14
  116. data/lib/avm/tools/runner/eac_redmine_base0/data.rb +0 -27
  117. data/lib/avm/tools/runner/eac_redmine_base0/data/dump.rb +0 -16
  118. data/lib/avm/tools/runner/eac_redmine_base0/deploy.rb +0 -15
  119. data/lib/avm/tools/runner/eac_redmine_base0/runner.rb +0 -14
  120. data/lib/avm/tools/runner/eac_wordpress_base0/apache_host.rb +0 -17
  121. data/lib/avm/tools/runner/eac_wordpress_base0/data.rb +0 -15
  122. data/lib/avm/tools/runner/eac_wordpress_base0/deploy.rb +0 -15
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
-
5
- module Avm
6
- module Git
7
- class Commit
8
- class Deploy
9
- module Appended
10
- class Base
11
- common_constructor :deploy
12
- end
13
- end
14
- end
15
- end
16
- end
17
- end
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
- require 'avm/git/commit/deploy/appended/base'
5
-
6
- module Avm
7
- module Git
8
- class Commit
9
- class Deploy
10
- module Appended
11
- class Directory < ::Avm::Git::Commit::Deploy::Appended::Base
12
- attr_reader :source_path
13
-
14
- def initialize(deploy, source_path)
15
- super(deploy)
16
- @source_path = source_path
17
- end
18
-
19
- def copy_to_build_dir
20
- raise 'Variables source not set' if deploy.variables_source.blank?
21
-
22
- ::EacRubyUtils::Templates::Directory.new(source_path).apply(
23
- deploy.variables_source,
24
- deploy.build_dir
25
- )
26
- end
27
- end
28
- end
29
- end
30
- end
31
- end
32
- end
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
- require 'avm/git/commit/deploy/appended/base'
5
-
6
- module Avm
7
- module Git
8
- class Commit
9
- class Deploy
10
- module Appended
11
- class FileContent < ::Avm::Git::Commit::Deploy::Appended::Base
12
- attr_reader :target_path, :content
13
-
14
- def initialize(deploy, target_path, content)
15
- super(deploy)
16
- @target_path = target_path
17
- @content = content
18
- end
19
-
20
- def copy_to_build_dir
21
- deploy.build_dir.to_pathname.join(target_path).write(content)
22
- end
23
- end
24
- end
25
- end
26
- end
27
- end
28
- end
@@ -1,35 +0,0 @@
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
@@ -1,48 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/console/docopt_runner'
4
- require 'eac_ruby_utils/core_ext'
5
-
6
- module Avm
7
- module Rails
8
- module Runners
9
- class Runner < ::EacRubyUtils::Console::DocoptRunner
10
- enable_console_speaker
11
- enable_simple_cache
12
-
13
- DOC = <<~DOC
14
- Runs a Ruby code with "rails runner".
15
-
16
- Usage:
17
- __PROGRAM__ [options] <code>
18
- __PROGRAM__ --version
19
- __PROGRAM__ -h | --help
20
-
21
- Options:
22
- -h --help Show this screen.
23
- -e --environment Specifies the environment for the runner to
24
- operate (test/development/production). Default: "development".
25
- DOC
26
-
27
- def run
28
- infov 'Runner arguments', runner_args
29
- infov 'Environment', context(:instance).host_env
30
- runner_command.system!
31
- end
32
-
33
- def runner_command_uncached
34
- context(:instance).bundle(*bundle_args)
35
- end
36
-
37
- def bundle_args
38
- %w[exec rails runner] + runner_args
39
- end
40
-
41
- def runner_args
42
- options.fetch('--environment').if_present([]) { |v| ['--environment', v] } +
43
- [options.fetch('<code>')]
44
- end
45
- end
46
- end
47
- end
48
- end
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/require_sub'
4
-
5
- module Avm
6
- module Stereotypes
7
- module EacRedmineBase0
8
- ::EacRubyUtils.require_sub(__FILE__)
9
- end
10
- end
11
- end
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'avm/eac_webapp_base0/apache_host'
4
-
5
- module Avm
6
- module Stereotypes
7
- module EacWordpressBase0
8
- class ApacheHost < ::Avm::EacWebappBase0::ApacheHost
9
- def document_root
10
- instance.read_entry(::Avm::Instances::EntryKeys::FS_PATH)
11
- end
12
-
13
- def extra_content
14
- "AssignUserID #{system_user} #{system_group}"
15
- end
16
-
17
- def system_user
18
- instance.read_entry('system.username')
19
- end
20
-
21
- def system_group
22
- instance.read_entry('system.groupname')
23
- end
24
- end
25
- end
26
- end
27
- end
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'avm/eac_webapp_base0/deploy'
4
-
5
- module Avm
6
- module Stereotypes
7
- module EacWordpressBase0
8
- class Deploy < ::Avm::EacWebappBase0::Deploy
9
- end
10
- end
11
- end
12
- end
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'avm/instances/entry_keys'
4
- require 'avm/eac_webapp_base0/instance'
5
-
6
- module Avm
7
- module Stereotypes
8
- module EacWordpressBase0
9
- class Instance < ::Avm::EacWebappBase0::Instance
10
- FILES_UNITS = { uploads: 'wp-content/uploads', themes: 'wp-content/themes' }.freeze
11
-
12
- def database_unit
13
- web_url = read_entry(::Avm::Instances::EntryKeys::WEB_URL)
14
- super.after_load do
15
- info 'Fixing web addresses...'
16
- run_sql(<<~SQL)
17
- update wp_options
18
- set option_value = '#{web_url}'
19
- where option_name in ('siteurl', 'home')
20
- SQL
21
- end
22
- end
23
- end
24
- end
25
- end
26
- end
@@ -1,65 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'avm/stereotypes/postgresql/instance/data_unit'
4
-
5
- module Avm
6
- module Stereotypes
7
- module Postgresql
8
- class Instance
9
- def initialize(env, connection_params)
10
- @env = env
11
- @connection_params = connection_params.with_indifferent_access
12
- end
13
-
14
- def data_unit
15
- ::Avm::Stereotypes::Postgresql::Instance::DataUnit.new(self)
16
- end
17
-
18
- def dump_command
19
- env.command('pg_dump', '--no-privileges', '--clean', '--no-owner', *common_command_args)
20
- .envvar('PGPASSWORD', password)
21
- end
22
-
23
- def dump_gzip_command
24
- dump_command.append(['@ESC_|', 'gzip', '-9', '-c'])
25
- end
26
-
27
- def psql_command
28
- env.command("@ESC_PGPASSWORD=#{password}", 'psql', *common_command_args)
29
- end
30
-
31
- def psql_command_command(sql)
32
- psql_command.append(['--quiet', '--tuples-only', '--command', sql])
33
- end
34
-
35
- private
36
-
37
- attr_reader :env, :connection_params
38
-
39
- def common_command_args
40
- ['--host', host, '--username', user, '--port', port, name]
41
- end
42
-
43
- def host
44
- connection_params[:host] || '127.0.0.1'
45
- end
46
-
47
- def port
48
- connection_params[:port] || '5432'
49
- end
50
-
51
- def user
52
- connection_params.fetch(:user)
53
- end
54
-
55
- def password
56
- connection_params.fetch(:password)
57
- end
58
-
59
- def name
60
- connection_params.fetch(:name)
61
- end
62
- end
63
- end
64
- end
65
- end
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'avm/data/instance/unit'
4
-
5
- module Avm
6
- module Stereotypes
7
- module Postgresql
8
- class Instance
9
- class DataUnit < ::Avm::Data::Instance::Unit
10
- EXTENSION = '.pgdump.gz'
11
-
12
- before_load :clear_database
13
-
14
- def dump_command
15
- instance.dump_gzip_command
16
- end
17
-
18
- def load_command
19
- instance.psql_command.prepend(['gzip', '-d', '@ESC_|'])
20
- end
21
-
22
- private
23
-
24
- def clear_database
25
- info 'Clearing database (Dropping all tables)...'
26
- run_sql(drop_all_tables_sql).if_present { |v| run_sql(v) }
27
- end
28
-
29
- def drop_all_tables_sql
30
- "select 'drop table \"' || tablename || '\" cascade;' from pg_tables " \
31
- "where schemaname = 'public';"
32
- end
33
-
34
- def run_sql(sql)
35
- instance.psql_command_command(sql).execute!
36
- end
37
- end
38
- end
39
- end
40
- end
41
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'avm/instances/entry_keys'
4
- require 'avm/stereotypes/postgresql/instance'
5
-
6
- module Avm
7
- module Stereotypes
8
- module Postgresql
9
- module InstanceWith
10
- def pg
11
- @pg ||= ::Avm::Stereotypes::Postgresql::Instance.new(
12
- host_env, user: read_entry(::Avm::Instances::EntryKeys::DATABASE_USERNAME),
13
- password: read_entry(::Avm::Instances::EntryKeys::DATABASE_PASSWORD),
14
- name: read_entry(::Avm::Instances::EntryKeys::DATABASE_NAME)
15
- )
16
- end
17
- end
18
- end
19
- end
20
- end
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'avm/eac_webapp_base0/runner/apache_host'
4
- require 'eac_ruby_utils/console/docopt_runner'
5
- require 'avm/eac_rails_base0/apache_host'
6
-
7
- module Avm
8
- module Tools
9
- class Runner < ::EacRubyUtils::Console::DocoptRunner
10
- class EacRailsBase0 < ::EacRubyUtils::Console::DocoptRunner
11
- class ApacheHost < ::Avm::EacWebappBase0::Runner::ApacheHost
12
- end
13
- end
14
- end
15
- end
16
- end
@@ -1,14 +0,0 @@
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,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'avm/eac_rails_base0/deploy'
4
- require 'avm/eac_webapp_base0/runner/deploy'
5
-
6
- module Avm
7
- module Tools
8
- class Runner < ::EacRubyUtils::Console::DocoptRunner
9
- class EacRailsBase0 < ::EacRubyUtils::Console::DocoptRunner
10
- class Deploy < ::Avm::EacWebappBase0::Runner::Deploy
11
- end
12
- end
13
- end
14
- end
15
- end
@@ -1,14 +0,0 @@
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 EacRedmineBase0 < ::EacRubyUtils::Console::DocoptRunner
9
- class Bundle < ::Avm::Rails::Runners::Bundle
10
- end
11
- end
12
- end
13
- end
14
- end
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'avm/eac_webapp_base0/runner/data'
4
- require 'eac_ruby_utils/console/docopt_runner'
5
-
6
- module Avm
7
- module Tools
8
- class Runner < ::EacRubyUtils::Console::DocoptRunner
9
- class EacRedmineBase0 < ::EacRubyUtils::Console::DocoptRunner
10
- class Data < ::EacRubyUtils::Console::DocoptRunner
11
- ::EacRubyUtils.require_sub(__FILE__)
12
-
13
- DOC = <<~DOCOPT
14
- Data utilities for EacRailsBase0 instances.
15
-
16
- Usage:
17
- __PROGRAM__ __SUBCOMMANDS__
18
- __PROGRAM__ -h | --help
19
-
20
- Options:
21
- -h --help Show this screen.
22
- DOCOPT
23
- end
24
- end
25
- end
26
- end
27
- end