travis 1.11.0 → 1.12.0
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.
- checksums.yaml +4 -4
- data/README.md +18 -4
- data/Rakefile +22 -20
- data/bin/travis +5 -3
- data/examples/org_overview.rb +2 -0
- data/examples/pro_auth.rb +3 -1
- data/examples/stream.rb +5 -3
- data/lib/travis/auto_login.rb +2 -0
- data/lib/travis/cli/accounts.rb +12 -9
- data/lib/travis/cli/api_command.rb +85 -81
- data/lib/travis/cli/branches.rb +8 -6
- data/lib/travis/cli/cache.rb +48 -44
- data/lib/travis/cli/cancel.rb +4 -2
- data/lib/travis/cli/command.rb +170 -142
- data/lib/travis/cli/console.rb +5 -5
- data/lib/travis/cli/disable.rb +4 -2
- data/lib/travis/cli/enable.rb +14 -12
- data/lib/travis/cli/encrypt.rb +57 -57
- data/lib/travis/cli/encrypt_file.rb +29 -18
- data/lib/travis/cli/endpoint.rb +9 -7
- data/lib/travis/cli/env.rb +13 -8
- data/lib/travis/cli/help.rb +10 -8
- data/lib/travis/cli/history.rb +19 -15
- data/lib/travis/cli/init.rb +27 -24
- data/lib/travis/cli/lint.rb +10 -8
- data/lib/travis/cli/login.rb +17 -11
- data/lib/travis/cli/logout.rb +4 -2
- data/lib/travis/cli/logs.rb +28 -19
- data/lib/travis/cli/monitor.rb +11 -8
- data/lib/travis/cli/open.rb +17 -14
- data/lib/travis/cli/parser.rb +2 -0
- data/lib/travis/cli/pubkey.rb +13 -11
- data/lib/travis/cli/raw.rb +4 -3
- data/lib/travis/cli/repo_command.rb +123 -112
- data/lib/travis/cli/report.rb +40 -33
- data/lib/travis/cli/repos.rb +14 -9
- data/lib/travis/cli/requests.rb +13 -12
- data/lib/travis/cli/restart.rb +4 -2
- data/lib/travis/cli/settings.rb +41 -35
- data/lib/travis/cli/setup/anynines.rb +7 -6
- data/lib/travis/cli/setup/appfog.rb +6 -4
- data/lib/travis/cli/setup/artifacts.rb +7 -5
- data/lib/travis/cli/setup/biicode.rb +6 -4
- data/lib/travis/cli/setup/cloud_66.rb +6 -4
- data/lib/travis/cli/setup/cloud_control.rb +8 -6
- data/lib/travis/cli/setup/cloud_files.rb +7 -5
- data/lib/travis/cli/setup/cloud_foundry.rb +9 -7
- data/lib/travis/cli/setup/code_deploy.rb +33 -29
- data/lib/travis/cli/setup/deis.rb +8 -6
- data/lib/travis/cli/setup/divshot.rb +20 -18
- data/lib/travis/cli/setup/elastic_beanstalk.rb +10 -8
- data/lib/travis/cli/setup/engine_yard.rb +9 -7
- data/lib/travis/cli/setup/gcs.rb +9 -7
- data/lib/travis/cli/setup/hackage.rb +6 -4
- data/lib/travis/cli/setup/heroku.rb +10 -4
- data/lib/travis/cli/setup/modulus.rb +5 -3
- data/lib/travis/cli/setup/ninefold.rb +7 -5
- data/lib/travis/cli/setup/nodejitsu.rb +6 -4
- data/lib/travis/cli/setup/npm.rb +6 -4
- data/lib/travis/cli/setup/open_shift.rb +8 -6
- data/lib/travis/cli/setup/opsworks.rb +24 -22
- data/lib/travis/cli/setup/pypi.rb +7 -5
- data/lib/travis/cli/setup/releases.rb +6 -6
- data/lib/travis/cli/setup/ruby_gems.rb +7 -5
- data/lib/travis/cli/setup/s3.rb +12 -8
- data/lib/travis/cli/setup/sauce_connect.rb +7 -5
- data/lib/travis/cli/setup/service.rb +36 -25
- data/lib/travis/cli/setup.rb +7 -3
- data/lib/travis/cli/show.rb +10 -8
- data/lib/travis/cli/sshkey.rb +31 -28
- data/lib/travis/cli/status.rb +5 -3
- data/lib/travis/cli/sync.rb +9 -7
- data/lib/travis/cli/token.rb +4 -2
- data/lib/travis/cli/version.rb +4 -3
- data/lib/travis/cli/whatsup.rb +10 -8
- data/lib/travis/cli/whoami.rb +2 -2
- data/lib/travis/cli.rb +39 -36
- data/lib/travis/client/account.rb +8 -6
- data/lib/travis/client/artifact.rb +16 -12
- data/lib/travis/client/auto_login.rb +7 -4
- data/lib/travis/client/broadcast.rb +2 -0
- data/lib/travis/client/build.rb +7 -3
- data/lib/travis/client/cache.rb +4 -2
- data/lib/travis/client/commit.rb +5 -2
- data/lib/travis/client/entity.rb +50 -46
- data/lib/travis/client/env_var.rb +13 -8
- data/lib/travis/client/error.rb +5 -3
- data/lib/travis/client/has_uuid.rb +3 -1
- data/lib/travis/client/job.rb +8 -3
- data/lib/travis/client/lint_result.rb +2 -0
- data/lib/travis/client/listener.rb +70 -55
- data/lib/travis/client/methods.rb +10 -5
- data/lib/travis/client/namespace.rb +20 -16
- data/lib/travis/client/not_loadable.rb +3 -1
- data/lib/travis/client/repository.rb +34 -22
- data/lib/travis/client/request.rb +5 -2
- data/lib/travis/client/restartable.rb +2 -0
- data/lib/travis/client/session.rb +118 -88
- data/lib/travis/client/settings.rb +8 -3
- data/lib/travis/client/singleton_setting.rb +2 -0
- data/lib/travis/client/ssh_key.rb +2 -0
- data/lib/travis/client/states.rb +8 -6
- data/lib/travis/client/user.rb +2 -0
- data/lib/travis/client/weak_entity.rb +6 -3
- data/lib/travis/client.rb +4 -1
- data/lib/travis/pro/auto_login.rb +2 -0
- data/lib/travis/pro.rb +2 -0
- data/lib/travis/tools/assets.rb +6 -3
- data/lib/travis/tools/completion.rb +10 -6
- data/lib/travis/tools/formatter.rb +20 -14
- data/lib/travis/tools/github.rb +59 -49
- data/lib/travis/tools/notification.rb +18 -13
- data/lib/travis/tools/safe_string.rb +4 -1
- data/lib/travis/tools/ssl_key.rb +5 -2
- data/lib/travis/tools/system.rb +11 -6
- data/lib/travis/version.rb +3 -1
- data/lib/travis.rb +3 -1
- data/spec/cli/api_command_spec.rb +11 -8
- data/spec/cli/cancel_spec.rb +2 -4
- data/spec/cli/encrypt_file_spec.rb +9 -7
- data/spec/cli/encrypt_spec.rb +19 -17
- data/spec/cli/endpoint_spec.rb +12 -10
- data/spec/cli/help_spec.rb +14 -12
- data/spec/cli/history_spec.rb +2 -0
- data/spec/cli/init_spec.rb +35 -33
- data/spec/cli/logs_spec.rb +2 -0
- data/spec/cli/open_spec.rb +6 -4
- data/spec/cli/repo_command_spec.rb +8 -4
- data/spec/cli/restart_spec.rb +2 -4
- data/spec/cli/setup/service_spec.rb +17 -18
- data/spec/cli/setup_spec.rb +2 -4
- data/spec/cli/show_spec.rb +4 -2
- data/spec/cli/status_spec.rb +7 -5
- data/spec/cli/token_spec.rb +7 -5
- data/spec/cli/version_spec.rb +2 -0
- data/spec/cli/whoami_spec.rb +9 -7
- data/spec/client/account_spec.rb +28 -20
- data/spec/client/auto_login_spec.rb +12 -9
- data/spec/client/broadcast_spec.rb +5 -3
- data/spec/client/build_spec.rb +28 -24
- data/spec/client/commit_spec.rb +17 -14
- data/spec/client/job_spec.rb +27 -23
- data/spec/client/methods_spec.rb +8 -4
- data/spec/client/namespace_spec.rb +8 -4
- data/spec/client/repository_spec.rb +33 -30
- data/spec/client/session_spec.rb +71 -67
- data/spec/client/user_spec.rb +13 -10
- data/spec/client_spec.rb +6 -4
- data/spec/pro_spec.rb +5 -3
- data/spec/spec_helper.rb +3 -1
- data/spec/support/fake_api.rb +662 -662
- data/spec/support/fake_github.rb +6 -3
- data/spec/support/helpers.rb +13 -8
- data/spec/travis_spec.rb +5 -3
- data/travis.gemspec +400 -399
- metadata +30 -50
data/lib/travis/cli/encrypt.rb
CHANGED
@@ -1,38 +1,39 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'travis/cli'
|
3
4
|
|
4
5
|
module Travis
|
5
6
|
module CLI
|
6
7
|
class Encrypt < RepoCommand
|
7
|
-
description
|
8
|
+
description 'encrypts values for the .travis.yml'
|
8
9
|
attr_accessor :config_key
|
9
10
|
|
10
11
|
on('-a', '--add [KEY]', 'adds it to .travis.yml under KEY (default: env.global)') do |c, value|
|
11
12
|
c.config_key = value || 'env.global'
|
12
13
|
end
|
13
14
|
|
14
|
-
on('-s', '--[no-]split',
|
15
|
+
on('-s', '--[no-]split', 'treat each line as a separate input')
|
15
16
|
on('-p', '--append', "don't override existing values, instead treat as list")
|
16
|
-
on('-x', '--override',
|
17
|
+
on('-x', '--override', 'override existing value')
|
17
18
|
|
18
19
|
def run(*args)
|
19
20
|
confirm = force_interactive.nil? || force_interactive
|
20
|
-
error
|
21
|
-
error
|
22
|
-
error
|
23
|
-
self.override |= !config_key.start_with?('env.') if add?
|
21
|
+
error 'cannot combine --override and --append' if append? && override?
|
22
|
+
error '--append without --add makes no sense' if append? && !add?
|
23
|
+
error '--override without --add makes no sense' if override? && !add?
|
24
|
+
self.override |= !config_key.start_with?('env.') if add? && !append?
|
24
25
|
|
25
|
-
if args.first =~ %r{\w+/\w+} && !args.first.include?(
|
26
|
-
warn
|
26
|
+
if args.first =~ %r{\w+/\w+} && !args.first.include?('=')
|
27
|
+
warn 'WARNING: The name of the repository is now passed to the command with the -r option:'
|
27
28
|
warn " #{command("encrypt [...] -r #{args.first}")}"
|
28
|
-
warn
|
29
|
+
warn ' If you tried to pass the name of the repository as the first argument, you'
|
29
30
|
warn " probably won't get the results you wanted.\n"
|
30
31
|
end
|
31
32
|
|
32
|
-
data = args.join(
|
33
|
+
data = args.join(' ')
|
33
34
|
|
34
35
|
if data.empty?
|
35
|
-
say color(
|
36
|
+
say color('Reading from stdin, press Ctrl+D when done', :info) if $stdin.tty?
|
36
37
|
data = $stdin.read
|
37
38
|
end
|
38
39
|
|
@@ -41,69 +42,68 @@ module Travis
|
|
41
42
|
encrypted = data.map { |data| repository.encrypt(data) }
|
42
43
|
|
43
44
|
if config_key
|
44
|
-
set_config
|
45
|
+
set_config(encrypted.map { |e| { 'secure' => e } })
|
45
46
|
confirm_and_save_travis_config confirm
|
46
47
|
else
|
47
|
-
list = encrypted.map { |data| format(data.inspect,
|
48
|
+
list = encrypted.map { |data| format(data.inspect, ' secure: %s') }
|
48
49
|
say(list.join("\n"), template(__FILE__), :none)
|
49
50
|
end
|
50
|
-
rescue OpenSSL::PKey::RSAError =>
|
51
|
-
error "#{
|
52
|
-
|
53
|
-
|
54
|
-
|
51
|
+
rescue OpenSSL::PKey::RSAError => e
|
52
|
+
error "#{e.message.sub(' for key size', '')} - consider using " <<
|
53
|
+
color('travis encrypt-file', %i[red bold]) <<
|
54
|
+
color(' or ', :red) <<
|
55
|
+
color('travis env set', %i[red bold])
|
55
56
|
end
|
56
57
|
|
57
58
|
private
|
58
59
|
|
59
|
-
|
60
|
-
|
61
|
-
|
60
|
+
def add?
|
61
|
+
!!config_key
|
62
|
+
end
|
62
63
|
|
63
|
-
|
64
|
-
|
65
|
-
|
64
|
+
def set_config(result)
|
65
|
+
parent_config[last_key] = merge_config(result)
|
66
|
+
end
|
66
67
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
end
|
68
|
+
def merge_config(result)
|
69
|
+
case subconfig = (parent_config[last_key] unless override?)
|
70
|
+
when nil then result.size == 1 ? result.first : result
|
71
|
+
when Array then subconfig + result
|
72
|
+
else result.unshift(subconfig)
|
73
73
|
end
|
74
|
+
end
|
74
75
|
|
75
|
-
|
76
|
-
end
|
76
|
+
def subconfig; end
|
77
77
|
|
78
|
-
|
79
|
-
|
80
|
-
|
78
|
+
def key_chain
|
79
|
+
@key_chain ||= config_key.split('.')
|
80
|
+
end
|
81
81
|
|
82
|
-
|
83
|
-
|
84
|
-
|
82
|
+
def last_key
|
83
|
+
key_chain.last
|
84
|
+
end
|
85
85
|
|
86
|
-
|
87
|
-
|
88
|
-
|
86
|
+
def parent_config
|
87
|
+
@parent_config ||= traverse_config(travis_config, *key_chain[0..-2])
|
88
|
+
end
|
89
89
|
|
90
|
-
|
91
|
-
|
90
|
+
def traverse_config(hash, key = nil, *rest)
|
91
|
+
return hash unless key
|
92
92
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
93
|
+
hash[key] = case value = hash[key]
|
94
|
+
when nil then {}
|
95
|
+
when Hash then value
|
96
|
+
else { 'matrix' => Array(value) }
|
97
|
+
end
|
98
98
|
|
99
|
-
|
100
|
-
|
99
|
+
traverse_config(hash[key], *rest)
|
100
|
+
end
|
101
101
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
102
|
+
def warn_env_assignments(data)
|
103
|
+
return unless /env/.match(config_key) && data.find { |d| /=/.match(d).nil? }
|
104
|
+
|
105
|
+
warn "Environment variables in #{config_key} should be formatted as FOO=bar"
|
106
|
+
end
|
107
107
|
end
|
108
108
|
end
|
109
109
|
end
|
@@ -1,4 +1,5 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'travis/cli'
|
3
4
|
require 'travis/tools/system'
|
4
5
|
|
@@ -11,6 +12,7 @@ module Travis
|
|
11
12
|
module CLI
|
12
13
|
class EncryptFile < RepoCommand
|
13
14
|
attr_accessor :stage
|
15
|
+
|
14
16
|
description 'encrypts a file and adds decryption steps to .travis.yml'
|
15
17
|
on '-K', '--key KEY', 'encryption key to be used (randomly generated otherwise)'
|
16
18
|
on '--iv IV', 'encryption IV to be used (randomly generated otherwise)'
|
@@ -18,7 +20,8 @@ module Travis
|
|
18
20
|
on '-f', '--force', 'override output file if it exists'
|
19
21
|
on '-p', '--print-key', 'print (possibly generated) key and iv'
|
20
22
|
on '-w', '--decrypt-to PATH', 'where to write the decrypted file to on the Travis CI VM'
|
21
|
-
on '-a', '--add [STAGE]',
|
23
|
+
on '-a', '--add [STAGE]',
|
24
|
+
'automatically add command to .travis.yml (default stage is before_install)' do |c, stage|
|
22
25
|
c.stage = stage || 'before_install'
|
23
26
|
end
|
24
27
|
|
@@ -37,7 +40,7 @@ module Travis
|
|
37
40
|
write_file(output_path, result, force)
|
38
41
|
return if decrypt?
|
39
42
|
|
40
|
-
error
|
43
|
+
error 'requires --decrypt-to option when reading from stdin' unless decrypt_to?
|
41
44
|
|
42
45
|
set_env_vars(input_path)
|
43
46
|
|
@@ -52,8 +55,8 @@ module Travis
|
|
52
55
|
super
|
53
56
|
self.key ||= SecureRandom.hex(32) unless decrypt?
|
54
57
|
self.iv ||= SecureRandom.hex(16) unless decrypt?
|
55
|
-
error
|
56
|
-
error
|
58
|
+
error 'key must be 64 characters long and a valid hex number' unless key =~ /^[a-f0-9]{64}$/
|
59
|
+
error 'iv must be 32 characters long and a valid hex number' unless iv =~ /^[a-f0-9]{32}$/
|
57
60
|
end
|
58
61
|
|
59
62
|
def print_command(command)
|
@@ -69,13 +72,15 @@ module Travis
|
|
69
72
|
end
|
70
73
|
|
71
74
|
def decrypt_command(path)
|
72
|
-
"openssl aes-256-cbc -K $#{env_name(path,
|
75
|
+
"openssl aes-256-cbc -K $#{env_name(path,
|
76
|
+
:key)} -iv $#{env_name(path,
|
77
|
+
:iv)} -in #{escape_path(path)} -out #{escape_path(decrypt_to)} -d"
|
73
78
|
end
|
74
79
|
|
75
80
|
def set_env_vars(input_path)
|
76
|
-
say
|
77
|
-
repository.env_vars.upsert env_name(input_path, :key), key, :
|
78
|
-
repository.env_vars.upsert env_name(input_path, :iv), iv, :
|
81
|
+
say 'storing secure env variables for decryption'
|
82
|
+
repository.env_vars.upsert env_name(input_path, :key), key, public: false
|
83
|
+
repository.env_vars.upsert env_name(input_path, :iv), iv, public: false
|
79
84
|
end
|
80
85
|
|
81
86
|
def env_name(input_path, name)
|
@@ -84,20 +89,24 @@ module Travis
|
|
84
89
|
end
|
85
90
|
|
86
91
|
def notes(input_path, output_path)
|
87
|
-
say "\nkey: #{color(key, :info)}\niv: #{color(iv,
|
92
|
+
say "\nkey: #{color(key, :info)}\niv: #{color(iv, :info)}" if print_key?
|
88
93
|
empty_line
|
89
94
|
say "Make sure to add #{color(output_path, :info)} to the git repository."
|
90
|
-
|
95
|
+
if input_path != '-'
|
96
|
+
say "Make sure #{color('not',
|
97
|
+
:underline)} to add #{color(input_path,
|
98
|
+
:info)} to the git repository."
|
99
|
+
end
|
91
100
|
say "Commit all changes to your #{color('.travis.yml', :info)}."
|
92
101
|
end
|
93
102
|
|
94
103
|
def transcode(input_path)
|
95
104
|
description = "stdin#{' (waiting for input)' if $stdin.tty?}" if input_path == '-'
|
96
|
-
say "#{decrypt ?
|
105
|
+
say "#{decrypt ? 'de' : 'en'}crypting #{color(description || input_path, :info)} for #{color(slug, :info)}"
|
97
106
|
|
98
107
|
data = input_path == '-' ? $stdin.read : File.binread(input_path)
|
99
108
|
aes = OpenSSL::Cipher.new('AES-256-CBC')
|
100
|
-
decrypt
|
109
|
+
decrypt ? aes.decrypt : aes.encrypt
|
101
110
|
aes.key = [key].pack('H*')
|
102
111
|
aes.iv = [iv].pack('H*')
|
103
112
|
|
@@ -106,6 +115,7 @@ module Travis
|
|
106
115
|
|
107
116
|
def decrypt_to_for(input_path)
|
108
117
|
return if input_path == '-'
|
118
|
+
|
109
119
|
if input_path.start_with? Dir.home
|
110
120
|
input_path.sub(Dir.home, '~')
|
111
121
|
else
|
@@ -114,18 +124,19 @@ module Travis
|
|
114
124
|
end
|
115
125
|
|
116
126
|
def escape_path(path)
|
117
|
-
Shellwords.escape(path).sub(
|
127
|
+
Shellwords.escape(path).sub(%r{^\\~/}, '~\/')
|
118
128
|
end
|
119
129
|
|
120
130
|
def output_path_for(input_path)
|
121
131
|
case input_path
|
122
132
|
when '-' then return '-'
|
123
|
-
when /^(.+)\.enc$/ then return
|
124
|
-
when /^(.+)\.dec$/ then return
|
133
|
+
when /^(.+)\.enc$/ then return ::Regexp.last_match(1) if decrypt?
|
134
|
+
when /^(.+)\.dec$/ then return ::Regexp.last_match(1) unless decrypt?
|
125
135
|
end
|
126
136
|
|
127
|
-
if interactive?
|
128
|
-
|
137
|
+
if interactive? && input_path =~ /(\.enc|\.dec)$/ && !(danger_zone? "File extension of input file is #{color(::Regexp.last_match(1),
|
138
|
+
:info)}, are you sure that is correct?")
|
139
|
+
exit 1
|
129
140
|
end
|
130
141
|
|
131
142
|
"#{input_path}.#{decrypt ? 'dec' : 'enc'}"
|
data/lib/travis/cli/endpoint.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'travis/cli'
|
2
4
|
|
3
5
|
module Travis
|
4
6
|
module CLI
|
5
7
|
class Endpoint < ApiCommand
|
6
|
-
description
|
8
|
+
description 'displays or changes the API endpoint'
|
7
9
|
|
8
10
|
skip :authenticate
|
9
11
|
on '--drop-default', 'delete stored default endpoint'
|
@@ -11,19 +13,19 @@ module Travis
|
|
11
13
|
on '--github', 'display github endpoint'
|
12
14
|
|
13
15
|
def run_github
|
14
|
-
error
|
15
|
-
error
|
16
|
+
error '--github cannot be combined with --drop-default' if drop_default?
|
17
|
+
error '--github cannot be combined with --set-default' if set_default?
|
16
18
|
load_gh
|
17
|
-
say github_endpoint.to_s,
|
19
|
+
say github_endpoint.to_s, 'GitHub endpoint: %s'
|
18
20
|
end
|
19
21
|
|
20
22
|
def run_travis
|
21
|
-
if drop_default?
|
23
|
+
if drop_default? && (was = config['default_endpoint'])
|
22
24
|
config.delete('default_endpoint')
|
23
|
-
say was,
|
25
|
+
say was, 'default API endpoint dropped (was %s)'
|
24
26
|
else
|
25
27
|
config['default_endpoint'] = api_endpoint if set_default?
|
26
|
-
say api_endpoint, "API endpoint: %s#{
|
28
|
+
say api_endpoint, "API endpoint: %s#{' (stored as default)' if set_default?}"
|
27
29
|
end
|
28
30
|
end
|
29
31
|
|
data/lib/travis/cli/env.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'travis/cli'
|
2
4
|
require 'shellwords'
|
3
5
|
|
@@ -5,11 +7,11 @@ module Travis
|
|
5
7
|
module CLI
|
6
8
|
class Env < RepoCommand
|
7
9
|
on('-P', '--[no-]public', 'make new values public')
|
8
|
-
on('-p', '--[no-]private', 'make new values private') { |c,v| c.public = !v }
|
10
|
+
on('-p', '--[no-]private', 'make new values private') { |c, v| c.public = !v }
|
9
11
|
on('-u', '--[no-]unescape', 'do not escape values')
|
10
12
|
on('-f', '--force', 'do not ask for confirmation when clearing out all variables')
|
11
13
|
|
12
|
-
description
|
14
|
+
description 'show or modify build environment variables'
|
13
15
|
subcommands :list, :set, :unset, :copy, :clear
|
14
16
|
|
15
17
|
def setup
|
@@ -19,8 +21,8 @@ module Travis
|
|
19
21
|
end
|
20
22
|
|
21
23
|
def set(name, value)
|
22
|
-
options ||= { :
|
23
|
-
say color('[+] ', [
|
24
|
+
options ||= { public: } unless public.nil?
|
25
|
+
say color('[+] ', %i[green bold]) + "setting environment variable #{color "$#{name}", :info}"
|
24
26
|
value = Shellwords.escape(value) unless unescape?
|
25
27
|
env_vars.upsert(name, value, options || {})
|
26
28
|
end
|
@@ -41,21 +43,24 @@ module Travis
|
|
41
43
|
|
42
44
|
def clear
|
43
45
|
exit if env_vars.empty?
|
44
|
-
exit 1 if interactive?
|
46
|
+
exit 1 if interactive? && !force? && !danger_zone?("Clear out all env variables for #{color(
|
47
|
+
repository.slug, :bold
|
48
|
+
)}?")
|
45
49
|
remove_vars
|
46
50
|
end
|
47
51
|
|
48
52
|
def remove_vars
|
49
53
|
env_vars.each do |var|
|
50
|
-
next if block_given?
|
51
|
-
|
54
|
+
next if block_given? && !yield(var)
|
55
|
+
|
56
|
+
say color('[x] ', %i[red bold]) + "removing environment variable #{color "$#{var.name}", :info}"
|
52
57
|
var.delete
|
53
58
|
end
|
54
59
|
end
|
55
60
|
|
56
61
|
def list
|
57
62
|
say color("# environment variables for #{color repository.slug, :bold}", :info)
|
58
|
-
env_vars.each { |v| say "#{v.name}=" << color(v.value ||
|
63
|
+
env_vars.each { |v| say "#{v.name}=" << color(v.value || '[secure]', :bold) }
|
59
64
|
end
|
60
65
|
|
61
66
|
def env_vars
|
data/lib/travis/cli/help.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'travis/cli'
|
2
4
|
|
3
5
|
module Travis
|
4
6
|
module CLI
|
5
7
|
class Help < Command
|
6
|
-
description
|
8
|
+
description 'helps you out when in dire need of information'
|
7
9
|
|
8
10
|
CommandGroup = Struct.new(:cmds, :header)
|
9
11
|
|
@@ -22,7 +24,7 @@ module Travis
|
|
22
24
|
say " #{color(cmd.command_name, :command).ljust(22)} #{color(cmd.description, :info)}"
|
23
25
|
end
|
24
26
|
end
|
25
|
-
say "\nrun
|
27
|
+
say "\nrun `#{$PROGRAM_NAME} help COMMAND` for more info"
|
26
28
|
end
|
27
29
|
end
|
28
30
|
|
@@ -33,20 +35,20 @@ module Travis
|
|
33
35
|
def api_commands
|
34
36
|
CLI.commands.select do |cmd|
|
35
37
|
cmd.ancestors.include?(CLI::ApiCommand) &&
|
36
|
-
|
37
|
-
end.sort_by {|c| c.command_name}
|
38
|
+
!cmd.ancestors.include?(CLI::RepoCommand)
|
39
|
+
end.sort_by { |c| c.command_name }
|
38
40
|
end
|
39
41
|
|
40
42
|
def repo_commands
|
41
43
|
CLI.commands.select do |cmd|
|
42
44
|
cmd.ancestors.include? CLI::RepoCommand
|
43
|
-
end.sort_by {|c| c.command_name}
|
45
|
+
end.sort_by { |c| c.command_name }
|
44
46
|
end
|
45
47
|
|
46
48
|
def other_commands
|
47
|
-
CLI.commands.
|
48
|
-
|
49
|
-
end.sort_by {|c| c.command_name}
|
49
|
+
CLI.commands.reject do |cmd|
|
50
|
+
cmd.ancestors.include? CLI::ApiCommand
|
51
|
+
end.sort_by { |c| c.command_name }
|
50
52
|
end
|
51
53
|
end
|
52
54
|
end
|
data/lib/travis/cli/history.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'travis/cli'
|
2
4
|
|
3
5
|
module Travis
|
@@ -15,9 +17,10 @@ module Travis
|
|
15
17
|
|
16
18
|
def run
|
17
19
|
countdown = Integer(limit || 10) unless all?
|
18
|
-
params = { :
|
20
|
+
params = { after_number: after } if after
|
19
21
|
repository.each_build(params) do |build|
|
20
22
|
next unless display? build
|
23
|
+
|
21
24
|
display(build)
|
22
25
|
|
23
26
|
if countdown
|
@@ -29,21 +32,22 @@ module Travis
|
|
29
32
|
|
30
33
|
private
|
31
34
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
true
|
36
|
-
end
|
35
|
+
def display?(build)
|
36
|
+
return build.pr_number == pull_request.to_i if pull_request
|
37
|
+
return build.branch_info == branch if branch
|
37
38
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
39
|
+
true
|
40
|
+
end
|
41
|
+
|
42
|
+
def display(build)
|
43
|
+
say [
|
44
|
+
date? && color(formatter.time(build.finished_at || build.started_at), build.color),
|
45
|
+
color("##{build.number} #{build.state}:".ljust(16), [build.color, :bold]),
|
46
|
+
color(build.branch_info.to_s, :info),
|
47
|
+
committer? && build.commit.author_name.ljust(25),
|
48
|
+
build.commit.subject
|
49
|
+
].compact.join(' ').strip + "\n"
|
50
|
+
end
|
47
51
|
end
|
48
52
|
end
|
49
53
|
end
|
data/lib/travis/cli/init.rb
CHANGED
@@ -1,18 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'travis/cli'
|
2
4
|
|
3
5
|
module Travis
|
4
6
|
module CLI
|
5
7
|
class Init < Enable
|
6
8
|
LANGUAGE_MAPPING = {
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
}
|
9
|
+
'node' => 'node_js',
|
10
|
+
'node.js' => 'node_js',
|
11
|
+
'javascript' => 'node_js',
|
12
|
+
'coffeescript' => 'node_js',
|
13
|
+
'c++' => 'cpp',
|
14
|
+
'obj-c' => 'objective-c'
|
15
|
+
}.freeze
|
14
16
|
|
15
|
-
description
|
17
|
+
description 'generates a .travis.yml and enables the project'
|
16
18
|
|
17
19
|
on('-f', '--force', 'override .travis.yml if it already exists')
|
18
20
|
on('-k', '--skip-enable', 'do not enable project, only add .travis.yml')
|
@@ -25,7 +27,8 @@ module Travis
|
|
25
27
|
]
|
26
28
|
|
27
29
|
options.each do |option|
|
28
|
-
on "--#{option.gsub('_', '-')} VALUE",
|
30
|
+
on "--#{option.gsub('_', '-')} VALUE",
|
31
|
+
"sets #{option} option in .travis.yml (can be used more than once)" do |c, value|
|
29
32
|
c.custom_config[option] &&= Array(c.custom_config[option]) << value
|
30
33
|
c.custom_config[option] ||= value
|
31
34
|
end
|
@@ -39,11 +42,11 @@ module Travis
|
|
39
42
|
end
|
40
43
|
|
41
44
|
def help
|
42
|
-
super("Available languages: #{self.class.languages.join(
|
45
|
+
super("Available languages: #{self.class.languages.join(', ')}\n\n")
|
43
46
|
end
|
44
47
|
|
45
48
|
def run(language = nil, file = '.travis.yml')
|
46
|
-
error "#{file} already exists, use --force to override" if File.exist?(file)
|
49
|
+
error "#{file} already exists, use --force to override" if File.exist?(file) && !force? && !print_conf?
|
47
50
|
language ||= ask('Main programming language used: ') { |q| q.default = detect_language }
|
48
51
|
self.travis_config = template(language).merge(custom_config)
|
49
52
|
|
@@ -63,21 +66,21 @@ module Travis
|
|
63
66
|
|
64
67
|
private
|
65
68
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
+
def template_name(language)
|
70
|
+
asset_path("init/#{language}.yml")
|
71
|
+
end
|
69
72
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
73
|
+
def template(language)
|
74
|
+
language = language.to_s.downcase
|
75
|
+
language = LANGUAGE_MAPPING[language] || language
|
76
|
+
file = template_name(language)
|
77
|
+
error "unknown language #{language}" unless File.exist? file
|
78
|
+
YAML.load_file(file)
|
79
|
+
end
|
77
80
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
+
def detect_language
|
82
|
+
repository.github_language || 'Ruby'
|
83
|
+
end
|
81
84
|
end
|
82
85
|
end
|
83
86
|
end
|
data/lib/travis/cli/lint.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'travis/cli'
|
2
4
|
require 'yaml'
|
3
5
|
|
@@ -9,15 +11,15 @@ module Travis
|
|
9
11
|
on '-x', '--[no-]exit-code', 'sets the exit code to 1 if there are warning'
|
10
12
|
|
11
13
|
def run(file = nil)
|
12
|
-
file ||= '.travis.yml' if $stdin.tty?
|
14
|
+
file ||= '.travis.yml' if $stdin.tty? || $stdin.eof?
|
13
15
|
|
14
|
-
if file
|
16
|
+
if file && (file != '-')
|
15
17
|
debug "reading #{file}"
|
16
18
|
error "file does not exist: #{color(file, :bold)}" unless File.exist? file
|
17
19
|
error "cannot read #{color(file, :bold)}" unless File.readable? file
|
18
20
|
content = File.read(file)
|
19
21
|
else
|
20
|
-
debug
|
22
|
+
debug 'reading stdin'
|
21
23
|
file = 'STDIN'
|
22
24
|
content = $stdin.read
|
23
25
|
end
|
@@ -32,24 +34,24 @@ module Travis
|
|
32
34
|
|
33
35
|
unless quiet?
|
34
36
|
if lint.ok?
|
35
|
-
say
|
37
|
+
say 'valid', color("Hooray, #{file} looks %s :)", :success)
|
36
38
|
else
|
37
39
|
say "Warnings for #{color(file, :info)}:"
|
38
40
|
lint.warnings.each do |warning|
|
39
|
-
say color('[x]', [
|
41
|
+
say "#{color('[x]', %i[red bold])} "
|
40
42
|
if warning.key.any?
|
41
43
|
say [
|
42
44
|
color('in ', :info),
|
43
|
-
color(warning.key.join('.'), [
|
45
|
+
color(warning.key.join('.'), %i[info bold underline]),
|
44
46
|
color(' section:', :info), ' '
|
45
47
|
].join
|
46
48
|
end
|
47
|
-
say warning.message.gsub(/"(.*?)"/) { color(
|
49
|
+
say warning.message.gsub(/"(.*?)"/) { color(::Regexp.last_match(1), %i[info important]) }
|
48
50
|
end
|
49
51
|
end
|
50
52
|
end
|
51
53
|
|
52
|
-
exit 1 if lint.warnings?
|
54
|
+
exit 1 if lint.warnings? && exit_code?
|
53
55
|
end
|
54
56
|
end
|
55
57
|
end
|