tomo 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tomo/cli/completions.rb +1 -1
- data/lib/tomo/cli.rb +7 -0
- data/lib/tomo/commands/default.rb +9 -3
- data/lib/tomo/commands/run.rb +5 -0
- data/lib/tomo/plugin/core.rb +15 -19
- data/lib/tomo/plugin/puma/tasks.rb +1 -1
- data/lib/tomo/runtime/task_runner.rb +6 -1
- data/lib/tomo/ssh/options.rb +17 -11
- data/lib/tomo/ssh.rb +3 -1
- data/lib/tomo/testing/local.rb +17 -4
- data/lib/tomo/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5df4b79a1c4cb50739874de698f09346f009a47c11fa99f51d79c6604adb93e4
|
4
|
+
data.tar.gz: 7c02ea4319e293ec156b4cf54bad2b06f4c43bbe7f4872d93c24c5b1a75d3f24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b803e5bf13962a2ecc92dfd61e332554ec72d45883d99255f4ef2e7464a668653e2579758e013527761ef6f7aa7a2a62e8750dd00883b97640732b914258a37a
|
7
|
+
data.tar.gz: a1c0c54ccf105d274c92a6ac84040c7682c7e3c5aae9c0719c7f2e75a202f8c2e6353afed9b483dc3f39e7ee63117ada23ea937fe88f374b24389b41e5bd9222
|
data/lib/tomo/cli/completions.rb
CHANGED
data/lib/tomo/cli.rb
CHANGED
@@ -51,14 +51,21 @@ module Tomo
|
|
51
51
|
argv << "" if argv.shift == "--complete"
|
52
52
|
end
|
53
53
|
|
54
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
54
55
|
def lookup_command(argv)
|
55
56
|
command_name = argv.first unless Completions.active? && argv.length == 1
|
56
57
|
command_name = Abbrev.abbrev(COMMANDS.keys)[command_name]
|
57
58
|
argv.shift if command_name
|
58
59
|
|
60
|
+
command_name = "run" if command_name.nil? && task_format?(argv.first)
|
59
61
|
command = COMMANDS[command_name] || Tomo::Commands::Default
|
60
62
|
[command, command_name]
|
61
63
|
end
|
64
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
65
|
+
|
66
|
+
def task_format?(arg)
|
67
|
+
arg.to_s.match?(/\A\S+:\S*\z/)
|
68
|
+
end
|
62
69
|
|
63
70
|
def handle_error(error, command_name)
|
64
71
|
return if Completions.active?
|
@@ -10,6 +10,7 @@ module Tomo
|
|
10
10
|
|
11
11
|
include CLI::CommonOptions
|
12
12
|
|
13
|
+
# rubocop:disable Metrics/AbcSize
|
13
14
|
def banner
|
14
15
|
<<~BANNER
|
15
16
|
Usage: #{green('tomo')} #{yellow('COMMAND [options]')}
|
@@ -19,9 +20,13 @@ module Tomo
|
|
19
20
|
|
20
21
|
#{commands.map { |name, help| " #{yellow(name.ljust(10))} #{help}" }.join("\n")}
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
23
|
+
The tomo CLI also provides some convenient shortcuts:
|
24
|
+
|
25
|
+
- Commands can be abbreviated, like #{blue('tomo d')} to run #{blue('tomo deploy')}.
|
26
|
+
- When running tasks, the #{yellow('run')} command is implied and can be omitted.
|
27
|
+
E.g., #{blue('tomo run rails:console')} can be shortened to #{blue('tomo rails:console')}.
|
28
|
+
- Bash completions are also available. Run #{blue('tomo completion-script')} for
|
29
|
+
installation instructions.
|
25
30
|
|
26
31
|
For help with any command, add #{blue('-h')} to the command, like this:
|
27
32
|
|
@@ -32,6 +37,7 @@ module Tomo
|
|
32
37
|
#{blue('https://tomo-deploy.com/')}
|
33
38
|
BANNER
|
34
39
|
end
|
40
|
+
# rubocop:enable Metrics/AbcSize
|
35
41
|
|
36
42
|
def call(*args, options)
|
37
43
|
# The bare `tomo` command (i.e. without `--help` or `--version`) doesn't
|
data/lib/tomo/commands/run.rb
CHANGED
@@ -34,6 +34,11 @@ module Tomo
|
|
34
34
|
|
35
35
|
#{blue('tomo run core:clean_releases')}
|
36
36
|
|
37
|
+
When you specify a task name, the #{blue('run')} command is implied and can be
|
38
|
+
omitted, so this works as well:
|
39
|
+
|
40
|
+
#{blue('tomo core:clean_releases')}
|
41
|
+
|
37
42
|
You can run any task defined by plugins loaded in #{DEFAULT_CONFIG_PATH}.
|
38
43
|
To see a list of available tasks, run #{blue('tomo tasks')}.
|
39
44
|
|
data/lib/tomo/plugin/core.rb
CHANGED
@@ -8,24 +8,20 @@ module Tomo::Plugin
|
|
8
8
|
helpers Tomo::Plugin::Core::Helpers
|
9
9
|
tasks Tomo::Plugin::Core::Tasks
|
10
10
|
|
11
|
-
defaults
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
ssh_extra_opts: %w[-o PasswordAuthentication=no],
|
27
|
-
ssh_forward_agent: true,
|
28
|
-
ssh_reuse_connections: true,
|
29
|
-
ssh_strict_host_key_checking: "accept-new"
|
11
|
+
defaults Tomo::SSH::Options::DEFAULTS.merge(
|
12
|
+
application: "default",
|
13
|
+
concurrency: 10,
|
14
|
+
current_path: "%<deploy_to>/current",
|
15
|
+
deploy_to: "/var/www/%<application>",
|
16
|
+
keep_releases: 10,
|
17
|
+
linked_dirs: [],
|
18
|
+
linked_files: [],
|
19
|
+
release_json_path: "%<release_path>/.tomo_release.json",
|
20
|
+
releases_path: "%<deploy_to>/releases",
|
21
|
+
revision_log_path: "%<deploy_to>/revisions.log",
|
22
|
+
shared_path: "%<deploy_to>/shared",
|
23
|
+
tmp_path: "/tmp/tomo",
|
24
|
+
run_args: []
|
25
|
+
)
|
30
26
|
end
|
31
27
|
end
|
@@ -36,7 +36,7 @@ module Tomo
|
|
36
36
|
|
37
37
|
def connect(host)
|
38
38
|
Current.with(host: host) do
|
39
|
-
conn = SSH.connect(host: host, options:
|
39
|
+
conn = SSH.connect(host: host, options: ssh_options)
|
40
40
|
remote = Remote.new(conn, context, helper_modules)
|
41
41
|
return remote unless block_given?
|
42
42
|
|
@@ -51,6 +51,11 @@ module Tomo
|
|
51
51
|
private
|
52
52
|
|
53
53
|
attr_reader :helper_modules, :tasks_by_name
|
54
|
+
|
55
|
+
def ssh_options
|
56
|
+
# TODO: replace with Hash#slice after dropping Ruby 2.4 support
|
57
|
+
settings.select { |key| SSH::Options::DEFAULTS.key?(key) }
|
58
|
+
end
|
54
59
|
end
|
55
60
|
end
|
56
61
|
end
|
data/lib/tomo/ssh/options.rb
CHANGED
@@ -1,17 +1,22 @@
|
|
1
1
|
module Tomo
|
2
2
|
module SSH
|
3
3
|
class Options
|
4
|
+
DEFAULTS = {
|
5
|
+
ssh_connect_timeout: 5,
|
6
|
+
ssh_executable: "ssh".freeze,
|
7
|
+
ssh_extra_opts: %w[-o PasswordAuthentication=no].map(&:freeze),
|
8
|
+
ssh_forward_agent: true,
|
9
|
+
ssh_reuse_connections: true,
|
10
|
+
ssh_strict_host_key_checking: "accept-new".freeze
|
11
|
+
}.freeze
|
12
|
+
|
4
13
|
attr_reader :executable
|
5
14
|
|
6
|
-
def initialize(
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
@connect_timeout = settings.fetch(:ssh_connect_timeout)
|
12
|
-
@strict_host_key_checking = settings.fetch(
|
13
|
-
:ssh_strict_host_key_checking
|
14
|
-
)
|
15
|
+
def initialize(options)
|
16
|
+
DEFAULTS.merge(options).each do |attr, value|
|
17
|
+
unprefixed_attr = attr.to_s.sub(/^ssh_/, "")
|
18
|
+
send(:"#{unprefixed_attr}=", value)
|
19
|
+
end
|
15
20
|
freeze
|
16
21
|
end
|
17
22
|
|
@@ -33,8 +38,9 @@ module Tomo
|
|
33
38
|
|
34
39
|
private
|
35
40
|
|
36
|
-
|
37
|
-
|
41
|
+
attr_writer :executable
|
42
|
+
attr_accessor :connect_timeout, :extra_opts, :forward_agent,
|
43
|
+
:reuse_connections, :strict_host_key_checking
|
38
44
|
|
39
45
|
def control_opts(path, verbose)
|
40
46
|
opts = [
|
data/lib/tomo/ssh.rb
CHANGED
@@ -13,7 +13,9 @@ module Tomo
|
|
13
13
|
autoload :UnsupportedVersionError, "tomo/ssh/unsupported_version_error"
|
14
14
|
|
15
15
|
class << self
|
16
|
-
def connect(host:, options:)
|
16
|
+
def connect(host:, options: {})
|
17
|
+
options = Options.new(options) unless options.is_a?(Options)
|
18
|
+
|
17
19
|
Tomo.logger.connect(host)
|
18
20
|
return Connection.dry_run(host, options) if Tomo.dry_run?
|
19
21
|
|
data/lib/tomo/testing/local.rb
CHANGED
@@ -8,6 +8,18 @@ require "tmpdir"
|
|
8
8
|
module Tomo
|
9
9
|
module Testing
|
10
10
|
module Local
|
11
|
+
def in_temp_dir(&block)
|
12
|
+
Local.in_temp_dir(&block)
|
13
|
+
end
|
14
|
+
|
15
|
+
def with_tomo_gemfile(&block)
|
16
|
+
Local.with_tomo_gemfile(&block)
|
17
|
+
end
|
18
|
+
|
19
|
+
def capture(*command, raise_on_error: true)
|
20
|
+
Local.capture(*command, raise_on_error: raise_on_error)
|
21
|
+
end
|
22
|
+
|
11
23
|
class << self
|
12
24
|
def with_tomo_gemfile
|
13
25
|
Bundler.with_original_env do
|
@@ -23,12 +35,13 @@ module Tomo
|
|
23
35
|
Dir.chdir(dir, &block)
|
24
36
|
end
|
25
37
|
|
26
|
-
def capture(command, raise_on_error: true)
|
27
|
-
|
28
|
-
|
38
|
+
def capture(*command, raise_on_error: true)
|
39
|
+
command_str = command.join(" ")
|
40
|
+
progress(command_str) do
|
41
|
+
output, status = Open3.capture2e(*command)
|
29
42
|
|
30
43
|
if raise_on_error && !status.success?
|
31
|
-
raise "Command failed: #{
|
44
|
+
raise "Command failed: #{command_str}\n#{output}"
|
32
45
|
end
|
33
46
|
|
34
47
|
output
|
data/lib/tomo/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tomo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Brictson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -114,14 +114,14 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - '='
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 0.
|
117
|
+
version: 0.73.0
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - '='
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: 0.
|
124
|
+
version: 0.73.0
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: rubocop-performance
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|