tomo 0.17.0 → 0.18.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/console.rb +7 -10
- data/lib/tomo/console/non_interactive_error.rb +27 -0
- data/lib/tomo/plugin/env/tasks.rb +8 -2
- data/lib/tomo/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24569b9d203580630d124df5ed6d5f42c4c5c8a8d7c2c9e6c2844abb662f03fb
|
4
|
+
data.tar.gz: f154292556548e3dab819e4fdd3e57395f4ebd0fef3ad17cf291689ea848aee8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e6ded002068ec55394a73e0799e5c1d0f4ae68b1c549cfe438f7ff665d003d9a9d102f3b10cb8515e47013117f38a076c373c9f74cb21735524887be6a21c65
|
7
|
+
data.tar.gz: ab85142a4744db02d8a0e5be818175e292531dfaef14626c35e9c0e9dc36793330e5c44b9e12cf3769c36c1b0087f5571a89f5c5ec010defcef9561b64ec57b8
|
data/lib/tomo/console.rb
CHANGED
@@ -5,6 +5,7 @@ module Tomo
|
|
5
5
|
class Console
|
6
6
|
autoload :KeyReader, "tomo/console/key_reader"
|
7
7
|
autoload :Menu, "tomo/console/menu"
|
8
|
+
autoload :NonInteractiveError, "tomo/console/non_interactive_error"
|
8
9
|
|
9
10
|
class << self
|
10
11
|
extend Forwardable
|
@@ -46,14 +47,13 @@ module Tomo
|
|
46
47
|
CI_VARS = %w[
|
47
48
|
JENKINS_HOME
|
48
49
|
JENKINS_URL
|
50
|
+
GITHUB_ACTION
|
49
51
|
TRAVIS
|
50
52
|
CIRCLECI
|
51
|
-
CI
|
52
53
|
TEAMCITY_VERSION
|
53
|
-
GO_PIPELINE_NAME
|
54
54
|
bamboo_buildKey
|
55
55
|
GITLAB_CI
|
56
|
-
|
56
|
+
CI
|
57
57
|
].freeze
|
58
58
|
private_constant :CI_VARS
|
59
59
|
|
@@ -66,13 +66,10 @@ module Tomo
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def raise_non_interactive
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
This appears to be a CI environment because the #{env_var} env var is set.
|
74
|
-
Tomo::Console cannot be used in a non-interactive CI environment.
|
75
|
-
ERROR
|
69
|
+
NonInteractiveError.raise_with(
|
70
|
+
task: Runtime::Current.task,
|
71
|
+
ci_var: (env.keys & CI_VARS).first
|
72
|
+
)
|
76
73
|
end
|
77
74
|
end
|
78
75
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Tomo
|
2
|
+
class Console
|
3
|
+
class NonInteractiveError < Tomo::Error
|
4
|
+
attr_accessor :task, :ci_var
|
5
|
+
|
6
|
+
def to_console
|
7
|
+
error = ""
|
8
|
+
error << "#{operation_name} requires an interactive console."
|
9
|
+
error << "\n\n#{seems_like_ci}" if ci_var
|
10
|
+
error
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def seems_like_ci
|
16
|
+
<<~ERROR
|
17
|
+
This appears to be a non-interactive CI environment because the
|
18
|
+
#{yellow(ci_var)} environment variable is set.
|
19
|
+
ERROR
|
20
|
+
end
|
21
|
+
|
22
|
+
def operation_name
|
23
|
+
task ? "The #{yellow(task)} task" : "Tomo::Console"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -14,6 +14,7 @@ module Tomo::Plugin::Env
|
|
14
14
|
modify_bashrc
|
15
15
|
end
|
16
16
|
|
17
|
+
# rubocop:disable Metrics/MethodLength
|
17
18
|
def update
|
18
19
|
return if settings[:env_vars].empty?
|
19
20
|
|
@@ -21,11 +22,15 @@ module Tomo::Plugin::Env
|
|
21
22
|
settings[:env_vars].each do |name, value|
|
22
23
|
next if value == :prompt && contains_entry?(env, name)
|
23
24
|
|
24
|
-
value = prompt_for(name) if value == :prompt
|
25
|
+
value = prompt_for(name, message: <<~MSG) if value == :prompt
|
26
|
+
The remote host needs a value for the $#{name} environment variable.
|
27
|
+
Please provide a value at the prompt.
|
28
|
+
MSG
|
25
29
|
replace_entry(env, name, value)
|
26
30
|
end
|
27
31
|
end
|
28
32
|
end
|
33
|
+
# rubocop:enable Metrics/MethodLength
|
29
34
|
|
30
35
|
def set
|
31
36
|
return if settings[:run_args].empty?
|
@@ -88,11 +93,12 @@ module Tomo::Plugin::Env
|
|
88
93
|
text.match?(/^export #{Regexp.quote(name.to_s.shellescape)}=/)
|
89
94
|
end
|
90
95
|
|
91
|
-
def prompt_for(name)
|
96
|
+
def prompt_for(name, message: nil)
|
92
97
|
synchronize do
|
93
98
|
@answers ||= {}
|
94
99
|
next @answers[name] if @answers.key?(name)
|
95
100
|
|
101
|
+
logger.info(message) if message
|
96
102
|
@answers[name] = Tomo::Console.prompt("#{name}? ")
|
97
103
|
end
|
98
104
|
end
|
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.18.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: 2020-01-
|
11
|
+
date: 2020-01-23 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.79.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.79.0
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: rubocop-minitest
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -217,6 +217,7 @@ files:
|
|
217
217
|
- lib/tomo/console.rb
|
218
218
|
- lib/tomo/console/key_reader.rb
|
219
219
|
- lib/tomo/console/menu.rb
|
220
|
+
- lib/tomo/console/non_interactive_error.rb
|
220
221
|
- lib/tomo/error.rb
|
221
222
|
- lib/tomo/error/suggestions.rb
|
222
223
|
- lib/tomo/host.rb
|