u3d 1.0.13 → 1.0.14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 921e48e10c0e312b264724db1e4e8e995580150c
4
- data.tar.gz: 65c8c9f9452e8a0ee9d8828301a17bc6cdbe114d
3
+ metadata.gz: 7da505bec2ad3c4609ec0afefe46329350425d04
4
+ data.tar.gz: 8c144e1dc9d9d8308cfa772cc8cf5c38515ff4e2
5
5
  SHA512:
6
- metadata.gz: 420bae13d8ce41a64ee1b7cbef71e0083af60a6e31c0335ceae7f4fcbe42c74fd34cfe3bf535a49fc891dac7e12293db181e641b46003e79cc0c7db59eb5d76e
7
- data.tar.gz: ca63925ef15a674149e5566f7afcc47b93e9c3782f22efe3e19febd2e8054100e9e5d44bd4c9ab3a5940651c87ec072099c63c5dc841507507314305d66e208f
6
+ metadata.gz: 0d4e7520378fb4cad4ea952732c29c2146bd89dc8756d3fdd2f6ea8a3d67fc29970e8f51cccd367552037de3d588d8cff84116e260380d42df1fcb3f0fbcc5fe
7
+ data.tar.gz: 0cc3430fea638963bcd2ed641e2cd6a4690920f4283e8129fa12bc3c0b68d56cf0559893cb0b2052f269c0b043252f4a8ccf1f35aa9c04f3e1ed9c39cd7deb42
@@ -1,4 +1,4 @@
1
- future-release=v1.0.13
1
+ future-release=v1.0.14
2
2
  since-tag=v0.9
3
3
  exclude_tags_regex=v0\.[0-8]\..*
4
4
  exclude-labels=nochangelog,question
data/.gitignore CHANGED
@@ -3,3 +3,4 @@ coverage/
3
3
  gems/
4
4
  doc/
5
5
  LOCAL/
6
+ .DS_Store
@@ -1,5 +1,20 @@
1
1
  # Change Log
2
2
 
