tomo 0.18.0 → 1.1.2

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 (63) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -2
  3. data/lib/tomo/cli.rb +1 -3
  4. data/lib/tomo/cli/common_options.rb +4 -12
  5. data/lib/tomo/cli/deploy_options.rb +2 -7
  6. data/lib/tomo/cli/parser.rb +1 -6
  7. data/lib/tomo/cli/project_options.rb +1 -3
  8. data/lib/tomo/cli/rules.rb +4 -22
  9. data/lib/tomo/cli/rules/switch.rb +1 -5
  10. data/lib/tomo/cli/rules/value_switch.rb +1 -2
  11. data/lib/tomo/cli/rules_evaluator.rb +3 -13
  12. data/lib/tomo/cli/usage.rb +1 -3
  13. data/lib/tomo/commands/default.rb +1 -5
  14. data/lib/tomo/commands/run.rb +1 -3
  15. data/lib/tomo/configuration.rb +5 -11
  16. data/lib/tomo/configuration/dsl/error_formatter.rb +0 -4
  17. data/lib/tomo/configuration/dsl/hosts_and_settings.rb +1 -2
  18. data/lib/tomo/configuration/plugins_registry.rb +1 -2
  19. data/lib/tomo/configuration/unknown_environment_error.rb +1 -4
  20. data/lib/tomo/console.rb +2 -8
  21. data/lib/tomo/console/menu.rb +1 -2
  22. data/lib/tomo/host.rb +1 -2
  23. data/lib/tomo/plugin/bundler/tasks.rb +8 -8
  24. data/lib/tomo/plugin/core/tasks.rb +3 -16
  25. data/lib/tomo/plugin/env/tasks.rb +2 -7
  26. data/lib/tomo/plugin/git.rb +0 -3
  27. data/lib/tomo/plugin/git/tasks.rb +4 -16
  28. data/lib/tomo/plugin/nodenv/tasks.rb +1 -3
  29. data/lib/tomo/plugin/puma.rb +0 -3
  30. data/lib/tomo/plugin/puma/systemd/service.erb +1 -1
  31. data/lib/tomo/plugin/puma/tasks.rb +6 -15
  32. data/lib/tomo/plugin/rails/helpers.rb +1 -1
  33. data/lib/tomo/plugin/rails/tasks.rb +2 -4
  34. data/lib/tomo/plugin/testing.rb +1 -3
  35. data/lib/tomo/remote.rb +1 -3
  36. data/lib/tomo/runtime.rb +3 -6
  37. data/lib/tomo/runtime/concurrent_ruby_thread_pool.rb +1 -4
  38. data/lib/tomo/runtime/execution_plan.rb +1 -4
  39. data/lib/tomo/runtime/explanation.rb +1 -7
  40. data/lib/tomo/runtime/settings_interpolation.rb +1 -3
  41. data/lib/tomo/runtime/settings_required_error.rb +1 -3
  42. data/lib/tomo/runtime/task_runner.rb +2 -7
  43. data/lib/tomo/runtime/unknown_task_error.rb +1 -4
  44. data/lib/tomo/script.rb +1 -5
  45. data/lib/tomo/shell_builder.rb +5 -10
  46. data/lib/tomo/ssh/child_process.rb +6 -13
  47. data/lib/tomo/ssh/connection.rb +3 -16
  48. data/lib/tomo/ssh/connection_validator.rb +1 -4
  49. data/lib/tomo/ssh/executable_error.rb +1 -2
  50. data/lib/tomo/ssh/options.rb +2 -5
  51. data/lib/tomo/task_api.rb +4 -15
  52. data/lib/tomo/testing.rb +0 -2
  53. data/lib/tomo/testing/Dockerfile +1 -3
  54. data/lib/tomo/testing/connection.rb +1 -6
  55. data/lib/tomo/testing/docker_image.rb +4 -17
  56. data/lib/tomo/testing/local.rb +1 -3
  57. data/lib/tomo/testing/mock_plugin_tester.rb +27 -4
  58. data/lib/tomo/testing/mocked_exit_error.rb +1 -1
  59. data/lib/tomo/testing/ubuntu_setup.sh +1 -2
  60. data/lib/tomo/version.rb +1 -1
  61. metadata +13 -29
  62. data/lib/tomo/testing/docker_plugin_tester.rb +0 -39
  63. data/lib/tomo/testing/plugin_tester.rb +0 -33
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 24569b9d203580630d124df5ed6d5f42c4c5c8a8d7c2c9e6c2844abb662f03fb
4
- data.tar.gz: f154292556548e3dab819e4fdd3e57395f4ebd0fef3ad17cf291689ea848aee8
3
+ metadata.gz: a5b5ce43b616e968193b178c5bdcf299a066fff72803f7e5d08e5b2f3031da36
4
+ data.tar.gz: df6827b5fccc78461849a2aa226f5fc625bc8d5aa3dece49dcd029451e27bc27
5
5
  SHA512:
