u3d 1.2.1 → 1.3.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/.circleci/config.yml +43 -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 +90 -11
- data/DEVELOPMENT_PROCESS.md +1 -0
- data/Gemfile.lock +148 -88
- data/Rakefile +55 -6
- data/appveyor.yml +25 -6
- data/examples/Example1/Gemfile +4 -2
- data/examples/Example1/Gemfile.lock +12 -7
- 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 +22 -17
- data/lib/u3d/commands_generator.rb +9 -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 -32
- data/lib/u3d/installation.rb +77 -66
- data/lib/u3d/installer.rb +50 -34
- 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 +82 -15
- data/lib/u3d/version.rb +8 -6
- data/lib/u3d.rb +13 -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 +35 -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 +67 -0
- data/lib/u3d_core/update_checker/update_checker.rb +129 -0
- data/lib/u3d_core/version.rb +2 -0
- data/lib/u3d_core.rb +5 -0
- data/u3d.gemspec +20 -10
- metadata +106 -31
data/lib/u3d/asset.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
|
#
|
@@ -36,8 +38,9 @@ module U3d
|
|
36
38
|
|
37
39
|
def initialize(path, unity_project = nil)
|
38
40
|
raise ArgumentError, "No file at #{path}" unless File.exist?(path)
|
41
|
+
|
39
42
|
@path = path
|
40
|
-
@meta_path = path
|
43
|
+
@meta_path = "#{path}.meta"
|
41
44
|
@meta = YAML.safe_load(File.read(@meta_path))
|
42
45
|
@guid = @meta['guid']
|
43
46
|
@unity_project = unity_project
|
@@ -63,6 +66,7 @@ module U3d
|
|
63
66
|
|
64
67
|
def eql?(other)
|
65
68
|
return false unless other.is_a? Asset
|
69
|
+
|
66
70
|
other.guid == @guid
|
67
71
|
end
|
68
72
|
|
@@ -81,7 +85,7 @@ module U3d
|
|
81
85
|
private
|
82
86
|
|
83
87
|
def grep_reference_root
|
84
|
-
@unity_project
|
88
|
+
@unity_project&.exist? ? 'Assets/' : '.'
|
85
89
|
end
|
86
90
|
end
|
87
91
|
end
|
data/lib/u3d/cache.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
|
#
|
@@ -32,12 +34,12 @@ module U3d
|
|
32
34
|
using ::CoreExtensions::OperatingSystem
|
33
35
|
|
34
36
|
# Name of the cache file
|
35
|
-
DEFAULT_NAME = 'cache.json'
|
37
|
+
DEFAULT_NAME = 'cache.json'
|
36
38
|
# Maximum duration after which the cache is considered outdated
|
37
39
|
# Currently set to 24h
|
38
40
|
CACHE_LIFE = 60 * 60 * 24
|
39
41
|
|
40
|
-
GLOBAL_CACHE_URL = 'https://dragonbox.github.io/unities/v1/versions.json'
|
42
|
+
GLOBAL_CACHE_URL = 'https://dragonbox.github.io/unities/v1/versions.json'
|
41
43
|
|
42
44
|
private
|
43
45
|
|
@@ -49,11 +51,13 @@ module U3d
|
|
49
51
|
|
50
52
|
def [](key)
|
51
53
|
return nil if @cache[key].nil?
|
54
|
+
|
52
55
|
@cache[key]
|
53
56
|
end
|
54
57
|
|
55
58
|
def initialize(path: nil, force_os: nil, force_refresh: false, offline: false, central_cache: false)
|
56
59
|
raise "Cache: cannot specify both offline and force_refresh" if offline && force_refresh
|
60
|
+
|
57
61
|
@path = path || Cache.default_os_path
|
58
62
|
@cache = {}
|
59
63
|
os = force_os || U3dCore::Helper.operating_system
|
@@ -78,23 +82,23 @@ module U3d
|
|
78
82
|
def check_for_update(file_path, os)
|
79
83
|
need_update = false
|
80
84
|
data = {}
|
81
|
-
if
|
82
|
-
need_update = true
|
83
|
-
else
|
85
|
+
if File.file?(file_path)
|
84
86
|
begin
|
85
87
|
File.open(file_path, 'r') do |f|
|
86
88
|
data = JSON.parse(f.read)
|
87
89
|
end
|
88
|
-
rescue JSON::ParserError =>
|
89
|
-
UI.error
|
90
|
+
rescue JSON::ParserError => e
|
91
|
+
UI.error "Failed to parse cache.json: #{e}"
|
90
92
|
need_update = true
|
91
|
-
rescue SystemCallError =>
|
92
|
-
UI.error
|
93
|
+
rescue SystemCallError => e
|
94
|
+
UI.error "Failed to open cache.json: #{e}"
|
93
95
|
need_update = true
|
94
96
|
else
|
95
97
|
need_update = os_data_need_update?(data, os)
|
96
98
|
data[os.id2name] = nil if need_update
|
97
99
|
end
|
100
|
+
else
|
101
|
+
need_update = true
|
98
102
|
end
|
99
103
|
return need_update, data
|
100
104
|
end
|
@@ -111,7 +115,7 @@ module U3d
|
|
111
115
|
update_cache(os) unless central_cache && fetch_central_cache(os)
|
112
116
|
|
113
117
|
File.delete(file_path) if File.file?(file_path)
|
114
|
-
File.
|
118
|
+
File.write(file_path, @cache.to_json)
|
115
119
|
end
|
116
120
|
|
117
121
|
# Fetches central versions.json. Ignore it if it is too old
|
data/lib/u3d/commands.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
|
#
|
@@ -37,7 +39,7 @@ require 'fileutils'
|
|
37
39
|
|
38
40
|
module U3d
|
39
41
|
# API for U3d, redirecting calls to class they concern
|
40
|
-
# rubocop:disable ClassLength
|
42
|
+
# rubocop:disable Metrics/ClassLength
|
41
43
|
class Commands
|
42
44
|
using ::CoreExtensions::Extractable
|
43
45
|
|
@@ -51,18 +53,18 @@ module U3d
|
|
51
53
|
return
|
52
54
|
end
|
53
55
|
list.each do |u|
|
54
|
-
version_format = "Version %-15
|
56
|
+
version_format = "Version %-15<version>s [%<build_number>s] %<do_not_move>s(%<root_path>s)"
|
55
57
|
do_not_move = u.do_not_move? ? '!'.red.bold : ' '
|
56
58
|
h = { version: u.version, build_number: u.build_number, root_path: u.root_path, do_not_move: do_not_move }
|
57
59
|
UI.message version_format % h
|
58
60
|
packages = u.packages
|
59
61
|
next unless options[:packages] && packages && !packages.empty?
|
62
|
+
|
60
63
|
UI.message 'Packages:'
|
61
64
|
packages.each { |pack| UI.message " - #{pack}" }
|
62
65
|
end
|
63
66
|
end
|
64
67
|
|
65
|
-
# rubocop:disable Style/FormatStringToken
|
66
68
|
def console
|
67
69
|
require 'irb'
|
68
70
|
ARGV.clear
|
@@ -81,7 +83,6 @@ module U3d
|
|
81
83
|
|
82
84
|
catch(:IRB_EXIT) { @irb.eval_input }
|
83
85
|
end
|
84
|
-
# rubocop:enable Style/FormatStringToken
|
85
86
|
|
86
87
|
def move(args: {}, options: {})
|
87
88
|
long_name = options[:long]
|
@@ -131,6 +132,7 @@ module U3d
|
|
131
132
|
v = cache_versions[k]
|
132
133
|
UI.message "Version #{k}: " + v.to_s.cyan.underline
|
133
134
|
next unless show_packages
|
135
|
+
|
134
136
|
version_packages = packages[k]
|
135
137
|
UI.message 'Packages:'
|
136
138
|
version_packages.each { |package| UI.message " - #{package.id.capitalize}" }
|
@@ -152,7 +154,8 @@ module U3d
|
|
152
154
|
|
153
155
|
definition = UnityVersionDefinition.new(version, os, cache_versions)
|
154
156
|
unity = check_unity_presence(version: version)
|
155
|
-
|
157
|
+
|
158
|
+
packages = verify_package_names(options[:packages], definition) || ['Unity']
|
156
159
|
|
157
160
|
begin
|
158
161
|
packages = enforce_setup_coherence(packages, options, unity, definition)
|
@@ -160,13 +163,12 @@ module U3d
|
|
160
163
|
return
|
161
164
|
end
|
162
165
|
|
163
|
-
verify_package_names(definition, packages)
|
164
|
-
|
165
166
|
get_administrative_privileges(options) if options[:install]
|
166
167
|
|
167
168
|
files = Downloader.fetch_modules(definition, packages: packages, download: options[:download])
|
168
169
|
|
169
170
|
return unless options[:install]
|
171
|
+
|
170
172
|
Installer.install_modules(files, definition.version, installation_path: options[:installation_path])
|
171
173
|
end
|
172
174
|
|
@@ -223,12 +225,14 @@ module U3d
|
|
223
225
|
action = args[0]
|
224
226
|
raise "Please specify an action to perform, one of #{credentials_actions.join(',')}" unless action
|
225
227
|
raise "Unknown action '#{action}'. Use one of #{credentials_actions.join(',')}" unless credentials_actions.include? action
|
226
|
-
|
228
|
+
|
229
|
+
case action
|
230
|
+
when 'add'
|
227
231
|
U3dCore::Globals.use_keychain = true
|
228
232
|
# credentials = U3dCore::Credentials.new(user: ENV['USER'])
|
229
233
|
# credentials.login # ask password
|
230
234
|
UI.error 'Invalid credentials' unless U3dCore::CommandExecutor.has_admin_privileges?
|
231
|
-
|
235
|
+
when 'remove'
|
232
236
|
U3dCore::Globals.use_keychain = true
|
233
237
|
U3dCore::Credentials.new(user: ENV['USER']).forget_credentials(force: true)
|
234
238
|
else
|
@@ -270,14 +274,15 @@ module U3d
|
|
270
274
|
def cache_versions(os, offline: false, force_refresh: false, central_cache: true)
|
271
275
|
cache = Cache.new(force_os: os, offline: offline, force_refresh: force_refresh, central_cache: central_cache)
|
272
276
|
cache_os = cache[os.id2name] || {}
|
273
|
-
|
274
|
-
cache_versions
|
277
|
+
cache_os['versions'] || {}
|
275
278
|
end
|
276
279
|
|
277
|
-
def verify_package_names(
|
278
|
-
packages.
|
279
|
-
|
280
|
+
def verify_package_names(packages, definition)
|
281
|
+
unless packages.nil?
|
282
|
+
invalid_packages = packages.reject { |package| definition.available_package? package }
|
283
|
+
raise ArgumentError, "Package(s) '#{invalid_packages.join(',')}' are not known. Use #{definition.available_packages.join(',')}" unless invalid_packages.empty?
|
280
284
|
end
|
285
|
+
packages
|
281
286
|
end
|
282
287
|
|
283
288
|
def specified_or_current_project_version(version)
|
@@ -341,9 +346,8 @@ module U3d
|
|
341
346
|
UI.verbose "Version #{version} of Unity is not installed yet"
|
342
347
|
else
|
343
348
|
UI.verbose "Unity #{version} is installed at #{unity.root_path}"
|
344
|
-
return unity
|
345
349
|
end
|
346
|
-
|
350
|
+
unity
|
347
351
|
end
|
348
352
|
|
349
353
|
# rubocop:disable Metrics/BlockNesting
|
@@ -418,6 +422,7 @@ module U3d
|
|
418
422
|
package = definition[package_name]
|
419
423
|
return true unless package.depends_on
|
420
424
|
return true if unity.package_installed?(package.depends_on)
|
425
|
+
|
421
426
|
installing.map { |other| definition[other] }.any? do |other|
|
422
427
|
other.id == package.depends_on || other.name == package.depends_on
|
423
428
|
end
|
@@ -430,7 +435,7 @@ module U3d
|
|
430
435
|
end
|
431
436
|
end
|
432
437
|
end
|
433
|
-
# rubocop:enable ClassLength
|
438
|
+
# rubocop:enable Metrics/ClassLength
|
434
439
|
end
|
435
440
|
|
436
441
|
class InstallationSetupError < StandardError
|
@@ -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
|
#
|
@@ -28,16 +30,19 @@ HighLine.track_eof = false
|
|
28
30
|
|
29
31
|
module U3d
|
30
32
|
# CLI using commander gem for u3d
|
31
|
-
# rubocop:disable ClassLength
|
33
|
+
# rubocop:disable Metrics/ClassLength
|
32
34
|
class CommandsGenerator
|
33
35
|
include Commander::Methods
|
34
36
|
UI = U3dCore::UI
|
35
37
|
|
36
|
-
UNICODE_FILE = File.expand_path('
|
38
|
+
UNICODE_FILE = File.expand_path('../assets/utf8.txt', __dir__)
|
37
39
|
|
38
40
|
def self.start
|
41
|
+
U3dCore::UpdateChecker.start_looking_for_update('u3d')
|
39
42
|
check_locale
|
40
43
|
new.run
|
44
|
+
ensure
|
45
|
+
U3dCore::UpdateChecker.show_update_status('u3d', U3d::VERSION)
|
41
46
|
end
|
42
47
|
|
43
48
|
def self.check_locale
|
@@ -94,7 +99,7 @@ Fore more information about how the rules work, see https://github.com/DragonBox
|
|
94
99
|
c.option '-u', '--unity_version STRING', String, 'Version of Unity to run with. If not specified, it runs with the version of the project (either specified as -projectPath or current)'
|
95
100
|
c.option '-r', '--raw_logs', 'Raw Unity output, not filtered by u3d\'s log prettifier'
|
96
101
|
c.action do |args, options|
|
97
|
-
UI.user_error! "Run doesn't take arguments. Did you forget '--' or did you mistake your command? (#{args})" if args.count
|
102
|
+
UI.user_error! "Run doesn't take arguments. Did you forget '--' or did you mistake your command? (#{args})" if args.count.positive?
|
98
103
|
U3dCore::Globals.log_timestamps = true
|
99
104
|
Commands.run(options: convert_options(options), run_args: run_args)
|
100
105
|
end
|
@@ -260,5 +265,5 @@ More on that: https://forum.unity3d.com/threads/unity-on-linux-release-notes-and
|
|
260
265
|
run!
|
261
266
|
end
|
262
267
|
end
|
263
|
-
# rubocop:enable ClassLength
|
268
|
+
# rubocop:enable Metrics/ClassLength
|
264
269
|
end
|
data/lib/u3d/compatibility.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
|
#
|
@@ -51,7 +53,8 @@ module U3d
|
|
51
53
|
|
52
54
|
class LinuxValidator < DownloadValidator
|
53
55
|
def validate(package, file, definition)
|
54
|
-
return size_validation(expected: definition[package].download_size, actual: File.size(file)) if definition[package]
|
56
|
+
return size_validation(expected: definition[package].download_size, actual: File.size(file)) if definition[package]&.download_size
|
57
|
+
|
55
58
|
UI.important "No file validation available, #{file} is assumed to be correct"
|
56
59
|
true
|
57
60
|
end
|
@@ -59,7 +62,7 @@ module U3d
|
|
59
62
|
|
60
63
|
class MacValidator < DownloadValidator
|
61
64
|
def validate(package, file, definition)
|
62
|
-
if definition[package].download_size % 1000 && definition[package].checksum.nil?
|
65
|
+
if (definition[package].download_size % 1000) && definition[package].checksum.nil?
|
63
66
|
UI.verbose "File '#{definition[package].name}' seems external. Validation skipped"
|
64
67
|
return true
|
65
68
|
end
|
@@ -71,7 +74,7 @@ module U3d
|
|
71
74
|
class WindowsValidator < DownloadValidator
|
72
75
|
def validate(package, file, definition)
|
73
76
|
# External packages have no md5 and a false size value
|
74
|
-
if definition[package].download_size % 1000 && definition[package].checksum.nil?
|
77
|
+
if (definition[package].download_size % 1000) && definition[package].checksum.nil?
|
75
78
|
UI.verbose "File '#{definition[package].name}' seems external. Validation skipped"
|
76
79
|
return true
|
77
80
|
end
|
data/lib/u3d/downloader.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,13 +29,13 @@ module U3d
|
|
27
29
|
# Take care of downloading files and packages
|
28
30
|
module Downloader
|
29
31
|
# Name of the directory for the package downloading
|
30
|
-
DOWNLOAD_DIRECTORY = 'Unity_Packages'
|
32
|
+
DOWNLOAD_DIRECTORY = 'Unity_Packages'
|
31
33
|
# Path to the directory for the package downloading
|
32
|
-
DOWNLOAD_PATH = "#{ENV['HOME']}/Downloads"
|
34
|
+
DOWNLOAD_PATH = "#{ENV['HOME']}/Downloads"
|
33
35
|
# Regex to get the name of a localization asset
|
34
|
-
UNITY_LANGUAGE_FILE_REGEX = %r{
|
36
|
+
UNITY_LANGUAGE_FILE_REGEX = %r{/\d+/[0-9.]+/([\w-]+)$}.freeze
|
35
37
|
# Regex to get the name of a package out of its file name
|
36
|
-
UNITY_MODULE_FILE_REGEX = %r{
|
38
|
+
UNITY_MODULE_FILE_REGEX = %r{/([\w\-_.+]+\.(?:pkg|dmg|exe|zip|sh|deb|msi|xz))[^/]*$}.freeze
|
37
39
|
|
38
40
|
class << self
|
39
41
|
def download_directory
|
@@ -112,15 +114,15 @@ module U3d
|
|
112
114
|
return
|
113
115
|
else
|
114
116
|
extension = File.extname(path)
|
115
|
-
new_path = File.join(File.dirname(path), File.basename(path, extension)
|
117
|
+
new_path = File.join(File.dirname(path), "#{File.basename(path, extension)}_CORRUPTED#{extension}")
|
116
118
|
UI.important "File present at #{path} is not correct, it has been renamed to #{new_path}"
|
117
119
|
File.rename(path, new_path)
|
118
120
|
end
|
119
121
|
end
|
120
122
|
|
121
123
|
UI.header "Downloading #{package_info.name} version #{definition.version}"
|
122
|
-
UI.message
|
123
|
-
UI.message
|
124
|
+
UI.message "Downloading from #{url.to_s.cyan.underline}"
|
125
|
+
UI.message "Download will be found at #{path}"
|
124
126
|
download_package(path, url, size: package_info.download_size)
|
125
127
|
|
126
128
|
if validator.validate(package, path, definition)
|
@@ -153,7 +155,7 @@ module U3d
|
|
153
155
|
Utils.ensure_dir(dir)
|
154
156
|
|
155
157
|
file_name = if (language_match = UNITY_LANGUAGE_FILE_REGEX.match(final_url))
|
156
|
-
language_match[1]
|
158
|
+
"#{language_match[1]}.po" # Unity uses PO (Portable object files) for localization
|
157
159
|
elsif (module_match = UNITY_MODULE_FILE_REGEX.match(final_url))
|
158
160
|
module_match[1]
|
159
161
|
else
|
@@ -182,8 +184,10 @@ module U3d
|
|
182
184
|
# for backward compatibility
|
183
185
|
class MacDownloader < StandardPackageDownloader
|
184
186
|
end
|
187
|
+
|
185
188
|
class LinuxDownloader < StandardPackageDownloader
|
186
189
|
end
|
190
|
+
|
187
191
|
class WindowsDownloader < StandardPackageDownloader
|
188
192
|
end
|
189
193
|
end
|
data/lib/u3d/failure_reporter.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'date'
|
2
4
|
require 'fileutils'
|
3
5
|
require 'json'
|
@@ -9,6 +11,7 @@ module U3d
|
|
9
11
|
class << self
|
10
12
|
def report(failure_type: "DEFAULT", failure_message: "", data: {})
|
11
13
|
return unless ENV['U3D_REPORT_FAILURES']
|
14
|
+
|
12
15
|
report = {
|
13
16
|
type: failure_type,
|
14
17
|
message: failure_message,
|
@@ -21,9 +24,7 @@ module U3d
|
|
21
24
|
"#{failure_type}.#{Date.now.strftime('%Y%m%dT%H%M')}.failure.json"
|
22
25
|
)
|
23
26
|
|
24
|
-
File.
|
25
|
-
file.write JSON.pretty_generate(report)
|
26
|
-
end
|
27
|
+
File.write(report_file, JSON.pretty_generate(report))
|
27
28
|
rescue StandardError => e
|
28
29
|
UI.important "Unable to report a #{failure_type} failure. Please use --verbose to get more information about the failure"
|
29
30
|
UI.verbose "Unable to report failure: #{e}"
|
@@ -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
|
#
|
@@ -28,19 +30,34 @@ require 'u3d_core/helper'
|
|
28
30
|
module U3d
|
29
31
|
module HubModulesParser
|
30
32
|
class << self
|
31
|
-
HUB_MODULES_NAME = '%<version>s-%<os>s-modules.json'
|
33
|
+
HUB_MODULES_NAME = '%<version>s-%<os>s-modules.json'
|
32
34
|
|
33
35
|
def load_modules(version, os: U3dCore::Helper.operating_system, offline: false)
|
34
36
|
path = modules_path(version, os)
|
35
37
|
|
36
|
-
|
37
|
-
|
38
|
-
|
38
|
+
# force download if no hub file present
|
39
|
+
download_modules(os: os) if !File.file?(path) && File.size(path).positive? && !offline
|
40
|
+
|
41
|
+
unless File.file?(path) && File.size(path).positive?
|
42
|
+
UI.verbose "No modules registered for UnityHub for version #{version}"
|
43
|
+
# cached_versions.keys.map{|s| UnityVersionNumber.new(s)}
|
44
|
+
# searching for closest version
|
45
|
+
files = Dir.glob("#{default_modules_path}/*-#{os}-modules.json")
|
46
|
+
|
47
|
+
vn = UnityVersionNumber.new(version)
|
48
|
+
|
49
|
+
versions_and_paths = files.map do |p|
|
50
|
+
v = File.basename(p).split('-')[0]
|
51
|
+
[UnityVersionNumber.new(v), p]
|
52
|
+
end
|
53
|
+
# filtered by version major.minor.patch (same major & minor and patch higher or equal)
|
54
|
+
versions_and_paths = versions_and_paths.select { |a| a[0].parts[0] == vn.parts[0] && a[0].parts[1] == vn.parts[1] && a[0].parts[2] >= vn.parts[2] }
|
39
55
|
|
40
|
-
|
41
|
-
UI.
|
56
|
+
if versions_and_paths.empty?
|
57
|
+
UI.info "No closest version from UnityHub found for version #{version}"
|
42
58
|
return []
|
43
59
|
end
|
60
|
+
path = versions_and_paths.first[1]
|
44
61
|
end
|
45
62
|
|
46
63
|
return JSON.parse(File.read(path))
|
@@ -81,7 +98,7 @@ module U3d
|
|
81
98
|
path = modules_path(build['version'], os)
|
82
99
|
Utils.ensure_dir(File.dirname(path))
|
83
100
|
|
84
|
-
File.
|
101
|
+
File.write(path, build['modules'].to_json)
|
85
102
|
end
|
86
103
|
end
|
87
104
|
end
|
@@ -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
|
#
|
@@ -25,36 +27,12 @@ require 'u3d/utils'
|
|
25
27
|
require 'u3d_core/helper'
|
26
28
|
|
27
29
|
module U3d
|
28
|
-
# Backwards compatibility
|
29
|
-
module INIParser
|
30
|
-
class << self
|
31
|
-
def method_missing(method_name, *arguments, &block)
|
32
|
-
UI.deprecated 'INIParser is obsolete, Use INIModulesParser instead'
|
33
|
-
if INIModulesParser.respond_to?(method_name)
|
34
|
-
INIModulesParser.send(method_name, *arguments, &block)
|
35
|
-
else
|
36
|
-
super
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def respond_to?(method_name, include_private = false)
|
41
|
-
UI.deprecated 'INIParser is obsolete, Use INIModulesParser instead'
|
42
|
-
INIModulesParser.respond_to?(method_name, include_private)
|
43
|
-
end
|
44
|
-
|
45
|
-
def respond_to_missing?(method_name, include_private = false)
|
46
|
-
UI.deprecated 'INIParser is obsolete, Use INIModulesParser instead'
|
47
|
-
INIModulesParser.respond_to_missing?(method_name, include_private)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
30
|
# Load and parse INI files
|
53
31
|
module INIModulesParser
|
54
32
|
#####################################################
|
55
33
|
# @!group INI parameters to load and save ini files
|
56
34
|
#####################################################
|
57
|
-
INI_NAME = 'unity-%<version>s-%<os>s.ini'
|
35
|
+
INI_NAME = 'unity-%<version>s-%<os>s.ini'
|
58
36
|
|
59
37
|
class << self
|
60
38
|
def load_ini(version, cached_versions, os: U3dCore::Helper.operating_system, offline: false)
|
@@ -66,8 +44,9 @@ module U3d
|
|
66
44
|
ini_name = format(INI_NAME, version: version, os: os)
|
67
45
|
Utils.ensure_dir(default_ini_path)
|
68
46
|
ini_path = File.expand_path(ini_name, default_ini_path)
|
69
|
-
unless File.file?(ini_path) && File.size(ini_path)
|
47
|
+
unless File.file?(ini_path) && File.size(ini_path).positive?
|
70
48
|
raise "INI file does not exist at #{ini_path}" if offline
|
49
|
+
|
71
50
|
download_ini(version, cached_versions, os, ini_name, ini_path)
|
72
51
|
end
|
73
52
|
begin
|
@@ -82,7 +61,8 @@ module U3d
|
|
82
61
|
ini_name = format(INI_NAME, version: version, os: 'linux')
|
83
62
|
Utils.ensure_dir(default_ini_path)
|
84
63
|
ini_path = File.expand_path(ini_name, default_ini_path)
|
85
|
-
return if File.file?(ini_path) && File.size(ini_path)
|
64
|
+
return if File.file?(ini_path) && File.size(ini_path).positive?
|
65
|
+
|
86
66
|
data = %([Unity]
|
87
67
|
; -- NOTE --
|
88
68
|
; This is not an official Unity file
|
@@ -114,16 +94,14 @@ url=#{url}
|
|
114
94
|
UI.verbose("Searching for ini file at #{uri}")
|
115
95
|
|
116
96
|
data = Net::HTTP.get(uri)
|
117
|
-
data.tr
|
118
|
-
data.gsub
|
97
|
+
data = data.tr("\"", '')
|
98
|
+
data = data.gsub(/Note:.+\n/, '')
|
119
99
|
|
120
100
|
write_ini_file(ini_path, data)
|
121
101
|
end
|
122
102
|
|
123
103
|
def write_ini_file(ini_path, data)
|
124
|
-
File.
|
125
|
-
f.write(data)
|
126
|
-
end
|
104
|
+
File.binwrite(ini_path, data)
|
127
105
|
end
|
128
106
|
|
129
107
|
def default_ini_path
|