3
+ ## [v1.0.14](https://github.com/DragonBox/u3d/tree/v1.0.14) (2018-01-15)
4
+ [Full Changelog](https://github.com/DragonBox/u3d/compare/v1.0.13...v1.0.14)
5
+
6
+ **Implemented enhancements:**
7
+
8
+ - Support 2018.1.0b2 VisualStudio package installation [\#225](https://github.com/DragonBox/u3d/issues/225)
9
+ - u3d/install: improve messages [\#231](https://github.com/DragonBox/u3d/pull/231) ([niezbop](https://github.com/niezbop))
10
+ - u3d/install: add support for installing .msi packages on Windows [\#230](https://github.com/DragonBox/u3d/pull/230) ([niezbop](https://github.com/niezbop))
11
+
12
+ **Merged pull requests:**
13
+
14
+ - Appveyor support / Windows build automation [\#228](https://github.com/DragonBox/u3d/pull/228) ([lacostej](https://github.com/lacostej))
15
+ - u3d/install Unity 2018. Download works on Windows and Mac and Mac installs. Fixes \#225 [\#227](https://github.com/DragonBox/u3d/pull/227) ([lacostej](https://github.com/lacostej))
16
+ - u3d/install: allow to download from one platform while on another one [\#226](https://github.com/DragonBox/u3d/pull/226) ([lacostej](https://github.com/lacostej))
17
+
3
18
  ## [v1.0.13](https://github.com/DragonBox/u3d/tree/v1.0.13) (2018-01-09)
4
19
  [Full Changelog](https://github.com/DragonBox/u3d/compare/v1.0.12...v1.0.13)
5
20
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- u3d (1.0.13)
4
+ u3d (1.0.14)
5
5
  colored (>= 1.2, < 2.0.0)
6
6
  commander (>= 4.4.0, < 5.0.0)
7
7
  file-tail (>= 1.2.0)
@@ -0,0 +1,21 @@
1
+ # https://www.appveyor.com/docs/appveyor-yml/
2
+
3
+ version: "{build}"
4
+
5
+ init:
6
+ - git config --global core.autocrlf false
7
+
8
+ # cloning the repository happens here
9
+
10
+ install:
11
+ - set PATH=C:\Ruby24-x64\bin;%PATH%
12
+ - bundle install
13
+
14
+ environment:
15
+ LC_ALL: en_US.UTF-8
16
+ LANG: en_US.UTF-8
17
+
18
+ build: off
19
+
20
+ test_script:
21
+ - bundle exec rake
@@ -103,7 +103,8 @@ module U3d
103
103
  def install(args: [], options: {})
104
104
  version = specified_or_current_project_version(args[0])
105
105
 
106
- os = U3dCore::Helper.operating_system
106
+ UI.user_error!("You cannot use the --operating_system and the --install options together") if options[:install] && options[:operating_system]
107
+ os = valid_os_or_current(options[:operating_system])
107
108
 
108
109
  packages = packages_with_unity_first(os, options)
109
110
 
@@ -122,7 +122,8 @@ Fore more information about how the rules work, see https://github.com/DragonBox
122
122
  end
123
123
 
124
124
  command :install do |c|
125
- c.syntax = 'u3d install [<version>] [ [-p | --packages <package1>,<package2> ...] | [-a | --all] ] [--[no-]download] [ [--[no-]install] [-i | --installation_path <path>] ]'
125
+ oses = U3dCore::Helper.operating_systems
126
+ c.syntax = 'u3d install [<version>] [ [-p | --packages <package1>,<package2> ...] | [-o | --operating_system <OS>] [-a | --all] ] [--[no-]download] [ [--[no-]install] [-i | --installation_path <path>] ]'
126
127
  c.summary = "Download (and/or) install Unity3D editor packages."
127
128
  c.description = %(
128
129
  #{c.summary}
@@ -139,10 +140,12 @@ E.g. U3D_DOWNLOAD_PATH=/some/path/you/want u3d install ...
139
140
  c.option '--[no-]download', 'Perform or not downloading before installation. Downloads by default'
140
141
  c.option '--[no-]install', 'Perform or not installation after downloading. Installs by default'
141
142
  c.option '-p', '--packages PACKAGES', Array, 'Specifies which packages to download/install. Overriden by --all'
143
+ c.option '-o', '--operating_system STRING', String, "Downloads packages for specific OS [#{oses.join(', ')}]. Requires the --no-install option."
142
144
  c.option '-a', '--all', 'Download all available packages. Overrides -p'
143
145
  c.option '-i', '--installation_path PATH', String, 'Specifies where package(s) will be downloaded/installed. Conflicts with --no-install'
144
146
  c.option '-k', '--keychain', 'Gain privileges right through the keychain. [OSX only]'
145
147
  c.example 'Download and install Unity, its Documentation and the Android build support and install them for version 5.1.2f1', 'u3d install 5.1.2f1 -p Unity,Documentation,Android'
148
+ c.example 'Download but do not install all Unity version 2018.1.0b2 packages for platform Windows (while e.g. on Mac)', 'u3d install 2018.1.0b2 -o win -a --no-install'
146
149
  c.example "The 'version' argument can be a specific version number, such as 5.6.1f1, or an alias in [#{Commands.release_letter_mapping.keys.join(', ')}]. If not specified, u3d will download the unity version for the current project", 'u3d install latest'
147
150
  c.example "The admin password can be passed through the U3D_PASSWORD environment variable.", 'U3D_PASSWORD=mysecret u3d install a_version'
148
151
  c.example "On Mac, the admin password can be fetched from (and stored into) the keychain.", 'u3d install -k a_version'
@@ -66,6 +66,11 @@ module U3d
66
66
 
67
67
  class WindowsValidator < DownloadValidator
68
68
  def validate(package, file, definition)
69
+ # External packages have no md5 and a false size value
70
+ if definition[package]['size'] % 1000 && definition[package]['md5'].nil?
71
+ UI.verbose "File '#{definition[package]['title']}' seems external. Validation skipped"
72
+ return true
73
+ end
69
74
  rounded_size = (File.size(file).to_f / 1024).floor
70
75
  size_validation(expected: definition[package]['size'], actual: rounded_size) &&
71
76
  hash_validation(expected: definition[package]['md5'], actual: Utils.hashfile(file))
@@ -31,7 +31,7 @@ module U3d
31
31
  # Path to the directory for the package downloading
32
32
  DOWNLOAD_PATH = "#{ENV['HOME']}/Downloads".freeze
33
33
  # Regex to get the name of a package out of its file name
34
- UNITY_MODULE_FILE_REGEX = %r{\/([\w\-_\.\+]+\.(?:pkg|exe|zip|sh|deb))}
34
+ UNITY_MODULE_FILE_REGEX = %r{\/([\w\-_\.\+]+\.(?:pkg|exe|zip|sh|deb|msi))[^\/]*$}
35
35
 
36
36
  class << self
37
37
  def download_directory
@@ -82,6 +82,7 @@ module U3d
82
82
  private #-----------------------------------------------------------------
83
83
 
84
84
  def setup_os(os)
85
+ # downloader = Downloader::StandardPackageDownloader.new
85
86
  case os
86
87
  when :linux
87
88
  validator = LinuxValidator.new
@@ -99,8 +100,7 @@ module U3d
99
100
  end
100
101
 
101
102
  def get_package(downloader, validator, package, definition, files)
102
- path = downloader.destination_for(package, definition)
103
- url = downloader.url_for(package, definition)
103
+ path, url = downloader.destination_and_url_for(package, definition)
104
104
  if File.file?(path)
105
105
  UI.verbose "Installer file for #{package} seems to be present at #{path}"
106
106
  if validator.validate(package, path, definition)
@@ -137,46 +137,44 @@ module U3d
137
137
  end
138
138
  end
139
139
 
140
- class MacDownloader
140
+ class StandardPackageDownloader
141
+ # for backward compatibility
141
142
  def destination_for(package, definition)
142
- dir = File.join(Downloader.download_directory, definition.version)
143
- Utils.ensure_dir(dir)
144
- file_name = UNITY_MODULE_FILE_REGEX.match(definition[package]['url'])[1]
145
-
146
- File.expand_path(file_name, dir)
143
+ destination_and_url_for(package, definition)[0]
147
144
  end
148
145
 
149
- def url_for(package, definition)
150
- definition.url + definition[package]['url']
151
- end
152
- end
146
+ def destination_and_url_for(package, definition)
147
+ final_url = url_for(package, definition)
153
148
 
154
- class LinuxDownloader
155
- def destination_for(package, definition)
156
149
  dir = File.join(Downloader.download_directory, definition.version)
157
150
  Utils.ensure_dir(dir)
158
- file_name = UNITY_MODULE_FILE_REGEX.match(definition[package]['url'])[1]
151
+ file_name = UNITY_MODULE_FILE_REGEX.match(final_url)[1]
159
152
 
160
- File.expand_path(file_name, dir)
161
- end
153
+ destination = File.expand_path(file_name, dir)
162
154
 
163
- def url_for(_package, definition)
164
- definition.url
165
- end
166
- end
167
-
168
- class WindowsDownloader
169
- def destination_for(package, definition)
170
- dir = File.join(Downloader.download_directory, definition.version)
171
- Utils.ensure_dir(dir)
172
- file_name = UNITY_MODULE_FILE_REGEX.match(definition[package]['url'])[1]
173
-
174
- File.expand_path(file_name, dir)
155
+ [destination, final_url]
175
156
  end
176
157
 
177
158
  def url_for(package, definition)
178
- definition.url + definition[package]['url']
159
+ url = definition[package]['url']
160
+ if url
161
+ if url =~ /^http/
162
+ Utils.final_url(url)
163
+ else
164
+ definition.url + url
165
+ end
166
+ else
167
+ definition.url
168
+ end
179
169
  end
180
170
  end
171
+
172
+ # for backward compatibility
173
+ class MacDownloader < StandardPackageDownloader
174
+ end
175
+ class LinuxDownloader < StandardPackageDownloader
176
+ end
177
+ class WindowsDownloader < StandardPackageDownloader
178
+ end
181
179
  end
182
180
  end
@@ -63,7 +63,8 @@ module U3d
63
63
  def self.install_modules(files, version, installation_path: nil)
64
64
  installer = Installer.create
65
65
  files.each do |name, file, info|
66
- UI.verbose "Installing #{name}#{info['mandatory'] ? ' (mandatory package)' : ''}, with file #{file}"
66
+ UI.header "Installing #{info['title']} (#{name})"
67
+ UI.message 'Installing with ' + file
67
68
  installer.install(file, version, installation_path: installation_path, info: info)
68
69
  end
69
70
  end
@@ -294,7 +295,7 @@ module U3d
294
295
 
295
296
  def install(file_path, version, installation_path: nil, info: {})
296
297
  extension = File.extname(file_path)
297
- raise "Installation of #{extension} files is not supported on Windows" if extension != '.exe'
298
+ raise "Installation of #{extension} files is not supported on Windows" unless %w[.exe .msi].include? extension
298
299
  path = installation_path || File.join(DEFAULT_WINDOWS_INSTALL, format(UNITY_DIR, version: version))
299
300
  install_exe(
300
301
  file_path,
@@ -305,13 +306,17 @@ module U3d
305
306
 
306
307
  def install_exe(file_path, installation_path: nil, info: {})
307
308
  installation_path ||= DEFAULT_WINDOWS_INSTALL
308
- final_path = installation_path.tr('/', '\\')
309
+ final_path = Utils.windows_path(installation_path)
309
310
  Utils.ensure_dir(final_path)
310
311
  begin
311
312
  command = nil
312
313
  if info['cmd']
313
314
  command = info['cmd']
314
- command.sub!(/{FILENAME}/, file_path)
315
+ if /msiexec/ =~ command
316
+ command.sub!(/{FILENAME}/, '"' + Utils.windows_path(file_path) + '"')
317
+ else
318
+ command.sub!(/{FILENAME}/, file_path)
319
+ end
315
320
  command.sub!(/{INSTDIR}/, final_path)
316
321
  command.sub!(/{DOCDIR}/, final_path)
317
322
  command.sub!(/{MODULEDIR}/, final_path)
@@ -320,7 +325,7 @@ module U3d
320
325
  command ||= file_path.to_s
321
326
  U3dCore::CommandExecutor.execute(command: command, admin: true)
322
327
  rescue StandardError => e
323
- UI.error "Failed to install exe at #{file_path}: #{e}"
328
+ UI.error "Failed to install package at #{file_path}: #{e}"
324
329
  else
325
330
  UI.success "Successfully installed #{info['title']}"
326
331
  end
@@ -34,14 +34,27 @@ module U3d
34
34
  UNITY_VERSION_REGEX = /(\d+)(?:\.(\d+)(?:\.(\d+))?)?(?:(\w)(?:(\d+))?)?/
35
35
 
36
36
  class << self
37
+ def final_url(url, redirect_limit: 10)
38
+ follow_redirects(url, redirect_limit: redirect_limit, http_method: :head) do |request, _response|
39
+ request.uri.to_s
40
+ end
41
+ end
42
+
37
43
  def get_ssl(url, redirect_limit: 10)
44
+ follow_redirects(url, redirect_limit: redirect_limit) do |_request, response|
45
+ response.body
46
+ end
47
+ end
48
+
49
+ def follow_redirects(url, redirect_limit: 10, http_method: :get, &block)
38
50
  raise 'Too many redirections' if redirect_limit.zero?
39
51
  response = nil
40
52
  request = nil
41
53
  uri = URI(url)
42
54
  begin
43
- Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
44
- request = Net::HTTP::Get.new uri
55
+ use_ssl = /^https/.match(url)
56
+ Net::HTTP.start(uri.host, uri.port, use_ssl: use_ssl) do |http|
57
+ request = http_request_class http_method, uri
45
58
  response = http.request request
46
59
  end
47
60
  rescue OpenSSL::OpenSSLError => ssl_error
@@ -51,14 +64,20 @@ module U3d
51
64
 
52
65
  case response
53
66
  when Net::HTTPSuccess then
54
- response.body
67
+ yield(request, response)
55
68
  when Net::HTTPRedirection then
56
69
  UI.verbose "Redirected to #{response['location']}"
57
- get_ssl(response['location'], redirect_limit: redirect_limit - 1)
70
+ follow_redirects(response['location'], redirect_limit: redirect_limit - 1, http_method: http_method, &block)
58
71
  else raise "Request failed with status #{response.code}"
59
72
  end
60
73
  end
61
74
 
75
+ def http_request_class(method, uri)
76
+ return Net::HTTP::Get.new uri if method == :get
77
+ return Net::HTTP::Head.new uri if method == :head
78
+ raise "Unknown method #{method}"
79
+ end
80
+
62
81
  # size a hint of the expected size
63
82
  def download_file(path, url, size: nil)
64
83
  File.open(path, 'wb') do |f|
@@ -173,6 +192,10 @@ module U3d
173
192
  def pretty_filesize(filesize)
174
193
  Filesize.from(filesize.round.to_s + ' B').pretty
175
194
  end
195
+
196
+ def windows_path(path)
197
+ path.gsub(%r{\/(\d)}, '/\\\\\1').tr('/', '\\')
198
+ end
176
199
  end
177
200
  end
178
201
  # rubocop:enable ModuleLength
@@ -21,7 +21,7 @@
21
21
  ## --- END LICENSE BLOCK ---
22
22
 
23
23
  module U3d
24
- VERSION = '1.0.13'.freeze
24
+ VERSION = '1.0.14'.freeze
25
25
  DESCRIPTION = 'Provides numerous tools for installing, managing and running the Unity3D game engine from command line.'.freeze
26
26
  UNITY_VERSIONS_NOTE = "Unity3d uses the following version formatting: 0.0.0x0. The \'x\' can takes different values:\n"\
27
27
  "\t. 'f' are the main release candidates for Unity3d\n"\
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: u3d
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.13
4
+ version: 1.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jerome Lacoste
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2018-01-09 00:00:00.000000000 Z
12
+ date: 2018-01-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: colored
@@ -269,6 +269,7 @@ files:
269
269
  - LOG_RULES.md
270
270
  - README.md
271
271
  - Rakefile
272
+ - appveyor.yml
272
273
  - build.sh
273
274
  - config/log_rules.json
274
275
  - docs/assets/ci_jenkins_ansi.png