u3d 1.2.3 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.circleci/config.yml +33 -10
- data/.github/workflows/ci.yml +35 -0
- data/.github_changelog_generator +3 -1
- data/.gitignore +1 -0
- data/.rubocop.yml +15 -3
- data/CHANGELOG.md +86 -11
- data/Gemfile.lock +149 -87
- data/Rakefile +13 -8
- data/examples/Example1/Gemfile +4 -2
- data/examples/Example1/Gemfile.lock +8 -6
- data/examples/Example1/Rakefile +2 -0
- data/examples/Example1/fastlane/Fastfile +2 -0
- data/examples/Example2/Gemfile +4 -2
- data/examples/Example2/Gemfile.lock +12 -7
- data/examples/Example2/fastlane/Fastfile +2 -0
- data/exe/u3d +3 -1
- data/lib/u3d/asset.rb +6 -2
- data/lib/u3d/cache.rb +14 -10
- data/lib/u3d/commands.rb +14 -9
- data/lib/u3d/commands_generator.rb +6 -4
- data/lib/u3d/compatibility.rb +2 -0
- data/lib/u3d/download_validator.rb +6 -3
- data/lib/u3d/downloader.rb +12 -8
- data/lib/u3d/failure_reporter.rb +4 -3
- data/lib/u3d/hub_modules_parser.rb +24 -7
- data/lib/u3d/ini_modules_parser.rb +10 -8
- data/lib/u3d/installation.rb +31 -49
- data/lib/u3d/installer.rb +44 -33
- data/lib/u3d/log_analyzer.rb +31 -27
- data/lib/u3d/unity_license.rb +2 -0
- data/lib/u3d/unity_module.rb +2 -0
- data/lib/u3d/unity_project.rb +4 -1
- data/lib/u3d/unity_runner.rb +12 -10
- data/lib/u3d/unity_version_definition.rb +3 -0
- data/lib/u3d/unity_version_number.rb +8 -2
- data/lib/u3d/unity_versions.rb +28 -23
- data/lib/u3d/utils.rb +86 -15
- data/lib/u3d/version.rb +8 -6
- data/lib/u3d.rb +2 -0
- data/lib/u3d_core/admin_tools.rb +2 -0
- data/lib/u3d_core/command_executor.rb +11 -7
- data/lib/u3d_core/command_runner.rb +17 -19
- data/lib/u3d_core/core_ext/hash.rb +2 -0
- data/lib/u3d_core/core_ext/operating_system_symbol.rb +3 -0
- data/lib/u3d_core/core_ext/string.rb +2 -0
- data/lib/u3d_core/credentials.rb +9 -7
- data/lib/u3d_core/env.rb +3 -0
- data/lib/u3d_core/globals.rb +7 -7
- data/lib/u3d_core/helper.rb +6 -4
- data/lib/u3d_core/ui/disable_colors.rb +2 -0
- data/lib/u3d_core/ui/implementations/shell.rb +8 -5
- data/lib/u3d_core/ui/interface.rb +3 -0
- data/lib/u3d_core/ui/ui.rb +5 -4
- data/lib/u3d_core/update_checker/changelog.rb +4 -0
- data/lib/u3d_core/update_checker/update_checker.rb +8 -9
- data/lib/u3d_core/version.rb +2 -0
- data/lib/u3d_core.rb +2 -0
- data/u3d.gemspec +20 -9
- metadata +112 -28
- data/appveyor.yml +0 -21
data/lib/u3d/utils.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
## --- BEGIN LICENSE BLOCK ---
|
2
4
|
# Copyright (c) 2016-present WeWantToKnow AS
|
3
5
|
#
|
@@ -27,11 +29,11 @@ require 'u3d_core/helper'
|
|
27
29
|
|
28
30
|
module U3d
|
29
31
|
# Several different utility methods
|
30
|
-
# rubocop:disable ModuleLength
|
32
|
+
# rubocop:disable Metrics/ModuleLength
|
31
33
|
module Utils
|
32
34
|
# Regex to capture each part of a version string (0.0.0x0)
|
33
35
|
CSIDL_LOCAL_APPDATA = 0x001c
|
34
|
-
UNITY_VERSION_REGEX = /(\d+)(?:\.(\d+)(?:\.(\d+))?)?(?:(\w)(?:(\d+))?)
|
36
|
+
UNITY_VERSION_REGEX = /(\d+)(?:\.(\d+)(?:\.(\d+))?)?(?:(\w)(?:(\d+))?)?/.freeze
|
35
37
|
|
36
38
|
class << self
|
37
39
|
def final_url(url, redirect_limit: 10)
|
@@ -53,6 +55,7 @@ module U3d
|
|
53
55
|
|
54
56
|
def follow_redirects(url, redirect_limit: 10, http_method: :get, request_headers: {}, &block)
|
55
57
|
raise 'Too many redirections' if redirect_limit.zero?
|
58
|
+
|
56
59
|
response = nil
|
57
60
|
request = nil
|
58
61
|
uri = URI(url)
|
@@ -65,15 +68,15 @@ module U3d
|
|
65
68
|
end
|
66
69
|
response = http.request request
|
67
70
|
end
|
68
|
-
rescue OpenSSL::OpenSSLError =>
|
71
|
+
rescue OpenSSL::OpenSSLError => e
|
69
72
|
UI.error 'SSL has faced an error, you may want to check our README to fix it'
|
70
|
-
raise
|
73
|
+
raise e
|
71
74
|
end
|
72
75
|
|
73
76
|
case response
|
74
|
-
when Net::HTTPSuccess
|
77
|
+
when Net::HTTPSuccess
|
75
78
|
yield(request, response)
|
76
|
-
when Net::HTTPRedirection
|
79
|
+
when Net::HTTPRedirection
|
77
80
|
UI.verbose "Redirected to #{response['location']}"
|
78
81
|
follow_redirects(response['location'], redirect_limit: redirect_limit - 1, http_method: http_method, request_headers: request_headers, &block)
|
79
82
|
else raise "Request failed with status #{response.code}"
|
@@ -83,6 +86,7 @@ module U3d
|
|
83
86
|
def http_request_class(method, uri)
|
84
87
|
return Net::HTTP::Get.new uri if method == :get
|
85
88
|
return Net::HTTP::Head.new uri if method == :head
|
89
|
+
|
86
90
|
raise "Unknown method #{method}"
|
87
91
|
end
|
88
92
|
|
@@ -111,10 +115,12 @@ module U3d
|
|
111
115
|
# FIXME revisits, this slows down download on fast network
|
112
116
|
# sleep 0.08 # adjust to reduce CPU
|
113
117
|
next unless print_progress
|
118
|
+
|
114
119
|
print_progress_now = Time.now.to_f - last_print_update > 0.5
|
115
120
|
# force printing when done downloading
|
116
121
|
print_progress_now = true if !print_progress_now && size && current >= size
|
117
122
|
next unless print_progress_now
|
123
|
+
|
118
124
|
last_print_update = Time.now.to_f
|
119
125
|
Utils.print_progress(current, size, started_at)
|
120
126
|
print "\n" unless UI.interactive?
|
@@ -140,6 +146,7 @@ module U3d
|
|
140
146
|
def hashfile(file_path, blocksize: 65_536)
|
141
147
|
require 'digest'
|
142
148
|
raise ArgumentError, 'Not a file' unless File.file?(file_path)
|
149
|
+
|
143
150
|
md5 = Digest::MD5.new
|
144
151
|
File.open(file_path, 'r') do |f|
|
145
152
|
md5 << f.read(blocksize) until f.eof?
|
@@ -155,9 +162,10 @@ module U3d
|
|
155
162
|
if U3dCore::Helper.operating_system == :win
|
156
163
|
yield
|
157
164
|
else
|
158
|
-
stat_command =
|
165
|
+
stat_command = case U3dCore::Helper.operating_system
|
166
|
+
when :linux
|
159
167
|
"stat -c \"%U,%a\" #{dir}"
|
160
|
-
|
168
|
+
when :mac
|
161
169
|
"stat -f \"%Su,%A\" #{dir}"
|
162
170
|
end
|
163
171
|
owner, access = U3dCore::CommandExecutor.execute(command: stat_command, admin: false).strip.split(',')
|
@@ -199,29 +207,87 @@ module U3d
|
|
199
207
|
ver = UNITY_VERSION_REGEX.match(version)
|
200
208
|
if ver.nil?
|
201
209
|
raise ArgumentError, "Version (#{version}) does not match the Unity "\
|
202
|
-
|
210
|
+
'version format 0.0.0x0'
|
203
211
|
end
|
204
212
|
[ver[1], ver[2], ver[3], ver[4], ver[5]]
|
205
213
|
end
|
206
214
|
|
207
215
|
def windows_local_appdata
|
208
|
-
require
|
216
|
+
require "fiddle"
|
209
217
|
|
218
|
+
shell32 = Fiddle.dlopen('shell32')
|
219
|
+
getdir = Fiddle::Function.new(shell32['SHGetFolderPath'], [Fiddle::TYPE_LONG, Fiddle::TYPE_LONG, Fiddle::TYPE_LONG, Fiddle::TYPE_LONG, Fiddle::TYPE_VOIDP], Fiddle::TYPE_LONG)
|
210
220
|
windir = ' ' * 261
|
211
|
-
|
212
|
-
getdir = Win32API.new('shell32', 'SHGetFolderPath', 'LLLLP', 'L')
|
213
221
|
result = getdir.call(0, CSIDL_LOCAL_APPDATA, 0, 0, windir)
|
222
|
+
|
214
223
|
raise "Unable to get Local Appdata directory, returned with value #{result}" unless result.zero?
|
224
|
+
|
215
225
|
windir.rstrip!
|
216
226
|
windir = windir.encode("UTF-8", Encoding.find('filesystem'))
|
217
227
|
windir = File.expand_path(windir.rstrip)
|
218
228
|
|
219
229
|
return windir if Dir.exist? windir
|
230
|
+
|
220
231
|
raise "Local Appdata retrieved (#{windir}) is not correct"
|
221
232
|
end
|
222
233
|
|
234
|
+
def windows_fileversion(info_key, path)
|
235
|
+
require "fiddle"
|
236
|
+
version_dll = Fiddle.dlopen('version.dll')
|
237
|
+
kernel32 = Fiddle.dlopen('kernel32.dll')
|
238
|
+
|
239
|
+
get_file_version_info_size = Fiddle::Function.new(version_dll['GetFileVersionInfoSize'], [Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP], Fiddle::TYPE_LONG)
|
240
|
+
get_file_version_info = Fiddle::Function.new(version_dll['GetFileVersionInfo'], [Fiddle::TYPE_VOIDP, Fiddle::TYPE_INT, Fiddle::TYPE_INT, Fiddle::TYPE_VOIDP], Fiddle::TYPE_INT) # FIXME: TYPE_INT => TYPE_LONG??
|
241
|
+
ver_query_value = Fiddle::Function.new(version_dll['VerQueryValue'], [Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP], Fiddle::TYPE_INT)
|
242
|
+
rtl_move_memory = Fiddle::Function.new(kernel32['RtlMoveMemory'], [Fiddle::TYPE_VOIDP, Fiddle::TYPE_LONG, Fiddle::TYPE_LONG], Fiddle::TYPE_INT)
|
243
|
+
|
244
|
+
file = "#{path.tr('/', '\\')}\u0000"
|
245
|
+
|
246
|
+
s = [0].pack('L')
|
247
|
+
version_size = get_file_version_info_size.call(file, s)
|
248
|
+
raise StandardError if version_size.zero?
|
249
|
+
|
250
|
+
version_info = ' ' * version_size
|
251
|
+
version_ok = get_file_version_info.call(file, 0, version_size, version_info)
|
252
|
+
raise StandardError if version_ok.zero? # TODO: use GetLastError
|
253
|
+
|
254
|
+
# hack, giving up using VerQueryValue for now.
|
255
|
+
rstring = version_info.unpack('v*').map { |c| c.chr if c < 256 } * ''
|
256
|
+
r = /#{info_key}..(.*?)\000/.match(rstring)
|
257
|
+
# puts "#{info_key} = #{r ? r[1] : '??'}"
|
258
|
+
return r ? r[1] : nil
|
259
|
+
|
260
|
+
# rubocop:disable Lint/UnreachableCode
|
261
|
+
# hardcoding lang codepage
|
262
|
+
struct_path = "\\StringFileInfo\\040904b0\\#{info_key}"
|
263
|
+
|
264
|
+
addr = [0].pack('L')
|
265
|
+
size = [0].pack('L')
|
266
|
+
query_ok = ver_query_value.call(version_info, "#{struct_path}\u0000", addr, size)
|
267
|
+
raise StandardError if query_ok.zero?
|
268
|
+
|
269
|
+
raddr = addr.unpack1('L')
|
270
|
+
rsize = size.unpack1('L')
|
271
|
+
|
272
|
+
# this is not working right now, getting seg faults and other low level issues
|
273
|
+
puts "Size: #{raddr} #{rsize}"
|
274
|
+
fixed_info = Array.new(rsize, 0).pack('L*')
|
275
|
+
query_ok = rtl_move_memory.call(fixed_info, raddr, fixed_info.length)
|
276
|
+
raise StandardError if query_ok.zero?
|
277
|
+
|
278
|
+
info = fixed_info.unpack('L*')
|
279
|
+
file_version = [info[4], info[3], info[6], info[5]]
|
280
|
+
product_version = [info[8], info[7], info[10], info[9]]
|
281
|
+
[file_version, product_version]
|
282
|
+
# rubocop:enable Lint/UnreachableCode
|
283
|
+
rescue StandardError => e
|
284
|
+
UI.error("Failure to find '#{info_key}' under '#{path}': #{e}")
|
285
|
+
UI.error(e.backtrace)
|
286
|
+
nil
|
287
|
+
end
|
288
|
+
|
223
289
|
def pretty_filesize(filesize)
|
224
|
-
Filesize.from(filesize.round
|
290
|
+
Filesize.from("#{filesize.round} B").pretty
|
225
291
|
end
|
226
292
|
|
227
293
|
def windows_path(path)
|
@@ -249,14 +315,19 @@ module U3d
|
|
249
315
|
end
|
250
316
|
end
|
251
317
|
|
318
|
+
def file_exists_not_empty?(path)
|
319
|
+
File.file?(path) && File.size(path).positive?
|
320
|
+
end
|
321
|
+
|
252
322
|
private
|
253
323
|
|
254
324
|
def http_max_retries
|
255
|
-
ENV
|
325
|
+
ENV.fetch('U3D_HTTP_MAX_RETRIES', nil)&.to_i
|
256
326
|
end
|
257
327
|
|
258
328
|
def http_read_timeout
|
259
329
|
return ENV['U3D_HTTP_READ_TIMEOUT'].to_i if ENV['U3D_HTTP_READ_TIMEOUT']
|
330
|
+
|
260
331
|
300
|
261
332
|
end
|
262
333
|
|
@@ -270,5 +341,5 @@ module U3d
|
|
270
341
|
end
|
271
342
|
end
|
272
343
|
end
|
273
|
-
# rubocop:enable ModuleLength
|
344
|
+
# rubocop:enable Metrics/ModuleLength
|
274
345
|
end
|
data/lib/u3d/version.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
## --- BEGIN LICENSE BLOCK ---
|
2
4
|
# Copyright (c) 2016-present WeWantToKnow AS
|
3
5
|
#
|
@@ -21,11 +23,11 @@
|
|
21
23
|
## --- END LICENSE BLOCK ---
|
22
24
|
|
23
25
|
module U3d
|
24
|
-
VERSION = '1.2
|
25
|
-
DESCRIPTION = 'Provides numerous tools for installing, managing and running the Unity game engine from command line.'
|
26
|
+
VERSION = '1.3.2'
|
27
|
+
DESCRIPTION = 'Provides numerous tools for installing, managing and running the Unity game engine from command line.'
|
26
28
|
UNITY_VERSIONS_NOTE = "Unity uses the following version formatting: 0.0.0x0. The \'x\' can takes different values:\n"\
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
29
|
+
"\t. 'f' are the main release candidates for Unity\n"\
|
30
|
+
"\t. 'p' are patches fixing those releases\n"\
|
31
|
+
"\t. 'b' are the beta releases\n"\
|
32
|
+
"\t. 'a' are the alpha releases (not currently discovered)\n"
|
31
33
|
end
|
data/lib/u3d.rb
CHANGED
data/lib/u3d_core/admin_tools.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
## --- BEGIN LICENSE BLOCK ---
|
2
4
|
# Original work Copyright (c) 2015-present the fastlane authors
|
3
5
|
# Modified work Copyright 2016-present WeWantToKnow AS
|
@@ -65,7 +67,7 @@ module U3dCore
|
|
65
67
|
output_callback = proc do |line|
|
66
68
|
# Prefix the current line with a string
|
67
69
|
prefix.each do |element|
|
68
|
-
line = element[:prefix] + line if element[:block]
|
70
|
+
line = element[:prefix] + line if element[:block]&.call(line)
|
69
71
|
end
|
70
72
|
UI.command_output(line)
|
71
73
|
end
|
@@ -97,27 +99,28 @@ module U3dCore
|
|
97
99
|
line = l.strip # strip so that \n gets removed
|
98
100
|
output << line
|
99
101
|
|
100
|
-
output_callback
|
102
|
+
output_callback&.call(l)
|
101
103
|
end
|
102
104
|
end
|
103
105
|
raise "Exit status: #{status}".red if !status.nil? && status.nonzero?
|
104
|
-
rescue StandardError =>
|
106
|
+
rescue StandardError => e
|
105
107
|
# This could happen
|
106
108
|
# * if the status is failed
|
107
109
|
# * when the environment is wrong:
|
108
110
|
# > invalid byte sequence in US-ASCII (ArgumentError)
|
109
|
-
output <<
|
111
|
+
output << e.to_s
|
110
112
|
o = output.join("\n")
|
111
113
|
UI.verbose o
|
112
|
-
raise
|
114
|
+
raise e unless error_callback
|
115
|
+
|
113
116
|
error_callback.call(o, nil)
|
114
117
|
end
|
115
118
|
return output.join("\n")
|
116
119
|
end
|
117
120
|
|
118
|
-
# rubocop:disable PredicateName
|
121
|
+
# rubocop:disable Naming/PredicateName
|
119
122
|
def has_admin_privileges?(retry_count: 2)
|
120
|
-
# rubocop:enable PredicateName
|
123
|
+
# rubocop:enable Naming/PredicateName
|
121
124
|
if Helper.windows?
|
122
125
|
begin
|
123
126
|
result = system_no_output('reg query HKU\\S-1-5-19')
|
@@ -152,6 +155,7 @@ module U3dCore
|
|
152
155
|
unless env_username == "root"
|
153
156
|
cred = U3dCore::Credentials.new(user: env_username)
|
154
157
|
raise CredentialsError, "The command \'#{command}\' must be run with admin privileges" unless has_admin_privileges?
|
158
|
+
|
155
159
|
command = "sudo -k && echo #{cred.password.shellescape} | sudo -S bash -c \"#{command}\""
|
156
160
|
end
|
157
161
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
## --- BEGIN LICENSE BLOCK ---
|
2
4
|
# Original work Copyright (c) 2015-present the fastlane authors
|
3
5
|
# Modified work Copyright 2016-present WeWantToKnow AS
|
@@ -36,6 +38,7 @@ module U3dCore
|
|
36
38
|
def select_runner_impl
|
37
39
|
# disable PTY by setting env variable
|
38
40
|
return U3dCore::SafePopen.method(:spawn) unless ENV['U3D_NO_TTY'].nil?
|
41
|
+
|
39
42
|
begin
|
40
43
|
require 'pty'
|
41
44
|
return U3dCore::SafePty.method(:spawn)
|
@@ -55,25 +58,20 @@ module U3dCore
|
|
55
58
|
def self.spawn(command, &_block)
|
56
59
|
require 'pty'
|
57
60
|
PTY.spawn(command) do |r, w, p|
|
61
|
+
trap('INT') do
|
62
|
+
Process.kill("INT", p)
|
63
|
+
end
|
64
|
+
yield r, w, p
|
65
|
+
# if the process has closed, ruby might raise an exception if we try
|
66
|
+
# to do I/O on a closed stream. This behavior is platform specific
|
67
|
+
rescue Errno::EIO
|
68
|
+
ensure
|
58
69
|
begin
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
# to do I/O on a closed stream. This behavior is platform specific
|
65
|
-
# rubocop:disable HandleExceptions
|
66
|
-
rescue Errno::EIO
|
67
|
-
# rubocop:enable HandleExceptions
|
68
|
-
ensure
|
69
|
-
begin
|
70
|
-
Process.wait p
|
71
|
-
# The process might have exited.
|
72
|
-
# This behavior is also ruby version dependent.
|
73
|
-
# rubocop:disable HandleExceptions
|
74
|
-
rescue Errno::ECHILD, PTY::ChildExited
|
75
|
-
end
|
76
|
-
# rubocop:enable HandleExceptions
|
70
|
+
Process.wait p
|
71
|
+
# The process might have exited.
|
72
|
+
# This behavior is also ruby version dependent.
|
73
|
+
rescue Errno::ECHILD, PTY::ChildExited
|
74
|
+
# do nothing
|
77
75
|
end
|
78
76
|
end
|
79
77
|
$CHILD_STATUS.exitstatus
|
@@ -88,7 +86,7 @@ module U3dCore
|
|
88
86
|
def self.spawn(command, &_block)
|
89
87
|
require 'open3'
|
90
88
|
Open3.popen2e(command) do |r, w, p|
|
91
|
-
yield w, r, p.value.pid #
|
89
|
+
yield w, r, p.value.pid # NOTE: the inversion
|
92
90
|
|
93
91
|
r.close
|
94
92
|
w.close
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
## --- BEGIN LICENSE BLOCK ---
|
2
4
|
# Copyright (c) 2017-present WeWantToKnow AS
|
3
5
|
#
|
@@ -26,6 +28,7 @@ module CoreExtensions
|
|
26
28
|
return 'Windows' if self == :win
|
27
29
|
return 'Mac OSX' if self == :mac
|
28
30
|
return 'Linux' if self == :linux
|
31
|
+
|
29
32
|
raise "Not a known operating system symbol #{self}"
|
30
33
|
end
|
31
34
|
end
|
data/lib/u3d_core/credentials.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
## --- BEGIN LICENSE BLOCK ---
|
2
4
|
# Original work Copyright (c) 2015-present the fastlane authors
|
3
5
|
# Modified work Copyright 2016-present WeWantToKnow AS
|
@@ -26,7 +28,7 @@ require 'security'
|
|
26
28
|
|
27
29
|
module U3dCore
|
28
30
|
class Credentials
|
29
|
-
MAC_U3D_SERVER = 'u3d'
|
31
|
+
MAC_U3D_SERVER = 'u3d'
|
30
32
|
def initialize(user: nil, password: nil)
|
31
33
|
@user = user
|
32
34
|
@password = password
|
@@ -39,6 +41,7 @@ module U3dCore
|
|
39
41
|
while @user.to_s.empty?
|
40
42
|
UI.verbose 'Username does not exist or is empty'
|
41
43
|
raise CredentialsError, 'Username missing and context is not interactive. Please check that the environment variable is correct' unless UI.interactive?
|
44
|
+
|
42
45
|
@user = UI.input 'Username for u3d:'
|
43
46
|
end
|
44
47
|
|
@@ -48,12 +51,10 @@ module U3dCore
|
|
48
51
|
def password
|
49
52
|
@password ||= ENV['U3D_PASSWORD']
|
50
53
|
|
51
|
-
if Helper.mac? && @use_keychain
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
@password = password_holder.password unless password_holder.nil?
|
56
|
-
end
|
54
|
+
if Helper.mac? && @use_keychain && !@password
|
55
|
+
UI.message 'Fetching password from keychain'
|
56
|
+
password_holder = Security::InternetPassword.find(server: server_name)
|
57
|
+
@password = password_holder.password unless password_holder.nil?
|
57
58
|
end
|
58
59
|
|
59
60
|
if @password.nil?
|
@@ -76,6 +77,7 @@ module U3dCore
|
|
76
77
|
while @password.nil?
|
77
78
|
UI.verbose 'Password does not exist'
|
78
79
|
raise CredentialsError, 'Password missing and context is not interactive. Please make sure it is correct' unless UI.interactive?
|
80
|
+
|
79
81
|
@password = UI.password "Password for #{user}:"
|
80
82
|
end
|
81
83
|
|
data/lib/u3d_core/env.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
## --- BEGIN LICENSE BLOCK ---
|
2
4
|
# Original work Copyright (c) 2015-present the fastlane authors
|
3
5
|
# Modified work Copyright 2019-present WeWantToKnow AS
|
@@ -26,6 +28,7 @@ module U3dCore
|
|
26
28
|
def self.truthy?(env)
|
27
29
|
return false unless ENV[env]
|
28
30
|
return false if %w[no false off 0].include?(ENV[env].to_s)
|
31
|
+
|
29
32
|
return true
|
30
33
|
end
|
31
34
|
end
|
data/lib/u3d_core/globals.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
## --- BEGIN LICENSE BLOCK ---
|
2
4
|
# Original work Copyright (c) 2015-present the fastlane authors
|
3
5
|
# Modified work Copyright 2016-present WeWantToKnow AS
|
@@ -52,13 +54,14 @@ module U3dCore
|
|
52
54
|
end
|
53
55
|
|
54
56
|
def method_missing(method_sym, *arguments, &block)
|
55
|
-
|
57
|
+
case method_sym.to_s
|
58
|
+
when /^with_(.*)$/
|
56
59
|
if attributes.include? Regexp.last_match(1)
|
57
60
|
with(Regexp.last_match(1).to_sym, arguments.first, &block)
|
58
61
|
else
|
59
62
|
super
|
60
63
|
end
|
61
|
-
|
64
|
+
when /^(.*)\?$/
|
62
65
|
if attributes.include? Regexp.last_match(1)
|
63
66
|
is?(Regexp.last_match(1).to_sym)
|
64
67
|
else
|
@@ -70,15 +73,12 @@ module U3dCore
|
|
70
73
|
end
|
71
74
|
|
72
75
|
def respond_to_missing?(method_sym, include_private = false)
|
73
|
-
|
74
|
-
|
75
|
-
return attributes.include? Regexp.last_match(1)
|
76
|
-
elsif method_sym.to_s =~ /^(.*)\?$/
|
76
|
+
case method_sym.to_s
|
77
|
+
when /^with_(.*)$/ || /^(.*)\?$/
|
77
78
|
return attributes.include? Regexp.last_match(1)
|
78
79
|
else
|
79
80
|
super
|
80
81
|
end
|
81
|
-
# rubocop:enable GuardClause
|
82
82
|
end
|
83
83
|
end
|
84
84
|
private_class_method :is?, :with, :attributes
|
data/lib/u3d_core/helper.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
## --- BEGIN LICENSE BLOCK ---
|
2
4
|
# Original work Copyright (c) 2015-present the fastlane authors
|
3
5
|
# Modified work Copyright 2016-present WeWantToKnow AS
|
@@ -42,7 +44,7 @@ module U3dCore
|
|
42
44
|
end
|
43
45
|
|
44
46
|
def self.windows_path(path)
|
45
|
-
path.gsub(%r{
|
47
|
+
path.gsub(%r{/(\d)}, '/\\\\\1').tr('/', '\\')
|
46
48
|
end
|
47
49
|
|
48
50
|
# Runs a given command using backticks (`)
|
@@ -95,6 +97,7 @@ module U3dCore
|
|
95
97
|
# taken from: https://github.com/Microsoft/BashOnWindows/issues/423#issuecomment-221627364
|
96
98
|
proc_version = '/proc/version'
|
97
99
|
return false unless File.exist? proc_version
|
100
|
+
|
98
101
|
File.open(proc_version, 'r') do |f|
|
99
102
|
return !(/Microsof|WSL/ =~ f.read).nil?
|
100
103
|
end
|
@@ -112,7 +115,7 @@ module U3dCore
|
|
112
115
|
|
113
116
|
# the current operating system
|
114
117
|
def self.operating_system
|
115
|
-
# rubocop:disable GuardClause
|
118
|
+
# rubocop:disable Style/GuardClause
|
116
119
|
if linux?
|
117
120
|
return :linux
|
118
121
|
elsif mac?
|
@@ -122,7 +125,7 @@ module U3dCore
|
|
122
125
|
else
|
123
126
|
raise 'Could not assume what OS you\'re running, please specify it as much as possible'
|
124
127
|
end
|
125
|
-
# rubocop:enable GuardClause
|
128
|
+
# rubocop:enable Style/GuardClause
|
126
129
|
end
|
127
130
|
|
128
131
|
def self.win_64?
|
@@ -153,5 +156,4 @@ module U3dCore
|
|
153
156
|
# return ENV["FL_BUILDLOG_PATH"] || "~/Library/Logs"
|
154
157
|
# end
|
155
158
|
end
|
156
|
-
# rubocop:enable Metrics/ModuleLength
|
157
159
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
## --- BEGIN LICENSE BLOCK ---
|
2
4
|
# Original work Copyright (c) 2015-present the fastlane authors
|
3
5
|
# Modified work Copyright 2016-present WeWantToKnow AS
|
@@ -27,6 +29,7 @@ module U3dCore
|
|
27
29
|
class Shell < Interface
|
28
30
|
# test_log_buffer: by default, don't show any logs when running tests
|
29
31
|
def initialize(test_log_buffer: nil)
|
32
|
+
super()
|
30
33
|
@test_log_buffer = test_log_buffer
|
31
34
|
end
|
32
35
|
|
@@ -52,16 +55,15 @@ module U3dCore
|
|
52
55
|
|
53
56
|
class EPipeIgnorerLogDevice < Logger::LogDevice
|
54
57
|
def initialize(logdev)
|
58
|
+
super
|
55
59
|
@logdev = logdev
|
56
60
|
end
|
57
61
|
|
58
|
-
# rubocop:disable HandleExceptions
|
59
62
|
def write(message)
|
60
63
|
@logdev.write(message)
|
61
64
|
rescue Errno::EPIPE
|
62
65
|
# ignored
|
63
66
|
end
|
64
|
-
# rubocop:enable HandleExceptions
|
65
67
|
end
|
66
68
|
|
67
69
|
def format_string(datetime = Time.now, severity = "")
|
@@ -79,7 +81,7 @@ module U3dCore
|
|
79
81
|
s = []
|
80
82
|
s << "#{severity} " if U3dCore::Globals.verbose? && severity && !severity.empty?
|
81
83
|
s << "[#{datetime.strftime(timestamp)}] " if timestamp
|
82
|
-
s.join
|
84
|
+
s.join
|
83
85
|
end
|
84
86
|
|
85
87
|
#####################################################
|
@@ -114,7 +116,7 @@ module U3dCore
|
|
114
116
|
actual = (message.split("\r").last || "") # as clearing the line will remove the `>` and the time stamp
|
115
117
|
actual.split("\n").each do |msg|
|
116
118
|
prefix = msg.include?("▸") ? "" : "▸ "
|
117
|
-
log.info(prefix
|
119
|
+
log.info("#{prefix}#{msg.magenta}")
|
118
120
|
end
|
119
121
|
end
|
120
122
|
|
@@ -125,7 +127,7 @@ module U3dCore
|
|
125
127
|
def header(message)
|
126
128
|
i = message.length + 8
|
127
129
|
success("-" * i)
|
128
|
-
success("---
|
130
|
+
success("--- #{message} ---")
|
129
131
|
success("-" * i)
|
130
132
|
end
|
131
133
|
|
@@ -167,6 +169,7 @@ module U3dCore
|
|
167
169
|
|
168
170
|
def verify_interactive!(message)
|
169
171
|
return if interactive?
|
172
|
+
|
170
173
|
important(message)
|
171
174
|
crash!("Could not retrieve response as u3d runs in non-interactive mode")
|
172
175
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
## --- BEGIN LICENSE BLOCK ---
|
2
4
|
# Original work Copyright (c) 2015-present the fastlane authors
|
3
5
|
# Modified work Copyright 2016-present WeWantToKnow AS
|
@@ -143,6 +145,7 @@ module U3dCore
|
|
143
145
|
attr_reader :show_github_issues
|
144
146
|
|
145
147
|
def initialize(show_github_issues: false)
|
148
|
+
super
|
146
149
|
@show_github_issues = show_github_issues
|
147
150
|
end
|
148
151
|
end
|
data/lib/u3d_core/ui/ui.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
## --- BEGIN LICENSE BLOCK ---
|
2
4
|
# Original work Copyright (c) 2015-present the fastlane authors
|
3
5
|
# Modified work Copyright 2016-present WeWantToKnow AS
|
@@ -30,22 +32,21 @@ module U3dCore
|
|
30
32
|
|
31
33
|
attr_writer :current
|
32
34
|
end
|
33
|
-
|
34
|
-
# rubocop:disable Style/MethodMissing
|
35
|
+
# rubocop:disable Style/MissingRespondToMissing
|
35
36
|
def self.method_missing(method_sym, *args, &_block)
|
37
|
+
# rubocop:enable Style/MissingRespondToMissing
|
36
38
|
# not using `responds` because we don't care about methods like .to_s and so on
|
37
39
|
interface_methods = Interface.instance_methods - Object.instance_methods
|
38
40
|
UI.user_error!("Unknown method '#{method_sym}', supported #{interface_methods}") unless interface_methods.include?(method_sym)
|
39
41
|
|
40
42
|
current.send(method_sym, *args)
|
41
43
|
end
|
42
|
-
# rubocop:enable Style/MethodMissing
|
43
44
|
end
|
44
45
|
end
|
45
46
|
|
46
47
|
require 'u3d_core/ui/interface'
|
47
48
|
|
48
49
|
# Import all available implementations
|
49
|
-
Dir[File.expand_path('implementations/*.rb', File.dirname(__FILE__))].each do |file|
|
50
|
+
Dir[File.expand_path('implementations/*.rb', File.dirname(__FILE__))].sort.each do |file|
|
50
51
|
require file
|
51
52
|
end
|