6
- metadata.gz: 4e6ded002068ec55394a73e0799e5c1d0f4ae68b1c549cfe438f7ff665d003d9a9d102f3b10cb8515e47013117f38a076c373c9f74cb21735524887be6a21c65
7
- data.tar.gz: ab85142a4744db02d8a0e5be818175e292531dfaef14626c35e9c0e9dc36793330e5c44b9e12cf3769c36c1b0087f5571a89f5c5ec010defcef9561b64ec57b8
6
+ metadata.gz: 71978c54069ac069386d7eac411fe85548492c8bc7f58dbbb48fed6791070c6abad2035d664111c93a827a1b8b03774cdfa1bf14fbd30c370066cee83d630bfb
7
+ data.tar.gz: f96b68f1c8f6457548c1d28276a3c599a99c02d4075cdb894d8ec16a9bc06b9f540758db3f7752ee3d5d964120db363145b8f2e0e1718c77610b36e0c386c02e
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/tomo.svg)](https://rubygems.org/gems/tomo)
4
4
  [![Travis](https://img.shields.io/travis/mattbrictson/tomo.svg?label=travis)](https://travis-ci.org/mattbrictson/tomo)
5
- [![Circle](https://circleci.com/gh/mattbrictson/tomo.svg?style=shield)](https://circleci.com/gh/mattbrictson/tomo)
5
+ [![Circle](https://circleci.com/gh/mattbrictson/tomo.svg?style=shield)](https://app.circleci.com/pipelines/github/mattbrictson/tomo?branch=master)
6
6
  [![Code Climate](https://codeclimate.com/github/mattbrictson/tomo/badges/gpa.svg)](https://codeclimate.com/github/mattbrictson/tomo)
7
7
 
8
8
  Tomo is a friendly command-line tool for deploying Rails apps. It is a new alternative to Capistrano, Mina, and Shipit that aims for simplicity and developer happiness.
@@ -191,7 +191,6 @@ Read the [Writing Custom Tasks](https://tomo-deploy.com/tutorials/writing-custom
191
191
  - [Result](https://tomo-deploy.com/api/Result/)
192
192
  - [TaskLibrary](https://tomo-deploy.com/api/TaskLibrary/)
193
193
  - [Testing::MockPluginTester](https://tomo-deploy.com/api/testing/MockPluginTester/)
194
- - [Testing::DockerPluginTester](https://tomo-deploy.com/api/testing/DockerPluginTester/)
195
194
 
196
195
  ## FAQ
197
196
 
@@ -55,8 +55,7 @@ module Tomo
55
55
  argv << "" if argv.shift == "--complete"
56
56
  end
57
57
 
58
- # rubocop:disable Metrics/CyclomaticComplexity
59
- def lookup_command(argv)
58
+ def lookup_command(argv) # rubocop:disable Metrics/CyclomaticComplexity
60
59
  command_name = argv.first unless Completions.active? && argv.length == 1
61
60
  command_name = Abbrev.abbrev(COMMANDS.keys)[command_name]
62
61
  argv.shift if command_name
@@ -65,7 +64,6 @@ module Tomo
65
64
  command = COMMANDS[command_name] || Tomo::Commands::Default
66
65
  [command, command_name]
67
66
  end
68
- # rubocop:enable Metrics/CyclomaticComplexity
69
67
 
70
68
  def task_format?(arg)
71
69
  arg.to_s.match?(/\A\S+:\S*\z/)
@@ -1,22 +1,15 @@
1
1
  module Tomo
2
2
  class CLI
3
3
  module CommonOptions
4
- # rubocop:disable Metrics/MethodLength
5
- def self.included(mod)
4
+ def self.included(mod) # rubocop:disable Metrics/MethodLength
6
5
  mod.class_eval do
7
- option :color,
8
- "--[no-]color",
9
- "Enable/disable color output" do |color|
6
+ option :color, "--[no-]color", "Enable/disable color output" do |color|
10
7
  Colors.enabled = color
11
8
  end
12
- option :debug,
13
- "--[no-]debug",
14
- "Enable/disable verbose debug logging" do |debug|
9
+ option :debug, "--[no-]debug", "Enable/disable verbose debug logging" do |debug|
15
10
  Tomo.debug = debug
16
11
  end
17
- option :trace,
18
- "--[no-]trace",
19
- "Display full backtrace on error" do |trace|
12
+ option :trace, "--[no-]trace", "Display full backtrace on error" do |trace|
20
13
  CLI.show_backtrace = trace
21
14
  end
22
15
  option :help, "-h, --help", "Print this documentation" do |_help|
@@ -27,7 +20,6 @@ module Tomo
27
20
  after_parse :dump_runtime_info
28
21
  end
29
22
  end
30
- # rubocop:enable Metrics/MethodLength
31
23
 
32
24
  private
33
25
 
@@ -1,8 +1,7 @@
1
1
  module Tomo
2
2
  class CLI
3
3
  module DeployOptions
4
- # rubocop:disable Metrics/MethodLength
5
- def self.included(mod)
4
+ def self.included(mod) # rubocop:disable Metrics/MethodLength
6
5
  mod.class_eval do
7
6
  option :environment,
8
7
  "-e, --environment ENVIRONMENT",
@@ -23,7 +22,6 @@ module Tomo
23
22
  after_parse :prompt_for_environment
24
23
  end
25
24
  end
26
- # rubocop:enable Metrics/MethodLength
27
25
 
28
26
  private
29
27
 
@@ -49,10 +47,7 @@ module Tomo
49
47
  return if envs.empty?
50
48
  return unless Console.interactive?
51
49
 
52
- options[:environment] = Console.menu(
53
- "Choose an environment:",
54
- choices: envs
55
- )
50
+ options[:environment] = Console.menu("Choose an environment:", choices: envs)
56
51
  end
57
52
  end
58
53
  end
@@ -46,12 +46,7 @@ module Tomo
46
46
  attr_reader :rules, :usage, :after_parse_methods
47
47
 
48
48
  def evaluate(argv, state, literal:)
49
- RulesEvaluator.evaluate(
50
- rules: rules.to_a,
51
- argv: argv,
52
- state: state,
53
- literal: literal
54
- )
49
+ RulesEvaluator.evaluate(rules: rules.to_a, argv: argv, state: state, literal: literal)
55
50
  end
56
51
 
57
52
  def check_required_rules(state)
@@ -3,9 +3,7 @@ module Tomo
3
3
  module ProjectOptions
4
4
  def self.included(mod)
5
5
  mod.class_eval do
6
- option :project,
7
- "-c, --config PATH",
8
- "Location of project config (default: #{DEFAULT_CONFIG_PATH})"
6
+ option :project, "-c, --config PATH", "Location of project config (default: #{DEFAULT_CONFIG_PATH})"
9
7
  end
10
8
  end
11
9
 
@@ -51,21 +51,11 @@ module Tomo
51
51
  attr_reader :rules
52
52
 
53
53
  def optional_arg_rule(spec, values_proc)
54
- Rules::Argument.new(
55
- spec,
56
- values_proc: values_proc,
57
- required: false,
58
- multiple: false
59
- )
54
+ Rules::Argument.new(spec, values_proc: values_proc, required: false, multiple: false)
60
55
  end
61
56
 
62
57
  def required_arg_rule(spec, values_proc)
63
- Rules::Argument.new(
64
- spec,
65
- values_proc: values_proc,
66
- required: true,
67
- multiple: false
68
- )
58
+ Rules::Argument.new(spec, values_proc: values_proc, required: true, multiple: false)
69
59
  end
70
60
 
71
61
  def mutiple_optional_args_rule(spec, values_proc)
@@ -73,10 +63,7 @@ module Tomo
73
63
  end
74
64
 
75
65
  def on_off_switch_rule(key, name, _values_proc, callback_proc)
76
- Rules::Switch.new(key,
77
- "--#{name}",
78
- "--no-#{name}",
79
- callback_proc: callback_proc) do |arg|
66
+ Rules::Switch.new(key, "--#{name}", "--no-#{name}", callback_proc: callback_proc) do |arg|
80
67
  arg == "--#{name}"
81
68
  end
82
69
  end
@@ -86,12 +73,7 @@ module Tomo
86
73
  end
87
74
 
88
75
  def value_switch_rule(key, *switches, values_proc, callback_proc)
89
- Rules::ValueSwitch.new(
90
- key,
91
- *switches,
92
- values_proc: values_proc,
93
- callback_proc: callback_proc
94
- )
76
+ Rules::ValueSwitch.new(key, *switches, values_proc: values_proc, callback_proc: callback_proc)
95
77
  end
96
78
  end
97
79
  end
@@ -1,10 +1,6 @@
1
1
  class Tomo::CLI::Rules
2
2
  class Switch
3
- def initialize(key,
4
- *switches,
5
- required: false,
6
- callback_proc:,
7
- &convert_proc)
3
+ def initialize(key, *switches, required: false, callback_proc:, &convert_proc)
8
4
  @key = key
9
5
  @switches = switches
10
6
  @callback_proc = callback_proc
@@ -51,8 +51,7 @@ class Tomo::CLI::Rules
51
51
  end
52
52
 
53
53
  def raise_missing_value(switch)
54
- raise Tomo::CLI::Error,
55
- "Please specify a value for the #{yellow(switch)} option."
54
+ raise Tomo::CLI::Error, "Please specify a value for the #{yellow(switch)} option."
56
55
  end
57
56
  end
58
57
  end
@@ -41,11 +41,7 @@ module Tomo
41
41
  def complete_if_needed(matched_rules, *matched_args)
42
42
  return unless Completions.active?
43
43
 
44
- completions.print_completions_and_exit(
45
- matched_rules,
46
- *matched_args,
47
- state: state
48
- )
44
+ completions.print_completions_and_exit(matched_rules, *matched_args, state: state)
49
45
  end
50
46
 
51
47
  def remaining_rules
@@ -56,15 +52,9 @@ module Tomo
56
52
 
57
53
  def raise_unrecognized_args
58
54
  problem_arg = argv.first
59
- type = if literal || !problem_arg.start_with?("-")
60
- "arg"
61
- else
62
- "option"
63
- end
55
+ type = literal || !problem_arg.start_with?("-") ? "arg" : "option"
64
56
 
65
- raise CLI::Error,
66
- "#{Colors.yellow(problem_arg)} is not a recognized #{type} "\
67
- "for this tomo command."
57
+ raise CLI::Error, "#{Colors.yellow(problem_arg)} is not a recognized #{type} for this tomo command."
68
58
  end
69
59
  end
70
60
  end
@@ -18,9 +18,7 @@ module Tomo
18
18
  end
19
19
 
20
20
  def to_s
21
- indent([
22
- "", banner_proc.call, "Options:", "", indent(options_help), "\n"
23
- ].join("\n"))
21
+ indent(["", banner_proc.call, "Options:", "", indent(options_help), "\n"].join("\n"))
24
22
  end
25
23
 
26
24
  private
@@ -10,7 +10,6 @@ module Tomo
10
10
 
11
11
  include CLI::CommonOptions
12
12
 
13
- # rubocop:disable Metrics/AbcSize
14
13
  def banner
15
14
  <<~BANNER
16
15
  Usage: #{green('tomo')} #{yellow('COMMAND [options]')}
@@ -37,16 +36,13 @@ module Tomo
37
36
  #{blue('https://tomo-deploy.com/')}
38
37
  BANNER
39
38
  end
40
- # rubocop:enable Metrics/AbcSize
41
39
 
42
40
  def call(*args, options)
43
41
  # The bare `tomo` command (i.e. without `--help` or `--version`) doesn't
44
42
  # do anything, so if we got this far, something has gone wrong.
45
43
 
46
44
  if options.any?
47
- raise CLI::Error,
48
- "Options must be specified after the command: " +
49
- yellow("tomo #{args.first} [options]")
45
+ raise CLI::Error, "Options must be specified after the command: " + yellow("tomo #{args.first} [options]")
50
46
  end
51
47
 
52
48
  raise_unrecognized_command(args.first)
@@ -3,9 +3,7 @@ module Tomo
3
3
  class Run < CLI::Command
4
4
  include CLI::DeployOptions
5
5
 
6
- option :privileged,
7
- "--[no-]privileged",
8
- "Run the task using a privileged user (e.g. root)"
6
+ option :privileged, "--[no-]privileged", "Run the task using a privileged user (e.g. root)"
9
7
 
10
8
  include CLI::ProjectOptions
11
9
  include CLI::CommonOptions
@@ -3,16 +3,13 @@ module Tomo
3
3
  autoload :DSL, "tomo/configuration/dsl"
4
4
  autoload :Environment, "tomo/configuration/environment"
5
5
  autoload :Glob, "tomo/configuration/glob"
6
- autoload :PluginFileNotFoundError,
7
- "tomo/configuration/plugin_file_not_found_error"
6
+ autoload :PluginFileNotFoundError, "tomo/configuration/plugin_file_not_found_error"
8
7
  autoload :PluginsRegistry, "tomo/configuration/plugins_registry"
9
8
  autoload :ProjectNotFoundError, "tomo/configuration/project_not_found_error"
10
9
  autoload :RoleBasedTaskFilter, "tomo/configuration/role_based_task_filter"
11
- autoload :UnknownEnvironmentError,
12
- "tomo/configuration/unknown_environment_error"
10
+ autoload :UnknownEnvironmentError, "tomo/configuration/unknown_environment_error"
13
11
  autoload :UnknownPluginError, "tomo/configuration/unknown_plugin_error"
14
- autoload :UnspecifiedEnvironmentError,
15
- "tomo/configuration/unspecified_environment_error"
12
+ autoload :UnspecifiedEnvironmentError, "tomo/configuration/unspecified_environment_error"
16
13
 
17
14
  def self.from_config_rb(path=DEFAULT_CONFIG_PATH)
18
15
  ProjectNotFoundError.raise_with(path: path) unless File.file?(path)
@@ -27,8 +24,7 @@ module Tomo
27
24
  raise DSL::ErrorFormatter.decorate(e, path, config_rb&.lines)
28
25
  end
29
26
 
30
- attr_accessor :environments, :deploy_tasks, :setup_tasks, :hosts, :plugins,
31
- :settings, :task_filter, :path
27
+ attr_accessor :environments, :deploy_tasks, :setup_tasks, :hosts, :plugins, :settings, :task_filter, :path
32
28
 
33
29
  def initialize
34
30
  @environments = {}
@@ -116,9 +112,7 @@ module Tomo
116
112
  end
117
113
 
118
114
  def raise_unknown_environment(environ)
119
- UnknownEnvironmentError.raise_with(
120
- name: environ, known_environments: environments.keys
121
- )
115
+ UnknownEnvironmentError.raise_with(name: environ, known_environments: environments.keys)
122
116
  end
123
117
  end
124
118
  end
@@ -50,8 +50,6 @@ module Tomo
50
50
  HINT
51
51
  end
52
52
 
53
- # rubocop:disable Metrics/AbcSize
54
- # rubocop:disable Metrics/MethodLength
55
53
  def highlighted_lines
56
54
  first = [1, error_line_no - 1].max
57
55
  last = [dsl_lines.length, error_line_no + 1].min
@@ -68,8 +66,6 @@ module Tomo
68
66
  end
69
67
  end
70
68
  end
71
- # rubocop:enable Metrics/AbcSize
72
- # rubocop:enable Metrics/MethodLength
73
69
  end
74
70
  end
75
71
  end
@@ -7,8 +7,7 @@ module Tomo
7
7
  self
8
8
  end
9
9
 
10
- def host(address, port: 22, roles: [],
11
- log_prefix: nil, privileged_user: "root")
10
+ def host(address, port: 22, roles: [], log_prefix: nil, privileged_user: "root")
12
11
  @config.hosts << Host.parse(
13
12
  address,
14
13
  privileged_user: privileged_user,
@@ -1,8 +1,7 @@
1
1
  module Tomo
2
2
  class Configuration
3
3
  class PluginsRegistry
4
- autoload :FileResolver,
5
- "tomo/configuration/plugins_registry/file_resolver"
4
+ autoload :FileResolver, "tomo/configuration/plugins_registry/file_resolver"
6
5
  autoload :GemResolver, "tomo/configuration/plugins_registry/gem_resolver"
7
6
 
8
7
  attr_reader :helper_modules, :settings
@@ -36,10 +36,7 @@ module Tomo
36
36
  end
37
37
 
38
38
  def suggestions
39
- @_suggestions ||= Error::Suggestions.new(
40
- dictionary: known_environments,
41
- word: name
42
- )
39
+ @_suggestions ||= Error::Suggestions.new(dictionary: known_environments, word: name)
43
40
  end
44
41
  end
45
42
  end
@@ -18,10 +18,7 @@ module Tomo
18
18
  end
19
19
 
20
20
  def interactive?
21
- input.respond_to?(:raw) &&
22
- input.respond_to?(:tty?) &&
23
- input.tty? &&
24
- !ci?
21
+ input.respond_to?(:raw) && input.respond_to?(:tty?) && input.tty? && !ci?
25
22
  end
26
23
 
27
24
  def prompt(question)
@@ -66,10 +63,7 @@ module Tomo
66
63
  end
67
64
 
68
65
  def raise_non_interactive
69
- NonInteractiveError.raise_with(
70
- task: Runtime::Current.task,
71
- ci_var: (env.keys & CI_VARS).first
72
- )
66
+ NonInteractiveError.raise_with(task: Runtime::Current.task, ci_var: (env.keys & CI_VARS).first)
73
67
  end
74
68
  end
75
69
  end
@@ -12,8 +12,7 @@ module Tomo
12
12
  extend Forwardable
13
13
  include Colors
14
14
 
15
- def initialize(question, options, key_reader: KeyReader.new,
16
- output: $stdout)
15
+ def initialize(question, options, key_reader: KeyReader.new, output: $stdout)
17
16
  @question = question
18
17
  @options = options
19
18
  @position = 0
@@ -13,8 +13,7 @@ module Tomo
13
13
  new(**{ user: user, address: address }.merge(kwargs))
14
14
  end
15
15
 
16
- def initialize(address:, port: nil, log_prefix: nil, roles: nil,
17
- user: nil, privileged_user: "root")
16
+ def initialize(address:, port: nil, log_prefix: nil, roles: nil, user: nil, privileged_user: "root")
18
17
  @user = user.freeze
19
18
  @port = (port || 22).to_i.freeze
20
19
  @address = address.freeze
@@ -30,13 +30,7 @@ module Tomo::Plugin::Bundler
30
30
 
31
31
  def upgrade_bundler
32
32
  needed_bundler_ver = version_setting || extract_bundler_ver_from_lockfile
33
- return if needed_bundler_ver.nil?
34
-
35
- remote.run(
36
- "gem", "install", "bundler",
37
- "--conservative", "--no-document",
38
- "-v", needed_bundler_ver
39
- )
33
+ remote.run("gem", "install", "bundler", "--conservative", "--no-document", "-v", needed_bundler_ver)
40
34
  end
41
35
 
42
36
  private
@@ -61,7 +55,13 @@ module Tomo::Plugin::Bundler
61
55
  "tail", "-n", "10", paths.release.join("Gemfile.lock"),
62
56
  raise_on_error: false
63
57
  )
64
- lockfile_tail[/BUNDLED WITH\n (\S+)$/, 1]
58
+ version = lockfile_tail[/BUNDLED WITH\n (\S+)$/, 1]
59
+ return version if version
60
+
61
+ die <<~REASON
62
+ Could not guess bundler version from Gemfile.lock.
63
+ Use the :bundler_version setting to specify the version of bundler to install.
64
+ REASON
65
65
  end
66
66
  end
67
67
  end